Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Building the book and the simulator

Everything in this book runs from one repository. The simulator is a set of Rust crates; the laboratories on these pages are the same code compiled to WebAssembly; the desktop application is the same code again behind a native window. This appendix lists what is where, what you need installed, and the command for each task.

What is where

PathContents
crates/biomechThe simulator: rigid skeleton dynamics, muscle, tendon and ligament laws, muscle paths and wrapping, load sharing and task control, surface geometry, deformable tissue, time stepping. It reads no files and opens no windows.
crates/biomech_armThe arm model’s file format and the code that assembles a skeleton with muscles from it.
crates/arm_builderThe tool that measures the arm model from the anatomy atlas and writes models/arm/arm.json.
crates/biomech_labsThe laboratories. Each describes its controls, readouts, 3D scene and plots; it contains no drawing code.
crates/biomech_wasmThe WebAssembly bindings that hand the laboratories to the browser.
crates/kenoma_desktopThe desktop application, which draws the same laboratories natively and replays recorded tissue runs with their stress.
book/This book: Markdown chapters, the browser viewer (src/labs/lab.js) and the build script.
models/Inputs to the model: the anatomy atlas, body-segment proportions, the arm model.
reference/Published measurements and model definitions used to judge the simulator, tables generated by OpenSim, and the registry of sources.
proofs/Machine-checked proofs about the simulator’s equations.
tools/Scripts: source registry, laboratory checks in a real browser, mesh preparation, OpenSim table generation.

What you need

  • Rust with the wasm32-unknown-unknown target (rustup target add wasm32-unknown-unknown). The repository builds with Rust 1.92.

  • mdBook 0.5.4, mdbook-katex 0.10.0 and the wasm-bindgen command-line tool at exactly the version of the wasm-bindgen crate in Cargo.lock. They can be installed inside the repository, where the build script looks first:

    cargo install --root .tools/cargo --locked mdbook --version 0.5.4
    cargo install --root .tools/cargo --locked mdbook-katex --version 0.10.0
    cargo install --root .tools/cargo --locked wasm-bindgen-cli --version <version in Cargo.lock>
    
  • Python 3.11 or later for the source registry and the mesh scripts. Only the standard library is used.

  • Node 22 or later and a Chromium binary to check the laboratories in a real browser. Set CHROME, or install one with npx playwright install chromium-headless-shell.

  • For the desktop application, a graphics adapter that wgpu supports (Vulkan, Metal or DirectX 12).

  • For the proofs, nothing beforehand: proofs/install_toolchain.sh downloads Lean 4 and mathlib into .tools/lean.

Tasks

TaskCommand
Run the simulator’s testscargo test -p biomech -p biomech_arm
Run every testcargo test --workspace
Check the code for common mistakescargo clippy --workspace --all-targets
Build this book into target/book./book/build.sh
Load and exercise every laboratory in headless Chromiumnode tools/labcheck/labcheck.mjs
Check that every cited source is registeredpython3 tools/book/sources.py check
Open the desktop applicationcargo run --release -p kenoma_desktop
List the laboratoriescargo run -p kenoma_desktop -- --list-labs
Render one laboratory to a picture without a windowcargo run -p kenoma_desktop -- --screenshot <lab> --out <file.png>
Replay a recorded tissue runcargo run --release -p kenoma_desktop -- --replay models/arm/recordings/elbow-curl.kenrun
Rebuild the arm model from the atlascargo run -p arm_builder
Confirm the stored arm model matches a fresh buildcargo run -p arm_builder -- --check
Check the proofsproofs/check.sh

./book/build.sh compiles the laboratories to WebAssembly, generates their JavaScript glue, writes the sources page from the registry, checks every citation, and renders the chapters. The result is a static site: open target/book/index.html through any web server.

How the pieces are checked

  • Against closed-form answers. Each law has tests that compare it with a result that can be worked out by hand: the energy of a swinging weight, the stretch of an incompressible block, the path of a string round a pulley.
  • Against another simulator. OpenSim 4.6 generated tables of muscle curves, isometric forces and forward-dynamics runs for a published arm model. The tests in crates/biomech/tests/opensim_*.rs reproduce them. OpenSim is used only to make these tables; nothing here depends on it. The scripts and the exact environment are in tools/oracles/.
  • Against measurement. The arm model’s moment arms, fibre excursions and strength are compared with published measurements in crates/biomech_arm/tests/. The measurements are in reference/measurements/.
  • By proof. Properties the algorithms rely on are proved in proofs/ and listed in Proved properties. Each proved property is also exercised on the code by a test.
  • In a real browser and a real window. tools/labcheck/labcheck.mjs loads every laboratory on every page, presses its controls and fails on any error. The desktop application has the same kind of check with screenshots.

Where the checks run. Since 29 November 2026 the project’s automatic checks on GitHub, its continuous integration (CI), do not run the simulator’s tests: many of them run the solver, and on a hosted machine they did not finish in 25 minutes. The tests are run locally instead, with the commands above. CI does these on every change:

  • builds this book, which also checks that every cited source is registered, and loads and exercises every laboratory in a real browser;
  • checks the source registry on its own;
  • checks that the stored arm model, the stored tissue volume and the bone surfaces the laboratories draw match a fresh build;
  • runs the lints, cargo clippy with every warning an error;
  • builds the proofs from clean and audits the axioms of every registered theorem.

So a passing CI says the book, the laboratories, the builder and the proofs are sound. It says nothing about whether the simulator’s tests pass; their latest counts are in Where the model and the measurements disagree.