Professional Documents
Culture Documents
MAPH 4161
Each week:
Assessment:
+ (v) = 0
t x
(v)t + (v 2 + P )x = 0
Et + (v(E + P ))x = 0
(Density) + (F lux) = 0
t x
But first lets look at the kind of advanced results that can
be obtained in this area.
Examples
u u
+ v(x, t) =0 (2)
t x
u(x, 0) = u0(x)
dx
= v(x, t)
dt
u=constant
Analytic Examples
1. v(x, t) = v = constant
Characteristic curve, along which u(x, t) is constant,
is the solution to
dx
=v x = x + vt
dt
(x vt)2
!
u(x, t) = exp
L2
dx 1 + x2
= t = (x x)(1 + x2)
dt 1 + 2xt + 2x2 + x4
" 2 #
1 t
u(x, t) = exp 2 x
L 1 + x2
ut + (v(x)u)x = 0
ut + v(x)ux = v (x)u
(x j,t )
n
h
We denote by un j the numerical approximation to u(x, t)
at the jth spatial point and nth timestep; i.e. un
j u(xj , tn ).
Forward differences :
Backward differences :
Central differences :
tu(x, t) u(x, t + /2) u(x, t /2)
xu(x, t) u(x + h/2, t) u(x h/2, t)
1
0xu(x, t) +x + x u(x, t)
2
1
= [u(x + h, t) u(x h, t)]
2
Forward Time Centered Space (FTCS) method
+tun
j n
x u n
j
= vj
2h
un+1
j un
j u n
j+1 u n
j1
= vjn
2h
n+1 n n n
uj = uj uj+1 uj1
2
un n ikxj
j = e
2
Dividing by neikjh gives
ikh ikh
= 1 e e = 1 i sin(kh)
q 2
|| = 1 + 2 sin2(kh)
Upwind scheme
1
0
0
1
t n+1
1
0
0
1 1
0
0
1
tn
xj
Characteristic
+tun
j = x u n
j
un+1
j = u n un
j x j
= (1 )un
j + u n
j1
Note that = 1 v = h/ , a characteristic goes
through (xj1, tn) and (xj , tn+1) so that the upwind scheme
gives the correct answer un+1
j = u n . Similarly when
j1
= 0 we get un+1 j = u n . For all cases where 0 <
j
< 1, the upwind scheme gives a linear interpolation
(see below) approximation to un+1
j .
= 1 (1 eikh)
2 = [(1 ) + cos(kh)]2 + [ sin(kh)]2
= (1 )2 + 2 + 2(1 ) cos(kh)
= 1 2(1 )(1 cos(kh))
2 = 1 4(1 ) sin2(kh/2)
u u
+ v(x, t) =0
t x
+tun
j n
x u n
j
+ vj =0
h
The truncation error, Tjn , is obtained by inserting the ana-
lytic solution, u(x, t), into the numerical scheme and Tay-
lor expanding in the following manner
1
Tjn = (1 )vhuxx + ...
2
There are numerous other schemes to solve the linear
advection scheme such as the Lax method
1 n n
un+1
j = (uj+1 + un
j1 ) (uj+1 un
j1)
2 2
un+1
j = un1
j (un n
j+1 uj1)
1
0
0
1 1
0
0
1 1
0
0
1 1
0
0
1
tn
B Q A C
xj
Characteristic
uP = uQ
uP = uQ uB + (1 )uA
The Lax Wendroff scheme uses quadratic interpolation
between uB , uA and uC at time tn as shown in the di-
agram.
U(x)
u
11
00
B uC
11
00
u
1
0
A
x x x x x
B Q A C
(x xA)(x xC )
U (x) = uB
(xB xA)(xB xC )
(x xB )(x xC )
+ uA
(xA xB )(xA xC )
(x xB )(x xA)
+ uC
(xC xB )(xC xA)
xB + (1 )h
xQ = xA h
xC (1 + )h
to give
1 1
uQ = (1 + )uB + (1 2)uA (1 )uC
2 2
which is equivalent to
u u v 2 2 u
= v +
t x 2 x2
1
u(x, t + ) = u(x, t) + ut(x, t) + 2utt(x, t) + O( 3)
2
u n
0x j
un+1
j = u n
j vj
n
h
n n n
2 n
0x u j v u
n x j x j
+ (vt)j + vj (4)
2 h h2
1 1
0.8 0.8
0.6 0.6
0.4 0.4
0.2 0.2
0 0
0 0.5 1 1.5 0 0.5 1 1.5
1 1
0.8 0.8
0.6 0.6
0.4 0.4
0.2 0.2
0 0
0 0.5 1 1.5 0 0.5 1 1.5
The same qualitative features can be seen with the up-
wind method for the top-hat initial condition. Again the
pulse moves at the correct speed but the amplitude is re-
duced and the edges of the pulse are smoothed out.
1 1
0.8 0.8
0.6 0.6
0.4 0.4
0.2 0.2
0 0
0 0.5 1 1.5 0 0.5 1 1.5
1 1
0.8 0.8
0.6 0.6
0.4 0.4
0.2 0.2
0 0
0 0.5 1 1.5 0 0.5 1 1.5
The Lax Wendroff scheme for the gaussian profile shows
very good agreement between the numerical results and
the analytic solution and represents a considerable im-
provement on the upwind method.
1 1
0.8 0.8
0.6 0.6
0.4 0.4
0.2 0.2
0 0
0 0.5 1 1.5 0 0.5 1 1.5
1 1
0.8 0.8
0.6 0.6
0.4 0.4
0.2 0.2
0 0
0 0.5 1 1.5 0 0.5 1 1.5
However, Lax Wendroff method for the top-hat condition
shows how difficult it is to reproduce non-smooth solu-
tions; quite advanced schemes are needed ! In the case
of the Lax-Wendroff scheme the coefficient of un j+1 is
(1 )/2 which negative because of the stability re-
quirement. Therefore, un+1
j is a weighted mean of three
values with two positive and one negative weight. The
solution can, and does in the case of non-smooth data,
generate internal local maxima and minima.
1 1
0.8 0.8
0.6 0.6
0.4 0.4
0.2 0.2
0 0
0 0.5 1 1.5 0 0.5 1 1.5
1 1
0.8 0.8
0.6 0.6
0.4 0.4
0.2 0.2
0 0
0 0.5 1 1.5 0 0.5 1 1.5
1.3 Lax Wendroff Method for Conservation Laws
u f (u)
+ =0 (5)
t x
i.e. the flux is a function of u(x, t). This can also be re-
written as
f
ut + v(u)ux = 0 where v(u)
u
1
u(x, t + ) = u(x, t) + ut(x, t) + 2utt(x, t) + O( 3)
2
Again we need to replace the t-derivatives with x-derivatives
by using the pde and then apply central differencing. Be-
gin by noting that
1 2
u(x, t + ) = u(x, t) fx + (vfx)x
2
2
n+1 n n 1 h
n n
i
uj = uj 0xf (uj ) + x v(uj )xf (uj )
h 2 h
where un
j1/2 (u n + un )/2.
j j1
n
Adopting the notation that vj1/2 v(un ) and f n
j1/2 j
n
f (uj ), the Lax Wendroff method for conservation laws
can be written as,
n+1 n n
uj = uj 1 vj+1/2 +xfjn
2h h
n
1 + vj1/2 xfjn (6)
2h h
1
ut + uux = px + uxx
dx
= u (x(t), t)
dt
dt 1
=
dx u0(x)
u(x,0)
u(x,t)
u(x,o)
The problem is that the mathematical model for gas flow
breaks down at this point since viscosity becomes impor-
tant as steep gradients develop and we should be solving
the equation
ut + uux = uxx
ur x<0
u(x, 0) =
ul x0
v
s
u
r
d L
Z
u(x, t) dx = f (ul ) f (ur )
dt L
Z L
u(x, t) dx = (L + vst)ul + (L vst)ur
L
Z L
d
u(x, t) dx = vs(ul ur )
dt L
t Shock
u
l
ur
u
l
t Rarefaction wave
n+1/2 1 n n
n n
uj+1/2 = uj + uj+1 f (uj+1) f (uj )
2 2h
n f (un+1/2 ) f (un+1/2 )
un+1
j = u j j+1/2 j1/2
h
f
There is no need to calculate u which is an advantage
when dealing with systems of equations.
uj h +xfjn
n n
if vj+1/2 <0
un+1
j = (8)
un x f n n
if vj1/2 >0
j h j
MATLAB Programme burgers.m
1 1
0.8 0.8
0.6 0.6
0.4 0.4
0.2 0.2
0 0
0 0.2 0.4 0.6 0 0.2 0.4 0.6
1 1
0.8 0.8
0.6 0.6
0.4 0.4
0.2 0.2
0 0
0 0.2 0.4 0.6 0 0.2 0.4 0.6
The two-step method, for comparison, with Lax Wendroff.
1 1
0.8 0.8
0.6 0.6
0.4 0.4
0.2 0.2
0 0
0 0.2 0.4 0.6 0 0.2 0.4 0.6
1 1
0.8 0.8
0.6 0.6
0.4 0.4
0.2 0.2
0 0
0 0.2 0.4 0.6 0 0.2 0.4 0.6
All of the above methods can easily be generalised to sys-
tems of equations. For example the wave equation de-
scribing the propagation of waves on a string is
2A 2 2A
2
=v
t x2
A A
u1 and u2 v
t x
u1 u2 u2 u1
=v and =v
t x t x
ut + (f (u))x = 0
u1
u=
v u2
E u3
and
v u2
f = v 2 + p = u2 /u + p(u)
2 1
v(E + p) u2(u3 + p(u))/u1
(v)
+ =0
t x
!
v() = vm 1
m
b
+ a+ =0
t x 2
where a = vm and b = 2vm/m. This equation is
called the generalised inviscid Burgers equation. The
standard Burgers equation we obtained beforehand cor-
responds to a = 0 and b = 1.
+ (v()) = 0 + c() =0
t x t x
where
!
d 2
c() (v) = vm 1
d m
dx
= c()
dt
Note the limiting cases for c(),
vm for = 0
c() = 0 for = m/2
vm for = m
Note that v() is the speed of the traffic while c() is the
speed of disturbances or waves in the traffic which can be
seen from the following example.
Traffic at a Stoplight
m x
m
(x, 0) = x
1 x
2
0
x
m x vmt
(x, t) =
0 x vm t
i.e. the next car to move is at x = vmt and behind this
car it is still bumper-to-bumper while in front of the lead
car at x = vmt we still have a free road.
= =0
m
+ x
m x vmt
m
(x, t) = x
1 vmt vmt x vmt
2
0 x vm t
Vehicle
trajectories
There are other models for the car flux, f = v, for ex-
ample data for the Lincoln tunnel in New York City was
used by Greenberg (1959) to suggest the model f =
a log(m/).
where
1 n
cj1/2 c(n n n
j1/2) and j1/2 =
2
j + j1
and
!
F () = vm 1
m
0.9
0.8
0.7
0.6
0
0.5 5
0.4 10
Time
0.3 15
0.2 20
0.1 25
0 30
0 10 20 30 40 50 60 70 80 90 100
Position
m /2 for x < 0
(x, 0) =
m for x 0
t
Shock Front
Moving traffic