lmparticle reference

Complete command-line flags, Rad/Material/Geometry/Source/Sim/Result schema methods, built-in materials and elements, the standard lmcode_std_v3 catalog, and exit codes for lmparticle.

CLI flags and environment variables

Flag or variableArgumentsDescription
--versionnonePrint the lmparticle version string and exit 0.
--noticesnonePrint NIST XCOM citation and open-source license notices.
--lmcode-schema[--json]Print a human-readable schema summary or exact embedded schema JSON bytes.
--lmcode-signaturesnonePrint canonical context, function, and method signatures registered in the host.
--lmcodeFILELoad and execute compiled LMScript bytecode (repeatable for builder parts).
LMPARTICLE_MAX_MEMORY_MBinteger (default 4096)Maximum host memory budget in MiB before aborting cleanly with exit code 3.

Host schema types and methods (context rad: Rad)

Type / contextMethod signatureDescription
context rad: Radrad.builtin(string) -> MaterialLoad a built-in material: water, air, lead, iron, aluminum, copper, tungsten, silicon, germanium, concrete, nai, polyethylene, tissue, bone, or pmma.
Radrad.material(string, float) -> MaterialCreate a custom material with a name and density in g/cm3.
Radrad.element_table(string, int, string) -> voidRegister or replace an element symbol and atomic number Z from XCOM-format rows (E coherent incoherent photo pair_nuclear pair_electron in cm2/g, covering 0.001..20 MeV).
Radrad.geometry() -> Geometry | rad.source() -> Source | rad.simulation(Geometry, Source) -> SimConstruct empty Geometry, Source, or Sim builder handles.
Radrad.klein_nishina(float) -> float | rad.compton_mean_transfer(float) -> float | rad.sample_compton_mean(float, int, int) -> floatCompute total Klein-Nishina cross section (cm2/electron), analytic mean Compton energy transfer (MeV), or Monte Carlo sampled mean transfer for (E, samples, seed).
Radrad.assert_close(float, float, float) -> void | rad.assert_true(bool) -> voidAssert |actual - expected| <= tol or boolean truth; fails with exit code 3 on violation.
Radrad.save_text(string, string) -> void | rad.print(string) -> void | rad.version() -> stringWrite text to a file, print a diagnostic line to stderr, or return the host version string.
Materialm.element(string, float) -> MaterialAdd an element mass fraction (built-in: H, C, N, O, Na, Mg, Al, Si, P, S, Ar, K, Ca, Fe, Cu, Ge, I, W, Pb, or custom element_table symbols).
Materialm.name() -> string | m.density() -> floatReturn the material name or density in g/cm3.
Materialm.mu(float) -> float | m.mu_mass(float) -> float | m.mu_partial(float, string) -> floatReturn linear attenuation coefficient (1/cm), mass attenuation coefficient (cm2/g), or partial linear coefficient for rayleigh, compton, photo, or pair at energy E (MeV).
Materialm.mfp(float) -> float | m.hvl(float) -> floatReturn mean free path (1/mu) or half-value layer (ln(2)/mu) in cm at energy E (MeV).
Geometryg.box(string, Material, float, float, float, float, float, float) -> GeometryAdd an axis-aligned box region named name over [x0, x1] x [y0, y1] x [z0, z1] in cm.
Geometryg.slab(string, Material, float, float) -> GeometryAdd an infinite x-y slab region named name over [z0, z1] in cm.
Geometryg.sphere(string, Material, float, float, float, float) -> GeometryAdd a spherical region named name with center (cx, cy, cz) and radius r in cm.
Geometryg.cylinder(string, Material, float, float, float, float, float) -> GeometryAdd a z-axis cylindrical region named name with center (cx, cy), radius r, and z span [z0, z1] in cm.
Geometryg.regions() -> intReturn the number of defined regions in the geometry.
Sources.point(float, float, float) -> Source | s.disc(float) -> SourceSet source position (x, y, z) in cm, optionally spread uniformly over a disc of radius r perpendicular to the beam.
Sources.beam(float, float, float) -> Source | s.cone(float, float, float, float) -> Source | s.isotropic() -> SourceSet pencil beam direction (dx, dy, dz), cone direction with half-angle in degrees, or 4-pi isotropic emission.
Sources.energy(float) -> Source | s.line(float, float) -> SourceSet a monoenergetic source energy in MeV (replacing prior lines) or add a discrete spectral line (energy_MeV, relative_weight).
Simsim.plane(string, string, float) -> SimAdd an infinite scoring plane named name normal to axis x, y, or z at coordinate pos (cm) counting forward crossings.
Simsim.spectrum(int, float) -> Sim | sim.pulse_height(string) -> SimConfigure energy histogram binning (bins, emax_MeV) and enable per-history pulse-height tallying in a named region.
Simsim.cutoff(float) -> Sim | sim.no_rayleigh() -> Sim | sim.implicit_capture(float) -> SimSet absorption energy cutoff in MeV (>= 0.001), disable Rayleigh scattering, or enable implicit capture with Russian roulette weight cutoff (0 < w < 1).
Simsim.tracks(int) -> Sim | sim.seed(int) -> Sim | sim.run(int) -> ResultRecord interaction vertices for the first n histories (0..100000), set the RNG seed, and run n histories.
Resultr.histories() -> int | r.source_energy() -> float | r.track_points() -> intReturn simulated history count, mean emitted energy per source photon (MeV), or recorded track vertex count.
Resultr.deposited(string) | r.deposited_err(string) | r.deposited_uncollided(string) | r.deposited_uncollided_err(string) -> floatReturn total or first-collision kerma deposited in a named region (MeV per source photon) and its standard error.
Resultr.total_deposited() | r.total_deposited_err() | r.escaped() | r.escaped_err() | r.escaped_uncollided() | r.escaped_uncollided_err() | r.escaped_energy() -> floatReturn total energy deposited across all regions or fraction/energy of photons escaping the geometry.
Resultr.plane_count(string) | r.plane_count_err(string) | r.plane_uncollided(string) | r.plane_uncollided_err(string) | r.plane_energy(string) -> floatReturn total or uncollided forward crossings and forward energy per source photon across a named scoring plane.
Resultr.interactions(string) -> float | r.pulse_fraction(string, float, float) -> floatReturn interactions per source photon by process (rayleigh, compton, photo, pair, total) or pulse-height fraction in [lo, hi) MeV.
Resultr.save_regions(string) | r.save_plane_spectrum(string, string) | r.save_leakage_spectrum(string) | r.save_pulse_height(string, string) | r.save_tracks(string) -> voidWrite space-separated region kerma table, plane spectrum, leakage spectrum, pulse-height histogram, or interaction tracks to disk.

