SlideShare a Scribd company logo
1 of 12
Download to read offline
Crank Nicolson Solution to the Heat Equation
ME 448/548 Notes
Gerald Recktenwald
Portland State University
Department of Mechanical Engineering
gerry@pdx.edu
ME 448/548: Crank-Nicolson Solution to the Heat Equation
Overview
1. Use finite approximations to ∂u/∂t and ∂2
u/∂x2
: same components used in FTCS
and BTCS.
2. Average contribution from tk and tk+1 in the approximation of ∂2
u/∂x2
.
3. Computational formula is (still) implicit: all uk+1
i must be solved simultaneously.
Information from uk
i−1, uk
i , and uk
i+1 are used at each time step in the computation
of uk+1
i .
4. Solution is not significantly more complex than BTCS.
5. Like BTCS, the Crank-Nicolson methods is unconditionally stable for the heat
equation.
6. Truncation error is O(∆t2
) + O(∆x2
). Time accuracy is better than BTCS or
FTCS.
ME 448/548: Crank-Nicolson Solution to the Heat Equation page 1
The θ Method
Evaluate the diffusion operator ∂2
u/∂x2
at both time steps tk+1 and time step tk, and
use a weighted average
uk+1
i − uk
i
∆t
= αθ
"
uk+1
i−1 − 2uk+1
i + uk+1
i+1
∆x2
#
+ α(1 − θ)
"
uk
i−1 − 2uk
i + uk
i+1
∆x2
#
(1)
where
0 ≤ θ ≤ 1
θ = 0 ⇐⇒ FTCS
θ = 1 ⇐⇒ BTCS
θ =
1
2
⇐⇒ Crank-Nicolson
ME 448/548: Crank-Nicolson Solution to the Heat Equation page 2
Crank-Nicolson Computational Molecule
Solution is known
for these nodes
Crank-Nicolson scheme
requires simultaneous
calculation of u at all
nodes on the k+1 mesh line
t
i i+1
i 1
i=1 nx
k+1
k
k 1
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
x=L
x=0
t=0, k=1
ME 448/548: Crank-Nicolson Solution to the Heat Equation page 3
Compare Computational Molecules
FTCS
i i+1
i–1
k+1
k
BTCS
i i+1
i–1
k+1
k
Crank-Nicolson
i i+1
i–1
k+1
k
ME 448/548: Crank-Nicolson Solution to the Heat Equation page 4
Crank Nicolson Approximation to the Heat Equation
Set θ =
1
2
in the formulation of the θ method.
−
α
2∆x2
u
k+1
i−1 +

1
∆t
+
α
∆x2

u
k+1
i −
α
2∆x2
u
k+1
i+1 =
α
2∆x2
u
k
i−1 +

1
∆t
−
α
∆x2

u
k
i +
α
2∆x2
u
k
i+1 (2)
ME 448/548: Crank-Nicolson Solution to the Heat Equation page 5
Crank-Nicolson System of Equations
The system of equations has the same structure as BTCS









a1 b1 0 0 0 0
c2 a2 b2 0 0 0
0 c3 a3 b3 0 0
0 0 ... ... ... 0
0 0 0 cnx−1 anx−1 bnx−1
0 0 0 0 cnx anx




















uk+1
1
uk+1
2
uk+1
3
.
.
.
uk+1
nx−1
uk+1
nx











=









d1
d2
d3
.
.
.
dnx−1
dnx









