# Chaste Tutorials

## Before you start

If you are viewing this on the Chaste wiki, **the tutorials here are automatically updated to work with the latest development version of Chaste**.
They are not guaranteed to work with any release version, in fact they are unlikely to!
If you are working with a release version of the code then this page is archived upon releases; the tutorials corresponding to each release version of Chaste can be found at https://chaste.cs.ox.ac.uk/chaste/tutorials/

## The basics

These tutorials assume prior knowledge or understanding of various C++ language features and some libraries, including (at least): `std::vector`s, `c_vector`s, and object-oriented inheritance including abstract classes and virtual methods.

If you don't know anything about these we recommend a first course in C++, there are plenty online (here is one from cplusplus.com). There is also a Scientific Computing in C++ book by some of our team available too.

To run any of these tutorials, it is assumed you have first configured Chaste using `CMake`:

cmake /path/to/chaste/src

Then, run

make <NAME_OF_TUTORIAL_FILE>

to compile the tutorial source code, and

ctest -V -R <NAME_OF_TUTORIAL_FILE>

to run it.

For instance:

make TestSolvingOdesTutorial ctest -V -R TestSolvingOdesTutorial

- UserTutorials/WritingTests -
**start here**, then choose core/cardiac/cell-based

## Core functionality

### Solving ODEs

### Solving PDEs

- UserTutorials/SolvingLinearPdes
- UserTutorials/SolvingNonlinearPdes
- UserTutorials/SolvingLinearParabolicPdeSystemsWithCoupledOdeSystems

### Writing new PDE solvers (advanced)

### Solid Mechanics

- UserTutorials/SolvingElasticityProblems - computing the deformation of a nonlinearly elastic body
- UserTutorials/SolvingMoreElasticityProblems

## Cardiac Chaste

For executable users:

Source code users:

- UserTutorials/RunningBidomainSimulations -
**basic bidomain simulation**; note monodomain is virtually the same - UserTutorials/AnotherBidomainSimulation - shows how to use
**varying fibre directions**and**different output formats**in particular - UserTutorials/Monodomain3dExample - illustrates the (trivial) changes required to go from 2d to
**3d**, or bidomain to**monodomain** - UserTutorials/Monodomain3dExampleWithCvode - illustrates how to adapt the previous tutorial to create cells with
**CVODE solvers**, which can provide increased speed and accuracy. - UserTutorials/Monodomain3dRabbitHeart - illustrates loading meshes from file, and specifying fibre and cross-fibre conductivities, on a realistic (but low res) rabbit whole ventricles mesh.
- UserTutorials/BidomainWithBath - illustrates the use of
**Backward Euler**ODE solvers (very stable), and solving a bidomain problem in tissue surrounded by (extra-cellular domain) bath. - UserTutorials/BidomainWithBathAndFibres
- UserTutorials/BidomainWithConductivityModifier - shows how to use
**conductivity modifiers**in a bidomain simulation. - UserTutorials/CardiacCheckpointingAndRestarting
- UserTutorials/CardiacElectroMechanics
- UserTutorials/AnotherCardiacElectroMechanics
- UserTutorials/SingleCellSimulation

See also cardiac Chaste practical for details of a practical we have used to teach cardiac Chaste.

## Cell-based Chaste

Where to start with cell-based simulations:

Running basic simulations:

- UserTutorials/RunningMeshBasedSimulations - the simplest (and first to be implemented in Chaste) type of cell-based simulation, start here
- UserTutorials/RunningNodeBasedSimulations - includes details of how to simplify cell-based tests
- UserTutorials/RunningVertexBasedSimulations - includes adding boundary conditions and removing cells from simulations
- UserTutorials/RunningPottsBasedSimulations - lattice-based simulations
- UserTutorials/VisualizingWithParaview

Running crypt-specific simulations:

- UserTutorials/RunningMeshBasedCryptSimulations
- UserTutorials/RunningVertexBasedCryptSimulations
- UserTutorials/RunningCryptSimulationsWithMutations

More advanced examples:

- UserTutorials/RunningContactInhibitionSimulations
- UserTutorials/RunningDeltaNotchSimulations
- UserTutorials/RunningDifferentialAdhesionSimulations
- UserTutorials/RunningTumourSpheroidSimulations

Adding new functionality:

- UserTutorials/CreatingAndUsingANewCellCycleModel
- UserTutorials/CreatingAndUsingANewCellKiller
- UserTutorials/CreatingAndUsingANewCellPopulationBoundaryCondition
- UserTutorials/CreatingAndUsingANewForce
- UserTutorials/CreatingAndUsingANewCellMutationState
- UserTutorials/CreatingAndUsingANewCellProperty
- UserTutorials/CreatingAndUsingNewCellBasedWriters
- UserTutorials/CreatingAndUsingANewCellBasedSimulationModifier

See also cell-based Chaste practical for details of a practical we have used to teach cell-based Chaste.

## Lung Chaste

Generation and manipulation of airway geometries

Simulating ventilation and impedance

- UserTutorials/StaticVentilation
- UserTutorials/DynamicVentilation
- UserTutorials/SimpleImpedanceProblem

## Automatically generated alphabetical listing

