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 variableDescription
--lmcode FILE [FILE ...]Execute compiled LMScript bytecode FILE and print the JSON result envelope
--dry-run --lmcode FILEValidate bytecode FILE against the host without running simulations or file I/O
--lmcode-schemaPrint human-readable host schema summary
--lmcode-schema --jsonPrint the embedded JSON DSL schema (lmmolecule + lmcode_std_v3)
--lmcode-signaturesPrint canonical type, method, and function signatures
--versionPrint the lmmolecule release version
--noticesPrint embedded third-party open-source license notices (OpenMM, Lepton, PocketFFT, SFMT, L-BFGS)
LMMOLECULE_MAX_MEMORY_MBOverride the default 4096 MiB process memory budget

Md methods (context object md)

MethodSignatureDescription
system() -> SystemCreate a new empty molecular system builder
platform(name: string) -> MdSelect OpenMM execution platform: "reference" (double precision) or "cpu" (SIMD mixed precision)
threads(n: int) -> MdSet CPU platform thread count for subsequent simulations (1 for byte-identical reruns)
eval(expr: string) -> floatEvaluate a Lepton expression with constants pi, e, kB, and one_4pi_eps0
assert_close(actual: float, expected: float, tol: float) -> voidAssert that |actual - expected| <= tol, failing with exit code 3 otherwise
print(msg: string) -> voidWrite a diagnostic line to stderr
version() -> stringReturn the lmmolecule version string

System methods

MethodSignatureDescription
box(lx: float, ly: float, lz: float) -> SystemSet orthorhombic periodic box dimensions in nm
particle(mass: float) -> intAdd 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) -> SystemAdd a particle with mass (amu) and coordinates (nm)
count() -> intReturn the current number of particles in the system
fcc(cells: int, a: float, mass: float) -> SystemPopulate 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) -> SystemPopulate an 8 * cells^3 NaCl rock-salt lattice with alternating charges +q and -q
gas(n: int, box_len: float, mass: float, seed: int) -> SystemPlace n non-overlapping particles randomly in a cubic box of side box_len (nm)
load_xyz(path: string, mass: float) -> SystemLoad particle coordinates (nm) from an XYZ file with uniform mass
load_pdb(path: string) -> SystemLoad 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) -> SystemAdd one rigid constrained water molecule ("tip3p" or "spce") at (x, y, z) nm
water_box(model: string, n: int, spacing: float, seed: int) -> SystemPopulate n^3 rigid water molecules ("tip3p" or "spce") on a cubic grid of spacing nm
constrain(i: int, j: int, d: float) -> SystemAdd a rigid distance constraint of length d (nm) between particles i and j
pos(i: int, x: float, y: float, z: float) -> SystemSet initial position (nm) of particle i
vel(i: int, vx: float, vy: float, vz: float) -> SystemSet initial velocity (nm/ps) of particle i
bond(i: int, j: int, r0: float, k: float) -> SystemAdd 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) -> SystemAdd 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) -> SystemAdd a periodic dihedral torsion k_torsion * (1 + cos(periodicity * phi - phase))
lj(eps: float, sigma: float, cutoff: float) -> SystemSet default Lennard-Jones 12-6 parameters (eps in kJ/mol, sigma and cutoff in nm)
lj_particle(i: int, eps: float, sigma: float) -> SystemOverride Lennard-Jones epsilon and sigma for particle i
charge(i: int, q: float) -> SystemSet partial charge q (in elementary charge e) on particle i
coulomb(method: string, cutoff: float) -> SystemSelect electrostatic method ("none", "cutoff" (same as "reaction_field"), "ewald", or "pme") and cutoff (nm)
dispersion_correction(enabled: bool) -> SystemEnable or disable isotropic long-range Lennard-Jones tail correction
dielectric(eps: float) -> SystemSet reaction-field solvent dielectric constant (default 78.3; 1.0 for shifted cutoff)
exclude(i: int, j: int) -> SystemExclude nonbonded interactions between particle pair (i, j)
custom_external(expr: string, params: string) -> SystemAdd a Lepton custom external force field function of x, y, z
custom_bond(i: int, j: int, expr: string) -> SystemAdd a Lepton custom bond potential function of distance r between i and j
custom_nonbonded(expr: string, params: string, cutoff: float) -> SystemAdd a Lepton custom pairwise nonbonded potential function of r within cutoff
barostat(pressure_bar: float, temp_K: float, freq: int, seed: int) -> SystemAdd a Monte Carlo NPT barostat at pressure_bar and temp_K
andersen(temp_K: float, rate: float, seed: int) -> SystemAdd an Andersen collision thermostat (for use with verlet integrator)
sim(integrator: string, dt: float, temp_K: float, friction: float, seed: int) -> SimCompile the system into a simulation context ("verlet" or "langevin")

Sim methods

MethodSignatureDescription
velocities(temp_K: float, seed: int) -> SimAssign Maxwell-Boltzmann velocities at temp_K respecting constraints
minimize(tol: float, max_iter: int) -> SimRun L-BFGS local energy minimization
report(path: string, every: int) -> SimWrite thermodynamic columns (step, time, ke, pe, energy, temperature) every N steps
xyz(path: string, every: int) -> SimAppend multi-frame XYZ coordinates (in nm) every N steps
save_xyz(path: string) -> SimWrite current coordinates (in nm) to a single-frame XYZ file
save_pdb(path: string) -> SimWrite current coordinates (in Angstroms) and CRYST1 box to a PDB file
step(n: int) -> SimAdvance the simulation by n time steps
dof() -> intReturn active degrees of freedom (3 * mobile_particles - constraints)
mark() -> SimRecord current unwrapped positions as the reference for msd()
msd() -> floatReturn mean squared displacement (nm^2) of mobile particles since mark()
rdf(path: string, rmax: float, bins: int, frames: int, stride: int) -> SimSample 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) -> SimSample and write element-pair radial distribution function g(r)
ke / pe / energy() -> floatReturn current kinetic, potential, or total energy in kJ/mol
temperature() -> floatReturn instantaneous kinetic temperature in K over dof()
time() -> floatReturn elapsed simulation time in ps
x / y / z(i: int) -> floatReturn x, y, or z position (nm) of particle i
vx / vy / vz(i: int) -> floatReturn x, y, or z velocity (nm/ps) of particle i
fx / fy / fz(i: int) -> floatReturn x, y, or z force (kJ/(mol*nm)) on particle i
distance(i: int, j: int) -> floatReturn Euclidean distance (nm) between particles i and j
angle_val(i: int, j: int, k: int) -> floatReturn bond angle i-j-k in radians
box_volume() -> floatReturn current periodic box volume in nm^3

Exit codes

CodePhaseMeaning
0runSimulation and all assertions completed successfully
2cliInvalid CLI flags or metadata query error
3load / runBytecode error, OpenMM exception, non-finite state, failed md.assert_close, or memory budget exceeded
4appApplication or output verification failure