Traffic example

Import the necessary packages.

Define the model

$$ \begin{aligned} V(x) &= 1 & W(x) &= 2 \left( e^{|x|/4} + e^{-2|x|}\right) \\ \mathop{\mathrm{mob}}(\rho) &= (1-\rho)_+ & W'(x) &= 2 \mathop{\mathrm{sign}}(x) \left( \frac{e^{|x|/4}}4 - 2e^{-2|x|} \right) \end{aligned} $$

Define the ODE problem and the initial conditions

The initial condition approximates $\rho_0 = 1_{[-1,-1/2]} + 1_{[1/2,1]}$.

Solve the ODE

Plot the density

Let us first compute a more refined solution.

Now we can plot an animation of the density.

We can translate the particles so that the barycenter stays at the origin.