Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
atztogo committed Sep 12, 2024
2 parents 7fac9a3 + 6aafd9c commit 46dda96
Show file tree
Hide file tree
Showing 40 changed files with 1,130 additions and 463 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:
- id: check-added-large-files

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.1
rev: v0.6.4
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

## Sep-12-2024: Version 2.28.0

- Maintenance release including minor fixes and updates.

## Aug-23-2024: Version 2.27.0

- Update for new `SpglibDataset` in spglib v.2.5 (PR #413 by @janosh, #414).
Expand Down
4 changes: 2 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
# built documents.
#
# The short X.Y version.
version = "2.27"
version = "2.28"
# The full version, including alpha/beta/rc tags.
release = "2.27.0"
release = "2.28.0"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
12 changes: 6 additions & 6 deletions doc/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ be different.

### `FORCE_SETS` file creation for VASP

~~~bash
~~~
% phonopy -f vasprun.xml
_
_ __ | |__ ___ _ __ ___ _ __ _ _
Expand All @@ -48,7 +48,7 @@ where `vasprun.xml` is the VASP output.

### DOS

~~~bash
~~~
% phonopy-load --mesh 31 31 31 -p
_
_ __ | |__ ___ _ __ ___ _ __ _ _
Expand Down Expand Up @@ -101,7 +101,7 @@ Summary of calculation was written in "phonopy.yaml".

### Thermal properties

~~~bash
~~~
% phonopy-load --mesh 31 31 31 -t -p
_
_ __ | |__ ___ _ __ ___ _ __ _ _
Expand Down Expand Up @@ -166,7 +166,7 @@ Number of phonon frequencies less than cutoff frequency: 1/178746

This requires to prepare `BORN` file.

~~~bash
~~~
% phonopy-load --band "0.0 0.0 0.0 0.5 0.0 0.0 0.5 0.5 0.0 0.0 0.0 0.0 0.5 0.5 0.5" -p
_
_ __ | |__ ___ _ __ ___ _ __ _ _
Expand Down Expand Up @@ -222,7 +222,7 @@ Summary of calculation was written in "phonopy.yaml".

### PDOS

~~~bash
~~~
% phonopy-load --mesh 41 41 41 --pdos "1, 2" -p
_
_ __ | |__ ___ _ __ ___ _ __ _ _
Expand Down Expand Up @@ -278,7 +278,7 @@ Summary of calculation was written in "phonopy.yaml".

Band structure and DOS or PDOS can be plotted on one figure together by

~~~bash
~~~
% phonopy-load --band "0.0 0.0 0.0 0.5 0.0 0.0 0.5 0.5 0.0 0.0 0.0 0.0 0.5 0.5 0.5" --mesh 41 41 41 --pdos "1, 2" -p
_
_ __ | |__ ___ _ __ ___ _ __ _ _
Expand Down
16 changes: 5 additions & 11 deletions doc/formulation.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
(formulations)=

# Formulations

## Second-order force constants
Expand Down Expand Up @@ -43,7 +42,6 @@ a finite displacement {math}`\Delta r_\alpha{(jl)}` and usually
{math}`F_\beta(j'l') \equiv 0`.

(force_constants_solver_theory)=

## Modified Parlinski-Li-Kawazoe method

The following is a modified and simplified version of the Parlinski-Li-Kawazoe
Expand Down Expand Up @@ -118,7 +116,6 @@ where the superscript with parenthesis gives the index of site-symmetry
operations. This is solved by pseudo inverse.

(dynacmial_matrix_theory)=

## Dynamical matrix

In phonopy, a phase convention of dynamical matrix is used as follows:
Expand Down Expand Up @@ -162,7 +159,6 @@ annihilation operators of phonon, {math}`\hbar` is the reduced Planck constant,
and {math}`t` is the time.

(non_analytical_term_correction_theory)=

## Non-analytical term correction

To treat long range interaction of macroscopic electric field induced by
Expand All @@ -180,12 +176,12 @@ D_{\alpha\beta}(jj',\mathbf{q}=\mathbf{0}) + \frac{1}{\sqrt{m_j m_{j'}}}
{\sum_{\alpha\beta}q_{\alpha}\epsilon_{\alpha\beta}^{\infty} q_{\beta}}.
```

Phonon frequencies at general **q**-points with long-range dipole-dipole
interaction are calculated by the method of Gonze _et al._
({ref}`reference_dp_dp_NAC`).
where {math}`\Omega_0` is the unit cell volume. See more details about the
physical units at {ref}`physical_unit_conversion`. Phonon frequencies at general
**q**-points with long-range dipole-dipole interaction are calculated by the
method of Gonze _et al._ ({ref}`reference_dp_dp_NAC`).

(thermal_properties_expressions)=

## Thermodynamic properties

### Phonon number
Expand Down Expand Up @@ -399,7 +395,6 @@ difference is employed, and {math}`+\Delta q_\alpha` and
`GV_DELTA_Q` tag.

(physical_unit_conversion)=

## Physical unit conversion

Phonopy calculates phonon frequencies based on input values from users. In the
Expand Down Expand Up @@ -449,8 +444,6 @@ In the default case of the Wien2k interface, the conversion factor is
the conversion factors are similarly calculated following the unit systems
employed in phonopy ({ref}`calculator_interfaces`).

(definition_of_commensurate_points)=

## Crystal structure

### Coordinates in direct and reciprocal spaces
Expand Down Expand Up @@ -502,6 +495,7 @@ written at {ref}`primitive_axes_tag`, therefore
those calculated following Eq. {eq}`eq_rec_basis_vectors` with this
{math}`( \mathbf{a} \; \mathbf{b} \; \mathbf{c})`.

(definition_of_commensurate_points)=
### Commensurate points

In phonopy, so-called commensurate points mean the q-points whose waves are
Expand Down
2 changes: 1 addition & 1 deletion doc/output-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ with open("band.yaml") as f:
- Phonon frequency in a specified unit at each phonon mode
* - eigenvector
- Eigenvector at each phonon mode.
Each eigenvector :math:`\mathbf{e}` of
Each eigenvector {math}`\mathbf{e}` of
{ref}`dynamical matrix <dynacmial_matrix_theory>`
is shown as sets of three
complex values of each atom along the Cartesian axes in
Expand Down
2 changes: 1 addition & 1 deletion doc/phonopy-module.md
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ phonon.run_mesh([20, 20, 20], with_group_velocities=True)
```

