Sunteți pe pagina 1din 34

2.

29 Numerical Fluid Mechanics


Fall 2011 Lecture 16
REVIEW Lecture 15:
Fourier Error Analysis
Provide additional information to truncation error: indicates how well Fourier mode
solution, i.e. wavenumber and phase speed, is represented
Effective wavenumber:
| c e
i kx
|
i kx
j nd
sin(kAx)
|
= i k
eff
e (for CDS, 2 order, k
eff
= )
\
cx
.
j
Ax
c f c f
Effective wave speed (for linear convection eqn., + c = 0 , integrating in time exactly):
ct c x
num.
df
c o k
k
num. i kx i k
eff
t i k x ( c
eff
t ) eff eff eff
= f ( ) t ci k f (x t , ) =

f (0) e =

f (0) e = =
k eff numerical k k
dt
k = k=
c o k
(with o = i k c = i kc )
eff eff eff
Stability
Heuristic Method: trial and error
n
Energy Method: Find a quantity, l
2
norm
(
|
j
)
2
, and then aim to show that it
j
remains bounded for all n.
| c| A
Example: for
c
+ c = 0 we obtained 0 s
c t
s 1
ct c x Ax
Von Neumann Method (Introduction), also called Fourier Analysis Method/Stability
2.29
Numerical Fluid Mechanics PFJL Lecture 16, 1
1

Outline for TODAY (Lecture 16):
FINITE DIFFERENCES, Contd
Fourier Analysis and Error Analysis
Stability
Heuristic Method
Energy Method
Von Neumann Method (Introduction): 1
st
order linear convection/wave eqn
Hyperbolic PDEs and Stability
Example: 2
nd
order wave equation and waves on a string
Effective numerical wave numbers and dispersion
CFL condition:
Definition
Examples: 1
st
order linear convection/wave eqn, 2
nd
order wave eqn
Other FD schemes
Von Neumann examples: 1
st
order linear convection/wave eqn
Tables of schemes for 1
st
order linear convection/wave eqn
2.29
Numerical Fluid Mechanics PFJL Lecture 16, 2
2

References and Reading Assignments
Lapidus and Pinder, 1982: Numerical solutions of PDEs in
Science and Engineering. Section 4.5 on Stability.
Chapter 3 on Finite Difference Methods of J. H. Ferziger
and M. Peric, Computational Methods for Fluid Dynamics.
Springer, NY, 3
rd
edition, 2002
Chapter 3 on Finite Difference Approximations of H. Lomax,
T. H. Pulliam, D.W. Zingg, Fundamentals of Computational
Fluid Dynamics (Scientific Computation). Springer, 2003
Chapter 29 and 30 on Finite Difference: Elliptic and Parabolic
equations of Chapra and Canale, Numerical Methods for
Engineers, 2010/2006.
2.29
Numerical Fluid Mechanics PFJL Lecture 16, 3
3




Von Neumann Stability
Widely used procedure
Assumes initial error can be represented as a Fourier Series and
considers growth or decay of these errors
In theoretical sense, applies only to periodic BC problems and to
linear problems
Superposition of Fourier modes can then be used


c x t t
|
Again, use, f ( , ) x t =

f
k
( ) t e
i kx
but for the error:
( , ) =

c
|
( ) e
i x
k =
| =
Being interested in error growth/decay, consider only one mode:
i x t i |x
c
|
|
| = ( ) ( ) t e ~ e e where is in general complex and function of : |
t
e s 1
Strict Stability: for the error not to grow in time,
in other words, for t = nt, the condition for strict stability can be written:
At At
e s 1 or for = e , s 1
von Neumann condition
Norm of amplification factor smaller than 1
2.29
Numerical Fluid Mechanics PFJL Lecture 16, 4
4

Evaluation of the Stability of a FD Scheme
Von Neumann Example
(t = nt, x = jx) which can be rewritten:
t x A A
1
1
(1 ) with
n n n
j j j
c t
x
| | |
+

