Skip to content

Commit

Permalink
Merge branch 'develop' into rc
Browse files Browse the repository at this point in the history
  • Loading branch information
atztogo committed Dec 5, 2024
2 parents 56de0fe + 354cd97 commit ddb7b32
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 98 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.7.4
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
70 changes: 44 additions & 26 deletions doc/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -154,28 +163,37 @@ 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:

```bash
% 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`):
Expand All @@ -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
```

<!-- (install_openmp)=
## Multithreading and its controlling by C macro
Phono3py uses multithreading concurrency in two ways. One is that written in the
Expand All @@ -201,17 +229,7 @@ be deactivated at the compilation time. This is achieved by setting the C macro
`MULTITHREADED_BLAS`, which can be written in `CMakeLists.txt`. Deactivating the
multithreading of BLAS using the environment variables is not recommended
because it is also used in the non-nested parts of the code and these
multithreadings are unnecessary to be deactivated.

### OpenMP library of gcc

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
```
multithreadings are unnecessary to be deactivated. -->

## Trouble shooting

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
Loading

0 comments on commit ddb7b32

Please sign in to comment.