# 2. DEMO - wawes in solid state # Here we model the motion of longitudinal waves in a # solid state with bodies, coupled by springs. We give # an initial displacement to the first body . # You can change the parameters and see how changes # the graph of the motion. func x0,v0; # displacements and velocities func x1,v1; func x2,v2; func x3,v3; func x4,v4; const D,m; # constant of the spring, mass aux F0,a0; # forces, accelerations aux F1,a1; aux F2,a2; aux F3,a3; aux F4,a4; x0'=v0; # the velocities are the derivatives of the displacements x1'=v1; x2'=v2; x3'=v3; x4'=v4; F0=D*(x1-2*x0); # forces of the springs F1=D*(x2-2*x1+x0); F2=D*(x3-2*x2+x1); F3=D*(x4-2*x3+x2); F4=D*(-2*x4+x3); a0=F0/m; # Newton's second Laws a1=F1/m; a2=F2/m; a3=F3/m; a4=F4/m; v0'=a0; # the accelerations are the derivatives of the velocities v1'=a1; v2'=a2; v3'=a3; v4'=a4; endmodel; x0=1; # initial displacement v0=0; # initial velocity D=10; # the constant of the spring [N/m] m=1; # mass [kg] run(0,1.5,0.01,x0,v0,a0); # interval of the modelling print(table,0,1.5,0.1,x0,v0,x2,v2,x4,v4); # table plot(graph,0,1.5,0.03,x0=a(-1,1),x2=b(-1,1),x4=c(-1,1)); # graph