Skip to content

Commit

Permalink
Merge branch 'rc'
Browse files Browse the repository at this point in the history
  • Loading branch information
atztogo committed Jun 6, 2024
2 parents a0f886b + 44f43c1 commit e3478ca
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ repos:
name: isort (python)

- repo: https://github.com/Takishima/cmake-pre-commit-hooks
rev: v1.9.5
rev: v1.9.6
hooks:
- id: clang-format
args:
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

## Jun-7-2024: Version 3.0.4

- Bug fix when handling different supercell size of fc2 than that of fc3.

## May-4-2024: Version 3.0.3

- Release to follow the update of phonopy.
Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
# The short X.Y version.
version = "3.0"
# The full version, including alpha/beta/rc tags.
release = "3.0.3"
release = "3.0.4"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
8 changes: 7 additions & 1 deletion doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ Papers that may introduce phono3py:
<http://dx.doi.org/10.1103/PhysRevB.91.094306> (arxiv
<http://arxiv.org/abs/1501.00691>).
- Introduction to phono3py application:
<https://doi.org/10.1103/PhysRevB.97.224306> (open access).
<https://journals.jps.jp/doi/10.7566/JPSJ.92.012001> (open access),
and phono3py inputs for 103 compounds found in Fig.17
<https://github.com/atztogo/phonondb/blob/main/mdr/phono3py_103compounds_fd/README.md>
- Implementation of phono3py:
<https://iopscience.iop.org/article/10.1088/1361-648X/acd831> (open access)

A set of pre-calculated data for phono3py in

