- class matlantis_features.features.md.post_features.diffusion.PostMDDiffusionFeature#
-
Bases:
FeatureBase
The matlantis-feature for calculating the diffusion coefficient using the MD trajectory.
Note
The breaking change is made in
PostMDDiffusionFeature
at version 0.8.0.
The new implementation is fast,
and enables a more comprehensive analysis of diffusion properties.
The old version is renamed as
OldPostMDDiffusionFeature
.References
For more information, please refer to Matlantis Guidebook.
Methods
__init__
()Initialize an instance.
__call__
(md_results[, init_time, stride, …])Calculate the diffusion coefficient of each element from the MD trajectory.
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__() None #
-
Initialize an instance.
- __call__(md_results: MDFeatureResult, init_time: float = 0.0, stride: int = 1, atom_indices: Optional[List[int]] = None, molecule: Union[bool, List[List[int]]] = False, number_of_segments: int = 1, direction: Optional[ndarray] = None, method: str = ‘normal’, effective_msd_range: Optional[Tuple[float, float]] = None) PostMDDiffusionFeatureResult #
-
Calculate the diffusion coefficient of each element from the MD trajectory.
- Parameters
-
-
md_results (MDFeatureResult) – MD feature’s result object containing the trajectory.
-
init_time (float, optional) – Trajectory frames before this time (in fs) is ignored for the calculation.
Defaults to 0.0 (i.e., all frames are used for calculation). -
stride (int, optional) – Size of the skip strie of the trajectory frames.
Defaults to 1 (i.e., all frames are used for calculation). -
atom_indices (list[int] or None, optional) – The indices of atoms whose diffusion coefficient is to be calculated explicitly.
Defaults to None. -
molecule (bool or list[list[int]], optional) – The indices of atoms who form a molecule. If it is used, the diffusion coefficient
of the center of mass of molecules will be calculated. The results will be saved in
the PostMDDiffusionFeatureResult.diffusion_coefficient_molecule. If True, all the
atoms will be regard as one molecule. Defaults to False. -
number_of_segments (int, optional) – Divides the given trajectory in to segments to allow statistical analysis, such as
standard deviation of diffuion coefficient.
Defaults to 1. -
direction (np.ndarray or None, optional) – Calculate the diffusion coefficient along specific directions. It must be a nx3 array
where n is number of directions. The result will be saved in
PostMDDiffusionFeatureResult.diffusion_coefficient as, e.g. H_direc_1,
O_direc_2 etc. If None, only the diffusion coefficient along x, y and z directions
is calculated. Defaults to None -
method (str, optional) – The method to calculate mean square displacement (MSD). Now, two methods, i.e.
“normal” and “segment”, are supported. Defaults to “normal”. -
effective_msd_range (tuple[float, float] or None, optional) – A tuple of two floats representing the range of MSD sequence
to be used in the calculation of diffusion coefficient.
The values should be in the range of [0.0, 1.0].
If None, all the mean square displacements will be used.
Defaults to None.
-
- Returns
-
Result dataclass object.
- 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.md.post_features.diffusion.PostMDDiffusionFeature