College of Engineering and Computer Science Mechanical

advertisement
College of Engineering and Computer Science
Mechanical Engineering Department
ME 692 – Computational Fluid Dynamics
Spring 2002 Ticket: 57541 Instructor: Larry Caretto
Solutions to Second Homework Assignment
1.
The DuFort-Frankel finite-difference for the heat conduction equation is obtained by
considering three time steps. The time derivative at point n is obtained by a central
difference first derivative expression using data at times n-1 and n+1. The second order
space derivative is replaced by a term that looks like the usual second-order finitedifference expression for the space derivative. However, in the DuFort-Frankel method,
the term at the current space and time step, uin is replacd by an average of the currentspace-step values at the previous and future time step: u in-1 and uin+1.
a.
derive the finite-difference equation for this method.
b. determine the truncation error for this expression.
c.
explain why the method is explicit or implicit?
d. the property of consistency requires that the truncation error goes to zero as Δt
and Δx approach zero. Is the DuFort-Frankel method consistent if Δt and Δx
approach zero at a constant ratio of Δt to Δx.
To derive the finite difference method we start with the usual approach of writing the appropriate
finite difference expressions for the derivatives in the conduction equation at time step n, using a
central difference, and space step i. We use central differences for both finite-difference
expressions. This is similar to equation [3-27] in the notes for the Crank Nicholson method. The
only difference is that here we are expanding about time step n (not n + ½) and have a full time
step, Δt.
T
t
n
i
Ti n 1  Ti n 1

 O[( t ) 2 ]
2t
 2T
x 2
n
i
Ti n  Ti n  2Ti n

 O[( x) 2 ]
2
(x)
[A]
n
Following the problem statement, we replace the term Ti with the average of the temperatures at
the previous (n-1) and future (n+1) time steps. Doing this produces another truncation error as
shown in the Crank-Nicholson derivation, equation [3-29].
Ti n1  Ti n1
Ti 
 O[(t ) 2 ]
2
n
[B]
n
Making this substitution for Ti in equation [A], and substituting both derivative approximations
T
into the differential equation,
t
n
i

 2T
x 2
n
gives the following result.
i
Ti n 1  Ti n 1
T n  Ti n  Ti n 1  Ti n 1  O[( t ) 2 ]
 O[( t ) 2 ]   i
 O[( x) 2 ]
2
2t
(x)
Engineering Building Room 2303
E-mail: lcaretto@csun.edu
Mail Code
8348
Phone: 818-677-6448
Fax: 818-677-7062
[C]
Page 2
ME 692, L. S. Caretto, Spring 2002
Homework Two Solutions
We thus see that the truncation error for this method has the following leading terms. This
is the solution to part a.
 (t ) 2 
 DuFort  Frankel
2

O
[(

t
)
]

O
 O[( x) 2 ]

 Truncation Error 
2
(

x
)




[C]
We can write the finite difference equation as shown below if we ignore the truncation
error. This is the solution to part b.
Tkn 1  Tkn 1 Tkn1  Tkn1  Tkn 1  Tkn 1

2t
(x) 2
[D]
We can rewrite this as follows, using our usual definition of f = αΔt/(Δx) 2
Tkn 1 (1  2 f )  2 f (Tkn1  Tkn1 )  Tkn 1 (1  2 f )
[E]
We see that there is only one temperature at the future time step. Thus we conclude that the
DuFort-Frankel method is an explicit method to answer part c.
We see that the truncation error contains a term that involves the ratio of Δt/Δx. If we let each of
these approach zero in a constant ratio, we will maintain a constant term in our truncation error.
This violates the consistency requirement that the finite difference equation should approach the
differential equation as all the step sizes approach zero. To provide consistency, we must
have Δt approaching zero faster than Δx in the DuFort-Frankel method.
2.
Apply the DuFort-Frankel finite-difference expression to the solution of the conduction
equation for the same problem used in section three of the notes. Use Δx = 0.1 and Δt =
0.1, 0.01, and 0.001 with 0 ≤ x ≤ L = 1, and a maximum time of 1.
The DuFort-Frankel scheme is an explicit one, so its application should be simple. The only
problem is that it requires data at a previous time step (n-1), in addition to the current time
step(n), to obtain the results at the new time step (n+1). However, at the start of the problem, we
only have data for one time step (n = 0). Thus we need to use another method to take the first
time step. If f = αΔt/(Δx)2 ≤ 0.5, we can use an explicit first step; if f > 0.5, we must use an implicit
method for the first step.
The conduction program distributed last week uses a Crank-Nicholson first step for the DuFortFrankel method regardless of the size of f. The results shown below use an explicit method for
the first time step when f < 0.5 and a fully implicit method otherwise. (The Crank-Nicholson
method was not used because it produces unrealistic temperatures for Δt = 0.01.) For
computational purposes, equation [E] is rewritten to solve directly for the new temperature.
Tkn 1 
2f
(1  2 f ) n 1
(Tkn1  Tkn1 ) 
Tk
(1  2 f )
(1  2 f )
[E-2]
This shows that there are only two factors required to advance the solution beyond the first step
for which some other method is required. The values of these factors for the space and time
steps specified in this problem are shown in the table below.
Homework Two Solutions
ME 692, L. S. Caretto, Spring 2002
Page 3
Δt
Δx
f
2f
(1  2 f )
(1  2 f )
(1  2 f )
0.001
0.01
0.1
0.1
0.1
0.1
0.1
1
10
1/6
2/3
20/21
2//3
-1/3
-19/21
The initial steps for the DuFort-Frankel solutions as well as the final results are shown in the
tables below for the first five space locations. Locations 6 to 10 are symmetric with 0 to 4.
DuFort-Frankel Solution of the Conduction Equation
 = 1, Δx = 0.1, Δt = 0.001, f = 0.1, t max = 1 Explicit First Step
