Merge pull request #399 from phonopy/cell-info

Update following the change of collect_cell_info in phonopy
This commit is contained in:
Atsushi Togo 2025-06-23 10:50:18 +09:00 committed by GitHub
commit d4dcd0465e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 332 additions and 132 deletions

View File

@ -37,6 +37,7 @@
from __future__ import annotations
import copy
import os
import pathlib
import sys
from dataclasses import asdict
@ -54,6 +55,7 @@ from phonopy.interface.calculator import get_calculator_physical_units
from phonopy.interface.pypolymlp import PypolymlpParams, parse_mlp_params
from phono3py import Phono3py
from phono3py.cui.settings import Phono3pySettings
from phono3py.cui.show_log import show_phono3py_force_constants_settings
from phono3py.file_IO import (
get_length_of_first_line,
@ -80,13 +82,13 @@ from phono3py.phonon3.fc3 import (
def create_phono3py_force_constants(
phono3py: Phono3py,
settings,
ph3py_yaml: Optional[Phono3pyYaml] = None,
phono3py_yaml_filename: Optional[str] = None,
calculator: Optional[str] = None,
input_filename: Optional[str] = None,
output_filename: Optional[str] = None,
log_level=1,
settings: Phono3pySettings,
ph3py_yaml: Phono3pyYaml | None = None,
phono3py_yaml_filename: str | os.PathLike | None = None,
calculator: str | None = None,
input_filename: str | os.PathLike | None = None,
output_filename: str | os.PathLike | None = None,
log_level: int = 1,
):
"""Read or calculate force constants.

View File

@ -34,11 +34,18 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
from __future__ import annotations
import dataclasses
import numpy as np
from numpy.typing import ArrayLike
from phonopy.cui.collect_cell_info import CellInfoResult
from phonopy.interface.calculator import write_supercells_with_displacements
from phonopy.structure.cells import print_cell
from phono3py import Phono3py
from phono3py.cui.settings import Phono3pySettings
from phono3py.cui.show_log import print_supercell_matrix
from phono3py.interface.calculator import (
get_additional_info_to_write_fc2_supercells,
@ -48,12 +55,23 @@ from phono3py.interface.calculator import (
from phono3py.interface.fc_calculator import determine_cutoff_pair_distance
@dataclasses.dataclass
class Phono3pyCellInfoResult(CellInfoResult):
"""Phono3py cell info result.
This is a subclass of CellInfoResult to add phonon supercell matrix.
"""
phonon_supercell_matrix: ArrayLike | None = None
def create_phono3py_supercells(
cell_info,
settings,
symprec,
interface_mode="vasp",
log_level=1,
cell_info: Phono3pyCellInfoResult,
settings: Phono3pySettings,
symprec: float,
interface_mode: str | None = "vasp",
log_level: int = 1,
):
"""Create displacements and supercells.
@ -61,17 +79,17 @@ def create_phono3py_supercells(
The default unit is Angstrom.
"""
optional_structure_info = cell_info["optional_structure_info"]
optional_structure_info = cell_info.optional_structure_info
if settings.displacement_distance is None:
distance = get_default_displacement_distance(interface_mode)
else:
distance = settings.displacement_distance
ph3 = Phono3py(
cell_info["unitcell"],
cell_info["supercell_matrix"],
primitive_matrix=cell_info["primitive_matrix"],
phonon_supercell_matrix=cell_info["phonon_supercell_matrix"],
cell_info.unitcell,
cell_info.supercell_matrix,
primitive_matrix=cell_info.primitive_matrix,
phonon_supercell_matrix=cell_info.phonon_supercell_matrix,
is_symmetry=settings.is_symmetry,
symprec=symprec,
calculator=interface_mode,

View File

@ -224,18 +224,18 @@ def _get_parser():
return args
def _read_files(args: argparse.Namespace) -> tuple[h5py.File, PhonopyAtoms]:
def _read_files(args: argparse.Namespace) -> tuple[h5py.File, PhonopyAtoms | None]:
primitive = None
cell_info = collect_cell_info(
supercell_matrix=np.eye(3, dtype=int),
phonopy_yaml_cls=Phono3pyYaml,
)
cell_filename = cell_info["optional_structure_info"][0]
cell_filename = cell_info.optional_structure_info[0]
print(f'# Crystal structure was read from "{cell_filename}".')
cell = cell_info["unitcell"]
phpy_yaml = cell_info.get("phonopy_yaml", None)
cell = cell_info.unitcell
phpy_yaml = cell_info.phonopy_yaml
if phpy_yaml is not None:
primitive = cell_info["phonopy_yaml"].primitive
primitive = phpy_yaml.primitive
if primitive is None:
primitive = cell
f_kappa = h5py.File(args.filenames[0], "r")

View File

@ -387,8 +387,8 @@ def load(
def load_fc2_and_fc3(
ph3py: Phono3py,
fc3_filename: Optional[os.PathLike] = None,
fc2_filename: Optional[os.PathLike] = None,
fc3_filename: str | os.PathLike | None = None,
fc2_filename: str | os.PathLike | None = None,
log_level: int = 0,
):
"""Set force constants."""
@ -401,12 +401,12 @@ def load_fc2_and_fc3(
def load_dataset_and_phonon_dataset(
ph3py: Phono3py,
ph3py_yaml: Optional[Phono3pyYaml] = None,
forces_fc3_filename: Optional[Union[os.PathLike, Sequence]] = None,
forces_fc2_filename: Optional[Union[os.PathLike, Sequence]] = None,
phono3py_yaml_filename: Optional[os.PathLike] = None,
cutoff_pair_distance: Optional[float] = None,
calculator: Optional[str] = None,
ph3py_yaml: Phono3pyYaml | None = None,
forces_fc3_filename: str | os.PathLike | Sequence | None = None,
forces_fc2_filename: str | os.PathLike | Sequence | None = None,
phono3py_yaml_filename: str | os.PathLike | None = None,
cutoff_pair_distance: float | None = None,
calculator: str | None = None,
log_level: int = 0,
):
"""Set displacements, forces, and create force constants."""
@ -520,8 +520,8 @@ def _load_fc3(
def _select_and_load_dataset(
ph3py: Phono3py,
ph3py_yaml: Phono3pyYaml | None = None,
forces_fc3_filename: os.PathLike | Sequence | None = None,
phono3py_yaml_filename: os.PathLike | None = None,
forces_fc3_filename: str | os.PathLike | Sequence | None = None,
phono3py_yaml_filename: str | os.PathLike | None = None,
cutoff_pair_distance: float | None = None,
calculator: str | None = None,
log_level: int = 0,
@ -572,7 +572,7 @@ def _select_and_load_dataset(
def _load_fc2(
ph3py: Phono3py, fc2_filename: os.PathLike | None = None, log_level: int = 0
ph3py: Phono3py, fc2_filename: str | os.PathLike | None = None, log_level: int = 0
):
phonon_p2s_map = ph3py.phonon_primitive.p2s_map
if fc2_filename is None:

View File

@ -37,13 +37,16 @@
from __future__ import annotations
import argparse
import dataclasses
import os
import pathlib
import sys
import warnings
from typing import Optional
from typing import Optional, cast
import numpy as np
from numpy.typing import NDArray
from phonopy.api_phonopy import Phonopy
from phonopy.cui.collect_cell_info import collect_cell_info
from phonopy.cui.phonopy_argparse import show_deprecated_option_warnings
from phonopy.cui.phonopy_script import (
@ -56,7 +59,8 @@ from phonopy.cui.phonopy_script import (
set_magnetic_moments,
store_nac_params,
)
from phonopy.exception import ForceCalculatorRequiredError
from phonopy.cui.settings import PhonopySettings
from phonopy.exception import CellNotFoundError, ForceCalculatorRequiredError
from phonopy.file_IO import is_file_phonopy_yaml
from phonopy.harmonic.force_constants import show_drift_force_constants
from phonopy.interface.calculator import get_calculator_physical_units
@ -76,7 +80,10 @@ from phono3py.cui.create_force_sets import (
create_FORCES_FC2_from_FORCE_SETS,
create_FORCES_FC3_and_FORCES_FC2,
)
from phono3py.cui.create_supercells import create_phono3py_supercells
from phono3py.cui.create_supercells import (
Phono3pyCellInfoResult,
create_phono3py_supercells,
)
from phono3py.cui.load import (
compute_force_constants_from_datasets,
load_dataset_and_phonon_dataset,
@ -334,31 +341,36 @@ def get_input_output_filenames_from_args(args: argparse.Namespace):
return input_filename, output_filename
def get_cell_info(
settings: Phono3pySettings, cell_filename: str, log_level: int
) -> dict:
def _get_cell_info(
settings: Phono3pySettings, cell_filename: str | os.PathLike | None, log_level: int
) -> Phono3pyCellInfoResult:
"""Return calculator interface and crystal structure information."""
cell_info = collect_cell_info(
supercell_matrix=settings.supercell_matrix,
primitive_matrix=settings.primitive_matrix,
interface_mode=settings.calculator,
cell_filename=cell_filename,
chemical_symbols=settings.chemical_symbols,
phonopy_yaml_cls=Phono3pyYaml,
)
if "error_message" in cell_info:
print_error_message(cell_info["error_message"])
if log_level > 0:
try:
cell_info = collect_cell_info(
supercell_matrix=settings.supercell_matrix,
primitive_matrix=settings.primitive_matrix,
interface_mode=settings.calculator,
cell_filename=cell_filename,
chemical_symbols=settings.chemical_symbols,
phonopy_yaml_cls=Phono3pyYaml,
)
except CellNotFoundError as e:
print_error_message(str(e))
if log_level:
print_error()
sys.exit(1)
set_magnetic_moments(cell_info, settings, log_level)
cell_info = Phono3pyCellInfoResult(
**dataclasses.asdict(cell_info),
phonon_supercell_matrix=settings.phonon_supercell_matrix,
)
cell_info["phonon_supercell_matrix"] = settings.phonon_supercell_matrix
ph3py_yaml: Phono3pyYaml = cell_info["phonopy_yaml"]
if cell_info["phonon_supercell_matrix"] is None and ph3py_yaml:
set_magnetic_moments(cell_info.unitcell, settings.magnetic_moments, log_level)
ph3py_yaml = cast(Phono3pyYaml, cell_info.phonopy_yaml)
if cell_info.phonon_supercell_matrix is None and ph3py_yaml:
ph_smat = ph3py_yaml.phonon_supercell_matrix
cell_info["phonon_supercell_matrix"] = ph_smat
cell_info.phonon_supercell_matrix = ph_smat
return cell_info
@ -437,40 +449,41 @@ def get_default_values(settings: Phono3pySettings):
return params
def check_supercell_in_yaml(
cell_info: dict, ph3: Phono3py, distance_to_A: float | None, log_level: int
def _check_supercell_in_yaml(
cell_info: Phono3pyCellInfoResult,
ph3: Phono3py,
distance_to_A: float | None,
log_level: int,
):
"""Check consistency between generated cells and cells in yaml."""
if cell_info["phonopy_yaml"] is not None:
if cell_info.phonopy_yaml is not None:
if distance_to_A is None:
d2A = 1.0
else:
d2A = distance_to_A
if (
cell_info["phonopy_yaml"].supercell is not None
and ph3.supercell is not None
): # noqa E129
yaml_cell = cell_info["phonopy_yaml"].supercell.copy()
phono3py_yaml = cast(Phono3pyYaml, cell_info.phonopy_yaml)
if phono3py_yaml.supercell is not None and ph3.supercell is not None: # noqa E129
yaml_cell = phono3py_yaml.supercell.copy()
yaml_cell.cell = yaml_cell.cell * d2A
if not cells_isclose(yaml_cell, ph3.supercell):
if log_level:
print(
"Generated supercell is inconsistent with "
'that in "%s".' % cell_info["optional_structure_info"][0]
f'that in "{cell_info.optional_structure_info[0]}".'
)
print_error()
sys.exit(1)
if (
cell_info["phonopy_yaml"].phonon_supercell is not None
phono3py_yaml.phonon_supercell is not None
and ph3.phonon_supercell is not None
): # noqa E129
yaml_cell = cell_info["phonopy_yaml"].phonon_supercell.copy()
yaml_cell = phono3py_yaml.phonon_supercell.copy()
yaml_cell.cell = yaml_cell.cell * d2A
if not cells_isclose(yaml_cell, ph3.phonon_supercell):
if log_level:
print(
"Generated phonon supercell is inconsistent with "
'that in "%s".' % cell_info["optional_structure_info"][0]
f'that in "{cell_info.optional_structure_info[0]}".'
)
print_error()
sys.exit(1)
@ -478,7 +491,7 @@ def check_supercell_in_yaml(
def init_phono3py(
settings: Phono3pySettings,
cell_info: dict,
cell_info: Phono3pyCellInfoResult,
interface_mode: str | None,
symprec: float,
log_level: int,
@ -488,7 +501,7 @@ def init_phono3py(
distance_to_A = physical_units["distance_to_A"]
# Change unit of lattice parameters to angstrom
unitcell = cell_info["unitcell"].copy()
unitcell = cell_info.unitcell.copy()
if distance_to_A is not None:
lattice = unitcell.cell
lattice *= distance_to_A
@ -503,9 +516,9 @@ def init_phono3py(
phono3py = Phono3py(
unitcell,
cell_info["supercell_matrix"],
primitive_matrix=cell_info["primitive_matrix"],
phonon_supercell_matrix=cell_info["phonon_supercell_matrix"],
cell_info.supercell_matrix,
primitive_matrix=cell_info.primitive_matrix,
phonon_supercell_matrix=cell_info.phonon_supercell_matrix,
cutoff_frequency=updated_settings["cutoff_frequency"],
frequency_factor_to_THz=updated_settings["frequency_factor_to_THz"],
is_symmetry=settings.is_symmetry,
@ -520,7 +533,7 @@ def init_phono3py(
phono3py.sigmas = updated_settings["sigmas"]
phono3py.sigma_cutoff = settings.sigma_cutoff_width
check_supercell_in_yaml(cell_info, phono3py, distance_to_A, log_level)
_check_supercell_in_yaml(cell_info, phono3py, distance_to_A, log_level)
return phono3py, updated_settings
@ -546,7 +559,7 @@ def grid_addresses_to_grid_points(grid_addresses: NDArray, bz_grid: BZGrid):
def create_supercells_with_displacements(
settings: Phono3pySettings,
cell_info: dict,
cell_info: Phono3pyCellInfoResult,
confs_dict: dict,
unitcell_filename: str,
interface_mode: Optional[str],
@ -570,9 +583,9 @@ def create_supercells_with_displacements(
if pathlib.Path("BORN").exists():
store_nac_params(
phono3py,
settings,
cell_info["phonopy_yaml"],
cast(Phonopy, phono3py),
cast(PhonopySettings, settings),
cell_info.phonopy_yaml,
unitcell_filename,
log_level,
nac_factor=get_physical_units().Hartree * get_physical_units().Bohr,
@ -1019,10 +1032,10 @@ def main(**argparse_control):
else:
symprec = settings.symmetry_tolerance
cell_info = get_cell_info(settings, cell_filename, log_level)
unitcell_filename = cell_info["optional_structure_info"][0]
interface_mode = cell_info["interface_mode"]
# ph3py_yaml = cell_info['phonopy_yaml']
cell_info = _get_cell_info(settings, cell_filename, log_level)
unitcell_filename = cell_info.optional_structure_info[0]
interface_mode = cell_info.interface_mode
# ph3py_yaml = cell_info.phonopy_yaml
if run_mode is None:
run_mode = get_run_mode(settings)
@ -1176,9 +1189,9 @@ def main(**argparse_control):
##################################
if settings.is_nac:
store_nac_params(
ph3py,
settings,
cell_info["phonopy_yaml"],
cast(Phonopy, ph3py),
cast(PhonopySettings, settings),
cell_info.phonopy_yaml,
unitcell_filename,
log_level,
nac_factor=get_physical_units().Hartree * get_physical_units().Bohr,
@ -1193,7 +1206,7 @@ def main(**argparse_control):
assert ph3py.phonon_dataset is None
load_dataset_and_phonon_dataset(
ph3py,
ph3py_yaml=cell_info["phonopy_yaml"],
ph3py_yaml=cast(Phono3pyYaml, cell_info.phonopy_yaml),
phono3py_yaml_filename=unitcell_filename,
cutoff_pair_distance=settings.cutoff_pair_distance,
calculator=interface_mode,
@ -1258,7 +1271,7 @@ def main(**argparse_control):
create_phono3py_force_constants(
ph3py,
settings,
ph3py_yaml=cell_info["phonopy_yaml"],
ph3py_yaml=cast(Phono3pyYaml, cell_info.phonopy_yaml),
phono3py_yaml_filename=unitcell_filename,
calculator=interface_mode,
input_filename=input_filename,

View File

@ -452,7 +452,7 @@ def write_fc2_to_hdf5(
)
def read_fc2_from_hdf5(filename="fc2.hdf5", p2s_map=None):
def read_fc2_from_hdf5(filename: str | os.PathLike = "fc2.hdf5", p2s_map=None):
"""Read fc2 from fc2.hdf5."""
return read_force_constants_from_hdf5(
filename=filename, p2s_map=p2s_map, calculator="vasp"

View File

@ -37,15 +37,15 @@
from __future__ import annotations
import dataclasses
from typing import TYPE_CHECKING, Optional
from typing import TYPE_CHECKING, cast
import numpy as np
from numpy.typing import ArrayLike, NDArray
from phonopy.interface.phonopy_yaml import (
PhonopyYaml,
PhonopyYamlDumperBase,
PhonopyYamlLoaderBase,
load_yaml,
phonopy_yaml_property_factory,
)
if TYPE_CHECKING:
@ -60,26 +60,26 @@ from phonopy.structure.symmetry import Symmetry
class Phono3pyYamlData:
"""PhonopyYaml data structure."""
configuration: Optional[dict] = None
calculator: Optional[str] = None
physical_units: Optional[dict] = None
unitcell: Optional[PhonopyAtoms] = None
primitive: Optional[Primitive] = None
supercell: Optional[Supercell] = None
dataset: Optional[dict] = None
supercell_matrix: Optional[np.ndarray] = None
primitive_matrix: Optional[np.ndarray] = None
nac_params: Optional[dict] = None
force_constants: Optional[np.ndarray] = None
symmetry: Optional[Symmetry] = None # symmetry of supercell
frequency_unit_conversion_factor: Optional[float] = None
version: Optional[str] = None
configuration: dict | None = None
calculator: str | None = None
physical_units: dict | None = None
unitcell: PhonopyAtoms | None = None
primitive: Primitive | PhonopyAtoms | None = None
supercell: Supercell | PhonopyAtoms | None = None
dataset: dict | None = None
supercell_matrix: NDArray | None = None
primitive_matrix: NDArray | None = None
nac_params: dict | None = None
force_constants: NDArray | None = None
symmetry: Symmetry | None = None # symmetry of supercell
frequency_unit_conversion_factor: float | None = None
version: str | None = None
command_name: str = "phono3py"
phonon_supercell_matrix: Optional[np.ndarray] = None
phonon_dataset: Optional[dict] = None
phonon_supercell: Optional[Supercell] = None
phonon_primitive: Optional[Primitive] = None
phonon_supercell_matrix: NDArray | None = None
phonon_dataset: dict | None = None
phonon_supercell: Supercell | PhonopyAtoms | None = None
phonon_primitive: Primitive | PhonopyAtoms | None = None
class Phono3pyYamlLoader(PhonopyYamlLoaderBase):
@ -156,10 +156,12 @@ class Phono3pyYamlLoader(PhonopyYamlLoaderBase):
and "phonon_displacements" not in self._yaml
and "displacements" in self._yaml
): # old type1
self._data.phonon_dataset = self._get_dataset(self._data.phonon_supercell)
self._data.phonon_dataset = self._get_dataset(
cast(PhonopyAtoms, self._data.phonon_supercell)
)
else:
self._data.phonon_dataset = self._get_dataset(
self._data.phonon_supercell, key_prefix="phonon_"
cast(PhonopyAtoms, self._data.phonon_supercell), key_prefix="phonon_"
)
def _parse_fc3_dataset(self):
@ -181,7 +183,7 @@ class Phono3pyYamlLoader(PhonopyYamlLoaderBase):
elif isinstance(disp, list): # type2
if "displacement" in disp[0]:
dataset = self._parse_force_sets_type2()
if "displacement_pair_info" in self._yaml:
if "displacement_pair_info" in self._yaml and dataset is not None:
info_yaml = self._yaml["displacement_pair_info"]
if "cutoff_pair_distance" in info_yaml:
dataset["cutoff_distance"] = info_yaml["cutoff_pair_distance"]
@ -402,28 +404,6 @@ class Phono3pyYaml(PhonopyYaml):
default_filenames = ("phono3py_disp.yaml", "phono3py.yaml")
command_name = "phono3py"
configuration = phonopy_yaml_property_factory("configuration")
calculator = phonopy_yaml_property_factory("calculator")
physical_units = phonopy_yaml_property_factory("physical_units")
unitcell = phonopy_yaml_property_factory("unitcell")
primitive = phonopy_yaml_property_factory("primitive")
supercell = phonopy_yaml_property_factory("supercell")
dataset = phonopy_yaml_property_factory("dataset")
supercell_matrix = phonopy_yaml_property_factory("supercell_matrix")
primitive_matrix = phonopy_yaml_property_factory("primitive_matrix")
nac_params = phonopy_yaml_property_factory("nac_params")
force_constants = phonopy_yaml_property_factory("force_constants")
symmetry = phonopy_yaml_property_factory("symmetry")
frequency_unit_conversion_factor = phonopy_yaml_property_factory(
"frequency_unit_conversion_factor"
)
version = phonopy_yaml_property_factory("version")
phonon_supercell_matrix = phonopy_yaml_property_factory("phonon_supercell_matrix")
phonon_dataset = phonopy_yaml_property_factory("phonon_dataset")
phonon_supercell = phonopy_yaml_property_factory("phonon_supercell")
phonon_primitive = phonopy_yaml_property_factory("phonon_primitive")
def __init__(
self, configuration=None, calculator=None, physical_units=None, settings=None
):
@ -435,6 +415,193 @@ class Phono3pyYaml(PhonopyYaml):
)
self._dumper_settings = settings
@property
def configuration(self) -> dict | None:
"""Return configuration of phonopy calculation."""
return self._data.configuration
@configuration.setter
def configuration(self, value: dict):
"""Set configuration of phonopy calculation."""
self._data.configuration = value
@property
def calculator(self) -> str | None:
"""Return calculator of phonopy calculation."""
return self._data.calculator
@calculator.setter
def calculator(self, value: str):
"""Set calculator of phonopy calculation."""
self._data.calculator = value
@property
def physical_units(self) -> dict | None:
"""Return physical units of phonopy calculation."""
return self._data.physical_units
@physical_units.setter
def physical_units(self, value: dict):
"""Set physical units of phonopy calculation."""
self._data.physical_units = value
@property
def unitcell(self) -> PhonopyAtoms | None:
"""Return unit cell of phonopy calculation."""
return self._data.unitcell
@unitcell.setter
def unitcell(self, value: PhonopyAtoms):
"""Set unit cell of phonopy calculation."""
self._data.unitcell = value
@property
def primitive(self) -> PhonopyAtoms | None:
"""Return primitive cell of phonopy calculation."""
return self._data.primitive
@primitive.setter
def primitive(self, value: PhonopyAtoms):
"""Set primitive cell of phonopy calculation."""
self._data.primitive = value
@property
def supercell(self) -> PhonopyAtoms | None:
"""Return supercell of phonopy calculation."""
return self._data.supercell
@supercell.setter
def supercell(self, value: PhonopyAtoms):
"""Set supercell of phonopy calculation."""
self._data.supercell = value
@property
def dataset(self) -> dict | None:
"""Return dataset of phonopy calculation."""
return self._data.dataset
@dataset.setter
def dataset(self, value: dict):
"""Set dataset of phonopy calculation."""
self._data.dataset = value
@property
def supercell_matrix(self) -> NDArray | None:
"""Return supercell matrix of phonopy calculation."""
return self._data.supercell_matrix
@supercell_matrix.setter
def supercell_matrix(self, value: ArrayLike):
"""Set supercell matrix of phonopy calculation."""
self._data.supercell_matrix = np.array(value, dtype="intc", order="C")
@property
def primitive_matrix(self) -> NDArray | None:
"""Return primitive matrix of phonopy calculation."""
return self._data.primitive_matrix
@primitive_matrix.setter
def primitive_matrix(self, value: ArrayLike):
"""Set primitive matrix of phonopy calculation."""
self._data.primitive_matrix = np.array(value, dtype="double", order="C")
@property
def nac_params(self) -> dict | None:
"""Return non-analytical term correction parameters."""
return self._data.nac_params
@nac_params.setter
def nac_params(self, value: dict):
"""Set non-analytical term correction parameters."""
if value is not None:
if "born" in value:
value["born"] = np.array(value["born"], dtype="double", order="C")
if "dielectric" in value:
value["dielectric"] = np.array(
value["dielectric"], dtype="double", order="C"
)
self._data.nac_params = value
@property
def force_constants(self) -> NDArray | None:
"""Return force constants of phonopy calculation."""
return self._data.force_constants
@force_constants.setter
def force_constants(self, value: ArrayLike):
"""Set force constants of phonopy calculation."""
self._data.force_constants = np.array(value, dtype="double", order="C")
@property
def symmetry(self) -> Symmetry | None:
"""Return symmetry of phonopy calculation."""
return self._data.symmetry
@symmetry.setter
def symmetry(self, value: Symmetry):
"""Set symmetry of phonopy calculation."""
self._data.symmetry = value
@property
def frequency_unit_conversion_factor(self) -> float | None:
"""Return frequency unit conversion factor."""
return self._data.frequency_unit_conversion_factor
@frequency_unit_conversion_factor.setter
def frequency_unit_conversion_factor(self, value: float):
"""Set frequency unit conversion factor."""
self._data.frequency_unit_conversion_factor = value
@property
def version(self) -> str | None:
"""Return version of phonopy calculation."""
return self._data.version
@version.setter
def version(self, value: str):
"""Set version of phonopy calculation."""
self._data.version = value
@property
def phonon_primitive(self) -> PhonopyAtoms | None:
"""Return phonon primitive cell of phonopy calculation."""
return self._data.phonon_primitive
@phonon_primitive.setter
def phonon_primitive(self, value: PhonopyAtoms):
"""Set phonon primitive cell of phonopy calculation."""
self._data.phonon_primitive = value
@property
def phonon_supercell(self) -> PhonopyAtoms | None:
"""Return phonon supercell of phonopy calculation."""
return self._data.phonon_supercell
@phonon_supercell.setter
def phonon_supercell(self, value: PhonopyAtoms):
"""Set phonon supercell of phonopy calculation."""
self._data.phonon_supercell = value
@property
def phonon_dataset(self) -> dict | None:
"""Return phonon dataset of phonopy calculation."""
return self._data.phonon_dataset
@phonon_dataset.setter
def phonon_dataset(self, value: dict):
"""Set phonon dataset of phonopy calculation."""
self._data.phonon_dataset = value
@property
def phonon_supercell_matrix(self) -> NDArray | None:
"""Return phonon supercell matrix of phonopy calculation."""
return self._data.phonon_supercell_matrix
@phonon_supercell_matrix.setter
def phonon_supercell_matrix(self, value: ArrayLike):
"""Set supercell matrix of phonopy calculation."""
self._data.phonon_supercell_matrix = np.array(value, dtype="intc", order="C")
def __str__(self):
"""Return string text of yaml output."""
ph3yml_dumper = Phono3pyYamlDumper(