Using generalized coordinates and Lagrange Equations
In this example, we are considering the motion of 3 objects attached by pulleys to a supporting ceiling.

This system has 5 moving parts: 2 pulleys and 3 blocks
but, there are only 2 independent degrees of freedom
We can choose different ways to describe the state of the system, but we can only choose 2 independent generalized coordinates.
In this case, we use
$$\mathbf{q} = [y_1,~y_2]$$
Using system pulley constraints, the following relations are true,
$$\dot{s}_2 = \dot{y}_1 - \dot{y}_2$$
and
$$\dot{s}_3 = \dot{y}_1 + \dot{y}_2$$
and the total kinetic energy is
$$T = \frac{1}{2}m_1\dot{y}_1^2 + \frac{1}{2}m_2\dot{s}_2^2 +\frac{1}{2}m_3\dot{s}_3^2$$
where it follows,
$$T = \frac{1}{2}m_1\dot{y}_1^2 + \frac{1}{2}m_2(\dot{y}_1 - \dot{y}_2)^2 +\frac{1}{2}m_3(\dot{y}_1 + \dot{y}_2)_3^2$$
and the potential energy changes are given as
$$V = -m_1gy_1 + m_2g s_2 + m_3 g s_3$$
or
$$V = -m_1gy_1 + m_2g(y_1 - y_2) + m_3 g (y_1 + y_2)$$
The Lagrange equations create differential equations that relate all the degrees of freedom. In this case, we will have 2 second order differential equations,
$$\frac{d}{dt}\left(\frac{\partial L}{\partial \dot{y}_1}\right) = \frac{\partial L}{\partial y_1}$$
$$\frac{d}{dt}\left(\frac{\partial L}{\partial \dot{y}_2}\right) = \frac{\partial L}{\partial y_2}$$
or
$$(m_1 + m_2 + m_3)\ddot{y}_1 + (m_3 - m_2)\ddot{y}_2 = (m_1 - m_2 - m_3)g$$
$$(m_3 - m_2)\ddot{y}_1 + (m_2 + m_3)\ddot{y}_2 = (m_2 - m_3)g$$
using Plots, OrdinaryDiffEq
If all the masses are equal, only \(y_1\) should change. If \(m_2+m_3 = m_1\), what happens next? Will the motion of blocks 2 and 3 move block 1?
@doc raw"""
Solve for accelerations a1 and a2 for motion of blocks in the given pulley system.
1. $(m_1 + m_2 + m_3)\ddot{y}_1 + (m_3 - m_2)\ddot{y}_2 = (m_1 - m_2 - m_3)g$
2. $(m_3 - m_2)\ddot{y}_1 + (m_2 + m_3)\ddot{y}_2 = (m_2 - m_3)g$
"""
function pulley_accel(m1, m2, m3)
g = 9.81
M = [m1+m2+m3 m3 - m2;
m3-m2 m2+m3]
b = [m1 - m2 - m3;
m2-m3]*9.81
return M\b
end
pulley_accel(1, 0.8, 0.2)
2-element Vector{Float64}:
2.153414634146342
7.178048780487806
Wrapping up
We have constant acceleration for three blocks with constrained motion. The kinematic equations demonstrate motion
$$x_i(t) = x_0 + v_0t + \frac{1}{2}at^2$$
Below, there are a lot of filler functions for plotting pulleys and blocks. The result is that you can play with the masses of each block to see the motion over 0.5 sec. Try some different values for \(m_1,~m_2,~m_3\) and see what the results are? Can you get \(m_1\) to stay motionless while \(m_2\) and \(m_3\) move?
draw_pulley! (generic function with 1 method)
plot_pulley_diagram (generic function with 1 method)
function calc_motion(m1, m2, m3,
N = 50)
t = LinRange(0, 0.5, N)
a1, a2 = pulley_accel(m1, m2, m3)
y1 = 1 .- a1.*t.^2/2
p2 = 0.5 .+ a1.*t.^2/2
y2 = -a2.*t.^2/2 .+ p2 .- 1
y3 = a2.*t.^2/2 .+ p2 .- 1
return y1, p2, y2, y3
end
calc_motion (generic function with 2 methods)
begin
y1, p2, y2, y3 = calc_motion(1, 0.2, 0.8)
@gif for i in 1:length(y1)
block_positions = Dict(
:block1 => (1.0, y1[i]),
:block2 => (1.8, y2[i]),
:block3 => (2.2, y3[i]),
)
pulley_positions = Dict(
:circle1 => (1.5, 2.0), # big pulley
:circle2 => (2.0, p2[i]), # small pulley
)
diagram_plot = plot_pulley_diagram(block_positions, pulley_positions)
ylims!(-2, 3)
diagram_plot
end
end
Built with Julia 1.12.4 and
OrdinaryDiffEq 6.108.0Plots 1.41.6
To run this tutorial locally, download this file and open it with Pluto.jl.

