16.elliptic PDE
16.elliptic PDE
12/22/2015
Recall in the first lecture of this course ….
Assume…
• you know how to use a computer to compute;
• but have not done any serious numerical computations,
• and only know some very basic numerics.
+ + =0 ⋅ =0
momentum conservation:
1 1
=− − − − + + + =− ⋅ − +
1 =− − ( )
=− − − − + + +
1
=− − − − + + +
−
=− − ( ) ≈ = ≈− − ( )
Δ
i.e., after obtaining and at , marching towards to get
−
⋅ ≈− − ( )
Δ
• Take divergence of the time-discretized momentum equation:
− ⋅ − ⋅
⋅ ≈− − ⟹ ≈− ⋅ − ⋅ ( )
Δ Δ
• But due to numerical approximation, the solenoidal condition may not be satisfied exactly.
Let say, there is a small value of ⋅ at = .
+ + = , ,
• One-dimensional: =
=0 1 2 −1
= =
0 =
1
=
• Two-dimensional:
−1
, = , = ,
=
1 1 2
, = , 1
=0
=0 1 2 −1
=
Numerical Solution of Poisson Equation
+ = ,
= , ⟹ , = ( , )
=
, = ̂ , + = ,
= 0, 1, 2, … , −1 = 0, 1, 2, … , −1 −1
=
Similarly,
2
, = , 1
=0
=0 1 2 −1
=
, = ̂ , , = ,
2 2
̂ , + ̂ , = ,
2 2
− ̂ , − ̂ , = , = , =
,
⟹ ̂ , =−
+
• This is because the solution of the Poisson equation subject to periodic boundary conditions in
both direction is indeterminant,
i.e. any constant, , = , can be the solution.
+ = ,
periodic periodic
=0 1 2 −1
= given
= − ̂
= , = ̂ ⟹
̂
=
Similarly,
= , =
• Substitute the expansions of , and , into the Poisson equation:
̂ 2
− ̂ + = =
̂
⇒ − ̂ =
• This is an ordinary differential equation for ̂ subject to the upper and lower boundary conditions
of Dirichlet type for different .
• If 2nd-order finite-difference scheme is used to approximate the differentiation of :
̂ = given = ̂ , given
̂ = ̂ ,
̂ +1
̂ , −2 ̂ , + ̂ ,
− ̂ = − ̂ , = ,
−1 △
2
∆= =
̂ = 0 given =0 ̂ , given
Discretized equation for ̂ = ̂ : ̂ , −2 ̂ , + ̂ ,
, − ̂ , = ,
△
known
−1 ̂ , − 2+ ∆ ̂ , + ̂ , =△ ,
−2
+1
̂ , − 2+ ∆ ̂ , + ̂ , =△ ,
−1
2
1 ̂ − 2+ ∆ ̂ + ̂ =△
, , , ,
=0 known
− 2+ ∆ 1 , △ , − ,
, ⋮
⋮ ⋮
− 2+ ∆ 1 △ ,
1 ,
1 − 2+ ∆ 1 , = △ ,
1 − 2+ ∆ 1 , △ ,
⋮ ⋮
, ⋮
1 − 2+ ∆ , △ , − ,
The ( − 1)× − 1 matrix is a tridiagonal, and can be solved efficiently for various .
Only need to consider = 0 to /2 for real DFT.
Homework 18
■ Write a subroutine solving Poisson equation in a rectangular domain with periodic boundary
conditions in direction and Dirichlet conditions on the other two boundaries.
■ Use routine in Lapack to solve the tridiagonal system of linear equation. Use FFFTW to do
discrete Fourier transform. Use random numbers between −1 and 1.
■ In calling the subroutine, the following data are input :
• the length and width of the rectangular domain and
• the numbers of discrete grids and
• the source function , , = 0 ~ ( − 1), = 1 ~ ( − 1)
• the boundary value on the bottom and top , and , , = 0 ~ ( − 1)
■ Write a test driver (use the second approach in the following) to assess the maximum error
calling the subroutine to confirm if the Poisson solver has been implemented correctly.
given
( − 1)
periodic in periodic in
+ = ,
2
1
=0
=0 1 2 ( −1)
given
Two approaches to test the Poisson solver
The first approach:
• Invent a known analytical function , and compute ANALYTICALLY the right-hand-side
source function of the Poisson equation ( , ) and the boundary conditions:
′ ′
, = +
,0 = ′ ,0
, = ′ ,
• Given the analytical source function , and the boundary conditions , and , , the Poisson
equation is then solved for , , and the numerical solution is compared with the known
function , .
−1
+ ≈ , =
, ,
2
1
=0
=0 1 2 −1
=
• Such an approach can be used to test the convergence of the solver by increase the grid points.
The second approach:
• Generating the solutions , and the boundary conditions , and , using random numbers.
• The source function is then computed numerically using spectral scheme in the periodic direction
and finite-difference scheme in the other direction.
′ ′ −1
, = +
, ,
=
spectral finite
scheme difference 2
1
, = , , = , =0
=0 1 2 −1
=
• Given the source function , and the boundary conditions , , , , the Poisson equation is
then solved numerically.
+ = ,
, ,
• The numerical results , should be equal to the original given random numbers , since the
forward (computing the source function) and inverse (solving the equation) operators are identical.