Report on the derivation of the solid pendulum with mass-spring system demonstration

Nasser M. Abbasi, updated August 28, 2012

Physical description of the problem

The problem is described in the following diagram

A solid pendulum has a mass-less tube at the end of it with spring around it that has a bob at its end. Hence the mass-spring can only move in a horizontal direction inside the tube. There are 2 degrees of freedom for this system x(t) and θ(t) . The Lagrangian is derived for the case if a spring is present of not.

Derivation for the solid pendulum with the case when the spring is present

The kinetic energy KE is given by

vSquared=((x'[t]+L0 θ'[t])^2+(x[t] θ'[t])^2);
momentOfInteriaOfBar= m0(L0^2)/3;
ke=(1/2) M0 vSquared+(1/2) (momentOfInteriaOfBar)θ'[t]^2

and the potential energy is given by (assuming the pivot at zero potential, and negative potential is below that)

pe=-m0 g  L0/2 Cos[θ[t]]- M0 g( L0 Cos[θ[t]]-x[t] Sin[θ[t]])+1/2 k x[t]^2

The Lagrangian is found and the differential equations derived

lagrangian=ke-pe;
eq1=D[D[lagrangian,x'[t]],t]-D[lagrangian,x[t]]==0

eq2=D[D[lagrangian,θ'[t]],t]-D[lagrangian,θ[t]]==0

Parameters are given values, NDSolve is used to generate numerical solution

params={k->1,M0->10,g->9.8,L0->.5,m0->0};
ic={x[0]==0.04,x'[0]==0,θ[0]==45 Degree,θ'[0]==0};
sol=NDSolve[Flatten[{eq1,eq2,ic}]/.params,{x,θ,x',θ'},{t,0,0.5},Method->{"StiffnessSwitching"}]

Grid[{{Plot[x[t]/.sol,{t,0,0.5},PlotRange->All,AxesOrigin->{0,0}],Plot[θ[t]/.sol,{t,0,0.5},PlotRange->All,AxesOrigin->{0,0}]}}]

Derivation for the solid pendulum with the case when spring is missing

The kinetic energy remain the same and is given by

vSquared=((x'[t]+L0 θ'[t])^2+(x[t] θ'[t])^2);
momentOfInteriaOfBar= m0(L0^2)/3;
ke=(1/2) M0 vSquared+(1/2) (momentOfInteriaOfBar)θ'[t]^2

and the potential energy is given by (assuming the pivot at zero potential, and negative potential is below that)

pe=-m0 g  L0/2 Cos[θ[t]]- M0 g( L0 Cos[θ[t]]-x[t] Sin[θ[t]])

The Lagrangian is found and the differential equations derived

lagrangian=ke-pe;
eq1=D[D[lagrangian,x'[t]],t]-D[lagrangian,x[t]]==0

eq2=D[D[lagrangian,θ'[t]],t]-D[lagrangian,θ[t]]==0

Parameters are given values, NDSolve is used to generate numerical solution

params={k->1,M0->10,g->9.8,L0->.5,m0->0};
ic={x[0]==0.04,x'[0]==0,θ[0]==45 Degree,θ'[0]==0};
sol=NDSolve[Flatten[{eq1,eq2,ic}]/.params,{x,θ,x',θ'},{t,0,0.5},Method->{"StiffnessSwitching"}]

Grid[{{Plot[x[t]/.sol,{t,0,0.5},PlotRange->All,AxesOrigin->{0,0}],Plot[θ[t]/.sol,{t,0,0.5},PlotRange->All,AxesOrigin->{0,0}]}}]

Derivation for the massless pendulum with the spring present

This case was not part of the demo. But I include the model here for illustration. In this case, the  pendulum is assumed massless. As follows

In this case, for some reason, singularity can be generated by NDSolve under some very specific conditions.

Kinetic energy

vSquared=((x'[t]+L0 θ'[t])^2+(x[t] θ'[t])^2);
ke=(1/2) M0 vSquared

Potential energy

pe=- M0 g( L0 Cos[θ[t]]-x[t] Sin[θ[t]])+1/2 k x[t]^2

Lagrnagian is found and the 2 equations derived

lagrangian=ke-pe;
eq1=D[D[lagrangian,x'[t]],t]-D[lagrangian,x[t]]==0

eq2=D[D[lagrangian,θ'[t]],t]-D[lagrangian,θ[t]]==0

NDSolve is used to solve and solution is plotted

params={k->1,M0->10,g->9.8,L0->.5};
ic={x[0]==0.04,x'[0]==0,θ[0]==45 Degree,θ'[0]==0};
sol=NDSolve[Flatten[{eq1,eq2,ic}]/.params,{x,θ,x',θ'},{t,0,0.5},Method->{"StiffnessSwitching"}]

Grid[{{Plot[x[t]/.sol,{t,0,0.5},PlotRange->All,AxesOrigin->{0,0}],Plot[θ[t]/.sol,{t,0,0.5},PlotRange->All,AxesOrigin->{0,0}]}}]

Singularity exist under some specific conditions. Needs more investigation

ic={x[0]==0.23,x'[0]==-2,θ[0]==5,θ'[0]==3};
sol=NDSolve[Flatten[{eq1,eq2,ic}]/.params,{x,θ,x',θ'},{t,0,0.1},Method->{"StiffnessSwitching"}]

NDSolve::ndsz: