Skip to content

Commit 7806f7e

Browse files
committed
Merge branch 'develop'
2 parents 7a2b54f + 806bad7 commit 7806f7e

File tree

9 files changed

+82
-45
lines changed

9 files changed

+82
-45
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repos:
1111
exclude: ^example/AlN-LDA/
1212

1313
- repo: https://github.com/astral-sh/ruff-pre-commit
14-
rev: v0.9.7
14+
rev: v0.9.9
1515
hooks:
1616
- id: ruff
1717
args: [ "--fix", "--show-fixes" ]

doc/changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
# Change Log
44

5+
## Mar-4-2025: Version 3.15.0
6+
7+
- Release to follow the change of phonopy
8+
59
## Mar-1-2025: Version 3.14.1
610

711
- Release to follow the change of phonopy

doc/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@
5858
# built documents.
5959
#
6060
# The short X.Y version.
61-
version = "3.14"
61+
version = "3.15"
6262
# The full version, including alpha/beta/rc tags.
63-
release = "3.14.1"
63+
release = "3.15.0"
6464

6565
# The language for content autogenerated by Sphinx. Refer to documentation
6666
# for a list of supported languages.

doc/pypolymlp.md

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ in the distribution from GitHub or PyPI.
6464
`phono3py_params.yaml`. Use {ref}`--cf3 <cf3_option>` and {ref}`--sp
6565
<sp_option>` option simultaneously.
6666
4. Develop MLPs. By default, 90 and 10 percents of the dataset are used for the
67-
training and test, respectively. At this step `phono3py.pmlp` is saved.
67+
training and test, respectively. At this step `polymlp.yaml` is saved.
6868
5. Generate displacements in supercells either systematic or random displacements.
6969
6. Evaluate MLPs for forces of the supercells generated in step 5.
7070
7. Calculate force constants from displacement-force dataset from steps 5 and 6.
@@ -217,7 +217,7 @@ Regression: model selection ...
217217
- alpha = 1.000e-01 : rmse (train, test) = 0.00002 0.00002
218218
- alpha = 1.000e+00 : rmse (train, test) = 0.00002 0.00002
219219
- alpha = 1.000e+01 : rmse (train, test) = 0.00002 0.00002
220-
MLPs were written into "phono3py.pmlp"
220+
MLPs were written into "polymlp.yaml"
221221
------------------------------ pypolymlp end -------------------------------
222222
Generate displacements (--rd or -d) for proceeding to phonon calculations.
223223
Summary of calculation was written in "phono3py.yaml".
@@ -231,7 +231,7 @@ Summary of calculation was written in "phono3py.yaml".
231231

232232
Information about the development of MLPs using pypolymlp is provided between
233233
the `pypolymlp start` and `pypolymlp end` sections. The polynomial MLPs are
234-
saved in the `phono3py.pmlp` file, which can be reused in subsequent phono3py
234+
saved in the `polymlp.yaml` file, which can be reused in subsequent phono3py
235235
executions with the `--pypolymlp` option when only displacements (and no forces)
236236
are provided.
237237

@@ -240,7 +240,7 @@ are provided.
240240

241241
With the `-d` option, displacements are systematically generated while taking
242242
crystal symmetry into account. When running with the `--pypolymlp` option, MLPs
243-
are read from `phono3py.pmlp` if the file exists. In this case, training data is
243+
are read from `polymlp.yaml` if the file exists. In this case, training data is
244244
no longer required, and files such as `phono3py.yaml` can be used as the input
245245
structure file.
246246

@@ -274,7 +274,7 @@ NAC parameters were read from "phono3py.yaml".
274274
Pypolymlp is a generator of polynomial machine learning potentials.
275275
Please cite the paper: A. Seko, J. Appl. Phys. 133, 011101 (2023).
276276
Pypolymlp is developed at https://github.com/sekocha/pypolymlp.
277-
Load MLPs from "phono3py.pmlp".
277+
Load MLPs from "polymlp.yaml".
278278
------------------------------ pypolymlp end -------------------------------
279279
Generate displacements
280280
Displacement distance: 0.01
@@ -318,7 +318,7 @@ Random displacements are generated by specifying {ref}`--rd
318318
<random_displacements_option>` option. To compute force constants with random
319319
displacements, an external force constants calculator is necessary. By default,
320320
symfc is used unless another force constants solver is explicitly specified.
321-
When running with the `--pypolymlp` option, MLPs are read from `phono3py.pmlp`
321+
When running with the `--pypolymlp` option, MLPs are read from `polymlp.yaml`
322322
if the file exists. In this case, training data is no longer required, and files
323323
such as `phono3py.yaml` can be used as the input structure file.
324324

