Change default disp-distance for pypolymlp

This commit is contained in:
Atsushi Togo 2025-01-19 18:25:58 +09:00
parent b8677363b2
commit 2a9fd71e53
3 changed files with 127 additions and 89 deletions

View File

@ -154,24 +154,22 @@ obtained by
``````
### Steps 4-7: Force constants calculation (systematic displacements in step 5)
### Step 4: Development of MLPs
After developing MLPs, displacements are generated systematically considering
crystal symmetry.
Having `phono3py_params.yaml`, phono3py is executed with `--pypolymlp` option,
The `phono3py_params.yaml` file contains the training data required for
developing polynomial MLPs when running with the `--pypolymlp` option.
```
% phono3py-load phono3py_params.yaml --pypolymlp -d
% phono3py-load --pypolymlp phono3py_params.yaml
_ _____
_ __ | |__ ___ _ __ ___|___ / _ __ _ _
| '_ \| '_ \ / _ \| '_ \ / _ \ |_ \| '_ \| | | |
| |_) | | | | (_) | | | | (_) |__) | |_) | |_| |
| .__/|_| |_|\___/|_| |_|\___/____/| .__/ \__, |
|_| |_| |___/
3.11.2
3.11.3
-------------------------[time 2025-01-15 16:25:17]-------------------------
-------------------------[time 2025-01-19 18:02:40]-------------------------
Compiled with OpenMP support (max 10 threads).
Running in phono3py.load mode.
Python version 3.12.6
@ -192,6 +190,14 @@ Displacement dataset for fc3 was read from "phono3py_params.yaml".
Pypolymlp is a generator of polynomial machine learning potentials.
Please cite the paper: A. Seko, J. Appl. Phys. 133, 011101 (2023).
Pypolymlp is developed at https://github.com/sekocha/pypolymlp.
Parameters:
cutoff: 8.0
model_type: 3
max_p: 2
gtinv_order: 3
gtinv_maxl: (8, 8)
gaussian_params1: (1.0, 1.0, 1)
gaussian_params2: (0.0, 7.0, 10)
Developing MLPs by pypolymlp...
Regression: cholesky decomposition ...
- alpha: 0.001
@ -210,29 +216,9 @@ Regression: model selection ...
- alpha = 1.000e+01 : rmse (train, test) = 0.00002 0.00002
MLPs were written into "phono3py.pmlp"
------------------------------ pypolymlp end -------------------------------
Generate displacements
Displacement distance: 0.001
Evaluate forces in 292 supercells by pypolymlp
----------------------------- Force constants ------------------------------
Computing fc3[ 1, x, x ] using numpy.linalg.pinv.
Displacements (in Angstrom):
[ 0.0010 0.0000 0.0000]
[-0.0010 0.0000 0.0000]
Computing fc3[ 33, x, x ] using numpy.linalg.pinv.
Displacements (in Angstrom):
[ 0.0010 0.0000 0.0000]
[-0.0010 0.0000 0.0000]
Expanding fc3.
fc3 was symmetrized.
fc2 was symmetrized.
Max drift of fc3: 0.000000 (xxx) 0.000000 (xxx) 0.000000 (xxx)
Max drift of fc2: 0.000000 (yy) 0.000000 (yy)
fc3 was written into "fc3.hdf5".
fc2 was written into "fc2.hdf5".
----------- None of ph-ph interaction calculation was performed. -----------
Dataset generated using MLPs was written in "phono3py_mlp_eval_dataset.yaml".
Generate displacements (--rd or -d) for proceeding to phonon calculations.
Summary of calculation was written in "phono3py.yaml".
-------------------------[time 2025-01-15 16:26:37]-------------------------
-------------------------[time 2025-01-19 18:03:44]-------------------------
_
___ _ __ __| |
/ _ \ '_ \ / _` |
@ -246,40 +232,33 @@ saved in the `phono3py.pmlp` file, which can be reused in subsequent phono3py
executions with the `--pypolymlp` option when only displacements (and no forces)
are provided.
After the MLPs are developed, systematic displacements, such as those involving
the displacement of one or two atoms in supercells, are generated with a
displacement distance of 0.001 Angstrom. The forces for these supercells are
then evaluated using pypolymlp. Both the generated displacements and the
corresponding forces are stored in the `phono3py_mlp_eval_dataset` file.
(systematic displacements)
### Steps 5-7: Force constants calculation (systematic displacements in step 5)
### Steps 4-7: Force constants calculation (random displacements in step 5)
After developing MLPs, random displacements are generated by specifying
{ref}`--rd <random_displacements_option>` option. To compute force constants
with random displacements, an external force constants calculator is necessary.
By default, symfc is used unless another force constants solver is explicitly
specified.
Having `phono3py_params.yaml`, phono3py is executed with `--pypolymlp` option,
With the `-d` option, displacements are systematically generated while taking
crystal symmetry into account. When running with the `--pypolymlp` option, MLPs
are read from `phono3py.pmlp` if the file exists. In this case, training data is
no longer required, and files such as `phono3py.yaml` can be used as the input
structure file.
```
% phono3py-load --pypolymlp --rd 200 phono3py_params.yaml
% phono3py-load --pypolymlp -d phono3py.yaml
_ _____
_ __ | |__ ___ _ __ ___|___ / _ __ _ _
| '_ \| '_ \ / _ \| '_ \ / _ \ |_ \| '_ \| | | |
| |_) | | | | (_) | | | | (_) |__) | |_) | |_| |
| .__/|_| |_|\___/|_| |_|\___/____/| .__/ \__, |
|_| |_| |___/
3.11.2
3.11.3
-------------------------[time 2025-01-15 19:30:47]-------------------------
-------------------------[time 2025-01-19 18:06:46]-------------------------
Compiled with OpenMP support (max 10 threads).
Running in phono3py.load mode.
Python version 3.12.3
Python version 3.12.6
Spglib version 2.5.0
----------------------------- General settings -----------------------------
HDF5 data compression filter: gzip
Crystal structure was read from "phono3py_params.yaml".
Crystal structure was read from "phono3py.yaml".
Supercell (dim): [2 2 2]
Primitive matrix:
[0. 0.5 0.5]
@ -287,33 +266,94 @@ Primitive matrix:
[0.5 0.5 0. ]
Spacegroup: Fm-3m (225)
Use -v option to watch primitive cell, unit cell, and supercell structures.
NAC parameters were read from "phono3py_params.yaml".
Displacement dataset for fc3 was read from "phono3py_params.yaml".
NAC parameters were read from "phono3py.yaml".
----------------------------- pypolymlp start ------------------------------
Pypolymlp is a generator of polynomial machine learning potentials.
Please cite the paper: A. Seko, J. Appl. Phys. 133, 011101 (2023).
Pypolymlp is developed at https://github.com/sekocha/pypolymlp.
Developing MLPs by pypolymlp...
Regression: cholesky decomposition ...
- alpha: 0.001
- alpha: 0.01
- alpha: 0.1
- alpha: 1.0
- alpha: 10.0
Clear training X.T @ X
Calculate X.T @ X for test data
Clear test X.T @ X
Regression: model selection ...
- alpha = 1.000e-03 : rmse (train, test) = 1.12211e+15 1.12211e+15
- alpha = 1.000e-02 : rmse (train, test) = 1.12211e+15 1.12211e+15
- alpha = 1.000e-01 : rmse (train, test) = 0.00002 0.00002
- alpha = 1.000e+00 : rmse (train, test) = 0.00002 0.00002
- alpha = 1.000e+01 : rmse (train, test) = 0.00002 0.00002
MLPs were written into "phono3py.pmlp"
Load MLPs from "phono3py.pmlp".
------------------------------ pypolymlp end -------------------------------
Generate displacements
Displacement distance: 0.01
Evaluate forces in 292 supercells by pypolymlp
----------------------------- Force constants ------------------------------
Computing fc3[ 1, x, x ] using numpy.linalg.pinv.
Displacements (in Angstrom):
[ 0.0100 0.0000 0.0000]
[-0.0100 0.0000 0.0000]
Computing fc3[ 33, x, x ] using numpy.linalg.pinv.
Displacements (in Angstrom):
[ 0.0100 0.0000 0.0000]
[-0.0100 0.0000 0.0000]
Expanding fc3.
fc3 was symmetrized.
fc2 was symmetrized.
Max drift of fc3: 0.000000 (zzz) 0.000000 (zzz) 0.000000 (zzz)
Max drift of fc2: 0.000000 (zz) 0.000000 (zz)
fc3 was written into "fc3.hdf5".
fc2 was written into "fc2.hdf5".
----------- None of ph-ph interaction calculation was performed. -----------
Dataset generated using MLPs was written in "phono3py_mlp_eval_dataset.yaml".
Summary of calculation was written in "phono3py.yaml".
-------------------------[time 2025-01-19 18:06:55]-------------------------
_
___ _ __ __| |
/ _ \ '_ \ / _` |
| __/ | | | (_| |
\___|_| |_|\__,_|
```
After the MLPs are read, systematic displacements, such as those involving the
displacement of one or two atoms in supercells, are generated with a
displacement distance of 0.01 Angstrom. The forces for these supercells are then
evaluated using pypolymlp. Both the generated displacements and the
corresponding forces are stored in the `phono3py_mlp_eval_dataset.yaml` file.
### Steps 5-7: Force constants calculation (random displacements in step 5)
Random displacements are generated by specifying {ref}`--rd
<random_displacements_option>` option. To compute force constants with random
displacements, an external force constants calculator is necessary. By default,
symfc is used unless another force constants solver is explicitly specified.
When running with the `--pypolymlp` option, MLPs are read from `phono3py.pmlp`
if the file exists. In this case, training data is no longer required, and files
such as `phono3py.yaml` can be used as the input structure file.
```
% phono3py-load --pypolymlp --rd 200 phono3py.yaml
_ _____
_ __ | |__ ___ _ __ ___|___ / _ __ _ _
| '_ \| '_ \ / _ \| '_ \ / _ \ |_ \| '_ \| | | |
| |_) | | | | (_) | | | | (_) |__) | |_) | |_| |
| .__/|_| |_|\___/|_| |_|\___/____/| .__/ \__, |
|_| |_| |___/
3.11.3
-------------------------[time 2025-01-19 18:13:21]-------------------------
Compiled with OpenMP support (max 10 threads).
Running in phono3py.load mode.
Python version 3.12.6
Spglib version 2.5.0
----------------------------- General settings -----------------------------
HDF5 data compression filter: gzip
Crystal structure was read from "phono3py.yaml".
Supercell (dim): [2 2 2]
Primitive matrix:
[0. 0.5 0.5]
[0.5 0. 0.5]
[0.5 0.5 0. ]
Spacegroup: Fm-3m (225)
Use -v option to watch primitive cell, unit cell, and supercell structures.
NAC parameters were read from "phono3py.yaml".
----------------------------- pypolymlp start ------------------------------
Pypolymlp is a generator of polynomial machine learning potentials.
Please cite the paper: A. Seko, J. Appl. Phys. 133, 011101 (2023).
Pypolymlp is developed at https://github.com/sekocha/pypolymlp.
Load MLPs from "phono3py.pmlp".
------------------------------ pypolymlp end -------------------------------
Generate random displacements
Twice of number of snapshots will be generated for plus-minus displacements.
Displacement distance: 0.001
Displacement distance: 0.01
Evaluate forces in 400 supercells by pypolymlp
----------------------------- Force constants ------------------------------
Symfc will be used to handle general (or random) displacements.
@ -338,7 +378,7 @@ fc2 was written into "fc2.hdf5".
----------- None of ph-ph interaction calculation was performed. -----------
Dataset generated using MLPs was written in "phono3py_mlp_eval_dataset.yaml".
Summary of calculation was written in "phono3py.yaml".
-------------------------[time 2025-01-15 19:32:04]-------------------------
-------------------------[time 2025-01-19 18:13:34]-------------------------
_
___ _ __ __| |
/ _ \ '_ \ / _` |
@ -346,20 +386,18 @@ Summary of calculation was written in "phono3py.yaml".
\___|_| |_|\__,_|
```
The development of MLPs follows the same procedure as described for the
systematic displacements (in step 5) above.
After the MLPs are developed, 200 supercells with random directional
displacements are generated. These displacements are then inverted, resulting in
an additional 200 supercells. In total, 400 supercells are created. The forces
for these supercells are then evaluated. Finally, the force constants are
calculated using symfc.
After the MLPs are read, 200 supercells with random directional displacements
are generated. These displacements are then inverted (such as $\Delta
\mathbf{u}_i$ and $-\Delta \mathbf{u}_i$ of all atoms $i$ in each supercell),
resulting in an additional 200 supercells. In total, 400 supercells are created.
The forces for these supercells are then evaluated. Finally, the force constants
are calculated using symfc.
### Command options for force constants calculation
After obtaining the MLPs, displacements are generated using those MLPs, and the
resulting forces are computed accordingly. The displacement distance is set by
the `--amplitude` option, whose default value is 0.001 Angstrom. When the `--rd`
the `--amplitude` option, whose default value is 0.01 Angstrom. When the `--rd`
option is used, it specifies the number of supercells with random directional
displacements. Note that to achieve accurate force constants, the actual number
of generated supercells is twice the specified number. If `--rd` is omitted,
@ -371,19 +409,19 @@ files, `phono3py-load` will detect `phono3py.pmlp` and then compute the force
constants by loading the MLPs from `phono3py.pmlp` as follows:
```
% phono3py-load --pypolymlp --rd 100 --amplitude 0.01 phono3py.yaml
% phono3py-load --pypolymlp --rd 100 --amplitude 0.005 phono3py.yaml
_ _____
_ __ | |__ ___ _ __ ___|___ / _ __ _ _
| '_ \| '_ \ / _ \| '_ \ / _ \ |_ \| '_ \| | | |
| |_) | | | | (_) | | | | (_) |__) | |_) | |_| |
| .__/|_| |_|\___/|_| |_|\___/____/| .__/ \__, |
|_| |_| |___/
3.11.2
3.11.3
-------------------------[time 2025-01-15 19:28:22]-------------------------
-------------------------[time 2025-01-19 18:19:02]-------------------------
Compiled with OpenMP support (max 10 threads).
Running in phono3py.load mode.
Python version 3.12.3
Python version 3.12.6
Spglib version 2.5.0
----------------------------- General settings -----------------------------
HDF5 data compression filter: gzip
@ -404,7 +442,7 @@ Load MLPs from "phono3py.pmlp".
------------------------------ pypolymlp end -------------------------------
Generate random displacements
Twice of number of snapshots will be generated for plus-minus displacements.
Displacement distance: 0.01
Displacement distance: 0.005
Evaluate forces in 200 supercells by pypolymlp
----------------------------- Force constants ------------------------------
Symfc will be used to handle general (or random) displacements.
@ -429,7 +467,7 @@ fc2 was written into "fc2.hdf5".
----------- None of ph-ph interaction calculation was performed. -----------
Dataset generated using MLPs was written in "phono3py_mlp_eval_dataset.yaml".
Summary of calculation was written in "phono3py.yaml".
-------------------------[time 2025-01-15 19:28:30]-------------------------
-------------------------[time 2025-01-19 18:19:09]-------------------------
_
___ _ __ __| |
/ _ \ '_ \ / _` |

View File

@ -2272,7 +2272,7 @@ class Phono3py:
The displacements may be generated by the produce_force_constants method
with number_of_snapshots > 0. With MLP, a small distance parameter, such
as 0.001, can be numerically stable for the computation of force
as 0.01, can be numerically stable for the computation of force
constants.
"""
@ -2336,7 +2336,7 @@ class Phono3py:
The displacements may be generated by the produce_force_constants method
with number_of_snapshots > 0. With MLP, a small distance parameter, such
as 0.001, can be numerically stable for the computation of force
as 0.01, can be numerically stable for the computation of force
constants.
"""

View File

@ -561,7 +561,7 @@ def run_pypolymlp_to_compute_forces(
if prepare_dataset:
if displacement_distance is None:
_displacement_distance = 0.001
_displacement_distance = 0.01
else:
_displacement_distance = displacement_distance
@ -629,7 +629,7 @@ def run_pypolymlp_to_compute_phonon_forces(
print("-" * 30 + " pypolymlp end " + "-" * 31, flush=True)
if displacement_distance is None:
_displacement_distance = 0.001
_displacement_distance = 0.01
else:
_displacement_distance = displacement_distance
if log_level: