Post on 11-Aug-2020
Lecture 618.086
Info• Project proposals…!
4
Schär, ETH Zürich
t
n+1!
n!
n-1!
n-2!
x i-3! i-2! i-1! i! i+1! i+2! i+3!
CFL criterion for Leapfrog scheme
numerical domain of dependence
physical domain of dependence
!"!t
+ u !"!x
= 0Equation:
!in+1 = !i
n–1 –" !i+1n #!i–1
n( ) with " = u$t$x
Scheme:
stable |uΔt/Δx| ≤ 1
unstable |uΔt/Δx| > 1
Leapfrog scheme• Easiest numerical scheme for 2nd order problem: Leapfrog
Notation:
Uj,n+1 � 2Uj,n + Uj,n�1
�t
2= c
2Uj+1,n � 2Uj,n + Uj�1,n
�x
2
Uj,n = U(j�x, n�t)
• Stability: |r| ≤ 1 (equiv. CFL condition!)
• Accuracy: 2nd order
Lecture
Lecture / see Mathematica notebook leapfrog_stability.nb
c
c
Accuracy of FD schemes: Alternative way (using modified equations)
• Approach is general and gives GLOBAL error directly (not local error)
Uj,n+1 � 2Uj,n + Uj,n�1
�t
2= c
2Uj+1,n � 2Uj,n + Uj�1,n
�x
2
• Using wave equation and leapfrog as an example:
• Plug in analytical u and expand in Taylor on LHS and RHS of FD equation E.g.:uj,n+1 = u(x, t) + u
x
(x, t)�t+1
2utt
(x, t)�t2 +O(�t3)
• Simplifying LHS and RHS givesu
tt
+1
12�t
2u
tttt
+ . . . = c
2(uxx
+1
12�x
2u
xxxx
+ . . .)
• Note that , so the global error isutttt
= c2uttxx
= c4uxxxx
1
12
⇥�t
2c
4 ��x
2⇤u
xxxx
=> p=2 in time and space
Staggered grids• Remember:• Equivalent 1st order problem: @
@t
✓v1
v2
◆=
✓0 c
c 0
◆@
@x
✓v1
v2
◆
with v1 = ut
, v2 = cux
• There are a number of “physical” wave equations that are of this form, most importantly the Maxwell equations of electrodynamics (in vacuum):
Leads to a 1st order system as above!
We could try this….• Discretize 1st order problem:
with 1st order “leapfrog”
This would give us 2nd order accuracy, because we use two centered differences for space and time in leapfrog!
@
@t
✓v
w
◆=
✓0 c
c 0
◆@
@x
✓v
w
◆
Vj,n+1 � Vj,n
2�t
= c
Wj+1,n �Wj�1,n
2�x
Wj,n+1 �Wj,n
2�t
= c
Vj+1,n � Vj�1,n
2�x
• 1way wave eqleapfrog:
Uj,n+1 � Uj,n
2�t
= c
Uj+1,n � Uj�1,n
2�x
• Here:
Lecture: interesting numerical “dispersion”!
• 1-way wave eq. leapfrog: dispersion-free |G|=1 for all k, as long as CFL condition r<=1
correct typo in one-way LF scheme!
1way-Leapfrog• “Coupled” equations decouple in current leapfrog formulation!
Diffusion and Advection (6.5)• The heat equation is another famous PDE
ut
= Duxx
u(x, t) =1p4⇡Dt
e
�x
2
4Dt
• Solution to IV u(x,0) = δ(x) is given by:
• D is the diffusion constant (units length^2/time)
• Growth factor: G(k, t) = e�Dk2t
Numerical scheme (FD)• Heat equation is dissipative, so why not try Forward Euler:
Uj,n+1 � Uj,n
�t
=Uj+1,n � 2Uj,n + Uj�1,n
�x
2
• Expected accuracy: O(Δt) in time, O(Δx2) in space.
• Stability in the usual way gives
• We can use previous ODE methods using the old method of lines, of course…
• Or implicit methods (see book, 6.5). Notice that matrix contains O(Δx-2
) terms and is stiff!
R =�t
�x
2 1
2
Incorporating boundary conditions into FD matrices
• Writing the heat equation using method of lines (with centered differences in x), we have
~ut = A~u• Away from boundaries, Ai = (0, . . . ,�1, 2,�1, 0, . . . , 0)
position j=i
• Boundary conditions determine values of A near boundaries, e.g.0
BBBBBB@
0 0 0 0 0 0�1 2 �1 0 0 00 �1 2 �1 0 00 0 �1 2 �1 00 0 0 �1 2 �10 0 0 0 0 0
1
CCCCCCA
0
BBBBBB@
u0
u1
u3
. . .uN�1
uN
1
CCCCCCA
BCs:u(0,t)=v1 u(X,t)=v2
see book, 1.2