Sunteți pe pagina 1din 8

Computational Fluid Dynamics

http://www.nd.edu/~gtryggva/CFD-Course/!

Computational Fluid Dynamics



Wave equation!

2 f
2 f
c2 2 = 0
t 2
x

Wave Equation!

First write the equation as a system of first order equations!


Introduce!
yielding!

Grtar Tryggvason!
Spring 2013!

Computational Fluid Dynamics



Wave equation!
To find the characteristics!

u 2 v
c
=0
t
x
v u
=0
t x


det A T I = det
2
c
= c

We can also use!

1
b b 2 4ac with!
2a

v
u

l1
c2
= 0
t

x
v u

+l2
= 0
t x

from the pde!


since!

2 f 2 f
=
tx xt

dt
1 dt
1
=+ ;
=
dx
c dx
c

dt
1
=+
dx
c

P

dt
1
=
dx
c

b = 0; a = 1; c = c 2

Computational Fluid Dynamics



Wave equation!
To find the solution we need
to find the eigenvectors!

u 2 v
c
=0
t
x
v u
=0
t x

Two characteristic lines!

1
2
2
= c =0

f
f
; v= ;
t
x

Computational Fluid Dynamics



Wave equation!

2
x
0
c
+
=0

1 0 v

u
t
v
t

u=

= c

2
c

l1
=0

l2

Take l1=1!

For! = +c

c l1 l2 = 0 l2 = c

For! = c

+c l1 l2 = 0 l2 = +c

Computational Fluid Dynamics



Wave equation!
For!

= +c

l1 = 1 l2 = c
u 2 v
v u

1 c
= 0 c = 0
t
t x

u
u v
v
+ c c + c = 0
t
x t
x
du
dv
c
= 0 on
dt
dt
Similarly:!
For! = c

dx
= +c
dt

l1 = 1 l2 = +c
du
dv
dx
+c
= 0 on
= c
dt
dt
dt

Add the
equations!

Relation
between the
total derivative
on the
characteristic!

Computational Fluid Dynamics



Wave equation!

du
dv
c
= 0 on
dt
dt

dx
= +c
dt

du
dv
+c
= 0 on
dt
dt

dx
= c
dt

The general solution can


therefore be written as:!

f ( x,t ) = r1 ( x ct ) + r2 ( x + ct )
where!

For constant c!

dr1
dx
= 0 on
= +c where r1 = u cv
dt
dt
dr2
dx
= 0 on
= c where r2 = u + cv
dt
dt

Computational Fluid Dynamics



Wave equation-general!
Two characteristic lines!

f
f
r1 ( x ) = c
t
x t= 0
f
f
r2 ( x ) = + c
t
x t= 0

Can also be verified by direct substitution!

r1 and r2 are called the Rieman invariants!

Computational Fluid Dynamics



Wave equation!

Computational Fluid Dynamics


dt
1 dt
1
=+ ;
=
dx
c dx
c

Domain of !
Influence!
dt
1
=+
dx
c

P

Domain of !
Dependence

Ill-posed
problems!

dt
1
=
dx
c

Computational Fluid Dynamics



Ill-posed Problems!

Consider the initial value problem:!

2 f
2f
2 =
t
x 2
This is simply Laplaces equation!

2 f 2 f
+
=0
t 2 x 2
which has a solution if f/t or f are given on
the boundaries!

Computational Fluid Dynamics



Ill-posed Problems!

Here, however, this equation appeared as an initial


value problem, where the only boundary conditions
available are at t = 0. Since this is a second order
equation we will need two conditions, which we may
assume are that f and f/x are specified at t =0.!

Computational Fluid Dynamics



Ill-posed Problems!

Computational Fluid Dynamics



Ill-posed Problems!

d 2 ak
= k 2 ak
dt 2

The general solution can be written as:!

f ( x,t ) = ak (t)e

ikx

where the as depend


on the initial conditions!

Look for solutions of the type:!

f = ak (t)e ikx
Substitute into:!

2 f 2 f
+
=0
t 2 x 2

to get:!

d 2 ak
= k 2 ak
dt 2

Computational Fluid Dynamics



Ill-posed Problems!
Long wave with short wave perturbations!

General solution!

ak (t) = Ae kt + Bekt

A, B

determined by initial conditions ! a (0);

ika(0)

Generally, both A and B are non-zero!


Therefore:! a (t )

as!

Ill-posed Problem!

Computational Fluid Dynamics



Ill-posed Problems!
Similarly, it can be shown that the diffusion
equation with a negative diffusion coefficient!