The first argument of `run_mesh()` can be a float value, which is a length
measure as explained at {ref}`mehs_tag`, for example:
measure as explained at {ref}`mesh_tag`, for example:

```python
phonon.run_mesh(100.0)
Expand Down
12 changes: 11 additions & 1 deletion doc/qe.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ More tags may be supported on request.
nat, ntyp, celldm(1), ATOMIC_SPECIES, ATOMIC_POSITIONS, CELL_PARAMETERS
```

Chemical symbols with natural number for `ATOMIC_SPECIES` like `Xn` (`n>0`),
e.g.. `Fe1`, can be used. The formats of `X_*` and `X-*` are not supported. When
this extended symbol is used, masses of all atoms including usual chemical
symbols are read from QE structure file. Otherwise, masses of respective
chemical symbols implemented in phonopy are used. Note that when using the
extended symbol, if the unit cell of QE structure file is not a primitive cell,
and the primitive cell is defined by the transformation matrix (`PRIMITIVE_AXES`
tag or `--pa` option), atoms with the extended symbols in the unit cell have to
be mapped properly to those in the primitive cell.

## How to run

The procedure of QE-phonopy calculation is shown below using the
Expand Down Expand Up @@ -331,7 +341,7 @@ Saving this script as `make_born_q2r.py`,
#### NaCl example

NaCl example is found at
https://github.com/phonopy/phonopy/tree/master/example/NaCl-QE-q2r.
<https://github.com/phonopy/phonopy/tree/master/example/NaCl-QE-q2r>.

