Skip to content

Commit

Permalink
Merge branch 'develop' into publish-gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
atztogo committed Jan 8, 2025
2 parents 99b6548 + 7a5d6ad commit 51b46a8
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 23 deletions.
4 changes: 4 additions & 0 deletions doc/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

# Change Log

## Jan-8-2025: Version 0.8.1

- Fix minor bugs in velph command

## Jan-5-2025: Version 0.8.0

- Refactoring of `Phelel` class
Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
author = "Atsushi Togo"

version = "0.8"
release = "0.8.0"
release = "0.8.1"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
12 changes: 12 additions & 0 deletions doc/reference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(references)=
# References

This page presents the methodologies and software packages that the phelel code relies on.

(reference_finufft)=
## finufft

The local potentials from VASP calculation results are interpolated using
[finufft](https://finufft.readthedocs.io/). For more information and references
on finufft, visit
[https://finufft.readthedocs.io/en/latest/refs.html](https://finufft.readthedocs.io/en/latest/refs.html).
34 changes: 34 additions & 0 deletions doc/velph-subcommands.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ This subcommand calculates the derivatives of local potentials and PAW strengths
with respect to displacement, performing similar operations as steps 1 and 3
carried out by the `phelel` command in the {ref}`workflow <workflow_minimal>`.

The subcommands below should be executed in the following order:

1. {ref}`velph_phelel_init_subcommand`
2. {ref}`velph_phelel_generate_subcommand`
3. {ref}`velph_phelel_differentiate_subcommand`
4. {ref}`velph_phelel_phonopy_subcommand` (optional)

(velph_phelel_init_subcommand)=
### `velph phelel init`

This subcommand generates the `phelel_disp.yaml` file, which contains
Expand All @@ -82,8 +90,11 @@ Found "nac" directory. Read NAC params.
VASP input files will be generated by "velph phelel generate".
```

(velph_phelel_generate_subcommand)=
### `velph phelel generate`

VASP input files and job scripts are generated.

```bash
% velph phelel generate
VASP input files were generated in "phelel/disp-000".
Expand All @@ -93,10 +104,33 @@ VASP input files were generated in "phelel/disp-003".
VASP input files were generated in "phelel/disp-004".
```

(velph_phelel_differentiate_subcommand)=
### `velph phelel differentiate`

The derivatives of local potentials and PAW strengths with respect to
displacement are calculated and stored in `phelel_params.hdf5`.

```bash
% velph phelel differentiate
FFT mesh: [30 30 30].
Running finufft (eps=1.000e-06)...
Running finufft (eps=1.000e-06)...
"phelel/phelel_params.hdf5" has been made.
```

(velph_phelel_phonopy_subcommand)=
### `velph phelel phonopy`

`phonopy_params.yaml` that contains information necessary for phonon calculation
by the phonopy code is generated from `phelel_disp.yaml` and the results of the
VASP inputs generated by `velph phelel generate`.

```bash
% velph phelel phonopy
"phelel/phonopy_params.yaml" has been made.
% phonopy-load phelel/phonopy_params.yaml --band auto -p
```

## `velph transport`

### `velph transport generate`
Expand Down
40 changes: 34 additions & 6 deletions src/phelel/api_phelel.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,6 @@ def unit_conversion_factor(self) -> float:
else:
return self._phonon.unit_conversion_factor

@property
def phonon(self) -> Optional[Phonopy]:
"""Return Phonopy class instance."""
return self._phonon

@property
def fft_mesh(self) -> np.ndarray:
"""Setter and getter of FFT mesh numbers."""
Expand Down Expand Up @@ -427,6 +422,20 @@ def generate_displacements(
distance=distance, is_plusminus=is_plusminus, is_diagonal=is_diagonal
)

def generate_phonon_displacements(
self,
distance=0.01,
is_plusminus="auto",
is_diagonal=True,
):
"""Generate displacement dataset."""
if self._phonon is None:
msg = "Phonon instance has to be initialized."
raise RuntimeError(msg)
self._phonon.generate_displacements(
distance=distance, is_plusminus=is_plusminus, is_diagonal=is_diagonal
)

def run_derivatives(self, phe_input: PhelelDataset):
"""Run displacement derivatives calculations from temporary raw data.
Expand Down Expand Up @@ -488,6 +497,7 @@ def save_hdf5(
"atom_indices_in_derivatives": self._atom_indices_in_derivatives,
"disp_dataset": self._phelel_phonon.dataset,
"nac_params": self._phelel_phonon.nac_params,
"filename": filename,
}
if self._phonon is not None:
params.update(
Expand All @@ -497,11 +507,29 @@ def save_hdf5(
"phonon_primitive": self._phonon.primitive,
"phonon_supercell": self._phonon.supercell,
"symmetry_dataset": self._phonon.primitive_symmetry.dataset,
"filename": filename,
}
)
write_phelel_params_hdf5(**params)

def save_phonon(
self,
filename="phonopy_params.yaml",
settings=None,
hdf5_settings=None,
compression: Union[str, bool] = False,
):
"""Save phonon in yaml format."""
if self._phonon is None:
ph = self._phelel_phonon
else:
ph = self._phonon
ph.save(
filename=filename,
settings=settings,
hdf5_settings=hdf5_settings,
compression=compression,
)

def _prepare_phonon(
self,
dataset: Optional[dict] = None,
Expand Down
14 changes: 7 additions & 7 deletions src/phelel/cui/create_supercells.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ def create_phelel_supercells(
additional_info=additional_info,
)

if phelel.phonon is not None:
if phelel.phonon_supercell_matrix is not None:
additional_info = get_additional_info_to_write_fc2_supercells(
interface_mode, phelel.phonon_supercell_matrix, suffix="PH"
)
write_supercells_with_displacements(
phelel.phonon.calculator,
phelel.phonon.supercell,
phelel.phonon.supercells_with_displacements,
phelel.calculator,
phelel.phonon_supercell,
phelel.phonon_supercells_with_displacements,
optional_structure_info=optional_structure_info,
additional_info=additional_info,
)
Expand Down Expand Up @@ -115,12 +115,12 @@ def generate_phelel_supercells(
print("Displacement distance: %s" % _distance)
print("Number of displacements: %d" % len(phelel.supercells_with_displacements))

if phelel.phonon is not None:
phelel.phonon.generate_displacements(
if phelel.phonon_supercell_matrix is not None:
phelel.generate_phonon_displacements(
distance=distance, is_plusminus=is_plusminus, is_diagonal=is_diagonal
)
if log_level:
print(
"Number of displacements for phonon: %d"
% len(phelel.phonon.supercells_with_displacements)
% len(phelel.phonon_supercells_with_displacements)
)
2 changes: 1 addition & 1 deletion src/phelel/cui/phelel_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def main(**argparse_control):
print_cell(phelel.supercell)
if phelel.phonon_supercell_matrix is not None:
print("-" * 28 + " phonon super cell " + "-" * 29)
print_cell(phelel.phonon.supercell)
print_cell(phelel.phonon_supercell)
print("-" * 76)

##################################
Expand Down
5 changes: 1 addition & 4 deletions src/phelel/interface/vasp/derivatives.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,7 @@ def read_files(
"atoms in the vasprun.xml file."
)

if phelel.phonon_supercell_matrix is None:
phelel.forces = forces
else:
phelel.phonon.forces = forces
phelel.forces = forces

nac_params = _read_born(
phelel.primitive, phelel.primitive_symmetry, log_level=log_level
Expand Down
10 changes: 7 additions & 3 deletions src/phelel/velph/cli/phelel/phonopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,16 @@ def create_phonopy_yaml(

# NAC params should be contained phelel_disp.yaml.
# Therefore nac_params is not set to phe here.
if phe.phonon_supercell_matrix is None:
supercell = phe.supercell
else:
supercell = phe.phonon_supercell
forces = read_forces_from_vasprunxmls(
[d / "vasprun.xml" for d in dir_names],
phe.phonon,
supercell,
subtract_rfs=subtract_residual_forces,
log_level=0,
)
phe.phonon.forces = forces
phe.phonon.save(filename=phonopy_yaml_filename)
phe.forces = forces
phe.save_phonon(filename=phonopy_yaml_filename)
click.echo(f'"{phonopy_yaml_filename}" has been made.')
2 changes: 1 addition & 1 deletion src/phelel/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Version number."""

__version__ = "0.8.0"
__version__ = "0.8.1"

0 comments on commit 51b46a8

Please sign in to comment.