/gotranx:gotranx-odesfrom gotranx
Generates code from ODE models (cardiac cell models, etc.) using gotranx. Converts between .ode and CellML, composes coupled models, selects numerical schemes (Rush-Larsen, explicit Euler), and outputs Python (numpy/numba/JAX), C, C++, CUDA, Julia, UFL, or Markdown.
Ships in gotranx. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
gotranx parses ODE models written in its .ode language (or converted from CellML), builds a
symbolic (sympy) model, and generates code that evaluates the right-hand side and takes one time
step with a chosen scheme, in Python, C, C++, CUDA, Julia, UFL and more. Two ways to drive it:
gotranx cellml2ode, gotranx ode2py / ode2c / …, gotranx compose,
gotranx list-schemes. Good for one-off conversions and reproducible files on disk.gotranx.load_ode, gotranx.compose, gotranx.cli.gotran2py.get_code. Needed
for splitting models, generating code inside a simulation script, or anything programmatic.gotranx does not solve tissue problems: it produces the cell-model code that fenicsx-beat, sknm and simcardemsx consume.
Your job: find out what the user really wants, agree on an approach with them, build it, and check it before they rely on it. Work through the five steps below in order. Ask one question at a time (use your agent's question tool if it has one, otherwise ask in plain text). Do not skip the interview because the request looks clear — the scheme, backend and composition choices change the result.
Reference files (read when a step needs them):
.ode files, CellML, odezoopython -c "import gotranx; print(gotranx.__version__)"
gotranx list-schemes
gotranx compose is new in 2.11,
the second-order schemes in 2.10). An editable install can report a stale __version__, so check
features: gotranx list-schemes must list rush_larsen_2, and gotranx compose --help must
work. If both work, the installed gotranx is new enough whatever the number says. If they do not,
recommend upgrading (python -m pip install -U gotranx) or follow that version's documentation
instead of this skill.nvcc for CUDA, numba or JAX for fast Python, Julia for Julia/CytoZoo,
odezoo for registry models.Ask one question at a time, multiple choice with an "other" option, and say why it matters when that
is not obvious. Skip a topic the user already answered (confirm instead), and skip topics that do not
apply. For a narrow debugging request ("my generated code gives NaN", "which scheme?") ask only what
changes the answer — target dt, single cell or tissue, which scheme they used — then reproduce the
problem before proposing fixes. Topics, in order:
.ode; coupling two models (electrophysiology + contraction, or other parts). The goal
decides the backend and whether a scheme is needed at all..ode file; a CellML file or Physiome Model Repository link; a model
from the odezoo registry; several models to couple. See models.md. If they bring
two or more models to couple, go through the composition questions in
composition.md now (coupling direction, variables that cross, units of each
part, one model or split halves, who provides stretch).dt, or only the right-hand side for
an adaptive solver (scipy solve_ivp with BDF/LSODA, Julia's solvers). For a scheme: how
accurate (first or second order — second order pays off only with Strang splitting downstream),
which dt they plan, and how long they pace (a few beats, or many beats to a steady state: errors
that grow every beat matter only then). See schemes.md.init_parameter_values), which
intermediate values they need to read (currents, active tension: monitored values), and whether
the model must run vectorized over many cells.Present 2–3 approaches with trade-offs and a recommendation. Typical axes:
rush_larsen_2 (second order, gating states exponential; fenicsx-beat's default) vs
generalized_rush_larsen (every state exponential, most robust at large dt, less accurate at
the same dt) vs explicit_euler (cheapest per step, needs a small dt) vs right-hand side + an
adaptive stiff solver (reference quality, slow, not for tissue). A model with a Markov chain
(ToR-ORd's IKr) paced for many beats drifts with both Rush–Larsen defaults at 0.05 ms (APD90
+65 ms with rush_larsen_2, −21 ms with GRL after 200 beats); offer hybrid_rush_larsen_2
without the chain at dt ≤ 0.025 ms, or rush_larsen_2 at dt ≤ 0.01 ms. Details:
schemes.md.--shape single) vs a C extension (fastest on CPU, needs a compiler) vs CUDA (many cells on a
GPU). Details: targets.md.Then summarize the chosen setup in a few lines (model source, composition, scheme, dt,
backend, output file names, stimulus handling) and get an explicit yes before building.
Work in a fresh folder the user agrees on (suggest one, e.g. ./gotranx-<model>/), without a pyproject.toml that has a [tool.gotranx]
table in it or in any parent folder — such a table silently overrides command-line flags
(gotchas.md). Check with
d=$PWD; while [ "$d" != / ]; do grep -l "tool.gotranx" "$d/pyproject.toml" 2>/dev/null; d=$(dirname "$d"); done
(no output means none), or pass -c <file> with a config file you control.
CLI route, e.g.:
gotranx cellml2ode model.cellml -o model.ode
gotranx ode2py model.ode --scheme rush_larsen_2 -o model.py
Python route, e.g.:
import gotranx
ode = gotranx.load_ode("model.ode")
code = gotranx.cli.gotran2py.get_code(ode, scheme=[gotranx.schemes.Scheme.rush_larsen_2])
model = {}
exec(code, model) # or write `code` to model.py and import it
Before using a gotranx function, read its signature in the installed version
(python -c "import gotranx, inspect; print(inspect.signature(gotranx.cli.gotran2py.get_code))",
gotranx ode2py --help) — options change between versions.
Generating code for a large model takes a while: ToR-ORd (45 states) takes ~15 s for ode2py, most
of it in sympy; --format none skips the formatter. Warnings "Dropping a guard whose replacement
failed its numeric check" for nai, ki, cli or clss come from Nernst potentials
(log(c_o/c_i) at c_i = 0, a logarithmic singularity that cannot be guarded) and are harmless —
tell the user what they mean, do not hide them (gotchas.md). If loading or generating
does not finish within a few minutes (Courtemanche 1998 is one such model), the singularity guards
are the cause: use --no-remove-singularities (gotchas.md).
Find the names you will need in the generated module, not by guessing:
import model
print([k for k in model.parameter if "stim" in k.lower()]) # the model's own stimulus parameters
print(list(model.state)) # find the membrane potential (v, V, V_m, membrane_V, ...)
If no parameter has "stim" in its name, look for the stimulus component in the .ode file
(grep -n -i -A6 "stim" model.ode): ORdmm_Land, for instance, has amp and duration in a
component Istim, and a single pulse at the start (Conditional(Le(t, duration), amp, 0)) instead
of a periodic one.
When adapting a gotranx example:
.ode by hand: regenerating it loses the edit
(composition.md).init_state_values() and
init_parameter_values(), run one beat (or one period of the user's protocol) at the chosen
dt, and check: all values finite; the membrane potential makes an upstroke (from rest to above
about 0 mV for physiological models) when stimulated and returns near rest; states that must stay
in [0, 1] (gates, occupancies) do. Then compare against a reference: the same run at dt/4,
or rhs with scipy.integrate.solve_ivp(method="BDF", rtol=1e-8) and max_step at most half
the stimulus duration (otherwise it can step over the stimulus, schemes.md). Report the difference in
action-potential duration or peak, not only "it runs". As a rule of thumb, an APD90 within ~1 %
and a peak within ~1 mV of the reference is fine for tissue work; ask the user what they need.
Measure from the stimulus onset (the model's own stimulus may start at 0 ms or 50 ms) and keep the
stimulus edges on the time grid (dt dividing the pulse duration), otherwise the error is
dominated by when the stimulus switches and the expected convergence order does not show.
APD90: the time from the upstroke until v has come back 90 % of the way from its peak to the
resting value (the value at the end of the beat). If the run at the user's dt gives NaN (typical
for explicit_euler through the upstroke), compare the candidate schemes at that dt against the
adaptive reference instead of against dt/4.dt and with a reference (dt/10, or a
scheme that keeps the model's invariants), compare APD90 at the last beat, and track linear
invariants such as a Markov chain's occupancies summing to 1. A first beat that matches does not
rule out an error that grows every beat: ToR-ORd with rush_larsen_2 at 0.05 ms is within 1 ms
on beat 1 and 65 ms off after 200 beats (schemes.md).
A ToR-ORd beat takes a few seconds in generated numpy code, so ask before starting this run.gotranx compose prints it; in Python, missing_variables of each half).dt it was checked at, and how
to regenerate after editing the model.Never start a long run without asking — offer the command; run it only on an explicit yes.
Use a related skill if it is available; if not, follow the link.
--help, gotranx list-schemes,
inspect.signature, or the docs (https://finsberg.github.io/gotranx). If something does not
exist, say so and offer the closest thing that does.rhs(t, states, parameters) but a scheme is
scheme(states, t, dt, parameters). Pass by keyword where the consumer allows it.dt.[tool.gotranx] table in a parent
pyproject.toml overriding flags; a CellML model's own stimulus firing in a tissue simulation;
numba needing --shape single; automatic gating detection breaking Markov chains, which makes the
action potential drift over many beats; units and double-counted troponin when composing.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub finsberg/gotranx --plugin gotranxOther plugins' skills for the same job