f
2 f
= D 2 ; D<0
t
x
has solutions with unbounded growth rate for high wave
number modes and is therefore an ill-posed problem!

Computational Fluid Dynamics



Ill-posed Problems!
Ill-posed problems generally appear when the initial or
boundary data and the equation type do not match.!
!
Frequently arise because small but important higher order
effects have been neglected!
!
Ill-posedness generally manifests itself in the exponential
growth of small perturbations so that the solution does not
depend continuously on the initial data !
!
Inviscid vortex sheet rollup, multiphase flow models and
some viscoelastic constitutive models are examples of
problems that exhibit ill-posedness. !

Computational Fluid Dynamics


Classical Methods!
for Hyperbolic!
Equations!

Computational Fluid Dynamics



Methods for Advection!

u 2 v
c
=0
t
x
v u
=0
t x

The wave equation:!

2 f
2 f
c2 2 = 0
t 2
x

Write as:!

In general:!

u
t
v
t

a
a
+ 11 12
a21 a22

Computational Fluid Dynamics


u
x
v
x

Forward in Time,
Centered in Space
(FTCS) and
Upwind!

=0

Most of the issues involved can be addressed by examining:!

f
f
+U =0
t
x

Computational Fluid Dynamics



Methods for Advection!

Computational Fluid Dynamics



Methods for Advection!

We will start by examining the linear advection equation:!

f
f
+U
=0
t
x

f
f
+U
=0
t
x

A simple forward in time, centered in space


discretization yields!

The characteristic for this equation are:!

dx
= U;
dt

df
= 0;
dt

t
f

Showing that the


initial conditions are
simply advected by a
constant velocity U!

fj

n+1

= fj
n

t
n
n
U ( f j +1 f j 1)
2h

n+1

x

n

j-1

Computational Fluid Dynamics



Methods for Advection!

j+1

Computational Fluid Dynamics



Methods for Advection!
Another scheme for!

f
f
+U
=0
t
x

This scheme is O(t, h2) accurate, but a stability


analysis shows that the error grows as!

n+1
Ut
= 1 i
sin kh
n
2h
Since the amplification
factor has the form 1+i()
the absolute value of this
complex number is always
larger than unity and the
method is unconditionally
unstable for this case.!

n+1

A simple forward in time but upwind in space


discretization yields!

f jn+1 = f jn
Ut
sinkh
2h

Flow direction!

This scheme
is O(t, h)
accurate. !

n+1

n

t
U ( f jn f jn1)
h

j-1

Computational Fluid Dynamics



Methods for Advection!

Computational Fluid Dynamics



Methods for Advection!

To examine the stability we use the von Neumans method:!


!
The
evolution of the error is governed by:!

U
+ ( nj nj 1) = 0
t
h
n
n ikx j
Write the error as:! j = e
n+1
j

n
j

n+1 n
n
+ U (1 e ikh ) = 0
t
h
Amplification factor!

Or:! G = 1 + e

ikh

G = 1 + eikh ,

Ut
h

Im(G)

Ut
=
h
Need to find when! G < 1

Ut
1
h

Stable!

This restriction was first


derived by Courant, Fredrik,
and Levy in 1932, and is
usually called the Courant
condition, or the CFL
condition. !

Computational Fluid Dynamics



Methods for Advection!

kh
1

1-

Computational Fluid Dynamics



Methods for Advection!

Another way: Find the absolute value of the amplification factor!


G = 1 + eikh = 1 + cos kh i sin kh

The CFL condition implies that a signal has to travel


less than one grid spacing in one time step!

G = (1 + cos kh ) + 2 sin 2 kh
2

Stability condition: <1!

n +1
Ut
= 1
(1 eikh )
n
h

n +1
G = n = 1 (1 eikh ),

Graphically:!

Ut h

= (1 ) + 2(1 ) cos kh + 2 cos2 kh + 2 sin 2 kh


2

Allowable characteristics!

= (1 ) + 2(1 ) cos kh +
2

= 1 2 + 2 + 2(1 ) cos kh

n+1

G = 1 2 (1 )
2

if cos kh = 0

if cos kh = 1

G =1
G = 1 ( 4 3 )
2

Flow direction!

1!

if cos kh = 1

G 1

Computational Fluid Dynamics



Methods for Advection!

The Upwind Scheme!


For the linear advection equation:!

f jn+1 = f jn

f
f
+U =0
t
x

t
U ( f jn f jn1)
h

Flow direction! n+1



U

n

j-1

O(t, h)
accurate. !

Ut
1
h

cos kh = 1

