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

InvocationEffectExit
lmcell --versionPrint lmcell and its version, for example lmcell 0.1.40
lmcell --noticesPrint the embedded third-party license notices0
lmcell --lmcode-schema --jsonPrint the exact embedded schema JSON (schema format 2, name lmcell) that lmscript compiles against0
lmcell --lmcode-schemaPrint the signature list as text (same as --lmcode-signatures)0
lmcell --lmcode-signaturesPrint one line per context, function and method signature: 243 lines in 0.1.40
lmcell --lmcode FILE.dslb [FILE.dslb ...]Load every compiled program first, then run them in order; one terminal result frame on stdout0, 3 or 4
lmcell --dry-run --lmcode FILE.dslb ...Verify and load the bytecode without running simulations or writing files0 or 3
Anything elseUsage text on stderr and a failure frame with code CLI_USAGE2
ItemValue
Block headercli="lmcell" install="github:lmctl-ai/lmcell@latest"
Outer callr = 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 valueSet inside the block with lmcode_return_set(value) or lmcode_return_put(name, value); null when unset
Exit codes0 success, 2 CLI or invocation metadata, 3 load or run error, 4 application or output failure
EnvironmentLMCELL_MAX_MEMORY_MB: total memory budget in MiB, default 4096
Streamsstdout carries only the result frame; cell.print and solver chatter go to stderr; data leaves through CSV files
Standard librarylmcode_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.

CallReturnsPurpose
cell.sim(seed)SimSeeded simulation builder; seed in 0..4294967295
cell.eval(expression)floatEvaluate a scalar math expression string such as 2000*exp(0.6)
cell.assert_close(a, b, tolerance), cell.assert_true(condition)voidStop the run with an error when a check fails
cell.print(text)voidWrite a line to stderr
sim.domain(xmin, xmax, ymin, ymax, voxel_size)SimRectangular 2D domain; default -100..100 on both axes with spacing 20
sim.substrate(name, diffusion, decay, initial, boundary)SimDiffusing field; boundary -1 is no flux, otherwise every edge voxel is held at that value
sim.edge(substrate, side, value)SimPer-side override for xmin, xmax, ymin or ymax
sim.diffusion_dt(dt)SimLargest diffusion and exchange substep inside each cell step
sim.cell_type(name)CellTypeNamed phenotype builder
type.cycle(rate), type.death(rate), type.radius(r)CellTypeDivision rate, apoptosis rate, cell radius
type.motility(speed, persistence_time)CellTypePersistent random walk
type.chemotaxis(substrate, bias)CellTypeSteer up a gradient; bias in 0..1
type.exchange(substrate, uptake, secretion)CellTypeUptake and secretion of one substrate; once per substrate
type.rule(signal, effect, target, half_max, hill)CellTypeHill rule; effect increases or decreases
type.rule_toward(signal, target, saturation, half_max, hill)CellTypeSaturating rule that pulls a rate toward a value
sim.seed(type, count, x, y)SimColocated cells at one point
sim.scatter(type, count, xmin, xmax, ymin, ymax), sim.seed_disk(type, count, x, y, radius)SimUniform random placement from a portable seeded generator; call after domain
sim.record(interval)SimKeep positions and fields every interval minutes
sim.run(duration, max_dt)ResultFreeze the builder and run once
result.live(), result.live_of(type), result.substrate(index)int, int, stringFinal live counts and substrate names
result.counts(), type_counts(), cells(), profiles(), history(), profile_history()MatrixNumeric tables of the run
matrix.rows(), matrix.cols(), matrix.get(row, col), matrix.save_csv(path)int, int, float, voidZero-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