Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:phonopy/phono3py into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
atztogo committed Jan 13, 2025
2 parents 5146070 + 2afef35 commit d5f48c0
Show file tree
Hide file tree
Showing 12 changed files with 155 additions and 41 deletions.
6 changes: 6 additions & 0 deletions doc/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

# Change Log

## Jan-12-2024: Version 3.11.1

- `-i`, `-o`, `--io` options have been deprecated.
- The `--amplitude` option can now be used to specify the displacement distance
for `phono3py-load --pypolymlp`.

## Jan-2-2024: Version 3.11.0

- Release to follow the change of phonopy
Expand Down
8 changes: 5 additions & 3 deletions doc/command-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -1358,8 +1358,11 @@ 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>).

(output_filename_option)=
### `-o`, `-i`, `--io`

These options are deprecated.

<!-- (output_filename_option)=
### `-o` (command option only)
This modifies default output file names to write.
Expand All @@ -1378,7 +1381,6 @@ This rule is applied to
* `gamma_detail-xxx.hdf5` (write only)
(input_filename_option)=

### `-i` (command option only)
This modifies default input file names to read.
Expand All @@ -1399,7 +1401,7 @@ This rule is applied to
This modifies default input and output file names.
This is equivalent to setting `-i` and `-o` simultaneously.
This is equivalent to setting `-i` and `-o` simultaneously. -->

<!-- ## References
Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
# The short X.Y version.
version = "3.11"
# The full version, including alpha/beta/rc tags.
release = "3.11.0"
release = "3.11.1"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
1 change: 0 additions & 1 deletion doc/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ removed.
If phono3py is compiled with a special compiler or special options, manual
modification of `CMakeLists.txt` may be needed.

- {ref}`OpenMP library <install_openmp>`: For the multithreding support.
- {ref}`Linear algebra library <install_lapacke>`: BLAS, LAPACK, and LAPACKE
(optional, see {ref}`install_with_lapacke`)

