0% found this document useful (0 votes)
9 views24 pages

CS Project PDF

Uploaded by

Baishali Sur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views24 pages

CS Project PDF

Uploaded by

Baishali Sur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

Modeling and Simulation of Optimal

baseball problem and Bungee Jumping

By Baishali Sur
2111240, Int. Msc.
What is Modelling and Simulation?

 We have a system in the real world that interests us, and want to know the
properties about. Often, real-world systems are very complicated, so we
must decide which details can be left out; removing details is called
abstraction.
 The result of abstraction is a model, which describes the system and
includes only the features we think are essential. A model can be
represented in the form of diagrams and equations, which can be used for
mathematical analysis. It can also be implemented in the form of a
computer program, which can run simulations.
 The result of analysis and simulation might be a prediction about what the
system will do, an explanation of why it behaves the way it does, or a
design intended to achieve a purpose.
The Baseball Problem:

 We will model the flight of a baseball first.


 Assumptions:
1. We ignore any spin that might be on the ball and the resulting Magnus
U force. Under this assumption, the ball travels in a vertical plane, so we’ll run
simulations in two dimensions rather than three.
2. We’ll start with a simple model where the drag coefficient does not
depend on velocity.
For this, we will need a vector object. The ModSim library provides a Vector
object that represents a vector quantity. A Vector object is like a NumPy array;
it contains elements that represent the components of the vector.
Modelling the flight of a baseball

 Let’s simulate the flight of a baseball that is batted from home plate at an
angle of 45° and initial speed 40 m/s. Using the center of home plate as the
origin, the x-axis is parallel to the ground; the y-axis is vertical. The initial
height is about 1 m.
Modelling the flight of a baseball

The trajectory will look like this:


The Manny Ramirez Problem

Fenway Park is a baseball stadium in Boston, Massachusetts. One of its most


famous features is the “Green Monster”, which is a wall in left field that is
unusually close to home plate, only 310 feet away. To compensate for the
short distance, the wall is unusually high, at 37 feet.
We want to find the minimum velocity at which a ball can leave the home
plate and still go over the Green Monster.
We’ll proceed in the following steps:
1. For a given velocity, we’ll find the optimal launch angle: the angle the ball
should leave home plate to maximize its height when it reaches the wall.
2. Then we’ll find the minimal velocity that clears the wall, given that it has the
optimal launch angle.
.

We again create a params


object to store all the
parameters. Then, we create an
event function that stops the
simulation when the ball is at the
wall distance. Next, write a height
function that takes a launch
angle, simulates the flight of a
baseball, and returns the height
of the baseball when it reaches
the wall. Now, we
use maximize_scalar to find the
optimal angle. Now, let’s find the
initial speed that makes the
height at the wall exactly 37 feet,
given that it’s launched at the
optimal angle. This is a root-
finding problem, so we’ll
use root_scalar.
We Write an error function that
takes a speed and
a System object as parameters. It
uses maximize_scalar to find the
highest possible height of the ball
at the wall for the given speed.
Then, it returns the difference
between that optimal height
and wall_height, a parameter
in params. Then, we
use root_scalar to find the answer
to the problem, the minimum
speed that gets the ball out of
the park.
The answer for the minimum
speed here is
41.039294634028856 and the
optimal angle here is
43.105080979149434.
The trajectory of the ball is:
Applying this model to a different scenario: The
basketball problem
 I tried to do the same thing I did for the baseball optimization problem, find
the optimal angle and the minimum velocity that gets the ball past the
hoop. I have followed the same procedure, with the parameters from an
average basketball, and the height of an average basketball player and
the distance and height of a basketball hoop.
 The results are: The optimal angle here is around 74 degrees, and the
minimum speed is 15.339 m/s. The trajectory is:
Bungee Jumping: Bungee Dunk
 A Bungee Dunk is a stunt in which a bungee jumper dunks a cookie in a
cup of tea at the lowest point of a jump.
 We aim to set a record for the longest Bungee Dunk: i.e., 80 meters. For this,
