From e3504bd86bee15d16acd06c0eb05ec4f9492eb6c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 5 Nov 2024 00:13:51 +0000 Subject: [PATCH 01/11] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.7.1 → v0.7.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.7.1...v0.7.2) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7250fbd..9c5622f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,7 +10,7 @@ repos: - id: check-added-large-files - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.7.1 + rev: v0.7.2 hooks: - id: ruff args: [ "--fix", "--show-fixes" ] From 3011ffe5821f5d3ecfdd470a9c17df374004ab1a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 23:47:57 +0000 Subject: [PATCH 02/11] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.7.2 → v0.7.3](https://github.com/astral-sh/ruff-pre-commit/compare/v0.7.2...v0.7.3) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9c5622f..6632de8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,7 +10,7 @@ repos: - id: check-added-large-files - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.7.2 + rev: v0.7.3 hooks: - id: ruff args: [ "--fix", "--show-fixes" ] From f707cb2dd3401ec513abd8720cdaee3a62d1771d Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Thu, 14 Nov 2024 17:46:25 +0900 Subject: [PATCH 03/11] Update document --- doc/install.md | 9 +- doc/velph.md | 674 +++++++++++++++++- .../velph/cli/transport/plot/__init__.py | 9 + 3 files changed, 678 insertions(+), 14 deletions(-) diff --git a/doc/install.md b/doc/install.md index e0f11d2..1d2669b 100644 --- a/doc/install.md +++ b/doc/install.md @@ -15,6 +15,13 @@ A simplest installation using conda-forge packages: +``` +% conda create -n phelel -c conda-forge +% conda activate phelel +% conda install phelel +``` + +From source code of phelel, ``` % conda create -n phelel -c conda-forge % conda activate phelel @@ -24,4 +31,4 @@ A simplest installation using conda-forge packages: % pip install -e . ``` -PyPI and conda forge package will be made in the future. +The pypi package is also available. diff --git a/doc/velph.md b/doc/velph.md index 3656236..4965526 100644 --- a/doc/velph.md +++ b/doc/velph.md @@ -1,25 +1,24 @@ -## velph command +# velph command -### Configuration of shell completion +The `velph` command is a convenient tool to systematically perform +electron-phonon interaction calculations with VASP code and analyze the results. +Velph works in combination of command options. The `velph` command is installed +along with the installation of phelel. -Velph command is a convenient tool to systematically perform electron-phonon -interaction calculations with VASP code and analyze the results. Velph works in -combination of command options. The command `velph` is installed along with -the installation of phelel. +## Shell completion for `velph` command -Velph relies on click, and shell completion is provided for popular shell implementations, see -https://click.palletsprojects.com/en/stable/shell-completion/. +Velph relies on [click](https://click.palletsprojects.com), and shell completion +is provided for popular shell implementations, see +[shell-completion](https://click.palletsprojects.com/en/stable/shell-completion/). For example using bash (zsh) in conda environment, write the following line -(for bash) ``` -eval "$(_VELPH_COMPLETE=bash_source velph)" +eval "$(_VELPH_COMPLETE=bash_source velph)" # BASH ``` -(for zsh) ``` -eval "$(_VELPH_COMPLETE=zsh_source velph)" +eval "$(_VELPH_COMPLETE=zsh_source velph)" # ZSH ``` in `~/.bashrc` (`~/.zshrc`), or in a conda environment in @@ -43,6 +42,655 @@ selfenergy -- Choose selfenergy options. transport -- Choose transport options. ``` -### `velph-hints` +## `velph-hints` This command provides a quick reference of calculation steps. + +``` +% velph hints +``` + +## `velph init` + +`velph init` with command options will generate modified `velph.toml` from the +template. +``` +% velph init [OPTIONS] CELL_FILENAME PROJECT_FOLDER +``` + +`velph init --help` shows short documents of the options. Two arguments have to +be specified, POSCAR-format crystal structure and directory name that is created +where `velph.toml` is stored. The available options are explained below. Some +options can be specified in `[init.options]` section of the velph-toml template +file (see {ref}`velph-init-template`). + + +### `--template-toml` + +Using this option, `velph.toml` like file is read as the template instead of the +template hard coded in velph code. + +### `--tolerance` + +This is used for the symmetry check tolerance in Angstrom. Symmetry is searched +always even without `--symmetrize`. + +### `--symmetrize` + +By default (no-symmetrize), the input POSCAR-type structure is simply used as +the unit cell. With `--symmetrize`, input POSCAR-type structure is symmetrized +and standardized conventional unit cell and primitive cell ("unitcell" and +"primitive_cell", respectively) are written in `velph.toml`. + +### `--no-find-primitive` + +By this option, the input POSCAR-type structure is used as the primitive cell +even if it is not a primitive cell. + +### `--kspacing` and `--kspacing-dense` + +Sampling k-point meshes are calculated from these values in the similar way to +VASP `KSPACING` definition by overwriting the template. + +### `--max-num-atoms` + +Supercell shape is determined so that its number of atoms is equal or less than +this number respecting the crystallographic point group. + +### `--cell-for-relax` + +This chooses unit cell or primitive cell for structure optimization (`relax`). +The default is `unitcell`. Specify `primitive` to use primitive cell. + +### `--cell-for-nac` + +This chooses unit cell or primitive cell for NAC calculation (`nac`). The +default is `primitive`. Specify `primitive` to use primitive cell. + +### `--primitive-cell-choice` + +Primitive cell choice, "standardized" (default) or "reduced". + +### `--use-grg` + +Use generalized regular grid. + +### `--amplitude` + +Distance of displacements in Angstrom. + +### `--magmom` + +String corresponding to INCAR MAGMOM tag value for unit cell, e.g., "24*1" or "0 +0 1". This is similar to `MAGMOM` tag in phonopy, see +https://phonopy.github.io/phonopy/setting-tags.html#magmom. In velph, the +asterisk symbol (`*`) is supported. + +(velph-init-template)= +## velph-init template + +`velph-init` is the command to prepare `velph.toml`. Without specifying a +velph-toml-template, the default template is used. Custom template can be +specified as follows: + +``` +% velph init [OPTIONS] CELL_FILENAME PROJECT_FOLDER --template-toml velph-tmpl.toml +``` + +The `velph-tmpl.toml` (arbitrary file name) is almost like the `velph.toml` +file. It means that the `velph-tmpl.toml` may be created modifying +`velph.toml`. The sections that exist only in the `velph-tmpl.toml` but not in +`velph.toml` is `[init.options]`. This can be used as alternatives of command +options of `velph-init`, e.g., + +```toml +[init.options] +kspacing = 0.2 +kspacing_dense = 0.1 +max_num_atoms = 120 +``` + +These `[init.options]` keywords can be found along with the list of the command +options by + +``` +% velph init --help +``` + +## Settings in sections of `velph.toml` + +Note that the same can be applied to `velph-tmpl.toml`. + +### Scheduler settings + +The parameters used for generating the job submission script are specified as +strings in `[scheduler]`. If `[vasp.CALC_TYPE.scheduler]`, where, `CALC_TYPE` +can be `relax`, `nac`, `transport`, `phono3py`, `phono3py.phonon`, etc, is +specified, `[scheduler]` settings are overwritten by the settings for +`[vasp.CALC_TYPE]`. The content in this section operates through [Python string +formatting](https://docs.python.org/3/library/stdtypes.html#str.format), using +replacement fields named after keyword arguments. Each parameter line in the +`[scheduler]` section is treated as a keyword argument, which is then inserted +into the string format. + +In the `[scheduler]` section, the parameters `scheduler_name` and +`scheduler_template` have special roles: + +- `scheduler_name`: Specifies the template type, with options `slurm`, `sge`, or + `custom`. For `slurm` and `sge`, the template string (i.e., + `scheduler_template`) is + [hard-coded](https://github.com/phonopy/phelel/blob/develop/src/phelel/velph/utils/scheduler.py). + If `custom` is selected, the string provided by `scheduler_template` is used, + into which the parameters are inserted. +- `scheduler_template`: The string template where parameters defined in this + section are inserted. + +An example is shown below. + +```toml +[scheduler] +scheduler_name = "sge" +job_name = "PbTe" +mpirun_command = "mpirun" +vasp_binary = "/usr/local/cluster-1/bin/vasp_std" +pe = "vienna 32" +prepend_text = ''' +source /opt/intel/oneapi/setvars.sh --config="/home/togo/.oneapi-config" +''' + +... +[vasp.phelel.scheduler] +pe = "paris 24" + +... +[vasp.phono3py.phonon.scheduler] +scheduler_template = '''#!/bin/bash +#QSUB2 core 192 +#QSUB2 mpi 192 +#QSUB2 smp 1 +#QSUB2 wtime 48:00:00 +#PBS -N {job_name} +cd $PBS_O_WORKDIR + +{prepend_text} +{mpirun_command} {vasp_binary} | tee vasp_output +{append_text} +''' +job_name = "PbTe" +mpirun_command = "mpijob" +vasp_binary = "/usr/local/cluster-2/bin/vasp_std" +prepend_text = ''' +. /etc/profile.d/modules.sh +module load inteloneapi22u3 +''' +append_text = "" +``` + + +## Example (NiTiSn) + +`POSCAR-unitcell`, `POTCAR`, and `velph-tmpl.toml` are located in the current directory. + +Initial `POSCAR-unitcell`, +``` +Ti4Sn4Ni4 +1.0 +5.906882041566931 0.000000000000000 0.000000000000000 +0.000000000000000 5.906882041566931 0.000000000000000 +0.000000000000000 0.000000000000000 5.906882041566931 +Ti Sn Ni +4 4 4 +Direct +0.000000000000000 0.000000000000000 0.000000000000000 +0.000000000000000 0.500000000000000 0.500000000000000 +0.500000000000000 0.000000000000000 0.500000000000000 +0.500000000000000 0.500000000000000 0.000000000000000 +0.500000000000000 0.500000000000000 0.500000000000000 +0.500000000000000 0.000000000000000 0.000000000000000 +0.000000000000000 0.500000000000000 0.000000000000000 +0.000000000000000 0.000000000000000 0.500000000000000 +0.250000000000000 0.250000000000000 0.250000000000000 +0.250000000000000 0.750000000000000 0.750000000000000 +0.750000000000000 0.250000000000000 0.750000000000000 +0.750000000000000 0.750000000000000 0.250000000000000 +``` + +`velph-tmpl.toml`, +```toml +[init.options] +kspacing = 0.1 +kspacing_dense = 0.2 +max_num_atoms = 100 + +[vasp.incar] +encut = 520 +ncore = 4 + +[vasp.phelel.incar] +kpar = 2 +[vasp.phelel.scheduler] +pe = "mpi* 48" + +[vasp.transport.scheduler] +pe = "mpi* 144" + +[scheduler] +scheduler_name = "sge" +job_name = "TiNiSn" +mpirun_command = "mpirun" +vasp_binary = "/home/togo/phelel/vasp-tmp1-atztogo/bin/vasp_std" +pe = "vienna 32" +prepend_text = ''' +source /opt/intel/oneapi/setvars.sh intel64 --config="/home/togo/.oneapi-config" +''' +append_text = "" +``` + +`POTCAR` choice, +``` + PAW_PBE Ti_sv 26Sep2005 + PAW_PBE Sn_d 06Sep2000 + PAW_PBE Ni 02Aug2007 +``` + +``` +% velph init POSCAR_Ti4Sn4Ni4 relax --template-toml velph-tmpl.toml +Crystal structure file: "POSCAR_Ti4Sn4Ni4". +Velph template file: "velph-tmpl.toml". +Read crystal structure file "POSCAR_Ti4Sn4Ni4". +Read velph template file "velph-tmpl.toml". +Following options were found in "velph-tmpl.toml": + kspacing = "0.1" + kspacing_dense = "0.2" + max_num_atoms = "100" +The command options were prefered to [init.options] in "velph-tmpl.toml". +Found a primitive cell whose transformation matrix is + [ 0.000 0.500 0.500] + [ 0.500 0.000 0.500] + [ 0.500 0.500 0.000] +Supercell is generated with respect to the cell below. +-------------------------------------------------------------------------------- +lattice: +- [ 5.906882041566931, 0.000000000000000, 0.000000000000000 ] # a +- [ 0.000000000000000, 5.906882041566931, 0.000000000000000 ] # b +- [ 0.000000000000000, 0.000000000000000, 5.906882041566931 ] # c +points: +- symbol: Ti # 1 + coordinates: [ 0.000000000000000, 0.000000000000000, 0.000000000000000 ] + mass: 47.867000 +- symbol: Ti # 2 + coordinates: [ 0.000000000000000, 0.500000000000000, 0.500000000000000 ] + mass: 47.867000 +- symbol: Ti # 3 + coordinates: [ 0.500000000000000, 0.000000000000000, 0.500000000000000 ] + mass: 47.867000 +- symbol: Ti # 4 + coordinates: [ 0.500000000000000, 0.500000000000000, 0.000000000000000 ] + mass: 47.867000 +- symbol: Sn # 5 + coordinates: [ 0.500000000000000, 0.500000000000000, 0.500000000000000 ] + mass: 118.710000 +- symbol: Sn # 6 + coordinates: [ 0.500000000000000, 0.000000000000000, 0.000000000000000 ] + mass: 118.710000 +- symbol: Sn # 7 + coordinates: [ 0.000000000000000, 0.500000000000000, 0.000000000000000 ] + mass: 118.710000 +- symbol: Sn # 8 + coordinates: [ 0.000000000000000, 0.000000000000000, 0.500000000000000 ] + mass: 118.710000 +- symbol: Ni # 9 + coordinates: [ 0.250000000000000, 0.250000000000000, 0.250000000000000 ] + mass: 58.693400 +- symbol: Ni # 10 + coordinates: [ 0.250000000000000, 0.750000000000000, 0.750000000000000 ] + mass: 58.693400 +- symbol: Ni # 11 + coordinates: [ 0.750000000000000, 0.250000000000000, 0.750000000000000 ] + mass: 58.693400 +- symbol: Ni # 12 + coordinates: [ 0.750000000000000, 0.750000000000000, 0.250000000000000 ] + mass: 58.693400 +-------------------------------------------------------------------------------- +[vasp.incar] (basic INCAR settings) + ismear = 0 + sigma = 0.01 + ediff = 1e-08 + encut = 520 + prec = accurate + lreal = False + lwave = False + lcharg = False + ncore = 4 +[phelel] + supercell_dimension: [2 2 2] +[vasp.*.kpoints.mesh] (*kspacing=0.1) + selfenergy: [18 18 18]* + el_bands: [18 18 18]* + phelel: [5 5 5]* + relax: [11 11 11]* + nac: [18 18 18]* +[vasp.*.kpoints_dense.mesh] (*kspacing_dense=0.2) + selfenergy: [9 9 9]* + el_bands: [9 9 9]* +Created new folder "relax". +Initial settings were written to "relax/velph.toml". +Found "POTCAR". + PAW_PBE Ti_sv 26Sep2005 + PAW_PBE Sn_d 06Sep2000 + PAW_PBE Ni 02Aug2007 + Max ENMAX in "POTCAR" is 274.61. +"POTCAR" was copied to "relax/POTCAR". +``` + + +A directory `relax` is created and `velph.toml` is stored in it. + +`relax/velph.toml`, +```toml +[phelel] +version = "0.6.0" +supercell_dimension = [2, 2, 2] +amplitude = 0.03 +diagonal = true +plusminus = true +fft_mesh = [32, 32, 32] + +# ... + +[vasp.relax] +cell = "unitcell" +[vasp.relax.incar] +ediffg = -1e-06 +ibrion = 2 +isif = 3 +nsw = 10 +ismear = 0 +sigma = 0.01 +ediff = 1e-08 +encut = 520 +prec = "accurate" +lreal = false +lwave = false +lcharg = false +ncore = 4 +[vasp.relax.kpoints] +mesh = [11, 11, 11] + +# ... + +[scheduler] +scheduler_name = "sge" +job_name = "TiNiSn" +mpirun_command = "mpirun" +vasp_binary = "/home/togo/phelel/vasp-tmp1-atztogo/bin/vasp_std" +pe = "vienna 32" +prepend_text = "source /opt/intel/oneapi/setvars.sh intel64 --config=\"/home/togo/.oneapi-config\"\n" +append_text = "" + +[symmetry] +spacegroup_type = "F-43m" +tolerance = 1e-05 +primitive_matrix = [ + [ 0.000000000000000, 0.500000000000000, 0.500000000000000 ], + [ 0.500000000000000, 0.000000000000000, 0.500000000000000 ], + [ 0.500000000000000, 0.500000000000000, 0.000000000000000 ], +] + +[unitcell] +lattice = [ + [ 5.906882041566931, 0.000000000000000, 0.000000000000000 ], # a + [ 0.000000000000000, 5.906882041566931, 0.000000000000000 ], # b + [ 0.000000000000000, 0.000000000000000, 5.906882041566931 ], # c +] +[[unitcell.points]] # 1 +symbol = "Ti" +coordinates = [ 0.000000000000000, 0.000000000000000, 0.000000000000000 ] +[[unitcell.points]] # 2 +symbol = "Ti" +coordinates = [ 0.000000000000000, 0.500000000000000, 0.500000000000000 ] +[[unitcell.points]] # 3 +symbol = "Ti" +coordinates = [ 0.500000000000000, 0.000000000000000, 0.500000000000000 ] +[[unitcell.points]] # 4 +symbol = "Ti" +coordinates = [ 0.500000000000000, 0.500000000000000, 0.000000000000000 ] +[[unitcell.points]] # 5 +symbol = "Sn" +coordinates = [ 0.500000000000000, 0.500000000000000, 0.500000000000000 ] +[[unitcell.points]] # 6 +symbol = "Sn" +coordinates = [ 0.500000000000000, 0.000000000000000, 0.000000000000000 ] +[[unitcell.points]] # 7 +symbol = "Sn" +coordinates = [ 0.000000000000000, 0.500000000000000, 0.000000000000000 ] +[[unitcell.points]] # 8 +symbol = "Sn" +coordinates = [ 0.000000000000000, 0.000000000000000, 0.500000000000000 ] +[[unitcell.points]] # 9 +symbol = "Ni" +coordinates = [ 0.250000000000000, 0.250000000000000, 0.250000000000000 ] +[[unitcell.points]] # 10 +symbol = "Ni" +coordinates = [ 0.250000000000000, 0.750000000000000, 0.750000000000000 ] +[[unitcell.points]] # 11 +symbol = "Ni" +coordinates = [ 0.750000000000000, 0.250000000000000, 0.750000000000000 ] +[[unitcell.points]] # 12 +symbol = "Ni" +coordinates = [ 0.750000000000000, 0.750000000000000, 0.250000000000000 ] +[primitive_cell] +lattice = [ + [ 0.000000000000000, 2.953441020783465, 2.953441020783465 ], # a + [ 2.953441020783465, 0.000000000000000, 2.953441020783465 ], # b + [ 2.953441020783465, 2.953441020783465, 0.000000000000000 ], # c +] +[[primitive_cell.points]] # 1 +symbol = "Ti" +coordinates = [ 0.000000000000000, 0.000000000000000, 0.000000000000000 ] +[[primitive_cell.points]] # 2 +symbol = "Sn" +coordinates = [ 0.500000000000000, 0.500000000000000, 0.500000000000000 ] +[[primitive_cell.points]] # 3 +symbol = "Ni" +coordinates = [ 0.250000000000000, 0.250000000000000, 0.250000000000000 ] +``` + +`fft_mesh` is calculated from `encut` value in the `[vasp.selfenergy.incar]` section. + +Change directory to `relax`. +``` +% velph relax generate +% cd relax/iter1 +% qsub _job.sh +``` +Structure optimization is done until stress becomes less than 0.1kB (0.01GPa). +Go back to the top directory and start supercell calculation. + +``` +% velph init --template-toml velph-tmpl.toml `ls relax/relax/iter*/CONTCAR|tail -n 1` calc +% velph init --template-toml velph-tmpl.toml `ls relax/relax/iter*/CONTCAR|tail -n 1` calc +Crystal structure file: "relax/relax/iter2/CONTCAR". +Velph template file: "velph-tmpl.toml". +Read crystal structure file "relax/relax/iter2/CONTCAR". +Read velph template file "velph-tmpl.toml". +Following options were found in "velph-tmpl.toml": + kspacing = "0.1" + kspacing_dense = "0.2" + max_num_atoms = "100" +The command options were prefered to [init.options] in "velph-tmpl.toml". +Found a primitive cell whose transformation matrix is + [ 0.000 0.500 0.500] + [ 0.500 0.000 0.500] + [ 0.500 0.500 0.000] +Supercell is generated with respect to the cell below. +-------------------------------------------------------------------------------- +lattice: +- [ 5.949975748250650, 0.000000000000000, 0.000000000000000 ] # a +- [ 0.000000000000000, 5.949975748250650, -0.000000000000000 ] # b +- [ 0.000000000000000, 0.000000000000000, 5.949975748250650 ] # c +points: +- symbol: Ti # 1 + coordinates: [ 0.000000000000000, 0.000000000000000, 0.000000000000000 ] + mass: 47.867000 +- symbol: Ti # 2 + coordinates: [ 0.000000000000000, 0.500000000000000, 0.500000000000000 ] + mass: 47.867000 +- symbol: Ti # 3 + coordinates: [ 0.500000000000000, 0.000000000000000, 0.500000000000000 ] + mass: 47.867000 +- symbol: Ti # 4 + coordinates: [ 0.500000000000000, 0.500000000000000, 0.000000000000000 ] + mass: 47.867000 +- symbol: Sn # 5 + coordinates: [ 0.500000000000000, 0.500000000000000, 0.500000000000000 ] + mass: 118.710000 +- symbol: Sn # 6 + coordinates: [ 0.500000000000000, 0.000000000000000, 0.000000000000000 ] + mass: 118.710000 +- symbol: Sn # 7 + coordinates: [ 0.000000000000000, 0.500000000000000, 0.000000000000000 ] + mass: 118.710000 +- symbol: Sn # 8 + coordinates: [ 0.000000000000000, 0.000000000000000, 0.500000000000000 ] + mass: 118.710000 +- symbol: Ni # 9 + coordinates: [ 0.250000000000000, 0.250000000000000, 0.250000000000000 ] + mass: 58.693400 +- symbol: Ni # 10 + coordinates: [ 0.250000000000000, 0.750000000000000, 0.750000000000000 ] + mass: 58.693400 +- symbol: Ni # 11 + coordinates: [ 0.750000000000000, 0.250000000000000, 0.750000000000000 ] + mass: 58.693400 +- symbol: Ni # 12 + coordinates: [ 0.750000000000000, 0.750000000000000, 0.250000000000000 ] + mass: 58.693400 +-------------------------------------------------------------------------------- +[vasp.incar] (basic INCAR settings) + ismear = 0 + sigma = 0.01 + ediff = 1e-08 + encut = 520 + prec = accurate + lreal = False + lwave = False + lcharg = False + ncore = 4 +[phelel] + supercell_dimension: [2 2 2] +[vasp.*.kpoints.mesh] (*kspacing=0.1) + selfenergy: [18 18 18]* + el_bands: [18 18 18]* + phelel: [5 5 5]* + relax: [11 11 11]* + nac: [18 18 18]* +[vasp.*.kpoints_dense.mesh] (*kspacing_dense=0.2) + selfenergy: [9 9 9]* + el_bands: [9 9 9]* +Created new folder "calc". +Initial settings were written to "calc/velph.toml". +Found "POTCAR". + PAW_PBE Ti_sv 26Sep2005 + PAW_PBE Sn_d 06Sep2000 + PAW_PBE Ni 02Aug2007 + Max ENMAX in "POTCAR" is 274.61. +"POTCAR" was copied to "calc/POTCAR". +``` + +Change directory to `calc`. +``` +% cd calc +``` + +`velph.toml`, +``` +[phelel] +version = "0.6.0" +supercell_dimension = [2, 2, 2] +amplitude = 0.03 +diagonal = true +plusminus = true +fft_mesh = [32, 32, 32] + +[vasp.phelel.incar] +lwap = true +isym = 0 +kpar = 2 +ismear = 0 +sigma = 0.01 +ediff = 1e-08 +encut = 520 +prec = "accurate" +lreal = false +lwave = false +lcharg = false +ncore = 4 +[vasp.phelel.kpoints] +mesh = [5, 5, 5] +[vasp.phelel.scheduler] +pe = "mpi* 48" + +# ... + +[vasp.nac] +cell = "primitive" +[vasp.nac.incar] +lepsilon = true +ismear = 0 +sigma = 0.01 +ediff = 1e-08 +encut = 520 +prec = "accurate" +lreal = false +lwave = false +lcharg = false +[vasp.nac.kpoints] +mesh = [18, 18, 18] + +# ... +``` + +NAC and supercell calculations, +``` +% velph nac generate +% cd nac; qsub _job.sh; cd .. +% velph phelel init +Found "nac" directory. Read NAC params. +"phelel/phelel_disp.yaml" was generated by phelel. +VASP input files will be generated by "velph phelel generate". +% velph supercell generate +VASP input files were generated in "supercell/disp-000". +VASP input files were generated in "supercell/disp-001". +VASP input files were generated in "supercell/disp-002". +VASP input files were generated in "supercell/disp-003". +VASP input files were generated in "supercell/disp-004". +VASP input files were generated in "supercell/disp-005". +VASP input files were generated in "supercell/disp-006". +% for i in {000..006};do cd phelel/disp-$i; qsub _job.sh; cd ../..;done +``` + +Using the VASP results of the supercell calculations, derivatives of properties +are computed using the phelel code. The results are stored in a newly created +file `phelel/phelel_params.hdf5`. This process creates only +`phelel/phelel_params.hdf5` and is invoked by the following velph command: +``` +% velph phelel differentiate +Running finufft (eps=1.000e-06)... +Running finufft (eps=1.000e-06)... +Running finufft (eps=1.000e-06)... +"phelel/phelel_params.hdf5" has been made. +``` + +NAC parameters in `phelel/phelel_params.hdf5` comes from +`phelel/phelel_disp.yaml`, i.e., + +1. NAC parameters are stored in `phelel/phelel_disp.yaml` when + `phelel/phelel_disp.yaml` is created by `velph phelel init`. +2. NAC data in `phelel/phelel_disp.yaml` are transfered to + `phelel/phelel_params.hdf5` by `velph phelel differentiate`. + +Therefore, `nac` calculation has to exist in the initial step `velph phelel +init`. If the `nac` calculation is performed after the supercell calculation, +`velph phelel init` and `velph phelel differentiate` have to be re-executed to +store the NAC parameters in `phelel/phelel_params.hdf5`. diff --git a/src/phelel/velph/cli/transport/plot/__init__.py b/src/phelel/velph/cli/transport/plot/__init__.py index 9720018..56a4e4e 100644 --- a/src/phelel/velph/cli/transport/plot/__init__.py +++ b/src/phelel/velph/cli/transport/plot/__init__.py @@ -114,6 +114,13 @@ def cmd_plot_transport(vaspout_filename: str, save_plot: bool): default=None, help=("Index of temperature. (tid: int, default=None)"), ) +@click.option( + "--nid", + nargs=1, + type=int, + default=None, + help=("Index of N. (nid: int, default=None)"), +) @click.help_option("-h", "--help") def cmd_plot_eigenvalues( vaspout_filename: str, @@ -121,6 +128,7 @@ def cmd_plot_eigenvalues( cutoff_occupancy: float, mu: Optional[float], tid: Optional[int], + nid: Optional[int], ): """Show eigenvalues in transports.""" args = _get_f_h5py_and_plot_filename( @@ -130,6 +138,7 @@ def cmd_plot_eigenvalues( plot_eigenvalues( args[0], tid=tid, + nid=nid, temperature=temperature, cutoff_occupancy=cutoff_occupancy, mu=mu, From d5456eeee9aa8b1249b09dec61c24e1b7d47f5d7 Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Thu, 14 Nov 2024 17:56:57 +0900 Subject: [PATCH 04/11] Update document --- doc/velph.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/doc/velph.md b/doc/velph.md index 4965526..a36ec69 100644 --- a/doc/velph.md +++ b/doc/velph.md @@ -5,7 +5,7 @@ electron-phonon interaction calculations with VASP code and analyze the results. Velph works in combination of command options. The `velph` command is installed along with the installation of phelel. -## Shell completion for `velph` command +## Shell completion Velph relies on [click](https://click.palletsprojects.com), and shell completion is provided for popular shell implementations, see @@ -161,11 +161,16 @@ options by Note that the same can be applied to `velph-tmpl.toml`. +### Default INCAR settings + +The default INCAR settins are written in `[vasp.incar]`. These settings are +overwritten by `[vasp.CALC_TYPE.incar]` (`CALC_TYPE` can be `phelel`, `relax`, +`nac`, `transport`, `phono3py`, `phono3py.phonon`, etc). + ### Scheduler settings The parameters used for generating the job submission script are specified as -strings in `[scheduler]`. If `[vasp.CALC_TYPE.scheduler]`, where, `CALC_TYPE` -can be `relax`, `nac`, `transport`, `phono3py`, `phono3py.phonon`, etc, is +strings in `[scheduler]`. If `[vasp.CALC_TYPE.scheduler]` is specified, `[scheduler]` settings are overwritten by the settings for `[vasp.CALC_TYPE]`. The content in this section operates through [Python string formatting](https://docs.python.org/3/library/stdtypes.html#str.format), using @@ -278,7 +283,7 @@ pe = "mpi* 144" scheduler_name = "sge" job_name = "TiNiSn" mpirun_command = "mpirun" -vasp_binary = "/home/togo/phelel/vasp-tmp1-atztogo/bin/vasp_std" +vasp_binary = "/usr/local/vasp/bin/vasp_std" pe = "vienna 32" prepend_text = ''' source /opt/intel/oneapi/setvars.sh intel64 --config="/home/togo/.oneapi-config" @@ -423,7 +428,7 @@ mesh = [11, 11, 11] scheduler_name = "sge" job_name = "TiNiSn" mpirun_command = "mpirun" -vasp_binary = "/home/togo/phelel/vasp-tmp1-atztogo/bin/vasp_std" +vasp_binary = "/usr/local/vasp/bin/vasp_std" pe = "vienna 32" prepend_text = "source /opt/intel/oneapi/setvars.sh intel64 --config=\"/home/togo/.oneapi-config\"\n" append_text = "" @@ -509,7 +514,6 @@ Go back to the top directory and start supercell calculation. ``` % velph init --template-toml velph-tmpl.toml `ls relax/relax/iter*/CONTCAR|tail -n 1` calc -% velph init --template-toml velph-tmpl.toml `ls relax/relax/iter*/CONTCAR|tail -n 1` calc Crystal structure file: "relax/relax/iter2/CONTCAR". Velph template file: "velph-tmpl.toml". Read crystal structure file "relax/relax/iter2/CONTCAR". From ea053de77760edc8a62235afcd35095040de1659 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 18 Nov 2024 23:51:56 +0000 Subject: [PATCH 05/11] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.7.3 → v0.7.4](https://github.com/astral-sh/ruff-pre-commit/compare/v0.7.3...v0.7.4) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6632de8..7caf494 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,7 +10,7 @@ repos: - id: check-added-large-files - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.7.3 + rev: v0.7.4 hooks: - id: ruff args: [ "--fix", "--show-fixes" ] From e96e30acc6c4e553babf0e53ced079d9fd462dc8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 25 Nov 2024 23:44:34 +0000 Subject: [PATCH 06/11] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.7.4 → v0.8.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.7.4...v0.8.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7caf494..dd1ffe4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,7 +10,7 @@ repos: - id: check-added-large-files - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.7.4 + rev: v0.8.0 hooks: - id: ruff args: [ "--fix", "--show-fixes" ] From a432b445f3fc153a91b5043feb711e1c832c736d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 3 Dec 2024 00:25:09 +0000 Subject: [PATCH 07/11] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.8.0 → v0.8.1](https://github.com/astral-sh/ruff-pre-commit/compare/v0.8.0...v0.8.1) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index dd1ffe4..7bd1141 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,7 +10,7 @@ repos: - id: check-added-large-files - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.8.0 + rev: v0.8.1 hooks: - id: ruff args: [ "--fix", "--show-fixes" ] From 3159f2eefda575af491ebe34077bc144a17f1e0e Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Thu, 5 Dec 2024 19:59:34 +0900 Subject: [PATCH 08/11] Improve velph-phono3py --- src/phelel/cui/create_supercells.py | 16 +++--- src/phelel/velph/cli/init/__init__.py | 21 ++++---- src/phelel/velph/cli/init/init.py | 26 +++++----- src/phelel/velph/cli/phono3py/__init__.py | 23 ++++++++- src/phelel/velph/cli/phono3py/init.py | 24 +++++---- src/phelel/velph/cli/utils.py | 4 +- .../cli/phono3py/init/test_phono3py_init.py | 49 ++++++++++--------- 7 files changed, 96 insertions(+), 67 deletions(-) diff --git a/src/phelel/cui/create_supercells.py b/src/phelel/cui/create_supercells.py index 85c84e6..919bc81 100644 --- a/src/phelel/cui/create_supercells.py +++ b/src/phelel/cui/create_supercells.py @@ -12,15 +12,17 @@ from phonopy.interface.calculator import write_supercells_with_displacements from phelel.api_phelel import Phelel +from phelel.cui.settings import PhelelSettings +from phelel.interface.phelel_yaml import PhelelYaml def create_phelel_supercells( - cell_info, - settings, - symprec, - interface_mode="vasp", - load_phelel_yaml=False, - log_level=1, + cell_info: dict, + settings: PhelelSettings, + symprec: float, + interface_mode: Optional[str] = "vasp", + load_phelel_yaml: bool = False, + log_level: int = 1, ): """Create displacements and supercells. @@ -30,7 +32,7 @@ def create_phelel_supercells( """ optional_structure_info = cell_info["optional_structure_info"] unitcell_filename = cell_info["optional_structure_info"][0] - phe_yml = cell_info["phonopy_yaml"] + phe_yml: Optional[PhelelYaml] = cell_info["phonopy_yaml"] phelel = Phelel( cell_info["unitcell"], diff --git a/src/phelel/velph/cli/init/__init__.py b/src/phelel/velph/cli/init/__init__.py index c602d38..45c1a9f 100644 --- a/src/phelel/velph/cli/init/__init__.py +++ b/src/phelel/velph/cli/init/__init__.py @@ -54,12 +54,12 @@ ), ) @click.option( - "--diagonal/--parallel-to-axes", + "--diagonal", "diagonal", type=bool, default=None, help=( - "Generate displacements only along axes or not." + "Generate displacements in diagonal directions or only along axes." f"(diagonal: bool, default={VelphInitParams.diagonal})" ), ) @@ -146,16 +146,17 @@ ), ) @click.option( - "--phonon-max-num-atoms", - "phonon_max_num_atoms", + "--phono3py-max-num-atoms", + "phono3py_max_num_atoms", nargs=1, default=None, type=int, help=( - "Determine phonon supercell dimension so that number of atoms in supercell " - "for phonon is less than this number if different one from electron-phonon " - "(phelel) or phonon-phonon (phono3py) is expected. " - f"(phonon_max_num_atoms: int, default={VelphInitParams.phonon_max_num_atoms})" + "Determine phono3py supercell dimension so that number of atoms in supercell " + "for phono3py is less than this number if different dimension from " + "that of electron-phonon (phelel) is expected. " + "(phono3py_max_num_atoms: int, " + f"default={VelphInitParams.phono3py_max_num_atoms})" ), ) @click.option( @@ -245,7 +246,7 @@ def cmd_init( max_num_atoms: Optional[int], phelel_dir_name: str, phelel_nosym: Optional[bool], - phonon_max_num_atoms: Optional[int], + phono3py_max_num_atoms: Optional[int], primitive_cell_choice: Optional[str], project_folder: str, symmetrize_cell: Optional[bool], @@ -286,7 +287,7 @@ def cmd_init( "magmom": magmom, "max_num_atoms": max_num_atoms, "phelel_nosym": phelel_nosym, - "phonon_max_num_atoms": phonon_max_num_atoms, + "phono3py_max_num_atoms": phono3py_max_num_atoms, "primitive_cell_choice": primitive_cell_choice, "symmetrize_cell": symmetrize_cell, "tolerance": tolerance, diff --git a/src/phelel/velph/cli/init/init.py b/src/phelel/velph/cli/init/init.py index 437a1e4..51bad8c 100644 --- a/src/phelel/velph/cli/init/init.py +++ b/src/phelel/velph/cli/init/init.py @@ -629,9 +629,9 @@ def _get_toml_lines( ) return None - phonon_supercell_dimension = _get_supercell_dimension( - velph_dict.get("phonopy", {}), - vip.phonon_max_num_atoms, + phono3py_supercell_dimension = _get_supercell_dimension( + velph_dict.get("phono3py", {}), + vip.phono3py_max_num_atoms, sym_dataset, vip.find_primitive, ) @@ -639,9 +639,9 @@ def _get_toml_lines( click.echo("[phelel]") _show_supercell_dimension(supercell_dimension) - if phonon_supercell_dimension is not None: - click.echo("[phonopy]") - _show_supercell_dimension(phonon_supercell_dimension) + if phono3py_supercell_dimension is not None: + click.echo("[phono3py]") + _show_supercell_dimension(phono3py_supercell_dimension) ( kpoints_dict, @@ -657,7 +657,7 @@ def _get_toml_lines( primitive, sym_dataset, supercell_dimension, - phonon_supercell_dimension, + phono3py_supercell_dimension, cell_choices["nac"], cell_choices["relax"], phelel_dir_name=phelel_dir_name, @@ -696,12 +696,12 @@ def _get_toml_lines( vip.phelel_nosym, ) - # [phonopy] - if phonon_supercell_dimension is not None: - lines += ["[phonopy]"] - lines += _get_supercell_dimension_lines(phonon_supercell_dimension) + # [phono3py] + if phono3py_supercell_dimension is not None: + lines += ["[phono3py]"] + lines += _get_supercell_dimension_lines(phono3py_supercell_dimension) lines += _get_displacement_settings_lines( - velph_dict, "phonopy", vip.amplitude, vip.diagonal, vip.plusminus + velph_dict, "phono3py", vip.amplitude, vip.diagonal, vip.plusminus ) lines.append("") @@ -1333,7 +1333,7 @@ def _get_supercell_dimension_lines( def _get_displacement_settings_lines( velph_dict: dict, - calc_type: Literal["phelel", "phonopy"], + calc_type: Literal["phelel", "phono3py"], amplitude: Optional[float], diagonal: Optional[bool], plusminus: Optional[bool], diff --git a/src/phelel/velph/cli/phono3py/__init__.py b/src/phelel/velph/cli/phono3py/__init__.py index 2c5285c..446bfeb 100644 --- a/src/phelel/velph/cli/phono3py/__init__.py +++ b/src/phelel/velph/cli/phono3py/__init__.py @@ -38,13 +38,32 @@ def cmd_phono3py(): type=int, help="Number of snapshots of supercells with random directional displacement.", ) +@click.option( + "--rd-fc2", + "random_displacements_fc2", + nargs=1, + default=None, + type=int, + help=( + "Number of snapshots of phonon supercells " + "with random directional displacement." + ), +) @click.help_option("-h", "--help") -def cmd_init(toml_filename: str, random_displacements: Optional[int]): +def cmd_init( + toml_filename: str, + random_displacements: Optional[int], + random_displacements_fc2: Optional[int], +): """Generate displacements and write phelel_disp.yaml.""" with open(toml_filename, "rb") as f: toml_dict = tomli.load(f) - ph3py = run_init(toml_dict, number_of_snapshots=random_displacements) + ph3py = run_init( + toml_dict, + number_of_snapshots=random_displacements, + number_of_snapshots_fc2=random_displacements_fc2, + ) phono3py_yaml_filename = pathlib.Path("phono3py/phono3py_disp.yaml") phono3py_yaml_filename.parent.mkdir(parents=True, exist_ok=True) diff --git a/src/phelel/velph/cli/phono3py/init.py b/src/phelel/velph/cli/phono3py/init.py index 5a91393..41be45c 100644 --- a/src/phelel/velph/cli/phono3py/init.py +++ b/src/phelel/velph/cli/phono3py/init.py @@ -18,6 +18,7 @@ def run_init( toml_dict: dict, current_directory: pathlib.Path = pathlib.Path(""), number_of_snapshots: Optional[int] = None, + number_of_snapshots_fc2: Optional[int] = None, ) -> Optional[Phono3py]: """Generate displacements and write phono3py_disp.yaml. @@ -27,8 +28,9 @@ def run_init( """ convcell = parse_cell_dict(toml_dict["unitcell"]) supercell_matrix = toml_dict["phelel"].get("supercell_dimension", None) - if "phonopy" in toml_dict: - phonon_supercell_matrix = toml_dict["phonopy"].get("supercell_dimension", None) + if "phono3py" in toml_dict: + phonon_supercell_matrix = supercell_matrix + supercell_matrix = toml_dict["phono3py"].get("supercell_dimension", None) else: phonon_supercell_matrix = None if "primitive_cell" in toml_dict: @@ -70,6 +72,7 @@ def run_init( is_plusminus=is_plusminus, is_diagonal=is_diagonal, number_of_snapshots=number_of_snapshots, + number_of_snapshots_fc2=number_of_snapshots_fc2, ) nac_directory = current_directory / "nac" @@ -99,6 +102,7 @@ def _generate_phono3py_supercells( is_plusminus: Union[str, bool] = "auto", is_diagonal: bool = True, number_of_snapshots: Optional[int] = None, + number_of_snapshots_fc2: Optional[int] = None, ): """Generate phelel supercells.""" if distance is None: @@ -119,12 +123,14 @@ def _generate_phono3py_supercells( if phono3py.phonon_supercell_matrix is not None: # For estimating number of displacements for harmonic phonon - phono3py.generate_fc2_displacements( - distance=distance, is_plusminus=False, is_diagonal=False - ) - n_disps = len(phono3py.phonon_supercells_with_displacements) - phono3py.generate_fc2_displacements( - distance=distance, number_of_snapshots=n_disps, is_plusminus=True - ) + if number_of_snapshots_fc2 is None: + phono3py.generate_fc2_displacements( + distance=distance, is_plusminus="auto", is_diagonal=False + ) + else: + phono3py.generate_fc2_displacements( + distance=distance, + number_of_snapshots=number_of_snapshots_fc2, + ) n_snapshots = len(phono3py.phonon_supercells_with_displacements) click.echo(f"Number of displacements for phonon: {n_snapshots}") diff --git a/src/phelel/velph/cli/utils.py b/src/phelel/velph/cli/utils.py index f841bf3..3f83c0a 100644 --- a/src/phelel/velph/cli/utils.py +++ b/src/phelel/velph/cli/utils.py @@ -78,13 +78,13 @@ class VelphInitParams: cell_for_nac: Optional[CellChoice] = CellChoice.UNSPECIFIED cell_for_relax: Optional[CellChoice] = CellChoice.UNSPECIFIED find_primitive: Optional[bool] = True - diagonal: Optional[bool] = True + diagonal: Optional[bool] = False plusminus: Optional[bool] = True kspacing: Optional[float] = 0.1 kspacing_dense: Optional[float] = 0.05 magmom: Optional[str] = None max_num_atoms: Optional[int] = None - phonon_max_num_atoms: Optional[int] = None + phono3py_max_num_atoms: Optional[int] = None phelel_nosym: Optional[bool] = False primitive_cell_choice: Optional[PrimitiveCellChoice] = ( PrimitiveCellChoice.STANDARDIZED diff --git a/test/velph/cli/phono3py/init/test_phono3py_init.py b/test/velph/cli/phono3py/init/test_phono3py_init.py index cb97d7e..b8c3b8f 100644 --- a/test/velph/cli/phono3py/init/test_phono3py_init.py +++ b/test/velph/cli/phono3py/init/test_phono3py_init.py @@ -10,31 +10,20 @@ @pytest.mark.parametrize("distance", [0.03, 0.05]) def test_phono3py_init_random_displacements(distance: float): """Test of plusminus and diagonal with Ti.""" - toml_str = f"""title = "VASP el-ph settings" + phelel_str = f"""title = "VASP el-ph settings" [phelel] supercell_dimension = [4, 4, 2] amplitude = {distance} fft_mesh = [18, 18, 28] +""" -[vasp.phonopy.incar] -lwap = true -isym = 0 -kpar = 2 -ncore = 24 -ismear = 0 -sigma = 0.2 -ediff = 1e-08 -encut = 329.532 -prec = "accurate" -lreal = false -lwave = false -lcharg = false -addgrid = true -lsorbit = true -[vasp.phonopy.kpoints] -mesh = [6, 6, 7] + phono3py_str = f"""[phono3py] +supercell_dimension = [2, 2, 1] +amplitude = {distance} +""" + unitcell_str = """ [unitcell] lattice = [ [ 2.930720886111760, 0.000000000000000, 0.000000000000000 ], # a @@ -48,13 +37,25 @@ def test_phono3py_init_random_displacements(distance: float): [[unitcell.points]] # 2 symbol = "Ti" coordinates = [ 0.666666666666664, 0.333333333333336, 0.750000000000000 ] -magnetic_moment = [ 0.00000000, 0.00000000, 0.00000000 ] -""" +magnetic_moment = [ 0.00000000, 0.00000000, 0.00000000 ]""" - toml_dict = tomli.loads(toml_str) + toml_dict = tomli.loads(phelel_str + unitcell_str) ph3 = run_init(toml_dict, number_of_snapshots=10) np.testing.assert_array_equal(ph3.supercell_matrix, np.diag([4, 4, 2])) - natom = len(ph3.supercell) - assert natom == 64 - assert ph3.displacements.shape == (10, natom, 3) + assert len(ph3.supercell) == 64 + assert ph3.displacements.shape == (10, 64, 3) + np.testing.assert_allclose(np.linalg.norm(ph3.displacements, axis=2), distance) + + toml_dict = tomli.loads(phelel_str + phono3py_str + unitcell_str) + ph3 = run_init(toml_dict, number_of_snapshots=10, number_of_snapshots_fc2=4) + np.testing.assert_array_equal(ph3.supercell_matrix, np.diag([2, 2, 1])) + np.testing.assert_array_equal(ph3.phonon_supercell_matrix, np.diag([4, 4, 2])) + + assert len(ph3.supercell) == 8 + assert ph3.displacements.shape == (10, 8, 3) + assert len(ph3.phonon_supercell) == 64 + assert ph3.phonon_displacements.shape == (4, 64, 3) np.testing.assert_allclose(np.linalg.norm(ph3.displacements, axis=2), distance) + np.testing.assert_allclose( + np.linalg.norm(ph3.phonon_displacements, axis=2), distance + ) From aba725331bb944aab30b02532f2650597e00dc27 Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Sun, 8 Dec 2024 12:21:18 +0900 Subject: [PATCH 09/11] Support reading non-KPOINTS_OPT DOS results in vaspout.h5 --- src/phelel/velph/cli/el_bands/plot.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/phelel/velph/cli/el_bands/plot.py b/src/phelel/velph/cli/el_bands/plot.py index 25c95b3..b2f9699 100644 --- a/src/phelel/velph/cli/el_bands/plot.py +++ b/src/phelel/velph/cli/el_bands/plot.py @@ -38,7 +38,20 @@ def plot_el_bandstructures( f_h5py_bands = h5py.File(vaspout_filename_bands) f_h5py_dos = h5py.File(vaspout_filename_dos) - efermi = f_h5py_dos["results"]["electron_dos_kpoints_opt"]["efermi"][()] + if "results" not in f_h5py_bands: + raise ValueError( + f"No electronic band structure results found in {vaspout_filename_bands}." + ) + if "results" not in f_h5py_dos: + raise ValueError(f"No electronic DOS results found in {vaspout_filename_dos}.") + if "electron_dos_kpoints_opt" in f_h5py_dos["results"]: + f_h5py_dos_results = f_h5py_dos["results"]["electron_dos_kpoints_opt"] + elif "electron_dos" in f_h5py_dos["results"]: + f_h5py_dos_results = f_h5py_dos["results"]["electron_dos"] + else: + raise ValueError("No electron DOS data found in vaspout.h5.") + + efermi = f_h5py_dos_results["efermi"][()] emin = window[0] emax = window[1] _, axs = plt.subplots(1, 2, gridspec_kw={"width_ratios": [3, 1]}) @@ -57,7 +70,7 @@ def plot_el_bandstructures( ax0.set_ylabel("E[eV]", fontsize=14) ymin, ymax = ax0.get_ylim() - dos, energies, xmax = _get_dos_data(f_h5py_dos, ymin, ymax) + dos, energies, xmax = _get_dos_data(f_h5py_dos_results, ymin, ymax) ax1.plot(dos, energies, "-k", linewidth=1) ax1.hlines(efermi, 0, xmax, "r", linewidth=1) @@ -99,9 +112,9 @@ def _get_bands_data(f_h5py: h5py.File): return distances, eigvals, points, labels_at_points -def _get_dos_data(f_h5py: h5py.File, ymin: float, ymax: float): - dos = f_h5py["results"]["electron_dos_kpoints_opt"]["dos"][0, :] - energies = f_h5py["results"]["electron_dos_kpoints_opt"]["energies"][:] +def _get_dos_data(f_h5py_dos_results: h5py.Group, ymin: float, ymax: float): + dos = f_h5py_dos_results["dos"][0, :] + energies = f_h5py_dos_results["energies"][:] i_min = 0 i_max = len(energies) for i, val in enumerate(energies): From cd0a2090b7cab6a369e2d8df8f93ad1df38b219e Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Sun, 8 Dec 2024 13:00:56 +0900 Subject: [PATCH 10/11] Minor refactoring of el_bands-plot --- src/phelel/velph/cli/el_bands/plot.py | 28 +++++++++++++---------- test/velph/cli/el_bands/plot/test_plot.py | 12 ++++++++-- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/phelel/velph/cli/el_bands/plot.py b/src/phelel/velph/cli/el_bands/plot.py index b2f9699..7979e9c 100644 --- a/src/phelel/velph/cli/el_bands/plot.py +++ b/src/phelel/velph/cli/el_bands/plot.py @@ -6,6 +6,7 @@ import click import h5py +import numpy as np from phelel.velph.cli.utils import ( get_distances_along_BZ_path, @@ -45,9 +46,9 @@ def plot_el_bandstructures( if "results" not in f_h5py_dos: raise ValueError(f"No electronic DOS results found in {vaspout_filename_dos}.") if "electron_dos_kpoints_opt" in f_h5py_dos["results"]: - f_h5py_dos_results = f_h5py_dos["results"]["electron_dos_kpoints_opt"] + f_h5py_dos_results = f_h5py_dos["results/electron_dos_kpoints_opt"] elif "electron_dos" in f_h5py_dos["results"]: - f_h5py_dos_results = f_h5py_dos["results"]["electron_dos"] + f_h5py_dos_results = f_h5py_dos["results/electron_dos"] else: raise ValueError("No electron DOS data found in vaspout.h5.") @@ -57,7 +58,12 @@ def plot_el_bandstructures( _, axs = plt.subplots(1, 2, gridspec_kw={"width_ratios": [3, 1]}) ax0, ax1 = axs - distances, eigvals, points, labels_at_points = _get_bands_data(f_h5py_bands) + reclat = get_reclat_from_vaspout(f_h5py_bands) + distances, eigvals, points, labels_at_points = _get_bands_data( + reclat, + f_h5py_bands["results/electron_eigenvalues_kpoints_opt"], + f_h5py_bands["input/kpoints_opt"], + ) ax0.plot(distances, eigvals[0, :, :], "ok", markersize=1) ax0.hlines(efermi, distances[0], distances[-1], "r", linewidth=1) @@ -86,20 +92,18 @@ def plot_el_bandstructures( click.echo(f'Electronic band structure plot was saved in "{plot_filename}".') -def _get_bands_data(f_h5py: h5py.File): - eigvals = f_h5py["results"]["electron_eigenvalues_kpoints_opt"]["eigenvalues"] +def _get_bands_data( + reclat: np.ndarray, f_h5py_bands_results: h5py.Group, f_h5py_bands_input: h5py.Group +): + eigvals = f_h5py_bands_results["eigenvalues"] - reclat = get_reclat_from_vaspout(f_h5py) # k-points in reduced coordinates - kpoint_coords = f_h5py["results"]["electron_eigenvalues_kpoints_opt"][ - "kpoint_coords" - ] + kpoint_coords = f_h5py_bands_results["kpoint_coords"] # Special point labels labels = [ - label.decode("utf-8") - for label in f_h5py["input"]["kpoints_opt"]["labels_kpoints"][:] + label.decode("utf-8") for label in f_h5py_bands_input["labels_kpoints"][:] ] - nk_per_seg = f_h5py["input"]["kpoints_opt"]["number_kpoints"][()] + nk_per_seg = f_h5py_bands_input["number_kpoints"][()] nk_total = len(kpoint_coords) k_cart = kpoint_coords @ reclat n_segments = nk_total // nk_per_seg diff --git a/test/velph/cli/el_bands/plot/test_plot.py b/test/velph/cli/el_bands/plot/test_plot.py index e0899a6..c870010 100644 --- a/test/velph/cli/el_bands/plot/test_plot.py +++ b/test/velph/cli/el_bands/plot/test_plot.py @@ -7,6 +7,7 @@ import pytest from phelel.velph.cli.el_bands.plot import _get_bands_data, _get_dos_data +from phelel.velph.cli.utils import get_reclat_from_vaspout cwd = pathlib.Path(__file__).parent @@ -21,9 +22,16 @@ def test_velph_el_bands_plot_TiNiSn(): assert vaspout_filename_bands.exists() f_h5py_bands = h5py.File(vaspout_filename_bands) f_h5py_dos = h5py.File(vaspout_filename_dos) - distances, eigvals, points, labels_at_points = _get_bands_data(f_h5py_bands) + reclat = get_reclat_from_vaspout(f_h5py_bands) + distances, eigvals, points, labels_at_points = _get_bands_data( + reclat, + f_h5py_bands["results/electron_eigenvalues_kpoints_opt"], + f_h5py_bands["input/kpoints_opt"], + ) ymin, ymax = 3.575980267703933, 17.575980267703933 - dos, energies, xmax = _get_dos_data(f_h5py_dos, ymin, ymax) + dos, energies, xmax = _get_dos_data( + f_h5py_dos["results/electron_dos_kpoints_opt"], ymin, ymax + ) assert len(distances) == 306 assert pytest.approx(distances[100], 1e-5) == 1.421887803385511 From 1cd1d0c89c393ba4b5812d11462d668fa7288db3 Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Mon, 9 Dec 2024 10:09:55 +0900 Subject: [PATCH 11/11] Set version 0.6.5 --- doc/changelog.md | 7 +++++++ doc/conf.py | 2 +- doc/index.md | 1 + src/phelel/version.py | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 doc/changelog.md diff --git a/doc/changelog.md b/doc/changelog.md new file mode 100644 index 0000000..45f0ff9 --- /dev/null +++ b/doc/changelog.md @@ -0,0 +1,7 @@ +(changelog)= + +# Change Log + +## Dec-9-2024: Version 0.6.6 + +- Collection of minor updates of velph command. diff --git a/doc/conf.py b/doc/conf.py index 3b10b92..1f7812a 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -11,7 +11,7 @@ author = "Atsushi Togo" version = "0.6" -release = "0.6.1" +release = "0.6.5" # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration diff --git a/doc/index.md b/doc/index.md index f87ec93..21d0ee3 100644 --- a/doc/index.md +++ b/doc/index.md @@ -21,4 +21,5 @@ BSD-3-Clause. :hidden: install velph +changelog ``` diff --git a/src/phelel/version.py b/src/phelel/version.py index edde350..1302b66 100644 --- a/src/phelel/version.py +++ b/src/phelel/version.py @@ -1,3 +1,3 @@ """Version number.""" -__version__ = "0.6.4" +__version__ = "0.6.5"