Assignment6 Final
Assignment6 Final
4856198
Assignment 6
Numerical solution of a non-linear coupled
reaction-diffusion problem
∂u
= Du ∆u + k a − u + u2 v
∂t
∂v
= Dv ∆v + k b − u2 v
∂t (1)
(x, y) ∈ Ω, t ∈ (0, T ]
u(x, y, 0) = u0 (x, y), v(x, y, 0) = v0 (x, y), (x, y) ∈ Ω
−Du ∇u · n = 0, −Dv ∇v · n = 0, (x, y) ∈ ∂Ω
1
In contrary to assignment 3 the boundary conditions are now zero
Neumann. The domain is a square. That means that n points in
4 different directions. Since the opposite (negative direction) will
not make a difference (the minus sign will drop), because all the
derivatives equal zero. Therefore only 2 equations will be shown.
∂u ∂u ∂u
−Du ∇u · n = −Du , · (0, 1) → =0 (2)
∂x ∂y ∂y
∂u ∂u ∂u
−Du ∇u · n = −Du , · (1, 0) → =0 (3)
∂x ∂y ∂x
Since the value of the boundary points is not known, these ele-
ments need to be substituted.
The grid has 9 internal points and 12 boundary points. The image
below illustrates the grid. The green dots are the internal points
and the red dots are the boundary points.
2
−ui−1,j − ui+1,j + 4ui,j − ui,j−1 − ui,j+1
−∆ui,j =
h2 (5)
2
+O h
ui−1,j + ui+1,j − 4ui,j + ui,j−1 + ui,j+1
∆ui,j =
h2 (6)
2
+O h
Internal point
There is one equation for the internal point.
3
Near-corner-points
There are four equations for the near-corner-points.
4
u2,3 + u4,3 − 4u3,3 + u3,2 + u3,4
∆u3,3 = (10)
h2
u3,4 − u3,3
= 0 → u3,3 = u3,4
h
u4,4 − u3,3
= 0 → u3,3 = u4,4
h
5
u1,1 + u3,1 − 4u2,1 + u2,0 + u2,2
∆u2,1 = (13)
h2
u2,1 − u2,0
= 0 → u2,1 = u2,0
h
6
To attain the matrix for the negative LaPlacian, all the above
equations should be multiplied with -1.
The matrix A:
2 −1 0 −1 0 0 0 0 0
−1 3 −1 0 −1 0 0 0 0
0 −1 2 0 0 −1 0 0 0
−1 0 0 3 −1 0 −1 0 0
1
A= 2 0 −1 0 −1 4 −1 0 −1 0 (17)
h
0 0 −1 0 −1 3 0 0 −1
0 0 0 −1 0 0 2 −1 0
0 0 0 0 −1 0 −1 3 −1
0 0 0 0 0 −1 0 −1 2
7
(b) Find the matrices Dx and Dy , such that:
x−1 − x0
=0
h
x0 − x1
= dx1
h
x1 − x2
= dx2
h
x2 − x3
=0
h
This results in the matrix Dx and Dy
0 0 0
−1 1 0
0 −1 1 (18)
0 0 0
Axx and Ayy :
1 −1 0
−1 2 −1 (19)
0 −1 1
A = Iy ⊗ Axx + Ayy ⊗ Ix :
1 −1 0 1 0 0 1 0 0 1 −1 0
−1 2 −1 ⊗ 0 1 0 + 0 1 0 ⊗ −1 2 −1
0 −1 1 0 0 1 0 0 1 0 −1 1
(20)
8
(c) Let u(t) and v(t) be the lexicographic vectors of the grid
values u (xi , yj , t) and v (xi , yj , t) at time t. After spatial dis-
cretization we obtain two coupled systems of ODE’s:
u0 = fu (u, v)
v0 = fv (u, v)
∂u
= Du ∆u + k a − u + u2 v
∂t
0
u = −Du Au + k (a − u + u ◦ u ◦ v) (21)
∂v
= Dv ∆v + k b − u2 v
∂t
v 0 = −Dv Av + k (b − u ◦ u ◦ v) (22)
This can be written in the form of a system:
d u fu (u, v)
− (23)
dt v fv (u, v)
d u −Du Au + k (a − u + u ◦ u ◦ v)
− (24)
dt v −Dv Av + k (b − u ◦ u ◦ v)
9
2. Numerical time integration
∂u
= ∆u − ku, k>0 (26)
∂t
bj 2 − (ht (−A − k) + 1) bj k = 0
bj = 0 v bj − (ht (−A − k) + 1) = 0
bj = 1 − ht (λ + k)
|1 − ht (λ + k)| < 1
(27)
−1 < 1 − ht (λ + k) < 1
2
0 < ht <
λmax + k
10
T 2
0< < 8
Nt h2
+k
T (8N 2 + kL2 )
Nt > (28)
2L2
(c) Write down the iteration formula that you need to solve at
each step of the Backward-Euler Method for the coupled
system (6) or for the single system that you have derived.
k+1 k+1 k
u d u u
=h· + (29)
v dt v v
3. Newton-Raphson algorithm
(a) Write down the nonlinear problem that you need to solve
at each step of the Backward-Euler algorithm. This is
easier to do in the single-system formulation derived in
1(c). Identify the residual that will be minimized by the
Newton-Raphson algorithm at a given time step. Write
down the (inner) iteration formula of the Newton-Raphson
algorithm.
First we need to write the system of two equations as one equa-
tion to simplify
the expressions. That is done by substituting the
u
vector by the the new variable w Let
v
−Du Au + k(a − u + u ◦ u ◦ v)
f (w) =
−Dv Av + k(b − u ◦ u ◦ v)
The Backward-Euler problem becomes now:
w − wi ≈ pi (wi ) (31)
11
wi+1 = wi + pi (wi ) (32)
The inner iteration formula of the Newton-Raphson algorithm is
as follows:
k+1 −1
wk+1 k+1 k+1 k+1
k
i+1 = w i + I − ht J w i wi + ht f w i − w i
(33)
or
−1 k
pi (wik+1 ) = I − ht J wk+1 wi + ht f wk+1 − wk+1
i i i
(34)
(b) Compute the Jacobian matrix. Hint: use the single-
system formulation, the Jacobian matrix will have four
blocks: " #
∂fu (u,v) ∂fu (u,v)
J(u, v) = ∂u ∂v
∂fv (u,v) ∂fv (u,v)
∂u ∂v
∂fu (u, v)
= −Du A + k(−I + 2 diag(u ◦ v))
∂u
∂fu (u, v)
= k diag(u ◦ u
∂v
∂fv (u, v)
= −2k diag(u ◦ v)
∂u
∂fv (u, v)
= −Dv A + −k diag(u ◦ u)
∂v
12
4. Programming the Forward-Euler (FE) Method. With the FE
Method it is possible to work in terms of the coupled sys-
tems (6) and vectors u and v. Your code and report will be
evaluated based on the following:
13
(c) The report should contain the images of the activator
u(x, y, t) and inhibitor v(x, y, t) at t = 0 and t = T, obtained
with the FE Method.
14
In order to make an empirical choice of Nt the results are plotted
of a nested loop with the outer loop k from 2 to 9 and the step size
Nt varying from 10 to 100 with an interval of 10. In each iteration
the total number of inner iterations was counted for a certain k
and Nt
as long as h > 0 is sufficiently small, Newton-Raphson’s algorithm
has quadratic convergence. In the left figure the the number of
total iterations starts large and drops as N t increases. From that
point on there is quadratic convergence and the number of total
inner iterations increases linearly with N t. As k increases, The
optimum shifts to the right. The right plot differs from the left
plot in the way that the algorithm has non-deterministic behavior
for small N t.
Figure 6: The number of total iterations plotted against the number of time
steps. The left figure shows the plots for low values of k. The right plot
shows larger values for k.
15
Figure 7: The same plot as Figure 5. The upper limit is set to 400 in order
to delete the noise
16
(c) The report should contain the images of the activator
u(x, y, t) and inhibitor v(x, y, t) at t = T, obtained with
the BENR Method for the same initial guess as the FE
Method
Figure 8: The solution of the BENR method. The Nt = 100 and k = 4. This
solution and the solution of the FE method with the same inital conditions
look the same.
17