Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/examples/yoyo.ipynb
Views: 531
Simulating a Yo-Yo
Modeling and Simulation in Python
Copyright 2021 Allen Downey
License: Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
Yo-yo
Suppose you are holding a yo-yo with a length of string wound around its axle, and you drop it while holding the end of the string stationary. As gravity accelerates the yo-yo downward, tension in the string exerts a force upward. Since this force acts on a point offset from the center of mass, it exerts a torque that causes the yo-yo to spin.
The following diagram shows the forces on the yo-yo and the resulting torque. The outer shaded area shows the body of the yo-yo. The inner shaded area shows the rolled up string, the radius of which changes as the yo-yo unrolls.
In this system, we can't figure out the linear and angular acceleration independently; we have to solve a system of equations:
where the summations indicate that we are adding up forces and torques.
As in the previous examples, linear and angular velocity are related because of the way the string unrolls:
In this example, the linear and angular accelerations have opposite sign. As the yo-yo rotates counter-clockwise, increases and , which is the length of the rolled part of the string, decreases.
Taking the derivative of both sides yields a similar relationship between linear and angular acceleration:
Which we can write more concisely:
This relationship is not a general law of nature; it is specific to scenarios like this where there is rolling without stretching or slipping.
Because of the way we've set up the problem, actually has two meanings: it represents the length of the rolled string and the height of the yo-yo, which decreases as the yo-yo falls. Similarly, represents acceleration in the length of the rolled string and the height of the yo-yo.
We can compute the acceleration of the yo-yo by adding up the linear forces:
Where is positive because the tension force points up, and is negative because gravity points down.
Because gravity acts on the center of mass, it creates no torque, so the only torque is due to tension:
Positive (upward) tension yields positive (counter-clockwise) angular acceleration.
Now we have three equations in three unknowns, , , and , with , , , and as known parameters. We could solve these equations by hand, but we can also get SymPy to do it for us.
The results are
where is the augmented moment of inertia, .
You can also see the derivation of these equations in this video.
We can use these equations for and to write a slope function and simulate this system.
Exercise: Simulate the descent of a yo-yo. How long does it take to reach the end of the string?
Here are the system parameters:
Rmin
is the radius of the axle.Rmax
is the radius of the axle plus rolled string.Rout
is the radius of the yo-yo body.mass
is the total mass of the yo-yo, ignoring the string.L
is the length of the string.g
is the acceleration of gravity.
Based on these parameters, we can compute the moment of inertia for the yo-yo, modeling it as a solid cylinder with uniform density (see here).
In reality, the distribution of weight in a yo-yo is often designed to achieve desired effects. But we'll keep it simple.
And we can compute k
, which is the constant that determines how the radius of the spooled string decreases as it unwinds.
The state variables we'll use are angle, theta
, angular velocity, omega
, the length of the spooled string, y
, and the linear velocity of the yo-yo, v
.
Here is a State
object with the initial conditions.
And here's a System
object with init
and t_end
(chosen to be longer than I expect for the yo-yo to drop 1 m).
Write a slope function for this system, using these results from the book:
where is the augmented moment of inertia, .
Test your slope function with the initial conditions. The results should be approximately
Notice that the initial acceleration is substantially smaller than g
because the yo-yo has to start spinning before it can fall.
Write an event function that will stop the simulation when y
is 0.
Test your event function:
Then run the simulation.
Check the final state. If things have gone according to plan, the final value of y
should be close to 0.
How long does it take for the yo-yo to fall 1 m? Does the answer seem reasonable?
The following cells plot the results.
theta
should increase and accelerate.
y
should decrease and accelerate down.
Plot velocity as a function of time; is the acceleration constant?
We can use gradient
to estimate the derivative of v
. How does the acceleration of the yo-yo compare to g
?
And we can use the formula for r
to plot the radius of the spooled thread over time.