/usr/share/genius/examples/vibrating-drumhead-modes.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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | # Category: Differential Equations
# Name: Vibrating circular drumhead (wave equation)
#
# Make an animation of the various modes of a vibrating circular drumhead.
# The equation is u_{tt} = \nabla^2 u in polar coordinates and the
# drum is of radius 1. The varius modes n,m are of the form
# BesselJn(n,k*r)*cos(n*theta)*sin(k*t)
# where k is the mth zero of the BesselJn(n,x)
# The superposition is a superposition of 3 different modes,
# with some shifts also applied in the theta direction for
# added complexity
the_answer = AskButtons("Which mode? n-m where n is the Bessel J_n to use",
"0-1", # 1
"0-2", # 2
"0-3", # 3
"1-1", # 4
"1-2", # 5
"1-3", # 6
"2-1", # 7
"2-2", # 8
"2-3", # 9
"Superposition" # 10
);
# the zeros of the Bessel functions
knm = [2.4048, 5.5201, 8.6537
3.8317, 7.0156, 10.1735
5.1356, 8.4172, 11.6198];
node_lines = null;
function node_circle(r) = r*[cos(0:2*pi/ceil(r*40):2*pi);sin(0:2*pi/ceil(r*40):2*pi);0]';
if the_answer == 1 then (
n = 0;
k = knm@(n+1,1);
) else if the_answer == 2 then (
n = 0;
k = knm@(n+1,2);
node_lines@(1) = node_circle(knm@(n+1,1)/k);
) else if the_answer == 3 then (
n = 0;
k = knm@(n+1,3);
node_lines@(1) = node_circle(knm@(n+1,1)/k);
node_lines@(2) = node_circle(knm@(n+1,2)/k);
) else if the_answer == 4 then (
n = 1;
k = knm@(n+1,1);
node_lines@(1) = [0,-1,0;0,1,0];
) else if the_answer == 5 then (
n = 1;
k = knm@(n+1,2);
node_lines@(1) = [0,-1,0;0,1,0];
node_lines@(2) = node_circle(knm@(n+1,1)/k);
) else if the_answer == 6 then (
n = 1;
k = knm@(n+1,3);
node_lines@(1) = [0,-1,0;0,1,0];
node_lines@(2) = node_circle(knm@(n+1,1)/k);
node_lines@(3) = node_circle(knm@(n+1,2)/k);
) else if the_answer == 7 then (
n = 2;
k = knm@(n+1,1);
node_lines@(1) = (1/sqrt(2))*[-1,-1,0;1,1,0];
node_lines@(2) = (1/sqrt(2))*[1,-1,0;-1,1,0];
) else if the_answer == 8 then (
n = 2;
k = knm@(n+1,2);
node_lines@(1) = (1/sqrt(2))*[-1,-1,0;1,1,0];
node_lines@(2) = (1/sqrt(2))*[1,-1,0;-1,1,0];
node_lines@(3) = node_circle(knm@(n+1,1)/k);
) else if the_answer == 9 then (
n = 2;
k = knm@(n+1,3);
node_lines@(1) = (1/sqrt(2))*[-1,-1,0;1,1,0];
node_lines@(2) = (1/sqrt(2))*[1,-1,0;-1,1,0];
node_lines@(3) = node_circle(knm@(n+1,1)/k);
node_lines@(4) = node_circle(knm@(n+1,2)/k);
) else (
# Superposition
n = -1; # signals superposition
# Two put together
coeff1 = 0.5;
shift1 = 0.0;
n1 = 1;
k1 = knm@(n1+1,2);
coeff2 = 0.3;
shift2 = 0.5;
n2 = 0;
k2 = knm@(n2+1,3);
coeff3 = 0.3;
shift3 = 2;
n3 = 2;
k3 = knm@(n3+1,1);
);
if not IsNull(node_lines) and
1 == AskButtons("Draw node lines over the graph?",
"yes", "no") then (
draw_node_lines = true
) else (
draw_node_lines = false
);
SurfacePlotDrawLegends = false; # don't draw the legend
PlotWindowPresent(); # Make sure the window is raised
# use standard variable names (in case they got reset)
SurfacePlotVariableNames = ["x","y","z"];
#One mode
if n >= 0 then (
for t=0.0 to 30.0 by 0.03 do (
data = null;
for r=0 to 1.0 by 1.0/10 do (
for theta=0 to 2*pi by pi/16 do (
x = r*cos(theta);
y = r*sin(theta);
data = [data;[x,y,BesselJn(n,k*r)*cos(n*theta)*sin(k*t)]]
)
);
# Plot the data
PlotCanvasFreeze();
SurfacePlotData(data,[-1,1,-1,1,-1,1]);
if draw_node_lines then (
for nline in node_lines do (
SurfacePlotDrawLine(nline,"color","blue","thickness",3)
)
);
PlotCanvasThaw();
)
) else (
for t=0.0 to 30.0 by 0.03 do (
data = null;
for r=0 to 1.0 by 1.0/10 do (
for theta=0 to 2*pi by pi/16 do (
x = r*cos(theta);
y = r*sin(theta);
val = coeff1*BesselJn(n1,k1*r)*cos(n1*theta+shift1)*sin(k1*t) +
coeff2*BesselJn(n2,k2*r)*cos(n2*theta+shift2)*sin(k2*t) +
coeff3*BesselJn(n3,k3*r)*cos(n3*theta+shift3)*sin(k3*t);
data = [data;[x,y,val]]
)
);
# Plot the data
SurfacePlotData(data,[-1,1,-1,1,-1,1])
)
);
|