You are on page 1of 22

ODEs: Basic Methods

PHYS 416/517
Garcia, Chapter 2
Projectile Motion
The Basic Equations for 2D projectile motion are

dr
=v
dt

dv 1 (1)
Where = gy + Fa ( v)
dt m
m = mass (kg)
g = acceleration due to gravity ( 9.81 m/s2 )

r = position(x, y)

v = velocity(x, y)

Fa (v) = any additional force such as air resistance
Projectile motion -
no air resistance
The solution for the
projectile motion in a
vacuum is:

x(t) = x0 + v0 t cos
y(y) = y0 + v0 t sin 12 gt 2

where:
(x0 , y0 ) initial position
v0 initial speed
initial launch angle
g acceleration due to gravity
Projectile motion -
no air resistance
In the simple case of an object launched with initial
speed v0 and an angle with respect to the ground
at a height y0, one can show that the time of flight
tR is
v sin + v 2
sin 2
+ 2gy 0
tR = 0 0

g
the range is: x max = x 0 + v 0 t R cos

v o2 sin 2
and the maximum height is: y max = y 0 + 2g
Air Resistance
The air resistance term takes on the form
1
Fa (v) = Cd A v v
2
where = density of air (in kg/m3 )
A = cross sectional area of projectile (in m2 )
Cd = drag coefficient (dimensionless)
which depends on the speed and geometry of the object
Drag Coefficient
The drag coefficient for a sphere (radius R) moving slowly
(v<0.2 mm/s) through the air is defined by Stokes Law as
12 24
Cd = =
Rv Re
Where
= viscosity of the air ( 1.5 10 -5 m 2 / s for air)

R e = Reynolds Number (dimensionless)
2Rv
=




Aside: Reynolds Number
In fluid dynamics, the properties of a fluid are often
characterized by dimensionless numbers. A
common one is the so-called Reynolds Number
( Re ) , which is defined as the ratio
Kinematic Forces
R e
Viscous Forces
The origin of the ratio comes from the Navier-Stokes
equation (Newtons 2nd Law for fluids)
v 2
( + v v) = p + v + f

=
t
where v velocity
= density
p = pressure
= dynamic viscosity

f = force
Aside: Reynolds Number
If we do some dimensional analysis and replace
gradients with 1/L (L=size of the system) and
equate the second term on the RHS with the
viscous term (second term on the LHS) we get
v2
~ 2v
L L
The LHS represents the inertial term the the RHS the
viscous term, then v 2
Re = L = Lv = Lv
v
2
L

Where kinematic viscosity=
Drag Coefficient - Reynolds Number
For baseball, Stokes Law is valid for |v| < 0.2
mm/s (Re 1)
At higher speeds (above 20 cm/s) and Re > 103,
there is a wake that forms behind the object
which results in a roughly constant Cd 0.5
When Re > 105, turbulence destroys the wake and
Cd drops dramatically
For the baseball problem and for the speeds we
will be modeling, Cd~0.35
Drag Coefficients for a Baseball
0.6
smooth
normal
rough
0.5

0.4
Cd

0.3

0.2

0.1

0
0 10 20 30 40 50 60 70 80
v(m/s)
The Effects of Spin Magnus Force
The force due to a spinning ball, rotating
at angular
velocity and moving a velocity v is


Fm = S0 v


The drag coefficient S0 can be variable, for
simplicity assume it is constant. Note that S0/m is
a dimensionless number.
Numerical Methods
We will begin by using the simplest numerical
method, which is the Euler Method.
If we divide time into a set of discrete intervals so
that at the nth interval the time is t = (n 1) We
then convert equations (1) into finite difference

approximations r (t + ) r (t) v(t)



v(t + ) v(t)
a(t)

Rearranging, we get

r (t + ) r (t) + v(t)

v(t + ) v(t) + a(t)

Which provides a simple prescription of getting the new
position at time t + given the information at time t. This
approximation introduces a certain amount of error, and
we can rewrite the above equation as

r (t + ) r (t) + v(t) + O( 2 )
(2)
v(t + ) v(t) + a(t) + O( ) 2


