Pierson Guthrey 12 f (t)

advertisement
Pierson Guthrey
pguthrey@iastate.edu
12
Asymptotic Behavior f (t) is amyptotic to t means the following:
f (t) ∼ t2 as t → 0 means t−2 f (t) → 0 as t → 0
Equivalently, we write f (t) = t2 + o(t2 ). Also, it could be the case:
f (t) = O(t2 ) means t−2 f (t) is bounded as t → 0
1
Floating Point Arithmetic
A Floating Point Number System is a finite subset of the reals defined by F(b, K, m, M ) where b is the
base of the system, K is the number of digits, m is the smallest exponent representable and M is the
largest exponent representable.
If y ∈ F(b, K, m, M ), then
y = ± (0.d1 d2 d3 ....dK )b × bE , m ≤ M, d1 6= 0 ⇐⇒ y = 0
1.1
Round-off Error
The error in representing z ∈ R by its nearest element in F(b, K, m, M ). If z ∈ R, then
(
±(0.d1 d2 ...dK )b × bE
dk+1 < 2b
f l(z) =
−K
E
± (0.d1 d2 ...dK )b + b
×b
dk+1 ≥ 2b
IEEE Double precision (Used in MATLAB) is b = 2 and K = 52. In base 10, this is approximately K ≈ 16,
m ≈ −308, and M ≈ 308.
1.2
Relative error in rounding
Let y ∈ R, y 6= 0. f l(y) ∈ F(b, K, m, M ). Assume dk+1 ≤
b
2
|f l(y)| = (0.d1 d2 ...dK )b × bE
The Relative error is
Rel error:
|y − f l(y)|
|y|
Since |y| = (0.d1 d2 ...dk dk+1 ...)b × bE ≥ (0.1)b × bE = bE−1
and |y − f l(y)| = (0.dk+1dk+2 ....b × bE−k ≤ 12 bE−k thus
Rel error:
|y − f l(y)|
1
≤ b1−K =machine
|y|
2
This Machine Epsilon is the smallest representable number In IEEE DP, b = 2, and K = 52, so
2−52 ≈ 2.2204 × 10−16
1
machine
=
Pierson Guthrey
pguthrey@iastate.edu
1.3
in Computation
1.3 Error
Error
in Computation
1.3.1
Finite Difference Operators
Recall
1
1
(f (x − h) − 2f (x) + f (x + h)) = − h2 f (4) (ξ)
2
h
12
Assume the round off error e(x − h) is in the evaluation of function values f (x − h) = f˜(x − h) + e(x − h).
1
1
1 f 00 (x) − 2 f˜(x − h) − 2f˜(x) + f˜(x + h) = Eh = − h2 f (4) (ξ) + 2 (e(x − h) − 2e(x) + e(x + h))
h
12
h
1
1 2 (4) |Eh | ≤
h f (ξ) + 2 (|e(x − h)| + |2e(x)| + |e(x + h)|)
12
h
Assume f (4) (ξ) ≤ M for ξ ∈ [x − h, x + h] and assume |e(x)| ≤ for x ∈ [x − h, x + h].
f 00 (x) −
|Eh | ≤
1 2
1
h M + 24
12
h
The first term shrinks but the second term blows up as h → 0. One hopes to find the minimum at
41
48
hoptimal =
M
We could take to be machine
2
2.1
Polynomial Approximations
Taylor Expansion Theorem
The Taylor series expansion for a function f centered at α evaluated at z is
f (z) =
∞
X
ak (z − α)k
where ak =
f (k) (α)
k!
where ak =
f (k) (α)
k!
k=0
A Taylor polynomial is any finite truncation of this series:
f (z) =
N
X
ak (z − α)k
k=0
The Taylor series is the limit of the Taylor Polynomials, given that the limit exists.
Analytic Functions A function that is equal to its Taylor Series in an open interval (or open disc in the
complex plane), is known as an Analytic Function
Maclaurin Series If the Taylor series or Polynomial is centered at the origin (α = 0), then it is also a
MacLaurin series.
2.1.1
Important Taylor Series
The Maclaurin series for (x − 1)−1 is
(x − 1)−1 = 1 + x + x2 + x3 + ... =
∞
X
k=0
2
xk
3
Numerical Linear Algebra
4
Solving Ax = b
4.1
Pierson Guthrey
pguthrey@iastate.edu
Tridiagonal Solver
For a tridiagonal system of equations
A~u = ~f ,
A tridiagonal
take b1 = cn = 0 and

a1
 b2

A = LU = 

c1
a2
..
.

c2
..
.
bn


1
  β2
 
=
.. 
.  
an
1
..
.




..
.
βn
1
So to solve LU ~u = ~f
1. Solve L~v = ~f using Forward Substitution
2. Solve U ~u = ~v using Backward Substitution
4.1.1
Pseudocode
INPUT: ~a, ~b,~c,~f , all length n LU decomposition:
α1 = a1
for k = 2 to n
βk = bk \ αk−1
αk = ak − βk ck−1
end
Forward Substitution:
v1 = f 1
for k = 2 to n
vk = fk − βk vk−1
end
Backward Substitution:
un = vn \ αn
for k = 2 to n
j = (n + 1) − k
uj = (vj − cj uj+1 ) \ αj
end
Operation count: O(n)
4.2
Spectral Decomposition Method
If A ∈ Cm×m is Hermitian, we can do the following
1. Compute the spectral decomposition (not trivial when m is large)
A = U DU ∗
3
α1
c1
α2

c2
..
.


.. 
. 
αn
Pierson Guthrey
pguthrey@iastate.edu
2. Reform equation
A~x = U DU ∗~x = ~b
So we see
~x = α1 ~u1 + α2 ~u2 + ... + αm ~um =⇒ U ∗~x = ~α
and
~b = β1 ~u1 + β2 ~u2 + ... + βm ~um =⇒ βk = ~u∗ ~b
k
so
U ∗ ~b = ~β and D~α = ~β =⇒ ~α = D−1 ~β
−1
but since Dii
=
1
λi ,
m
X
~u∗ ~b
αk = k =⇒ ~x =
λk
k=1
5
~u∗k ~b
λk
!
~uk
Finite Differences
Finite Differences seeks to approximate an ODE or PDE over a mesh or grid. The steps involved are:
1. Discretize the PDE using a difference scheme.
2. Solve the discretized PDE by iterating and/or time stepping.
5.1
5.1.1
Meshes
Uniform Meshes
Given a closed domain Ω = R̄ × [0, tF ], we divide it into a (J + 1) × (N + 1) grid of parallel lines. Assume
R̄ = [0, 1]. Given the mesh sizes ∆x = J1 , ∆t = N1 , a mesh point is
(xj , tn ) = (j∆x, n∆t)
j = 0, ..., J
n = 0, ..., N
and x0 = 0, xn = 1
An alternative convention uses a (J + 2) × (N + 2) grid with the mesh sizes ∆x =
xn+1 = 1 are the boundary points. and
(xj , tn ) = (j∆x, n∆t)
j = 0, ..., J + 1
1
J+1 , ∆t
=
1
N +1 .
n = 0, ..., N + 1
We seek approximations to the solution at these mesh points, denoted by
Ujn ≈ u(xj , tn )
Where initial values are exact from the initial value function u0 (x, t) = u(x, 0)
Uj0 = u0 (xj )
j = 1, ..., J − 1
and boundary values are exact from the boundary value functions f (t) = u(0, t) and g(t) = u(1, t)
U0n = f (tn )
5.2
UJn = g(tn )
Difference Coefficients
D+ , D−
4
n = 1, 2, ...,
x0 = 0,
Pierson Guthrey
pguthrey@iastate.edu
5.3
Scheme
5.3 Explicit
Explicit
Scheme
A scheme is explicit if the solution at the next iteration (time level tn+1 ) can be written as a single equation
involving only previous time steps. This is, if it can be written in the form
XX
Ujn+1 =
ai,k Uik + bi,k fik
i
k≤n
Example For the Heat Equation ut = uxx , using a forward difference in time and a centered difference in
space, we get
n
n
Ujn+1 = Ujn + µ(Uj+1
− 2Ujn + Uj−1
)
µ :=
∆t
(∆x)2
Pseudocode :
At n = 0, Uj0 = u0 (xj , 0)
for n = 1 : N
U0n = 0, UJn = 0
for j = 1 : (J − 1)
n
n
Ujn+1 = Ujn + µ(Uj+1
− 2Ujn + Uj−1
)
end
end
The stability of the problem depends on µ.
5.4
Truncation Error
Example For our model problem (the Heat Equation), the trucation error is
T (x, t) :=
D+t u(x, t) Dx2 u(x, t)
−
∆t
(∆x)2
So we see that since ut − uxx = 0,
1
1
1
1
2
2
utt ∆t − uxxxx (∆x) + ... =
utt ∆t − uxxxx (∆x) + ...
T (x, t) = (ut − uxx ) +
2
12
2
12
If we truncate this Infinite Taylor series using η ∈ (t, t + t∆t) and ξ ∈ (x − ∆x, x + ∆x) and assume the
boundry and initial data are consistent at the corners and are both sufficientl smooth, we can then estimate
|utt (x, η)| ≤ Mtt and |uxxxx (ξ, n)| ≤ Mxxxx , so it follows that
1
1
|T (x, t)| ≤ ∆t Mtt −
Mxxxx
2
6µ
We can assume these bounds will hold uniformly over the domain. We see that
|T (x, t)| → 0 as ∆t, ∆x → 0 ∀ (x, t) ∈ Ω
and this result is independent of any relaton between the two mesh sizes. Thus this scheme is unconditionally consistent with the differential equation.
Since |T (x, t)| will behave asymptotically like O(∆t) as ∆t → 0, this scheme is said to have first order
accuracy
Since ut = uxx , utt = uxxxx and so for µ = 61 ,
1
1
T (x, t) = ∆t utt −
uxxxx + O (∆t)2 = O (∆t)2
2
6µ
and so the scheme is second order accurate for µ =
We can define notation: Tjn = T (xj , tn )
5
1
6
Pierson Guthrey
pguthrey@iastate.edu
5.5
5.5 Consistency
Consistency
Does the difference scheme approximate the PDE as ∆x, ∆t → 0?
A scheme is consistent if
T (x, t) → 0 as ∆x, ∆t → 0
• A scheme is unconditionally consistent if the scheme is consistent for any relationship between ∆x
and ∆t
• A scheme is conditionally consistent if the scheme is consistent only for certain relationships between ∆x and ∆t
5.6
Accuracy
a
c
Take µ finite, so (∆t) b = µ(∆x) d , so (∆t)α = (∆t)ad = µbd (∆x)cb and we have
|T (x, t)| = O(∆tα )
• If α = 1, the scheme is first order accurate.
• If α = 2, the scheme is second order accurate.
• etc...
• The scheme is α-order accurate.
5.7
Convergence
A scheme is convergent if as ∆t, ∆x → 0 for any fixed point (x∗ , t∗ ) in the domain,
xj → x∗ , tn → t∗ =⇒ Ujn → u(x∗ , t∗ )
It suffices to show this for mesh points for sufficiently refined meshes, as convergence at all other points will
follow from continuity of u(x, t). We suppose that we can find a bound for the error T̄ :
n
Tj ≤ T̄ < ∞
We denote the error
enj := Ujn − u(xj , tn )
Taking the difference between the scheme and u(xj , tn+1 ) in terms the truncation error and the exact solution at previous time steps yields the error at en+1
. If the RHS of our difference scheme is represented by
j
D, then
en+1
= DUjn − (Du(xj , tn ) + T (xj , tn )∆t) = Denj − Tjn ∆t
j
Choose µ such that the coefficients of the RHS are positive so that you may estimate E n := max enj , j = 0, ..., J
and so
E n+1 ≤ E n + T̄ ∆t s.t. E 0 = 0
and thus
E n ≤ nT̄ ∆t
n = 0, 1, 2, ...
and considering the domain
E n ≤ T̄ tF
n = 0, 1, 2, ..., N
and since T̄ → 0 as ∆t, dx → 0, E n → 0
6
Pierson Guthrey
pguthrey@iastate.edu
5.8
Error: IfFourier
Analysis
Example
we replace
Ujn with u(xj , tn ) in the definition of Tjn we obtain
en+1
= enj + µDx2 enj − Tjn ∆t
j
which is
en+1
= (1 − 2µ)enj + µenj+1 + µenj−1 − Tjn ∆t
j
For µ ≤ 21 , define E n := max enj , j = 0, ..., J and so
n+1 e
≤ E n + T̄ ∆t =⇒ E n+1 ≤ E n + T̄ ∆t
j
Since E 0 = 0 (the initial values are exact), we have
1
1
E n ≤ nT̄ ∆t = ∆t Mtt −
Mxxxx tF → 0 as t → 0
2
6µ
5.7.1
Refinement Path
A refinement path is a sequence of pairs of mesh sizes each which tends to zero
refinement path := {((∆x)i , (∆t)i ), i = 0, 1, 2, ...; (∆x)i , (∆t)i → 0}
We can specify particular paths by requiring certain relationships between the mesh sizes.
Examples
(∆t)i ∼ (∆x)i or (∆t)i ∼ (∆x)2i
(∆t)i
Theorem For the heat equation, µi = (∆x)
2 and if µi ≤
i
the positive numbers ni , ji are such that
1
2
∀ i and if for all sufficiently large values of i and
ni (∆t)i → t > 0, ji (∆x)i → x ∈ [0, 1]
and if |uxxxx | ≤ Mxxxx uniformly on Ω, then the approximations Ujnii generated by the explicit scheme for
i = 0, 1, ... converge to the solution u(x, t) of the differential equation uniformly in the region.
This means that arbitrarily good accuracy can be attained by use of a sufficiently fine mesh.
5.8
Error: Fourier Analysis
Let
Ujn = (λ)n eik(j∆x)
where λ(k) is known as the amplification factor of the Fourier Node Ujn . Place this into the difference
equation of your scheme and solve for λ. We then have another numerical approximation
Ujn
=
∞
X
Am e−imπ(j∆x) (λ(k))
n
−∞
which can be compared to the Fourier expansion approximating the exact solution.
n
n
Example For Ujn = Ujn + µ(Uj+1
− 2Ujn + Uj−1
), we see
λ(k) = 1 + µ(e
ik∆x
−2+e
−ik∆x
2
) = 1 − 4µ sin
1
k∆x
2
So now
e
−k2 ∆t
1 4
1 4
(∆t)2
∆t(∆x)2
2
2
2
2
−λ(k) = 1 − k ∆t + k ∆t(∆t) − ... − 1 − k ∆t + k ∆t(∆x) − ... =
−
k 4 −...
2
12
2
12
Thus we have first order accuracy in general but second order accuracy if (∆x)2 = 6∆t.
7
Pierson Guthrey
pguthrey@iastate.edu
5.9
5.9 Stability
Stability
A scheme is stable if there exists a constant K such that
n
|(λ)| ≤ K,
n∆t ≤ tF , ∀ k
That is, if the difference in the solutions of the DE and the numerical DE is bounded uniformly in the domain
for any amount of time less than tF . Thus
|λ(k)| ≤ 1 + K 0 ∆t
This is necessary and sufficient.
5.10
Implicit Scheme
If the scheme cannot be written in a form that has Ujn+1 explicitly computed given values Ujn , j = 0, 1, ..., J,
it is implicit. Implicit schemes involve more work but often have higher accuracy and/or stability, and thus
much larger time steps allow us to reach the solution much more quickly.
Example
n+1
n+1
Ujn+1 − Ujn
Uj+1
− 2Ujn+1 + Uj−1
=
∆t
(∆x)2
which can be written as
∆−t Ujn+1 = µδx2 Ujn+1
µ=
∆t
(∆x)2
This involves solving a system of linear equations. However, Fourier analysis for the stability shows
λ=
1
1 + 4 sin2
1
2 k∆t
Since λ < 1 for any positive µ, this scheme is unconditionally stable
5.11
Other Conditions
If an equation obeys extra conditions such as a Maximum Principle, uniqueness condition, or a physical
constraint, the numerical scheme must also obey such conditions else it may not converge.
6
6.1
Methods
Weighted Average θ method
Given two schemes, you can weight one θ and the other with (1 − θ) and add them together. Then stability,
covergence, and accuracy may depend on θ, and it can be chosen to
Example For the explicit and implicit first order accurate schemes for the heat equation are averaged, we
have
Ujn+1 − U n = µ θδx2 Ujn+1 + (1 − θ)δx2 Ujn
θ = 0 yields the explicit scheme and θ = 1 yields the implicit scheme.
8
7
Pierson Guthrey
pguthrey@iastate.edu
General Boundary Conditions
Boundary conditions like
ux = α(t)u + g(t)
x=0
Can be handled like
U1n − U n )0
= αn U0n + g n =⇒ U0n = β n U1n − β n g n ∆t
∆x
βn =
1
1 + αn ∆x
Dirichlet conditions are trivial
u(0, t) = 0 =⇒ U0n = 0
Dx2 yi = D+ D− yi =
1
(yi+1 − 2yi + yi−1 )
h2
1
1
1
yi±1 = yi ± hyi0 + h2 yi00 ± h3 yi000 + h4 yi0000 ...
2
6
24
Dx2 yi
1
= 2
h
yi +
hyi0
1 4 0000
1 3 000
1 4 0000
1 3 000
0
2 00
+ h y + h yi + h yi − 2yi + yi − hyi + h y − h yi + h yi + ...
6
24
6
24
2 00
which simplifies to
Dx2 yi = yi00 + O(h2 )
Let ui ≈ yi = y(xi )
uxx + q(x)u = f (x)
with u(0) = α and u(1) = β becomes
−1
(ui+1 − 2ui + ui−1 ) + qi ui = fi
h2
or

2
2

−u2 + (2 + h q1 )u1 = h f1 + α
−ui+1 + (2 + h2 qi )ui − ui−1 = h2 fi


(2 + h2 qn )un − un−1 = h2 fn + β
i=1
2≤i≤n
i=n
where u0 = α and un+1 = β we must solve
2 + h2 q1

−1

An ~un = 


−1
2 + h2 q2
..
.
−1
..
.
−1
..
.
2 + h2 qn






u1
..
.
..
.
un


 
 
=
 

Note: An is tridiagonal and symmetric. We can solve this by using An = LU
L~vn = ~fn
8
U ~un = ~vn
New Notes
9
h2 f1 + α
h2 f2
..
.
h2 fn + β


 ~
 = fn

9
9.1
Pierson Guthrey
pguthrey@iastate.edu
Finite Difference Coefficients
Centered Differences
For the difference scheme for the α derivative of f ,
f (α) (xi ) ≈ Dhα f =
1 ai−4 f (xi−4 ) + ... + ai f (xi ) + ... + ai+4 f (xi+4 )
d
hα
where d is the denominator to make the coefficients ai integers. If we want the scheme to have accuracy β,
f (α) (xi ) = Dhα f + Ohβ
Then the difference coefficients are given by
α
1
2
3
4
9.2
β
2
4
6
8
2
4
6
8
2
4
6
2
4
6
d
2
12
60
840
1
12
180
5040
2
8
240
1
6
240
ai−4
ai−3
ai−2
3
−1
−32
1
9
168
−9
2
128
−7
1
72
7
−1
−96
−1
−27
−1008
−1
−8
−338
1
12
676
ai−1
−1
−8
−45
−672
1
16
270
8064
2
13
488
−4
−39
−1952
ai
ai+1
0
1
0
8
0
45
0
672
−2
1
−30
16
−490
270
−14350 8064
0
−2
0
−13
0
−488
6
−4
56
−39
2730
−1952
ai+2
ai+3
ai+4
−1
−9
−168
1
32
−3
2
128
−9
−1
−72
7
−1
−96
7
−1
−27
−1008
1
8
338
1
12
676
Forward/Backwards Differences
For the difference scheme for the α derivative of f ,
α
f (α) (xi ) ≈ D±
f=
1 ai f (xi ) + ... + ai±4 f (xi±4 ) + ... + ai±8 f (xi±8 )
d
hα
where d is the denominator to make the coefficients ai integers. If we want the scheme to have accuracy β,
α
f (α) (xi ) = D±
f + Ohβ
10
Pierson Guthrey
pguthrey@iastate.edu
9.2
Differences
Then Forward/Backwards
the difference coefficients
are given by
α
1
2
3
4
β
1
2
3
4
5
6
1
2
3
4
5
6
1
2
3
4
5
6
1
2
3
4
5
d
1
2
6
12
60
60
1
1
12
12
180
180
1
2
4
8
120
240
1
1
6
6
240
ai
∓1
∓3
∓11
∓25
∓137
∓147
1
2
35
45
812
938
∓1
∓5
∓17
∓49
∓967
∓2403
1
3
35
56
3207
ai+1
ai+2
ai+3
±1
±4
∓1
±18
∓9
±2
±48
∓36
±16
±300
∓300
±200
±360
∓450
±400
−2
1
−5
4
−1
−104
114
−56
−154
214
−156
−3132
5265
−5080
−4014
7911
−9490
±3
∓3
1
±18
∓24
±14
±71
∓118
±98
±232
∓461
±496
±5104 ∓11787 ±15560
±13960 ∓36706 ±57384
−4
6
−4
−14
26
−24
−186
411
−484
−333
852
−1219
−21056 61156 −102912
11
ai+4
ai+5
ai+6
∓3
∓75
∓225
±12
±72
∓10
11
61
2970
7389
−10
−972
−3616
137
1019
−126
±7
±104
±6432
±39128
∓15
∓1849
∓16830
±232
±4216
∓469
−2
−114
−555
−76352
17
164
33636
−21
−8576
967
∓3
∓41
∓307
∓12725
∓58280
1
11
321
1056
109930
ai+7
ai+8
Pierson Guthrey
pguthrey@iastate.edu
Part I
New Notes
10
Two Dimensional Problems
Given a problem
Ω = [0, X] × [0, Y ]
ut = b(uxx + uyy
With initial conditions on Ω for t = 0 and boundary conditions on ∂Ω
So for a uniform grid mesh
N
Ui,j
≈ u(xi , yj , tn ) = u(i∆x, j∆y, n∆t), i = 0, 1, ...I, j = 0, 1, ...J, n = 0, 1, ...N
Explicit Scheme
n+1
n
Ui,j
− Ui,j
=b
∆t
n
n
δx2 Ui,j
δy2 Ui,j
+
∆x2
∆y 2
!
Consistency
Tijn
=
1
1
∆tutt − b ∆x2 uxxxx + ∆y 2 uyyyy
2
12
n
+ ....
ij
Tijn ≈ O(∆t + ∆x2 + ∆y 2 )
Stability
n
Uij
≈ (λ)n ei(kx i∆x+ky i∆y)
????
Convergence The error estimate
n
enij = Uij
− unij
n
n
n
n
Uij
= Uij
+ b µx δx2 Uij
+ µy δy2 Uij
en+1
= eny + b µx δx2 enij + µy δy2 enij − ∆tTijn
y
µx = b
∆t
∆t
, µy = b 2
2
∆x
∆y
10.0.1 θ Scheme
Accuracy is O(∆t + ∆x2 + ∆y 2 ), but if θ =
∆x2 + ∆y 2 ).
This requires to solve a system
1
2
we have the Crank-Nicholson Scheme with accuracy O(∆t2 +
~ n+1 = ~bn
AU
Where U n ij is reshaped into a vector.
12
10.1
Direction
Implicit (ADI)
Methods
10.1 Alternating
Alternating
Direction
Implicit
(ADI)
Methods
Pierson Guthrey
pguthrey@iastate.edu
We see to modify the 2D problem so that we solve several 1D problems. We approximate the 2D CrankNicholson scheme
1
1
1
1
n+1
2
2
2
2
n
1 − µx δx
1 − µx δy Uij = 1 − µx δx
1 − µx δy Uij
(1)
2
2
2
2
Note that
1
1
1
1
1
n+ 1
1 − µx δy2 = 1 − µx δx2 − µy δy2 + µx µy δx2 δy2 ≈ O(∆tTij 2
1 − µx δx2
2
2
2
2
4
We solve for the intermediate solution
1
1
n+ 21
2
2
n
1 − µx δx Uij
= 1 + µy δy Uij
usingasystemof equations.T henf orthesolutionatthenextstepwemustsolveanothersy
2
2
Stability is based on Fourier Analysis on equation (??) and shows that this scheme is unconditionally
stable.
Maximum principle on (??) yields that we require µx ≤ 1. The same analysis on (??) yields that we
require µy ≤ 1 . Thus we require max {µx , µy } ≤ 1.
Consistency
n+ 21
1
1
1
1 2
1 2
1 2
n+ 12
2
2
Tij
=
+... ≈ O(∆t2 +∆x2 +∆y 2 )
∆t uttt − uxxxx − ∆y uyyyy − ∆t uxxtt − ∆t uyytt + ∆t uxxyyt
24
12
12
8
8
4
ij
10.2
Locally One Dimensional (LOD) Scheme
We can expand this to 3D
ut = b(uxx + uyy + uzz )

n+∗
n
1
1
2
2

 1 − 2 µx δx Uij = 1 + 2 µx δx Uij
n+∗∗
n+∗
1 − 12 µy δy2 Uij
= 1 + 12 µy δy2 Uij


n+1
n+∗∗
= 1 + 12 µz δz2 Uij
1 − 12 µz δz2 Uij
11
First Order Problems
F (Du, u, x) = 0
In general there is no classical solution globally. Weak solutions may exist.
11.1
Method of Characteristics
z(s)u(x(s)), ~p(s) = Du(x(s))


ẋ(s) = D~p F (~p(s), z(s), x(s))
ż(s) = D~p F (~p(s), z(s), x(s)) · ~p(s)

˙
~p(s) = −Dx F − Dz F · ~p(s)
Model problem: Transport equation/advection equaton
ut + a(x, t)ux
u(x, t = 0) = u0 (x)
If a constant:
Upwind Scheme
If (a) = ±1,
n
Ujn+1 − Ujn
±Ujn ∓ Uj∓1
+a
=0
∆t
∆x
13
Pierson Guthrey
pguthrey@iastate.edu
11.2
for Parabolic
Equations
11.2 Schemes
Schemes
for Parabolic
Equations
Courant Friedrich Lowry (CFL) Condition for convergence
|v| ≤ 1
v=
a∆t
(CFL number)
∆x
• The CFL is necessary but not sufficient for convergence.
• This ensures the domain of dependence of the scheme is a subset of the domain of dependence of
the equation.
Characteristic Ray Tracing Method (Semi-Lagrangian Method)
11.2.1
Euler Schemes
J
Upwind Differencing Interpolate U (x∗ , tn ) with Ujn j=0
Forward Time - Backward Difference Scheme
....?
Higher Dimensions
ut + aux + buy = 0,
a, b > 0
∆t
∆t
, vy = b ∆y
Let vx = a ∆x
n+1
n
n
n
n
n
Ui,j
− Ui,j
Ui,j
− Ui−1,j
Ui,j
− Ui,j−1
+a
+b
=0
∆t
∆x
∆x
• CFL conditions: |νx | ≤ 1 , |νy | ≤ 1
• We find that we require νx + νy ≤ 1
Backward Time - Forward Difference Scheme
n+1
Ujn+1 − Ujn
Ujn+1 − Uj−1
+a
=0
∆t
∆x
Since the computational domain of dependence is a rectangle, CFL will be satisfied.
• Unconditionally stable
Forward Time - Central Difference Scheme
n+1
n+1
Ujn+1 − Ujn
Uj−1
− Uj−1
+a
=0
∆t
2∆x
• Unconditionally unstable
Backward Time - Central Difference Scheme
n+1
n+1
Ujn+1 − Ujn
Uj−1
− Uj−1
+a
=0
∆t
2∆x
• Unconditionally stable
• Accuracy is O((∆x)2 )
14
Pierson Guthrey
pguthrey@iastate.edu
Lax-Wendroff
ν2
ν
− −
2
2
n+1
Uj−1
+ 1+ν
2
Ujn+1
ν2
ν
+ − −
2
2
n+1
Uj+1
= Ujn
• Unconditionally Stable
• Accuracy O((∆x)2 + (∆t)2 )
Crank-Nicolson
Ujn+1 − Ujn
1
+a
∆t
2
n+1
n+1
n
n
Uj−1
− Uj−1
Uj−1
− Uj−1
+
2∆x
2∆x
!
=0
• Unconditionally Stable with |λ| = 1, so may become unstable due to roundoff error
• Accuracy O((∆x)2 + (∆t)2 )
Lax Friedrichs Higher Dimensions
n+1
Ui,j
=
1
1
1
n
n
n
n
n
n
n
n
Ui+1,j
+ Ui−1,j
+ Ui,j−1
+ Ui,j+1
− νx Ui+1,j
− Ui−1,j
− νy Ui,j+1
− Ui,j−1
4
2
2
• λ = 21 (cos(ξ) + cos(η)) − i(νx sin(ξ) + νy sin(η))
• νx2 + νy2 ≤ 1
Euler Scheme
n+ 12
Uij
n
1
2 2
n
= U ij −νx ∆x0 Uij + 2 νx δx Uij
n+ 21
n+1
Uij
= Uij
n+ 12
− νy ∆y0 Uij
1
n+1
+ νy2 δy2 Uij
2
• Accuracy O((∆t)2 + (∆x)2 + (∆y)2 )
• max {|νx | , |νy |} ≤ 1
Leap Frog
Beam Wamming?
12
2.20.2014
ut + aux + buy = 0
Method of Characteristics tells us
u(x, y, t) = u0 (x − at, y − bt),
Forward Time Upwind Scheme
n
n
n
n
n+1
Ui,j
= U i,j − 2 νx (Ui,j −Ui−1,j )− 2 νy (Ui,j −Ui,j−1 )
1
• CFL condition: max {|νX | , |νy |} ≤ 1
• Stability (Fourier analysis) |νx | + |νy | ≤ 1
15
1
Pierson Guthrey
pguthrey@iastate.edu
• Truncation error: O(∆t + ∆x + ∆y)
Law Wendroff Scheme
n+ 12
Ui,j
n
1
1
2 2
n
= U i,j − 2 ν∆x0 Ui,j + 2 νx δx Ui,j
n+ 21
n+1
Ui,j
= Ui,j
1
n
n
− νy ∆y0 Ui,j
+ νy2 δy2 Ui,j
2
• CFL condition: max {|νX | , |νy |} ≤ 1
• Stability (Fourier analysis) |νx | + |νy | ≤ 1
• Truncation error: O((∆t)2 + (∆x)2 + (∆y)2 )
13
13.1
ADI Schemes
Locally One Dimensional Scheme
n+ 12
(1 + νx ∆x0 )Ui,j
n
= Ui,j
n+ 21
n+1
(1 + νy ∆y0 )Ui,j
= Ui,j
• CFL condition: ?
• Stability: Unconditionally Stable. Fourier Analysis: we find |λ| ≤ 1.
• Truncation error: O(∆t + (∆x)2 + (∆y)2 )
13.2
Crank Nicolson Scheme
n+1
n
Ui,j
− Ui,j
1
1
n+1
n+1
n
n
+ νx ∆x0 (Ui,j
+ Ui,j
) + νy ∆y0 (Ui,j
+ Ui,j
)=0
∆t
2
2
• CFL condition: ?
• Stability: Unconditionally Stable. Unproven
• Truncation error: O((∆t)2 + (∆x)2 + (∆y)2 )
Beam Wamming
1
1
1
∗
n
1 − νy ∆y0 Ui,j
1 + νx ∆x0 Ui,j = 1 − νx ∆x0
2
2
2
1
n+1
∗
1 + νy ∆x0 Ui,j
= Ui,j
2
• CFL condition: ?
• Stability: |λ| = 1
• Truncation error: ?
16
14
Pierson Guthrey
pguthrey@iastate.edu
2.25.2014
Consistency, convergence, stability, and Lax Equivalence Theorem.
Consider the problem in the general form.

∂u

Ω × [0, tF ]
 ∂t = Lu
g(u) = g0
u ∈ ∂Ω


u(x, 0) = u0 (x) x ∈ Ω, t = 0
We assume that Ω is bounded, and L represents a differential operator such that ∂u
∂t = Lu is well posed:
• Existence of solutions: A solution exists for all data u0 for which u0 is bounded.
• Continuous dependence
on
data: There exists a constant K such that for any pair of solutions u
and v, ku − vk ≤ K u0 − v 0 for all t ≤ tF .
Schemes for solutions
~ n+1 = B0 U
~n+F
~n
B1 U
Assume B1 exists. Then a solution to the difference scheme exists:
~ n ~n
~ n+1 = B (B0 U +F )
U
1
The truncation error is defined by the equation
~n +T
~n
B1 ~un+1 = B0 ~un + F
Thus subtracting the discrete PDE scheme by the continuous PDE scheme we get
~n
~ n+1 − ~un+1 = B B 0 U
~ n − ~un − B T
U
1
1
Using the implied recursive relationship,
~
~ n+1 − ~un+1 = B T
U
1
n−1
~0
~ n−2 +...+(B B )n−1 B T
T
1 0
1
+B1B 0 B1
n ~ n
)
So if (B 1 B0 ) ≤ K ∀ n∆t ≤ tF and kB 1 k ≤ K1 ∆t, then (B1B 0 )m B0 ≤ K1 K∆t ∀ m ≤ n so U
− ~un ≤
n−1
P ~ m
K1 K∆t
T m=0
n
~n →
• Consistency: Ti,j
→ 0 as ∆t, ∆x, ∆y, ... → 0 for all i, j which implies B1 ~un+1 − B0 ~un + F
∂u
∂t
− Lu
n
• Accuracy: If p, q are the largest positive numbers for which Ti,j
≤ O ((∆t)p + hq ) as ∆t → 0and h → 0
for sufficiently smooth u, where h = max ∆x, ∆y, ..., the scheme is said to have order of accuracy p
in ∆t and q in h.
~ n and V
~ n of the scheme which have the
• Stability: The scheme is said to be stable if two solutions U
n
~
~
~ 0 satisfy
same inhomogeneous terms F but start form different initial data U0 and V
~ n ~ n
~ 0 ~ 0
−V ∀ n∆t ≤ tF
U − V ≤ K U
for some constant K independent of the initial data and mesh sizes. Equivalently,
B n ∀ n∆t ≤ tF
B1 0 ≤ K
17
14.1
Dissipation
andhas
Dispersion
– If the PDE
constant coefficients, Fourier Analysis can be used
Pierson Guthrey
pguthrey@iastate.edu
– A maximum principle is sometimes necessary for Parabolic
~ n
• Convergence: The scheme provides convergent approximations to the problem if U
− ~un → 0
as ∆t, h → 0, n∆t → t ∈ [0, tF ] for every u0 for which the problem is well posed.
Lax Equivalence Theorem For a consistent difference approximation to a well posed linear evolutionary
problem which is uniformly stable in the sense that kB k ≤ K∆t for some constant K, the stability of the
scheme is necessary and sufficient for convergence.
14.1
Dissipation and Dispersion
The Dissipation of solutions of PDEs is when the Fourier modes do not grow with time and at least one
mode decays. The PDE is Non-dissipative if the Fourier modes neither decay nor grow.
The Dispersion of of solutions of PDEs is when the Fourier modes of differing wave lengthd (or wave numbers) propagate at different speeds.
Von Neumann Condition A necessary condition for stability is that the exists a constant K such that
~ ~ n∆t ≤ tF
λ(k) ≤ 1 + K∆t, ∀ K,
or as ∆t → 0 and h → 0
or
~ n
λ(k) ≤ K
~ n
λ(k) ≤ (1 + K∆t)n ≈ (1 + K∆tn) + O((∆t)2 )
18
Download