lmspace reference

Complete reference for lmspace command-line flags, environment variables, host schema types and methods, global functions, standard catalog, and exit codes.

Command-line flags

Flag or invocation Purpose
lmspace --version Print lmspace X.Y.Z to stdout and exit 0
lmspace --notices Print embedded third-party license notices (including Caltech/JPL/NASA CSPICE N0067 notices) and exit 0
lmspace --lmcode-schema Print the canonical registry signatures, one per line, to stdout and exit 0
lmspace --lmcode-schema --json Print the exact embedded lmspace.host.json schema bytes to stdout and exit 0
lmspace --lmcode-signatures Print canonical sorted registry signatures for parity verification with lmscript and exit 0
lmspace --lmcode FILE [FILE ...] Load and verify all bytecode files against the embedded schema, then execute each slot in order
lmspace --dry-run --lmcode FILE [FILE ...] Load and verify all bytecode files and schema contracts without executing numerical work or writing files

Environment variables

Variable Default Description
LMSPACE_MAX_MEMORY_MB 4096 Total memory budget in MiB for propagation tables and host objects; exceeding it stops execution with exit code 3
LMCODE_INVOCATION_FILE unset Internal SDK invocation envelope path supplied automatically by run_lmcode

Context objects

Name Type Description
space Space Root orbital mechanics and SPICE context shared across bytecode blocks in one invocation

Host types and methods

Type Method signature Description
Space Space.angular_momentum() -> Vector Compute total mass-weighted angular momentum vector (with mu as mass, G=1) of all bodies in space
Space Space.body(name: string, mu: float) -> Body Create a body at the origin with zero velocity and positive gravitational parameter mu
Space Space.body(name: string, mu: float, x: float, y: float, z: float, vx: float, vy: float, vz: float) -> Body Create a body with positive gravitational parameter mu and Cartesian position (x, y, z) and velocity (vx, vy, vz)
Space Space.clear_kernels() -> void Unload all SPICE kernels currently loaded in the host process
Space Space.energy() -> float Compute total mass-weighted mechanical energy (kinetic plus potential, mu as mass) of all bodies in space
Space Space.energy_drift() -> float Return the largest relative energy change recorded during the most recent space.propagate call
Space Space.ephemeris(target: string, observer: string, frame: string, et: float) -> Matrix Query geometric 1x6 state matrix (km and km/s, aberration NONE) from loaded SPICE kernels at ephemeris time et
Space Space.frame(from: string, to: string, et: float) -> Matrix Return the 3x3 coordinate rotation matrix from reference frame from to frame to at ephemeris time et
Space Space.load_kernel(path: string) -> void Validate and load a local binary (DAF/DAS) or text (\begindata) SPICE kernel or metakernel
Space Space.propagate(duration: float, points: int, step: float, method: string, tol: float) -> Matrix Propagate all bodies created in space over duration across points rows using symplectic or rk45
Space Space.system() -> System Create an empty independent N-body System
Space Space.time(text: string) -> float Convert a time string to SPICE ephemeris time (ET seconds past J2000); requires a loaded leap-second kernel for UTC
System System.add(body: Body) -> System Copy the current state of body into the system and return the system for chaining
System System.angular_momentum() -> Vector Compute total mass-weighted angular momentum vector of bodies in this system
System System.energy() -> float Compute total mass-weighted mechanical energy of bodies in this system
System System.energy_drift() -> float Return the largest relative energy change recorded during the most recent system.propagate call
System System.propagate(duration: float, points: int, step: float, method: string, tol: float) -> Matrix Propagate the bodies in this system over duration across points rows using symplectic or rk45
Body Body.elements(central_mu: float) -> Elements Convert the body Cartesian state to classical orbital elements around central_mu
Body Body.mu() -> float Return the body gravitational parameter mu
Body Body.name() -> string Return the body name
Body Body.propagate(central_mu: float, dt: float) -> State Propagate the body analytically for dt along its two-body Keplerian orbit around central_mu
Body Body.state() -> State Return the initial Cartesian State of the body
State State.elements(central_mu: float) -> Elements Convert this Cartesian state to classical orbital elements around central_mu
State State.position() -> Vector Return the 3D position Vector
State State.propagate(central_mu: float, dt: float) -> State Propagate this Cartesian state analytically for dt along a two-body Keplerian orbit around central_mu
State State.velocity() -> Vector Return the 3D velocity Vector
Elements Elements.a() -> float Return the semi-major axis a
Elements Elements.e() -> float Return the orbital eccentricity e
Elements Elements.i() -> float Return the orbital inclination i in radians
Elements Elements.raan() -> float Return the right ascension of the ascending node in radians
Elements Elements.argp() -> float Return the argument of periapsis in radians
Elements Elements.nu() -> float Return the true anomaly in radians
Elements Elements.to_state(central_mu: float) -> State Convert these classical orbital elements to a Cartesian State around central_mu
Vector Vector.get(index: int) -> float Return component 0 (x), 1 (y), or 2 (z)
Vector Vector.x() -> float Return the x coordinate
Vector Vector.y() -> float Return the y coordinate
Vector Vector.z() -> float Return the z coordinate
Matrix Matrix.rows() -> int Return the number of rows in the matrix
Matrix Matrix.cols() -> int Return the number of columns in the matrix
Matrix Matrix.get(row: int, col: int) -> float Return the value at 0-based (row, col)
Matrix Matrix.save_csv(path: string) -> void Write the matrix to path as comma-separated values with 17 significant digits per cell

