matcalc._diffusion module
Calculator for ionic diffusivity and conductivity via MD and DiffusionAnalyzer.
- class DiffusionCalc(calculator: Calculator | str, *, specie: str, temperature: float, timestep: float, loginterval: int, backend: Literal['ase', 'lammps'] = 'ase', ensemble: _ASE_ENSEMBLES = 'nvt_nose_hoover', steps: int = 100000, equilibration_frames: int = 0, taut: float = 100.0, seed: int | None = None, relax_structure: bool = True, relax_atoms_only: bool = True, set_com_stationary: bool = True, set_zero_rotation: bool = False, relax_calc_kwargs: dict | None = None, analyzer_kwargs: dict[str, Any] | None = None, **md_kwargs: Any)[source]
Bases:
PropCalcCalculate ionic diffusivity and conductivity from an MD trajectory.
Runs MD with
MDCalcorLAMMPSMDCalcand analyses the equilibrated trajectory with pymatgen’s DiffusionAnalyzer. An input dict containingtrajectoryskips MD and uses those frames directly. Requires thediffusionextra.Initialize the MD protocol and diffusion analysis.
- Parameters:
calculator – ASE calculator instance or universal model name.
specie – Symbol of the mobile ion species, e.g.
"Li".temperature – Simulation temperature in Kelvin, also used for the conductivity. For a supplied trajectory, the temperature it was run at.
timestep – MD time step in femtoseconds. For a supplied trajectory, the step it was run with.
loginterval – Steps between saved frames, also used as the analyzer’s
step_skip. For a supplied trajectory, the interval it was saved with.backend – MD engine. LAMMPS requires a model name string and runs in a temporary directory.
ensemble – Ensemble supported by the selected MD engine. Use NVT or NVE: the analysis unwraps displacements on each frame’s cell, which is only approximate when the cell fluctuates.
steps – Total number of MD steps.
equilibration_frames – Leading saved frames discarded by the internal MD run. The default of 0 keeps the thermostat transient from the Maxwell-Boltzmann start in the MSD, which biases the linear fit for short runs. Set it to cover at least the equilibration period, e.g. a few ps (
equilibration_frames * loginterval * timestepfs).taut – Thermostat time constant in femtoseconds.
seed – Seed for initial velocities on each MD run; must be positive for LAMMPS. None uses a random seed.
relax_structure – Whether to relax the structure before MD.
relax_atoms_only – Relax atomic positions only, keeping the input cell. Set False to also relax the cell; this gives the 0 K volume, which excludes thermal expansion and typically lowers D at the elevated temperatures used for Arrhenius fits.
set_com_stationary – Remove initial center-of-mass momentum.
set_zero_rotation – Remove initial angular momentum.
relax_calc_kwargs – Extra arguments for RelaxCalc when relaxation is enabled. A
relax_cellentry here takes precedence overrelax_atoms_only.analyzer_kwargs – Extra arguments for DiffusionAnalyzer, e.g.
smoothed.**md_kwargs – Additional arguments forwarded to the selected MD calculator in its native units. Relative LAMMPS file paths are temporary; absolute paths retain explicit outputs.
- _build_md_calc() MDCalc | LAMMPSMDCalc[source]
Build the MD calculator with a fresh initial-velocity generator.
- calc(structure: Structure | Atoms | dict[str, Any]) dict[str, Any][source]
Compute diffusivity and conductivity.
- Parameters:
structure – Structure, ASE Atoms, or a result dict. If the dict contains
trajectory(ASE Atoms or pymatgen Structures), all supplied frames are analysed without MD or further equilibration trimming. Set temperature, timestep and loginterval to match that trajectory.- Returns:
Dict with
diffusivity(cm²/s),conductivity(mS/cm),final_structure,trajectoryand_units, preserving upstream fields and the energy outputs from any internal MD run.