i=0
i=1
i=2
i=3
i=4
x = 0.00
x = 0.1
x = 0.2
x = 0.3
x = 0.4
t=0
1000
1000
1000
1000
1000
n=0
t = 0+
0
1000
1000
1000
1000
n=1
t = 0.001
0
900
1000
1000
1000
n=2
t = 0.002
0
833.3
983.3
1000
1000
n=3
t = 0.003
0
763.9
972.2
997.2
1000
n=4
t = 0.004
0
717.6
949.1
995.4
999.5
n=5
t = 0.005
0
667.4
933.6
989.6
999.2
n=6
t = 0.006
0
634.0
908.9
985.7
997.9
Gap in output here
n = 999 t = 0.999
0
0.02187 0.04168 0.05726 0.06744
n = 1000
t = 1.0
0
0.02170 0.04119 0.05681 0.06665
Exact
t = 1.0
0
0.02035 0.03871 0.05328 0.06263
Error
t = 1.0
0.00135 0.00248 0.00353 0.00402
Rel Error
t =1.0
6.62%
6.42%
6.62%
6.42%
n=0
n=1
n=2
n=3
n=4
n=5
n=6
DuFort-Frankel Solution of the Conduction Equation
 = 1, Δx = 0.1, Δt = 0.01, f = 1, tmax = 1 Implicit First Step
i=0
i=1
i=2
i=3
i=4
x = 0.00
x = 0.1
x = 0.2
x = 0.3
x = 0.4
t=0
1000
1000
1000
1000
1000
t = 0+
0
1000
1000
1000
1000
t = 0.01
0
617.9
853.7
943.1
975.6
t = 0.02
0
235.8
707.3
886.2
951.2
t = 0.03
0
265.6
463.4
791.3
910.6
t = 0.04
0
230.4
468.8
620.6
837.4
t = 0.05
0
224.0
412.8
607.0
704.6
t = 0.06
0
198.4
397.8
538.1
660.9
I=5
x=0.5
1000
1000
1000
1000
1000
1000
999.8
999.7
0.07077
0.07022
0.06586
0.00436
6.62%
I=5
x=0.5
1000
1000
983.7
967.5
940.4
891.6
803.1
642.3
Gap in output here
n = 99
n = 1000
Exact
Error
Rel Error
t = 0.99
t = 1.0
t = 1.0
t = 1.0
t =1.0
0
0
0
0.00790
0.00671
0.02035
0.01364
67.0%
0.01424
0.01346
0.03871
0.02525
65.2%
0.02068
0.01756
0.05328
0.03572
67.0%
0.02304
0.02178
0.06263
0.04085
65.2%
0.02556
0.02171
0.06586
0.04415
67.0%
Page 4
ME 692, L. S. Caretto, Spring 2002
n=0
n=1
n=2
n=3
n=4
n=5
n=6
n=7
N=8
n=9
n = 10
Exact
Error
Rel Error
Homework Two Solutions
DuFort-Frankel Solution of the Conduction Equation
 = 1, Δx = 0.1, Δt = 0.1, f = 10, tmax = 1 Implicit First Step
