Академический Документы
Профессиональный Документы
Культура Документы
http://www.nd.edu/~gtryggva/CFD-Course/!
Warm-up:!
One-Dimensional
Conservation
Equation!
Grtar Tryggvason!
Spring 2013!
f
f
2 f
+U
=D 2
t
x
x
f (x, t = 0) = Asin(2kx)
It can be verified by direct substitution that the solution
is given by:!
which is a decaying
traveling wave!
f (t)
U (x)
x
Given f at the inlet as a function of time (as well as
everywhere at time zero), how do we predict the f(t,x)? !
Amount of f in
the control
volume at the
beginning of
the time
interval t!
Amount of
f that
flows into
the control
volume
during t!
Amount of
f that flows
out of the
control
volume
during t!
U (x)
f (t)
fTotal =
f dx f av x
()
f av t + t f av t x = t Fin Fout
()
f av t + t f av t x = t Fin Fout
Divide by tx!
!
()
f av t + t f av t
= Fout Fin
t
x
or:!
f av
F
=
t
x
Taking the
limit, we get:!
f F
+
=0
t x
F: Flux of f!
f F
+
=0
t x
Taking the flux to be the sum of advective and
diffusive fluxes:!
F = Uf F
f
x
f
f
2 f
+U
=D 2
t
x
x
Finite Difference
Approximations of
the Derivatives!
f (t + 2t)
t
t
The!
Time Derivative!
f (t + t)
f(t,x-h) f(t,x) f(t,x+h) !
h
f (t)
Time derivative!
The Time Derivative is found using a FORWARD
EULER method. The approximation can be found by
using a Taylor series
f(t+t,x)
t
f(t,x)!
h
The Spatial!
First Derivative!
f (t + t) = f (t) +
f (t)
2 f (t) t 2
t +
+
t
t 2 2
+
t
t
t 2 2
f (x)
2 f (x) h 2 3 f (x) h 3 4 f (x) h 4
f (x + h) = f (x) +
h+
+
+
+
x
x 2 2
x 3 6
x 4 24
f (x h) = f (x)
f (x)
2 f (x) h 2 3 f (x) h 3 4 f (x) h 4
h+
x
x 2 2
x 3 6
x 4 24
f (x + h) f (x h) = 2
f (x)
3 f (x) h 3
h+2
+
x
x 3 6
f (x + h) f (x h) = 2
f (x)
3 f (x) h 3
h+2
+
x
x 3 6
f (x) f (x + h) f (x h) 3 f (x) h 2
=
+
x
2h
x 3 6
The Spatial!
Second Derivative!
f (x + h) = f (x) +
f (x)
2 f (x) h 2 3 f (x) h 3 4 f (x) h 4
h+
+
+
+
x
x 2 2
x 3 6
x 4 24
f (x h) = f (x)
f (x)
2 f (x) h 2 3 f (x) h 3 4 f (x) h 4
h+
x
x 2 2
x 3 6
x 4 24
f (x + h) + f (x h) = 2 f (x) + 2
f 2 (x) h 2
4 f (x) h 4
+2
+
2
x
2
x 4 24
f (x + h) + f (x h) = 2 f (x) + 2
f 2 (x) h 2
4 f (x) h 4
+2
+
2
x
2
x 4 24
+
x 2
h2
x 4 12
f
f
2 f
+U
=D 2
t
x
x
f j = f (t, x j )
f jn+1
f jn+1
f jn+1
= f (t + t, x j )
f jn1
= f (t, x j + h)
f jn f jn+1
h
f jn1 = f (t, x j h)
n
n
2 f
f
f
+U
= D 2
t j
x j
x j
f jn+1
f jn1
f jn f jn+1
h
gives!
f fj
f
= j
+ O(t)
t j
t
n
f jn = f (t, x j )
f jn+1 = f (t + t, x j )
n+1
f
f
2 f
+U
=D 2
t
x
x
gives!
f f j 1
f
= j +1
+ O(h2 )
x j
2h
n
f jn+1 = f (t, x j + h)
f jn1 = f (t, x j h)
f jn+1 fjn
f jn+1 fjn1
fjn+1 2 f jn + f jn1
+U
=D
+ O(t, h 2 )
t
2h
h2
2 f
f jn+1 2 f jn + f jn1
2
=
+ O(h )
2
x j
h2
Solving for the new value and dropping the error terms yields!
fj
n+1
= fj
n
Ut n
Dt n
n
n
n
( f f j 1) + 2 ( f j +1 2 f j + f j 1)
2h j +1
h
f jn+1 = f jn
Ut n
Dt
( f j +1 f jn1) + 2 ( f jn+1 2 f jn + f jn1)
2h
h
f jn+1
f jn1
f jn f jn+1
h
Example!
Evolution
for!
U=1;
D=0.05;
k=1
N=21
t=0.05
Accuracy!
Movie: adv1!
Exact!
Numerical!
Evolution
for!
U=1;
D=0.05;
k=1
N=21
t=0.05
m=11; time=0.50!
2
1.5
1
0.5
0
-0.5
Exact!
-1
-1.5
Numerical!
-2
10
12
14
16
18
20
m=21; time=0.50!
Repeat with
a smaller
time-step!
t=0.025
N=21
m=41; time=0.50!
Repeat with
a smaller
time-step!
t=0.0125
N=21
1.5
1.5
0.5
0.5
-0.5
-0.5
-1
Exact!
-1
Exact!
-1.5
Numerical!
-2
-1.5
Numerical!
2
10
12
14
16
18
20
-2
10
12
14
16
18
20
m=1001; time=0.50!
2
U=1;
D=0.05;
k=1
N=200
t=0.0005
1.5
1
0.5
0
-0.5
-1
Exact!
-1.5
Numerical!
-2
20
40
60
80
100
120
140
160
180
200
time=0.50!
Numerical!
E=h
( f
j =1
N=11; E = 0.1633!
N =21; E = 0.0403!
N =41; E = 0.0096!
N =61; E = 0.0041!
N =81; E = 0.0022!
N =101; E = 0.0015!
N =121; E = 0.0011!
N =161; E = 9.2600e-04!
fexact )2
time=0.50!
100
10-1
-2
E
10
10-3
10-4 0
10
10
10
10
1/ h
1
E = Ch 2 = C
h
10-1
-2
E
10
1 2
1
ln E = ln C = lnC 2ln
h
h
Error!
Truncation!
Total!
Roundoff!
Number of Steps, N = 1/h!
100
2!
1!
10-3
dt=0.0005!
!
N=11 to N=161!
10-4 0
10
10
1/ h