we start with the following modeling assumptions:
1. Initially the bungee cord hangs from a crane with the attachment point
80 m above a cup of tea.
2. Until the cord is fully extended, it applies no force to the jumper. It turns out
this might not be a reasonable assumption; we’ll revisit it in the following
case study.
3. After the cord is fully extended, it obeys Hooke’s Law; that is, it applies a
force to the jumper proportional to the extension beyond its resting length.
The mass of the jumper is 75 kg.
4. The jumper is subject to drag force so that their terminal velocity is 60 m/s.

Our objective is to choose the length of the cord, L, and its spring constant, k,
so that the jumper falls all the way to the teacup, but no farther!
First, we’ll create a Param object to contain the quantities we'll need:

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.
Then, we run the simulation and plot the position as a function of time to obtain the
trajectory.

The position of the jumper vs time plot looks like this:

After reaching the lowest point, the jumper springs back almost to almost 70 m and
oscillates several times. That looks like more oscillation that we expect from an actual
jump, which suggests that there is some dissipation of energy in the real world that is not
captured in our model.
We see that the jumper does not reach the full length, so the cord length or the cord
tension need to be modified. We find out the cord length for which the jumper’s lowest
point is exactly 0.
To find the length of the cord
required to make the jump, we
write an error function that
simulates a bungee jump, and
returns the lowest point.

We use root_scalar with the error


function to find the value of cord
length that yields a perfect bungee
dunk.

After simulating with the required length


of cord, we get the position vs time plot
as:

Here we see that the lowest point of the


first jump is zero, which is our
requirement.
Bungee Dunk: With a different model

 In the previous case study, we assume that the cord applies no force to the
jumper until it is stretched. It is tempting to say that the cord has no effect
because it falls along with the jumper, but that intuition is incorrect. As the
cord falls, it transfers energy to the jumper. So, we modify our model to
accommodate the force due to the jumper.
 With accommodating that, the acceleration of the jumper becomes:

 Where g is the acceleration due to gravity, L is the length of the cord, and
μ is the ratio of the mass of the cord, m, and the mass of the jumper, M.
Assumptions:
 Following the previous case study, we'll model the jump with the following assumptions:
1. Initially, the bungee cord hangs from a crane with an attachment point 80 m above a cup
of tea.
2. Until the cord is fully extended, it applies a force to the jumper as explained above.
3. After the cord is fully extended, it obeys Hooke’s law, that is, it applies a force to the
jumper proportional to the extension beyond its resting length.
4. The jumper is subject to drag force proportional to the square of their velocity, opposite
their direction of motion.
5. Let's assume that the jumper's mass is 75 kg and the cord's mass is also 75 kg, so mu=1.

6. The jumper'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.
7. The length of the bungee cord is L = 25 m.

8. The spring constant of the cord is k = 40 N / m when the cord is stretched, and 0 when it's
compressed.
We divide the simulation into Phases 1 and Phase 2, phase 1 for which the
jumper has not fallen the entire length of the rope and the rope is slack, and
phase 2 for which the rope is extended.
For phase 1, we only modify the function which computes the acceleration of
the jumper.

And then we run the simulation with an event function that stops the
simulation when we get to the end of the cord.
For phase 2, Once the jumper has falled more than 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.
Then we follow similar procedure as before, and run the simulation. The position vs time
plot will look like:
I tried to investigate how would the jump vary with the variation of the mass of
the cord, here is the result. With varying mass of cord, the μ varies, and so does
the force exerted by the cord. The difference between lowest and highest
value of μ is the difference in lowest points of the jump, which is 1 meter. The
rest of the values of μ are in between them.
I also tried to investigate how these trajectories vary with the mass of the
jumper. Here is the plot for the position vs time of the jumper for different
masses of the jumper. It is as expected, with the lightest jumper falling to the
least length and the heaviest jumper falling the most.
Applying the model to a
different scenario: The
falling body problem

I have, once again, used the


same procedure to the problem
of a falling body, and tried to
map its position vs. time. The
properties I use are follows:

The position vs time graph is :


References:

 Modeling and Simulation in Python, Version 3.4.3, by Allen B. Downey


 https://www.sciencedirect.com/
 https://www1.grc.nasa.gov/
 Understanding the physics of bungee jumping, André Heck et al 2010 Phys.
Educ. 45 63
THANK YOU!!

You might also like