mirror of https://github.com/phonopy/phono3py.git
Call symfc project for FD when phonopy-load and fc-calculator is blank
This commit is contained in:
parent
ac2653147e
commit
9441266bbb
|
@ -0,0 +1,13 @@
|
|||
import phonopy
|
||||
|
||||
import phono3py
|
||||
|
||||
ph3 = phono3py.load("phono3py_params_NaCl.yaml.xz", produce_fc=False, log_level=2)
|
||||
ph = phonopy.Phonopy(
|
||||
unitcell=ph3.unitcell,
|
||||
supercell_matrix=ph3.phonon_supercell_matrix,
|
||||
primitive_matrix=ph3.primitive_matrix,
|
||||
)
|
||||
ph.dataset = ph3.phonon_dataset
|
||||
ph.nac_params = ph3.nac_params
|
||||
ph.save("phonopy_params_NaCl.yaml")
|
|
@ -1536,10 +1536,8 @@ class Phono3py:
|
|||
fc2 = fc_solver.force_constants[2]
|
||||
fc3 = fc_solver.force_constants[3]
|
||||
|
||||
if symmetrize_fc3r and (
|
||||
fc_calculator is None or fc_calculator == "traditional"
|
||||
):
|
||||
if use_symfc_projector:
|
||||
if symmetrize_fc3r:
|
||||
if use_symfc_projector and fc_calculator is None:
|
||||
if self._log_level:
|
||||
print("Symmetrizing fc3 by symfc projector.", flush=True)
|
||||
fc3 = symmetrize_by_projector(
|
||||
|
@ -1548,6 +1546,7 @@ class Phono3py:
|
|||
3,
|
||||
primitive=self._primitive,
|
||||
log_level=self._log_level,
|
||||
show_credit=True,
|
||||
)
|
||||
if self._fc2 is None:
|
||||
if self._log_level:
|
||||
|
@ -1559,16 +1558,22 @@ class Phono3py:
|
|||
primitive=self._primitive,
|
||||
log_level=self._log_level,
|
||||
)
|
||||
else:
|
||||
elif fc_calculator is None or fc_calculator == "traditional":
|
||||
if self._log_level:
|
||||
print("Symmetrizing fc3 by traditional approach.", flush=True)
|
||||
if is_compact_fc:
|
||||
set_translational_invariance_compact_fc3(fc3, self._primitive)
|
||||
set_permutation_symmetry_compact_fc3(fc3, self._primitive)
|
||||
if self._fc2 is None:
|
||||
symmetrize_compact_force_constants(fc2, self._primitive)
|
||||
else:
|
||||
set_translational_invariance_fc3(fc3)
|
||||
set_permutation_symmetry_fc3(fc3)
|
||||
if self._fc2 is None:
|
||||
|
||||
if self._fc2 is None:
|
||||
if self._log_level:
|
||||
print("Symmetrizing fc2 by traditional approach.", flush=True)
|
||||
if is_compact_fc:
|
||||
symmetrize_compact_force_constants(fc2, self._primitive)
|
||||
else:
|
||||
symmetrize_force_constants(fc2)
|
||||
|
||||
self._fc3 = fc3
|
||||
|
|
|
@ -44,7 +44,7 @@ import numpy as np
|
|||
from numpy.typing import ArrayLike
|
||||
from phonopy.cui.collect_cell_info import CellInfoResult
|
||||
from phonopy.cui.collect_cell_info import get_cell_info as phonopy_get_cell_info
|
||||
from phonopy.cui.settings import PhonopySettings
|
||||
from phonopy.cui.settings import Settings
|
||||
from phonopy.interface.calculator import write_supercells_with_displacements
|
||||
from phonopy.structure.cells import print_cell
|
||||
|
||||
|
@ -80,7 +80,7 @@ def get_cell_info(
|
|||
) -> Phono3pyCellInfoResult:
|
||||
"""Return calculator interface and crystal structure information."""
|
||||
cell_info = phonopy_get_cell_info(
|
||||
cast(PhonopySettings, settings),
|
||||
cast(Settings, settings),
|
||||
cell_filename,
|
||||
log_level=log_level,
|
||||
load_phonopy_yaml=load_phonopy_yaml,
|
||||
|
|
|
@ -381,7 +381,6 @@ def load(
|
|||
fc_calculator_options=fc_calculator_options,
|
||||
symmetrize_fc=symmetrize_fc,
|
||||
is_compact_fc=is_compact_fc,
|
||||
log_level=log_level,
|
||||
)
|
||||
|
||||
if log_level and ph3py.fc3 is not None:
|
||||
|
@ -412,12 +411,11 @@ def load_fc2_and_fc3(
|
|||
|
||||
def compute_force_constants_from_datasets(
|
||||
ph3py: Phono3py,
|
||||
fc_calculator: Literal["traditional", "symfc", "alm"] | None = None,
|
||||
fc_calculator: Literal["traditional", "symfc", "alm"] | str | None = None,
|
||||
fc_calculator_options: str | None = None,
|
||||
cutoff_pair_distance: float | None = None,
|
||||
symmetrize_fc: bool = True,
|
||||
is_compact_fc: bool = True,
|
||||
log_level: int = 0,
|
||||
load_phono3py_yaml: bool = False,
|
||||
):
|
||||
"""Compute force constants from datasets.
|
||||
|
@ -449,9 +447,6 @@ def compute_force_constants_from_datasets(
|
|||
use_symfc_projector=load_phono3py_yaml,
|
||||
)
|
||||
|
||||
if log_level and symmetrize_fc and fc_calculator is None:
|
||||
print("fc3 was symmetrized.")
|
||||
|
||||
if not exist_fc2:
|
||||
if (
|
||||
ph3py.phonon_supercell_matrix is None and forces_in_dataset(ph3py.dataset)
|
||||
|
@ -466,8 +461,6 @@ def compute_force_constants_from_datasets(
|
|||
fc_calculator_options=fc2_calc_opts,
|
||||
use_symfc_projector=load_phono3py_yaml,
|
||||
)
|
||||
if log_level and symmetrize_fc and fc_calculator is None:
|
||||
print("fc2 was symmetrized.")
|
||||
|
||||
|
||||
def _load_fc3(
|
||||
|
|
|
@ -617,7 +617,6 @@ def _produce_force_constants(
|
|||
cutoff_pair_distance=cutoff_pair_distance,
|
||||
symmetrize_fc=settings.fc_symmetry,
|
||||
is_compact_fc=settings.is_compact_fc,
|
||||
log_level=log_level,
|
||||
load_phono3py_yaml=load_phono3py_yaml,
|
||||
)
|
||||
except ForceCalculatorRequiredError as e:
|
||||
|
@ -637,7 +636,6 @@ def _produce_force_constants(
|
|||
cutoff_pair_distance=cutoff_pair_distance,
|
||||
symmetrize_fc=settings.fc_symmetry,
|
||||
is_compact_fc=settings.is_compact_fc,
|
||||
log_level=log_level,
|
||||
)
|
||||
|
||||
if log_level:
|
||||
|
@ -659,10 +657,6 @@ def _produce_force_constants(
|
|||
sys.exit(1)
|
||||
|
||||
if log_level:
|
||||
if load_phono3py_yaml:
|
||||
print("Max drift after symmetrization by symfc projector: ")
|
||||
else:
|
||||
print("Max drift after symmetrization by translation: ")
|
||||
show_drift_fc3(ph3py.fc3, primitive=ph3py.primitive)
|
||||
show_drift_force_constants(
|
||||
ph3py.fc2, primitive=ph3py.phonon_primitive, name="fc2"
|
||||
|
@ -1235,9 +1229,10 @@ def main(**argparse_control):
|
|||
###################
|
||||
if settings.use_pypolymlp:
|
||||
assert ph3py.mlp_dataset is None
|
||||
if ph3py.dataset is not None:
|
||||
if ph3py.dataset is not None: # If None, load mlp from polymlp.yaml.
|
||||
ph3py.mlp_dataset = ph3py.dataset
|
||||
ph3py.dataset = None
|
||||
|
||||
prepare_dataset = (
|
||||
settings.create_displacements or settings.random_displacements is not None
|
||||
)
|
||||
|
|
|
@ -120,9 +120,9 @@ class FC3Solver(FCSolver):
|
|||
|
||||
|
||||
def extract_fc2_fc3_calculators(
|
||||
fc_calculator: str | None,
|
||||
fc_calculator: Literal["traditional", "symfc", "alm"] | str | None,
|
||||
order: int,
|
||||
) -> str | None:
|
||||
) -> Literal["traditional", "symfc", "alm"] | str | None:
|
||||
"""Extract fc_calculator and fc_calculator_options for fc2 and fc3.
|
||||
|
||||
fc_calculator : str
|
||||
|
@ -177,7 +177,7 @@ def get_fc_calculator_params(
|
|||
fc_calculator_options: str | None,
|
||||
cutoff_pair_distance: float | None,
|
||||
log_level: int = 0,
|
||||
) -> tuple[Literal["traditional", "symfc", "alm"] | None, str | None]:
|
||||
) -> tuple[str | None, str | None]:
|
||||
"""Compile fc_calculator and fc_calculator_options from input settings."""
|
||||
_fc_calculator = None
|
||||
fc_calculator_list = []
|
||||
|
|
Loading…
Reference in New Issue