This package provides a set of models for the circulation of blood in the heart and the rest of the body.
python -m pip install circulation
circulation ships an agent skill that helps you simulate, calibrate and
couple a 0D circulation: it checks your environment, asks what you want to simulate (a baseline,
a pathology, a calibration, a boundary condition for a 3D heart), proposes a model and, for 3D
coupling, a route (including UFL code generated from the model's .ode file), and builds and
checks the simulation.
- Claude Code:
/plugin marketplace add ComputationalPhysiology/circulationthen/plugin install circulation@circulation - Other agents (Codex, Gemini CLI, GitHub Copilot, Cursor, OpenCode, ...):
npx skills add ComputationalPhysiology/circulation --skill circulation-simulation - Manually: copy
plugins/circulation/skills/circulation-simulationinto your agent's skills directory (e.g.~/.claude/skills/).
See the section "Using circulation with an AI agent" below.
See https://computationalphysiology.github.io/circulation
import matplotlib.pyplot as plt
import circulation
# Create a model
model = circulation.regazzoni2020.Regazzoni2020()
# Solve the model for 5 seconds with a time step of 1 ms and an evaluation time step of 10 ms
results = model.solve(T=5.0, dt=1e-3, dt_eval=0.01)
# Print some information about the pressure, flows and volumes inside the model
model.print_info()
# Plot the pressure-volume loop
fig, ax = plt.subplots()
ax.plot(results["V_LV"], results["p_LV"])
ax.set_xlabel("V [mL]")
ax.set_ylabel("p [mmHg]")
plt.show()See more examples in the documentation.
The circulation-simulation skill (installed as above) turns a coding agent into a guide for 0D
circulation models. It
- checks that circulation is installed (by feature, as the package has no version string), and what else the plan needs (scipy, matplotlib, gotranx, dolfinx with fenicsx-pulse or simcardemsx);
- asks you, one question at a time, about your goal, which chambers are 0D, the time scale, your targets and, for a 3D heart, the coupling route;
- proposes alternatives with measured trade-offs (Regazzoni2020, the Windkessel, Zenker or Bestel; the built-in elastance or your own chamber pressure; segregated or monolithic 3D coupling; forward Euler or a scipy integrator; calibration by hand or by optimisation) and recommends one;
- writes the simulation as a script, checks that it is periodic, physiological, conserves blood
and is converged in
dt, and hands over the PV loop and metrics against your targets; - generates the circuit as UFL (or Python, C) from
regazzoni2020.odewith gotranx, removing the components a 3D model replaces; - knows the common pitfalls (units on parameters not converted, misspelled keys accepted,
num_beatshiding events at absolute times, the whole.odefile not translating to UFL, a heart rate changed without the elastance timings); - never installs anything without asking.
Describe what you want, for example
Simulate a healthy closed-loop circulation and plot the PV loops
and the agent loads the skill on its own; or invoke it explicitly
(/circulation:circulation-simulation in Claude Code, /circulation-simulation if you copied the
folder). Update it with /plugin marketplace update circulation or npx skills update.
MIT
