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, units_GPa: bool = False, relax_calc_kwargs: dict | None = None)[source]
Bases:
PropCalcElastic tensor and related moduli via strain-stress fitting with pymatgen.
- Parameters:
calculator – ASE calculator or universal model name string.
norm_strains – Normal strains (non-empty, no zeros); scalar broadcast to one value.
shear_strains – Shear strains (non-empty, no zeros); scalar allowed.
fmax – Force tolerance for relaxations.
symmetry – Pass-through to pymatgen
DeformedStructureSet.relax_structure – Relax parent structure before generating deformations.
relax_deformed_structures – Relax each deformed structure before stress eval.
use_equilibrium – Use equilibrium stress in fit; forced True if only one strain type.
units_GPa – If True, return moduli (and elastic tensor / residuals) in GPa. Defaults to False, in which case values are returned in pymatgen’s native units of eV/A^3.
relax_calc_kwargs – Optional kwargs for
RelaxCalc.
- _elastic_tensor_from_strains(strains: ArrayLike, stresses: ArrayLike, eq_stress: ArrayLike = None, tol: float = 1e-07) tuple[ElasticTensor, float][source]
Fit elastic constants from strain-stress pairs (Voigt), optionally subtracting equilibrium stress.
- Parameters:
strains – Strain states (array-like) for each deformation.
stresses – Matching stress tensors (array-like).
eq_stress – Equilibrium stress to subtract; None to omit.
tol – Small components below this are zeroed on the fitted tensor.
- Returns:
Tuple of
(ElasticTensor, residuals_sum).
- calc(structure: Structure | Atoms | dict[str, Any]) dict[str, Any][source]
- Parameters:
structure – Pymatgen structure, ASE atoms, or dict with structure keys.
- Returns:
Dict including
elastic_tensor,shear_modulus_vrh,bulk_modulus_vrh,youngs_modulus,residuals_sum,structure, and merged relaxation fields.elastic_tensor,shear_modulus_vrh,bulk_modulus_vrhandresiduals_sumare returned in GPa ifunits_GPa=True, otherwise in eV/A^3 (pymatgen’s native units).youngs_modulusis always reported in pymatgen’s default units (see pymatgenElasticTensordocs).