A
= + =
A
j j-1
n
n+1
x
t
Consider again:
0 c
t x
| c
+
| c
=
c c
n+1 n n n
| | | |
j j j j1
A possible FD formula (upwind scheme) + c = 0
Consider the Fourier error decomposition (one mode) and discretize it:
i x t i |x n nA i | jAx | t
( , ) = c
|
( ) e = e e c
j
= e e c x t t
Insert it in the FD scheme, assuming the error mode satisfies the FD:
n+1 n n (n+1) At i | jAx nAt i | jAx nAt i | ( j1) Ax
j
(1 c )
j
+ c
j1
e e = ) e e + e c = (1 e
n nAt i | jAx
Cancel the common term (which is
c
j
= e e
) and obtain:
At i | Ax
(1 ) + e e =
2.29
Numerical Fluid Mechanics PFJL Lecture 16, 5
5



Evaluation of the Stability of a FD Scheme
von Neumann Example
At
The magnitude of = e is then obtained by multiplying with its
complex conjugate:
i | Ax i | Ax
2
i | Ax i | Ax
| e + e |
=
(
(1 ) + e
) (
(1 ) + e
)
= 1 2 (1 )

1
|
2
\ .
i | Ax i | Ax
e + e
2
| Ax
Since = cos( | Ax) and 1 cos( | Ax) = 2sin ( )
2 2
2 | Ax
= 2 (1
(
cos( A )
)
= (1 ) sin ( ) 1 ) 1 | x 1 4
2
2
Thus, the strict von Neumann stability criterion gives
2
| Ax
s 1 1 4(1 )sin ( ) s 1
2
2
| Ax
Since sin ( ) > 0 |
( (
1 cos( | Ax)
)
> 0 |
)
2
we obtain the same result as for the energy method:
1 (1 ) 0 0 1 ( )
c t c t
x x

A A
s > s s =
A A
Equivalent to the
CFL condition
2.29
Numerical Fluid Mechanics PFJL Lecture 16, 6
6

(from Lecture 12)
Partial Differential Equations
Hyperbolic PDE: B
2
- 4 A C > 0
Examples: c
2
u
2
c
2
u
Wave equation, 2
nd
order (1) = c
ct
2
cx
2
cu cu
Sommerfeld Wave/radiation equation,
(2) c = 0
ct cx 1
st
order
cu
Unsteady (linearized) inviscid convection
(3) + (U V ) u = g
ct
(Wave equation first order)
(4) (U V) u = g
Steady (linearized) inviscid convection
Allows non-smooth solutions
t
Information travels along characteristics, e.g.:
c
For (3) above:
d x
= ( ( )) U x
c
t
dt
d x
c
For (4), along streamlines: = U
ds
Domain of dependence of u(x,T) =characteristic path
e.g., for (3), it is: x
c
(t) for 0< t < T
0
x, y
Finite Differences, Finite Volumes and Finite Elements
2.29
Numerical Fluid Mechanics PFJL Lecture 16, 7
7

(from Lecture 12)
Partial Differential Equations
Hyperbolic PDE
Waves on a String
2 2
t
c ( , )
2
c ( , ) u x t u x t
2
= c
2
0 < x < L, 0 < t <
ct cx
Initial Conditions
Boundary Conditions
u(0,t) u(L,t)
Wave Solutions
u(x,0), u
t
(x,0) x
Typically Initial Value Problems in Time, Boundary Value Problems in Space
Time-Marching Solutions: Explicit Schemes Generally Stable
2.29
Numerical Fluid Mechanics PFJL Lecture 16, 8
8

(from Lecture 12)
Partial Differential Equations
Hyperbolic PDE
Wave Equation
c
2
( , )
2
c
2
( , ) u x t u x t
= c 0 < x < L, 0 < t < t
ct
2
cx
2
Discretization:
Finite Difference Representations
u(L,t) u(0,t)
j+1
j
j-1
u(x,0), u
t
(x,0) x
i
i-1 i+1
Finite Difference Representations
2.29
Numerical Fluid Mechanics PFJL Lecture 16, 9
9



(from Lecture 12)
Partial Differential Equations
Hyperbolic PDE
t
x
u(x,0), u
t
(x,0)
u(0,t) u(L,t)
j+1
j-1
j
i
i-1 i+1
Introduce Dimensionless Wave Speed
Explicit Finite Difference Scheme
Stability Requirement:
c t A
C = < 1 Courant-Friedrichs-Lewy condition (CFL condition)
Ax
Physical wave speed must be smaller than the largest numerical wave speed, or,
Time-step must be less than the time for the wave to travel to adjacent grid points:
Ax Ax
c < or A < t
At c
2.29
Numerical Fluid Mechanics PFJL Lecture 16, 10
10

Wave Equation
dAlemberts Solution
Periodicity Properties
Proof
F
Wave Equation
c
2
u x t
2
2
( , )
t
( , ) c u x t
2
= c
2
0 < x < L, 0 < t <
ct cx
Solution
u(0,t)
G
F
u(L,t)
u(x,0)=f(x) , u
t
(x,0)=g(x)
2.29
Numerical Fluid Mechanics PFJL Lecture 16, 11
11
x

Hyperbolic PDE
Method of Characteristics
Explicit Finite Difference Scheme
t
G
F
Characteristic Sampling
Exact Discrete Solution
u(L,t) u(0,t)
First 2 Rows known
j+1
j
j-1
u(x,0)=f(x) , u
t
(x,0)=g(x)
2.29
Numerical Fluid Mechanics PFJL Lecture 16, 12
12
x

Hyperbolic PDE
Method of Characteristics
Lets proof the following FD scheme is
an exact Discrete Solution
t
DAlemberts Solution
Proof
u(0,t)
G
F
u(L,t)
j+1
j
j-1
u(x,0)=f(x) , u
t
(x,0)=g(x)
2.29
Numerical Fluid Mechanics PFJL Lecture 16, 13
13
x

Partial Differential Equations
Hyperbolic PDE
Start of Integration: Euler and Higher Order starts
t
1
st
order Euler Starter
u(x,0)=f(x) , u
t
(x,0)=g(x)
u(0,t) u(L,t)
i
i-1
j=1 i+1
j=2
But, second derivative in x at t = 0 is known from IC:
From Wave Equation
Higher order Taylor Expansion
+k
Higher Order Self Starter
- 2
2.29
Numerical Fluid Mechanics PFJL Lecture 16, 14
14
x
PFJL Lecture 16, 15


Waves on a String
c
2
( , )
2
c
2
( , ) u x t u x t
= c 0 < x < L, 0 < t <
ct
2
cx
2
L=10;
T=10;
c=1.5;
N=100;
h=L/N;
M=400;
k=T/M;
C=c*k/h
Lf=0.5;
x=[0:h:L]';
t=[0:k:T];
%fx=['exp(-0.5*(' num2str(L/2) '-x).^2/(' num2str(Lf) ').^2)'];
%gx='0';
fx='exp(-0.5*(5-x).^2/0.5^2).*cos((x-5)*pi)';
gx='0'; %Zero first time derivative at t=0
f=inline(fx,'x');
g=inline(gx,'x');
n=length(x);
m=length(t);
u=zeros(n,m);
% Second order starter
u(2:n-1,1)=f(x(2:n-1));
for i=2:n-1
u(i,2) = (1-C^2)*u(i,1) + k*g(x(i)) +C^2*(u(i-1,1)+u(i+1,1))/2;
end
% CDS: Iteration in time (j) and space (i)
for j=2:m-1
for i=2:n-1
u(i,j+1)=(2-2*C^2)*u(i,j) + C^2*(u(i+1,j)+u(i-1,j)) - u(i,j-1);
end
end
waveeq.m
Initial condition
figure(1)
plot(x,f(x));
a=title(['fx = ' fx]);
set(a,'FontSize',16);
figure(2)
wavei(u',x,t);
a=xlabel('x');
set(a,'Fontsize',14);
a=ylabel('t');
set(a,'Fontsize',14);
a=title('Waves on String');
set(a,'Fontsize',16);
colormap;
Numerical Fluid Mechanics
15
2.29




Waves on a String, Longer simulation:
Effects of dispersion and effective wavenumber/speed
L=10;
T=10;
c=1.5;
N=100;
h=L/N;
M=400;
% Test: increase duration of simulation, to see effect of
%dispersion and effective wavenumber/speed (due to 2
nd
order)
%T=100;M=4000;
k=T/M;
C=c*k/h
Lf=0.5;
x=[0:h:L]';
t=[0:k:T];
%fx=['exp(-0.5*(' num2str(L/2) '-x).^2/(' num2str(Lf) ').^2)'];
%gx='0';
fx='exp(-0.5*(5-x).^2/0.5^2).*cos((x-5)*pi)';
gx='0';
f=inline(fx,'x');
g=inline(gx,'x');
n=length(x);
m=length(t);
u=zeros(n,m);
%Second order starter
u(2:n-1,1)=f(x(2:n-1));
for i=2:n-1
u(i,2) = (1-C^2)*u(i,1) + k*g(x(i)) +C^2*(u(i-1,1)+u(i+1,1))/2;
end
%CDS: Iteration in time (j) and space (i)
for j=2:m-1
for i=2:n-1
u(i,j+1)=(2-2*C^2)*u(i,j) + C^2*(u(i+1,j)+u(i-1,j)) - u(i,j-1);
end
end
waveeq.m
2.29
Numerical Fluid Mechanics PFJL Lecture 16, 16
16

Courant-Fredrichs-Lewy Condition (1920s)
Basic idea: the solution of the Finite-Difference (FD) equation
can not be independent of the (past) information that determines
the solution of the corresponding PDE
In other words: Numerical domain of dependence of FD scheme
must include the mathematical domain of dependence of the
corresponding PDE
CFL NOT satisfied CFL satisfied
time
time
( , ) u x t
( , ) u x t
space
space
PDE dependence
Numerical stencil
2.29
Numerical Fluid Mechanics PFJL Lecture 16, 17
17

True solution
is outside of
numerical
domain of
influence
CFL NOT satisfied
True solution
is within
numerical
domain of
influence
CFL: Linear convection (Sommerfeld Eqn) Example
Determine domain of dependence of PDE and of FD scheme
PDE:
c ( , ) c ( , ) dx u x t u x t
+ c = 0 Characteristics: If = c x = ct +, and du = 0 u = cst
ct cx dt
Solution of the form: ( , ) F x ct ) u x t = (
FD scheme. For our Upwind discretization, with t = nt, x = jx :
n+1 n n n
| | | |
j j j j1
+ c = 0
At Ax
j-1 j
Slope of characteristic:
dt
=
1
CFL satisfied
dx c
Slope of Upwind scheme:
At
Ax
At 1
=> CFL condition:
s
Ax c
n
n+1
1
c t
x
A
s
A
2.29 Numerical Fluid Mechanics PFJL Lecture 16, 18
18
Springer. All rights reserved. This content is excluded from our Creative Commons license.
For more information, see http://ocw.mit.edu/fairuse. Source: Figure 2.1 from Durran,
D. Numerical Methods for Wave Equations in Geophysical Fluid Dynamics. Springer, 1998.

CFL: 2
nd
order Wave equation Example
Determine domain of dependence of PDE and of FD scheme
PDE, second order wave eqn example:
c
2
( , )
2
c
2
( , ) u x t u x t
2
= c
2
0 < x < L, 0 < t <
ct cx
As seen before: ( , ) = F(x ct ) + ( + ct )
dt 1
u x t G x slope of characteristics: =
dx c
FD scheme: discretize: t = nt, x = jx
CD scheme (CDS) in time and space (2nd order), explicit
n+1 n n1 n n n
u 2u + u u 2u + u
j j j 2 j+1 j j 1 n+1 2 n 2 n n n1
A
= c u = (2 2C )u + C (u + u ) u where C=
c t
2 2
j j j+1 j1 j
At Ax Ax
We obtain from the respective slopes:
Full line case: CFL satisfied
c t A
s 1
Dotted lines case:
Ax
c and t too big, x too
small (CFL NOT satisfied)
t
x
2.29
Numerical Fluid Mechanics PFJL Lecture 16, 19
19



CFL Condition: Some comments
CFL is only a necessary condition for stability
Other (sufficient) stability conditions are often more restrictive
c ( , ) c ( , ) u x t u x t
For example: if + c = 0 is discretized as
ct cx
|
c ( , )
| |
c ( , )
|
u x t u x t
+ c ~ 0
| |
nd th
\
ct
.
CD,2 order in t
\
cx
.
CD,4 order in x
Five grid-points stencil:
(-1,8,0,-8,1) / 12
c t
One obtains from the CFL:
A
s 2
See Taylor tables in
Ax
eqn sheet
c t
While a Von Neuman analysis leads:
A
s 0.728
Ax
For equations that are not purely hyperbolic or that can
change of type (e.g. as diffusion term increases), CFL
condition can at times be violated locally for a short time,
without leading to global instability further in time
2.29
Numerical Fluid Mechanics PFJL Lecture 16, 20
20


von Neumann Examples
Forward in time (Euler), centered in space, Explicit
n+1 n n n
|
j
|
j
|
j+1
|
j1 n+1 n
C
n n
+ c = 0 |
j
= |
j
(|
j+1
|
j1
)
At 2Ax 2
| i x n i x t | n At i | jAx
Von Neumann: insert
c x t
|
( ) t = e c
j
= e e ( , ) = c e e
n+1 n
C
n n At
C
i | Ax i | Ax
c
j
= c
j
(c
j+1
c
j1
) e = 1
(
e e
)
= 1 Ci sin( |Ax)
2 2
Taking the norm:
2
t 2 2
e
2
= =
(
1 Ci sin(|Ax)
) (
1 + Ci sin(|Ax)
)
= 1 + C sin ( |Ax) > 1 for C = 0 !
Unconditionally Unstable
Implicit scheme (later)
2.29
Numerical Fluid Mechanics PFJL Lecture 16, 21
21

Stability of FD schemes for u
t
+ b u
y
= 0 (t denoted x below)
2.29
Numerical Fluid Mechanics PFJL Lecture 16, 22
22
Table showing various finite difference forms removed due to copyright restrictions.
Please see Table 6.1 in Lapidus, L., and G. Pinder. Numerical Solution of Partial
Differential Equations in Science and Engineering. Wiley-Interscience, 1982.

(from Lecture 11)
Partial Differential Equations
Elliptic PDE
Laplace Operator
Laplace Equation Potential Flow
Poisson Equation
Potential Flow with sources
Heat flow in plate
Helmholtz equation Vibration of plates
Convection-Diffusion
Smooth solutions (diffusion effect)
Very often, steady state problems
Domain of dependence of u is the full domain D(x,y) => global solutions
Finite difference, finite elements, boundary integral methods (Panel methods)
Examples:
U Vu =v V
2
u
2.29
Numerical Fluid Mechanics PFJL Lecture 16, 24
24

u(a,y)=g
2
(y)
j+1
j-1
j
i
i-1 i+1
u(0,y)=g
1
(y)
Equidistant Sampling
Discretization
Finite Differences
u(x,0) = f
1
(x)
Dirichlet BC
Partial Differential Equations
Elliptic PDEs
y
u(x,b) = f
2
(x)
(from Lecture 11)
2.29
Numerical Fluid Mechanics PFJL Lecture 16, 25
25
x

(from Lecture 11)
Partial Differential Equations
Elliptic PDE
Discretized Laplace Equation
y
x u(x,0) = f
1
(x)
u(0,y)=g
1
(y) u(a,y)=g
2
(y)
j+1
j-1
j
i
i-1 i+1
u(x,b) = f
2
(x)
Finite Difference Scheme
Global Solution Required
Boundary Conditions
2.29
Numerical Fluid Mechanics PFJL Lecture 16, 26
26

Elliptic PDEs
Laplace Equation, Global Solvers
p
1
p
2
p
3
p
4
p
5
p
6
p
7
p
8
p
9
u
1,2
u
5,2
u
2,1
u
5,2
Dirichlet BC
Leads to Ax = b, with A block-tridiagonal:
A = tri { I , T , I }
2.29
Numerical Fluid Mechanics PFJL Lecture 16, 27
27

Ellipticic PDEs
Neumann Boundary Conditions
Neumann (Derivative) Boundary Condition
y
x u(x,0) = f
1
(x)
u(0,y)=g
1
(y)
u
x
(a,y) given
i
i-1 i+1
u(x,b) = f
2
(x)
Finite Difference Scheme
Finite Difference Scheme
Derivative Finite Difference at BC
Boundary Finite Difference Scheme
1, 1, , 1 , 1 ,
2 4 0
n j n j n j n j n j
n
u
u x u u u u
x
+
c
+ A + + + =
c
given
Leads to a factor 2 (a matrix 2 I in A) for points along boundary
j
2.29
Numerical Fluid Mechanics PFJL Lecture 16, 28
28

Elliptic PDEs
c
2
u c
2
u
Iterative Schemes: Laplace equation
+ = 0
cx
2
cy
2
Finite Difference Scheme
k k k k k +1
u + u + u + u 4u = 0
+ , + , i 1, j i 1, j i j 1 i j , 1 i j
k k k k
u + u + u + u
k i i1, i j 1 1 Liebman Iterative Scheme (Jacobi/Gauss-Seidel) +1 +1, j j , + i j ,
u =
, i j
4
y
u(x,b) = f
2
(x)
SOR Iterative Scheme, Jacobi
u(0,y)=g
1
(y) u(a,y)=g
2
(y)
j+1
j-1
j
i
i-1 i+1
Optimal SOR
1, 1, , 1 , 1 ,
,
4
4
k k k k k
i j i j i j i j i j k
i j
u u u u u
r
+ +
+ + +
=
(1 ) u e
i k 1, 1, i , 1 , 1
,
1,
4
i j + ,
1, , 1 , 1
,
4
4
k k k k k
j j i j i j
i j
k k k k
i j i j i j i j k
i j
u u u u u
u
u u u u
e
e
+
+ +
+ + +
= +
+ + +
= +
u(x,0) = f
1
(x) x
2.29
Numerical Fluid Mechanics PFJL Lecture 16, 29
29

(from Lecture 11)
Elliptic PDE:
Poisson Equation
SOR Iterative Scheme, with Jacobi
k k k k k 2
u + u + u + u 4u h g
k i+1, j i1, j i , j+1 i, j1 i , j i , j
= u +e
,
4
i j
k k k k 2
u + u + u + u h g
k i+1, j i1, j i , j+1 i , j1 i, j
= (1 e) u
,
+e
i j
4
2.29
Numerical Fluid Mechanics PFJL Lecture 16, 30
30

Elliptic PDE:
Poisson Equation
SOR Iterative Scheme, with Gauss-Seidel
k k+1 k k+1 k 2
u + u + u + u 4u h g
k i+1, j i1, j i , j+1 i, j1 i , j i , j
= u +e
,
4
i j
k k+1 k k+1 2
u + u + u + u h g
k i+1, j i1, j i , j+1 i , j1 i, j
= (1 e) u
,
+e
i j
4
2.29
Numerical Fluid Mechanics PFJL Lecture 16, 31
31

Laplace Equation
Steady Heat diffusion (with source: Poisson eqn)
Lx=1;
u_0=mean( u( 1, : ) ) +mean( u( n, : ) ) +mean( u( : , 1) ) +mean( u( : , m) ) ;
Ly=1;
u( 2: n- 1, 2: m- 1) =u_0*ones( n- 2, m- 2) ;
N=10;
duct.m
omega=4/ ( 2+sqr t ( 4- ( cos( pi / ( n- 1) ) +cos( pi / ( m- 1) ) ) ^2) )
h=Lx/ N;
f or k=1: ni t er
M=f l oor ( Ly/ Lx*N) ;
u_ol d=u;
ni t er =20;
f or i =2: n- 1
eps=1e- 6;
f or j =2: m- 1
u( i , j ) =( 1- omega) *u( i , j )
x=[ 0: h: Lx] ' ;
+omega*( u( i - 1, j ) +u( i +1, j ) +u( i , j - 1) +u( i , j +1) - h^2*v( i , j ) ) / 4;
y=[ 0: h: Ly] ;
end
f 1x=' 4*x- 4*x. ^2' ;
end
%f 1x=' 0'
r =abs( u- u_ol d) / max( max( abs( u) ) ) ;
f 2x=' 0' ;
k, r
g1x=' 0' ;
i f ( max( max( r ) ) <eps)
g2x=' 0' ;
br eak;
vxy=' 0' ;
end
f 1=i nl i ne( f 1x, ' x' ) ;
end
f 2=i nl i ne( f 2x, ' x' ) ;
f i gur e( 3)
g1=i nl i ne( g1x, ' y' ) ;
sur f ( y, x, u) ;
g2=i nl i ne( g2x, ' y' ) ;
shadi ng i nt er p;
vf =i nl i ne( vxy, ' x' , ' y' ) ;
a=yl abel ( ' x' ) ;
set ( a, ' Font si ze' , 14) ;
n=l engt h( x) ;
a=xl abel ( ' y' ) ;
m=l engt h( y) ;
set ( a, ' Font si ze' , 14) ;
u=zer os( n, m) ;
a=t i t l e( [ ' Poi sson Equat i on - v = ' vxy] ) ;
u( 2: n- 1, 1) =f 1( x( 2: n- 1) ) ;
set ( a, ' Font si ze' , 16) ;
u( 2: n- 1, m) =f 2( x( 2: n- 1) ) ;
u( 1, 1: m) =g1( y) ;
u( n, 1: m) =g2( y) ;
f or i =1: n
f or j =1: m
c
2
u c
2
u
BCs : u x t = f ( ) = 4x 4x
2
( , 0, ) x
v( i , j ) = vf ( x( i ) , y( j ) ) ;
+ ( , )
2 2
= g x y
end
cx cy Three other BCs are null
end
2.29
Numerical Fluid Mechanics PFJL Lecture 16, 32
32

Helmholtz Equation
SOR Iterative Scheme
k k
+1
k k
+1
2 k 2
k
u
i+1, j
+ u
i1, j
+ u
i, j+1
+ u
i, j1
(4 h f
i, j
)u
i, j
h g
i , j
i j
= u
,
+e
2
i j
(4 h f
,
)
k k
+1
k k
+1
2
k
u
+
+ u

+ u
, +
+ u

h g
, i 1, j i 1, j i j 1 i j , 1 i j
(1 e) u
,
+e
2
=
i j
(4 h f
,
)
i j
2.29
Numerical Fluid Mechanics PFJL Lecture 16, 33
33

Elliptic PDEs
Higher Order Finite Differences
CD, 4
th
order (see tables eqn sheet)
i
i-1 i+1
y
2
k k k k k
u(x,b) = f
2
(x)
| c u |
u +16 u + 30 u +16 u u
i+2, j i 1, j i j i 1, + , j i2, j
=
2 | 2
\
cx
.
th
12h
CD, 4 order
The resulting 9 point cross stencil is more
challenging computationally (boundary, etc)
u(a,y)=g
2
(y) u(0,y)=g
1
(y)
j+1
j
Use more compact scheme instead
j-1
Square stencil (see figure):
Use Taylor series, then
cancel the terms so as to
get a 4
th
order scheme
u(x,0) = f
1
(x) x
+
Leads to:
2.29
Numerical Fluid Mechanics PFJL Lecture 16, 34
34

MIT OpenCourseWare
http://ocw.mit.edu
2.29 Numerical Fluid Mechanics
Fall 2011
For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.

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