0% found this document useful (0 votes)
69 views

Assignment6 Final

This document summarizes the discretization of a reaction-diffusion system of PDEs using the finite difference method on a uniform grid. It derives: 1) The matrix A for the discrete Laplacian operator with zero Neumann boundary conditions on a 9-point grid. 2) The matrices Dx and Dy to write A as A = Iy⊗Axx + Ayy⊗Ix using a tensor product. 3) The coupled system of ODEs obtained after spatial discretization as du/dt = -Du*A*u + f(u,v) and dv/dt = -Dv*A*v + g(u,v).

Uploaded by

Pythonraptor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views

Assignment6 Final

This document summarizes the discretization of a reaction-diffusion system of PDEs using the finite difference method on a uniform grid. It derives: 1) The matrix A for the discrete Laplacian operator with zero Neumann boundary conditions on a 9-point grid. 2) The matrices Dx and Dy to write A as A = Iy⊗Axx + Ayy⊗Ix using a tensor product. 3) The coupled system of ODEs obtained after spatial discretization as du/dt = -Du*A*u + f(u,v) and dv/dt = -Dv*A*v + g(u,v).

Uploaded by

Pythonraptor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Terrence Dahoe

4856198

Assignment 6
Numerical solution of a non-linear coupled
reaction-diffusion problem

Numerical Analysis For PDE’s (WI3730TU-2020/2021)

1. Discretize the problem in space on a doubly-uniform grid with


the Finite-Difference Method
(a) For a doubly-uniform grid on a rectangular domain and
lexicographic ordering of the unknowns, derive the sym-
metric matrix A of the negative 2D FD Laplacian with
zero Neumann BC0 s
The boundary conditions of this problem are stated as followed:

∂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) ∈ ∂Ω

In this example ∆u will be approximated. The same principle


holds for ∆v. The only difference is the symbol behind the LaPlace
operator.

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.

Figure 1: Illustration of the grid

The O (h2 ) approximation of the negative Laplacian operator in


two dimensions is defined by the following equation.

−ui−1,j + 2ui,j − ui+1,j −ui,j−1 + 2ui,j − ui,j+1


−∆ui,j = +
h2x h2y (4)
2 2
 
+ O hx + O hy

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.

Figure 2: The internal point

This equation doesn’t contain boundary points, so there is no need


to substitute elements from the equation.

u1,2 + u3,2 − 4u2,2 + u2,1 + u2,3


∆u2,2 = (7)
h2

3
Near-corner-points
There are four equations for the near-corner-points.

Figure 3: The near corner points

u0,1 + u2,1 − 4u1,1 + u1,0 + u1,2


∆u1,1 = (8)
h2
u1,1 − u0,1
= 0 → u1,1 = u0,1
h
u1,1 − u1,0
= 0 → u1,1 = u1,0
h

u2,1 − 2u1,1 + u1,2


∆u1,1 =
h2
u2,1 + u4,1 − 4u3,1 + u3,0 + u3,2
∆u3,1 = (9)
h2
u4,1 − u3,1
= 0 → u3,1 = u4,1
h
u3,0 − u3,1
= 0 → u3,1 = u3,0
h

u2,1 − 2u3,1 + u3,2


∆u3,1 =
h2

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

u2,3 − 2u3,3 + u3,2


∆u4,4 = (11)
h2
u0,3 + u2,3 − 4u1,3 + u1,2 + u1,4
∆u1,3 = (12)
h2
u1,3 − u0,3
= 0 → u1,3 = u0,3
h
u1,3 − u1,4
= 0 → u1,3 = u1,4
h

u2,3 − 2u1,3 + u1,2


∆u1,3 =
h2
Near-boundary-points
There are four equations for the near-boundary-points.

Figure 4: The near-boundary-points

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

u1,1 + u3,1 − 3u2,1 + u2,2


∆u2,1 =
h2
u2,2 + u4,2 − 4u3,2 + u3,1 + u3,3
∆u3,2 = (14)
h2
u4,2 − u3,2
= 0 → u3,2 = u4,2
h

u2,2 − 3u3,2 + u3,1 + u3,3


