lmcell
lmcell is a native lmcode host for 2D multicellular simulations: cell types that divide, die, migrate, follow gradients and exchange diffusing substrates, with Hill rules that couple signals to behavior. It embeds serial PhysiCell and BioFVM in one static executable, is installed automatically by lmscript, and writes plain numeric CSV for plotting hosts.
This page is the quick reference. The latest release is lmcell 0.1.4; it ships the 206-signature lmcode_std_v3 standard library next to its 36 host methods.
Install and run
npm install -g @lmctl-ai/lmctl
lmscript colony.lms # downloads the lmcell release on first use
lmscript --check colony.lms # compile the _lmcode_ block against the cached host schema
lmscript --dry-run colony.lms # plan only: no simulation, no files
The install attribute github:lmctl-ai/lmcell@latest on the block makes lmscript download and cache the release binary. Linux binaries need dynamic glibc 2.35 or newer (Ubuntu 22.04 and later). Run a repository example straight from its URL:
mkdir try-lmcell
cd try-lmcell
lmctl https://raw.githubusercontent.com/lmctl-ai/lmcell/main/examples/contact_inhibition.lms
The gallery examples also draw pictures, so they additionally need a compatible lmplot on PATH (and lmdraw, lmblender or ffmpeg for a few of them).
Minimal runnable example
prog = _lmcode_ cli="lmcell" install="github:lmctl-ai/lmcell@latest";
let s = cell.sim(12345);
s.cell_type("growing").cycle(0.3).radius(1.0);
let r = s.seed("growing", 2000, 0.0, 0.0).run(2.0, 0.01);
cell.assert_close(float(r.live()), cell.eval("2000*exp(0.6)"), 190.0);
cell.assert_true(r.counts().rows() == 201);
r.counts().save_csv("counts.csv");
lmcode_return_put("live", r.live());
lmcode_return_put("rows", r.counts().rows());
end _lmcode_
r = run_lmcode(prog);
println(json_stringify(r));
require(r.ok, "colony failed");
Saved as colony.lms and run with lmscript colony.lms, the program prints this line on stdout (the solver banner from BioFVM goes to stderr) and writes counts.csv with 201 rows of time,live:
lmscript colony.lms
{"ok":true,"result":{"live":3625,"rows":201}}
Host CLI and protocol
| Invocation | Effect | Exit |
|---|---|---|
| lmcell --version | Print lmcell and its version, for example lmcell 0.1.4 | 0 |
| lmcell --notices | Print the embedded third-party license notices | 0 |
| lmcell --lmcode-schema --json | Print the exact embedded schema JSON (schema format 2, name lmcell) that lmscript compiles against | 0 |
| lmcell --lmcode-schema | Print the signature list as text (same as --lmcode-signatures) | 0 |
| lmcell --lmcode-signatures | Print one line per context, function and method signature: 243 lines in 0.1.4 | 0 |
| lmcell --lmcode FILE.dslb [FILE.dslb ...] | Load every compiled program first, then run them in order; one terminal result frame on stdout | 0, 3 or 4 |
| lmcell --dry-run --lmcode FILE.dslb ... | Verify and load the bytecode without running simulations or writing files | 0 or 3 |
| Anything else | Usage text on stderr and a failure frame with code CLI_USAGE | 2 |
| Item | Value |
|---|---|
| Block header | cli="lmcell" install="github:lmctl-ai/lmcell@latest" |
| Outer call | r = run_lmcode(prog) returns a map with ok and result; on failure ok is false and phase, code, message, line and column are set |
| Result value | Set inside the block with lmcode_return_set(value) or lmcode_return_put(name, value); null when unset |
| Exit codes | 0 success, 2 CLI or invocation metadata, 3 load or run error, 4 application or output failure |
| Environment | LMCELL_MAX_MEMORY_MB: total memory budget in MiB, default 4096 |
| Streams | stdout carries only the result frame; cell.print and solver chatter go to stderr; data leaves through CSV files |
| Standard library | lmcode_std_v3, 206 signatures in release 0.1.4 (the current catalog has 226; see the reference) |
Host API quick reference
The single context object is cell, of type Cell. Units follow PhysiCell: micrometers and minutes, rates per minute, diffusion in square micrometers per minute.
| Call | Returns | Purpose |
|---|---|---|
| cell.sim(seed) | Sim | Seeded simulation builder; seed in 0..4294967295 |
| cell.eval(expression) | float | Evaluate a scalar math expression string such as 2000*exp(0.6) |
| cell.assert_close(a, b, tolerance), cell.assert_true(condition) | void | Stop the run with an error when a check fails |
| cell.print(text) | void | Write a line to stderr |
| sim.domain(xmin, xmax, ymin, ymax, voxel_size) | Sim | Rectangular 2D domain; default -100..100 on both axes with spacing 20 |
| sim.substrate(name, diffusion, decay, initial, boundary) | Sim | Diffusing field; boundary -1 is no flux, otherwise every edge voxel is held at that value |
| sim.edge(substrate, side, value) | Sim | Per-side override for xmin, xmax, ymin or ymax |
| sim.diffusion_dt(dt) | Sim | Largest diffusion and exchange substep inside each cell step |
| sim.cell_type(name) | CellType | Named phenotype builder |
| type.cycle(rate), type.death(rate), type.radius(r) | CellType | Division rate, apoptosis rate, cell radius |
| type.motility(speed, persistence_time) | CellType | Persistent random walk |
| type.chemotaxis(substrate, bias) | CellType | Steer up a gradient; bias in 0..1 |
| type.exchange(substrate, uptake, secretion) | CellType | Uptake and secretion of one substrate; once per substrate |
| type.rule(signal, effect, target, half_max, hill) | CellType | Hill rule; effect increases or decreases |
| type.rule_toward(signal, target, saturation, half_max, hill) | CellType | Saturating rule that pulls a rate toward a value |
| sim.seed(type, count, x, y) | Sim | Colocated cells at one point |
| sim.scatter(type, count, xmin, xmax, ymin, ymax), sim.seed_disk(type, count, x, y, radius) | Sim | Uniform random placement from a portable seeded generator; call after domain |
| sim.record(interval) | Sim | Keep positions and fields every interval minutes |
| sim.run(duration, max_dt) | Result | Freeze the builder and run once |
| result.live(), result.live_of(type), result.substrate(index) | int, int, string | Final live counts and substrate names |
| result.counts(), type_counts(), cells(), profiles(), history(), profile_history() | Matrix | Numeric tables of the run |
| matrix.rows(), matrix.cols(), matrix.get(row, col), matrix.save_csv(path) | int, int, float, void | Zero-based access and headerless 17-digit CSV |
Rule targets are cycle entry, apoptosis and migration speed. A rule signal is a declared substrate name or the built-in signal neighbors, the number of other live cells in the same voxel. One simulation can run per host process.
Detail pages
- Skill: install, commands, safety rules, worked examples, errors and verification for agents.
- Guide: the model, architecture, workflow, numerics and limits.
- Reference: every type, method, matrix layout, limit, flag, exit code and the standard library tables.
- GitHub repository lmctl-ai/lmcell: source, 16 gallery examples and releases.