QuantityCalculator module
- class QuantityCalculator.QuantityCalculator[source]
Bases:
objectDerived-quantity calculator for MD post-processing.
All methods are implemented as
@staticmethodfunctions and do not maintain internal state.Notes
Callers are responsible for providing consistent units. This class does not validate units or sampling assumptions.
- static calculateModuli(C_matrix)[source]
Compute isotropic elastic moduli from a stiffness matrix.
- Parameters:
C_matrix (array-like of shape (6, 6)) – Stiffness matrix in Voigt notation.
- Returns:
(bulk_modulus, shear_modulus, youngs_modulus).- Return type:
tuple of float
- static computeBulkModulus(stretch_sequence)[source]
Fit an equation of state to compute the bulk modulus.
Collects potential energy and volume from a stretch sequence, sorts by volume, and fits a Birch–Murnaghan EOS using ASE’s
ase.eos.EquationOfState.- Parameters:
stretch_sequence (sequence) – Sequence of frames containing energy and volume information.
- Returns:
float – Bulk modulus in GPa.
Side Effects
————
Writes an EOS plot image file named
Ag-eos.png.
Notes
This function calls
_get(frame, name), which must be provided by the surrounding codebase.
- static computeDebyeTemperature(V_A3, mass_u, N, G, K)[source]
Estimate the Debye temperature from density and elastic moduli.
- Parameters:
V_A3 (float) – Volume in Å^3.
mass_u (float) – Total mass in atomic mass units (u).
N (int) – Number of atoms.
G (float) – Shear modulus (unit consistency required).
K (float) – Bulk modulus (same unit convention as G).
- Returns:
Debye temperature in Kelvin.
- Return type:
float
Notes
The factor
/ 10.18is used as a unit conversion (comment suggests conversion related to fs/Å). Ensure G, K, and density are consistent with this convention.
- static computeLindemannIndex(msd, nearest_neighbour)[source]
Compute the Lindemann index.
- Parameters:
msd (float) – Mean-squared displacement (typically in Å^2).
nearest_neighbour (float) – Nearest-neighbour distance (typically in Å).
- Returns:
Lindemann index (dimensionless).
- Return type:
float
- static computeSelfDiffusionCoefficient(msd_list, sample_spacing)[source]
Estimate self-diffusion coefficient from mean-squared displacement (MSD).
Uses the Einstein relation with an endpoint slope estimate:
D ≈ (MSD_end - MSD_0) / (6 * (t_end - t_0))
- Parameters:
msd_list (array-like) – Mean-squared displacement values (typically in Å^2).
sample_spacing (float) – Time between MSD samples (typically in fs).
- Returns:
Diffusion coefficient in Å^2/fs (if MSD is Å^2 and time is fs).
- Return type:
float
Notes
This uses only the first and last MSD points. For better statistics, a linear fit over a diffusive regime is often preferred.
- static computeSpecificHeatNVT(E_tot_seq, total_mass_amu, T)[source]
Compute specific heat capacity from total energy fluctuations (NVT).
- Parameters:
E_tot_seq (array-like) – Total energy time series (typically in eV).
total_mass_amu (float) – Total mass of the system in atomic mass units (amu).
T (float) – Temperature in Kelvin.
- Returns:
Specific heat capacity in eV/(amu·K), assuming energies are in eV.
- Return type:
float
Notes
This uses a fluctuation expression based on the variance of the total energy time series.
- static nearestNeighborsMean(atoms_sequence, start, end=None)[source]
Compute mean nearest-neighbour distance over a range of configurations.
For each configuration in the interval [start, end), builds an ASE neighbour list using
natural_cutoffsand computes each atom’s nearest-neighbour distance. The return value is the mean over all atoms and all configurations in the interval.- Parameters:
atoms_sequence (sequence of ase.Atoms) – Sequence of atomic configurations.
start (int) – Start index (inclusive).
end (int, optional) – End index (exclusive). If None, uses
start + 1.
- Returns:
Mean nearest-neighbour distance in Å, or None if no neighbours could be found for some atom.
- Return type:
float or None