@@ -352,7 +352,7 @@ NAC parameters were read from "phono3py.yaml".
352352
Pypolymlp is a generator of polynomial machine learning potentials.
353353
Please cite the paper: A. Seko, J. Appl. Phys. 133, 011101 (2023).
354354
Pypolymlp is developed at https://github.com/sekocha/pypolymlp.
355-
Load MLPs from "phono3py.pmlp".
355+
Load MLPs from "polymlp.yaml".
356356
------------------------------ pypolymlp end -------------------------------
357357
Generate random displacements
358358
Twice of number of snapshots will be generated for plus-minus displacements.
@@ -406,10 +406,10 @@ displacements. Note that to achieve accurate force constants, the actual number
406406
of generated supercells is twice the specified number. If `--rd` is omitted,
407407
systematic displacements are introduced.
408408

409-
Once the file `phono3py.pmlp` is obtained, force constants can be calculated
410-
using MLPs from `phono3py.pmlp`. After removing the `fc3.hdf5` and `fc2.hdf5`
411-
files, `phono3py-load` will detect `phono3py.pmlp` and then compute the force
412-
constants by loading the MLPs from `phono3py.pmlp` as follows:
409+
Once the file `polymlp.yaml` is obtained, force constants can be calculated
410+
using MLPs from `polymlp.yaml`. After removing the `fc3.hdf5` and `fc2.hdf5`
411+
files, `phono3py-load` will detect `polymlp.yaml` and then compute the force
412+
constants by loading the MLPs from `polymlp.yaml` as follows:
413413