(3)
where the coefficients of the interior nodes (i = 2, 3, . . . , N − 1) are
ai = 1/∆t + α/∆x
2
= 1/∆t − (bi + ci),
bi = ci = −α/(2∆x
2
),
di = −ciu
k
i−1 + (1/∆t + bi + ci) u
k
i − biu
k
i+1.
ME 448/548: Crank-Nicolson Solution to the Heat Equation page 6
demoCN Code
% --- Coefficients of the tridiagonal system
b = (-alfa/2/dx^2)*ones(nx,1); % Super diagonal: coefficients of u(i+1)
c = b; % Subdiagonal: coefficients of u(i-1)
a = (1/dt)*ones(nx,1) - (b+c); % Main Diagonal: coefficients of u(i)
at = (1/dt + b + c); % Coefficient of u_i^k on RHS
a(1) = 1; b(1) = 0; % Fix coefficients of boundary nodes
a(end) = 1; c(end) = 0;
[e,f] = tridiagLU(a,b,c); % Save LU factorization
% --- Assign IC and save BC values in ub. IC creates u vector
x = linspace(0,L,nx)’; u = sin(pi*x/L); ub = [0 0];
% --- Loop over time steps
for k=2:nt
% --- Update RHS for all equations, including those on boundary
d = - [0; c(2:end-1).*u(1:end-2); 0] ...
+ [ub(1); at(2:end-1).*u(2:end-1); ub(2)] ...
- [0; b(2:end-1).*u(3:end); 0];
u = tridiagLUsolve(e,f,b,d); % Solve the system
end
ME 448/548: Crank-Nicolson Solution to the Heat Equation page 7
Convergence of FTCS, BTCS and CN
Truncation Errors
Scheme Spatial Temporal
FTCS ∆x2
∆t
BTCS ∆x2
∆t
C-N ∆x2
∆t2
Reduce both dx and dt within the FTCS stability limit
------------- Errors ------------
nx nt FTCS BTCS CN
4 5 2.903e-02 5.346e-02 1.304e-02
8 21 6.028e-03 1.186e-02 2.929e-03
16 92 1.356e-03 2.716e-03 6.804e-04
32 386 3.262e-04 6.522e-04 1.630e-04
64 1589 7.972e-05 1.594e-04 3.984e-05
128 6453 1.970e-05 3.939e-05 9.847e-06
256 26012 4.895e-06 9.790e-06 2.448e-06
512 104452 1.220e-06 2.440e-06 6.101e-07
Reduce dt while holding dx = 9.775171e-04 (L=1.0, nx=1024) constant
------------- Errors ------------
nx nt FTCS BTCS CN
1024 8 NaN 2.601e-02 1.291e-03
1024 16 NaN 1.246e-02 2.798e-04
1024 32 NaN 6.102e-03 6.534e-05
1024 64 NaN 3.020e-03 1.570e-05
1024 128 NaN 1.502e-03 3.749e-06
1024 256 NaN 7.492e-04 8.154e-07
1024 512 NaN 3.742e-04 8.868e-08
1024 1024 NaN 1.871e-04 9.218e-08
ME 448/548: Crank-Nicolson Solution to the Heat Equation page 8
Convergence of FTCS, BTCS and CN
10
−3
10
−2
10
−1
10
0
10
−7
10
−6
10
−5
10
−4
10
−3
10
−2
10
−1
∆ x
E(∆
x,∆
t)
FTCS
BTCS
CN
E ∝∆ x2
10
−3
10
−2
10
−1
10
0
10
−8
10
−7
10
−6
10
−5
10
−4
10
−3
10
−2
10
−1
∆ t
E(∆
x,∆
t)
∆ x = 9.8e−04 (constant)
FTCS
BTCS
CN
E∝∆ t
E∝∆ t2
In the plot of truncation error versus ∆t (right hand plot), there is an irregularity at
∆t ∼ 3.9 × 10−3
. At that level of ∆t, and for the chosen ∆x (which is constant), the
truncation error due to ∆x is no longer negligible. Further reductions in ∆t alone will
not reduce the total truncation error.
ME 448/548: Crank-Nicolson Solution to the Heat Equation page 9
Truncation Error is Additive
10-4
10-3
10-2
10-1
100
t
10-12
10
-10
10-8
10-6
10-4
10-2
Error:
||u-u
e
||
2
nx = 400
nx = 800
nx = 1600
nx = 3200
nx = 6400
nx = 12800
Ideal
The truncation error for the
finite-difference schemes that we have
explored so far are of the form
ē = O(∆t
p
) + O(∆x
q
)
For example, for the Crank-Nicolson
scheme, p = q = 2.
If ∆t is reduced while ∆x is held
constant, the measured error is reduced
until the point that the temporal
truncation error is less than the spatial
truncation error.
ME 448/548: Crank-Nicolson Solution to the Heat Equation page 10
Summary for the Crank-Nicolson Scheme
• The Crank-Nicolson method is more accurate than FTCS or BTCS.
Although all three methods have the same spatial truncation error (∆x2
), the better
temporal truncation error for the Crank-Nicolson method is a big advantage.
• Like BTCS, the Crank-Nicolson scheme is unconditionally stable for the heat equation.
• Like BTCS, a system of equations for the unknown uk
i must be solved at each time
step. The tridiagonal solver for the 1D heat equation obtains an efficient solution of
the system of equations.
• The Crank-Nicolson scheme is recommended over FTCS and BTCS.
ME 448/548: Crank-Nicolson Solution to the Heat Equation page 11

