diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index eebc7b06..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.7.4 + rev: v0.8.1 hooks: - id: ruff args: [ "--fix", "--show-fixes" ] 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/doc/install.md b/doc/install.md index 13c965f3..6ff25900 100644 --- a/doc/install.md +++ b/doc/install.md @@ -61,6 +61,7 @@ See an example at {ref}`install_an_example`. In the standard output, flags and libraries found by cmake are shown. Please carefully check if those configurations are expected ones or not. +(install_without_lapacke)= ### Building without linking LAPACKE **Experimental** @@ -118,7 +119,14 @@ wrong python libraries can be imported. For x86-64 system: ```bash - % conda install numpy scipy h5py pyyaml matplotlib-base c-compiler cxx-compiler "libblas=*=*mkl" spglib mkl-include cmake + % conda install numpy scipy h5py pyyaml matplotlib-base c-compiler cxx-compiler cmake spglib + ``` + + Unless {ref}`install_without_lapacke`, the following packages will be + necessary to compile phono3py: + + ```bash + % conda install "libblas=*=*mkl" mkl-include ``` A libblas library can be chosen among `[openblas, mkl, blis, netlib]`. If @@ -128,20 +136,21 @@ wrong python libraries can be imported. % conda install "libblas=*=*openblas" ``` - For macOS ARM64 system, currently only openblas can be chosen: + For macOS ARM64 system: ```bash - % conda install numpy scipy h5py pyyaml matplotlib-base c-compiler cxx-compiler spglib cmake openblas + % conda install numpy scipy h5py pyyaml matplotlib-base c-compiler cxx-compiler spglib cmake ``` - Note that using hdf5 files on NFS mounted file system, you may have to disable - file locking by setting + Unless {ref}`install_without_lapacke`, the following package will be + necessary to compile phono3py: ```bash - export HDF5_USE_FILE_LOCKING=FALSE + % conda install openblas ``` - Install the latest phonopy and phono3py from github sources: + The latest phonopy and phono3py are obtained from github, and they are + compiled and installed by: ```bash % mkdir dev @@ -154,20 +163,29 @@ wrong python libraries can be imported. % pip install . -vvv ``` - The editable install (`pip install -e`) may not work depending on the - computer environment. The conda packages dependency can often change and this - recipe may not work properly. So if you find this instruction doesn't work, - it is very appreciated if letting us know it in the phonopy mailing list. +## Dependent libraries + +### OpenMP + +#### GCC on Ubuntu + +With system provided gcc, `libgomp1` may be necessary to enable OpenMP +multithreading support. This library is probably installed already in your +system. If you don't have it and you use Ubuntu linux, it is installed by: + +```bash +% sudo apt-get install libgomp1 +``` (install_lapacke)= -## Installation of LAPACKE +### LAPACKE LAPACK library is used in a few parts of the code to diagonalize matrices. LAPACK*E* is the C-wrapper of LAPACK and LAPACK relies on BLAS. Both single-thread or multithread BLAS can be used in phono3py. In the following, multiple different ways of installation of LAPACKE are explained. -### OpenBLAS provided by conda +#### OpenBLAS provided by conda The installation of LAPACKE is easy by conda. It is: @@ -175,7 +193,7 @@ The installation of LAPACKE is easy by conda. It is: % conda install -c conda-forge openblas ``` -### Netlib LAPACKE provided by Ubuntu package manager (with single-thread BLAS) +#### Netlib LAPACKE provided by Ubuntu package manager (with single-thread BLAS) LAPACKE (http://www.netlib.org/lapack/lapacke.html) can be installed from the Ubuntu package manager (`liblapacke` and `liblapacke-dev`): @@ -184,7 +202,17 @@ Ubuntu package manager (`liblapacke` and `liblapacke-dev`): % sudo apt-get install liblapack-dev liblapacke-dev ``` -(install_openmp)= +## Using HDF5 files on NFS mounted file system + +If you are using HDF5 files on an NFS-mounted file system, you might need to +disable file locking. This can be done by setting the following environment +variable: + +```bash +export HDF5_USE_FILE_LOCKING=FALSE +``` + + ## Trouble shooting 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 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/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 5836dc48..910ddb95 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,13 +10,13 @@ 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", - "phonopy>=2.31,<2.32", + "PyYAML", + "matplotlib", + "h5py", + "spglib", + "phonopy>=2.32,<2.33", ] license = { file = "LICENSE" }