Overview
TheMD task drives ASE molecular dynamics simulations in the NVE, NVT, or NPT ensemble. It supports temperature and pressure schedules (time-varying control), trajectory restart, and multiple integrators per ensemble. The task is registered in Prefect as MD with a TASK_SOURCE + INPUTS cache policy.
Function signature
Parameters
ase.Atoms
required
The input atomic structure. A copy is made internally.
ase.calculators.calculator.BaseCalculator
required
ASE-compatible calculator for energy and force evaluations.
string
default:"nvt"
Statistical ensemble for the simulation. Accepted values:
string | MolecularDynamics
default:"langevin"
Integrator string name or an ASE
MolecularDynamics subclass. Available string values per ensemble:String matching is case-insensitive.
number | None
default:"None"
Integration time step in femtoseconds. When
None, defaults to 0.5 fs if the structure contains hydrogen isotopes, or 2.0 fs otherwise.number
default:"1000"
Total simulation time in femtoseconds. The number of MD steps is computed as
int(total_time / time_step).number | Sequence | np.ndarray | None
default:"300.0"
Temperature target in Kelvin.
- Scalar (
float): constant temperature throughout the run. - Sequence / 1-D array: linearly interpolated onto all MD steps to create a temperature schedule (ramp or arbitrary profile).
None/ ignored for"nve"ensemble.
number | Sequence | np.ndarray | None
default:"None"
External pressure in eV/ų.
- Scalar (
float): constant pressure throughout the run. - Sequence / 1-D array: linearly interpolated to create a pressure schedule.
- Required only for
"npt"ensemble; ignored for"nve"and"nvt".
dict | None
default:"None"
Extra keyword arguments forwarded to the integrator constructor. For the Langevin integrator,
friction defaults to 10.0 ps⁻¹ (same default as VASP) when not specified. For NPT, the special key fraction_traceless (default 1.0) controls the traceless part of the stress.number | None
default:"None"
Integer seed for
numpy.random.default_rng used to draw the initial Maxwell–Boltzmann velocity distribution. Set for reproducible runs.boolean
default:"true"
Remove net linear momentum from initial velocities using ASE
Stationary.boolean
default:"true"
Remove net angular momentum from initial velocities using ASE
ZeroRotation.string | Path | None
default:"None"
Path to an ASE trajectory file (
.traj) for writing simulation frames. Parent directories are created automatically. When None, no trajectory is written.number
default:"1"
Write a frame to the trajectory file every
traj_interval steps.boolean
default:"true"
When
True and traj_file already exists, the simulation resumes from the last frame (positions and momenta are restored). If reading the existing trajectory fails, the run starts fresh.Return value
ase.Atoms
Final atomic structure with positions and momenta from the last MD step.
datetime.timedelta
Wall-clock duration of the MD integration loop.
int
Number of MD steps performed (may be less than
total_time / time_step when restarting from a partially completed trajectory).Examples
- NVE
- NVT (Langevin)
- NVT (temperature ramp)
- NPT
For NPT dynamics the cell is transformed to upper triangular form automatically (required by the ASE
NPT implementation). If you supply a non-upper-triangular cell, it will be rotated; the physical geometry is preserved.