Preface From time to time,
the AiS coordinators and teachers have talked about trying to get students
involved in the activity of "journaling" their project work. In working
on the mathematical template that follows, I have made and effort to walk
through the modeling steps in "journal mode". I am beginning to think that
we might be able to use this type of "fill in the template" as a means
to get students to produce journals of their progress in working through
a computational science project. Maybe we can use this kind of exercise
to parallel what students do in laboratory based courses.
1. Identify Problem Area
We have chosen to study the behavior of a pendulum and try to learn
how the length of the pendulum arm and the size and mass of the pendulum
bob affect its motion.
2. Background Research Using Yahoo to search on the keyword "pendulum" produced several useful resources:
At the site
http://es.rice.edu/ES/humsoc/Galileo/Student_Work/Experiment95/galileo_pendulum.htmlwe found that
"Pendulums are mentioned in both Galileo's Dialogue Concerning the Two Chief World Systems and his Dialogues Concerning Two New Sciences. In these two works, Galileo discusses some of the major points he discovered about pendulums. Follow the links to jump to an experimental evaluation of the claim.
http://www.calacademy.org/products/pendulum.htmlwe found that there is a type of pendulum called the Foucault Pendulum which was "the first terrestrial device to demonstrate the rotation of the earth". This is very interesting, but we chose to restrict this project to pendulums like those found on grandfather clocks.
The URL
http://theory.uwinnipeg.ca/physics/shm/node5.htmlprovides a diagram of a simple pendulum and states that the pendulum experiences a net restoring force due to gravity of
This site also states that if we approximate the term
by
in the restoring force expression, then the period of the pendulum is independent
of the amplitude of the angle through which it swings. This would support
Galileo's claim based on experiments: "The period is independent of the
amplitude."
At this point in our research we have found some of the things we will need to develop a mathematical model of a pendulum, but we think we need to know more. To find more about the physics of a pendulum, we conducted an advanced search asking Yahoo to search for the words pendulum AND physics. This led to the URL
http://www.smv.mus.va.us/balance.htmwhere we found
"Newton's First Law of Motion says that an object in motion tends to remain in motion at a constant speed and direction unless a force acts upon it and that an object at rest tends to remain at rest unless a force acts on it. This tendency of an object to keep doing whatever it is doing is called inertia and it has two components: mass and velocity. The product of these two components is called momentum. If we increase either the mass or the velocity of an object, we increase its momentum. The greater the momentum, the greater the force required to change it. We call the tendency of an object to maintain its position or speed and direction, to resist a force-conservation of momentum."
The mass of our pendulum bob is constant and its velocity changes, so we know that its momentum is not constant as it swings. Reading a little further in this reference we find, "Newton's Second Law of Motion defines acceleration as a change in speed or direction when a force is applied."
So, it seems we need to find more about Newton's Second Law. Using Yahoo to search for the words Newton's AND Second AND Law produced 15,045 web sites!! The first line of the the first URL states, "We define a force as the time rate of change of a particle's momentum"
With this last piece of information we felt ready to move on to the
next stages of our project.
3. Identify Project Goal and State Simplifying Assumptions
Our background research uncovered many possible projects we could pursue on the subject of pendulums. One area we found interesting was Galileo's claim that, "The period is independent of the amplitude." Our first reference showed how to do an experiment that shows this claim is not true. We decided the goal of our project will be to develop a mathematical model that allows us to study how a pendulum's amplitude affects its period. For our initial study we chose to make these simplifying assumption:
We plan to develop a mathematical model that predicts the position and the velocity of the pendulum bob at equally spaced times, with the user having the ability to choose the interval between the "observation times" or time grid points. With this plan in mind we introduce the following notation for the input and output variables and parameters for our problem. We think of input variables as quantities that will be provided by the user to the program at run time. Output variables are quantities that the computer program computes and returns to the user. Auxiliary variables are quantities derived from groupings of input or output variables. Parameters are problem dependent constants that are set at the time the program is compiled.
| Notation | Description | Units | Type |
|---|---|---|---|
| m | Mass of Pendulum Bob | Mass | Parameter |
| g | Gravitational Acceleration | Length/(Time2) | Parameter |
| L | Length of Pendulum | Length | Input Variable |
| Time Increment | Time | Input Variable | |
| IMAX | Number of Time Steps to be Computed | Unitless | Input Variable |
| ti | Time Grid Point | Time | Auxiliary Variable |
| Initial Deflection Angle | Radians | Input Variable | |
| Deflection Angle at time ti | Radians | Auxiliary Variable | |
| v0 | Initial Angular Velocity of Bob | Length/Time | Input Variable |
| vi | Approximate Angular Velocity of Bob | Length/Time | Output Variable |
| si | Arc Length Measured from Vertical | Length | Output Variable |
The last equation reflects the fact that we have chosen to let vi
represent the approximate velocity on the interval from ti-1
to ti. That is, in our notation, the subscript on v refers
to the right end of the time interval over which that velocity applies.
5. Identify Governing Principle(s)
Reviewing our Background Research, we recall two important facts we uncovered.
1. Force equals the time rate of change of momentum (Newton's Second Law)
2. The restoring force due to gravity acting on the pendulum
bob equals
At this point we believe these are the principles that govern the behavior of the pendulum. We will next try to develop some equations (a mathematical model) that incorporate these two statements.
6. Develop Mathematical Model Solution Algorithm
In the statement, "Force equals the time rate of change of momentum.",
we know what to use for the Force. We need an expression for, "the time
rate of change of momentum". The change of any quantity over a period of
time of length
is that quantity at the end of the time period minus the quantity at the
beginning of the period. The momentum of the pendulum bob at time ti
is given by mvi. The momentum of the bob
seconds later is given by mvi+1. So, the change
of momentum over the interval of time from ti to ti+1
is mvi+1 - mvi. We can now
write the time rate of change of momentum as
Setting the last expression equal to the restoring force acting on the pendulum bob at time ti gives
We should revise our simplifying assumptions and state that we are assuming we can use the value of the restoring force at the beginning of a time interval as a good approximation to the restoring force during the time interval. We may need to talk more about this approximation.
After dividing each term by the constant mass, m, and some algebra we have
which allows us to predict a new velocity value if we know the present
values of the pendulum's velocity and angular displacement. For example,
if the pendulum is released from rest (v0 = 0) from an
initial angular displacement of
we could compute v1 for a
sec. from
where we have used g = 9.8 meters/sec2.
This gives a value for v1, the pendulum's velocity at
time
.
In addition to predicting the pendulum's velocity we want to predict its
position.
To continue the development of our mathematical model we examine how we can predict a new value of the pendulum's angular displacement. From the Background Research and Notation Sections, we recall that
Our mathematical model consists of the following pair of equations for updating the pendulum's angular velocity and angular displacement starting with given values for the initial velocity and angular displacement
| (1) |
| (2) |
7. Write P-Code
Step 1. Document Code
This algorithm approximates the velocity and angular displacement of the bob of a pendulum using a time stepping scheme to first update the velocity and then use the updated velocity to update the displacement using Equations (1) and (2) of the previous section.
INPUT
Set i = 0 t = 0 theta = theta0 vel = vel0Output i,t,theta,vel
Step 3. Begin Time Stepping
For i = 1,2,3,...IMAX Do Steps 4-5Step 4. Advance Solution One Time Step
Set vel = vel - g*sin(theta)*dt theta = theta + vel*dt/L t = t + dtStep 5. Output Numerical Solution
Output i, t, theta, vel
8. Write and Debug Computer Code
Here is our first attempt at a C++ code that computes the approximate position and velocity of the pendulum bob.
In addition to the C++ code we decided to write a Java
application that does the same calculations as
or C++ code. We used the C++ code as a starting point for our
Java code and commented out the
part of the C++ code that we replaced with Java code. Looking
at our Java application we see it is
very similar to the C++ code in all the calculation parts. The
only change in the calculations is the replacement of sin(theta)
in the C++ code with Math.sin(theta) in the Java code. The
code required to write the output variables was similar in both the C++
and the Java code. Comparing the code
required to receive the input from the keyboard, we found a huge difference
in the two codes. The
convenient cin and cout functions available in C++ made
it very easy to set the input variables in the C++ code. We were
surprised to find how hard it was to use Java to get keyboard input!!
After looking through a few Java books, we found that many authors have written Java classes containing methods that make keyboard input in Java as easy as in C++. On the CD that goes with the book Core Java (Horstmann and Cornell) we found a Console class that we used to construct our second Java application.
One way to gain access the Console class is to
As a partial validation of the code, we plan to use a one meter long pendulum and a stop watch to see if a pendulum released from 45 degrees takes about .5 seconds to reach the vertical (.5 seconds is what the code predicts). We will probably have to time several cycles of the pendulum to get a good timing of a quarter cycle of the pendulum.
To visualize the results of our code, we could proceed in at least two
ways. One approach would be to
modify the C++ code so that it writes output that can be viewed by
some commercial graphics program.
A second approach is to use the graphics capabilities of Java to visualize
the model results. We choose to construct Java code that will produce
graphics using Java's AWT.
The Java code in PendulumFrame.java
is a first start at connecting our calculations to some rudimentary graphics.
We need to make the theta-scale more flexible so that we can visualize
both large and small oscillations.
10. Explore Extensions and Improvements to Mathematical Model
There are several extension and improvements to that we can explore: