Examples showing how to solve a system of coupled linear parabolic PDEs and ODEs#
In this tutorial we show how Chaste can be used to solve a system of coupled linear
parabolic PDEs and ODEs. This test uses the LinearParabolicPdeSystemWithCoupledOdeSystemSolver.
The following header files need to be included.
First we include the header needed to define this class as a test suite.
On some systems there is a clash between Boost Ublas includes and PETSc. This can be
resolved by making sure that Chaste’s interface to the Boost libraries are included
as early as possible.
This is the class that is needed to solve a system of coupled linear
parabolic PDEs and ODEs.
The next header file defines the Schnackenberg system, which comprises
two reaction-diffusion PDEs that are coupled through their reaction terms.
The next header file will allow us to specify a random initial condition.
We then include header files that allow us to specify boundary conditions for the PDEs,
deal with meshes and output files, and use PETSc. As noted before, PetscSetupAndFinalize.hpp
must be included in every test that uses PETSc.
on a 2d butterfly-shaped domain. We impose non-zero Dirichlet
boundary conditions and an initial condition that is a random
perturbation of the spatially uniform steady state of the
system.
To do this we define the test suite (a class). It is sensible to name it the same
as the filename. The class should inherit from CxxTest::TestSuite.
All individual tests defined in this test suite must be declared as public.
Define a particular test.
As usual, we first create a mesh. Here we are using a 2d mesh of a butterfly-shaped domain.
We scale the mesh to an appropriate size.
Next, we instantiate the PDE system to be solved. We pass the parameter values into the
constructor. (The order is $D_1, D_2, k_1, k_{-1}, k_2, k_3$)
Then we have to define the boundary conditions. As we are in 2d, SPACE_DIM=2 and
ELEMENT_DIM=2. We also have two unknowns u and v,
so in this case PROBLEM_DIM=2. The value of each boundary condition is
given by the spatially uniform steady state solution of the Schnackenberg system,
given by $u = (k_1 + k_2)/k_{-1}$, $v = k_2 k_{-1}^2 / k_3(k_1 + k_2)^2$.
This is the solver for solving coupled systems of linear parabolic PDEs and ODEs,
which takes in the mesh, the PDE system, the boundary conditions and optionally
a vector of ODE systems (one for each node in the mesh). Since in this example
we are solving a system of coupled PDEs only, we do not supply this last argument.
Then we set the end time and time step and the output directory to which results will be written.
We create a vector of initial conditions for u and v that are random perturbations
of the spatially uniform steady state and pass this to the solver.
We now solve the PDE system and write results to VTK files, for
visualization using Paraview. Results will be written to $CHASTE_TEST_OUTPUT/TestSchnackenbergSystemOnButterflyMesh
as a results.pvd file and several results_[time].vtu files.
You should see something like
for
u and
for v.
All PETSc Vecs should be destroyed when they are no longer needed.