More Related Content

Similar to CN_slides.pdf

Fast dct algorithm using winograd’s method
Fast dct algorithm using winograd’s methodFast dct algorithm using winograd’s method
Fast dct algorithm using winograd’s method
IAEME Publication
 
Introduction to FEM
Introduction to FEMIntroduction to FEM
Introduction to FEM
mezkurra
 

Similar to CN_slides.pdf (20)

Video lectures for b.tech
Video lectures for b.techVideo lectures for b.tech
Video lectures for b.tech
 
free Video lecture in india
free Video lecture in indiafree Video lecture in india
free Video lecture in india
 
Free video lecture in india
Free video lecture in indiaFree video lecture in india
Free video lecture in india
 
Admission in india 2014
Admission in india 2014Admission in india 2014
Admission in india 2014
 
UNIT I_4.pdf
UNIT I_4.pdfUNIT I_4.pdf
UNIT I_4.pdf
 
numerical.ppt
numerical.pptnumerical.ppt
numerical.ppt
 
Fast dct algorithm using winograd’s method
Fast dct algorithm using winograd’s methodFast dct algorithm using winograd’s method
Fast dct algorithm using winograd’s method
 
Recurrence relation solutions
Recurrence relation solutionsRecurrence relation solutions
Recurrence relation solutions
 
a decomposition methodMin quasdratic.pdf
a decomposition methodMin quasdratic.pdfa decomposition methodMin quasdratic.pdf
a decomposition methodMin quasdratic.pdf
 
Partial differential equations
Partial differential equationsPartial differential equations
Partial differential equations
 
Fundamentals of Transport Phenomena ChE 715
Fundamentals of Transport Phenomena ChE 715Fundamentals of Transport Phenomena ChE 715
Fundamentals of Transport Phenomena ChE 715
 
dynamical analysis of soil and structures
dynamical analysis of soil and structuresdynamical analysis of soil and structures
dynamical analysis of soil and structures
 
Joint blind calibration and time-delay estimation for multiband ranging
Joint blind calibration and time-delay estimation for multiband rangingJoint blind calibration and time-delay estimation for multiband ranging
Joint blind calibration and time-delay estimation for multiband ranging
 
Dsp U Lec10 DFT And FFT
Dsp U   Lec10  DFT And  FFTDsp U   Lec10  DFT And  FFT
Dsp U Lec10 DFT And FFT
 
wave_equation
wave_equationwave_equation
wave_equation
 
Ece4510 notes10
Ece4510 notes10Ece4510 notes10
Ece4510 notes10
 
IVR - Chapter 4 - Variational methods
IVR - Chapter 4 - Variational methodsIVR - Chapter 4 - Variational methods
IVR - Chapter 4 - Variational methods
 
Heat conduction equation
Heat conduction equationHeat conduction equation
Heat conduction equation
 
lecture-2-not.pdf
lecture-2-not.pdflecture-2-not.pdf
lecture-2-not.pdf
 
Introduction to FEM
Introduction to FEMIntroduction to FEM
Introduction to FEM
 

Recently uploaded

"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
mphochane1998
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
jaanualu31
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
MayuraD1
 

Recently uploaded (20)

A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal load
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planes
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
Rums floating Omkareshwar FSPV IM_16112021.pdf
Rums floating Omkareshwar FSPV IM_16112021.pdfRums floating Omkareshwar FSPV IM_16112021.pdf
Rums floating Omkareshwar FSPV IM_16112021.pdf
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 

