Crate dynamics

Crate dynamics 

Source
Expand description

See the Readme for a general overview, or Molchanica docs, MD section for more information about assumptions. Or see the examples folder on Github for how to use this in your application.

The textual information here is informal, and aimed at code maintenance; not library use.

This module contains high-level tools for running Newtonian molecular dynamics simulations.

Good article A summary on molecular dynamics

Amber Force Fields reference Small molucules using GAFF2 Amber RM 2025

To download .dat files (GAFF2), download Amber source (Option 2) here. Files are in dat -> leap -> parm

Base units: Å, ps (10^-12), Dalton (AMU), native charge units (derive from other base units; not a traditional named unit).

Amber: ff19SB for proteins, gaff2 for ligands. (Based on recommendations from https://ambermd.org/AmberModels.php).

We use the term “Non-bonded” interactions to refer to Coulomb, and Lennard Interactions, the latter of which is an approximation for both Van der Waals force and exclusion.

§A broad list of components of this simulation:

  • Water: Rigid OPC water molecules that have mutual non-bonded interactions with dynamic atoms and water
  • Thermostat/barostat, with a way to specify temp, pressure, water density
  • OPC water model
  • Cell wrapping
  • Velocity Verlet integration (Water and non-water)
  • Amber parameters for mass, partial charge, VdW (via LJ), dihedral/improper, angle, bond len
  • Optimizations for Coulomb: Ewald/SPME.
  • Optimizations for LJ: Dist cutoff for now.
  • Amber 1-2, 1-3 exclusions, and 1-4 scaling of covalently-bonded atoms.
  • Rayon parallelization of non-bonded forces
  • WIP SIMD and CUDA parallelization of non-bonded forces, depending on hardware availability. todo
  • A thermostat and barostat
  • An energy-measuring system.
  • An integrated tool for inferring atom types, bonded-parameter overrides, and partial charges for arbitrary small organic molecules. (Similar to Amber’s Antechamber)

A timing test, using bond-stretching forces between two atoms only. Measure the period of oscillation for these atom combinations, e.g. using custom Mol2 files. c6-c6: 35fs (correct). os-os: 47fs nc-nc: 34fs hw-hw: 9fs Our measurements, 2025-08-04 c6-c6: 35fs os-os: 31fs nc-nc: 34fs (Correct) hw-hw: 6fs


We use traditional MD non-bonded terms to maintain geometry: Bond length, valence angle between 3 bonded atoms, dihedral angle between 4 bonded atoms (linear), and improper dihedral angle between each hub and 3 spokes. (E.g. at ring intersections). We also apply Coulomb force between atom-centered partial charges, and Lennard Jones potentials to simulate Van der Waals forces. These use spring-like forces to retain most geometry, while allowing for flexibility.

We use the OPC water model. (See water_opc.rs). For both maintaining the geometry of each water molecule, and for maintaining Hydrogen atom positions, we do not apply typical non-bonded interactions: We use SHAKE + RATTLE algorithms for these. In the case of water, it’s required for OPC compliance. For H, it allows us to maintain integrator stability with a greater timestep, e.g. 2fs instead of 1fs.

On f32 vs f64 floating point precision: f32 may be good enough for most things, and typical MD packages use mixed precision. Long-range electrostatics are a good candidate for using f64. Or, very long runs.

Note on performance: It appears that non-bonded forces dominate computation time. This is my observation, and it’s confirmed by an LLM. Both LJ and Coulomb take up most of the time; bonded forces are comparatively insignificant. Building neighbor lists are also significant. These are the areas we focus on for parallel computation (Thread pools, SIMD, CUDA)

Re-exports§

pub use integrate::Integrator;

Modules§

integrate
Contains integration code, including the primary time step.
minimize_energy
param_inference
Uses reasoning similar to AnteChamber’s to estimate force field parameters using DEF files. Specifically, we use DEF_GFF2 for Gaff2 force field names, and DEF_ABCG2 for FRCMOD bonded paraemter (generally dihedral) overrides. Reference source code
params
For Amber and other parameters.
partial_charge_inference
For inferring partial charge of small organic molecules using Amber’s GeoStd library as training data. Uses a neural net. Force field types must be assigned prior to running this, e.g. from the param_inference module.
snapshot
Related to storing snapshots (also known as trajectories) of MD runs.
snapshot_mdt
For saving and loading to our custom snapshot format: MDT (Molecular Dynamics Trajectory)

Structs§

AtomDynamics
A trimmed-down atom for use with molecular dynamics. Contains parameters for single-atom, but we use ParametersIndex for multi-atom parameters.
Dihedral
An amino acid in a protein structure, including all dihedral angles required to determine the conformation. Includes backbone and side chain dihedral angles. Doesn’t store coordinates, but coordinates can be generated using forward kinematics from the angles.
ForcesOnWaterMol
Per-water, per-site force accumulator. Used transiently when applying nonbonded forces. This is the force on each atom in the molecule.
MdConfig
MdOverrides
These are primarily used for debugging and testing, but may be used for specific scenarios as well, e.g. if wishing to speed up computations for real-time use by removing long range forces.
MdState
MolDynamics
Packages information required to perform dynamics on a Molecule. This is used to initialize the simulation with atoms and related; one or more of these is passed at init.
ParamError
Represents problems loading parameters. For example, if an atom is missing a force field type or partial charge, or has a force field type that hasn’t been loaded.
WaterInitTemplate
We store pre-equilibrated water molecules in a template, and use it to initialize water for a simulation. This keeps the equilibration steps relatively low. Note that edge effects from tiling will require equilibration, as well as adjusting a template for the runtime temperature target.

Enums§

ComputationDevice
FfMolType
This is used to assign the correct force field parameters to a molecule.
HydrogenConstraint
We use this variant in the configuration API. Deferrs to HydrogenConstraintInner for holding constraints.
SimBoxInit
Note: The shortest edge should be > 2(r_cutoff + r_skin), to prevent atoms from interacting with their own image in the real-space component.

Constants§

LANGEVIN_GAMMA_DEFAULT
TAU_TEMP_DEFAULT

Functions§

compute_energy_snapshot
Set up with no water molecules or relaxation. Run one step to compute energies, then return the snapshot taken.
find_planar_posit
Given two positions, find the third planar position. Uses the central_posit_0 distance for the computed distances.
find_tetra_posit_final
Given 3 satellite atoms, find the 4th, in tetrahedral config.
find_tetra_posits
Given two satelite positions, find the third and fourth tetrahedral position. Uses the central, posit_0 distance for the computed distances.
load_snapshots_from_file
For calling by the application. Loads snapshots from a file (e.g. DCD/XTC/MDT) into memory.
merge_params
Add items from one parameter set to the other. If there are duplicates, the second set’s overrides the baseline.
populate_hydrogens_dihedrals
Adds hydrogens to a molecule, and populdates residue dihedral angles. This is useful in particular for mmCIF files from RCSB PDB, as they don’t have these. Uses Amber (or similar)-provided parameters as a guide.