Numerical Models For Engineering: Finite Difference For 1-D Initial Value Problems
Numerical Models For Engineering: Finite Difference For 1-D Initial Value Problems
Explicit method;
Implicit method;
Crank-Nicholson.
Matlab implementation;
Conclusions.
n +1 n
∂2T Ti −1 − 2Ti + Ti +1
∂T T − T ≃
2
∂θ
≃
∆θ ∂x ∆x 2
It is clear that the LHS refers to the node for which the
equation is discretized in space
The RHS can be calculated at different instants of time:
θn+1 or θn (these will be referred to as instants “n” and
“n+1”);
∂T T n +1 − T n
=
∂θ ∆θ
Tn
n
(Qɺ n et ) i
θn θn+1 θ
∆θ
∆θ
∆x ∆x
i = 1,..., M − 1
a ∆θ
Tin + 1 = Tin +
∆x 2
(Tin−1 − 2Tin + Tin+ 1 )
We can write:
2a∆θ n a∆θ
Ti n+1 = 1 −
∆x 2
⋅
i
T +
∆x 2
⋅ ( T n
i −1 + Ti +1 )
n
i = 1,..., M − 1
0 1 0 T3 − T3 = − a −1 2 −1 T n + a ⋅ ∆θ
n
∆θ ∆x 2 3 ∆x 2 0
0 0 1 n +1 0 −1 2 T4n T n
T4 − T4n 5
∆θ
⇓
T n +1 − T n n n
[M ] = − [ K ]{T } + {b}
∆θ
so we can write:
{T }
n +1
( −1
) n −1
= 1 − [ M ] ⋅ ∆θ [ K ] {T } + [ M ] ∆θ {b}
n
i-1 i i+1
After ∆θ
This condition corresponds to a limitation on the primary
n +1 n +1
coefficient on RHS; this coefficient should assume a positive Ti−1 Ti n +1 Ti+1
value to achieve a stable solution with explicit method:
1 ∆x 2 i-1 i i+1
1 − 2 ⋅ Foi ≥ 0 ⇔ Foi ≤ ⇔ ∆θ ≤
2 2a
Therefore, only ∆x is fixed.
n +1 − T n
Ti Ti − 1 − 2Ti + Ti + 1 n + 1 Tin−+1 1 − 2Tin + 1 + Tin++1 1
i
= a
= a
∆θ ∆x 2 ∆x 2
T in + 1 − T in a
∆θ
=
2
(T i n−+1 1 − 2T i n + 1 + T i n++1 1 )
∆x
T n +1 − T n T0
( ρcV )i i i
= Qɺ i
n +1
= Qɺ in−+1,1i − Qɺ in,i++11
∆θ
TL
T n + 1 − T n
n +1 n +1
{ } { }
M = − K T + b
∆θ
⇓
n +1 n n +1
( M + ∆θ K ){T } = M {T } + ∆θ {b }
posing:
A = M + K
we get:
n +1 −1 n −1 n +1
{T } = A M {T } + A ∆θ {b }
T n +1 − T n
( ρcV )i i i
= ξ ⋅ Qɺ i
n +1
+ ( 1 − ξ ) ⋅ Qɺ in with 0<ξ<1
∆θ
for ξ=1/2 the classical Crank-Nicholson method is obtained, while for ξ=1 and
ξ=0, the implicit method and the explicit method are obtained, respectively.
A.A. 2014/2015 NUMERICAL MODELS FOR ENGINEERING PROF. N. MASSAROTTI 17
Analysis of stability
By considering a general spatial discretization with M node and by
introducing the matrix [K]:
1 − 2 ⋅ ( 1 − ξ ) ⋅ Fo ( 1 − ξ ) ⋅ Fo
( 1 − ξ ) ⋅ Fo 1 − 2 ⋅ ( 1 − ξ ) ⋅ Fo ( 1 − ξ ) ⋅ Fo
( 1 − ξ ) ⋅ Fo 1 − 2 ⋅ ( 1 − ξ ) ⋅ Fo ( 1 − ξ ) ⋅ Fo
[K ] =
( 1 − ξ ) ⋅ Fo 1 − 2 ⋅ ( 1 − ξ ) ⋅ Fo ( 1 − ξ ) ⋅ Fo
( 1 − ξ ) ⋅ Fo 1 − 2 ⋅ ( 1 − ξ ) ⋅ Fo (1 − ξ ) ⋅ Fo
( 1 − ξ ) ⋅ Fo 1 − 2 ⋅ ( 1 − ξ ) ⋅ Fo
{e }
n +1
(
= K ⋅ M
−1
)
⋅ {e }
n
⇓
n
{e }
n +1
(
= K ⋅ M
−1
) ⋅ {e }
0
We can demonstrate that stability conditions are the same of that ones
calculated for the previous case.
0 ≤G ≤ 1
T1n +1 = λ ⋅ T1n
G E = 1 − 2 ⋅ F o
1 − F o
G S =
1 + F o
1
G I =
1 + 2 ⋅ F o
∂T ∂ 2T
= a 0 ≤ x ≤ L; θ > 0
∂θ 2
∂x
Algorithm implementation
n +1 n
{T } − {T } n +1 n +1
M
= K SFD ⋅ {T } + {b }
∆θ
Solution plot
Algorithm implementation
∂T ∂ 2T
= a 0 ≤ x ≤ L; θ > 0
∂θ ∂x 2
Neumann BC ∂T (L, θ)
=0 θ>0
∂x L=0.7 m
∂T ∂ 2T
= a 0 ≤ x ≤ L; θ > 0
∂θ 2
∂x
T0 TL
Initial Cond. T (x , 0) = Tb = 0 0≤x ≤L