Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Electro-mechanics on a slab

The previous tutorials took the pieces apart. This one puts them together: an action potential spreads across a small slab of tissue, the calcium it releases makes the tissue contract, and the contraction feeds back into the electrophysiology.

Two solvers, each on its own mesh and with its own time step, are coupled:

  • EP: the monodomain model, solved by fenicsx-beat with operator splitting. The ODE step advances the EP half of the cell model at every node, and the PDE step diffuses the membrane potential vv:

    χCm∂v∂t=∇⋅(M∇v)−χIion(v,s)+Istim.\chi C_m \frac{\partial v}{\partial t} = \nabla\cdot(\mathbf{M}\nabla v) - \chi I_{ion}(v, \mathbf{s}) + I_{stim}.

    Here χ\chi is the membrane surface-to-volume ratio, CmC_m the membrane capacitance, M\mathbf{M} the (anisotropic) conductivity tensor and s\mathbf{s} the cell model’s states.

  • Mechanics: quasistatic, solved by fenicsx-pulse, with the contraction half of the cell model stepped inside Newton by GeneratedActivation, as in tutorial 3.

simcardemsx.controller.SimulationController runs the coupled loop. Every mechanics step of Δtmech\Delta t_{mech} it

  1. runs Δtmech/Δtep\Delta t_{mech} / \Delta t_{ep} EP steps;

  2. sends what the contraction model needs from EP to the mechanics mesh;

  3. solves mechanics and accepts the step (begin_step, solve, post_solve);

  4. sends what EP needs back (here the distortion states and the stretch λ\lambda), averaged onto the EP mesh.

What crosses is not configured by hand. It is read off the generated modules’ missing and provides dictionaries, which tutorial 1 printed. If a step fails, the controller restores every component to where it was before the step and raises.

2026-11-09 14:03:20 [info     ] Load ode /__w/simcardemsx/simcardemsx/examples/odefiles/ToRORd_dynCl_endo_zetasplit.ode
2026-11-09 14:03:25 [warning  ] Dropping a guard whose replacement failed its numeric check value=0 var=ki
2026-11-09 14:03:25 [warning  ] Dropping a guard whose replacement failed its numeric check value=0 var=nai
2026-11-09 14:03:25 [warning  ] Dropping a guard whose replacement failed its numeric check value=0 var=cli
2026-11-09 14:03:25 [warning  ] Dropping a guard whose replacement failed its numeric check value=0 var=clss
2026-11-09 14:03:25 [info     ] Num states 52                 
2026-11-09 14:03:25 [info     ] Num parameters 140            

The slab

A 3 × 1 × 0.5 mm slab with fibres along xx. EP and mechanics share this mesh here. They need not: the transfer between them interpolates between any two meshes.

576 cells

Electrophysiology

The cell model’s own stimulus current is switched off (i_Stim_Amplitude = 0). Instead a stimulus current is applied for 2 ms in the corner x,y,z≤0.5x, y, z \le 0.5 mm, from where the action potential spreads through the slab.

The ODE is stepped at every node of a P1 space. States, parameters and the variables coming from mechanics are stored with one column per node. The controller writes the stretch λ\lambda and the distortion states into these arrays in place, and they differ from node to node.

Mechanics

This is the problem of tutorial 3 on the slab, with rollers on the three faces through the origin. The displacement is P2, and the contraction states live at the quadrature points of a degree 4 rule, which must match the form’s.

Coupling

The controller checks the set-up when it is built: the backend must be the problem’s active model, Δtmech\Delta t_{mech} a whole multiple of Δtep\Delta t_{ep}, and the backend’s quadrature degree the form’s. It then works out what crosses between the two sides, with simcardemsx.transfer_plan.resolve, which we can call ourselves to see the answer. It raises if either side needs something the other does not provide.

EP → mechanics: ('XS', 'XW')
mechanics → EP: ('Zetas', 'Zetaw')
λ sent to EP:   True

Running

controller.step() advances everything by one mechanics step. Its callbacks are called after every EP step and after every mechanics step. We use the EP callback to record when each node is activated (when vv first rises above 0 mV), and the mechanics callback to record the means of vv, λ\lambda and TaT_a.

200 ms in 64 s

The activation wave

The activation times on the face z=0z = 0 show the wave leaving the stimulated corner. It travels faster along the fibres (xx) than across them, because the conductivity is higher along the fibres.

<Figure size 700x280 with 2 Axes>
conduction velocity along the fibres: 0.59 mm/ms = 59 cm/s

Contraction

Tension builds up over the 150 ms after the action potential, as in tutorial 1, and the slab shortens along its fibres.

<Figure size 1500x320 with 4 Axes>

The stretch λ\lambda goes back to EP after every mechanics step, where it enters the contraction half of the cell model that EP steps. In this split that is the crossbridge populations XS and XW and troponin binding. This is the mechano-electric feedback of the model.

λ at the EP nodes after 200 ms: 0.8099 to 0.8178

Where to go from here

  • The slab example is this tutorial grown into a full program. It takes the split, the scheme and a crossbridge model on the command line, writes results.bp for ParaView, and checkpoints and restarts.

  • controller.snapshot() and controller.restore(snapshot) copy and restore the state of every component, and simcardemsx.checkpoint.Checkpointer writes it to disk, so a run can continue in a new process.

  • The BiV and Rodero examples put the same coupling into a beating biventricular heart, closed by a circulation model.