Skip to content

Commit

Permalink
Merge branch 'develop' into rc
Browse files Browse the repository at this point in the history
  • Loading branch information
atztogo committed Sep 13, 2024
2 parents c56f8d5 + 575c410 commit cf89c01
Show file tree
Hide file tree
Showing 26 changed files with 232 additions and 477 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/phono3py-pytest-conda-mkl-phphmtblas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Install phonopy develop branch
run: |
conda activate test
git clone --depth 1 https://github.com/phonopy/phonopy.git
git clone https://github.com/phonopy/phonopy.git
cd phonopy
pip install -e . -vvv
cd ..
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phono3py-pytest-conda-mkl-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Install phonopy develop branch
run: |
conda activate test
git clone --depth 1 https://github.com/phonopy/phonopy.git
git clone https://github.com/phonopy/phonopy.git
cd phonopy
pip install -e . -vvv
cd ..
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phono3py-pytest-conda-mkl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Install phonopy develop branch
run: |
conda activate test
git clone --depth 1 https://github.com/phonopy/phonopy.git
git clone https://github.com/phonopy/phonopy.git
cd phonopy
pip install -e . -vvv
cd ..
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/phono3py-pytest-conda-numpy2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ jobs:
- name: Install symfc develop branch
run: |
conda activate test
git clone --depth 1 https://github.com/symfc/symfc.git
git clone https://github.com/symfc/symfc.git
cd symfc
pip install -e . -vvv
cd ..
- name: Install phonopy develop branch
run: |
conda activate test
git clone --depth 1 https://github.com/phonopy/phonopy.git
git clone https://github.com/phonopy/phonopy.git
cd phonopy
pip install -e . -vvv
cd ..
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/phono3py-pytest-conda-phphmtblas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ jobs:
- name: Install symfc develop branch
run: |
conda activate test
git clone --depth 1 https://github.com/symfc/symfc.git
git clone https://github.com/symfc/symfc.git
cd symfc
pip install -e . -vvv
cd ..
- name: Install phonopy develop branch
run: |
conda activate test
git clone --depth 1 https://github.com/phonopy/phonopy.git
git clone https://github.com/phonopy/phonopy.git
cd phonopy
pip install -e . -vvv
cd ..
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phono3py-pytest-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Install phonopy develop branch
run: |
conda activate test
git clone --depth 1 https://github.com/phonopy/phonopy.git
git clone https://github.com/phonopy/phonopy.git
cd phonopy
pip install -e . -vvv
cd ..
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
exclude: ^example/AlN-LDA/

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.1
rev: v0.6.4
hooks:
- id: ruff
args: [ "--fix", "--show-fixes" ]
Expand Down
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

## Sep-13-2024: Version 3.5

- Maintenance release.

## Aug-23-2024: Version 3.4

- Update for spglib v2.5 and for following the change in phonopy.
Expand Down
76 changes: 47 additions & 29 deletions doc/command-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ These options have no respective configuration file tags.

This is used to create `FORCES_FC3` from `phono3py_disp.yaml` and force
calculator outputs containing forces in supercells. `phono3py_disp.yaml` has to
be located at the current directory. Calculator interface has to be specified
except for VASP (default) case.
be located at the current directory.

```bash
% phono3py --cf3 disp-{00001..00755}/vasprun.xml
Expand All @@ -97,14 +96,26 @@ except for VASP (default) case.
% phono3py --cf3 supercell_out/disp-{00001..00111}/Si.out
```

````{note}
The calculator interface should be stored in `phono3py_disp.yaml`, so it is not
needed to set it manually. Command-line-options like `--qe` will be ignored. If
the calculator interface is missing from `phono3py_disp.yaml` but needed, please
update the `phono3py` section in the file as follows:
```yaml
phono3py:
calculator: qe
```
````

(cf3_file_option)=

### `--cf3-file` (command option only)

This is used to create `FORCES_FC3` from a text file containing a list of
calculator output file names. `phono3py_disp.yaml` has to be located at the
current directory. Calculator interface has to be specified except for VASP
(default) case.
current directory. The calculator interface is unnecessary to specify, see the
note at {ref}`--cf3 <cf3_option>`.

```bash
% phono3py --cf3-file file_list.dat
Expand All @@ -130,8 +141,9 @@ together with `--cutoff-pair` option.

This is used to create `FORCES_FC2` similarly to `--cf3` option.
`phono3py_disp.yaml` has to be located at the current directory. This is
optional. Calculator interface has to be specified except for VASP (default)
case. `FORCES_FC2` is necessary to run with `--dim-fc2` option.
optional. `FORCES_FC2` is necessary to run with `--dim-fc2` option. The
calculator interface is unnecessary to specify, see the note at {ref}`--cf3
<cf3_option>`.

```bash
% phono3py --cf2 disp_fc2-{00001..00002}/vasprun.xml
Expand All @@ -142,8 +154,8 @@ case. `FORCES_FC2` is necessary to run with `--dim-fc2` option.
### `--cfz` (command option only)

This is used to create `FORCES_FC3` and `FORCES_FC2` subtracting residual forces
combined with `--cf3` and `--cf2`, respectively. Calculator interface has to be
specified except for VASP (default) case.
combined with `--cf3` and `--cf2`, respectively. The calculator interface is
unnecessary to specify, see the note at {ref}`--cf3 <cf3_option>`.

