matcalc._elasticity module
Calculator for elastic properties.
- class ElasticityCalc(calculator: Calculator | str, *, norm_strains: Sequence[float] | float = (-0.01, -0.005, 0.005, 0.01), shear_strains: Sequence[float] | float = (-0.06, -0.03, 0.03, 0.06), fmax: float = 0.1, symmetry: bool = False, relax_structure: bool = True, relax_deformed_structures: bool = False, use_equilibrium: bool = True, relax_calc_kwargs: dict | None = None)[source]
Bases:
PropCalc
Class for calculating elastic properties of a material. This includes creating an elastic tensor, shear modulus, bulk modulus, and other related properties with the help of strain and stress analyses. It leverages the provided ASE Calculator for computations and supports relaxation of structures when necessary.
- Variables:
calculator – The ASE Calculator used for performing computations.
norm_strains – Sequence of normal strain values to be applied.
shear_strains – Sequence of shear strain values to be applied.
fmax – Maximum force tolerated for structure relaxation.
symmetry – Whether to apply symmetry reduction techniques during calculations.
relax_structure – Whether the initial structure should be relaxed before applying strains.
relax_deformed_structures – Whether to relax atomic positions in deformed/strained structures.
use_equilibrium – Whether to use equilibrium stress and strain in calculations.
relax_calc_kwargs – Additional arguments for relaxation calculations.
Initializes the class with parameters to construct normalized and shear strain values and control relaxation behavior for structures. Validates input parameters to ensure appropriate constraints are maintained.
- Parameters:
calculator (Calculator | str) – An ASE calculator object used to perform energy and force calculations. If string is provided, the corresponding universal calculator is loaded.
norm_strains – Sequence of normalized strain values applied during deformation. Can also be a single float. Must not be empty or contain zero.
shear_strains – Sequence of shear strain values applied during deformation. Can also be a single float. Must not be empty or contain zero.
fmax – Maximum force magnitude tolerance for relaxation. Default is 0.1.
symmetry – Boolean flag to enforce symmetry in deformation. Default is False.
relax_structure – Boolean flag indicating if the structure should be relaxed before applying strains. Default is True.
relax_deformed_structures – Boolean flag indicating if the deformed structures should be relaxed. Default is False.
use_equilibrium – Boolean flag indicating if equilibrium conditions should be used for calculations. Automatically enabled if multiple normal and shear strains are provided.
relax_calc_kwargs – Optional dictionary containing keyword arguments for structure relaxation calculations.
- _elastic_tensor_from_strains(strains: ArrayLike, stresses: ArrayLike, eq_stress: ArrayLike = None, tol: float = 1e-07) tuple[ElasticTensor, float] [source]
Compute the elastic tensor from given strain and stress data using least-squares fitting.
This function calculates the elastic constants from strain-stress relations, using a least-squares fitting procedure for each independent component of stress and strain tensor pairs. An optional equivalent stress array can be supplied. Residuals from the fitting process are accumulated and returned alongside the elastic tensor. The elastic tensor is zeroed according to the given tolerance.
- Parameters:
strains – Strain data array-like, representing different strain states.
stresses – Stress data array-like corresponding to the given strain states.
eq_stress – Optional array-like, equivalent stress values for equilibrium stress states. Defaults to None.
tol – A float representing the tolerance threshold used for zeroing the elastic tensor. Defaults to 1e-7.
- Returns:
- A tuple consisting of:
ElasticTensor object: The computed and zeroed elastic tensor in Voigt notation.
float: The summed residuals from least-squares fittings across all tensor components.
- calc(structure: Structure | dict[str, Any]) dict[str, Any] [source]
Performs a calculation to determine the elastic tensor and related elastic properties. It involves multiple steps such as optionally relaxing the input structure, generating deformed structures, calculating stresses, and evaluating elastic properties. The method supports equilibrium stress computation and various relaxations depending on configuration.
- Parameters:
structure – The input structure which can either be an instance of Structure or a dictionary containing structural data.
- Returns:
A dictionary containing the calculation results that include: - elastic_tensor: The computed elastic tensor of the material. - shear_modulus_vrh: Shear modulus obtained from the elastic tensor
using the Voigt-Reuss-Hill approximation.
bulk_modulus_vrh: Bulk modulus calculated using the Voigt-Reuss-Hill approximation.
youngs_modulus: Young’s modulus derived from the elastic tensor.
residuals_sum: The residual sum from the elastic tensor fitting.
structure: The (potentially relaxed) final structure after calculations.