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/notebooks/jump2.ipynb
Views: 531
Modeling and Simulation in Python
Bungee dunk example, taking into account the mass of the bungee cord
Copyright 2019 Allen Downey
Bungee jumping
In the previous case study, we simulated a bungee jump with a model that took into account gravity, air resistance, and the spring force of the bungee cord, but we ignored the weight of the cord.
It is tempting to say that the weight of the cord doesn't matter, because it falls along with the jumper. But that intuition is incorrect, as explained by Heck, Uylings, and Kędzierska. As the cord falls, it transfers energy to the jumper. They derive a differential equation that relates the acceleration of the jumper to position and velocity:
where is the net acceleration of the number, is acceleration due to gravity, is the velocity of the jumper, is the position of the jumper relative to the starting point (usually negative), is the length of the cord, and is the mass ratio of the cord and jumper.
If you don't believe this model is correct, this video might convince you.
Following the example in Chapter 21, we'll model the jump with the following modeling assumptions:
Initially the bungee cord hangs from a crane with the attachment point 80 m above a cup of tea.
Until the cord is fully extended, it applies a force to the jumper as explained above.
After the cord is fully extended, it obeys Hooke's Law; that is, it applies a force to the jumper proportional to the extension of the cord beyond its resting length.
The jumper is subject to drag force proportional to the square of their velocity, in the opposite of their direction of motion.
First I'll create a Param
object to contain the quantities we'll need:
Let's assume that the jumper's mass is 75 kg and the cord's mass is also 75 kg, so
mu=1
.The jumpers's frontal area is 1 square meter, and terminal velocity is 60 m/s. I'll use these values to back out the coefficient of drag.
The length of the bungee cord is
L = 25 m
.The spring constant of the cord is
k = 40 N / m
when the cord is stretched, and 0 when it's compressed.
I adopt the coordinate system and most of the variable names from Heck, Uylings, and Kędzierska.
Now here's a version of make_system
that takes a Params
object as a parameter.
make_system
uses the given value of v_term
to compute the drag coefficient C_d
.
It also computes mu
and the initial State
object.
Let's make a System
drag_force
computes drag as a function of velocity:
Here's drag force at 20 m/s.
The following function computes the acceleration of the jumper due to tension in the cord.
Here's acceleration due to tension in the cord if we're going 20 m/s after falling 20 m.
Now here's the slope function:
As always, let's test the slope function with the initial params.
We'll need an event function to stop the simulation when we get to the end of the cord.
We can test it with the initial conditions.
And then run the simulation.
Here's how long it takes to drop 25 meters.
Here's the plot of position as a function of time.
We can use min
to find the lowest point:
Here's velocity as a function of time:
Velocity when we reach the end of the cord.
Although we compute acceleration inside the slope function, we don't get acceleration as a result from run_ode_solver
.
We can approximate it by computing the numerical derivative of v
:
The maximum downward acceleration, as a factor of g
Using Equation (1) from Heck, Uylings, and Kędzierska, we can compute the peak acceleration due to interaction with the cord, neglecting drag.
If you set C_d=0
, the simulated acceleration approaches the theoretical result, although you might have to reduce max_step
to get a good numerical estimate.
Sweeping cord weight
Now let's see how velocity at the crossover point depends on the weight of the cord.
Here's what it looks like. As expected, a heavier cord gets the jumper going faster.
There's a hitch near 25 kg that seems to be due to numerical error.
Phase 2
Once the jumper falls past the length of the cord, acceleration due to energy transfer from the cord stops abruptly. As the cord stretches, it starts to exert a spring force. So let's simulate this second phase.
spring_force
computes the force of the cord on the jumper:
The spring force is 0 until the cord is fully extended. When it is extended 1 m, the spring force is 40 N.
The slope function for Phase 2 includes the spring force, and drops the acceleration due to the cord.
I'll run Phase 1 again so we can get the final state.
Now I need the final time, position, and velocity from Phase 1.
And that gives me the starting conditions for Phase 2.
Here's how we run Phase 2, setting the direction of the event function so it doesn't stop the simulation immediately.
We can plot the results on the same axes.
And get the lowest position from Phase 2.
To see how big the effect of the cord is, I'll collect the previous code in a function.
Now we can run both phases and get the results in a single TimeFrame
.
The difference is more than 2 meters, which could certainly be the difference between a successful bungee dunk and a bad day.