Archive for December, 2009


[Link] Top ten iPhone apps for people who could build iPhone apps (but who choose to make web things instead)

December 24th, 2009

Top ten iPhone apps for people who could build iPhone apps (but who choose to make web things instead) (warpedvisions.org)

[Link] Christmas Plans

December 22nd, 2009

Christmas Plans (xkcd.com)

[Link] Backup Ubuntu using rdiff-backup|Ubuntu Geek

December 19th, 2009

Backup Ubuntu using rdiff-backup | Ubuntu Geek (www.ubuntugeek.com)

[Link] Website mockups and jQuery: disable anchors by default

December 19th, 2009

Website mockups and jQuery: disable anchors by default (warpedvisions.org)

Poster Presentation on Traffic Flow

December 17th, 2009

Lighthill-Whitham Model

The continuity equation for traffic flow is defined as:

 \frac{\partial \rho}{\partial t} + \frac{\partial q}{\partial x} = 0

where  \rho is the car density,  u is the car speed, and  q is the traffic flow ( q = \rho u ). This equation corresponds to a one dimensional fluid-dynamic model where no vehicles will enter or leave the traffic flow except at the boundary.

Let us assume that the car’s velocity depends only on the density ( u=u(\rho) ). The simplest model
would be to consider the following linear relationship:

  u(\rho) = u_{max} ( 1-\frac{\rho}{\rho_{max}})

where \rho_{max} is the traffic density in which you have bumper-to-bumper traffic and u_{max} is the maximum speed that a vehicle can travel. This usually corresponds to the speed limit.

You will notice that when there are no vehicles on the road an individual vehicle would travel at u_{max}. Likewise, when you have bumper-to-bumper traffic, the vehicles on the road won’t be moving.

The relationship between density and traffic flow can be shown by the Fundamental Diagram of Road Traffic which has a maximum flow at \frac{\rho_{max}}{2}.

If we put our velocity model into the continuity equation, we get the following:

 \frac{\partial \rho}{\partial t} + u_{max} ( 1-2 \frac{\rho}{\rho_{max}} ) \frac{\partial \rho}{\partial x} = 0

Shock Waves

The Lighthill-Whitham Model is a non-linear wave equation. This equation can be solved using the method of characteristic lines. One of the defining features of this equation is the creation of expansion and shock waves. Shock waves are formed when characteristic lines intersect which causes \rho (x) to become discontinuous. It can be shown that shock waves will have speed

 S(\rho_+,\rho_-) = \frac{q(\rho_+)-q(\rho_-)}{\rho_+-\rho_-}

where \rho_+ and \rho_- is the density when approaching from the right and left of the discontinuity.

Dealing with shock waves numerically has serious difficulties. To avoid shock waves, we can add a small diffusive term to the LW Model. If we define the traffic flow as

 q = u_{max} ( 1-\frac{\rho}{\rho_{max}} ) \rho-\epsilon \frac{\partial \rho}{\partial x}

we can get a variation of burgers equation

 \frac{\partial \rho}{\partial t} + u_{max} ( 1-2 \frac{\rho}{\rho_{max}} ) \frac{\partial \rho}{\partial x} = \epsilon \frac{\partial^2 \rho}{\partial x^2}

Fourier-Galerkin Spectral Method

The diffusive LW model can be solved using a Fourier-Galerkin Spectral Method. If we assume the problem has periodic boundary conditions and x \in [0, 2\pi] , we can expand \rho using e^{inx} as a basis. This will lead us to the following system of equations

 \frac{d a_n(t)}{dt} + i~n~u_{max}~a_n(t) + \epsilon~n^2~a_n(t) = \frac{2~i~u_{max}}{\rho_{max}} \displaystyle\sum_{j=-N/2}^{N/2} j~a_j(t)~a_{n-j}(t)
 a_n(0) = \begin{cases}\frac{1}{2 \pi} \displaystyle\int_{0}^{2\pi} \rho(x,0)~e^{inx}~dx & \text{for $n \in [-\frac{N}{2}, \frac{N}{2}]$} \\ 0 & \text{otherwise} \end{cases}

where

 \rho(x,t) = \displaystyle\sum_{j=-N/2}^{N/2} a_j(t)~e^{inx}

After a Traffic Light Turns Green

Let’s analyze the behavior of traffic after a light turns green. We can do this by using the following initial conditions:

 \rho(x,0) = \begin{cases}\rho_{max} & \text{for $0 \leq x \leq \pi$} \\0 & \text{for $\pi < x \leq 2\pi$}\end{cases}

If we use the Fourier-Galerkin Spectral Method, we get the following results

when \rho_{max} = 3, \epsilon = .01, u_{max} = .5, and N=100. You will notice the Gibbs phenomenon in our initial conditions. This is because a step-function can’t be exactly represented by our Fourier basis functions. However, the diffusive term will quickly damp any highly oscillating term.

If we look at the exact solution to this problem for the Non-Diffusive LW Model, we will get an expansion wave. The length of expansion can be shown to be 2 u_{max} t.

If we look at the Diffusive LW Model, we can see that the expansion length is dependant on \epsilon.

After a Traffic Light Turns Red

Let’s analyze the behavior of traffic after a light turns red. We can do this by using the following initial conditions:

  \rho(x,0) = \begin{cases}  \rho_0 & \text{for $0 \leq x \leq \pi$} \\  \rho_{max} & \text{for $\pi < x \leq 2\pi$}\end{cases}

If we use the Fourier-Galerkin Spectral Method, we get the following results

when \rho_{max} = 3, \rho_0 = 1, \epsilon = .01, u_{max} = .5, and N=100. After the Gibbs phenomenon dies down from our diffusive term, you will notice a shock that moves at speed -0.1685.

If we look at the exact solution to this problem for the Non-Diffusive LW Model, we will get a shock that moves at speed

 u = - \frac{\rho_0 ~ u_{max}}{\rho_{max}-\rho_0} ( 1-\frac{\rho_0}{\rho_{max}} )

If we use the same parameters as the above numerics, we get a shock speed of -0.166667.

If we look at the Diffusive LW Model, we can see that the shock speed doesn’t vary much for different values of \epsilon.

References:

[1] Kopriva, D. (2009). Implementing Spectral Methods for Partial Differential Equations. Springer Science
[2] Gottlieb, D. & Orszag, S.A. (1977). Numerical analysis of spectral methods: Theory and Applications. Montpelier,Vermont: Capital City Press
[3] Haberman, R. (1977). Mathematical Models: Mechanical Vibrations, Population Dynamics, and Traffic Flow. Englewood Cliffs, NJ: Prentice-Hall
[4] Helbing, D. (2001). Traffic and related self-driven many-particle systems. Rev. Mod. Phys. 73 (4), 1067–1141.