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
The input atomic structure. A copy is made internally.
ASE-compatible calculator for energy and force evaluations.
Statistical ensemble for the simulation. Accepted values:
| Value | Description |
|---|---|
"nve" | Microcanonical — constant energy, volume |
"nvt" | Canonical — constant temperature, volume |
"npt" | Isothermal-isobaric — constant temperature, pressure |
Integrator string name or an ASE
String matching is case-insensitive.
MolecularDynamics subclass. Available string values per ensemble:| Ensemble | Accepted strings |
|---|---|
nve | "velocityverlet" |
nvt | "langevin", "nose-hoover", "andersen", "berendsen" |
npt | "nose-hoover", "berendsen" |
Integration time step in femtoseconds. When
None, defaults to 0.5 fs if the structure contains hydrogen isotopes, or 2.0 fs otherwise.Total simulation time in femtoseconds. The number of MD steps is computed as
int(total_time / time_step).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.
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".
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.Integer seed for
numpy.random.default_rng used to draw the initial Maxwell–Boltzmann velocity distribution. Set for reproducible runs.Remove net linear momentum from initial velocities using ASE
Stationary.Remove net angular momentum from initial velocities using ASE
ZeroRotation.Path to an ASE trajectory file (
.traj) for writing simulation frames. Parent directories are created automatically. When None, no trajectory is written.Write a frame to the trajectory file every
traj_interval steps.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
Final atomic structure with positions and momenta from the last MD step.
Wall-clock duration of the MD integration loop.
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.