lmmolecule reference
Complete reference for lmmolecule CLI flags, environment variables, Md, System, and Sim schema methods, and exit codes.
Command-line flags and environment variables
| Flag or variable | Description |
|---|---|
| --lmcode FILE [FILE ...] | Execute compiled LMScript bytecode FILE and print the JSON result envelope |
| --dry-run --lmcode FILE | Validate bytecode FILE against the host without running simulations or file I/O |
| --lmcode-schema | Print human-readable host schema summary |
| --lmcode-schema --json | Print the embedded JSON DSL schema (lmmolecule + lmcode_std_v3) |
| --lmcode-signatures | Print canonical type, method, and function signatures |
| --version | Print the lmmolecule release version |
| --notices | Print embedded third-party open-source license notices (OpenMM, Lepton, PocketFFT, SFMT, L-BFGS) |
| LMMOLECULE_MAX_MEMORY_MB | Override the default 4096 MiB process memory budget |
Md methods (context object md)
| Method | Signature | Description |
|---|---|---|
| system | () -> System | Create a new empty molecular system builder |
| platform | (name: string) -> Md | Select OpenMM execution platform: "reference" (double precision) or "cpu" (SIMD mixed precision) |
| threads | (n: int) -> Md | Set CPU platform thread count for subsequent simulations (1 for byte-identical reruns) |
| eval | (expr: string) -> float | Evaluate a Lepton expression with constants pi, e, kB, and one_4pi_eps0 |
| assert_close | (actual: float, expected: float, tol: float) -> void | Assert that |actual - expected| <= tol, failing with exit code 3 otherwise |
| (msg: string) -> void | Write a diagnostic line to stderr | |
| version | () -> string | Return the lmmolecule version string |
System methods
| Method | Signature | Description |
|---|---|---|
| box | (lx: float, ly: float, lz: float) -> System | Set orthorhombic periodic box dimensions in nm |
| particle | (mass: float) -> int | Add a particle at the origin with mass in amu and return its 0-based index |
| add_particle | (mass: float, x: float, y: float, z: float) -> System | Add a particle with mass (amu) and coordinates (nm) |
| count | () -> int | Return the current number of particles in the system |
| fcc | (cells: int, a: float, mass: float) -> System | Populate a 4 * cells^3 face-centered cubic lattice with lattice constant a (nm) |
| rocksalt | (cells: int, a: float, mass_a: float, mass_b: float, q: float) -> System | Populate an 8 * cells^3 NaCl rock-salt lattice with alternating charges +q and -q |
| gas | (n: int, box_len: float, mass: float, seed: int) -> System | Place n non-overlapping particles randomly in a cubic box of side box_len (nm) |
| load_xyz | (path: string, mass: float) -> System | Load particle coordinates (nm) from an XYZ file with uniform mass |
| load_pdb | (path: string) -> System | Load ATOM/HETATM coordinates (converted from Angstroms to nm), element masses, and CRYST1 box from a PDB file |
| water | (model: string, x: float, y: float, z: float) -> System | Add one rigid constrained water molecule ("tip3p" or "spce") at (x, y, z) nm |
| water_box | (model: string, n: int, spacing: float, seed: int) -> System | Populate n^3 rigid water molecules ("tip3p" or "spce") on a cubic grid of spacing nm |
| constrain | (i: int, j: int, d: float) -> System | Add a rigid distance constraint of length d (nm) between particles i and j |
| pos | (i: int, x: float, y: float, z: float) -> System | Set initial position (nm) of particle i |
| vel | (i: int, vx: float, vy: float, vz: float) -> System | Set initial velocity (nm/ps) of particle i |
| bond | (i: int, j: int, r0: float, k: float) -> System | Add a harmonic bond 0.5 * k * (r - r0)^2 between particles i and j |
| angle | (i: int, j: int, k: int, theta0: float, k_angle: float) -> System | Add a harmonic bond angle 0.5 * k_angle * (theta - theta0)^2 in radians |
| torsion | (i: int, j: int, k: int, l: int, periodicity: int, phase: float, k_torsion: float) -> System | Add a periodic dihedral torsion k_torsion * (1 + cos(periodicity * phi - phase)) |
| lj | (eps: float, sigma: float, cutoff: float) -> System | Set default Lennard-Jones 12-6 parameters (eps in kJ/mol, sigma and cutoff in nm) |
| lj_particle | (i: int, eps: float, sigma: float) -> System | Override Lennard-Jones epsilon and sigma for particle i |
| charge | (i: int, q: float) -> System | Set partial charge q (in elementary charge e) on particle i |
| coulomb | (method: string, cutoff: float) -> System | Select electrostatic method ("none", "cutoff" (same as "reaction_field"), "ewald", or "pme") and cutoff (nm) |
| dispersion_correction | (enabled: bool) -> System | Enable or disable isotropic long-range Lennard-Jones tail correction |
| dielectric | (eps: float) -> System | Set reaction-field solvent dielectric constant (default 78.3; 1.0 for shifted cutoff) |
| exclude | (i: int, j: int) -> System | Exclude nonbonded interactions between particle pair (i, j) |
| custom_external | (expr: string, params: string) -> System | Add a Lepton custom external force field function of x, y, z |
| custom_bond | (i: int, j: int, expr: string) -> System | Add a Lepton custom bond potential function of distance r between i and j |
| custom_nonbonded | (expr: string, params: string, cutoff: float) -> System | Add a Lepton custom pairwise nonbonded potential function of r within cutoff |
| barostat | (pressure_bar: float, temp_K: float, freq: int, seed: int) -> System | Add a Monte Carlo NPT barostat at pressure_bar and temp_K |
| andersen | (temp_K: float, rate: float, seed: int) -> System | Add an Andersen collision thermostat (for use with verlet integrator) |
| sim | (integrator: string, dt: float, temp_K: float, friction: float, seed: int) -> Sim | Compile the system into a simulation context ("verlet" or "langevin") |
Sim methods
| Method | Signature | Description |
|---|---|---|
| velocities | (temp_K: float, seed: int) -> Sim | Assign Maxwell-Boltzmann velocities at temp_K respecting constraints |
| minimize | (tol: float, max_iter: int) -> Sim | Run L-BFGS local energy minimization |
| report | (path: string, every: int) -> Sim | Write thermodynamic columns (step, time, ke, pe, energy, temperature) every N steps |
| xyz | (path: string, every: int) -> Sim | Append multi-frame XYZ coordinates (in nm) every N steps |
| save_xyz | (path: string) -> Sim | Write current coordinates (in nm) to a single-frame XYZ file |
| save_pdb | (path: string) -> Sim | Write current coordinates (in Angstroms) and CRYST1 box to a PDB file |
| step | (n: int) -> Sim | Advance the simulation by n time steps |
| dof | () -> int | Return active degrees of freedom (3 * mobile_particles - constraints) |
| mark | () -> Sim | Record current unwrapped positions as the reference for msd() |
| msd | () -> float | Return mean squared displacement (nm^2) of mobile particles since mark() |
| rdf | (path: string, rmax: float, bins: int, frames: int, stride: int) -> Sim | Sample and write all-pair radial distribution function g(r) over frames * stride steps |
| rdf_pair | (path: string, sym_a: string, sym_b: string, rmax: float, bins: int, frames: int, stride: int) -> Sim | Sample and write element-pair radial distribution function g(r) |
| ke / pe / energy | () -> float | Return current kinetic, potential, or total energy in kJ/mol |
| temperature | () -> float | Return instantaneous kinetic temperature in K over dof() |
| time | () -> float | Return elapsed simulation time in ps |
| x / y / z | (i: int) -> float | Return x, y, or z position (nm) of particle i |
| vx / vy / vz | (i: int) -> float | Return x, y, or z velocity (nm/ps) of particle i |
| fx / fy / fz | (i: int) -> float | Return x, y, or z force (kJ/(mol*nm)) on particle i |
| distance | (i: int, j: int) -> float | Return Euclidean distance (nm) between particles i and j |
| angle_val | (i: int, j: int, k: int) -> float | Return bond angle i-j-k in radians |
| box_volume | () -> float | Return current periodic box volume in nm^3 |
Exit codes
| Code | Phase | Meaning |
|---|---|---|
| 0 | run | Simulation and all assertions completed successfully |
| 2 | cli | Invalid CLI flags or metadata query error |
| 3 | load / run | Bytecode error, OpenMM exception, non-finite state, failed md.assert_close, or memory budget exceeded |
| 4 | app | Application or output verification failure |