Skip to content

Commit

Permalink
Merge branch 'develop' into publish-gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
atztogo committed Dec 5, 2024
2 parents 1106bbd + b052a5d commit c7780df
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 72 deletions.
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.8.0
rev: v0.8.1
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

## 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.
Expand Down
4 changes: 4 additions & 0 deletions doc/command-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)=
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.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.
Expand Down
82 changes: 37 additions & 45 deletions phono3py/api_phono3py.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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(
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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(
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
13 changes: 6 additions & 7 deletions phono3py/cui/create_force_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,20 +529,19 @@ 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)
ph3py.save_mlp(filename=mlp_filename)
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)
Expand Down
11 changes: 1 addition & 10 deletions phono3py/cui/phono3py_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
from __future__ import annotations

import argparse
import datetime
import pathlib
import sys
from typing import Optional
Expand All @@ -50,6 +49,7 @@
print_end,
print_error,
print_error_message,
print_time,
print_version,
set_magnetic_moments,
store_nac_params,
Expand Down Expand Up @@ -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,
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.8.0"
__version__ = "3.9.0"
12 changes: 6 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ description = "This is the phono3py module."
authors = [{ name = "Atsushi Togo", email = "[email protected]" }]
requires-python = ">=3.9"
dependencies = [
"numpy>=1.17.0",
"numpy",
"scipy",
"PyYAML>=5.3",
"matplotlib>=2.2.2",
"h5py>=3.0",
"spglib>=2.3",
"phonopy>=2.31,<2.32",
"PyYAML",
"matplotlib",
"h5py",
"spglib",
"phonopy>=2.32,<2.33",
]
license = { file = "LICENSE" }

Expand Down

0 comments on commit c7780df

Please sign in to comment.