Global functions

Function signature Description
vector(x: float, y: float, z: float) -> Vector Create a 3D Vector with components (x, y, z)
state(position: Vector, velocity: Vector) -> State Create a Cartesian State from position and velocity vectors
elements(a: float, e: float, i: float, raan: float, argp: float, nu: float) -> Elements Create classical orbital Elements (all angles in radians)
from_elements(elem: Elements, central_mu: float) -> State Convert classical orbital elements to a Cartesian State around central_mu
to_elements(st: State, central_mu: float) -> Elements Convert a Cartesian State to classical orbital elements around central_mu
kepler(M: float, e: float) -> float Solve Kepler equation M = E - e * sin(E) for eccentric anomaly E in radians (0 <= e < 1)
period(a: float, central_mu: float) -> float Return the two-body orbital period 2 * pi * sqrt(a^3 / central_mu) for positive a and central_mu
hohmann(r1: float, r2: float, central_mu: float) -> Matrix Return a 1x3 Matrix containing departure delta-v, arrival delta-v, and transfer time between circular radii r1 and r2
lambert(r1: Vector, r2: Vector, dt: float, central_mu: float, prograde: bool) -> Matrix Solve the zero-revolution Lambert problem and return a 2x3 Matrix of departure (row 0) and arrival (row 1) velocity components
assert_close(actual: float, expected: float, tolerance: float) -> void SDK numeric assertion checking abs(actual - expected) <= tolerance; rejects NaN and negative tolerances
space_assert_close(actual: float, expected: float, tolerance: float) -> void Strict finite-only physical assertion requiring finite actual, expected, and non-negative finite tolerance
print(message: string) -> void Write a diagnostic line to stderr without disturbing the stdout result frame

Standard lmcode_std_v3 catalog

Item Value
Pinned catalog file cpp/std/lmcode-std.schema.json (206 canonical signatures)
Contents String, encoding, math, file, JSON, template, collection, and return-framing declarations; no REST or CLI interfaces

Exit codes

Exit code Phase Meaning
0 ok Command or all bytecode slots completed without error
2 cli Invalid command-line arguments, contradictory --dry-run flag, or invalid LMSPACE_MAX_MEMORY_MB value
3 load / run Bytecode load failure, schema mismatch, domain/physics error, missing SPICE kernel coverage, assertion failure, or memory budget exceeded
4 app Application error raised with code APP_FAIL, or an output failure