This notebook can be used to visualize the IVP for a conservation law PDE:
a(z) z_x + z_y = 0, 
z(x, 0) = f(x)
In applications y is time (t) and we are usually interested in y > 0 (t > 0).
Run the first cell to define “makeFigs”
Then run the next cells, where the parameters and functions are defined and the figures are made.

makeFigs := Module[{},
pInitialData = ParametricPlot3D[{x0, 0, f[x0]}, {x0, x0Min, x0Max}, PlotStyle -> Tube[0.02]];
pSolution = ParametricPlot3D[{x0 + a[f[x0]] y, y, f[x0]}   , {x0, x0Min, x0Max}, {y,yMin,yMax}, Mesh ->{15, 0}, PlotStyle -> Opacity[.8]];
fig3D =Show[pInitialData,pSolution, pInitialData, PlotRange ->{{xMin, xMax}, {yMin, yMax}, Automatic}, AxesLabel ->{x,y,z}, PlotLabel ->pdeName];
fig2D = ParametricPlot[{x0 + a[f[x0]] y, y}   , {x0, x0Min, x0Max}, {y,yMin,yMax}, Mesh ->{15, 0}, FrameLabel ->{x,y}, Axes -> False,PlotRange ->{{xMin, xMax}, {yMin, yMax}}, Epilog -> Point[{xShock, yShock}], PlotLabel ->pdeName];
GraphicsRow[{fig3D, fig2D}, ImageSize -> 800]
]

f[x_] := -x/2
a[z_] := z (* Inviscid Burgers' Equation *)
pdeName = "Burgers' Equation";
x0Min = -2; x0Max = 2; xMin = -2; xMax = 2; yMin = 0;yMax = 3;
xShock = 0;yShock = 2;
makeFigs

f[x_] := -Tanh[x]
a[z_] := z (* Inviscid Burgers' Equation *)
pdeName = "Burgers' Equation";
x0Min = -4; x0Max = 4; xMin = -2; xMax = 2; yMin = 0;yMax = 2;
xShock = 0;yShock = 1;
makeFigs

f[x_] := 1-x+x^3
a[z_] := z (* Inviscid Burgers' Equation *)
pdeName = "Burgers' Equation";
x0Min = -1; x0Max = 1.2; xMin = -1; xMax = 1.5; yMin = 0;yMax = 1.5;
xShock = 1; yShock = 1; (* Computed in class *)
makeFigs

f[x_] := Exp[-x^2/2]
a[z_] := z (* Inviscid Burgers' Equation *)
pdeName = "Burgers' Equation";
x0Min = -2; x0Max = 4; xMin = -1; xMax = 4; yMin = 0;yMax = 3;
xShock = 0; yShock = -1; (* out of range so it doesn't plot.  Figure out where it is *)
makeFigs

f[x_] := Which[x< 0, 1/3, x< 1, 1/3+5/12 x, True, 3/4] (* Example in book *)
a[z_] := 1-2z (* Traffic Flow, book's (6.6) *)
pdeName = "Traffic Flow";
x0Min = -4; x0Max = 4; xMin = -2; xMax = 2; yMin = 0;yMax = 2;
xShock = 2/5; yShock = 6/5; (* Calculated in book *)
makeFigs

f[x_] := (1 + Tanh[x])/2
a[z_] := 1-2z (* Traffic Flow, book's (6.6) *)
pdeName = "Traffic Flow";
x0Min = -4; x0Max = 4; xMin = -2; xMax = 2; yMin = 0;yMax = 2;
xShock = 0; yShock = 1;
makeFigs

Notice that the Characteristic curves are exactly the same for Burgers’ equation with a different f:  The integral surface is different, though.

f[x_] := -Tanh[x]
a[z_] := z (* Inviscid Burgers' Equation *)
pdeName = "Burgers' Equation";
x0Min = -4; x0Max = 4; xMin = -2; xMax = 2; yMin = 0;yMax = 2;
xShock = 0;yShock = 1;
makeFigs

This is a more realistic situation with a low density traffic (on the left) approaching a traffic jam (on the right) and the traffic jam moves left.

f[x_] := (2 + Tanh[x])/3
a[z_] := 1-2z (* Traffic Flow, book's (6.6) *)
pdeName = "Traffic Flow";
x0Min = -3; x0Max = 4; xMin = -2; xMax = 2; yMin = 0;yMax = 3;
xShock = 0; yShock = -1;
makeFigs

Here is a traffic flow showing a light turning green at time y = 0.  Initially the density is almost a step function with cars piled up at x < 0 and almost empty road with x > 0.

f[x_] := (-Tanh[5x]+1)/2
a[z_] := 1-2z (* Traffic Flow, book's (6.6) *)
pdeName = "Traffic Flow";
x0Min = -2; x0Max = 2; xMin = -2; xMax = 2; yMin = 0;yMax = 2.5;
xShock = 0; yShock = -1;  (* There is no shock in in the y > 0 half plane *)
makeFigs