Shockwaves in traffic flow I have been struggling on this problem for a while now so here it is:
I am looking to work out when the shockwaves occur in the traffic flow model given below:
A traffic flow governed by the equations below is observed at $t = 0$ to have a dip in the density distribution at $x = 0$ given by:
$$
\rho (x,t=0) = \left\{\begin{aligned}
&a &&: x \lt 0\\
&a- \frac {a}{2}(1+x)&&: -1<x< 0\\
&a- \frac {a}{2}(1-x)&&: 0<x<1\\
&a &&: 1<x\\
\end{aligned}
\right.$$
where $0<a<1$
Where the equation of characteristics is given by $x-(1-2 \rho)t=x_0$ 
I believe I have the correct sketch of this function however I cannot figure out how to find the equations and then the solution of the shocks.
Any explanation and help would be great.
 A: Here, we are dealing with the macroscopic traffic-flow model by Lighthill-Witham-Richards (LWR), which consists in a scalar hyperbolic conservation law
$$
\frac{\partial}{\partial t} \rho + \frac{\partial}{\partial x} Q(\rho) = 0 \, ,
$$
where the flux $Q(\rho)=\rho\, v(\rho)$ depends only on the density of cars $\rho$. The simplest expression for the car velocity of the form $v(\rho) = 1 - \rho$ was introduced by Greenshields. The car density is constant along the characteristics, which are given by $dx/dt = Q'(\rho) = 1 - 2\rho$. The characteristic curve issued from $x_0$ is a straight line in $x$-$t$ space, $x(t) = (1-2\rho_0(x_0))t + x_0$, on which the car density equals its initial value
$$
\rho_0(x_0) = \left\lbrace
\begin{aligned}
&a &&\text{if}\quad x_0<-1\\
&a(1-x_0)/2 &&\text{if}\quad {-1}<x_0<0\\
&a(1+x_0)/2 &&\text{if}\quad 0<x_0<1\\
&a &&\text{if}\quad 1<x_0\, .
\end{aligned}\right.
$$
Let us assume that $0< a < 1/2$. The slope of the characteristics is larger in the slit* than outside. Since the slope is positive, the characteristics cross on the right of the slit: a shock-wave arises. On the left of the shock trajectory $(x(t),t)$, we have the data coming from the slit. From the equation of characteristics, we deduce
$$
\rho_0(x_0) = -\frac{1}{2}\left( \frac{x(t) - x_0}{t} -1 \right) = \frac{a}{2} \left(1 \mp x_0\right) .
$$
Solving with respect to $x_0$, one obtains
$$
x_0 = \frac{x(t) - t + at}{ 1 \pm at} \quad\text{and}\quad
\rho_0(x_0) = \frac{a}{2} \frac{1 \mp (x(t) - t)}{1 \pm at} \, ,
$$
depending whether $(x(t),t)$ has $x_0$ in $[-1,0]$ or in $[0,1]$. On the right, we have the data from outside the slit: $\rho_0(x_0) = a$. Therefore, the Rankine-Hugoniot condition writes
$$
x'(t) = \frac{Q\!\left(\frac{a}{2} \frac{1 \mp (x(t) - t)}{1 \pm at}\right) - Q(a)  }{\frac{a}{2} \frac{1 \mp (x(t) - t)}{1 \pm at} - a}\, ,
$$
which is a differential equation with initial condition $x(0) = 1$. Solving this equation gives the shock trajectory. The case $1/2<a<1$ is tackled in a similar manner.

*slit : area where ${-1}<x_0<1$.
