single pendulum
single pendulum
The following are the equations of a nonlinear pendulum with mass m and length L under gravity g. The angle with respect to the verical is theta:
Compare the nonlinear solution with the following linearized version around the critical point (2pi,0) (i.e. k=2), with the same initial conditions. In order to obtain a comparison figure, you can execute the nonlinear version and during the execution select the opcion "File, Edit RHS" in order to change ¨sin(x)¨ by ¨(x-2*pi)¨. Then compare the phase diagrams (see spiral figure below).
The linealized pendulum presents a non-realistic behavior far away from the critical point (0,2*pi).
# nonlinear single pendulum
dx/dt = y
dy/dt = -b/M*y-g/L*sin(x)
# initial conditions
x(0)=0
y(0)=6
# initial energy
Ei=M*g*L*(1-cos(0))+.5*M*(L*6)^2
# total energy
Ep=M*g*L*(1-cos(x))
Ec=.5*M*(L*y)^2
Et=Ep+Ec
aux E.P.=Ep
aux E.C.=Ec
aux E.T.=Et
# Parameters
param M=10,b=4,g=9.8,L=4
param scale=0.0083333
@ bounds=50000
@ xplot=x, yplot=y
@ xlo=-10, xhi=10, ylo=-6, yhi=6
@ DT=0.025
done
The equation can be written as a system of two equations by means of two states: the angle x=theta and the angular velocity y=theta’.
Its behavior is shown, as well as a phase diagram and total energy.