Where the O( 2 )is an error term that depends on the
timestep .
Other Simple Methods

Introducing a simpler notation, rn = rn (t) = rn ((n 1) )

rn+1 rn + v n
Euler Method
v n+1 v n + an

v n+1 v n + an
Euler Cromer Method
rn+1 rn + v n+1


v n+1 v n + an

rn+1 rn + (v n + v n+1 ) / 2 Midpoint Method
2
rn + v n + an / 2

Note that the midpoint method is exact for projectile
motion without air resistance.
Local Error Versus Global Error
If we attempt to estimate the error in the methods, we need to
make an estimate of the global error. For the Euler
method, the error is of order , for other methods it is of
order m but if we assume that this error adds, the global
error ( G) = the local error x the number of steps taken (N),
or G N m
T m
T m1


The Euler method has a local error of but a global error of
2
Simple Pendulum
The Equation of motion for a simple pendulum is
d 2 g
2 = sin
dt L
If is small, sin
d 2 g
2
dt L
2t L
(t) = C1 cos + C2 Ts = 2
Ts g
C1 and C2 are constants
Simple Pendulum - Total Energy
The total energy (E) of a pendulum is simply the
sum of the kinetic and potential energy
1 2 2 d
E = mL mgL cos =
2 dt

Which is conserved E = mgL cos m


Where m is the maximum angle of travel of the pendulum.
Equating the above 2 equations and solving for w gives

2g
= (cos cos m )
2

L
dt 1
=
d 2g
(cos cos m
L
The pendulums period T is 4x the time it takes to go from = m
to =0, so
T m 1
=
4 0 2g
(cos cos m
L
L 2 m
=4 K sin
g 2
where
dz
K(x) is an elliptic integral of
2
0
1 x 2 sin 2 z the first kind

dz
Note that in MATLAB (elliptke): K MATLAB (x) 0
2

1 x sin 2 z
Second order in time Methods
With the desire to get higher accuracy in our time-
stepping methods, we will look at using central
differences. One can easily show (via Taylor
expansion) that f (t ) f (t )
f '(t n ) n +1 2n 1
+ O( )
2
So that the error term is of second order. In other words,
if you halve the timestep () the error goes down by a
factor of 4.
Leap Frog Method

r
If we define the solutions at time tn as n and vn

We write the second order discretized equations as



rn +2 rn v n +1 v n 1
+ O( ) = v n +1
2
+ O( ) = an
2

2 2
Note that the equation for position is centered at time t +
while the equation for velocity is centered at time t. Rewriting,

we get v n +1 = v n 1 + 2an + O( 3 )

rn +2 = rn + 2v n +1 + O( 3 )
The scheme has each set of variables Leap-Frogging each
other in time. To start the scheme, one needs the position at
n=0, for which the simplest is to use a backward Euler step.
Basic Leap Frog Algorithm
! !
1. Get and estimate of r0 and v 0 using a backward Euler step for
velocity and a midpoint for the position:
! ! ! 1! 2 ! ! !
r0 = r1 v1 + 2 a1 and v 0 = v1 a1
! ! ! !
2. Compute the new position r2 as r2 = r0 + 2 v1
! ! ! !
3. Compute the new velocity v 2 as v 2 = v 0 + 2 a1
4. Repeat using the equations:
! ! ! ! ! !
rn+1 = rn-1 + 2 v n and v n+1 = v n-1 + 2 a n
Note that this is a little different to what is in the textbook where
every other timestep is computed. The Leap Frog scheme is often

written as v 1 = v 1 + a n rn +1 = rn 1 + v 1
n+ n n+
2 2 2
Verlet Method
Another approach is to dispense with velocity in
calculating the position and solve the 2nd order
equation
d 2r
2 = a( r )
dt
Using the finite difference equation for second derivative,

we get rn +1 2 rn + rn 1
+ O( ) = an
2

2
or rn +1 = 2 rn rn 1 + an + O( 4 )

r r
The velocity is computed as a post process: v n = n +1 n 1 + O( 2 )
2
2
And can be started as r0 = r1 v1 + a1
2

You might also like