Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

2 DPoisson Heat Wave

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

Chapter 5

2-D Finite Difference

5.1 2-D Poisson’s equation


Solving Laplace’s (f = 0) or Poisson’s equation in 2-D:

Uxx + Uyy = f (5.1)

We discretise in x and y-directions:


yn+1 = b
yn

..
.

y3
y2
y1
y0
x0 x1 x2 x3 ... xm xm+1 = a

We discretise in x-direction with grid spacing: ∆x = a/(m + 1) and in


y-direction with grid spacing: ∆y = b/(n + 1), and let xk = k∆x where
0 ≤ k ≤ m + 1 and yj = j∆y where 0 ≤ j ≤ n + 1. We let Ukj = U (xk , yj )
and fkj = f (xk , yj ) We are solving equation (5.1) using Dirichlet boundary

34
conditions:

U (0, y) = U0,j = g0,j (yj )


U (a, y) = Um+1,j = gm+1,j (yj )
U (x, 0) = Uk,0 = gk,0 (xk )
U (x, b) = Uk,n+1 = gk,n+1 (xk )

Using central difference approximations for Uxx and Uyy then the finite dif-
ference approximations for equation (5.1) are given by:

∂ 2U Uk+1,j − 2Uk,j + Uk−1,j


2
= Uxx (xk , yj ) = ,
∂x ∆x2
∂ 2U Uk,j+1 − 2Uk,j + Uk,j−1
2
= Uyy (xk , yj ) = .
∂y ∆y 2

Our discretised PDE (equation 5.1) becomes (if ∆x = ∆y = h):

Uk+1,j − 2Uk,j + Uk−1,j Uk,j+1 − 2Uk,j + Uk,j−1


+ = fk,j ,
h2 h2
or Uk+1,j + Uk−1,j − 4Uk,j + Uk,j+1 + Uk,j−1 = h2 fk,j . (5.2)

Since we have Dirichlet boundary conditions: the outer boundaries of the


region we are solving for are known: U0,j , Um+1,j , Uk,0 , Uk,n+1 , and we need to
find the interior values: Uk,j for 1 ≤ k ≤ m and 1 ≤ j ≤ n.

For example: m = 3 and n = 3:

35
y4 = yn+1 = b

y3 ❤ ❤ ❤
U13 U23 U33

y2 ❤ ❤ ❤
U12 U22 U32

y1 ❤ ❤ ❤
U11 U21 U31

y0
x0 x1 x2 x3 x4 = xm+1 = a

Thus we need to solve for the interior values marked with a circle above
as the boundary values are already given. We let the vector of interior values
we are solving for be defined as:

 
U11

 U12 

 


U13 


 U21 

~ =
U

 U22 
, vector of interior values we are solving for.
 

 U23 


 U31 

 
 U32 
U33

~ using equation (5.2):


Thus the matrix system for U

36
Uk+1,j + Uk−1,j − 4Uk,j + Uk,j+1 + Uk,j−1 = h2 fk,j becomes:

 
k=1 −4 1 0 1 0 0 0 0 0  
U11
j=1 
 Uk,j Uk,j+1 Uk+1,j 
 
  
k=1  1 −4 1 0 1 0 0 0 0  
  U12 
j=2 
 Uk,j−1 Uk,j Uk,j+1 Uk+1,j 



  
k=1  0 1 −4 0 0 1 0 0 0  
  U13 
j=3 
 Uk,j−1 Uk,j Uk+1,j 



k=1 
 1 0 0 −4 1 0 1 0 0 



  U21 
j=1 
 Uk−1,j Uk,j Uk,j+1 Uk+1,j 



k=1 
 0 1 0 1 −4 1 0 1 0 



  U22 
j=2 
 Uk−1,j Uk,j−1 Uk,j Uk,j+1 Uk+1,j 



k=2  0 0 1 0 1 −4 0 0 1  



 U23 

j=3 

Uk−1,j Uk,j−1 Uk,j Uk+1,j 



k=2  0 0 0 1 0 0 −4 1 0  
  U31 
j=1 
 Uk−1,j Uk,j Uk,j+1 



  
k=3  0 0 0 0 1 0 1 −4 1  
  U32 
j=2 
 Uk−1,j Uk,j−1 Uk,j Uk,j+1 



  