1!

if

cos kh = 0

j-1

Not allowable characteristics!

Computational Fluid Dynamics



Methods for Advection!
dt=0.25*h!

1.5
Although the
upwind
Upwind
method is
1
exceptionally
robust, its low
accuracy in
0.5
space and
time makes it
unsuitable for
0
most serious
computations !
-0.5

20

40

60

80

Computational Fluid Dynamics



Methods for Advection!

Computational Fluid Dynamics


Finite Volume point of view:!

f jn +1 = f jn

t n
t
n
n
n
(F j +1/ 2 F j1/
U( f jn f j1
)
2) = f j
h
h
n
F j1/ 2=Uf j1

F j +1/ 2=Uf jn

f j 1
fj

f j +1
x!

xj-1/2 xj+1/2 !

Generalized Upwind Scheme (for both U > 0 and U < 0 )!


Ut n
n
f jn +1 = f jn
( f j f j1
), U > 0
h
Ut
f jn +1 = f jn
( f jn+1 f jn ), U < 0
h
1
1
+

Define:! U = (U + U ), U = (U U )
2
2
The two cases can be combined into a single expression:!
t
n
f jn +1 = f jn [U + ( f jn f j1
) + U ( f jn+1 f jn )]
h
+

Or, substituting! U , U
U t n
t
n
n
f jn +1 = f jn U ( f jn+1 f j1
)+
( f j +1 2 f jn + f j1
)
2h
2h
Uh
Dnum =
central difference + numerical viscosity!
2

Computational Fluid Dynamics


Computational Fluid Dynamics



Methods for Advection!
Implicit (Backward Euler) Method!

f jn +1 f jn
t

Other First Order Schemes!

U n +1
(f j +1 f jn+11 )= 0
2h

- Unconditionally stable!
- 1st order in time, 2nd order in space!
- Forms a tri-diagonal matrix (Thomas algorithm)!

U n +1 1 n +1 U n +1 1 n
f j +1 +
fj
f j 1 =
fj
2h
t
2h
t
a j f jn++11 + d j f jn +1 + b j f jn+11 = C j

Computational Fluid Dynamics



Methods for Advection!

Computational Fluid Dynamics


Lax-Fredrichs method!

f jn +1

1
2

