In this tutorial we show how Chaste can be used to create, run and visualize node-based simulations.
Full details of the mechanical model can be found in Pathamathan et al. “A computational study of
discrete mechanical tissue models”, Physical Biology. Vol. 6. No. 3. 2009. doi:10.1088/1478-3975/6/3/036001.
As in previous cell-based Chaste tutorials (Running Mesh Based Simulations), we begin by including the necessary header files.
The following header is usually included in all cell-based test suites. It enables us to write tests where the SimulationTime is handled automatically and simplifies the tests.
The remaining header files define classes that will be used in the cell population
simulation test. We encountered some of these header files in
Running Mesh Based Simulations.
The next header file defines the class for storing the spatial information of cells.
The next header file defines a node-based CellPopulation class.
The next header file defines a boundary condition to be used in the third test.
In the first test, we run a simple node-based simulation, in which we create a monolayer
of cells, using a nodes only mesh. Each cell is assigned a stochastic cell-cycle model.
The first thing we do is generate a nodes only mesh. To do this we first create a MutableMesh
to use as a generating mesh.
To do this we can use the HoneycombMeshGenerator. This generates a honeycomb-shaped mesh,
in which all nodes are equidistant. Here the first and second arguments
define the size of the mesh - we have chosen a mesh that is 2 nodes (i.e.
cells) wide, and 2 nodes high.
Once we have a MutableMesh we can generate a NodesOnlyMesh from it using the
following commands. Note you can also generate the NodesOnlyMesh from a collection of
nodes, see NodesOnlyMesh for details.
To run node-based simulations you need to define a cut off length (second argument in
ConstructNodesWithoutMesh), which defines the connectivity of the nodes by defining
a radius of interaction.
Having created a mesh, we now create a std::vector of CellPtrs.
To do this, we the CellsGenerator helper class, which is templated over the type
of cell model required (here UniformCellCycleModel)
and the dimension. We create an empty vector of cells and pass this into the
method along with the mesh. The second argument represents the size of that the vector
cells should become - one cell for each node, the third argument specifies
the proliferative type of the cell.
Now we have a mesh and a set of cells to go with it, we can create a CellPopulation.
In general, this class associates a collection of cells with a mesh.
For this test, because we have a NodesOnlyMesh, we use a particular type of
cell population called a NodeBasedCellPopulation.
We then pass in the cell population into an OffLatticeSimulation,
and set the output directory, output multiple and end time.
We now pass a force law to the simulation.
To run the simulation, we call Solve().
The next two lines are for test purposes only and are not part of this tutorial. If different simulation input parameters are being explored
the lines should be removed.
To visualize the results, open a new terminal, cd to the Chaste directory,
then cd anim. Then do java Visualize2dCentreCells $CHASTE_TEST_OUTPUT/NodeBasedMonolayer/results_from_time_0.
We need to select the Cells as circles option to be able to visualize the cells, as opposed
to just the centres.
You may have to do: javac Visualize2dCentreCells.java beforehand to create the
java executable if you haven’t done that before.
Alternatively, to view in Paraview, load the file $CHASTE_TEST_OUTPUT/NodeBasedMonolayer/results_from_time_0/results.pvd
and add glyphs to represent cells. An option is to use 3D spherical glyphs and then make a planar cut.
Note that, for larger simulations, you may need to unclick “Mask Points” (or similar) so as not to limit the number of glyphs
displayed by Paraview.
In the second test we run a simple node-based simulation in 3D. This is very similar
to the 2D test with the dimension template (<2,2> and <2>) changed from 2 to 3 and instead of using a mesh
generator we generate the nodes directly.
First, we generate a nodes only mesh. This time we specify the nodes manually by first
creating a vector of nodes.
We then create some nodes to add to this vector.
Finally a NodesOnlyMesh is created and the vector of nodes is passed to
the ConstructNodesWithoutMesh method.
To run node-based simulations you need to define a cut off length (second argument in
ConstructNodesWithoutMesh), which defines the connectivity of the nodes by defining
a radius of interaction.
Having created a mesh, we now create a std::vector of CellPtrs.
As before, we do this with the CellsGenerator helper class (this time with dimension 3).
We make a NodeBasedCellPopulation (this time with dimension 3) as before.
We then pass in the cell population into an OffLatticeSimulation,
(this time with dimension 3) and set the output directory, output multiple and end time.
Again we create a force law (this time with dimension 3), and pass it to the OffLatticeSimulation.
To run the simulation, we call Solve().
The next two lines are for test purposes only and are not part of this tutorial.
To avoid memory leaks, we conclude by deleting any pointers that we created in the test.
Note that you cannot view the results of a 3D simulation using the Java visualiser but
to visualize the results, use Paraview.
See the Visualizing With Paraview tutorial for more information.
Load the file $CHASTE_TEST_OUTPUT/NodeBasedSpheroid/results_from_time_0/results.pvd,
and add spherical glyphs to represent cells.
Test 3 - a node-based simulation on a restricted geometry#
In the third test we run a node-based simulation restricted to the surface of a sphere.
We begin with exactly the same code as the previous test: we create a cell population
from a mesh and vector of cells, and use this in turn to create
a simulation object.
To run node-based simulations you need to define a cut off length (second argument in
ConstructNodesWithoutMesh), which defines the connectivity of the nodes by defining
a radius of interaction.
As before, we create a linear spring force and pass it to the simulation object.
This time we create a CellPopulationBoundaryCondition and pass this to
the OffLatticeSimulation. Here we use a SphereGeometryBoundaryCondition
which restricts cells to lie on a sphere (in 3D) or circle (in 2D).
For a list of possible boundary conditions see subclasses of AbstractCellPopulationBoundaryCondition.
These can be found in the inheritance diagram, here for AbstractCellPopulationBoundaryCondition.
Note that some of these boundary conditions are not compatible with node-based simulations see the specific class documentation for details,
if you try to use an incompatible class then you will receive a warning.
First we set the centre (0,0,1) and radius of the sphere (1).
We then make a pointer to the boundary condition using the MAKE_PTR_ARGS macro, and pass
it to the OffLatticeSimulation.
To run the simulation, we call Solve().
The next two lines are for test purposes only and are not part of this tutorial.
To avoid memory leaks, we conclude by deleting any pointers that we created in the test.
To visualize the results, use Paraview. See the Visualizing With Paraview tutorial for more information.
Load the file $CHASTE_TEST_OUTPUT/NodeBasedOnSphere/results_from_time_0/results.pvd,
and add spherical glyphs to represent cells.