k=3  0 0 0 0 0 1 0 1 −4 
U33
j=3 Uk−1,j Uk,j−1 Uk,j

 
U10 + U01  
f11

 Uk,j−1 + Uk−1,j 
  
   
 U02   
   f12 

 Uk−1,j 





   
 U14 + U03   
   f13 

 Uk,j+1 + Uk−1,j 






 U20 





   f21 

 Uk,j−1 






 0 


2


+   = h  f22 
   
   
 U24   





 f23 



Uk,j+1 





 U30 + U41   
   f31 

 Uk,j−1 + Uk+1,j 





   
 U42   
   f32 

 Uk+1,j 





   
 U34 + U43 
f33
Uk,j+1 + Uk+1,j

37
ie:
  
−4 1 0 1 0 0 0 0 0 U11

 1 −4 1 0 1 0 0 0 0 
 U12 

  


0 1 −4 0 0 1 0 0 0 

U13 


 1 0 0 −4 1 0 1 0 0 
 U21 

  
 0 1 0 1 −4 1 0 1 0  U22 
  

 0 0 1 0 1 −4 0 0 1 
 U23 


 0 0 0 1 0 0 −4 1 0 
 U31 

  
 0 0 0 0 1 0 1 −4 1  U32 
0 0 0 0 0 1 0 1 −4 U33

 
h2 f11 − g10 − g01

 h2 f12 − g02 

 2 


h f13 − g14 − g03 


 h2 f21 − g20 

=

 h2 f22 
,
 

 h2 f23 − g24 

2

 h f31 − g30 − g41 

 
 h2 f32 − g42 
h2 f33 − g34 − g43
or ~ = f~.
AU (5.3)

If m × n ≤ 100 then direct matrix elimination methods can be used. Oth-


erwise iterative methods such as Jacobi, Gauss-Seidel, relaxation methods
~ , as discussed in previous chapter 4. Because A
should be used to solve for U
is sparse and diagonally dominant, iterative solutions are ideal here.
However we see in the next section 5.2.1 that when we solve 2-D parabolic
equations (2-D heat or diffusion equations) that the numerical solution re-
quires ‘tweaking’ since the matrix A is no longer tridiagonal for 2-D as it was
for 1-D.

5.2 2-D Heat (or Diffusion) Equation


We consider the 2-D heat equation:

Ut = β(Uxx + Uyy ) for 0 ≤ x ≤ a, 0 ≤ y ≤ b and 0 ≤ t ≤ T.

with initial conditions: U (0, x, y) = f (x, y) and boundary conditions: U (t, x, y) =


g(t, x, y) for (x, y) on boundary.

38
• If we use explicit forward Euler scheme as we did for the 1-D heat
equation the stability criteria is even stricter than for 1-D:

∆x2 + ∆y 2
∆t ≤

→ this is less attractive because the time step is much smaller.

• if we use backward Euler or the Crank-Nicolson methods they are no


longer as attractive because the matrix systems to be solved are much
larger and no longer tridiagonal.

• We will look at an alternative finite difference method specifically tai-


lored to the 2-D heat equation: the alternating direction implicit (ADI)
method.

5.2.1 Alternating Direct/Implicit method for the 2-D


heat equation

Ut = β(Uxx + Uyy )

We let ∆t = T /m, ∆x = a/(n + 1), ∆y = b/(p + 1) tk = k∆t, 0 ≤ k ≤


m, xi = i∆x, 0 ≤ i ≤ n + 1, yj = j∆y, 0 ≤ j ≤ p + 1, and:

U (tk , xi , yj ) = Uijk

The time derivative, Ut , is approximated using a leap-frog step in time about


the mid-point tk+1/2 , where tk+1/2 = (tk + tk+1 )/2 using a time step of ∆t/2:
k+1/2
∂Uij Uijk+1 − Uijk−1
= at time tk+1/2 .
∂t ∆t
The spatial derivatives, Uxx and Uyy , are approximated using central differ-
ences:

∂ 2 Uijk k
Ui+1,j − 2Uijk + Ui−1,j
k
= at time tk ,
∂x2 | ∆x
{z
2
}
EARLY STEP
∂ 2 Uijk+1 k+1
Ui,j+1 − 2Uijk+1 + Ui,j−1
k+1
= at time tk+1 .
∂y 2 ∆y 2