414414
```
415415
% phono3py-load --pypolymlp --rd 100 --amplitude 0.005 phono3py.yaml
@@ -441,7 +441,7 @@ NAC parameters were read from "phono3py.yaml".
441441
Pypolymlp is a generator of polynomial machine learning potentials.
442442
Please cite the paper: A. Seko, J. Appl. Phys. 133, 011101 (2023).
443443
Pypolymlp is developed at https://github.com/sekocha/pypolymlp.
444-
Load MLPs from "phono3py.pmlp".
444+
Load MLPs from "polymlp.yaml".
445445
------------------------------ pypolymlp end -------------------------------
446446
Generate random displacements
447447
Twice of number of snapshots will be generated for plus-minus displacements.
@@ -542,3 +542,14 @@ the next 100 supercells) will be computed and included. With this procedure in
542542
mind, it may be convenient to generate a sufficiently large number of supercells
543543
with random displacements in advance, such as 1000 supercells, before starting
544544
the LTC calculation with pypolymlp.
545+
546+
## Converting `phono3py.pmlp` to `polymlp.yaml`
547+
548+
In older versions, polynomial MLPs were stored in `phono3py.pmlp`. This file can
549+
be converted to `polymlp.yaml` using the following Python snippet.
550+
551+
```python
552+
from pypolymlp.mlp_dev.pypolymlp import Pypolymlp
553+
polymlp = Pypolymlp()
554+
polymlp.convert_to_yaml(filename_txt="phono3py.pmlp", filename_yaml="polymlp.yaml”)
555+
```

phono3py/cui/create_force_constants.py

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ def run_pypolymlp_to_compute_forces(
525525
random_seed: Optional[int] = None,
526526
prepare_dataset: bool = False,
527527
cutoff_pair_distance: Optional[float] = None,
528-
mlp_filename: str = "phono3py.pmlp",
528+
mlp_filename: Optional[str] = None,
529529
log_level: int = 0,
530530
):
531531
"""Run pypolymlp to compute forces."""
@@ -535,27 +535,48 @@ def run_pypolymlp_to_compute_forces(
535535
print("Please cite the paper: A. Seko, J. Appl. Phys. 133, 011101 (2023).")
536536
print("Pypolymlp is developed at https://github.com/sekocha/pypolymlp.")
537537

538-
if pathlib.Path(mlp_filename).exists():
539-
if log_level:
540-
print(f'Load MLPs from "{mlp_filename}".')
541-
ph3py.load_mlp(mlp_filename)
542-
elif forces_in_dataset(ph3py.mlp_dataset):
543-
if log_level:
544-
if mlp_params is None:
545-
pmlp_params = PypolymlpParams()
546-
else:
547-
pmlp_params = parse_mlp_params(mlp_params)
548-
print("Parameters:")
549-
for k, v in asdict(pmlp_params).items():
550-
if v is not None:
551-
print(f" {k}: {v}")
552-
print("Developing MLPs by pypolymlp...", flush=True)
553-
ph3py.develop_mlp(params=mlp_params)
554-
ph3py.save_mlp(filename=mlp_filename)
555-
if log_level:
556-
print(f'MLPs were written into "{mlp_filename}"', flush=True)
557-
else:
558-
raise RuntimeError(f'"{mlp_filename}" is not found.')
538+
mlp_loaded = False
539+
for mlp_filename in ["polymlp.yaml", "phono3py.pmlp"]:
540+
_mlp_filename_list = list(pathlib.Path().glob(f"{mlp_filename}*"))
541+
if _mlp_filename_list:
542+
_mlp_filename = _mlp_filename_list[0]
543+
print(_mlp_filename)
544+
if _mlp_filename.suffix not in [
545+
".yaml",
546+
".pmlp",
547+
".xz",
548+
".gz",
549+
".bz2",
550+
"lzma",
551+
]:
552+
continue
553+
if log_level:
554+
print(f'Load MLPs from "{mlp_filename}".')
555+
ph3py.load_mlp(mlp_filename)
556+
mlp_loaded = True
557+
if log_level and mlp_filename == "phono3py.pmlp":
558+
print(f'Loading MLPs from "{_mlp_filename}" is obsolete.')
559+
break
560+
561+
mlp_filename = "polymlp.yaml"
562+
if not mlp_loaded:
563+
if forces_in_dataset(ph3py.mlp_dataset):
564+
if log_level:
565+
if mlp_params is None:
566+
pmlp_params = PypolymlpParams()
567+
else:
568+
pmlp_params = parse_mlp_params(mlp_params)
569+
print("Parameters:")
570+
for k, v in asdict(pmlp_params).items():
571+
if v is not None:
572+
print(f" {k}: {v}")
573+
print("Developing MLPs by pypolymlp...", flush=True)
574+
ph3py.develop_mlp(params=mlp_params)
575+
ph3py.save_mlp(filename=mlp_filename)
576+
if log_level:
577+
print(f'MLPs were written into "{mlp_filename}"', flush=True)
578+
else:
579+
raise RuntimeError(f'"{mlp_filename}" is not found.')
559580

560581
if log_level:
561582
print("-" * 30 + " pypolymlp end " + "-" * 31, flush=True)

phono3py/cui/phono3py_script.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,7 @@ def main(**argparse_control):
12001200
)
12011201
ph3py.save(mlp_eval_filename)
12021202

1203-
# pypolymlp dataset is stored in "phono3py.pmlp" and stop here.
1203+
# pypolymlp dataset is stored in "polymlp.yaml" and stop here.
12041204
if not prepare_dataset:
12051205
if log_level:
12061206
print(

phono3py/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@
3434
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3535
# POSSIBILITY OF SUCH DAMAGE.
3636

37-
__version__ = "3.14.1"
37+
__version__ = "3.15.0"

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ dependencies = [
1616
"matplotlib",
1717
"h5py",
1818
"spglib",
19-
"phonopy>=2.37.1,<2.38",
19+
"phonopy>=2.38.0,<2.39",
2020
]
21-
license = { file = "LICENSE" }
21+
license = "BSD-3-Clause"
22+
license-files = ["LICENSE"]
2223

2324
[project.urls]
2425
Homepage = "https://phonopy.github.io/phono3py/"

test/cui/test_phono3py_load_script.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ def test_phono3py_with_QE_calculator(load_phono3py_yaml):
122122
def test_phono3py_load_with_pypolymlp_si():
123123
"""Test phono3py-load script with pypolymlp.
124124
125-
First run generates phono3py.pmlp.
126-
Second run uses phono3py.pmlp.
125+
First run generates polymlp.yaml.
126+
Second run uses polymlp.yaml.
127127
128128
"""
129-
pytest.importorskip("pypolymlp")
129+
pytest.importorskip("pypolymlp", minversion="0.9.2")
130130
pytest.importorskip("symfc")
131131

132132
argparse_control = _get_phono3py_load_args(
@@ -159,7 +159,7 @@ def test_phono3py_load_with_pypolymlp_si():
159159
"phono3py.yaml",
160160
"fc2.hdf5",
161161
"fc3.hdf5",
162-
"phono3py.pmlp",
162+
"polymlp.yaml",
163163
"phono3py_mlp_eval_dataset.yaml",
164164
):
165165
file_path = pathlib.Path(cwd_called / created_filename)

0 commit comments

Comments
 (0)