In the following example, it is supposed that `disp3-00000/vasprun.xml` and
`disp2-00000/vasprun.xml` contain the forces of the perfect supercells. In ideal
Expand Down Expand Up @@ -204,7 +216,6 @@ When using with `--cf2`, `--cf3` has to be specified simultaneously as below,
% phono3py --cf3 disp-{00001..00755}/vasprun.xml --cf2 disp_fc2-{00001..00002}/vasprun.xml --sp
```


## Supercell, primitive cell, masses, magnetic moments

(dim_option)=
Expand Down Expand Up @@ -299,6 +310,7 @@ web page](https://phonopy.github.io/phonopy/setting-tags.html#magmom).
## Displacement creation

(create_displacements_option)=

### `-d` (`CREATE_DISPLACEMENTS = .TRUE.`)

**`phono3py-load` doesn't have this option.**
Expand All @@ -317,6 +329,7 @@ information about primitive cell (`primitive_matrix` key) in
```

(random_displacements_option)=

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

**`phono3py-load` doesn't have this option.**
Expand All @@ -336,6 +349,7 @@ and/or `--rd-fc2`,
```

(amplitude_option)=

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

**`phono3py-load` doesn't have this option.**
Expand All @@ -348,6 +362,7 @@ The default value depends on calculator. See
{ref}`default_displacement_distance_for_calculator`.

(fc_calculator_option)=

### `--fc-calc`, `--fc-calculator` (`FC_CALCULATOR`)

Choice of force constants calculator.
Expand All @@ -357,14 +372,17 @@ Choice of force constants calculator.
```

To use different force constants calculators for fc2 and fc3

```bash
% phono3py-load --fc-calc "symfc|" ...
```

Those for fc2 and fc3 are seprated by `|` such as `symfc|` . Blank means to
employ the finite difference method for systematic displacements generated by
the option `-d`.

(fc_calculator_options_option)=

### `--fc-calc-opt`, `--fc-calculator-options` (`FC_CALCULATOR_OPTIONS`)

Special options for force constants calculators.
Expand Down Expand Up @@ -608,9 +626,9 @@ $$
\bigl|\Phi_{-\lambda\lambda'\lambda''}\bigl|^2
\left\{(n_{\lambda'}+ n_{\lambda''}+1)
\delta(\omega-\omega_{\lambda'}-\omega_{\lambda''}) \right.
+ (n_{\lambda'}-n_{\lambda''})
* (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 @@ -840,7 +858,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 @@ -854,7 +872,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 Down Expand Up @@ -922,11 +940,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 @@ -941,14 +959,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 @@ -1012,7 +1030,7 @@ A_\lambda(\omega) = \frac{1}{\pi} \frac{4\Omega^2_\lambda
\Gamma_\lambda(\omega)}
{\left[\omega^2 - \Omega^2_\lambda -
2\Omega_\lambda \Delta_\lambda(\omega) \right]^2
+ \left[ 2\Omega_\lambda
* \left[ 2\Omega_\lambda
\Gamma_\lambda(\omega) \right]^2},
$$

Expand Down Expand Up @@ -1348,12 +1366,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 @@ -1367,11 +1385,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
4 changes: 2 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@
# built documents.
#
# The short X.Y version.
version = "3.3"
version = "3.5"
# The full version, including alpha/beta/rc tags.
release = "3.3.4"
release = "3.5.0"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
5 changes: 1 addition & 4 deletions doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,8 @@ Papers that may introduce phono3py:
[JPCM.35.353001](https://iopscience.iop.org/article/10.1088/1361-648X/acd831)
(open access)


## Documentation

```{toctree}
:maxdepth: 1
:hidden:
install
workflow
examples
Expand Down
33 changes: 12 additions & 21 deletions phono3py/api_phono3py.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@
from phonopy.interface.pypolymlp import (
PypolymlpData,
PypolymlpParams,
develop_mlp_by_pypolymlp,
develop_polymlp,
evalulate_polymlp,
load_polymlp,
parse_mlp_params,
)
from phonopy.structure.atoms import PhonopyAtoms
Expand Down Expand Up @@ -2203,31 +2205,20 @@ def develop_mlp(
if self._mlp_dataset is None:
raise RuntimeError("MLP dataset is not set.")

if params is not None:
_params = parse_mlp_params(params)
else:
_params = params

disps = self._mlp_dataset["displacements"]
forces = self._mlp_dataset["forces"]
energies = self._mlp_dataset["supercell_energies"]
n = int(len(disps) * (1 - test_size))
train_data = PypolymlpData(
displacements=disps[:n], forces=forces[:n], supercell_energies=energies[:n]
)
test_data = PypolymlpData(
displacements=disps[n:], forces=forces[n:], supercell_energies=energies[n:]
)
self._mlp = develop_polymlp(
self._mlp = develop_mlp_by_pypolymlp(
self._mlp_dataset,
self._supercell,
train_data,
test_data,
params=_params,
verbose=self._log_level - 1 > 0,
params=params,
test_size=test_size,
log_level=self._log_level,
)

def load_mlp(self, filename: str = "phono3py.pmlp"):
"""Load machine learning potential of pypolymlp."""
self._mlp = load_polymlp(filename=filename)

def evaluate_mlp(self):
"""Evaluate the machine learning potential of pypolymlp.
"""Evaluate machine learning potential of pypolymlp.
This method calculates the supercell energies and forces from the MLP
for the displacements in self._dataset of type 2. The results are stored
Expand Down
Loading

0 comments on commit cf89c01

Please sign in to comment.