39
This introduces an ‘early’ bias which evaluates Uxx (tk ) at an earlier time
than Uyy (tk+1 ). This bias is compensated by also evaluating Uxx (tk+2 ) at
tk+2 ; Uyy (tk+1 ) again at tk+1 and Ut (tk+3/2 ) at mid-point between tk+1 and
tk+2 :
k+3/2
∂Uij Uijk+2 − Uijk+1
= ,
∂t ∆t
∂ 2 Uijk+2 k+2
Ui+1,j − 2Uijk+2 + Ui−1,j
k+2
=
∂x2 | ∆x{z
2
}
LATE STEP
∂ 2 Uijk+1
and as before.
∂y 2
k k
The boundary conditions specify Uoj , Um+1,j , Uiok , Ui,p+1
k
, and initial condi-
0
tions specify Uij . So we are solving for 1 ≤ k ≤ m, 1 ≤ i ≤ m, 1 ≤ j ≤ p.
ie. for each interior point at time tk .
We solve the problem for both time steps tk+1 and tk+2 at the same time
using early and late definitions. If we let sx = β∆t/∆x2 , sy = β∆t/∆y 2
then Ut = β(Uxx + Uyy ) becomes:
Early step:

Uijk+1 (1 + 2sy ) − sy [Ui,j+1


k+1 k+1
+ Ui,j−1 ] = Uijk (1 − 2sx ) + sx [Ui+1,j
k k
+ Ui−1,j ]

This is solved first for ith row of U k+1 matrix, for 1 ≤ i ≤ n.

Late step:

Uijk+2 (1 + 2sx ) − sx [Ui+1,j


k+2 k+2
+ Ui−1,j ] = Uijk+1 (1 − 2sy ) + sy [Ui,j+1
k+1 k+1
+ Ui,j−1 ]

This is solved for j th column of U k+2 matrix, for 1 ≤ j ≤ p.


These are solved using LU decomposition. (For more details see Schilling
and Harris, p. 445).

5.3 Cylindrical and spherical polar co-ordinates


• Spherical and cylindrical symmetry in problems are often exploited to
reduce 2-D → 1-D or 3-D → 1-D.

3-D Cylindrical Co-ordinates


x = r cos θ
y = r sin θ

40
Initial condition for plucked string
250

200

150
U

100

50

0
0 5 10 15 20 25 30 35 40 45 50
x

Figure 8.3: Initial conditions in (a) and matlab solution using explicit central
difference method for 1D wave equation with friction in (b)

8.2 2-D Wave Equation

Utt = β(Uxx + Uyy ), 0 ≤ x ≤ a, 0 ≤ y ≤ b, 0 ≤ t ≤ T

8.2.1 Example: vibrations of a thin elastic membrane


fixed at its walls
We discretise in x and y-directions:
yp+1 = b
yp

..
.

y3
y2
y1
y0
x0 x1 x2 x3 ... xn xn+1 = a

T a b
We discretise: ∆t = m , ∆x = n+1 , ∆y = p+1 , tk = k∆t, xi = i∆x, yj =
j∆y0 ≤ k ≤ m, 0 ≤ i ≤ n + 1, 0 ≤ j ≤ p + 1, and let Uijk = U (tk , xi , yj )

68
Suppose we solve for n = 3 and p = 3 and have Dirichlet boundary
conditions:
k k k
U (0, y, t) = 0 = Uoj , U (a, y, t) = 0 = Un+1,j = U4j , U (x, 0, t) = 0 =
k k k
Ui0 , U (x, b, t) = 0 = Ui,p+1 = Ui4
and initial conditions:
U (x, y, 0) = f (x, y) = fij Ut (x, y, 0) = g(x, y) = gij .
Since we have Dirichlet boundary conditions: the outer boundaries of the
k k k k
region we are solving for are known: U0,j , Un+1,j , Ui,0 , Ui,p+1 , and we need to
k
find the interior values: Ui,j for 1 ≤ i ≤ n and 1 ≤ j ≤ p.
y4 = yp+1 = b

y3 ❤ ❤ ❤
U13 U23 U33

y2 ❤ ❤ ❤
U12 U22 U32

y1 ❤ ❤ ❤
U11 U21 U31

y0
x0 x1 x2 x3 x4 = xn+1 = a

We will use the 2-D Central Difference Method

Uijk+1 − 2Uijk + Uijk−1


