On this wiki page we describe in detail the code that is used to run this example from the paper.
This example is based on UserTutorials/CardiacElectroMechanics
The example shows how an electrical wave is followed by contraction along cardiac fibres.
The fibres have different orientations in different parts of the tissue, resulting in a
“twisting” motion.
Remember to run with build=GccOptNative for speed.
e.g.
This example uses only files from the core Chaste code.
There is a special cmgui visualization script that loads both mechanics and voltage solution onto the
same mesh, which is in the same folder as this file: LoadElectroMechanicsSimulation.com
We first include some header files which define the classes we will use.
The following code is the test itself, we use the scons / cxx-test framework to run simulations, as it
provides a handy way to do all the necessary linking and library building.
Set the length of the simulation, long enough for some contraction to occur
This class sets up cells with the correct stimuli to
stimulate just those cells on the x=0 surface at t=0.
We define the strength of stimulus that we need.
For electro-mechanics we need to set up two meshes of 1mm by 1mm by 1mm
We have a fine electrics mesh and a coarser mechanics one.
We are going to fix some nodes on Z (dimension ‘2’ indexed from 0)
so we first need to identify these
We now define the electro-mechanics problem.
This includes specifying the contraction model and the material properties,
as well as those nodes that are fixed and the mechanics timestep to use.
Mechanics happens over a longer timescale than electrophysiology,
so we can use larger space and time steps for this aspect.
This is how to generate a fibre file for this mesh
(this could be generated once, stored and re-loaded, as indeed we do below)
We use a Streeter-style formula here.
Usually the fibres for a scientific problem would be determined by e.g. DTMRI
and stored with the mesh files.
We only compile the following if VTK is installed and set up.
This is optional - it is only used here for visualizing the fibre directions as in the paper figure.
The simulation will run without it.
Load up the file we just wrote to use as fibre directions for this mechanics problem.
Set up and solve the full cardiac electro-mechanics problem.