In this system there is a wheeled cart moving along a horizontal track. From the cart a pendulum is suspended. A spring is attached to the cart as shown.
There are two ways to find the equations of motion for a system like this, the direct Newtonian way or the indirect Lagrangian way. We show both methods here.
For both direct and indirect methods, we first need to get the kinematics right. Kinematics means the relations of the parts of the device, without regard to forces. In kinematics we are only trying to find expressions for the position, velocity, & acceleration in terms of whatever variables we have chosen.
The variables we choose here are:
We'll need the standard unit vectors,
The kinematics for the cart are simple
velocity = x' i
acceleration = x'' i
The kinematics for the pendulum are more complex.
velocity = x' i + R θ' cos θ i + R θ' sin θ j
acceleration = x'' i + R θ'' cos θ i
The position is derived by a fairly simple application of trigonometry. The velocity and acceleration are then just the first and second derivatives of the position.
We treat the cart and the pendulum bob as point particles. Begin by drawing the free body diagram for the cart and writing an expression for the net force acting it.
The variables are as follows
The forces on the cart are the spring force
Now using Newton's law
Next we draw the free body diagram for the pendulum. The forces on the pendulum are the tension in the rod and gravity. So we can write the net force as:
F = T cos θ j - T sin θ i - m g j
Using Newton's law
Now we can write the vector components of the above equations 1 & 2 as separate equations. This gives us 4 simultaneous equations.
N - M g - T cos θ = 0
- T sin θ = m(x'' + R θ'' cos θ - R θ'2 sin θ) (eqn 4)
T cos θ - m g = m(R θ'' sin θ
Now we do some algebraic manipulations to eliminate the unknown tension
(M + m)x'' = m R θ'2 sin θ - m R θ'' cos θ - k x (eqn 6)
Multiply equation 5 by
Use equation 4 to replace
This simplifies to
Using the trig identity
x''cos θ + R θ'' + g sin θ = 0 (eqn 7)
Equations 6 and 7 are the equations of motion. We have two equations in the two variables
x''cos θ + R θ'' + g sin θ = 0 (eqn 7)
We will need to do some further manipulations of these two equations to get them into a form suitable for the Runge-Kutta numerical analysis method (see below).
The indirect method is based on the energy of the system. In the current example there are no non-conservative forces (ie. no friction or damping) so we get to skip some steps. Our first step is to find the Lagrangian of the system which is the kinetic energy minus the potential energy.
L = T - V
For the kinetic energy we need the velocity of the cart and pendulum, which we calculated earlier
(see kinematics above). Kinetic energy is given by
Applying the dot product rule to square the vectors we get
There are two stores of potential energy in this system: the spring and the gravitational potential of the pendulum.
Vspring = (1/2)k x2
Vgravity = m g height = m g(R - R cos θ)
So the Lagrangian for the system is
Next we will derive the equations of motion from Lagrange's Equation. For the
0 =
Note that
L = M x' + m(x' + R θ' cos θ)
L = - k x
Taking the derivative with respect to time of L
L
= M x'' + m x'' + m R θ'' cos θ
which we can rearrange to be identical to the corresponding equation found above in the direct method
Here again is the Lagrangian for the system:
For the
0 =
Here are the partial derivatives:
L = m(x' + R θ' cos θ)R cos θ
L = -m(x' + R θ' cos θ)R θ' sin θ
Note that we can divide out the constant L
L
=
We can fully expand this to
After lots of cancellations and using the identity
x''cos θ + R θ'' + g sin θ = 0 (eqn 7)
To solve the equations of motion numerically, so that we can drive the simulation, we use the Runge-Kutta method for solving sets of ordinary differential equations.
To use the Runge-Kutta method, we need to get equations 6 and 7 into the following form:
x'' = f(x, x', θ, θ')
θ'' = g(x, x', θ, θ')
where
x''cos θ + R θ'' + g sin θ = 0 (eqn 7)
Here are the manipulations needed to get these equations into the desired form. First we rearrange equations 6 and 7 to the following:
θ'' = -x''cos θ/R - (g/R) sin θ (eqn 9)
Substitute equation 9 into equation 8 and then solve for
(M + m - m cos2θ)x'' = m R θ'2 sin θ
m R θ'2 sin θ + m g cos θ sin θ - k x
x'' = ————————————————————————————————————— (eqn 10)
M + m sin2θ
|
Substitute equation 8 into equation 9 and solve for
cos θ[m R θ'2 sin θ - m R θ'' cos θ - k x] -R θ'' = —————————————————————————————————————————— + g sin θ M + m |
m R θ'2sin θ cos θ - k x cos θ + g(M + m)sin θ θ'' = —————————————————————————————————————————————— -R(M+m) + m R cos2θ |
-m R θ'2sin θ cos θ + k x cos θ - g(M + m)sin θ
θ'' = ——————————————————————————————————————————————— (eqn 11)
R (M + m sin2θ)
|
Equations 10 and 11 are now close to the form needed for the Runge-Kutta method. The final step is convert these two 2nd order equations into four 1st order equations. First we define the first derivatives as separate variables:
Then we can write the four 1st order equations:
x' = v
θ' = ω
m R ω2 sin θ + m g cos θ sin θ - k x
v' = ————————————————————————————————————— (eqn 10)
M + m sin2θ
|
-m R ω2 sin θ cos θ + k x cos θ - g(M + m)sin θ
ω' = ——————————————————————————————————————————————— (eqn 11)
R (M + m sin2θ)
|
This is now exactly the form needed to plug in to the Runge-Kutta method for numerical solution of the system.