Utt = ,
∆t2
k
Ui+1,j − 2Uijk + Ui−1,j
k
Uxx = ,
∆x2
k
Ui,j+1 − 2Uijk + Ui,j+1
k
Uyy =
∆y 2

β∆t2 β∆t2
We let sx = ∆x2
, sy = ∆y 2
and substitute the central difference approx-

69
imations into our PDE, Utt = β(Uxx + Uyy ) we solve for Uijk+1 :

Uijk+1 = 2Uijk (1 − sx − sy ) − Uijk−1 + sx (Ui+1,j


k k
+ Ui−1,j k
) + sy (Ui,j+1 k
+ Ui,j−1 )

computing U ~ k and U
~ k+1 uses the solution at U ~ k−1 .
1 0 −1
For first time step Uij needs Uij and Uij . Again we need to use the initial
conditions to find the ghost point, Uij−1 :

∂Uij0 U 1 − Uij−1
= Ut (x, y, 0) = ij = g(xi , yj ) = gij ⇒ Uij−1 = Uij1 − 2∆tgij
∂t 2∆t
Solution at first time step k = 1:
sx 0 sy 0
Uij1 = Uij0 (1 − sx − sy ) + ∆tgij + (U 0
+ Ui−1,j ) + (Ui,j+1 0
+ Ui,j−1 )
2 i+1,j 2
 k 
U11
 Uk 
 12 
 k 
 U13 
 
 Uk 
 21 
~k = 
If we let U  U22k 

 k 
 U 
 23 
 Uk 
 31 
 k 
 U32 
k
U33
then for time steps, k > 1, the solution is:

Uijk+1 = 2Uijk (1 − sx − sy ) − Uijk−1 + sx (Ui+1,j


k k
+ Ui−1,j k
) + sy (Ui,j+1 k
+ Ui,j−1 )

and we can write this in vector form:

U ~ k + ~b − U
~ k+1 = AU ~ k−1

where:
 
λ sy 0 sx 0 0 0 0 0
 s
 y λ sy 0 sx 0 0 0 0  
 
 0 sy λ 0 0 sx 0 0 0 
 
 s
 x 0 0 λ sy 0 s x 0 0 

A =  0 sx 0 sy λ sy 0 s x 0 
 
 0 0 sx 0 sy λ 0 0 sx 
 
 0 0 0 sx 0 0 λ sy 0 
 
 
 0 0 0 0 s x 0 sy λ sy 
0 0 0 0 0 sx 0 sy λ
and λ = 2(1 − sx − sy )

70
 k k 
sx U01 + sy U10
k

 sx U02 

 k k 


sx U03 + sy U14 

k

 sy U20 

 
b =  0 
 k


 sy U24 

k k

 sx U41 + sy U30 

 k 
 sx U42 
k
sx U43 + sy sk34

8.2.2 Examples of wave equation


1. Elastic wave propagation through rocks in 1-D

σxx,x = ρUtt (8.1)

where

σxx = Eεxx , σxx = stress, εxx = strain


∂U
= E
∂x

E
8.1 ⇒ EUxx = ρUtt or Utt = Uxx
ρ
q
E
elastic waves propagate with speed ρ

2. Electromagnetic Wave Equation

c2 ∇2 E = Ë and c2 ∇2 B = B̈ (8.2)

From Maxwell’s equations where E is electric field, B is magnetic field.


Derived using:
ρ ∂B
∇·E = , ∇×E =− (8.3)
ǫ0 ∂t

∂E
∇ · B = 0, ∇ × B = µ0 ε 0 (8.4)
∂t
taking curl of 8.3 and ~ ~ 2~
 8.4 and using ∇ × (∇ × V ) = ∇(∇ · V ) − ∇ V
and ∇(∇ · E) = ∇ ǫρ0 = 0, ∇(∇ · B) = 0 gives Equation 8.2 where
q
1
c= µ0 ε 0
= 3 × 108 m/s.

71
3. Schrödinger’s Wave Equation
∂Ψ
ih̄ = HΨ
∂t
• for a wavefunction Ψ of a quantum system defined by Hamiltonian,
H.
2 2
eg. H = KE + P E = − h̄2m ∇
+ V (r)
R∞
• numerical solutions also need to satisfy −∞ |Ψ(x)|2dx = 1

72

You might also like