CN_slides.pdf

  • 1. Crank Nicolson Solution to the Heat Equation ME 448/548 Notes Gerald Recktenwald Portland State University Department of Mechanical Engineering gerry@pdx.edu ME 448/548: Crank-Nicolson Solution to the Heat Equation
  • 2. Overview 1. Use finite approximations to ∂u/∂t and ∂2 u/∂x2 : same components used in FTCS and BTCS. 2. Average contribution from tk and tk+1 in the approximation of ∂2 u/∂x2 . 3. Computational formula is (still) implicit: all uk+1 i must be solved simultaneously. Information from uk i−1, uk i , and uk i+1 are used at each time step in the computation of uk+1 i . 4. Solution is not significantly more complex than BTCS. 5. Like BTCS, the Crank-Nicolson methods is unconditionally stable for the heat equation. 6. Truncation error is O(∆t2 ) + O(∆x2 ). Time accuracy is better than BTCS or FTCS. ME 448/548: Crank-Nicolson Solution to the Heat Equation page 1
  • 3. The θ Method Evaluate the diffusion operator ∂2 u/∂x2 at both time steps tk+1 and time step tk, and use a weighted average uk+1 i − uk i ∆t = αθ " uk+1 i−1 − 2uk+1 i + uk+1 i+1 ∆x2 # + α(1 − θ) " uk i−1 − 2uk i + uk i+1 ∆x2 # (1) where 0 ≤ θ ≤ 1 θ = 0 ⇐⇒ FTCS θ = 1 ⇐⇒ BTCS θ = 1 2 ⇐⇒ Crank-Nicolson ME 448/548: Crank-Nicolson Solution to the Heat Equation page 2
  • 4. Crank-Nicolson Computational Molecule Solution is known for these nodes Crank-Nicolson scheme requires simultaneous calculation of u at all nodes on the k+1 mesh line t i i+1 i 1 i=1 nx k+1 k k 1 . . . . . . . . . . . . . . . . . . . . . x=L x=0 t=0, k=1 ME 448/548: Crank-Nicolson Solution to the Heat Equation page 3
  • 5. Compare Computational Molecules FTCS i i+1 i–1 k+1 k BTCS i i+1 i–1 k+1 k Crank-Nicolson i i+1 i–1 k+1 k ME 448/548: Crank-Nicolson Solution to the Heat Equation page 4
  • 6. Crank Nicolson Approximation to the Heat Equation Set θ = 1 2 in the formulation of the θ method. − α 2∆x2 u k+1 i−1 + 1 ∆t + α ∆x2 u k+1 i − α 2∆x2 u k+1 i+1 = α 2∆x2 u k i−1 + 1 ∆t − α ∆x2 u k i + α 2∆x2 u k i+1 (2) ME 448/548: Crank-Nicolson Solution to the Heat Equation page 5
  • 7. Crank-Nicolson System of Equations The system of equations has the same structure as BTCS          a1 b1 0 0 0 0 c2 a2 b2 0 0 0 0 c3 a3 b3 0 0 0 0 ... ... ... 0 0 0 0 cnx−1 anx−1 bnx−1 0 0 0 0 cnx anx                     uk+1 1 uk+1 2 uk+1 3 . . . uk+1 nx−1 uk+1 nx            =          d1 d2 d3 . . . dnx−1 dnx          (3) where the coefficients of the interior nodes (i = 2, 3, . . . , N − 1) are ai = 1/∆t + α/∆x 2 = 1/∆t − (bi + ci), bi = ci = −α/(2∆x 2 ), di = −ciu k i−1 + (1/∆t + bi + ci) u k i − biu k i+1. ME 448/548: Crank-Nicolson Solution to the Heat Equation page 6
  • 8. demoCN Code % --- Coefficients of the tridiagonal system b = (-alfa/2/dx^2)*ones(nx,1); % Super diagonal: coefficients of u(i+1) c = b; % Subdiagonal: coefficients of u(i-1) a = (1/dt)*ones(nx,1) - (b+c); % Main Diagonal: coefficients of u(i) at = (1/dt + b + c); % Coefficient of u_i^k on RHS a(1) = 1; b(1) = 0; % Fix coefficients of boundary nodes a(end) = 1; c(end) = 0; [e,f] = tridiagLU(a,b,c); % Save LU factorization % --- Assign IC and save BC values in ub. IC creates u vector x = linspace(0,L,nx)’; u = sin(pi*x/L); ub = [0 0]; % --- Loop over time steps for k=2:nt % --- Update RHS for all equations, including those on boundary d = - [0; c(2:end-1).*u(1:end-2); 0] ... + [ub(1); at(2:end-1).*u(2:end-1); ub(2)] ... - [0; b(2:end-1).*u(3:end); 0]; u = tridiagLUsolve(e,f,b,d); % Solve the system end ME 448/548: Crank-Nicolson Solution to the Heat Equation page 7
  • 9. Convergence of FTCS, BTCS and CN Truncation Errors Scheme Spatial Temporal FTCS ∆x2 ∆t BTCS ∆x2 ∆t C-N ∆x2 ∆t2 Reduce both dx and dt within the FTCS stability limit ------------- Errors ------------ nx nt FTCS BTCS CN 4 5 2.903e-02 5.346e-02 1.304e-02 8 21 6.028e-03 1.186e-02 2.929e-03 16 92 1.356e-03 2.716e-03 6.804e-04 32 386 3.262e-04 6.522e-04 1.630e-04 64 1589 7.972e-05 1.594e-04 3.984e-05 128 6453 1.970e-05 3.939e-05 9.847e-06 256 26012 4.895e-06 9.790e-06 2.448e-06 512 104452 1.220e-06 2.440e-06 6.101e-07 Reduce dt while holding dx = 9.775171e-04 (L=1.0, nx=1024) constant ------------- Errors ------------ nx nt FTCS BTCS CN 1024 8 NaN 2.601e-02 1.291e-03 1024 16 NaN 1.246e-02 2.798e-04 1024 32 NaN 6.102e-03 6.534e-05 1024 64 NaN 3.020e-03 1.570e-05 1024 128 NaN 1.502e-03 3.749e-06 1024 256 NaN 7.492e-04 8.154e-07 1024 512 NaN 3.742e-04 8.868e-08 1024 1024 NaN 1.871e-04 9.218e-08 ME 448/548: Crank-Nicolson Solution to the Heat Equation page 8
  • 10. Convergence of FTCS, BTCS and CN 10 −3 10 −2 10 −1 10 0 10 −7 10 −6 10 −5 10 −4 10 −3 10 −2 10 −1 ∆ x E(∆ x,∆ t) FTCS BTCS CN E ∝∆ x2 10 −3 10 −2 10 −1 10 0 10 −8 10 −7 10 −6 10 −5 10 −4 10 −3 10 −2 10 −1 ∆ t E(∆ x,∆ t) ∆ x = 9.8e−04 (constant) FTCS BTCS CN E∝∆ t E∝∆ t2 In the plot of truncation error versus ∆t (right hand plot), there is an irregularity at ∆t ∼ 3.9 × 10−3 . At that level of ∆t, and for the chosen ∆x (which is constant), the truncation error due to ∆x is no longer negligible. Further reductions in ∆t alone will not reduce the total truncation error. ME 448/548: Crank-Nicolson Solution to the Heat Equation page 9
  • 11. Truncation Error is Additive 10-4 10-3 10-2 10-1 100 t 10-12 10 -10 10-8 10-6 10-4 10-2 Error: ||u-u e || 2 nx = 400 nx = 800 nx = 1600 nx = 3200 nx = 6400 nx = 12800 Ideal The truncation error for the finite-difference schemes that we have explored so far are of the form ē = O(∆t p ) + O(∆x q ) For example, for the Crank-Nicolson scheme, p = q = 2. If ∆t is reduced while ∆x is held constant, the measured error is reduced until the point that the temporal truncation error is less than the spatial truncation error. ME 448/548: Crank-Nicolson Solution to the Heat Equation page 10
  • 12. Summary for the Crank-Nicolson Scheme • The Crank-Nicolson method is more accurate than FTCS or BTCS. Although all three methods have the same spatial truncation error (∆x2 ), the better temporal truncation error for the Crank-Nicolson method is a big advantage. • Like BTCS, the Crank-Nicolson scheme is unconditionally stable for the heat equation. • Like BTCS, a system of equations for the unknown uk i must be solved at each time step. The tridiagonal solver for the 1D heat equation obtains an efficient solution of the system of equations. • The Crank-Nicolson scheme is recommended over FTCS and BTCS. ME 448/548: Crank-Nicolson Solution to the Heat Equation page 11