- class matlantis_features.features.phonon.force_constant.ForceConstantFeature(supercell: Tuple[int, int, int], delta: float, method: str = ‘Frederiksen’, direction: str = ‘central’, symmetrize: int = 3, acoustic: bool = True, cutoff: Optional[float] = None, use_symmetry: bool = False, show_progress_bar: bool = False, tqdm_options: Optional[Dict[str, Any]] = None, show_logger: bool = False, estimator_fn: Optional[Callable[[], Estimator]] = None)#
-
Bases:
FeatureBase
The matlantis-feature for calculating the force constant for the given structure.
The force constant, which is the basis of phonon analysis, will be calculated with the finite displacement method, in which the second derivative of the potential energy is estimated by displacing each atom with a small distance within an enlarged supercell.
The results will be used in the post analysis, such as PostPhononBandFeature.References
For more information, please refer to Matlantis Guidebook.
Methods
__init__
(supercell, delta[, method, …])Initialize an instance.
__call__
(atoms[, primitive_matrix, prec])Calculates force constant for the input structure.
attach_ctx
([ctx])Attach the feature to matlantis_features.utils.Context.
check_estimator_fn
(estimator_fn)Checks if the given estimator function is None and output a warning if so.
cost_estimate
([atoms])Estimate the cost of the feature.
from_dict
(res)Construct a FeatureBase object from serialized dict.
Get the temporary save directory from the context.
Context manager that enable to set attribution of the feature.
repeat
(n_repeat)Set the maximum number of times that allowed to run the __call__ function.
to_dict
()Dictionary representation of the FeatureBase.
- __init__(supercell: Tuple[int, int, int], delta: float, method: str = ‘Frederiksen’, direction: str = ‘central’, symmetrize: int = 3, acoustic: bool = True, cutoff: Optional[float] = None, use_symmetry: bool = False, show_progress_bar: bool = False, tqdm_options: Optional[Dict[str, Any]] = None, show_logger: bool = False, estimator_fn: Optional[Callable[[], Estimator]] = None)#
-
Initialize an instance.
- Parameters
-
-
supercell (tuple[int, int, int]) – The enlarged supercell that is created by elongating
the input structure by (n, m, l) times along the axes. -
delta (float) – The distance of finite displacement applied to each atom. The unit
is Angstrom. -
method (str, optional) – The method to calculate force constant from the displaced
supercells and their forces. This parameter can be ‘Standard’ or ‘Frederiksen’.
Defaults to ‘Frederiksen’. -
direction (str, optional) – This parameter discribe how the displacment was found. Must
be in ‘forward’, ‘backward’ or ‘central’. When ‘direction=forward’/
‘direction=backward’, each atom is displaced along the positive/negative direction
of the axes. When ‘direction=center’, each atom is displaced along both positive
and negative directions of the axes. Defaults to ‘central’. -
symmetrize (int, optional) – After restoring the acoustic sum rule, the symmetry of the force
constant is broken. The parameter specifies the number of interactions to symmetrize
the force constant. Defaults to 3. -
acoustic (bool, optional) – Restores the acoustic sum rule of the force constant. Defaults
to True. -
cutoff (float or None, optional) – The corresponding elements in the force constant are set
to 0 if the interatomic distance between atoms is larger than cutoff. If None is
provided, the full force constant will be used. Defaults to None. -
use_symmetry (bool) – If True, the symmetry of input structure will be used to reduce the
number of force estimations. Defaults to False. -
show_progress_bar (bool, optional) – Show progress bar. Defaults to False.
-
tqdm_options (dict[str, Any] or None, optional) – Options for tqdm.
-
show_logger (bool, optional) – Show log information. Defaults to False.
-
estimator_fn (EstimatorFnType or None, optional) – A factory method to create a custom estimator.
Please refer Customizing estimator used in matlantis-features for detail.
-
- __call__(atoms: Union[MatlantisAtoms, Atoms], primitive_matrix: Optional[Union[ndarray, str]] = None, prec: float = 0.001) ForceConstantFeatureResult #
-
Calculates force constant for the input structure.
- Parameters
-
-
atoms (MatlantisAtoms or ASEAtoms) – The input structure.
-
primitive_matrix (np.ndarray or str or None, optional) – When ‘primitive_matrix’ is not None,
the input structure will be transformed to the primitive cell according to the
axes provided here. Then, the following force constant calculation will be
performed with the reduced primitive cell. Defaults to None. -
prec (float, optional) – Wrapper the input structure into the primitive cell with certain
precision. The distance between the wrapped atom and the atom in the primitive cell
should be smaller than prec. Defaults to 0.001.
-
- Returns
-
The force constant.
- Return type
- attach_ctx(ctx: Optional[Context] = None) None #
-
Attach the feature to matlantis_features.utils.Context.
- Parameters
-
ctx (Context or None, optional) – The matlantis_features.utils.Context object. Defaults to None.
- check_estimator_fn(estimator_fn: Optional[Callable[[], Estimator]]) None #
-
Checks if the given estimator function is None and output a warning if so.
- Parameters
-
estimator_fn (EstimatorFnType or None, optional) – A factory method to create a custom estimator.
Please refer Customizing estimator used in matlantis-features for detail. Defaults to None.
- cost_estimate(atoms: Optional[Union[Atoms, MatlantisAtoms]] = None) FeatureCost #
-
Estimate the cost of the feature.
- Parameters
-
atoms (ASEAtoms or MatlantisAtoms or None, optional) – The input atoms. Defaults to None.
- Returns
-
The cost of the feature.
- Return type
-
FeatureCost
- classmethod from_dict(res: Dict[str, Any]) FeatureBase #
-
Construct a FeatureBase object from serialized dict.
- Parameters
-
res (dict[str, Any]) – A dict containing a serialized FeatureBase from to_dict().
- Returns
-
The deserialized object from provided dict.
- Return type
- get_savedir_from_ctx() Path #
-
Get the temporary save directory from the context.
- Returns
-
The temporary save directory .
- Return type
-
pathlib.Path
- init_scope() Iterator[None] #
-
Context manager that enable to set attribution of the feature.
- Returns
-
Init_scope context manager.
- Return type
-
Iterator[None]
- repeat(n_repeat: int) Self #
-
Set the maximum number of times that allowed to run the __call__ function.
- Parameters
-
n_repeat (int) – The maximum number of repeats.
- Returns
-
The feature.
- Return type
-
Self
- to_dict() Dict[str, Any] #
-
Dictionary representation of the FeatureBase.
- Returns
-
A dict containing a serialized FeatureBase.
- Return type
-
dict[str, Any]
Resource Library
matlantis_features.features.phonon.force_constant.ForceConstantFeature