2. Mathematical Models
2.1 A Discrete in Time
Mathematical Model
2.1 A Continuous in
Time Mathematical Model
3. Algorithm for
the Discrete in Time Model
3.1 Pseudocode
3.2 C Code Algorithms
4. Computational
Experiments and Model Refinements
4.1 Computational
Experiments
4.2 Model Refinements
As a concrete example of a dynamical system, consider a solid mass attached to a coil spring. The spring is rigidly fixed at one end and the spring and the attached mass are free to move in a line along a horizontal surface. See Figure 1. We define the equilibrium position of the spring-mass system to be that in which the spring is neither compressed nor stretched and the mass is at rest. So that we can formulate a very simple mathematical model describing this physical system, we make the simplifying assumptions that (1) friction between the mass and the supporting horizontal is negligible; (2) if the spring is compressed by a length of L, then it exerts on the mass a force of k*L in the direction of the positive x-axis; and (3) if the spring is stretched by a length of L, then it exerts on the mass a force of k*L in the direction of the negative x-axis.
|--------------------------------------x=0----------------> x-axis
For a spring-mass system, we know from experience that if the spring is
compressed (or stretched) with the mass located at
Quantity |
Symbol |
Units |
| time | t | seconds |
| mass of object | m | kilograms |
| spring constant | k (k > 0) | meters/second/second |
| velocity of the object | V or V(t) | meters/second |
| displacement of the object | X or X(t) | meters |
| initial velocity of the object | V0 or V(0) | meters/second |
| initial displacement of the object | X0 or X(0) | meters |
Definition of Velocity: Velocity equals the rate of change of position.
Definition of Momentum: Momentum equals mass times velocity.
Newton's 2nd Law: Rate of change of momentum equals the applied force.
The definitions of velocity and momentum and Newton's 2nd Law are the physical principles from which we will develop two mathematical models for a spring-mass system.
To develop a discrete in time mathematical model, we mark off a time line as indicated in Fig. 2.
<---- h ---->
------x------|------x------|------x------|------x------|-- (t-axis)
t0 t1/2 t1 t3/2 t2 . . .
The grid we have defined is called a uniform grid since each pair of adjacent grid points are separated by a constant time interval. This time interval between grid points, h, is called the time step, the grid spacing or the mesh spacing.
Following the notation introduced in Figure 2, we can represent an arbitrary grid point on the t-axis as follows.
In the notation table of Section 2.3, we have chosen to denote the physical displacement and velocity of the object by X(t) and V(t), respectively. A common notational convention in mathematical modeling is to use variables of an opposite case to denote the mathematical model approximations of physical quantities. Following this convention, we define xi to be a numerical approximation to X(ti) and vi to be a numerical approximation to V(ti).
Momentum Equation
To continue our development of a mathematical model of the spring-mass system, consider an object of mass m that is moving in a straight line. Suppose the object has initial velocity VI along the x-axis. The initial momentum of this object is
Let VN denote the new velocity of the object after T seconds have elapsed. The new momentum of the object is
According to Newton's 2nd law, if a constant force F aligned with the
x-axis is applied to this object for an interval of time T, then the
change of momentum (new momentum minus old momentum) is equal to
Displacement Equation
If an object moves along a line at a constant rate R for a time T, then the object moves a distance D. In words, "distance traveled (D) equals rate (R) multiplied by time (T)", or
Put another way, if the initial position of the object is PI and the new position of the object T seconds later is PN, then
Equations (1) and (2) are special cases of the governing physical principles stated in Section 2.4.
Model Development
Recall that XO is the initial displacement and V0 is the initial velocity
of the mass attached to the spring. Let v1/2 denote the numerical
model velocity of the mass at t1/2 = h/2, the first point marked
The first step in development of a mathematical model for the spring-mass
system is to obtain an estimate of v1/2. First, observe that
the value of X0 determines the force applied to the object by the spring
at time
As time proceeds from t0 = 0 to
Setting VI = m*V0, VN = m*v1/2,
from which we can conclude that
Similar reasoning for successive points marked " | " yields,
provided the locations x1, x2, ... of the object can be computed.
Now we turn to the part of the mathematical model that deals with estimating
the position of the object as time varies. Recall that X0 is the initial
position of the mass. During the time interval
Now that we have assumed a constant velocity during t = 0 to
t = h, we can apply Equation (2) to estimate the position
of the mass at time
Similar reasoning for successive grid points marked
Equations (3a,b) and (4a,b) are the core of our discrete in time mathematical model for a spring-mass system . We will defer the discussion of how to implement this mathematical model until Section 3.
X'(t) = V(t), X(0) = X0
where the prime ' denotes differentiation with respect to time.
Those who have studied calculus can verify that the exact solution to the above mathematical model is given by
X(t) = (X0)*cos(r*t) + (V0/r)*sin(r*t) and V(t) = -(X0 *r)*sin(r*t)+ (V0)*cos(r*t)
where r = sqrt(k/m)
Later we will compare the mathematical model predictions from the discrete in time method with the continuous in time method.
Algorithm 1. Discrete in Time Mathematical Model of a Spring-Mass System
Step 1. Document the Code
This algorithm uses the discrete in time mathematical model defined
by Equations (3a,b) and (4a,b) to approximate the velocity and position
of a mass attached to a spring. The initial velocity of the mass is
V0 and the initial position is X0. The model is based on the assumptions
that
(1) motion is in a horizontal straight line;
(2) friction is negligible and
(3) the spring is linear.
INPUT
V0 -- initial velocity (double precision)
X0 -- initial position (double precision)
k, -- spring constant (positive) (double precision)
m -- mass of object (double precision)
h -- time step (double precision)
imax -- number of time steps to perform (integer)
OUTPUT
for i = 0 to imax
ti -- t-value a time step i (double precision)
xi -- approximate mass position at time ti (double precision)
vi -- approximate mass velocity at time ti (double precision)
AUXILIARY VARIABLES
vi_left -- approximate velocity at time ti - .5*h (double precision)
vi_right -- approximate velocity at time ti + .5*h (double precision)
i -- loop counter (integer)
Step 2. Initialize numerical solution at t = 0
Set ti = 0
vi = V0
xi = X0
Print ti, vi, xi
Step 3. Calculate velocity at t = .5*h
Set vi_left = V0 -.5*k*xi*h/m
Step 4. Begin time stepping
For i = 1,2,...,imax
Do steps 5-7
Step 5. Advance solution one time step
Set ti = ti + h
xi = xi + vi_left*h
vi_right = vi_left - k*xi*h/m
vi = .5*(vi_left + vi_right)
Step 6. Output numerical solution
Output ti, xi, vi
Step 7. Prepare for next time step
Set vi_left = vi_right
Experiment 1. Compile the C or Fortran code. Then make several runs with X0 = 1.0 meters, V0 = 0 meters/second and in different runs choose different values for the time step h. Choose imax sufficiently large so that the mass passes through the origin x = 0 several times. Compare the time values when the mass is over the origin for the different time steps. How does the model behave if the user should accidently enter a negative value of spring constant k? What is the model behavior is a negative value of time step h is used?
Experiment 2. Modify the C or Fortran code so that the modified code prints out the difference between the continuous in time model and the discrete in time model at each grid point. Run the modified code for various choices of Z0, V0 and h. What do you conclude about the accuracy of the discrete in time model?
where the constant s is proportional to the amount of sliding friction experienced by the mass. The negative sign makes the frictional force act in the direction opposite to the direction of travel and thus retard the motion of the mass. Reformulate the continuous in time mathematical model to incorporate the above expression for friction force. Can you find the exact solution to this modified continuous in time model?
Model Refinement 2. In the original discrete in time mathematical model the velocity variable is advanced in time in accordance with Newton's 2nd Law using the equation