Skip to content

Commit

Permalink
Command options for generating random directional displacements
Browse files Browse the repository at this point in the history
  • Loading branch information
atztogo committed Jun 29, 2024
1 parent 628b4fb commit a981a04
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 41 deletions.
5 changes: 5 additions & 0 deletions doc/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

# Change Log

## Jun-29-2024: Version 3.2.0

- `--rd` and `--rd-fc2` options for generating random directional displacements.
- Experimental implementation for using pypolymlp.

## Jun-19-2024: Version 3.1.2

- Treatment of numpy 2.0.
Expand Down
90 changes: 49 additions & 41 deletions doc/command-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ created from `FORCES_FC2` and `phono3py_disp.yaml` instead of `FORCES_FC3` and
### `--dim` (`DIM`)

Supercell dimension is specified. See the detail at
http://phonopy.github.io/phonopy/setting-tags.html#dim. When a proper
<http://phonopy.github.io/phonopy/setting-tags.html#dim>. When a proper
`phono3py_disp.yaml` exists in the current directory, this is unnecessary to be
specified.

Expand Down Expand Up @@ -233,7 +233,7 @@ that created in the usual phono3py run without `--dim-fc2` option.

Transformation matrix from a non-primitive cell to the primitive cell. See
phonopy `PRIMITIVE_AXES` tag (`--pa` option) at
http://phonopy.github.io/phonopy/setting-tags.html#primitive-axis. When a proper
<http://phonopy.github.io/phonopy/setting-tags.html#primitive-axis>. When a proper
`phono3py_disp.yaml` exists in the current directory, this is unnecessary to be
specified.

Expand Down Expand Up @@ -261,10 +261,17 @@ e.g., `--pa="F"` if the input unit cell has F-centring.

(amplitude_option)=

### `--rd` (`RANDOM_DISPLACEMENTS`), `--rd-fc2` (`RANDOM_DISPLACEMENTS_FC2`) and `--random-seed` (`RANDOM_SEED`)

