

gotranx
gotranx is the next generation General ODE translator. The general idea is that you write your ODE in a high level markup language and use gotranx to generate code for solving the ODE in different programming languages. gotranx uses sympy to create a symbolic representation of the ODE which is used to generate the jacobian and numerical schemes.
gotranx makes it also possible generate code from e.g CellML models using conversion tools from myokit.
Install
Install with pip
python3 -m pip install gotranx
or for the development version
python3 -m pip install git+https://github.com/finsberg/gotranx
You can also install gotranx using conda
conda install -c conda-forge gotranx
AI agent skill
gotranx ships an agent skill that helps you turn cell models into code:
it checks your environment, asks what you want (model, coupling of models, scheme, target
language), suggests alternatives, and writes and checks the generated code for you.
- Claude Code:
/plugin marketplace add finsberg/gotranx then /plugin install gotranx@gotranx
- Other agents (Codex, Gemini CLI, GitHub Copilot, Cursor, OpenCode, ...):
npx skills add finsberg/gotranx --skill gotranx-odes
- Manually: copy
plugins/gotranx/skills/gotranx-odes
into your agent's skills directory (e.g. ~/.claude/skills/).
See the section "Using gotranx with an AI agent" below.
Quick start
Define your ODE in a .ode file, e.g file.ode with the content
states(x=1, y=0)
parameters(a=1.0)
dx_dt = a * y
dy_dt = -x
which defines the ODE system
$$
\begin{align}
\frac{dx}{dt} &= ay \
\frac{dy}{dt} &= -x
\end{align}
$$
with the initial conditions $x(0) = 1$ and $y(0) = 0$ and the parameter $a$ with a value of 1.0. Now generate code in python for solving this ODE with the explicit euler scheme using the command
gotranx ode2py file.ode --scheme explicit_euler -o file.py
which will create a file file.py containing functions for solving the ODE.
The same ODE can be turned into C (ode2c), C++ (ode2cpp), CUDA (ode2cuda), Julia (ode2julia), a
ModelingToolkit system (ode2mtk), UFL (ode2ufl), Markdown (ode2md),
CellML (ode2cellml) or a CytoZoo
cell-model adapter (ode2cytozoo -- whose output needs a CytoZoo providing
resolve_parameter and primal, not yet released). Now you can solve the ode using the following code snippet
import file as model
import numpy as np
import matplotlib.pyplot as plt
s = model.init_state_values()
p = model.init_parameter_values()
dt = 1e-4 # 0.1 ms
T = 2 * np.pi
t = np.arange(0, T, dt)
x_index = model.state_index("x")
x = [s[x_index]]
y_index = model.state_index("y")
y = [s[y_index]]
for ti in t[1:]:
s = model.explicit_euler(s, ti, dt, p)
x.append(s[x_index])
y.append(s[y_index])
plt.plot(t, x, label="x")
plt.plot(t, y, label="y")
plt.legend()
plt.show()

Alternatively, you can use a third-party ODE solver, e.g scipy.integrate.solve_ivp to solve the ODE by passing in the right-hand side function
import file as model
from scipy.integrate import solve_ivp
import numpy as np
import matplotlib.pyplot as plt
s = model.init_state_values()
p = model.init_parameter_values()
dt = 1e-4 # 0.1 ms
T = 2 * np.pi
t = np.arange(0, T, dt)