```{image} Si-kaccum.png
:width: 20%
Expand Down
32 changes: 19 additions & 13 deletions phono3py/cui/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from __future__ import annotations

import os
import pathlib
from collections.abc import Sequence
from typing import Optional, Union

Expand Down Expand Up @@ -390,14 +391,13 @@ def set_dataset_and_force_constants(
cutoff_pair_distance=cutoff_pair_distance,
log_level=log_level,
)
if ph3py.phonon_supercell_matrix is not None:
read_fc["fc2"] = _set_dataset_phonon_dataset_or_fc2(
ph3py,
ph3py_yaml=ph3py_yaml,
fc2_filename=fc2_filename,
forces_fc2_filename=forces_fc2_filename,
log_level=log_level,
)
read_fc["fc2"] = _set_dataset_phonon_dataset_or_fc2(
ph3py,
ph3py_yaml=ph3py_yaml,
fc2_filename=fc2_filename,
forces_fc2_filename=forces_fc2_filename,
log_level=log_level,
)

# Cases that dataset is in phono3py.yaml but not forces.
if ph3py.dataset is None:
Expand Down Expand Up @@ -487,14 +487,14 @@ def _set_dataset_or_fc3(
cutoff_pair_distance,
log_level,
)
elif os.path.isfile("fc3.hdf5"):
elif pathlib.Path("fc3.hdf5").exists():
fc3 = read_fc3_from_hdf5(filename="fc3.hdf5", p2s_map=p2s_map)
_check_fc3_shape(ph3py, fc3)
ph3py.fc3 = fc3
read_fc3 = True
if log_level:
print('fc3 was read from "fc3.hdf5".')
elif os.path.isfile("FORCES_FC3"):
elif pathlib.Path("FORCES_FC3").exists():
_set_dataset_for_fc3(
ph3py,
ph3py_yaml,
Expand Down Expand Up @@ -544,14 +544,17 @@ def _set_dataset_phonon_dataset_or_fc2(
"phonon_fc2",
log_level,
)
elif os.path.isfile("fc2.hdf5"):
elif pathlib.Path("fc2.hdf5").exists():
fc2 = read_fc2_from_hdf5(filename="fc2.hdf5", p2s_map=phonon_p2s_map)
_check_fc2_shape(ph3py, fc2)
ph3py.fc2 = fc2
read_fc2 = True
if log_level:
print('fc2 was read from "fc2.hdf5".')
elif os.path.isfile("FORCES_FC2"):
elif (
pathlib.Path("FORCES_FC2").exists()
and ph3py.phonon_supercell_matrix is not None
):
_set_dataset_for_fc2(
ph3py,
ph3py_yaml,
Expand Down Expand Up @@ -583,7 +586,10 @@ def _set_dataset_phonon_dataset_or_fc2(
"fc2",
log_level,
)
elif os.path.isfile("FORCES_FC3"):
elif (
pathlib.Path("FORCES_FC3").exists()
and ph3py.phonon_supercell_matrix is not None
):
# suppose fc3.hdf5 is read but fc2.hdf5 doesn't exist.
_set_dataset_for_fc2(
ph3py,
Expand Down
43 changes: 21 additions & 22 deletions phono3py/interface/phono3py_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
import numpy as np
from phonopy.interface.phonopy_yaml import (
PhonopyYaml,
PhonopyYamlDumper,
PhonopyYamlLoader,
PhonopyYamlDumperBase,
PhonopyYamlLoaderBase,
load_yaml,
phonopy_yaml_property_factory,
)
Expand Down Expand Up @@ -82,7 +82,7 @@ class Phono3pyYamlData:
phonon_primitive: Optional[Primitive] = None


class Phono3pyYamlLoader(PhonopyYamlLoader):
class Phono3pyYamlLoader(PhonopyYamlLoaderBase):
"""Phono3pyYaml loader."""

def __init__(
Expand Down Expand Up @@ -115,18 +115,18 @@ def _parse_all_cells(self):
"""
super()._parse_all_cells()
if "phonon_primitive_cell" in self._yaml:
self._data.phonon_primitive = self._parse_cell(
self._yaml["phonon_primitive_cell"]
)
if "phonon_supercell" in self._yaml:
self._data.phonon_supercell = self._parse_cell(
self._yaml["phonon_supercell"]
)
if "phonon_supercell_matrix" in self._yaml:
self._data.phonon_supercell_matrix = np.array(
self._yaml["phonon_supercell_matrix"], dtype="intc", order="C"
)
if "phonon_primitive_cell" in self._yaml:
self._data.phonon_primitive = self._parse_cell(
self._yaml["phonon_primitive_cell"]
)
if "phonon_supercell" in self._yaml:
self._data.phonon_supercell = self._parse_cell(
self._yaml["phonon_supercell"]
)

def _parse_dataset(self):
"""Parse phonon_dataset.
Expand All @@ -137,8 +137,6 @@ def _parse_dataset(self):
self._data.phonon_dataset = self._get_dataset(
self._data.phonon_supercell, key_prefix="phonon_"
)
if self._data.phonon_dataset is None:
self._data.phonon_dataset = self._get_dataset(self._data.phonon_supercell)

def _parse_fc3_dataset(self):
"""Parse force dataset for fc3.
Expand Down Expand Up @@ -168,7 +166,7 @@ def _parse_fc3_dataset(self):
self._data.dataset = dataset

# This case should work only for v2.2 or later.
if self._data.dataset is None and "displacements" in self._yaml:
if self._data.dataset is None:
self._data.dataset = self._get_dataset(self._data.supercell)

def _parse_fc3_dataset_type1(self, natom):
Expand Down Expand Up @@ -263,7 +261,7 @@ def _parse_fc3_dataset_type1_without_forces(self, data1, d2, disp2_id):
return disp2_id


class Phono3pyYamlDumper(PhonopyYamlDumper):
class Phono3pyYamlDumper(PhonopyYamlDumperBase):
"""Phono3pyYaml dumper."""

_default_dumper_settings = {
Expand All @@ -286,13 +284,14 @@ def _cell_info_yaml_lines(self):
"""
lines = super()._cell_info_yaml_lines()
lines += self._supercell_matrix_yaml_lines(
self._data.phonon_supercell_matrix, "phonon_supercell_matrix"
)
lines += self._primitive_yaml_lines(
self._data.phonon_primitive, "phonon_primitive_cell"
)
lines += self._phonon_supercell_yaml_lines()
if self._data.phonon_supercell_matrix is not None:
lines += self._supercell_matrix_yaml_lines(
self._data.phonon_supercell_matrix, "phonon_supercell_matrix"
)
lines += self._primitive_yaml_lines(
self._data.phonon_primitive, "phonon_primitive_cell"
)
lines += self._phonon_supercell_yaml_lines()
return lines

def _phonon_supercell_yaml_lines(self):
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.0.3"
__version__ = "3.0.4"

0 comments on commit e3478ca

Please sign in to comment.