lmphysics reference

Complete CLI flags, environment variables, Phys/System/Body/Joint schema methods, recorded CSV columns, the standard lmcode_std_v3 catalog, and exit codes for lmphysics.

CLI flags and environment variables

Flag or variableArgumentsDescription
--versionnonePrint lmphysics X.Y.Z and exit 0.
--noticesnonePrint Project Chrono, Bullet, Eigen, and runtime 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.
--lmcodeFILE [FILE ...]Load and execute compiled LMScript bytecode; further files for multi-part builders follow the single flag.
--dry-runnonePlaced before --lmcode; requests dry mode for a standalone run that has no invocation manifest.
LMPHYSICS_MAX_MEMORY_MBinteger (default 4096)Maximum process memory budget in MiB for bodies, joints, recorded steps, and Chrono/Bullet state.

Phys and System schema methods (context phys: Phys)

Type / contextMethod signatureDescription
context phys: Physphys.system(string) -> SystemCreate a new physics world with contact mode "nsc" (non-smooth complementarity) or "smc" (smooth penalty contact).
Physphys.assert_close(float, float, float) -> void | phys.print(string) -> void | phys.version() -> stringAssert |actual - expected| <= tol (exiting 3 on failure), print a line, or return the host version string.
Systems.gravity(float, float, float) -> System | s.timestep(float) -> SystemSet world gravity vector in m/s2 (default 0, 0, -9.81) and fixed integration time step dt in seconds.
Systems.integrator(string) -> System | s.solver(string, int) -> SystemSelect time integrator (euler, trapezoidal, hht, newmark) and solver (psor, pjacobi, pminres, bb, apgd, minres, sparse_lu, sparse_qr) with max iterations.
Systems.newton(int, float, float) -> System | s.hht_alpha(float) -> SystemConfigure implicit integrator Newton iterations and relative/absolute tolerances, or HHT numerical damping alpha (in [-1/3, 0]; requires integrator("hht") first).
Systems.bounce_speed(float) -> System | s.collision_margins(float, float) -> SystemSet minimum approach speed (m/s, default 0.15) for restitution and NSC collision envelope/margin in meters (default 0.03, 0.01).
Systems.material(string, float, float) -> System | s.stiffness(string, float, float) -> SystemDefine a named contact material with friction and restitution, and set SMC Young's modulus (Pa) and Poisson ratio.
Systems.ground(string) -> Body | s.floor(string, string) -> BodyCreate a fixed non-colliding ground anchor or a fixed 200x200x2 m collision floor slab with top face at z = 0 using the named material.
Systems.box(string, float, float, float, float) -> Body | s.sphere(string, float, float) -> Body | s.cylinder(string, float, float, float) -> BodyCreate a rigid box (sx, sy, sz, density), sphere (radius, density), or local-y-axis cylinder (radius, height, density).
Systems.revolute(string, Body, Body, float, float, float, float, float, float) | s.prismatic(...) | s.cylindrical(...) -> JointConnect bodies A and B with a hinge, sliding guide, or cylindrical joint at world point (px, py, pz) along world axis (ax, ay, az).
Systems.universal(string, Body, Body, float, float, float, float, float, float, float, float, float) -> JointCreate a Cardan universal joint at (px, py, pz) with perpendicular cross axes (ax, ay, az) in A and (bx, by, bz) in B.
Systems.gear(string, Body, Body, float, float, float, float) -> JointCouple shafts of A and B along world axis (ax, ay, az) with transmission ratio (B turns at -ratio * A).
Systems.lock(string, Body, Body, float, float, float) | s.spherical(string, Body, Body, float, float, float) -> JointWeld bodies A and B together or connect them with a ball-and-socket joint at world point (px, py, pz).
Systems.distance(string, Body, Body, float, float, float, float, float, float) -> JointConstrain the distance between world anchor point (ax, ay, az) on A and (bx, by, bz) on B.
Systems.spring(string, Body, Body, float, float, float) | s.spring_at(string, Body, Body, float, float, float, float, float, float, float, float, float) -> JointAttach a linear spring-damper (k, c, rest_length) between body centers or between world anchor points on A and B.
Systems.motor_speed(string, Body, Body, float, float, float, float, float, float, string) | s.motor_angle(...) | s.motor_torque(...) -> JointDrive rotation of B relative to A about (px, py, pz) and axis (ax, ay, az) using a time expression expr(t).
Systems.motor_position(string, Body, Body, float, float, float, float, float, float, string) | s.motor_linear_speed(...) | s.motor_force(...) -> JointDrive linear translation of B relative to A along axis (ax, ay, az) through (px, py, pz) using expr(t).
Systems.record(string, string) -> System | s.record_every(int) -> System | s.save_csv(string) -> SystemRegister comma-separated columns for a named body or joint, subsample every n-th step, and write the logged CSV file.
Systems.step() -> System | s.run(float) -> System | s.time() -> float | s.energy() -> float | s.contacts() -> intAdvance one step or until t_end, or query current simulation time, total mechanical energy (kinetic + gravity + springs), or active contact count.

Body and Joint schema methods

TypeMethod signatureDescription
Bodyb.pos(float, float, float) | b.vel(float, float, float) | b.rot_axis(float, float, float, float) | b.omega(float, float, float) -> BodySet initial center-of-mass position, linear velocity, axis-angle rotation (ax, ay, az, angle_rad), or angular velocity in world coordinates.
Bodyb.fixed(bool) | b.mass_props(float, float, float, float) | b.collide(string) -> BodyFix or unfix the body in space, override mass and principal moments of inertia (m, ixx, iyy, izz), or enable collision using a named material.
Bodyb.force(string, string, string) | b.torque(string, string, string) | b.drag(float, float) -> BodyApply world-frame force or torque expressions (fx(t), fy(t), fz(t)) at the center of mass, or isotropic drag F = -(c1 + c2 * |v|) * v.
Bodyb.mass() | b.x() | b.y() | b.z() | b.vx() | b.vy() | b.vz() | b.wx() | b.wy() | b.wz() | b.lx() | b.ly() | b.lz() | b.speed() | b.ke() -> floatQuery body mass, position, linear velocity, angular velocity, world-frame angular momentum about the center, speed, or kinetic energy.
Jointj.angle() | j.travel() | j.length() | j.force() | j.torque() | j.effort() | j.reaction_x() | j.reaction_y() | j.reaction_z() -> floatQuery unwrapped rotation angle (rad), linear travel (m), distance/spring length (m), spring force or reaction magnitude (N), reaction torque magnitude (N*m), signed motor effort, or world-frame reaction force components on body B.

Standard lmcode_std_v3 catalog

Category or interfaceFunctions, types, or signaturesDescription
Strings, math, and filesstr_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_decode, math_abs, math_min, math_max, math_floor, math_ceil, math_round, math_sqrt, math_pow, file_read, file_write, file_append, file_exists, file_linesStandard byte-string operations, numeric math helpers, base64/hex encoding, and UTF-8 file I/O.
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 completed and emitted a terminal LMCODE_RETURN frame.
2cliInvalid CLI flags, malformed LMPHYSICS_MAX_MEMORY_MB, or invalid invocation manifest metadata.
3load / runBytecode load error, invalid simulation state (NaN/inf, singular solver, NSC with linear solver), failed assert_close, or exceeded memory limit.
4appApplication failure or CSV file output error.