Random directional displacements are generated for fc3 and fc2 supercells by
`--rd` and `--rd-fc2`, respectively. `--amplitude` and `--random-seed` options
may be used together. These are used in the equivalent way to [`--rd` of
phonopy](https://phonopy.github.io/phonopy/setting-tags.html#random-displacements).

### `--amplitude` (`DISPLACEMENT_DISTANCE`)

Atomic displacement distance is specified. This value may be increased for the
weak interaction systems and descreased when the force calculator is numerically
weak interaction systems and decreased when the force calculator is numerically
very accurate.

The default value depends on calculator. See
Expand All @@ -279,7 +286,7 @@ The default value depends on calculator. See
When creating force constants from `FORCES_FC3` and/or `FORCES_FC2`, force
constants that use smaller data size are created. The shape of the data array is
`(num_patom, num_satom)` for fc2 and `(num_patom, num_satom, num_satom)` for
fc3, where `num_patom` and `num_satom` are the numbers of atoms in primtive cell
fc3, where `num_patom` and `num_satom` are the numbers of atoms in primitive cell
and supercell. In the full size force constants case, `num_patom` is replaced by
`num_satom`. Therefore if the supercell dimension is large, this reduction of
data size becomes large. If the input crystal structure has centring
Expand All @@ -298,7 +305,7 @@ imperfect symmetrization scheme that phono3py employs.
### `--sym-fc` (`FC_SYMMETRY = .TRUE.`)

Second- and third-order force constants are symmetrized. The index exchange of
real space force constantsand translational invariance symmetry are applied in a
real space force constants and translational invariance symmetry are applied in a
simple way. This symmetrization just removes drift force constants evenly from
all elements and then applies averaging index-exchange equivalent elements.
Therefore the different symmetries are not simultaneously enforced. For better
Expand Down Expand Up @@ -336,7 +343,7 @@ or computed with less numerical accuracy. More details are found at

This invokes ALM as the force constants calculator for fc2 and fc3. See the
detail at
[phonopy documentaton](https://phonopy.github.io/phonopy/setting-tags.html#alm).
[phonopy documentation](https://phonopy.github.io/phonopy/setting-tags.html#alm).
This option is useful for fitting random displacement dataset or MD data to
force constants. Phono3py doesn't provide command-line interface to generate
random displacements. Instead simply
Expand All @@ -359,7 +366,7 @@ as written
### `--gp` (`GRID_POINTS`)

Grid points are specified by their unique indices, e.g., for selecting the
q-points where imaginary parts of self energees are calculated. For thermal
q-points where imaginary parts of self energies are calculated. For thermal
conductivity calculation, this can be used to distribute its calculation over
q-points (see {ref}`workload_distribution`).

Expand All @@ -382,7 +389,7 @@ This is used to specify grid points like `--gp` option but in their addresses
represented by integer numbers. For example with `--mesh="16 16 16"`, a q-point
of (0.5, 0.5, 0.5) is given by `--ga="8 8 8"`. The values have to be integers.
If you want to specify the point on a path,
`--ga="0 0 0 1 1 1 2 2 2 3 3 3 ..."`, where each three values are recogninzed as
`--ga="0 0 0 1 1 1 2 2 2 3 3 3 ..."`, where each three values are recognized as
a grid point. The grid points given by `--ga` option are translated to grid
point indices as given by `--gp` option, and the values given by `--ga` option
will not be shown in log files.
Expand All @@ -394,7 +401,7 @@ will not be shown in log files.
Band indices are specified. The calculated values at indices separated by space
are averaged, and those separated by comma are separately calculated. The output
file name will be, e.g., `gammas-mxxx-gxx(-sx)-bx.dat` where `bxbx...` shows the
band indices where the values are calcualted and summed and averaged over those
band indices where the values are calculated and summed and averaged over those
bands.

```bash
Expand Down Expand Up @@ -489,7 +496,7 @@ $$
\delta(\omega-\omega_{\lambda'}-\omega_{\lambda''}) \right.
+ (n_{\lambda'}-n_{\lambda''})
\left[\delta(\omega+\omega_{\lambda'}-\omega_{\lambda''})
- \left. \delta(\omega-\omega_{\lambda'}+\omega_{\lambda''})
+ \left. \delta(\omega-\omega_{\lambda'}+\omega_{\lambda''})
\right]\right\}.
$$

Expand Down Expand Up @@ -524,16 +531,17 @@ equivalent to that of `--br`. More detail is documented at

### `--wigner`

Run calculation of lattice thermal conductivity tensor computing the coherences (wave-like) contribution
to the thermal conductivity, obtained solving the Wigner transport equation equation.
This option can be combined with `--lbte` or `--br`; in the former case the populations
conductivity (particle-like, equivalent to the conductivity obtained solving the LBTE) is computed exactly,
in the latter case the populations conductivity is
computed in the relaxation-time approximation (RTA).
The coherences contribution to the conductivity is always computed exactly.
The coherences conductivity is usually non-negligible compared to the particle-like conductivity in materials
with ultralow or glass-like conductivity.
More details can be found at {ref}`wigner_solution`.
Run calculation of lattice thermal conductivity tensor computing the coherences
(wave-like) contribution to the thermal conductivity, obtained solving the
Wigner transport equation equation. This option can be combined with `--lbte` or
`--br`; in the former case the populations conductivity (particle-like,
equivalent to the conductivity obtained solving the LBTE) is computed exactly,
in the latter case the populations conductivity is computed in the
relaxation-time approximation (RTA). The coherences contribution to the
conductivity is always computed exactly. The coherences conductivity is usually
non-negligible compared to the particle-like conductivity in materials with
ultralow or glass-like conductivity. More details can be found at
{ref}`wigner_solution`.

## Scattering

Expand Down Expand Up @@ -718,7 +726,7 @@ $$
\bigl|\Phi_{-\lambda\lambda_1\lambda_2}\bigl|^2
(n_{\lambda_1}-n_{\lambda_2})
\left[\delta(\omega+\omega_{\lambda_1}-\omega_{\lambda_2})
- \delta(\omega-\omega_{\lambda_1}+\omega_{\lambda_2})
+ \delta(\omega-\omega_{\lambda_1}+\omega_{\lambda_2})
\right]
\end{align*}
$$
Expand All @@ -732,7 +740,7 @@ $$
\bigl|\Phi_{-\lambda\lambda_1\lambda_2}\bigl|^2
(n_{\lambda_1}+ n_{\lambda_2}+1)
\left[ \delta(\omega-\omega_{\lambda_1}-\omega_{\lambda_2})
- \delta(\omega + \omega_{\lambda_1} + \omega_{\lambda_2}) \right]
+ \delta(\omega + \omega_{\lambda_1} + \omega_{\lambda_2}) \right]
\end{align*},
$$

Expand All @@ -758,7 +766,7 @@ Specific temperatures are specified by `--ts`.

Temperatures at equal interval are specified by `--tmax`, `--tmin`, `--tstep`.
See phonopy's document for the same tags at
http://phonopy.github.io/phonopy/setting-tags.html#tprop-tmin-tmax-tstep.
<http://phonopy.github.io/phonopy/setting-tags.html#tprop-tmin-tmax-tstep>.

```bash
% phono3py --fc3 --fc2 --dim="2 2 2" -v --mesh="11 11 11" -c POSCAR-unitcell --br --tmin=100 --tmax=1000 --tstep=50
Expand All @@ -779,7 +787,7 @@ file.

This is used with `--nac` to specify reciprocal-space direction at
$\mathbf{q}\rightarrow \mathbf{0}$. See the detail at
http://phonopy.github.io/phonopy/setting-tags.html#q-direction.
<http://phonopy.github.io/phonopy/setting-tags.html#q-direction>.

(self_energy_options)=

Expand All @@ -800,11 +808,11 @@ $$
\bigl|\Phi_{-\lambda\lambda_1\lambda_2}\bigl|^2 &
\left\{(n_{\lambda_1}+ n_{\lambda_2}+1)
\left[ \delta(\omega-\omega_{\lambda_1}-\omega_{\lambda_2})
- \delta(\omega+\omega_{\lambda_1}+\omega_{\lambda_2}) \right] \right.
+ \delta(\omega+\omega_{\lambda_1}+\omega_{\lambda_2}) \right] \right.
\\
& + (n_{\lambda_1}-n_{\lambda_2})
\left[\delta(\omega+\omega_{\lambda_1}-\omega_{\lambda_2})
- \left. \delta(\omega-\omega_{\lambda_1}+\omega_{\lambda_2})
+ \left. \delta(\omega-\omega_{\lambda_1}+\omega_{\lambda_2})
\right]\right\},
\end{align*}
$$
Expand All @@ -819,14 +827,14 @@ $$
\left\{
\left[ \frac{(n_{\lambda_1}+ n_{\lambda_2}+1)}{
(\omega-\omega_{\lambda_1}-\omega_{\lambda_2})_\mathrm{p}}
- \frac{(n_{\lambda_1}+ n_{\lambda_2}+1)}{
+ \frac{(n_{\lambda_1}+ n_{\lambda_2}+1)}{
(\omega+\omega_{\lambda_1}+\omega_{\lambda_2})_\mathrm{p}}
\right]
\right. \\
& + \left[
\frac{(n_{\lambda_1}-n_{\lambda_2})}{(\omega +
\omega_{\lambda_1} - \omega_{\lambda_2})_\mathrm{p}}
- \left. \frac{(n_{\lambda_1}-n_{\lambda_2})}{(\omega -
+ \left. \frac{(n_{\lambda_1}-n_{\lambda_2})}{(\omega -
\omega_{\lambda_1} + \omega_{\lambda_2})_\mathrm{p}}
\right]\right\},
\end{align*}
Expand Down Expand Up @@ -1186,7 +1194,7 @@ different CPU architectures. {ref}`--pa <pa_option>` and

### `--write-pp` (`WRITE_PP = .TRUE.`) and `--read-pp` (`READ_PP = .TRUE.`)

Phonon-phonon (ph-ph) intraction strengths are written to and read from
Phonon-phonon (ph-ph) interaction strengths are written to and read from
`pp-mxxx-gx.hdf5`. This works only in the calculation of lattice thermal
conductivity, i.e., usable only with `--br` or `--lbte`. The stored data are
different with and without specifying `--full-pp` option. In the former case,
Expand All @@ -1212,7 +1220,7 @@ Most of phono3py HDF5 output file is compressed by default with the `gzip`
compression filter. To avoid compression, `--hdf5-compression=None` has to be
set. Other filters (`lzf` or integer values of 0 to 9) may be used, see h5py
documentation
(http://docs.h5py.org/en/stable/high/dataset.html#filter-pipeline).
(<http://docs.h5py.org/en/stable/high/dataset.html#filter-pipeline>).

(output_filename_option)=

Expand All @@ -1226,12 +1234,12 @@ Using this option, output file names are slightly modified. For example, with

This rule is applied to

- `fc3.hdf5`
- `fc2.hdf5`
- `kappa-xxx.hdf5`
- `phonon-xxx.hdf5`
- `pp-xxx.hdf5`
- `gamma_detail-xxx.hdf5` (write only)
+ `fc3.hdf5`
+ `fc2.hdf5`
+ `kappa-xxx.hdf5`
+ `phonon-xxx.hdf5`
+ `pp-xxx.hdf5`
+ `gamma_detail-xxx.hdf5` (write only)

(input_filename_option)=

Expand All @@ -1245,11 +1253,11 @@ specifying `-i iso --fc3`, a file name `fc3.iso.hdf5` is read instead of

This rule is applied to

- `fc3.hdf5`
- `fc2.hdf5`
- `kappa-xxx.hdf5`
- `phonon-xxx.hdf5`
- `pp-xxx.hdf5`
+ `fc3.hdf5`
+ `fc2.hdf5`
+ `kappa-xxx.hdf5`
+ `phonon-xxx.hdf5`
+ `pp-xxx.hdf5`

### `--io` (command option only)

Expand Down
10 changes: 10 additions & 0 deletions phono3py/cui/create_supercells.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,18 @@ def create_phono3py_supercells(
cutoff_pair_distance=settings.cutoff_pair_distance,
is_plusminus=settings.is_plusminus_displacement,
is_diagonal=settings.is_diagonal_displacement,
number_of_snapshots=settings.random_displacements,
random_seed=settings.random_seed,
)

if settings.random_displacements_fc2:
phono3py.generate_fc2_displacements(

Check warning on line 85 in phono3py/cui/create_supercells.py

View check run for this annotation

Codecov / codecov/patch

phono3py/cui/create_supercells.py#L84-L85

Added lines #L84 - L85 were not covered by tests
distance=distance,
is_plusminus=settings.is_plusminus_displacement,
number_of_snapshots=settings.random_displacements_fc2,
random_seed=settings.random_seed,
)

if log_level:
print("")
print('Unit cell was read from "%s".' % optional_structure_info[0])
Expand Down
8 changes: 8 additions & 0 deletions phono3py/cui/phono3py_argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,14 @@ def get_parser(fc_symmetry=False, is_nac=False, load_phono3py_yaml=False):
default=None,
help="Number of supercells with random displacements",
)
parser.add_argument(

Check warning on line 674 in phono3py/cui/phono3py_argparse.py

View check run for this annotation

Codecov / codecov/patch

phono3py/cui/phono3py_argparse.py#L674

Added line #L674 was not covered by tests
"--rd-fc2",
"--random-displacements-fc2",
dest="random_displacements_fc2",
type=int,
default=None,
help="Number of phonon supercells with random displacements",
)
parser.add_argument(
"--read-collision",
dest="read_collision",
Expand Down
17 changes: 17 additions & 0 deletions phono3py/cui/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class Phono3pySettings(Settings):
"pinv_solver": 0,
"pinv_method": 0,
"pp_conversion_factor": None,
"random_displacements_fc2": None,
"scattering_event_class": None, # scattering event class 1 or 2
"sigma_cutoff_width": None,
"solve_collective_phonon": False,
Expand Down Expand Up @@ -276,6 +277,10 @@ def set_pp_conversion_factor(self, val):
"""Set pp_conversion_factor."""
self._v["pp_conversion_factor"] = val

def set_random_displacements_fc2(self, val):
"""Set random_displacements_fc2."""
self._v["random_displacements_fc2"] = val

Check warning on line 282 in phono3py/cui/settings.py

View check run for this annotation

Codecov / codecov/patch

phono3py/cui/settings.py#L282

Added line #L282 was not covered by tests

def set_read_collision(self, val):
"""Set read_collision."""
self._v["read_collision"] = val
Expand Down Expand Up @@ -553,6 +558,11 @@ def _read_options(self):
if pp_conv_factor is not None:
self._confs["pp_conversion_factor"] = pp_conv_factor

if "random_displacements_fc2" in self._args:
rd_fc2 = self._args.random_displacements_fc2
if rd_fc2 is not None:
self._confs["random_displacements_fc2"] = rd_fc2

Check warning on line 564 in phono3py/cui/settings.py

View check run for this annotation

Codecov / codecov/patch

phono3py/cui/settings.py#L562-L564

Added lines #L562 - L564 were not covered by tests

if "read_fc2" in self._args:
if self._args.read_fc2:
self._confs["read_fc2"] = ".true."
Expand Down Expand Up @@ -695,6 +705,7 @@ def _parse_conf(self):
"pinv_method",
"pinv_solver",
"num_points_in_batch",
"random_displacements_fc2",
"scattering_event_class",
):
self.set_parameter(conf_key, int(confs[conf_key]))
Expand Down Expand Up @@ -943,6 +954,12 @@ def _set_settings(self):
if "pp_conversion_factor" in params:
self._settings.set_pp_conversion_factor(params["pp_conversion_factor"])

# Random displacements for fc2
if "random_displacements_fc2" in params:
self._settings.set_random_displacements_fc2(

Check warning on line 959 in phono3py/cui/settings.py

View check run for this annotation

Codecov / codecov/patch

phono3py/cui/settings.py#L959

Added line #L959 was not covered by tests
params["random_displacements_fc2"]
)

# Calculate real_self_energys
if "real_self_energy" in params:
self._settings.set_is_real_self_energy(params["real_self_energy"])
Expand Down
1 change: 1 addition & 0 deletions phono3py/interface/phono3py_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ def _displacements_yaml_lines(self, with_forces: bool = False) -> list:
with_forces=with_forces,
key_prefix="phonon_",
)
lines.append("")
lines += self._displacements_yaml_lines_2types(
self._data.dataset, with_forces=with_forces
)
Expand Down

0 comments on commit a981a04

Please sign in to comment.