- AirwayGeneration An example showing how generate a complete conducting airway model given segmentations of CT airways and lobes
- AnotherBidomainSimulation Another example showing how to run a bidomain simulation
- AnotherCardiacElectroMechanics Cardiac Electro-mechanical Problems (cont.)
- BidomainWithBath An example showing how to run a bidomain simulation for tissue contained in a perfusing bath
- BidomainWithBathAndFibres Running a bidomain simulation with a bath and fibres
- BidomainWithConductivityModifier A bidomain simulation with spatially varying conductivities.
- CardiacCheckpointingAndRestarting Checkpointing and restarting cardiac simulations
- CardiacElectroMechanics Cardiac Electro-mechanical Problems
- CardiacExecutable Using the cardiac executable
- BidomainSimulationsWithPerfusingBath Running a bidomain simulation of cardiac tissue contained in a perfusing bath
- CheckpointingAndRestarting Checkpointing
- DrugAction Running a simulation with multiple-channel drug action
- HardCodedCellModels Hardcoded cell model options
- HeterogeneousExample Simulations with heterogeneities
- MeshConvert Making the `MeshConvert` utility and using it to help produce scalable mesh loading
- Propagation1d Running a simple example: propagation in a tissue fibre
- Propagation3d 3D on a realistic cardiac geometry
- S1S2Protocol Running a simulation of a spiral wave in 2d mesh
- UsingCellmlFiles UserTutorials/CardiacExecutable/UsingCellmlFiles
- UsingFibreDefinitions Using fibre directions and postprocessing

- BidomainSimulationsWithPerfusingBath Running a bidomain simulation of cardiac tissue contained in a perfusing bath
- CellBasedDemo Examples showing how to create, run and cell-based simulations in Chaste
- CreatingAndUsingANewCellBasedSimulationModifier An example showing how to create a new cell-based simulation modifier and use it in a simulation
- CreatingAndUsingANewCellCycleModel An example showing how to create a new cell-cycle model and use it in a cell-based simulation
- CreatingAndUsingANewCellKiller An example showing how to create a new cell killer and use it in a cell-based simulation
- CreatingAndUsingANewCellMutationState An example showing how to create a new cell mutation state and use it in a cell-based simulation
- CreatingAndUsingANewCellPopulationBoundaryCondition An example showing how to create and use a new cell population boundary condition
- CreatingAndUsingANewCellProperty An example showing how to create a new cell property and use it in a cell-based simulation
- CreatingAndUsingANewForce An example showing how to create and use a new force
- CreatingAndUsingANewSrnModel An example showing how to create a new subcellular reaction network (SRN) model and use it in a cell-based simulation.
- CreatingAndUsingNewCellBasedWriters An example showing how to create a new cell writer and use it in a cell-based simulation
- DynamicVentilation An example showing how to simulate ventilation over a full breathing cycle.
- EquivalentMonoAndBidomain How to run a Bidomain simulation and its equivalent Monodomain reduction
- Monodomain3dExample 3D monodomain example
- Monodomain3dExampleWithCvode 3D monodomain example using CVODE for ODE solution
- Monodomain3dRabbitHeart 3D monodomain rabbit heart example
- RunningBidomainSimulations An example showing how to run bidomain simulations
- RunningContactInhibitionSimulations An example showing how to use a contact inhibition cell cycle model and volume tracking simulation modifier
- RunningCryptSimulationsWithMutations Examples showing how to run crypt simulations with various mutations
- RunningDeltaNotchSimulations An example showing how to run Delta/Notch simulations
- RunningDifferentialAdhesionSimulations An example showing how to simulate cell sorting due to differential adhesion in a vertex-based model
- RunningMeshBasedCryptSimulations Examples showing how to run crypt simulations on periodic meshes with different cell-cycle models
- RunningMeshBasedSimulations Examples showing how to create, run and visualize mesh-based simulations
- RunningNodeBasedSimulations Examples showing how to create, run and visualize node-based simulations
- RunningPottsBasedSimulations Examples showing how to create, run and visualize Potts-based simulations
- RunningTumourSpheroidSimulations An example showing how to run tumour spheroid simulations
- RunningVertexBasedCryptSimulations Examples showing how to create, run and visualize vertex-based simulations on periodic meshes with different cell-cycle models
- RunningVertexBasedSimulations Examples showing how to create, run and visualize vertex-based simulations
- SimpleImpedanceProblem An example showing how to calculate transfer impedance of an airway tree using a simple impedance model
- SingleCellSimulation An example showing how to run a single cell simulation
- SolvingElasticityProblems Solving solid mechanics problems
- SolvingLinearParabolicPdeSystemsWithCoupledOdeSystems Examples showing how to solve a system of coupled linear parabolic PDEs and ODEs
- SolvingLinearPdes Examples showing how to solve linear elliptic and parabolic PDEs
- SolvingMoreElasticityProblems Introduction
- SolvingNonlinearPdes An example showing how to solve a nonlinear elliptic PDE. Also includes function-based boundary conditions.
- SolvingOdes In this tutorial we show how Chaste can be used to solve an ODE system
- StaticVentilation An example showing how to calculate ventilation distribution in an airway tree for a given flow rate at the trachea
- VisualizingWithParaview Examples showing how to visualize simulations in Paraview
- WritingPdeSolvers Introduction
- WritingPdeSolversTwo Introduction
- WritingTests Writing tests