class matlantis_features.features.elasticity.elastic_tensor.ElasticTensorFeature(diagonal_strains: List[float], off_diagonal_strains: List[float], optimizer: ASEOptFeature, check_linear_elems: Optional[List[Tuple[int, int]]] = None, zero_tol: float = 0.001, show_progress_bar: bool = False, tqdm_options: Optional[Dict[str, Any]] = None, show_logger: bool = False, check_symmetry: bool = False, rtol: float = 0.01, atol: float = 1.0, estimator_fn: Optional[Callable[[], Estimator]] = None)#

Bases: FeatureBase

The matlantis-feature for calculating the elastic tensor for the specified atoms, by applying the specified strain.

References

For more information, please refer to Matlantis Guidebook.

Methods

__init__(diagonal_strains, …[, …])

Initialize an instance.

__call__(matlantis_atoms)

Calculate the elastic tensor.

attach_ctx([ctx])

Attach the feature to matlantis_features.utils.Context.

check_elastic_tensor_symmetry(atoms, …)

Check correctness of elastic tensor according to the lattice symmetry.

check_estimator_fn(estimator_fn)

Checks if the given estimator function is None and output a warning if so.

check_nonlinear(elastic_tensor, …)

Check non-linearity of stress-strain relation.

check_zero_elems(elastic_tensor, …)

Check if the elastic tensor elements are zero.

cost_estimate([atoms])

Estimate the cost of the feature.

from_dict(res)

Construct a FeatureBase object from serialized dict.

get_savedir_from_ctx()

Get the temporary save directory from the context.

init_scope()

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__(diagonal_strains: List[float], off_diagonal_strains: List[float], optimizer: ASEOptFeature, check_linear_elems: Optional[List[Tuple[int, int]]] = None, zero_tol: float = 0.001, show_progress_bar: bool = False, tqdm_options: Optional[Dict[str, Any]] = None, show_logger: bool = False, check_symmetry: bool = False, rtol: float = 0.01, atol: float = 1.0, estimator_fn: Optional[Callable[[], Estimator]] = None)#

Initialize an instance.

Parameters
  • diagonal_strains (list[float]) – Diagonal elements of the strain tensor.

  • off_diagonal_strains (list[float]) – Off-diagonal elements of the strain tensor.

  • optimizer (ASEOptFeature) – Optimization method to optimize the system after applying the strain.

  • check_linear_elems (list[tuple[int, int]] or None, optional) – Index list of the elastic tensor to check the linearlity.
    Default index list ((0, 0),(1, 1),(2, 2),(0, 1),(0, 2),(1, 2),(3, 3),(4, 4),(5, 5)) is used,
    if None is specified.
    Defaults to None.

  • zero_tol (float, optional) – Skip the linearity check if the elastic constant is smaller than this threshold.
    Defaults to 0.001.

  • 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.

  • check_symmetry (bool, optional) – Check the calculated elastic tensor is in accord with the type of lattice symmetry.
    For example, C11 = C22 and C14 = 0 in the cubic lattice. Please note that
    the two elements a and b are considered as equal if their difference is within a tolerance
    that us defined by rtol and atol, i.e. absolute(a – b) <= (atol + rtol * absolute(b)). If check_symmetry is enabled, the resultant elastic tensor corresponds to the rotated atomic coordinates after applying the symmetry operations, which might differ from the input atomic coordinates. Please call get_symmetry_lattice(atoms) if the rotated atomic coordinates are needed. In other words, if you do not want the atomic coordinates to be rotated from the original, please set check_symmetry to False.
    Default to False.

  • rtol (float, optional) – The relative tolerance of difference. The elastic tensor elements are regarded as the same
    if the relative difference is smaller than this value. Default to 0.01.

  • atol (float, optional) – The absolute tolerance of difference. The elastic tensor elements are regarded as the same
    if the absolute difference is smaller than this value. Default to 1.0

  • 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__(matlantis_atoms: Union[Atoms, MatlantisAtoms]) ElasticTensor#

Calculate the elastic tensor.

Parameters

matlantis_atoms (ASEAtoms or MatlantisAtoms) – Atoms representing the system to calculate the elastic tensor.

Returns

Resulting elastic tensor object.

Return type

ElasticTensor

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_elastic_tensor_symmetry(atoms: Atoms, elastic_tensor: ElasticTensor) None#

Check correctness of elastic tensor according to the lattice symmetry.

  1. Certain elements of elastic tensor should be zeros, except the triclinic lattice.

  2. Some elements of elastic tensor should be identical, e.g. C11 = C22 = C33 in cubic lattice.

  3. Some elements of elastic tensor should be opposite number, e.g. C16 = -C26 in tetragonal lattice.

  4. Certain relation exists between the elements, e.g. C66 = 1/2 (C11-C12) in hexagonal lattice.

Parameters
  • atoms (ASEAtoms) – Atoms representing the system to calculate the elastic tensor.

  • elastic_tensor (ElasticTensor) – Elastic tensor object containing the stress and strain data.

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.

check_nonlinear(elastic_tensor: ElasticTensor, check_linear_elems: List[Tuple[int, int]]) None#

Check non-linearity of stress-strain relation.

If non linearity is detected, warning will be reported to the logger
and self.report() will be called.

Parameters
  • elastic_tensor (ElasticTensor) – Elastic tensor object containing the stress and strain data.

  • check_linear_elems (list[tuple[int, int]]) – Index list of the tensor elements to check the linearity.

check_zero_elems(elastic_tensor: ElasticTensor, check_linear_elems: List[Tuple[int, int]], zero_tol: float) None#

Check if the elastic tensor elements are zero.

If non zero emenets are detected, warning will be reported to the logger
and self.report() will be called.

Parameters
  • elastic_tensor (ElasticTensor) – Elastic tensor object to be checked.

  • check_linear_elems (list[tuple[int, int]]) – Index list of the tensor elements to check the linearity.
    The elements specified in this list will not be checked,
    since these elements are expected to have non-zero elastic constants.

  • zero_tol (float) – Tolerance threshold for the zero check.

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

FeatureBase

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]