(f

n
j +1

+ f jn1

)+ U (f
2h

n
j +1

f jn1 = 0

- stable for < 1!


- 1st order in time, 1nd order in space!
- Conditionally consistent!
Error term:!

Uh 1
Uh 2

(1 2 )f xxx
f xx +
2
3

Ut
h
h
h2
=
Ut

Second Order Schemes!

Computational Fluid Dynamics



Methods for Advection!

Computational Fluid Dynamics



Methods for Advection!

Leap Frog Method!

Lax-Wendroffs Method (LW-I)!

The simplest stable second-order accurate (in time) method:!

f n +1 f jn 1
f
= j
+ O(t 2 )
t
2t
Ut n
(f j +1 f jn1 )
f jn +1 = f jn 1
h

Modified equation!

f
f Uh 2 2
( 1)f xxx +
+U
=
t
x
6

- Stable for ! < 1


- Dispersive (no dissipation) error will not damp out!
- Initial conditions at two time levels !
- Oscillatory solution in time (alternating) !

Ut
h

First expand the solution in time!

f (t + t ) = f (t ) +

f
2 f t 2 3 f t 3
t + 2
+ 3
+
t
t 2
t 6

Then use the original equation to rewrite the time derivatives!

f
f
= U
t
x
2 f
f
f
f
2 f
= = U = U
=U2 2
t 2 t t
t x
x t
x

Computational Fluid Dynamics



Methods for Advection!

Computational Fluid Dynamics



Methods for Advection!

Substituting!

Two-Step Lax-Wendroffs Method (LW-II)!

f
2 f t 2
f (t + t ) = f (t ) U
t + U 2 2
+ O(t 3 )
x
x 2

LW-I into two steps:!

f jn++11/ /22 ( f jn+1 + f jn ) / 2


t / 2

Using central differences for the spatial derivatives!

Ut n
U t
f jn +1 = f jn
( f j +1 f j1n ) + 2h 2
2h
2

(f

n
j +1

n
2 f jn + f j1
)

2nd order accurate in space and time!


Stable for!

Ut
<1
h

n +1
j

=0

=0

Step 1 (Lax)!
Step 2 (Leapfrog)!

Computational Fluid Dynamics



Methods for Advection!
Second-Order Upwind Method!

Similar to LW-II, without ! j + 1 / 2, j 1 / 2

- A fractional step method!


!- Predictor: forward differencing!
!- Corrector: backward differencing!
-For linear problems, accuracy and stability !
properties are identical to LW-I. !

n +1 / 2
j 1 / 2

For the linear equations, LW-II is identical to LW-I!

MacCormack Method!

t n
(f j +1 f jn )
h
1
t

f jn +1 = f jn + f jt U (f jt f jt1 )
2
h

+U

n +1 / 2
j +1 / 2

f jn+1 f jn

- Stable for U
! t / h < 1
- Second order accurate in time and space !

Computational Fluid Dynamics



Methods for Advection!

f jt = f jn U

n
j

+U

Warming and Beam (1975) Upwind for both steps!


Predictor!

f jt = f jn U

Corrector!

n+1
j

t n
(f j f jn1 )
h

Predictor!

Corrector!

1
t t
t n
= f jn + f jt U
f f jt1 U
f 2 f jn1 + f jn 2
2
h j
h j

Combining the two:!

1
f jn+1 = f jn f jn f jn1 + ( 1) f jn 2 f jn1 + f jn 2
2
- Stable if! 0 2
- Second-order accurate in time and space !

Computational Fluid Dynamics



Methods for Advection!

Computational Fluid Dynamics



Summary!

The one-step Lax-Wendroff is not easily extended to


non-linear or multi-dimensional problems. The split
version is.!
!
In the Lax-Wendroff and the MacCormack methods
the spatial and the temporal discretization are not
independent.!
!
Other methods have been developed where the time
integration is independent of the spatial discretization,
such as the Beam-Warming and various Runge-Kutta
methods!

f t + Uf x = 0
FTCS!

f jn +1 f jn
t

+U

f jn+1 f jn1

Implicit!

f jn +1 f jn
t

+U

+U

(f

f jn f jn1
h

n +1
j +1

t
+U

Computational Fluid Dynamics



Summary!

f jn +1 f jn 1
2t

f jn +1 f jn

Lax-Wendroff I!

t
U t
2

Lax-Wendroff II!

+U

(f

f jn+1 f jn1

+U

n
j +1

2h

(f

t / 2

t
f jt f jn

MacCormack!

t
f

n +1
j

+U
+U

t
j

+U

=0

f jn+1 f jn

(f

n
j +1

f jn )
h

+U

(f

t
j

=0

Uh 2
1 2 f xxx
6
Uh 3

1 2 f xxxx
8

=0

Stable for!
! 1

Same as LW-I!

Stable for!
! 1

Same as LW-I!

Stable for!
! 1

=0

f jt1 )
h

U 2 t
1
1

f xx Uh 2 + U 3 t 2 f xxx
2
3
6

Unconditionally!
Stable!

Uh 1
Uh 2

(1 2 )f xxx
f xx +
2
3

Conditionally
consistent!
Stable for ! 1

f jn+11 )

=0

(f

n
j +1

f jn1 )

2h

=0

Computational Fluid Dynamics



Summary!

Stable for!
!1

=0

f jn++11/ /22 f jn+11/ /22

(f + f )/ 2
n
j

f jn1 )

2h 2

f jn++11/ /22 ( f jn+1 + f jn ) / 2

f jn +1 f jn

n
j +1

2h
2 f jn + f jn1 )

Stable for!
! 1

f t + Uf x = 0

Uh 2 2
( 1)f xxx
6

=0

Uh
(1 )f xx
2
Uh 2

22 3 + 1 f xxx
6

2h

f t + Uf x = 0
Leap Frog!

=0

f jn +1 (f jn+1 + f jn1 )/ 2

Lax-Friedrichs!

Unconditionally
Unstable!

Upwind!
f jn +1 f jn

U2
Uh 2
(1 + 22 )f xxx
f xx
2
6

=0

2h

Beam-Warming! f

n +1
j

n
j

+U

(3 f

n
j

4f

n
j 1

+ f jn 2 )

2h

U t n
(f j 2 f jn1 + f jn2 )= 0

2h 2
2

QUICK!

Uh 2
(1 )(2 )f xxx
6
Uh 3
(1 )2 (2 )f xxxx

f jn +1 f jn
+
t
n
(3 f jn + 6 f j1n f j2
) (3 f jn+1 + 6 f jn f j1n )
U
8h

ENO!

WENO
!
A large

Stable for!
0 ! 2
Stable for!
!

And Many More!!

number of (conditionally) stable and


accurate methods exists for hyperbolic equations
with smooth solutions !

S-ar putea să vă placă și