∆u3,2 =
h2
u1,3 + u3,3 − 4u2,3 + u2,2 + u2,4
∆u2,3 = (15)
h2
u2,4 − u2,3
= 0 → u2,3 = u2,1
h

u1,3 + u3,3 − 3u2,3 + u2,2


∆u2,3 =
h2
u0,2 + u2,2 − 4u1,2 + u1,1 + u1,3
∆u1,2 = (16)
h2
u1,2 − u0,2
= 0 → u1,2 = u0,2
h
u2,2 − 3u1,2 + u1,1 + u1,3
∆u1,2 =
h2

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:

Axx = DxT Dx , Ayy = DyT Dy


A = Iy ⊗ Axx + Ayy ⊗ Ix

The equations to approximate the backward first-order derivative


are:

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)

Give the explicit expression for the vector functions fu


and fv in terms of A, u, v, etc. Rewrite (6) as a single
system of ODE0 s

∂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

(a) Write down the iteration formula of the Forward-Euler


(FE) Method for the coupled systems (6) or for the single
system of ODE’s that you have derived.
 k+1  k  k
u d u u
=h· + (25)
v dt v v
(b) To derive an approximate stability condition, consider a
simpler linear problem: ∂u
∂t
= ∆u − ku, k > 0 With zero
Dirichlet BC’s. What is the FE Method’s stability con-
dition on the number of time sub-intervals Nt for this
problem?

∂u
= ∆u − ku, k>0 (26)
∂t

uk−1 − uk = ht −Auk − kuk




uk+1 = (ht (−A − k) + 1) uk

bj k+1 = (ht (−A − k) + 1) bj k

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:

wk+1 = hf (wk+1 ) + wk (30)


In order to find w the Newton-Raphson’s algorithm finds an ap-
proximation for w − wi .

w − wi ≈ pi (wi ) (31)

and iterates as follows:

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

Provide explicit expressions for all blocks of the matrix


J.

∂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:

(a) The report should explain your empirical choice of a sta-


ble Nt . For finding the stability regime it is recommended
to use the animation of the inhibitor v(x, y, t), similar to
the one of Assignment 5, and perform many tests with a
modest grid Nx = Ny = 25 and different values of k, e.g.
k = 2, 5, 10.
In order to find a stability bound an empirical based method is
used. The derived stability condition in 2b. is for a simplified
problem. Probably the stability bound for some complex problem
changes with k in a way that is not included in the approximation
of the stability bound from 2b.
In order to find a value for Nt that leads to stable behavior the
first try included the approximated bound. This was not stable
for all values of k between 0 and 10. The second try was to use
a value that is 5 per cent larger. The value NtFE = 1.05 x NtFE
is stable for all k between 1 and 10. This value will be used to
approximate the solution.

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.

Figure 5: The solution of the FE method. Nt = 52542 and k = 4.

5. Programming the Backward-Euler-Newton-Raphson (BENR)


Method. In the inner iterations of the BENR Method you will
have to work with the single-system formulation. To joint
the two vectors u and v into a single vector, you may use,
e.g., the numpy. concatenate () function. To construct the
sparse Jacobian matrix from its four blocks, you may use the
scipy.sparse.bmat() function. The tolerance of inner itera-
tions, i.e., the desired norm of the residual below which inner
iterations are stopped and the code proceeds to the next outer
iteration, may be set to 10−3 .

(a) The report should explain your empirical choice of Nt for


the BENR Method. It is recommended to let your code
print out the norm of the residual at each inner itera-
tion and observe the rate of convergence of the Newton-
Raphson iterations and its dependence on Nt . Investigate
the possible dependence on k as well.

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.

It is explainable that the convergence series start with a very high


number of inner iterations. The number of inner iterations de-
pends on two processes. A small Nt results in a large ht . There-
fore the initial guess for the Newton-Raphson algorithm is bad and
needs many iterations to converge. As Nt increases the stepsize
becomes smaller. The result is a better initial guess that needs
less iterations to converge, but because there are many steps the
total number of inner iterations will increase.
Figure 6 shows the same concept as figure 5. The difference is
here that the noise is reduced in order to show the shift from left

15
Figure 7: The same plot as Figure 5. The upper limit is set to 400 in order
to delete the noise

to right of the value of N t where quadratic convergence starts for


the different values of k.

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

You might also like