Example 1
Example 1
Examples
1
Using Newton’s 2nd law to determine the terminal
velocity of a free falling body near the earth’s surface
FU
FD 2
The mathematical model for this case is derived by
expressing the acceleration as a time rate of
change of velocity (a = dv/dt)
dv F
= (4)
dt m
Where v is the velocity in m/s and t is time in seconds (s)
F = FD + FU (5)
g = 9.81 m/s2
The downward force due to gravity FD = mg
m = mass (kg)
3
Air resistance
FU = − cv (6)
c = proportionality constant
(drag coefficient kg/s)
Accounts for properties of the falling body
e.g. shape, surface roughness, etc.
4
The net force is the difference between the
downward force and the upward force
dv F mg − cv
= =
(8)
dt m m
or
dv c
=g− v (9)
dt m
A mathematical model which relates to the acceleration of a
falling object to Forces acting on it !!! 5
If the paratrooper is initially at rest (v = 0 at t = 0), we can
use calculus to find the solution of:
dv c
=g− v
dt m
as
v(t ) =
gm
c
(
1− e ( − c / m )t
) (10)
Where:
v(t ) ≡ dependent variable
t ≡ the independent variable
c, m ≡ parameters
g ≡ the forcing function
6
Example # 1
Solution:
30
20
10
0
0 10 20 30 40 50 60 70 80
t, s
9
v(t ) =
gm
c
(1− e − ( c / m )t
)
• The equation is called an analytical or exact
solution because it satisfies the original
differential equation exactly.
• Many mathematical models cannot be
solved exactly
• Alternative is to develop a numerical solution
that approximates the exact solution !!!
10
Numerical Methods
• Numerical methods are techniques by
which a mathematical problem is re-
formulated so that it can be solved by
arithmetic operations !!!!
11
Approximation for the time rate change of velocity
v(ti +1 )
Δv v(ti +1 ) − v(ti )
v(ti ) =
Δt ti +1 − ti
ti ti +1
dv Δv v(ti +1 ) − v(ti )
≅ = (11)
dt Δt ti +1 − ti
12
v(ti +1 ) − v(ti ) c
= g − v(ti )
ti +1 − ti m
i+1
⎡ c ⎤
v(ti +1 ) = v(ti ) + ⎢ g − v(ti ) ⎥ ( ti +1 − ti ) (12)
⎣ m ⎦
Thus the differential equation has been transformed into an equation that can
be solved algebraically at different times using the slope and previous values of
v and t
13
Example # 2
Solution:
At the start of the computation (ti = 0), the velocity of the paratrooper is zero.
Using this information and parameter values from example #1, equation (12) can
be used to compute the velocity at ti+1 = 2s:
⎡ 12.5 ⎤
v = 0 + ⎢9.8 − (0) ⎥ (2 − 0) = 19.60 m/s
⎣ 68.1 ⎦
14
⎡ 12.5 ⎤
v = 19.60 + ⎢9.8 − (19.60) ⎥ ( 4 − 2 ) = 32.00 m/s
⎣ 68.1 ⎦
t,s 0 2 4 6 8 10 12 inf
15
Comparison of analytical and
numerical solutions
60
Approximate ,numerical solution
50
40
v, m/s
30
Analytical Solution
10 Numerical Solution
0
0 2 4 6 8 10 12 14
t, s 16
Matlab solution: Interactive
Let’s use matlab to solve the falling paratrooper
problem : Example # 1 Analytical solution
v(t ) =
gm
c
(
1− e ( − c / m )t
) Eq. (10)
>> g = 9.81;
>> m = 68.1;
>> c = 12.5;
>> tf = 2;
>> v=g*m/c*(1-exp(-c/m*tf))
v=
16.4217
>>
17
Matlab solution : m-file
Open the matlab editor with a file named
analytic_sol.m
>> edit analytic_sol.m
>>
18
Type the following code:
g=9.81;
m=68.1;
c=12.5;
tf=2;
v=g*m/c*(1-exp(-c/m*t))
>> analytic_sol
v=
16.4217 19
Rewrite the program to include user input
g=9.81;
m=input(‘mass = (kg): ‘);
c=12.5;
tf=2;
v=g*m/c*(1-exp(-c/m*t))
>> analytic_sol2
mass (kg):
v=
17.3597
>>
20
Numerical solution g=9.81;
m=input(' mass (kg): ');
c=12.5;
⎡ c ⎤
v (ti +1 ) = v(ti ) + ⎢ g − v(ti ) ⎥ ( ti +1 − ti ) ti=0;
⎣ m ⎦ tf=2;
vi=0;
dt=0.1;
t = ti;
v = vi;
h = dt;
while (1)
if t + dt > tf
Save the file as numer_sol.m h = tf - t;
end
>> numer_sol dvdt = g - (c / m ) * v;
v = v + dvdt * h;
mass (kg): 100 t = t + h;
if t >= tf, break, end
velocity (m/s): end
17.4559 disp('Velocity (m/s):')
disp(v)
21
A proper function
% ************************************************* %************************
% function to compute the velocity of a falling % function to compute the
% paratrooper % derivative
% %------------------------------
%************************************************** function dy = fun(t,v,m,c)
function euler = fun(dt,ti,tf,yi,m,c) g = 9.81;
t = ti; dy = g - (c/m )* v;
y = yi; end
h = dt;
while (1)
if t + dt > tf >> m=68.1;
h = tf - t; >> c=12.5;
end >> ti=0;
dydt = dy(t, y, m, c ); >> tf=2.0;
y = y + dydt * h; >> vi=0;
t = t + h; >> dt=0.1;
if t >= tf, break, end >> euler(dt,ti,tf,vi,m,c)
end
euler = y;
22
end