```bash
% phonopy --qe -c NaCl.in --dim="8 8 8" --band="0 0 0 1/2 0 0 1/2 1/2 0 0 0 0 1/2 1/2 1/2" --readfc --readfc-format=hdf5 --fc-symmetry --nac -p
Expand Down
2 changes: 1 addition & 1 deletion doc/vasp-dfpt.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ procedure to calculate phonon properties may be as follows:

6) Run phonopy

~~~bash
~~~
% phonopy-load --readfc --band "0.0 0.0 0.0 0.5 0.0 0.0 0.5 0.5 0.0 0.0 0.0 0.0 0.5 0.5 0.5" -p
_
Expand Down
49 changes: 23 additions & 26 deletions phonopy/api_phonopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@
from phonopy.interface.fc_calculator import get_fc2
from phonopy.interface.phonopy_yaml import PhonopyYaml
from phonopy.interface.pypolymlp import (
PypolymlpData,
PypolymlpParams,
develop_polymlp,
develop_mlp_by_pypolymlp,
evalulate_polymlp,
load_polymlp,
)
from phonopy.phonon.animation import write_animation
from phonopy.phonon.band_structure import BandStructure, get_band_qpoints_by_seekpath
Expand Down Expand Up @@ -189,7 +189,7 @@ def __init__(
self._log_level = log_level

# Create supercell and primitive cell
self._unitcell = PhonopyAtoms(atoms=unitcell)
self._unitcell = unitcell.copy()
self._supercell_matrix = self._shape_supercell_matrix(supercell_matrix)
if isinstance(primitive_matrix, str):
self._primitive_matrix = self._set_primitive_matrix(primitive_matrix)
Expand Down Expand Up @@ -1242,44 +1242,41 @@ def symmetrize_force_constants_by_space_group(self, show_drift=True) -> None:
if self._primitive.masses is not None:
self._set_dynamical_matrix()

def develop_mlp(self, params: Optional[Union[PypolymlpParams, dict]] = None):
def develop_mlp(
self,
params: Optional[Union[PypolymlpParams, dict, str]] = None,
test_size: float = 0.1,
):
"""Develop MLP of pypolymlp.
Parameters
----------
params : PypolymlpParams or dict, optional
Parameters for developing MLP. Default is None. When dict is given,
PypolymlpParams instance is created from the dict.
test_size : float, optional
Training and test data are splitted by this ratio. test_size=0.1
means the first 90% of the data is used for training and the rest
is used for test. Default is 0.1.
"""
if self._mlp_dataset is None:
raise RuntimeError("MLP dataset is not set.")

if isinstance(params, dict):
_params = PypolymlpParams(**params)
else:
_params = params

disps = self._mlp_dataset["displacements"]
forces = self._mlp_dataset["forces"]
energies = self._mlp_dataset["supercell_energies"]
n = int(len(disps) * 0.9)
train_data = PypolymlpData(
displacements=disps[:n], forces=forces[:n], supercell_energies=energies[:n]
)
test_data = PypolymlpData(
displacements=disps[n:], forces=forces[n:], supercell_energies=energies[n:]
)
self._mlp = develop_polymlp(
self._mlp = develop_mlp_by_pypolymlp(
self._mlp_dataset,
self._supercell,
train_data,
test_data,
params=_params,
verbose=self._log_level - 1 > 0,
params=params,
test_size=test_size,
log_level=self._log_level,
)

def load_mlp(self, filename: str = "phonopy.pmlp"):
"""Load machine learning potential of pypolymlp."""
self._mlp = load_polymlp(filename=filename)

def evaluate_mlp(self):
"""Evaluate the machine learning potential of pypolymlp.
"""Evaluate machine learning potential of pypolymlp.
This method calculates the supercell energies and forces from the MLP
for the displacements in self._dataset of type 2. The results are stored
Expand Down Expand Up @@ -4002,7 +3999,7 @@ def _build_supercells_with_displacements(self) -> None:
for positions in all_positions:
supercells.append(
PhonopyAtoms(
numbers=self._supercell.numbers,
symbols=self._supercell.symbols,
masses=self._supercell.masses,
magnetic_moments=self._supercell.magnetic_moments,
positions=positions,
Expand Down
2 changes: 1 addition & 1 deletion phonopy/cui/collect_cell_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def collect_cell_info(
enforce_primitive_matrix_auto=False,
phonopy_yaml_cls: type[PhonopyYaml] = PhonopyYaml,
load_phonopy_yaml: bool = False,
):
) -> dict:
"""Collect crystal structure information from input file and parameters.
This function returns crystal structure information obtained from an input
Expand Down
Loading

0 comments on commit 46dda96

Please sign in to comment.