Skip to content

Molecular dynamics with UFF ​

The exploratory MD entry points integrate the UFF potential with velocity Verlet. They are intended for short sanity trajectories (vibrations, local relaxation, viewer demos), not for production thermodynamic sampling.

Status. Implemented on the Rust, Python and WASM surfaces. There is no CLI command. UFF is the only force field; NVE and Berendsen NVT are the only ensembles.

Feature. Core.

NVE propagation ​

For Cartesian coordinate xi, velocity vi and mass mi,

xi(t+Δt)=xi(t)+vi(t)Δt+12ai(t)Δt2,vi(t+Δt)=vi(t)+12[ai(t)+ai(t+Δt)]Δt,ai=−1mi∂UUFF∂xi.

The first frame records the input geometry and the initial kinetic energy. A trajectory with n_steps therefore contains n_steps + 1 frames at times 0, Δt, …, n_steps·Δt. The reported energy_drift_percent compares the total NVE energy of the first and last frames; it is null for thermostatted runs.

flowchart LR
    A[SMILES + coords] --> B[Parse and validate 3N finite coords]
    B --> C[Build UFF force field and gradient]
    C --> D[Initialize velocities: zero for NVE, Maxwell-Boltzmann for NVT]
    D --> E[Velocity Verlet step]
    E --> F[NVT: Berendsen velocity rescale]
    F --> G[Record frame: x, U, K, T]
    G --> H{step == n_steps?}
    H -- no --> E
    H -- yes --> I[MdTrajectory: frames, dt, notes, drift]

Berendsen NVT ​

NVT initializes velocities from a Maxwell-Boltzmann distribution at target_temp_k and rescales them after each step:

λ=1+Δtτ(T0T−1),vi←λvi,

with λ clamped to [0.5, 2]. The Berendsen thermostat suppresses temperature fluctuations too strongly and does not generate a canonical ensemble; use it to keep a short trajectory near a set point, not to compute thermodynamic averages.

Units and controls ​

QuantityUnit
CoordinatesÅ
Time step / frame timefs
Potential and kinetic energykcal/mol
TemperatureK
Thermostat coupling timefs

n_steps ≥ 1, dt_fs finite > 0, coordinates exactly 3N finite values, and for NVT target_temp_k finite > 0 and thermostat_tau_fs finite > 0. A non-finite coordinate, energy or velocity at any step aborts the run with MD diverged at step N.

API ​

rust
use sci_form::{compute_md_trajectory, compute_md_trajectory_nvt};

let conf = sci_form::embed("CCO", 42);
let nve = compute_md_trajectory("CCO", &conf.coords, 100, 0.25, 7)?;
let nvt = compute_md_trajectory_nvt("CCO", &conf.coords, 500, 0.25, 17, 300.0, 10.0)?;
for frame in &nvt.frames {
    println!("{} fs  T={:.1} K  U={:.3} kcal/mol",
        frame.time_fs, frame.temperature_k, frame.potential_energy_kcal_mol);
}
SurfaceEntry point
Rustcompute_md_trajectory, compute_md_trajectory_nvt
Pythoncompute_md_trajectory, compute_md_trajectory_nvt (deprecated md_trajectory*)
WASMcompute_md_trajectory[_seed64], compute_md_trajectory_nvt[_seed64]
CLInot exposed

See the Python API and TypeScript API for the frame schema.

Multi-backend MD (WASM) ​

The WASM surface also exposes compute_md_trajectory_with_method. It takes an explicit elements array and a backend:

BackendEnergy/gradient
uffUFF analytic gradient (fast)
pm3PM3 gradient, converted eV → kcal/mol
xtbGFN2-xTB gradient, converted eV → kcal/mol

target_temp_k > 0 enables the Berendsen thermostat with a fixed 100 fs coupling; 0 disables it. Negative/NaN targets are errors. The explicit elements must match the SMILES atom count and element sequence, coordinates must be exactly 3N and finite, dt_fs finite and positive, and n_steps ≥ 1. PM3/xTB are much slower because their gradients are numerical.

typescript
const traj = JSON.parse(compute_md_trajectory_with_method(
  'CCO', coords, elements, 5, 0.25, 42, 300, 'uff',
));

1D reaction dynamics (WASM) ​

compute_reaction_dynamics embeds one reactant and one product molecule, aligns the product into the reactant atom order, runs a simplified NEB for the reactive zone, and adds approach/departure frames with UFF/MMFF94/PM3/xTB/GFN/HF-3c energies.

flowchart LR
    A[Reactant SMILES] --> B[Embed]
    C[Product SMILES] --> D[Embed]
    B --> E[Element/bond-order graph-isomorphism atom mapping]
    D --> E
    E --> F[Product-guided reactant complex]
    F --> G[Simplified NEB]
    G --> H[Approach + reaction + departure frames]
    H --> I[TS = highest-energy frame]

Scope. The 1D path accepts exactly one molecule per side and requires the reactant and product to be isomorphic as element/connectivity/bond-order labelled graphs. The mapping enumerates every labelled-graph isomorphism and keeps the one with the lowest Kabsch RMSD, so symmetry-equivalent atoms follow the geometry rather than the SMILES atom order. For CCO → OCC the measured activation is 1.1165093760850304 kcal/mol (previously a spurious ~1179 kcal/mol) with finite frames; CC → CC returns 0.21685071115779975 kcal/mol and CCO → CCO returns a near-zero barrier.

Reactions that change connectivity or bond orders — including hydrogen migration such as the keto–enol pair CC=O → C=C-O — have no labelled-graph isomorphism and are rejected explicitly with a not isomorphic error instead of returning a non-physical energy. Multi-fragment reactions and connectivity-changing paths belong to the Rust-only 3D reaction dynamics, which keeps a distance-based fallback and records that limitation in its notes. The 1D path is still exploratory: inspect the frame energies before reporting a barrier.

Config validation: far_distance and reactive_distance finite and positive, NEB images ≥ 2, NEB iterations ≥ 1, step_size finite positive, spring_k finite non-negative, and energies must be finite. Invalid backend names are errors. Multi-fragment input, invalid configs and backend failures return an error object rather than zero-energy frames.

Validation ​

GateObservableResult
Frame countn_steps=100101 frames, last time 25 fs at dt=0.25
Velocity VerletCC NVE, 100 stepsfinite coordinates and finite drift
NVT thermostatCCO, 500 steps at 300 K, τ=10 fslast-50-frame mean 323.8 K
Invalid controlsdt ≤ 0/NaN/Inf, temp ≤ 0/NaN, τ ≤ 0/NaNrejected
Invalid geometrynon-finite coordinate or wrong lengthrejected
Divergencenon-finite stepaborts with step index

The NVT mean is a thermostat smoke check, not a temperature-calibration claim.

Limitations ​

  • UFF only; no polarizable, reactive or ML potential.
  • No SHAKE/RATTLE constraints, no rigid water, no PBC.
  • No barostat or NPT ensemble.
  • Berendsen is not canonical; no Nosé–Hoover/Langevin thermostat here.
  • No trajectory file writer (XYZ/DCD); callers serialize the JSON frames.
  • Fixed dt; no adaptive or multiple-time-step integration.
  • Energies are UFF kcal/mol, not a quantum potential energy surface.

Released under the MIT License.