Skip to content

About

MicroSimulator is a GPU-accelerated framework for simulating fluid flow, solute transport, and microbial cell mechanics in microfluidic devices, with independent Apple Metal, NVIDIA CUDA, and CPU implementations.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

MicroSimulator

MicroSimulator simulates microbial populations in microfluidic devices. It is a C++23 library that brings device geometry, steady fluid flow, solute transport, and individual-cell biology into one model, connecting the conditions in a channel or trap to colony growth, signaling, and washout. A Python package binds the library one to one, so a model reads the same in either language.

A model is declared as data: strains state what each kind of cell does, a device states where the cells live and what its medium carries, and the library runs the result on a native CPU, Apple Metal, or NVIDIA CUDA backend. Simulations can run headlessly or with an interactive browser viewer. Device geometry and flow are optional for standalone colony models.

Modeling cells in devices

  • Device geometry: describe traps, channels, and pillars with mechanical walls and solid masks that constrain cells and route solutes through the fluid space.
  • Flow and transport: solve depth-averaged Hele-Shaw/Darcy flow in shallow devices or resolved Stokes-Brinkman flow on a staggered grid, then use the velocity field for conservative advection, diffusion, and reactions.
  • Growth and signaling: combine nutrient uptake with conserved biochemical biomass, rod growth and division, contact mechanics, lineage, intracellular circuits, and diffusible signals.
  • Cells in flow: model free-cell drift and rotation, flow feedback from moving or attached populations, and removal of cells at an outlet the model states.
  • Reproducible experiments: inspect live simulations, resume versioned checkpoints, run parameter sweeps, and export Parquet/Zarr datasets for quantitative analysis.

The microfluidics modeling guide explains how these pieces fit together. The trap couples cell translation from contact mechanics to the shallow flow through an empirical relative drag law. The flow benchmarks and nutrient study document numerical checks and refinement studies. Experimental calibration remains specific to each model.

Quick start

MicroSimulator requires Python 3.12, CMake 3.25 or newer, Ninja, a C++23 compiler, and uv. The browser viewer also requires Node.js and pnpm.

git clone git@github.com:DRAGGON-Lab/MicroSimulator.git
cd MicroSimulator
uv sync --group dev
pnpm --dir viewer install
pnpm --dir viewer build
uv run microsimulator view \
  --model examples/microfluidic_trap.py \
  --backend cpu \
  --seed 42 \
  --dt 0.02 \
  --open

This opens a cell trap supplied with nutrient through a flowing channel in the live viewer. Press Play to watch the colony fill the trap and spill into the channel, where the flow carries cells to the outlet. Choose Growth rate coloring to see the packed interior stop growing while the cells at the trap mouth keep dividing, and click a cell to inspect it. Stop session or Ctrl+C in the terminal ends the run.

The same model runs headlessly with microsimulator run, which saves a checkpoint that holds the whole model and can be continued without the model file:

uv run microsimulator run \
  --model examples/microfluidic_trap.py \
  --backend cpu \
  --seed 42 \
  --steps 100 \
  --dt 0.02 \
  --output results/trap.json

Follow getting started to checkpoint and resume runs, or continue with microfluidic devices to explore walls, transport, growth, and washout.

The model API

The trap from the quick start, in full (examples/microfluidic_trap.py is the same model with its constants named and explained):

import microsimulator as ms

nutrient = ms.Signal("nutrient")

ecoli = (
    ms.Strain("E. coli")
    .grows(ms.monod(nutrient, rate=1.0, half=5.0))
    .consumes(nutrient, ms.growth_yield(0.5))
    .divides_at(ms.uniform(3.2, 3.8), ms.Jitter.XY)
)

chip = (
    ms.TrapChannel(trap=(40, 20, 1.5), channel_width=20)
    .flowing(20.0)
    .carrying(nutrient, ms.Medium(diffusion=40, inlet=10, initial=10))
    .washing_out_beyond(50.0)
)

model = (
    ms.Model.builder("trap")
    .seed(42)
    .inside(chip)
    .inoculate(ecoli, [ms.Founder(position=(35, 0, 0), length=3.5)])
    .mechanics(ms.Mechanics(flow_drift=True, load=ms.linear_load(200.0)))
    .resolving_flow_every(5, ms.FlowFeedback(drag=2.0, moving_biomass=True))
    .build()
)

model.run(steps=1000, dt=0.02, output="trap.json")
model.positions(), model.growth_rates(), model.field(nutrient)  # NumPy arrays

A strain says what a kind of cell does, a device says where the cells live and what its medium carries, and the builder puts them together. Rates are ordinary expressions (nutrient / (5 + nutrient)), and the library evaluates them for every cell natively, so no Python runs per step. The checkpoint holds the whole model: ms.Model.load("trap.json") continues it with no other code.

Write a model covers the whole API in a few pages: every strain verb, the devices, expressions, gene circuits, interacting strains, and running from a script or the command line.

The library is C++23 and the Python package binds it one to one, so the same model compiles as a C++ program that links the library with find_package(microsimulator). Models in C++ shows that side.

Examples

Explore Start with
Nutrient delivery, colony growth, and washout in a trap Microfluidic trap
Flow around pillars, attached founders, and released daughters Pillar channel
A quorum-sensing clock in a flowing device Danino clock
A single biopixel trap with documented dimensions and CAD provenance Biopixel tutorial
Nutrient penetration, biomass gain, and conservation Controlled nutrient study
The same models as C++ programs C++ examples

The tutorial suite also covers growth, gene circuits, signaling, plasmids, contacts, and analysis. Device examples state their geometry, units, and modeling assumptions alongside the runnable code.

Backend status

Backend Status Role
CPU Feature complete Portable execution and numerical reference
Apple Metal Feature complete Native Apple GPU execution
NVIDIA CUDA Under active development Native NVIDIA GPU execution

Both flow solvers have native CPU, Metal, and CUDA implementations. CPU and Metal support the complete current modeling workflow. CUDA compilation is checked, while NVIDIA runtime and application validation remain required for supported status. The validation policy defines the hardware and application acceptance criteria.

Documentation

Topic Entry point
Microfluidics Devices, flow, transport, and biology
Writing a model Write a model
Tutorials Modeling tutorials
The C++ library Models in C++
How a model is stepped Models declared as data and run natively
Architecture and numerics Design documents
HPC environments CPU, Metal, and CUDA setup
Analysis and visualization Research output workflows
Development Testing and validation

The complete documentation index is available at docs/README.md.

License

MicroSimulator is available under the MIT License.

About

MicroSimulator is a GPU-accelerated framework for simulating fluid flow, solute transport, and microbial cell mechanics in microfluidic devices, with independent Apple Metal, NVIDIA CUDA, and CPU implementations.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages