Another example showing how to run a bidomain simulation#
In this tutorial we run another bidomain simulation,
showing:
i) an example using one of the source cell factories,
ii) how to define and use fibre directions, and
iii) mentioning how to write other output file formats.
The first thing to do is to include the headers as before.
Rather than write our own cell factory this time, we will use
the PlaneStimulusCellFactory.
Now we define the test class, which must inherit from CxxTest::TestSuite
as usual, and the (public) test method
It is not the case here, but if there were other tests in the file that
had already been run and might have changed parameters in HeartConfig, we
would need to call Reset
Next, we have to create a cell factory of the type we defined above. The plane
stimulus cell factory sets up cells of the given type with a non-zero stimulus
for cells on the $x=0$ boundary. The 2 below is the dimension, and the -2000000
is the stimulus magnitude (the default stimulus duration is used).
Define an end time, output directory and prefix as before
Define a mesh to be read, saying that we also want to read fibres. The extra part can either be
cp::media_type::Orthotropic, in which case 2D_0_to_1mm_800_elements.ortho will also be read;
or cp::media_type::Axisymmetric, in which case 2D_0_to_1mm_800_elements.axi will also be read.
See the file formats documentation for full descriptions of these formats, but basically .axi
files provide the fibre direction for each element in the mesh, and .ortho files provide the fibre,
sheet (and normal in 3D) directions for each element in the mesh.
The fibre file provided here defines (non-physiological) ‘kinked’ fibres which are
in the x-direction for $x<0.05$, and then the diagonal $(1,1)$ direction for $x \geqslant 0.05$.
It was generated by looping over the mesh that is to be used, as shown here.
The output is the .ortho file minus the header.
This is of course not enough - by default isotropic conductivities are used so the
variable fibre directions won’t make any difference - so we have to alter the
intracellular and extracellular conductivities to be anisotropic. The first value in
the following is the conductivity in the fibre direction, the second the conductivity
in the sheet direction (and the third in 3d would be that in the normal direction).
Note, we have scaled all the conductivities from the physiological values as the mesh
is a little too coarse to be able to handle the smallest conductivities (try running with
scale = 1 to see the error message).
The output will be written to $CHASTE_TEST_OUTPUT/BidomainFibresTutorial
in HDF5 format. It can be converted to visualisable formats (Meshalyzer, Cmgui or VTK) at the end
of the simulation using methods in HeartConfig, e.g.
The other option is to write in VTK format (which needs VTK installed), following
which the results can be loaded in the visualiser Paraview
If the mesh is a DistributedTetrahedralMesh then we can use parallel VTK files (.pvtu)
Now we create a problem class, initialise and solve
The results can now be visualised - the effect of the fibres changing direction at x=0.05
on the wave should be very clear.
We described in the previous tutorial how to access the latest voltage vector using
ReplicatableVector, here we illustrate how to access the voltage values using the
DistributedVector class, which can be used to only iterate over the values
of the voltage owned by that process (for parallel simulations).
A loop over all the components owned by this process..
.. and a simple test, that the ’last’ node was stimulated: