/usr/share/genius/examples/shocks.gel is in genius-common 1.0.23-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | # Category: Differential Equations
# Name: Characteristics and shocks for the traffic flow equation
#
# We are looking at characteristics (looking for shocks)
# for the equation u_t + g(u) u_x = 0, with initial condition
# u(x,0) = phi(x)
#
# At the end of this example, there is also commented out code
# for plotting a surface of the solution, though that does not
# deal well with shocks.
# this is for flux u*(2-u)
#function g(u) = 2-2*u;
# Quadratic flow for flux u^2 / 2
function g(u) = u;
# ramp down
function phi(x) = (
if x < 0 then 1
else if x < 1 then 1-x
else 0
);
# rampup
#function phi(x) = (
# if x < 0 then 0
# else if x < 1 then x
# else 1
#);
# we'll have x going from
xstart = -3;
xend = 3;
xstep = 0.1;
# end at this t, start at 0
tend = 1.5;
LinePlotWindow = [xstart,xend,-0.1,tend+0.1];
LinePlotDrawLegends = false;
LinePlotClear();
PlotWindowPresent(); # Make sure the window is raised
# color in [red,green,blue]
# Color according to phi
function the_color(x0) = [phi(x0), #red
0.2, # green
1.0-phi(x0)]; #blue
# Color according to x0
#function the_color(x0) = [(x0-xstart)/(xend-xstart), #red
# 0.2, # green
# 1.0-(x0-xstart)/(xend-xstart)]; #blue
# Draw characteristics
for x0=xstart to xend by xstep do (
LinePlotDrawLine([x0,0;x0+g(phi(x0))*tend,tend], "color", the_color (x0))
);
# Draw the solution set as a surface graph. If there are shocks, the
# graph will be unpredictable. Use for standard parameters something
# like tend=0.99. Also good to change xstart and xend to someting like
# -1 and 1.5 for a nicer picture
#
#SurfacePlotVariableNames = ["x","t","u"];
#data = null;
#for x0=xstart to xend by xstep do (
# for t=0 to tend by tend/10.0 do (
# data = [data;[x0+g(phi(x0))*t,t,phi(x0)]];
# )
#);
#SurfacePlotData(data);
|