apm526 project2 - arizona state universitychris/apm52617/project2/prob3.pdf · 2018. 3. 15. ·...
TRANSCRIPT
APM 526 Project 2Name: Sijie Huang
ID #: 1211126264
1 Introduction
For the Lighthill-Whitham-Richardson (LWH) model, the governing equation is
∂u∂t+∂[vu]∂x
= 0,
where u stands for the car density, v stands for the optimal velocity for the traffic. For the LWH model,
v(x) = v0
(1 −
uc
). Consider v0 as a constant, then convert the conservative form to quasilinear form:
∂u∂t+ v0
∂(u − u2
c
)∂x
= 0
∂u∂t+ v0
(1 −
2uc
)∂u∂x= 0
therefore, the CFL condition and the time step size ∆t will determined by the convective velocity v0
(1 −
2uc
).
According to the CFL condition the time step size will be:
∆t =∆x
max[v0
(1 − 2u
c
)]2 Problem 1. Solving LWHModel with Lax-Friedrichs Scheme
In this case, the conditions are:
• Initial traffic density
u0(x, 0) =
50 cars/km 0 < x < 10
0 rest
• Optimal velocity for the traffic
v0(x) =
10 km/h 30 < x < 40
100 km/h rest
• Length of the road L = 50km;
1
• It has periodic boundary condition;
• Number of grid points N = 100, gives mesh size ∆x = 0.5.
Discretize the equation by Lax-Friedrichs method. Denote the flux as Fi = v0,i
[un
i −(un
i )2
c
], and then the
Lax-Friedrichs method will be:
un+1i =
12
(un
i+1 + uni−1
)−∆t
2∆x(Fn
i+1 − Fni−1
).
Solve the equation to time level T = 1, and the results are as Fig 1.
Some conclusion can be drew here:
1. The leading edge, or the leading discontinuity, is smears out;
2. The results are way too diffusive that some cars already pass the right boundary and get back to the left,
given that it has periodic boundary condition;
3. Some dispersion can be observed.
Fig. 1. Time-evolution of the results from Lax-Friedrichs method.
Now, lowering the mesh size. Since ∆t was calculated from CFL condition, so the time step size will also
be reduced as well. Fig. 2 shows the results for chosen mesh size at time level T = 1. It can be observed that,
with ∆t → 0, ∆x → 0 at the same time, the solutions get recovered better and better: it is getting closer to a
2
complete square wave, as it supposed to be. Also, no discernible dispersion. And Fig. 3 shows the evolution of
the wave with mesh number of N = 1000. Still, the leading edge is inevitably smeared out. This is because the
artificial diffusion of Lax-Friedrichs is too high.
Fig. 2. Comparing results between different mesh size.
Fig. 3. Time-evolution of the results from Lax-Friedrichs method with N = 1000.
3
3 Problem.2: Solving LWHModel with Lax-Wendroff Scheme
In this section, Lax-Wendroff method is applied to LWH model. All the given conditions are completely the
same as in the previous problem. Denoting the flux the same as in the previous section, then the LW scheme
for this nonlinear equation has the following form:
un+1i = un
i −∆t
2∆x(Fn
i+1 − Fni−1
)+∆t2
2∆x2
[Ai+ 1
2
(Fn
i+1 − Fni)− Ai− 1
2
(Fn
i − Fni−1
) ]. (1)
where Ai+ 12and Ai− 1
2is the Jacobian of F, which are evaluated by:
Ai+ 12=
12(Ai + Ai+1) =
12
[(∂F∂u
)i+
(∂F∂u
)i+1
]=
12
[v0,i
(1 −
2uni
c
)+ v0,i+1
(1 −
2uni+1c
)] (2)
Ai− 12=
12(Ai + Ai−1) =
12
[(∂F∂u
)i+
(∂F∂u
)i−1
]=
12
[v0,i
(1 −
2uni
c
)+ v0,i−1
(1 −
2uni−1c
)] (3)
Substitute (2) and (3) into (1) to get the complete form of Lax-Wendroff scheme for nonlinear hyperbolic
equation.
However, worth for notice: since the Lax-Wendroffmethod iswell-known for its dispersive quality, especially
for those cases which have discontinuities in their solutions. In order to prevent the large dispersive from blowing
up the solution, the following precaution is taken:
1. From previous problem, the wave starts to "congested" at the left boundary of congestion section which
x = 30km at approximately t = 0.25hr . Hence, for t < 0.25, if solution ui > 55, wipe out the extra part
and set it to 50. The reason choosing 55 is to left some space for the solution to present the nature of
dispersion of Lax-Wendroff. And set all negative values to 0;
2. For t > 0.25, if solution ui > 105, set it to 100 with the same reason. And zeroing all negative values as
well.
Use CFL condition to determine the time step as the same in the previous problem. The results are shown
in Fig. 4(a).
4
(a) (b)
(c) (d)
Fig. 4. Time-evolution of the solutions given by Lax-Wendroff scheme with number of grid points N = 100 but with
different Courant number C. (a). C = 1; (b). C = 0.1; (c). C = 0.05; (d). C = 0.005.
From Fig. 4(a), it can be observed that the wave is way too diffusive. The wave can barely be recognized.
Probably because the manually elimination of the overshoot.
Lowering the Courant number to 0.1, and the solutions are much better, as shown in Fig. 4(b). The wave
is mostly preserved. However, strong dispersion appears. Keep lowering the Courant number to 0.05, it gives
the solution in Fig. 4(c). Obviously, it gives better results than Courant = 0.1. However, keep lowering the
Courant number does not necessarily give better results. With Courant number = 0.005, it gives the solutions
in Fig. 4(d). Apparently, the dispersion gets stronger.
Next, increase the grid points to N = 200 with Courant number C = 1, the solutions are as shown in
5
Fig. 5(a). It’s much diffusive than the case with N = 100 & C = 1. Then, lowering the Courant number to
0.1 as before, as shown in Fig. 5(b). Obviously, it’s still not better than it’s counterpart with mesh number of
N = 100. So it can be concluded that, in this case, with finer mesh, it needs smaller Courant number to achieve
better results.
(a) (b)
Fig. 5. Time-evolution of the solutions given by Lax-Wendroff scheme with different Courant number C at number of grid
points N = 200. (a). C = 1; (b). C = 0.1.
It seems Lax-Wendroff is not the best choice for nonlinear hyperbolic equations, especially when there are
discontinuities in their solution, even though it is a high-order scheme. The main problem is the dispersion.
One way to solve this issue is that by introducing flux-limiter or slope-limiter. Or just go with other schemes
that are TVD.
4 Particle Method for LWHModel
In this section, particle method, or to be more specific, follow-the-leader(FTL) method, is applied to solve the
LWH model.
Basically, particle method is just tracking each particle and solve their motion individually. Hence, in this
spirit, Follow-the-Leader model will be defined as following. Denote the position the nth particle, or in this
case, car, as pn(t). Then, FTL model will be:
6
pn(t + ∆t) =
pn(t) + v0(x) · ∆t, if pn(t) + v0(x) · ∆t ≤ pn+1(t + ∆t)
pn+1(t + ∆t) − d , if pn(t) + v0(x) · ∆t > pn+1(t + ∆t)(4)
After acquiring all the positions of the cars for the new time level, do:
CM =
N∑i=1
δ(pi − xM) . (5)
to get the density u(x, t), and in this case, define CM as the number of particles in the M th cell, and xM as the
position of the left point for each cell.
Loop over all 500 particles and apply Eq. (4) to each particle individually. Then, apply Eq. (5) to get the
traffic density at each time level. The solutions are as in Fig. (6)
(a) (b)
Fig. 6. Solution of LWH model solved by Follow-the-Leader model. (a). Time-evolution of the solution; (b). Solution at
given time level (from left to right) (i). t = 0; (ii). t = 0.22; (iii). t = 0.24; (iv). t = T = 1.
Few observations:
1. The wave is perfectly preserved, no diffusion or dispersion at all;
2. From Fig. 6(b), when the wave hits the congested region at time level around t = 0.22, the wave has a
sudden jump, which means the density suddenly increased due to the congestion.
7
Next, try 3 different time step sizes:
1. ∆t = 0.05;
2. ∆t = 0.01;
3. ∆t = 0.0005
Fig. 7. Solutions at final time level with different time step sizes.
Obviously, the wave moves fastest with largest time step ∆t = 0.05, some of the cars already pass right
boundary and return from the left. And with lower time step size, the wave move slower.
Last, move the particles further with T = 2 hrs. Solve the system again with different time step size ∆t. The
results are in Fig. 8.
8
(a) (b)
(c) (d)
Fig. 8. Time-evolution of the solutions within time period of T = 2 hrs given by FTL method with different time step
sizes ∆t. (a). ∆t = 0.02; (b). ∆t = 0.01; (c). ∆t = 0.005; (d). ∆t = 0.001.
Given the periodic boundary condition, with longer period T = 2 hrs, the traffic flow leaves the right-hand
side and come back from the left-hand side. Apparently, varying time step sizes has impact on the solution
when the traffic flow leaving the congested area. With higher time step size, the wave will be more dispersive
leaving the area. Smaller ∆t gives smoother wave.
9
5 Problem 4. Solving Stochastic Brownian Motion
5.1 Determine the CFL Condition
Since this is a stochastic process, all the possibilities, in this case:
a =∆tv2∆x
+d∆t∆x2
b = −∆tv2∆x
+d∆t∆x2
c = 1 − a − b =2d∆t∆x2
a stands for the possibility of the particle moving to the negative direction; b stands for the possibility of the
particle moving to the positive direction; c stands for the possibility of the particle stay still. All the possibilities
have to be non-negative, i.e., a ≥ 0, b ≥ 0, c ≥ 0. Since all the variables, d, v, ∆t, ∆x are non-negative, a will
always be positive; and so a will not pose limitations on the CFL condition. With b ≥ 0 gives
∆x ≤2dv
which only pose limitation on the mesh size, not on time step size. With c ≥ 0 gives
∆t ≤∆x2
2d
this does pose limitation on the time step size, which gives the CFL condition.
5.2 Solving the Stochastic Process
Denote the position of the particle is p(t), and the motion of the particle follows
p(t + ∆t) = p(t) + q[p(t)]
with
dP[q(t) = y] = φ(y = x)dy
where
φ(y) =
a y = −∆x
1 − a − b y = 0
b y = ∆x
10
and so it gives
q(y) = φ−1(y) =
−∆x y ≤ a
0 a < y < 1 − b
+∆x 1 − b ≤ y
(6)
Use the random number generator function rand in MATLAB to generate random number for y, plug it into
Eq. (6) to determine to which direction the particle moves.
In this case, v = 1, d = 0.1, ∆x = 0.025, ∆t =∆x2
2d= 0.003125. Boundary condition is periodic boundary
condition. Apply Eq. 5 to find out which cell the particle is located. Solve the motion with one realization, and
the results at different time levels are shown in Fig. 9.
(a)
(b)
Fig. 9. Solution of stochastic process of one particle. (a). Plots in the wave-form; (b). Solution in the point-form.
It can be observed that the particle is moving to the direction of negative-x, since this possibility a is larger
than the possibility of moving to the positive-x direction which is b;
Then, repeat the same process with 10000 realizations, the results are shown in Fig. 10. It can be observed
that, in general, the particle is still moving to the left, or the negative-x direction. Eventually, due to the periodic
boundary condition, the wave almost spread out the entire domain. But also worth for notice, the process is
diffusive, the wave is getting weaker and weaker as time goes by, eventually it almost dies out. This obeys the
diffusive property of Brownian motion.
11
Fig. 10. Solution of stochastic process over 10000 realizations.
12
Project 2, problem 3
Particle Method for LWH traffic-flow Model
- Follow-the-Leader Model -
Name: Sijie Huang
Date: Mar.15.2018
1 Lighthill-Whitman-Richardson(LWR) Model
Governing equation: nonlinear hyperbolic equation:
∂ρ
∂t+∂(ρv)
∂x= 0 ,
here:
1. ρ(x, t) is the density of the cars;
2. v is the velocity. In LWR model: v = v0
(1 −
ρ
c
)v0: optimal max velocity;
c: constant, stands for max density of the cars.
1
2 Particle Method and Follow-the-Leader Model
Idea: Track each particle and solve their motion individually.
Follow-the-Leader model for nth particle:
pn(t + ∆t) =
pn(t) + v0(x) · ∆t , if pn(t) + v0(x) · ∆t ≤ pn+1(t + ∆t)
pn+1(t + ∆t) − d , else(1)
Count the number of cars in cell M:
CM =
N∑i=1
δ(pi − xM). (2)
Compute the density in each cell:
ρN(t) =CN
∆x. (3)
Algorithm:
1. Start with the leading particle and loop over all particles, apply Eq.(1)
to move the particles with 1 time step;
2. At chosen time levels, apply Eq.(2) and Eq.(3) to get the number and
then the density;
2
3. Advance in time, repeat the previous steps until reaches final time
level.
3 Conditions
Some conditions:
1. minimum distance between cars is d = 0.01 km;
2. mesh size ∆x = 0.5;
3. number of particles (cars) M = 500;
4. numbering the right-most car as the 500th, and so, the initial positions
are:
pn(x, 0) = 2 · m · d,
where m = 1, 2, 3, ...500.
3
4 Computation and Results
Choose time step ∆t = 0.005. The results:
(show a GIF here)
Fig. 1. Time-evolution of the results from Follow-the-Leader model.
4
Fig. 2. Solution of LWH model solved by Follow-the-Leader model. (a). Time-evolution of the solution; (b).
Solution at given time level (from left to right) (i). t = 0; (ii). t = 0.22; (iii). t = 0.24; (iv). t = T = 1.
Next, try 3 different time step sizes:
(1). ∆t = 0.05; (2). ∆t = 0.01; (3). ∆t = 0.0005
5
Fig. 3. Solutions at final time level with different time step sizes.
6
5 Move the Particles Further
Next, let’s extend the period to T = 2. Compare results from different
time step: (1).t = 0.02; (2).t = 0.01; (3).t = 0.005; (4). t = 0.001;
(show some GIFs here)
Fig. 4. Time-evolution of the traffic flow with ∆t = 0.02 for T = 2 hrs.
7
Fig. 5. Time-evolution of the traffic flow with ∆t = 0.01 for T = 2 hrs.
8
Fig. 6. Time-evolution of the traffic flow with ∆t = 0.005 for T = 2 hrs.
9
Fig. 7. Time-evolution of the traffic flow with ∆t = 0.001 for T = 2 hrs.
10