From a7cce8bdc29ded23fc3905dc92d93455dde9f31e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 3 Dec 2024 00:25:12 +0000 Subject: [PATCH 1/4] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.8.0 → v0.8.1](https://github.com/astral-sh/ruff-pre-commit/compare/v0.8.0...v0.8.1) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0617a8ab..a2a8794d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,7 +11,7 @@ repos: exclude: ^example/AlN-LDA/ - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.8.0 + rev: v0.8.1 hooks: - id: ruff args: [ "--fix", "--show-fixes" ] From 7edfadf4bbfe767ba50925a428933dc524101b94 Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Tue, 3 Dec 2024 12:18:29 +0900 Subject: [PATCH 2/4] Fix Phono3py.generate_displacements --- phono3py/api_phono3py.py | 82 ++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 45 deletions(-) diff --git a/phono3py/api_phono3py.py b/phono3py/api_phono3py.py index 8f112e10..a1dc63d4 100644 --- a/phono3py/api_phono3py.py +++ b/phono3py/api_phono3py.py @@ -1231,8 +1231,7 @@ def generate_displacements( is_diagonal: bool = True, number_of_snapshots: Optional[int] = None, random_seed: Optional[int] = None, - is_random_distance: bool = False, - min_distance: Optional[float] = None, + max_distance: Optional[float] = None, ): """Generate displacement dataset in supercell for fc3. @@ -1270,7 +1269,10 @@ def generate_displacements( Parameters ---------- distance : float, optional - Constant displacement Euclidean distance. Default is 0.03. + Constant displacement Euclidean distance. Default is 0.03. For + random direction and random distance displacements generation, this + value is also used as `min_distance`, is used to replace generated + random distances smaller than this value by this value. cutoff_pair_distance : float, optional This is used as a cutoff Euclidean distance to determine if each pair of displacements is considered to calculate fc3 or not. Default @@ -1295,14 +1297,10 @@ def generate_displacements( None. random_seed : int or None, optional Random seed for random displacements generation. Default is None. - is_random_distance : bool, optional - Random direction displacements are generated also with random - amplitudes. The maximum value is defined by `distance` and minimum - value is given by `min_distance`. Default is False. - min_distance : float or None, optional - In random direction displacements generation with random distance - (`is_random_distance=True`), the minimum distance is given by this - value. + max_distance : float or None, optional + In random direction and distance displacements generation, this + value is specified. In random direction and random distance + displacements generation, this value is used as `max_distance`. """ if number_of_snapshots is not None and number_of_snapshots > 0: @@ -1312,8 +1310,7 @@ def generate_displacements( distance=distance, is_plusminus=is_plusminus is True, random_seed=random_seed, - is_random_distance=is_random_distance, - min_distance=min_distance, + max_distance=max_distance, ) else: direction_dataset = get_third_order_displacements( @@ -1342,37 +1339,39 @@ def generate_fc2_displacements( is_diagonal: bool = False, number_of_snapshots: Optional[int] = None, random_seed: Optional[int] = None, - is_random_distance: bool = False, - min_distance: Optional[float] = None, + max_distance: Optional[float] = None, ): """Generate displacement dataset in phonon supercell for fc2. - This systematically generates single atomic displacements - in supercells to calculate phonon_fc2 considering crystal symmetry. - When this method is called, existing cache of supercells with - displacements for fc2 are removed. + This systematically generates single atomic displacements in supercells + to calculate phonon_fc2 considering crystal symmetry. When this method + is called, existing cache of supercells with displacements for fc2 are + removed. Note ---- - is_diagonal=False is chosen as the default setting intentionally - to be consistent to the first displacements of the fc3 pair - displacemets in supercell. + is_diagonal=False is chosen as the default setting intentionally to be + consistent to the first displacements of the fc3 pair displacemets in + supercell. Parameters ---------- distance : float, optional - Constant displacement Euclidean distance. Default is 0.03. + Constant displacement Euclidean distance. Default is 0.03. For + random direction and random distance displacements generation, this + value is also used as `min_distance`, is used to replace generated + random distances smaller than this value by this value. is_plusminus : True, False, or 'auto', optional With True, atomis are displaced in both positive and negative - directions. With False, only one direction. With 'auto', - mostly equivalent to is_plusminus=True, but only one direction - is chosen when the displacements in both directions are - symmetrically equivalent. Default is 'auto'. + directions. With False, only one direction. With 'auto', mostly + equivalent to is_plusminus=True, but only one direction is chosen + when the displacements in both directions are symmetrically + equivalent. Default is 'auto'. is_diagonal : Bool, optional - With False, the displacements are made along the basis - vectors of the supercell. With True, direction not along the basis - vectors can be chosen when the number of the displacements - may be reduced. Default is False. + With False, the displacements are made along the basis vectors of + the supercell. With True, direction not along the basis vectors can + be chosen when the number of the displacements may be reduced. + Default is False. number_of_snapshots : int or None, optional Number of snapshots of supercells with random displacements. Random displacements are generated displacing all atoms in random @@ -1382,14 +1381,10 @@ def generate_fc2_displacements( None. random_seed : int or None, optional Random seed for random displacements generation. Default is None. - is_random_distance : bool, optional - Random direction displacements are generated also with random - amplitudes. The maximum value is defined by `distance` and minimum - value is given by `min_distance`. Default is False. - min_distance : float or None, optional - In random direction displacements generation with random distance - (`is_random_distance=True`), the minimum distance is given by this - value. + max_distance : float or None, optional + In random direction and distance displacements generation, this + value is specified. In random direction and random distance + displacements generation, this value is used as `max_distance`. """ if number_of_snapshots is not None and number_of_snapshots > 0: @@ -1399,8 +1394,7 @@ def generate_fc2_displacements( distance=distance, is_plusminus=is_plusminus is True, random_seed=random_seed, - is_random_distance=is_random_distance, - min_distance=min_distance, + max_distance=max_distance, ) else: phonon_displacement_directions = get_least_displacements( @@ -2649,8 +2643,7 @@ def _generate_random_displacements( distance: float = 0.03, is_plusminus: bool = False, random_seed: Optional[int] = None, - is_random_distance: bool = False, - min_distance: Optional[float] = None, + max_distance: Optional[float] = None, ): if random_seed is not None and random_seed >= 0 and random_seed < 2**32: _random_seed = random_seed @@ -2664,8 +2657,7 @@ def _generate_random_displacements( distance, random_seed=_random_seed, is_plusminus=is_plusminus, - is_random_distance=is_random_distance, - min_distance=min_distance, + max_distance=max_distance, ) dataset["displacements"] = d return dataset From 34c81890b8aa332b3ebc10381ca343766df8b209 Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Fri, 6 Dec 2024 08:23:57 +0900 Subject: [PATCH 3/4] Minor change of MLP command line interface --- phono3py/cui/create_force_constants.py | 13 ++++++------- phono3py/cui/phono3py_script.py | 11 +---------- pyproject.toml | 2 +- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/phono3py/cui/create_force_constants.py b/phono3py/cui/create_force_constants.py index c1a97efa..489e2d61 100644 --- a/phono3py/cui/create_force_constants.py +++ b/phono3py/cui/create_force_constants.py @@ -529,7 +529,11 @@ def run_pypolymlp_to_compute_forces( if v is not None: print(f" {k}: {v}") - if forces_in_dataset(ph3py.mlp_dataset): + if pathlib.Path(mlp_filename).exists(): + if log_level: + print(f'Load MLPs from "{mlp_filename}".') + ph3py.load_mlp(mlp_filename) + elif forces_in_dataset(ph3py.mlp_dataset): if log_level: print("Developing MLPs by pypolymlp...", flush=True) ph3py.develop_mlp(params=mlp_params) @@ -537,12 +541,7 @@ def run_pypolymlp_to_compute_forces( if log_level: print(f'MLPs were written into "{mlp_filename}"', flush=True) else: - if pathlib.Path(mlp_filename).exists(): - if log_level: - print(f'Load MLPs from "{mlp_filename}".') - ph3py.load_mlp(mlp_filename) - else: - raise RuntimeError(f'"{mlp_filename}" is not found.') + raise RuntimeError(f'"{mlp_filename}" is not found.') if log_level: print("-" * 30 + " pypolymlp end " + "-" * 31, flush=True) diff --git a/phono3py/cui/phono3py_script.py b/phono3py/cui/phono3py_script.py index 804aac86..c5d77627 100644 --- a/phono3py/cui/phono3py_script.py +++ b/phono3py/cui/phono3py_script.py @@ -37,7 +37,6 @@ from __future__ import annotations import argparse -import datetime import pathlib import sys from typing import Optional @@ -50,6 +49,7 @@ print_end, print_error, print_error_message, + print_time, print_version, set_magnetic_moments, store_nac_params, @@ -124,15 +124,6 @@ def print_end_phono3py(): print_end() -def print_time(): - """Print current time.""" - print( - "-------------------------" - f'[time {datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")}]' - "-------------------------" - ) - - def finalize_phono3py( phono3py: Phono3py, confs_dict, diff --git a/pyproject.toml b/pyproject.toml index 5836dc48..82400f46 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,7 @@ dependencies = [ "matplotlib>=2.2.2", "h5py>=3.0", "spglib>=2.3", - "phonopy>=2.31,<2.32", + "phonopy>=2.32,<2.33", ] license = { file = "LICENSE" } From 0e272b6beb850235676dafb6d36b4e7b9de3335c Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Fri, 6 Dec 2024 08:29:46 +0900 Subject: [PATCH 4/4] Set version 3.9.0 --- doc/changelog.md | 4 ++++ doc/command-options.md | 4 ++++ doc/conf.py | 4 ++-- phono3py/version.py | 2 +- pyproject.toml | 10 +++++----- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/doc/changelog.md b/doc/changelog.md index dd7516ef..8f68a567 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -2,6 +2,10 @@ # Change Log +## Dec-6-2024: Version 3.9.0 + +- Update to follow the change of phonopy's internal functions + ## Nov-25-2024: Version 3.8.0 - Follow the change due to phonopy's refactoring of MLP interface. diff --git a/doc/command-options.md b/doc/command-options.md index 748a074b..8b603d1f 100644 --- a/doc/command-options.md +++ b/doc/command-options.md @@ -406,6 +406,10 @@ These are shortcuts of `--fc-calc symfc` and `--fc-calc alm`, respectively. Please be careful that `--symfc` and `--sym-fc` (deprecated) are similar, but different. +Refer to the [symfc](https://phonopy.github.io/phonopy/setting-tags.html#symfc) +and [alm](https://phonopy.github.io/phonopy/setting-tags.html#alm) sections in +the Phonopy documentation for additional details. + ## Force constants (compact_fc_option)= diff --git a/doc/conf.py b/doc/conf.py index 8a8a5292..5d421078 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -58,9 +58,9 @@ # built documents. # # The short X.Y version. -version = "3.8" +version = "3.9" # The full version, including alpha/beta/rc tags. -release = "3.8.0" +release = "3.9.0" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/phono3py/version.py b/phono3py/version.py index 23d47634..d2f316b5 100644 --- a/phono3py/version.py +++ b/phono3py/version.py @@ -34,4 +34,4 @@ # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. -__version__ = "3.8.0" +__version__ = "3.9.0" diff --git a/pyproject.toml b/pyproject.toml index 82400f46..910ddb95 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,12 +10,12 @@ description = "This is the phono3py module." authors = [{ name = "Atsushi Togo", email = "atztogo@gmail.com" }] requires-python = ">=3.9" dependencies = [ - "numpy>=1.17.0", + "numpy", "scipy", - "PyYAML>=5.3", - "matplotlib>=2.2.2", - "h5py>=3.0", - "spglib>=2.3", + "PyYAML", + "matplotlib", + "h5py", + "spglib", "phonopy>=2.32,<2.33", ] license = { file = "LICENSE" }