Demos#
This page indexes all the demos in fenicsx-beat, grouped the same way as in the sidebar. If you are
new to the library, start with the mathematical background page for the
model and notation used throughout, then work through the
FitzHugh–Nagumo demo below.
Getting started#
A simple example of excitable tissue: The FitzHugh–Nagumo model — the best starting point. Solves the monodomain model with the simplest possible ionic current model, both as a single-cell ODE and as a full 2D tissue simulation, introducing the
beatAPI step by step.
Examples#
Diffusion in a square domain with a stimulus in the lower left corner — the monodomain model with the ionic current switched off entirely, i.e. pure diffusion driven by a stimulus current.
Solving a simple ODE — solving a toy ODE system with
beat’s ODE solver at many points at once, the same kind of step used for the cell model in the full monodomain solver.Endocardial stimulation of a left ventricle ellipsoid — a full 3D simulation on an idealized left-ventricle geometry, with fibre directions, transmurally varying cell models (endocardial/mid-myocardial/epicardial), and endocardial stimulation.
Conduction velocity and ECG for slabs — conduction velocity and pseudo-ECG estimation on a simple slab of tissue.
Niederer benchmark — the standard cross-code monodomain benchmark [LGA+15], comparing activation times across spatial and temporal resolutions.
Premature Ventricular Complexes (PVCs) — reproducing an ectopic beat originating from a region of reduced repolarization reserve on a 1D cable [ZLH+21].
Pacing train — the same 1D cable as the PVC demo, rapidly paced from one end.
Purkinje like stimulation of a realistic BiV geometry — a realistic bi-ventricular geometry from a UK Biobank atlas, stimulated at many random endocardial points to mimic activation via the Purkinje network.
A Durrer-like activation sequence on a Bi-ventricular ellipsoid —
beat.activation_sequence.EndocardialActivation: the early activation sites of [DvDF+70] spreading over the endocardium at a Purkinje-like speed, used as the stimulus of a monodomain simulation.Spiral wave in a 2D sheet of human ventricular tissue — a single re-entrant spiral wave in the ten Tusscher–Panfilov 2006 model [tTP06], initiated with a cross-field S1–S2 protocol, with tracking of the meandering spiral tip.
Spiral wave breakup in a 2D sheet of human ventricular tissue — the same setup with the steep-restitution parameter set from [tTP06], where the spiral breaks up into many smaller spirals, as in the transition to ventricular fibrillation.
Activation times from the eikonal equation —
beat.eikonal’s Fast Iterative Method solver: an anisotropic point source against the exact solution, colliding fronts, and the wedge of [NCP+17].The reaction-eikonal model: activation in a ventricular wedge — R-D, R-E\(^+\) and R-E\(^-\) on the wedge of [NCP+17] (their Figs. 2 and 4): activation maps, deviations and upstrokes.
The reaction-eikonal model: repolarisation in a ventricular wedge — transmural repolarisation gradients of R-D, R-E\(^+\) and R-E\(^-\) (Fig. 5 of [NCP+17]).
The reaction-eikonal model: electrograms in a ventricular wedge — pseudo-bidomain extracellular potentials and electrograms of R-D, R-E\(^+\) and R-E\(^-\) in a bath (Fig. 7 of [NCP+17]).
Verification#
Verifying Second-Order Temporal Convergence — checks the second-order-in-time convergence of Strang splitting combined with a Crank–Nicolson PDE step, using the method of manufactured solutions, then with gotranx’s cell schemes (only the second-order
*_rush_larsen_2keeps it second order) and with the ten Tusscher–Panfilov 2006 cell model; a last section compares the cost and accuracy of merged Strang half-steps.Monodomain convergence test — the companion check of the (first-order) spatial and Godunov-splitting convergence rates (first order in time with Godunov splitting; see the verification demo above for second order with Strang).
Bidomain convergence test — the same kind of check for
beat.BidomainModel, measuring the rate in \(h\) and \(\Delta t\) for the extracellular potential as well as the transmembrane one, and confirming that the model collapses exactly onto the monodomain model when the conductivity tensors are proportional.
Advanced topics#
Fully implicit high-order time stepping with Irksome — replaces the default explicit/\(\theta\)-rule time stepping with fully implicit, high-order Runge–Kutta methods (via the optional Irksome dependency) for the PDE and/or ODE step, demonstrated on a
gotranx-generated cell model and a strongly heterogeneous conductivity field.Cell-model stepping via dolfinx-external-operator — a drop-in alternative ODE step (via the optional dolfinx-external-operator dependency) that reuses your existing cell-model function unchanged; cross-checks it against
DolfinODESolveron a realgotranx-generated cell model and reports the current performance trade-off honestly.A compiled C backend for cell models — compiles the C code that
gotranxgenerates into a drop-in replacement for the NumPy cell-model function, and compares NumPy, Numba, C and C with OpenMP for the ODE step alone and in a small monodomain simulation.Monolithic implicit PDE+ODE coupling with dolfinx-external-operator — a prototype fully implicit Newton solve of the PDE and cell model together, with a JAX-autodifferentiated Jacobian and no operator-splitting error at all; validated against an independent reference and quantitatively compared against
SplittingSolver.
Dirk Durrer, R Th van Dam, GE Freud, MJ Janse, FL Meijler, and RC Arzbaecher. Total excitation of the isolated human heart. Circulation, 41(6):899–912, 1970. doi:10.1161/01.CIR.41.6.899.
Sander Land, Viatcheslav Gurev, Sander Arens, Christoph M Augustin, Lukas Baron, Robert Blake, Chris Bradley, Sebastian Castro, Andrew Crozier, Marco Favino, and others. Verification of cardiac mechanics software: benchmark problems and solutions for testing active and passive material behavior. Proceedings of the Royal Society A: Mathematical, Physical and Engineering Sciences, 471(2184):20150641, 2015.
Aurel Neic, Fernando O. Campos, Anton J. Prassl, Steven A. Niederer, Martin J. Bishop, Edward J. Vigmond, and Gernot Plank. Efficient computation of electrograms and ECGs in human whole heart simulations using a reaction-eikonal model. Journal of Computational Physics, 346:191–211, 2017. doi:10.1016/j.jcp.2017.06.020.
Kirsten H W J ten Tusscher and Alexander V Panfilov. Alternans and spiral breakup in a human ventricular tissue model. American Journal of Physiology-Heart and Circulatory Physiology, 291(3):H1088–H1100, 2006. doi:10.1152/ajpheart.00109.2006.
Zhaoyang Zhang, Michael B Liu, Xiaodong Huang, Zhen Song, and Zhilin Qu. Mechanisms of premature ventricular complexes caused by qt prolongation. Biophysical journal, 120(2):352–369, 2021.