Expand Down
87 changes: 85 additions & 2 deletions doc/pypolymlp.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ 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 MMLPs was written in "phono3py_mlp_eval_dataset.yaml".
Dataset generated using MLPs was written in "phono3py_mlp_eval_dataset.yaml".
Summary of calculation was written in "phono3py.yaml".
-------------------------[time 2024-09-19 15:21:41]-------------------------
_
Expand Down Expand Up @@ -334,7 +334,7 @@ Max drift of fc2: 0.000000 (xx) 0.000000 (xx)
fc3 was written into "fc3.hdf5".
fc2 was written into "fc2.hdf5".
----------- None of ph-ph interaction calculation was performed. -----------
Dataset generated using MMLPs was written in "phono3py_mlp_eval_dataset.yaml".
Dataset generated using MLPs was written in "phono3py_mlp_eval_dataset.yaml".
Summary of calculation was written in "phono3py.yaml".
-------------------------[time 2024-09-19 15:34:41]-------------------------
_
Expand All @@ -353,6 +353,89 @@ 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`
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. Additionally, when using
`--rd`, the `--symfc` option must be used together. If `--rd` is omitted,
systematic displacements are introduced, and thus `--symfc` is not required.

Once the file `phono3py.pmlp` is obtained, force constants can be calculated
using MLPs from `phono3py.pmlp`. After removing the `fc3.hdf5` and `fc2.hdf5`
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 --symfc --amplitude 0.01 phono3py.yaml
_ _____
_ __ | |__ ___ _ __ ___|___ / _ __ _ _
| '_ \| '_ \ / _ \| '_ \ / _ \ |_ \| '_ \| | | |
| |_) | | | | (_) | | | | (_) |__) | |_) | |_| |
| .__/|_| |_|\___/|_| |_|\___/____/| .__/ \__, |
|_| |_| |___/
3.11.1-dev14+g5f281b65
-------------------------[time 2025-01-12 10:08:31]-------------------------
Compiled with OpenMP support (max 10 threads).
Running in phono3py.load mode.
Python version 3.12.3
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".
----------------------------- Force constants ------------------------------
----------------------------- 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.01
Evaluate forces in 200 supercells by pypolymlp
-------------------------------- Symfc start -------------------------------
Symfc is a force constants calculator. See the following paper:
A. Seko and A. Togo, Phys. Rev. B, 110, 214302 (2024).
Symfc is developed at https://github.com/symfc/symfc.
Computing [2, 3] order force constants.
Increase log-level to watch detailed symfc log.
--------------------------------- Symfc end --------------------------------
-------------------------------- Symfc start -------------------------------
Symfc is a force constants calculator. See the following paper:
A. Seko and A. Togo, Phys. Rev. B, 110, 214302 (2024).
Symfc is developed at https://github.com/symfc/symfc.
Computing [2] order force constants.
Increase log-level to watch detailed symfc log.
--------------------------------- Symfc end --------------------------------
Max drift of fc3: -0.000000 (zxz) -0.000000 (xzz) -0.000000 (xzz)
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".
Summary of calculation was written in "phono3py.yaml".
-------------------------[time 2025-01-12 10:08:40]-------------------------
_
___ _ __ __| |
/ _ \ '_ \ / _` |
| __/ | | | (_| |
\___|_| |_|\__,_|
```


## Parameters for developing MLPs

A few parameters can be specified using the `--mlp-params` option for the
Expand Down
12 changes: 5 additions & 7 deletions doc/workload-distribution.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,11 @@ indices are chosen and executed as follows:
% phono3py-load --mesh 19 19 19 --br --gp "0,1,2,3,4,5,6,7,8,9,20,21,22,23,24,25" --write-gamma
```

Then many `kappa-m191919-gx.hdf5` files are generated. These file
names should not be altered because in reading the data by phono3py,
those file names are supposed to be so, though there is a little
freedom to arrange those file names, for which see {ref}`-o <output_filename_option>` and {ref}`-i <input_filename_option>`
options. After completing calculations for all irreducible grid-point
indices, the RTA thermal conductivity is computed by another run in a
short time from the stored data:
Then many `kappa-m191919-gx.hdf5` files are generated. These file names should
not be altered because in reading the data by phono3py, those file names are
supposed to be so. After completing calculations for all irreducible grid-point
indices, the RTA thermal conductivity is computed by another run in a short time
from the stored data:

```bash
% phono3py-load --mesh 19 19 19 --br --read-gamma
Expand Down
22 changes: 18 additions & 4 deletions phono3py/api_phono3py.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from __future__ import annotations

import copy
import warnings
from collections.abc import Sequence
from typing import Literal, Optional, Union

Expand Down Expand Up @@ -2091,13 +2092,26 @@ def run_thermal_conductivity(
When writing results into files in hdf5, large data are compressed
by this options. See the detail at h5py documentation.
input_filename : str, optional, default is None
When specified, the string is inserted before filename extension
in reading files.
Deprecated. When specified, the string is inserted before filename
extension in reading files.
output_filename : str, optional, default is None
When specified, the string is inserted before filename extension
in writing files.
Deprecated. When specified, the string is inserted before filename
extension in writing files.
"""
if input_filename is not None:
warnings.warn(
"input_filename parameter is deprecated.",
DeprecationWarning,
stacklevel=2,
)
if output_filename is not None:
warnings.warn(
"output_filename parameter is deprecated.",
DeprecationWarning,
stacklevel=2,
)

if self._interaction is None:
msg = (
"Phono3py.init_phph_interaction has to be called "
Expand Down
28 changes: 12 additions & 16 deletions phono3py/cui/phono3py_argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,15 @@ def get_parser(fc_symmetry=False, is_nac=False, load_phono3py_yaml=False):
dest="use_alm",
action="store_true",
default=False,
help=("Use ALM for generating 2nd and 3rd force constants " "in one fitting"),
help=("Use ALM for generating 2nd and 3rd force constants in one fitting"),
)
parser.add_argument(
"--amplitude",
dest="displacement_distance",
type=float,
default=None,
help="Distance of displacements",
)
if not load_phono3py_yaml:
parser.add_argument(
"--amplitude",
dest="displacement_distance",
type=float,
default=None,
help="Distance of displacements",
)
parser.add_argument(
"--ave-pp",
dest="use_ave_pp",
Expand Down Expand Up @@ -106,8 +105,7 @@ def get_parser(fc_symmetry=False, is_nac=False, load_phono3py_yaml=False):
type=float,
default=None,
help=(
"Boundary mean free path in micrometre for thermal conductivity "
"calculation"
"Boundary mean free path in micrometre for thermal conductivity calculation"
),
)
parser.add_argument(
Expand Down Expand Up @@ -429,8 +427,7 @@ def get_parser(fc_symmetry=False, is_nac=False, load_phono3py_yaml=False):
action="store_true",
default=False,
help=(
"Atoms are clamped under applied strain in Gruneisen parameter "
"calculation"
"Atoms are clamped under applied strain in Gruneisen parameter calculation"
),
)
parser.add_argument(
Expand Down Expand Up @@ -747,7 +744,7 @@ def get_parser(fc_symmetry=False, is_nac=False, load_phono3py_yaml=False):
dest="scattering_event_class",
type=int,
default=None,
help=("Scattering event class 1 or 2 to draw imaginary part of self " "energy"),
help=("Scattering event class 1 or 2 to draw imaginary part of self energy"),
)
parser.add_argument(
"--sigma",
Expand Down Expand Up @@ -787,8 +784,7 @@ def get_parser(fc_symmetry=False, is_nac=False, load_phono3py_yaml=False):
action="store_true",
default=False,
help=(
"Show reduced number of triplets to be calculated at "
"specified grid points"
"Show reduced number of triplets to be calculated at specified grid points"
),
)
if not load_phono3py_yaml:
Expand Down
24 changes: 20 additions & 4 deletions phono3py/cui/phono3py_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import argparse
import pathlib
import sys
import warnings
from typing import Optional

import numpy as np
Expand Down Expand Up @@ -154,12 +155,10 @@ def finalize_phono3py(
else:
yaml_filename = filename

if phono3py.mlp_dataset is not None:
if phono3py.mlp is not None and phono3py.dataset is not None:
mlp_eval_filename = "phono3py_mlp_eval_dataset.yaml"
if log_level:
print(
f'Dataset generated using MMLPs was written in "{mlp_eval_filename}".'
)
print(f'Dataset generated using MLPs was written in "{mlp_eval_filename}".')
phono3py.save(mlp_eval_filename)

_physical_units = get_default_physical_units(phono3py.calculator)
Expand Down Expand Up @@ -307,9 +306,26 @@ def read_phono3py_settings(args, argparse_control, log_level):

def get_input_output_filenames_from_args(args):
"""Return strings inserted to input and output filenames."""
if args.input_filename is not None:
warnings.warn(
"-i option is deprecated and will be removed soon.",
DeprecationWarning,
stacklevel=2,
)
input_filename = args.input_filename
if args.output_filename is not None:
warnings.warn(
"-o option is deprecated and will be removed soon.",
DeprecationWarning,
stacklevel=2,
)
output_filename = args.output_filename
if args.input_output_filename is not None:
warnings.warn(
"--io option is deprecated and will be removed soon.",
DeprecationWarning,
stacklevel=2,
)
input_filename = args.input_output_filename
output_filename = args.input_output_filename
return input_filename, output_filename
Expand Down
2 changes: 1 addition & 1 deletion phono3py/cui/show_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def show_general_settings(

print("-" * 29 + " General settings " + "-" * 29)
if run_mode:
print("Run mode: {run_mode}")
print(f"Run mode: {run_mode}")
if output_filename:
print(f"Output filename is modified by {output_filename}.")
if input_filename:
Expand Down
2 changes: 1 addition & 1 deletion phono3py/interface/phono3py_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ def _displacements_yaml_lines_type1_info(dataset):
# 'duplicates' is dict, but written as a list of list in yaml.
# See the docstring of _parse_fc3_dataset for the reason.
if "duplicates" in dataset and dataset["duplicates"]:
lines.append(" duplicated_supercell_ids: " "# 0 means perfect supercell")
lines.append(" duplicated_supercell_ids: # 0 means perfect supercell")
# Backward compatibility for dict type
if isinstance(dataset["duplicates"], dict):
for disp1_id, j in dataset["duplicates"].items():
Expand Down
2 changes: 1 addition & 1 deletion phono3py/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

__version__ = "3.11.0"
__version__ = "3.11.1"

0 comments on commit d5f48c0

Please sign in to comment.