i=0
i=1
i=2
i=3
i=4
x = 0.00
x = 0.1
x = 0.2
x = 0.3
x = 0.4
t=0
1000
1000
1000
1000
1000
t = 0+
0
1000
1000
1000
1000
t = 0.01
0
243.8
412.0
521.4
583.0
t = 0.02
0
-512.3
-175.9
42.9
166.0
t = 0.03
0
-388.2
-819.9
-481.2
-290.7
t = 0.04
0
-317.3
-668.8
-1096.5 -826.8
t = 0.05
0
-285.8
-604.7
-989.0
-1485.9
t = 0.06
0
-288.8
-609.0
-998.9
-1496.3
t = 0.7
0
-321.4
-679.3
-1110.1 -1665.0
t = 0.8
0
-385.7
-812.4
-1328.9 -1239.5
t = 0.9
0
-482.9
-1018.3
-949.7
-917.6
t = 1.0
0
-620.8
-629.4
-641.4
-641.9
t = 1.0
0
0.0204
0.0387
0.0533
0.0626
t = 1.0
620.9
629.4
641.4
642.0
t =1.0
30508
16260
12039
10250
I=5
x=0.5
1000
1000
602.9
205.7
-229.2
-739.9
-1367.5
-2160.9
-1612.7
-1216.3
-901.7
-647.3
0.0659
647.4
9830
These results have a reasonable error for Δt = 0.001, but the relative error is high for Δt = 0.01.
For Δt = 0.01, f = 1, but we still obtain a solution even though we are using an explicit method
with f = 1. This case illustrates the fact that even though a method may be stable, a smaller time
step than that required by the stability limit may be required to obtain accurate results. The
calculations with Δt = 0.1 lead to a physically unrealistic result. In the solution to the next problem
we will show that the DuFort-Frankel method is unconditionally stable according to a Von
Neumann analysis. However, this example shows that unconditionally stable algorithms may
give strange results if the appropriate step sizes are not used.
3.
Analyze the stability of the DuFort-Frankel scheme.
We will use the Von Neumann stability analysis which examines a typical Fourier component
 kn  e ant ei m ( x0  kx)
n
We then substitute the typical Fourier component,  k for
Tkn
[F]
in the finite difference equation
(1  2 f )e a ( nt  t ) e i m ( x 0  kx )  2 fe ant e i m ( x 0  kx  x )
2 fe ant e i m ( x 0  kx  x )  (1  2 f )e a ( n 1) t e i m ( x 0  kx )
[G]
Following the Von Neumann approach, we divide through by common factor
ant i m ( x0  kx )
of e
e


(1  2 f )e at  2 f ei m x  e i m x  (1  2 f )e at
[H]
We then use the relationship for complex exponentials that eiθ+e-iθ = 2cos(θ) and the definition of
the growth factor, G, as eaΔt to rewrite equation [H] as follows
Homework Two Solutions
ME 692, L. S. Caretto, Spring 2002
(1  2 f )G  4 f cos( m x)  (1  2 f )
Page 5
1
G
[I]
(1  2 f )G 2  4 f cos(  m x)G  (1  2 f )  0
[J]
We find the value of G from the usual formula for the solution of a quadratic equation.
G
4 f cos(  m x)  16 f 2 cos 2 (  m x)  4(1  2 f )(1  2 f )
[K]
2(1  2 f )
We can simplify the term in the square root as follows.
16 f 2 cos2 (  m x)  4(1  2 f )(1  2 f ) 
16 f 2 cos2 (  m x)  4(1  4 f 2 )  4  16 f 2 1  cos2 (  m x) 
4  16 f 2 sin 2 (  m x)


[L]
This gives the following solution for G.
G
4 f cos(  m x)  4  16 f 2 sin 2 (  m x)
2(1  2 f )

2 f cos(  m x)  1  4 f 2 sin 2 (  m x)
1 2 f
[M]
G may be real or complex depending if the sign of the square root argument is positive or
negative. We will get a negative argument if
1  4 f 2 sin 2 (  m x)  0
1
f 
2 sin(  m x)
[N]
Stability depends on having |G| <= 1. If G is complex, we must have G *G <=1. Using the
equation just derived for G, we obtain the following stability requirement for complex G.
G *G 


4 f 2 cos 2 (  m x)  1  4 f 2 sin 2 (  m x) 1  4 f 2 1  2 sin 2 (  m x)

1
(1  2 f ) 2
(1  2 f ) 2
[O]
The sin2(βmΔx) term ranges from zero to one. Below we show that the stability condition is
satisfied in both these limits; this it is satisfied for all values of f that produce a complex growth
factor.
1 4 f 2
1
(1  2 f ) 2
1 4 f 2
2
*
When sin (  m x)  0, G G 
1
(1  2 f ) 2
When sin 2 (  m x)  1, G *G 
[P]
When f is less than or equal to [2 sin(βmΔx)]-1, the growth factor is real. In these cases, the
argument of the square root is one minus a positive number. This positive number must be less
than one to maintain a real solution. Thus the square root in the real case will always be less
Page 6
ME 692, L. S. Caretto, Spring 2002
Homework Two Solutions
than or equal to one. The limiting condition will be when the square root term is +1. In this case
the growth factor inequality becomes
G
1  2 f cos(  m x)
1
1 2 f
[Q]
We see that this will be satisfied for any values of f since cos(β mΔx) is always less than one.
Thus, the stability analysis shows that any value of f produces a growth factor whose magnitude
is less than or equal to one, regardless of whether the growth factor is real or complex. We
therefore conclude that the DuFort-Frankel method is unconditionally stable. (But we
remember the results of our sample calculations in problem two!)
Download