Upload
others
View
2
Download
0
Embed Size (px)
Citation preview
ScientificComputing I
Michael Bader
OutlinesPart I: Analytic Solutions ofthe 1D Heat Equation
Part II: Numerical Solutionsof the 1D Heat Equation
Part III: EnergyConsiderations
Scientific Computing IModule 6: The 1D Heat Equation
Michael Bader
Lehrstuhl Informatik V
Winter 2006/2007
ScientificComputing I
Michael Bader
OutlinesPart I: Analytic Solutions ofthe 1D Heat Equation
Part II: Numerical Solutionsof the 1D Heat Equation
Part III: EnergyConsiderations
Part I: Analytic Solutions of the 1DHeat Equation
1 The Heat Equation in 1D
2 Analytic SolutionsAnalytic SolutionsA Family of Solutions – Fourier’s Method
ScientificComputing I
Michael Bader
OutlinesPart I: Analytic Solutions ofthe 1D Heat Equation
Part II: Numerical Solutionsof the 1D Heat Equation
Part III: EnergyConsiderations
Part II: Numerical Solutions of the 1DHeat Equation
3 Numerical Solution 1 – An Explicit SchemeDiscretisationAccuracyNeumann Stability
4 Numerical Solution 2 – An Implicit SchemeImplicit Time-SteppingStability of the Implicit Scheme
ScientificComputing I
Michael Bader
OutlinesPart I: Analytic Solutions ofthe 1D Heat Equation
Part II: Numerical Solutionsof the 1D Heat Equation
Part III: EnergyConsiderations
Part III: Energy Considerations
5 Energy and StabilityEnergy of the analytic solutionUniqueness and StabilityEnergy of the numerical solutionEnergy for the Implicit Scheme
ScientificComputing I
Michael Bader
The Heat Equationin 1D
Analytic SolutionsAnalytic Solutions
A Family of Solutions –Fourier’s Method
Part I
Analytic Solutions of the 1D HeatEquation
ScientificComputing I
Michael Bader
The Heat Equationin 1D
Analytic SolutionsAnalytic Solutions
A Family of Solutions –Fourier’s Method
The Heat Equation in 1D
remember the heat equation:
Tt = κ∆T
we examine the 1D case, and set κ = 1 to get:
ut = uxx for x ∈ (0,1), t > 0
using the following initial and boundaryconditions:
u(x,0) = f(x), x ∈ (0,1)
u(0, t) = u(1, t) = 0, t > 0
ScientificComputing I
Michael Bader
The Heat Equationin 1D
Analytic SolutionsAnalytic Solutions
A Family of Solutions –Fourier’s Method
Computing Analytic Solutions
First steps:
try to find some solution of the PDE
try to satisfy boundary conditions(but not the initial condition)
Ansatz: Separation of Variables
assumption:
u(x, t) = X(x) ·T(t)
insert this assumption into the heat equation
ScientificComputing I
Michael Bader
The Heat Equationin 1D
Analytic SolutionsAnalytic Solutions
A Family of Solutions –Fourier’s Method
Separation of Variablesinsert u(x, t) = X(x) ·T(t) into PDE:
∂
∂ t(X(x) ·T(t)) =
∂ 2
∂x2 (X(x) ·T(t))
or X(x) ·Tt(t) = T(t) ·Xxx(x)
divide by X(x)T(t), and get:
Tt(t)T(t)
=Xxx(x)
X(x)
true for all x and all t, only if:
Tt(t)T(t)
=Xxx(x)
X(x)=−λ
ScientificComputing I
Michael Bader
The Heat Equationin 1D
Analytic SolutionsAnalytic Solutions
A Family of Solutions –Fourier’s Method
Transforming the PDE into two ODEsseparation of variables leads to:
Tt(t)T(t)
=Xxx(x)
X(x)=−λ
thus, we obtain two ODEs:
Xxx(x)+λX(x) = 0 X(0) = X(1) = 0, (1)
Tt(t)+λT(t) = 0 (2)
solve X(x)-part:
Xk(x) = sin(kπx) λk = (kπ)2,k = 1,2, . . .
solve T(t)-part (compare Model of Maltus):
Tk(t) = e−λkt = e−(kπ)2t
ScientificComputing I
Michael Bader
The Heat Equationin 1D
Analytic SolutionsAnalytic Solutions
A Family of Solutions –Fourier’s Method
Fourier’s Methodthe functions
uk(x, t) := Tk(t)Xk(x) = e−(kπ)2t sin(kπx), k = 1,2, . . . ,
solve the 1D heat equation PDEfor the initial and boundary conditions:
uk(0, t) = uk(1, t) = 0, t > 0
uk(x,0) = sin(kπx), x ∈ (0,1).
use Fourier sine series for initial condition:
f(x) =∞
∑k=1
ck sin(kπx).
and obtain solution for uk(x,0) = f(x):
u(x, t) =∞
∑k=1
cke−(kπ)2t sin(kπx),
ScientificComputing I
Michael Bader
The Heat Equationin 1D
Analytic SolutionsAnalytic Solutions
A Family of Solutions –Fourier’s Method
Fourier’s Method – A Recipe1 Find coefficients ck such that the initial
condition f(x) can be represented as
f(x) =∞
∑k=1
ck sin(kπx).
2 Verify that the solution candidate
u(x, t) := ∑k
cke−(kπ)2t sin(kπx)
converges to a well-defined function u3 Verify that u solves the differential equation
ut = uxx4 Verify that u satisfies the boundary conditions
u(0, t) = u(1, t) = 05 Verify that u satisfies the initial condition
u(x,0) = f(x)
ScientificComputing I
Michael Bader
NumericalSolution 1 – AnExplicit SchemeDiscretisation
Accuracy
Neumann Stability
NumericalSolution 2 – AnImplicit SchemeImplicit Time-Stepping
Stability of the ImplicitScheme
Part II
Numerical Solutions of the 1DHeat Equation
ScientificComputing I
Michael Bader
NumericalSolution 1 – AnExplicit SchemeDiscretisation
Accuracy
Neumann Stability
NumericalSolution 2 – AnImplicit SchemeImplicit Time-Stepping
Stability of the ImplicitScheme
Numerical Solution 1 – DiscretisationDiscretisation similar to ODEs:
compute approximations
v(m)j ≈ u(xj, tm)
at grid points xj and time points tm:
xj := j ·h tm := m · τ,
approximate equation ut = uxx by
v(m+1)j −v(m)
j
τ=
v(m)j−1 −2v(m)
j +v(m)j+1
h2 (3)
for j = 1, . . . ,n−1, and m≥ 0.
ScientificComputing I
Michael Bader
NumericalSolution 1 – AnExplicit SchemeDiscretisation
Accuracy
Neumann Stability
NumericalSolution 2 – AnImplicit SchemeImplicit Time-Stepping
Stability of the ImplicitScheme
An Explicit Scheme
add initial and boundary conditions:
v(m)0 = v(m)
n = 0, for all m≥ 0,
v(0)j = f(xj), for j = 1, . . . ,n−1.
and obtain an explicit scheme:
v(m+1)j = v(m)
j +τ
h2
(v(m)
j−1 −2v(m)j +v(m)
j+1
)we can, step by step, compute all values v(m)
jfor all time steps (m),starting with the initial conditions v(0)
j = f(xj).
“explicit time stepping scheme”
ScientificComputing I
Michael Bader
NumericalSolution 1 – AnExplicit SchemeDiscretisation
Accuracy
Neumann Stability
NumericalSolution 2 – AnImplicit SchemeImplicit Time-Stepping
Stability of the ImplicitScheme
Accuracy of the Explicit Scheme
Observations:
first order accurate in τ:
ut(x, t) =u(x, t+ τ)−u(x, t)
τ+O(τ)
second order accurate in h:
uxx(x, t) =u(x−h, t)−2u(x, t)+u(x +h, t)
h2 +O(h2)
stability condition of the step size!(similar to ODE)
⇒ examine conservation of “energy”or Neumann Stability Analysis
ScientificComputing I
Michael Bader
NumericalSolution 1 – AnExplicit SchemeDiscretisation
Accuracy
Neumann Stability
NumericalSolution 2 – AnImplicit SchemeImplicit Time-Stepping
Stability of the ImplicitScheme
Solutions of the Explicit Scheme
explicit scheme:
v(m+1)j −v(m)
j
τ=
v(m)j−1 −2v(m)
j +v(m)j+1
h2
assumption: there are solutions of the form
u(m)j = (ak)
m sin(πkxj), where xj := jh. (4)
compare with exact solution:
uk(x, t) = e−(kπ)2t sin(kπx)
(ak)m ∼ e−(kπ)2t, thus (ak)
m should decrease⇒ |ak|< 1 necessary
ScientificComputing I
Michael Bader
NumericalSolution 1 – AnExplicit SchemeDiscretisation
Accuracy
Neumann Stability
NumericalSolution 2 – AnImplicit SchemeImplicit Time-Stepping
Stability of the ImplicitScheme
Solutions of the Explicit Scheme (2)
insert u(m)j = (ak)
m sin(πkxj) into
v(m+1)j −v(m)
j
τ=
v(m)j−1 −2v(m)
j +v(m)j+1
h2
leads to condition (see separate worksheet)
ak = 1+τ
h2 (2cos(πkh)−2) = 1− 4τ
h2 sin2(
πkh2
).
for stability: |ak|< 1 only if
4τ
h2 < 2 or τ <h2
2.
ScientificComputing I
Michael Bader
NumericalSolution 1 – AnExplicit SchemeDiscretisation
Accuracy
Neumann Stability
NumericalSolution 2 – AnImplicit SchemeImplicit Time-Stepping
Stability of the ImplicitScheme
Solutions of the Explicit Scheme (3)
in practice: numerical solution is of the form
v(m)j :=
n−1
∑k=1
ck(ak)m sin(πkxj).
stability, because |ak|< 1 for all k
the coefficients ck result from a sine transformof the initial values fj:
u(0)j = fj =
n−1
∑k=1
ck sin(πkxj).
ScientificComputing I
Michael Bader
NumericalSolution 1 – AnExplicit SchemeDiscretisation
Accuracy
Neumann Stability
NumericalSolution 2 – AnImplicit SchemeImplicit Time-Stepping
Stability of the ImplicitScheme
Numerical Solution 2 – An ImplicitScheme
apply implicit Euler:
v(m+1)j −v(m)
j
τ=
v(m+1)j−1 −2v(m+1)
j +v(m+1)j+1
h2
for j = 1, . . . ,n−1, and m≥ 0.
boundary conditions:
v(m)0 = v(m)
n = 0, for all m≥ 0,
initial conditions:
v(0)j = f(xj), for j = 1, . . . ,n−1.
ScientificComputing I
Michael Bader
NumericalSolution 1 – AnExplicit SchemeDiscretisation
Accuracy
Neumann Stability
NumericalSolution 2 – AnImplicit SchemeImplicit Time-Stepping
Stability of the ImplicitScheme
Implicit Time Stepping
solve implicit scheme for v(m+1)j :
v(m+1)j − τ
h2
(v(m+1)
j−1 −2v(m+1)j +v(m+1)
j+1
)= v(m)
j .
with the ratio r := τ/h2, we can write it as
−rv(m+1)j−1 +(1+2r)v(m+1)
j − rv(m+1)j+1 = v(m)
j
for j = 1, . . . ,n−1, and m≥ 0
solve a system of linear equations to obtainv(m+1)
j in every step
ScientificComputing I
Michael Bader
NumericalSolution 1 – AnExplicit SchemeDiscretisation
Accuracy
Neumann Stability
NumericalSolution 2 – AnImplicit SchemeImplicit Time-Stepping
Stability of the ImplicitScheme
System of Linear Equations:
the matrix of the linear system of equations isgiven by I+ rA, where A = tridiag(−1,2,−1).
system is tridiagonal, solving requires O(n)
operations.
solution:
v(m) = (I+ rA)−1v(m−1);
ScientificComputing I
Michael Bader
NumericalSolution 1 – AnExplicit SchemeDiscretisation
Accuracy
Neumann Stability
NumericalSolution 2 – AnImplicit SchemeImplicit Time-Stepping
Stability of the ImplicitScheme
Solutions of the Implicit Scheme
implicit scheme:
v(m+1)j −v(m)
j
τ=
v(m+1)j−1 −2v(m+1)
j +v(m+1)j+1
h2
again: insert assumed solutions
u(m)j = (ak)
m sin(πkxj), where xj := jh.
into implicit scheme, and obtain:
ak−1 = −4τ
h2 sin2(
πkh2
)ak
ak =
(1+
4τ
h2 sin2(
πkh2
))−1
.
ScientificComputing I
Michael Bader
NumericalSolution 1 – AnExplicit SchemeDiscretisation
Accuracy
Neumann Stability
NumericalSolution 2 – AnImplicit SchemeImplicit Time-Stepping
Stability of the ImplicitScheme
Solutions of the Implicit Scheme (2)
solutions of the implicit scheme:
v(m)j :=
n−1
∑k=1
ck(ak)m sin(πkxj).
with
ak =
(1+
4τ
h2 sin2(
πkh2
))−1
.
0 < ak < 1 independent of k and h
⇒ unconditionally stable
ScientificComputing I
Michael Bader
Energy andStabilityEnergy of the analyticsolution
Uniqueness and Stability
Energy of the numericalsolution
Energy for the ImplicitScheme
Part III
Energy Considerations(Additional Material – Not
Compulsory)
ScientificComputing I
Michael Bader
Energy andStabilityEnergy of the analyticsolution
Uniqueness and Stability
Energy of the numericalsolution
Energy for the ImplicitScheme
Energy of the Analytic Solutionu(x,y) a solution of
(uk)t = (uk)xx, x ∈ (0,1), t > 0
uk(0, t) = uk(1, t) = 0, t > 0
uk(x,0) = f(x), x ∈ (0,1).
define the energy of the solution:
E(t) :=∫ 1
0u2(x, t)dx
for conservation of energy, analyse
E′(t) :=ddt
∫ 1
0u2(x, t)dx
ScientificComputing I
Michael Bader
Energy andStabilityEnergy of the analyticsolution
Uniqueness and Stability
Energy of the numericalsolution
Energy for the ImplicitScheme
Energy of the Analytic Solution (2)
E′(t) =∫ 1
0
∂
∂ tu2(x, t)dx =
∫ 1
02u(x, t)ut(x, t)dx
= 2∫ 1
0u(x, t)uxx(x, t)dx
= 2 [u(x, t)ux(x, t)]10−2∫ 1
0(ux(x, t))2 dx
= −2∫ 1
0(ux(x, t))2 dx ≤ 0
Therefore:E(t)≤ E(0) (energy never increases)compare to initial condition u(x,0) = f(x):∫ 1
0u2(x, t)dx = E(t)≤ E(0) =
∫ 1
0f2(x)dx
ScientificComputing I
Michael Bader
Energy andStabilityEnergy of the analyticsolution
Uniqueness and Stability
Energy of the numericalsolution
Energy for the ImplicitScheme
Corrollaries
assume: both u1(x, t) and u2(x, t) are solutionsfor initial conditions f1(x) and f2(x)
let w(x, t) := u1(x, t)−u2(x, t), then
wt(x, t) = (u1)t(x, t)− (u2)t(x, t)
= (u1)xx(x, t)− (u2)xx(x, t) = wxx(x, t)
w(0, t) = w(1, t) = 0
w(x,0) = u1(x,0)−u2(x,0) = f1(x)− f2(x)
therefore, w(x, t) is a solution of the heatequation for initial conditionfw(x) = f1(x)− f2(x)
ScientificComputing I
Michael Bader
Energy andStabilityEnergy of the analyticsolution
Uniqueness and Stability
Energy of the numericalsolution
Energy for the ImplicitScheme
Corrollary 1 – Uniqueness
if f1 = f2, then fw(x) = 0
energy is decreasing:∫ 1
0(u1−u2)2(x, t)dx =
∫ 1
0w2(x, t)dx
≤∫ 1
0(f1− f2)2(x)dx = 0
therefore:∫ 1
0w2(x, t)dx ≤ 0 ⇔ w = 0 ⇔ u1 = u2.
proof of uniqueness of the solution!
ScientificComputing I
Michael Bader
Energy andStabilityEnergy of the analyticsolution
Uniqueness and Stability
Energy of the numericalsolution
Energy for the ImplicitScheme
Corrollary 2 – Stability
now: f2 = f1 + ε (ε small), then∫ 1
0w2(x, t)dx ≤
∫ 1
0(f1− f2)2(x)dx
=∫ 1
0ε(x)dx ≤ ‖ε‖ ·1
therefore:if ε is small, the difference between u1 and u2
also has got to be small, i.e.small perturbations in the initial conditionslead to small perturbations in the solution.
stability estimate for the solution!
ScientificComputing I
Michael Bader
Energy andStabilityEnergy of the analyticsolution
Uniqueness and Stability
Energy of the numericalsolution
Energy for the ImplicitScheme
Energy of the Numerical Solution
we introduce the discrete energy:
E(m) := hn−1
∑j=1
(v(m)
j
)2.
we would like to show that:
E(m+1) ≤ E(m) for m≥ 0.
thus, we will compute ∆E(m) := E(m+1)−E(m):
∆E(m) = hn−1
∑j=1
((v(m+1)
j
)2−
(v(m)
j
)2)
ScientificComputing I
Michael Bader
Energy andStabilityEnergy of the analyticsolution
Uniqueness and Stability
Energy of the numericalsolution
Energy for the ImplicitScheme
Energy in the Explicit Scheme
lengthy computation (see separate worksheet)leads to stability condition:(
E(m+1)−E(m))≤ 0, or E(m+1) ≤ E(m)
is only correct, if
τ
h2 ≤12
or τ ≤ h2
2.
otherwise:increasing energy (physically incorrect), leadsto large oscillations in the solution
ScientificComputing I
Michael Bader
Energy andStabilityEnergy of the analyticsolution
Uniqueness and Stability
Energy of the numericalsolution
Energy for the ImplicitScheme
Energy for the Implicit Schemeanalyse discrete energy
E(m) := hn−1
∑j=1
(v(m)
j
)2= h
(v(m)
j
)Tv(m)
j .
change of energy in each time step:
∆E(m) = h((
v(m+1))T
v(m+1)−(
v(m))T
v(m)
)= h
((Mv(m)
)TMv(m)−
(v(m)
)Tv(m)
)= h
((v(m)
)TMTMv(m)−
(v(m)
)Tv(m)
)= h
(v(m)
)T (MTM− I
)v(m)
ScientificComputing I
Michael Bader
Energy andStabilityEnergy of the analyticsolution
Uniqueness and Stability
Energy of the numericalsolution
Energy for the ImplicitScheme
Energy for the Implicit Scheme (2)
energy for the implicit scheme:
∆E(m) = h(
v(m))T (
MTM− I)
v(m)
examine eigenvalues of matrix MTM− Iresult:
all eigenvalues < 0therefore ∆E(m) ≤ 0implicit scheme stable for any τ and h