lmparticle
lmparticle is a seeded Monte Carlo photon transport host for LMScript with embedded NIST XCOM cross sections. It simulates shielding, detector spectra, radiographic contrast, and collision kerma from 1 keV to 20 MeV in a self-contained 2.5 MB executable.
Quick reference
npm install -g @lmctl-ai/lmctl
lmparticle --version
lmparticle --lmcode-schema --json
lmctl autorun examples/depth_dose.lms
| Object or method | Signature or syntax | Purpose |
|---|---|---|
| context rad: Rad | rad.builtin(name) | rad.material(name, density) | Load 15 built-in materials or define custom mixtures from 19 NIST XCOM elements or custom element_table data. |
| Material | m.mu(E), m.mu_mass(E), m.mu_partial(E, proc), m.mfp(E), m.hvl(E) | Query linear and mass attenuation coefficients, partial cross sections, mean free paths, and half-value layers. |
| Geometry | g.box(...), g.slab(...), g.sphere(...), g.cylinder(...) | Build multi-region 3D geometries where earlier regions take priority on overlap and outside is vacuum. |
| Source | s.point(...), s.disc(r), s.beam(...), s.cone(...), s.isotropic(), s.energy(E), s.line(E, w) | Configure spatial origin, angular distribution, and monoenergetic or multi-line photon energies in MeV. |
| Sim / Result | rad.simulation(g, s).plane(...).spectrum(...).pulse_height(...).seed(n).run(N) | Run seeded xoshiro256** transport and query collision kerma, plane crossings, spectra, and standard errors. |
p = _lmcode_ cli="lmparticle" install="github:lmctl-ai/lmparticle@latest";
let pb = rad.builtin("lead");
let g = rad.geometry().slab("shield", pb, 0.0, 1.0);
let s = rad.source().point(0.0, 0.0, -1.0).beam(0.0, 0.0, 1.0).energy(0.662);
let r = rad.simulation(g, s).plane("exit", "z", 1.0).seed(1).run(200000);
rad.assert_close(r.plane_uncollided("exit"), pow(2.718281828459045, -pb.mu(0.662)), 0.005);
end _lmcode_
r = run_lmcode(p);
require(r.ok, json_stringify(r));
Documentation pages
- Skill — authoring rules, CLI commands, unit conventions, safety rules, worked examples, and verification steps.
- Guide — photon physics models, collision kerma vs dose, geometry priority, variance reduction, and the standard lmcode_std_v3 library.
- Reference — complete CLI flags, Rad/Material/Geometry/Source/Sim/Result method tables, standard library catalog, and exit codes.