Standard lmcode_std_v3 catalog

CategoryFunctions, types, or signaturesDescription
Strings and encodingsstr_len, str_substr, str_find, str_contains, str_starts_with, str_ends_with, str_lower, str_upper, str_trim, str_replace, str_repeat, str_split, str_match, str_to_int, str_is_int, str_to_float, str_is_float, str_base64_encode, str_base64_decode, str_hex_encode, str_hex_decodeByte string operations, decimal conversion, and base64/hex encoding.
Math and filesmath_abs, math_min, math_max, math_floor, math_ceil, math_round, math_sqrt, math_pow, file_read, file_write, file_append, file_exists, file_linesNumeric math helpers and UTF-8 file I/O functions.
Collections, JSON, and return framingIntList, FloatList, StrList, IntMap, FloatMap, StrMap, IntStack, FloatStack, StrStack, IntQueue, FloatQueue, StrQueue, IntPQ, FloatPQ, StrPQ, Json (json_parse, template_render), lmcode_return_set, lmcode_return_put, lmcode_return_put_null, lmcode_return_nullTyped containers, JSON parsing, template rendering, and structured LMCODE_RETURN payload builders.

Exit codes

Exit codePhaseMeaning
0successSimulation and assertions succeeded and emitted a terminal LMCODE_RETURN frame.
2cliInvalid command-line arguments, unknown or retired flag, or malformed invocation manifest.
3load / runBytecode load failure, invalid physics parameter, failed assert_close/assert_true, or exceeded LMPARTICLE_MAX_MEMORY_MB.
4appOutput file write failure or application I/O error.