Solving Nonlinear Governing Equations of Motion Using Matlab and Simulink in First Dynamics Course
Solving Nonlinear Governing Equations of Motion Using Matlab and Simulink in First Dynamics Course
Page 11.1141.1
Overview
Students in first dynamics courses deal with some dynamical problems in which the governing
equations of motion are simultaneous, second order systems of non-linear ordinary differential
equations. There are no known quantitative methods or closed-form solution to these systems of
non-linear differential equations. To teach students analytic methods and solution techniques to
this category of dynamical problems, the authors devised a model example in which the motion
of a particle on a rough cylindrical surface is considered. The authors then formulate qualitative
and quantitative solution methods and employ both MATLAB and SIMULINK to these analytic
methods and solution techniques to arrive at the stable, numerical solution to the proposed
example.
In the model example provided, the governing equations of motion are first obtained in the state
form. Four different approaches then were adopted to arrive at the stable, numerical solution of
the system of first order, simultaneous, non-linear differential equations of motion.
In the first approach, the governing differential equations were converted to appropriate
difference equations, and then a program was written in MATLAB to solve the resulted system
of nonlinear algebraic equations. The second approach employed fourth-order Runge-Kutta
scheme by writing a program in MATLAB to render a stable solution to the system of
differential equations. The third method utilized MATLAB built-in function, ode45, to solve
the governing non-linear system of differential equations. Finally SIMULINK, which is an
extension to MATLAB, was used to provide solutions to the governing differential equations.
The results of these different approaches were then compared with each other.
It should be mentioned that, at our institution, dynamics is taught in the first semester of the
junior year and right after the differential equations class, which is offered in the second semester
of the sophomore year. In other curriculums, where dynamics is taught before students take
differential equations, the method applied here (in the SIMULINK part of this paper) becomes
extremely valuable as it can be introduced and employed in the dynamics course before the
differential equation class (See Appendix D). Appendix D clearly shows that SIMULINK
integration block symbol requires no need for a priori knowledge of differential equations
course. Nonetheless, SIMULINK still can be used in the differential equations course, as we did
in ours.
The authors of this study received positive feedback from students regarding this experience.
Students especially enjoyed using SIMULINK and expressed that this project help them a great
deal in understanding not only dynamics topics but also the subjects covered in their previous
differential equation course.
Problem Statement
In our model example, we propose to evaluate the position, velocity and the time at which the 1
pound block leaves the surface of a cylindrical surface on which it slides. The block is assumed
to have an initial velocity V0 at the top of the cylinder and is subject to a constraint friction force
of kinetic coefficient of friction, k (See Figure 1). To achieve a stable numerical solution, we
assume, without loss of generality, a specific initial speed of 10 ft/s for the block and consider
the coefficient of kinetic friction between the block and surface to be zero in one case and 0.2 in
the other. The radius of cylinder, r = 5 ft.
V0
r
Page 11.1141.3
Figure 1
Formulation
Figure 2 shows the free body and inertia response diagrams of the block, degrees from the top
of the cylinder.
W
t
n mat
man
N F
Figure 2
Adopting the path coordinate and applying Newtons second law of motion, one obtains:
V2
Fn ma n : W cos s / N ? m (1)
r
Ft ma t : W sins F ma t (2)
Where m is the mass, W is the weight, V is the speed of the block degree(s) from the top, r is
the radius of the cylinder, N is the surface normal force, F is the surface friction force and an and
at are the normal and tangential components of accelerations of the block, respectively. However:
F ok N (3)
2
d s
at (4)
dt 2
Where s is the path traversed by the block on the cylindrical surface. Solving for N from
equation (1), one obtains:
V2
N m ( g cos s ) (5)
r
Substituting N from (5) into (3), and the result together with (4) into (2), one gets:
d 2s V2
g (sin s o k cos s ) o k (6)
dt 2 r
Substituting (7) into (6), and rearranging (8), one arrives at the state form of the governing
equations of motion as:
ds
V (9)
dt
dV V2
g (sin s o k cos s ) o k (10)
dt r
ds V
? (11)
dt r
s( 0 ) 0.
V ( 0 ) V0 10 ft / s (12)
s ( 0 ) 0.
The problem at hand is clearly a single degree of freedom autonomous system (since s = r s )
and, therefore, it should be governed by two first order state equations. However, we formulated
the problem in the current manner by using equations 9-11 to obtain numerical solutions
separately for both angular and curvilinear positions of the block. The block leaves the
cylindrical surface when there is no contact with it (N = 0) and, at the same time, when the rate
of change of the normal force with respect to s is negative. When N = 0, equation (5) becomes:
V2
g cos s 0 (13)
r
Equations (9), (10), (11) form a set of nonlinear simultaneous differential equations of motion,
in state form, with initial conditions (12) and subject to condition (13) on angle , at which the
block leaves the surface of the cylinder.
Solution Methods
ode45. This is the first time that the students try to use numerical methods to solve system of
differential equations in the curriculum. Pedagogically, it is very useful if students try different
solution approaches and compare the results of these different ways. We also introduced students
to SIMULINK to teach them a fourth approach to obtain a stable solution to the problem at hand,
in particular, and to this category of simultaneous non-linear differential equations in general.
In this approach we approximate the variables and their derivatives in equations (9), (10), and
(11) as follows:
ds s( t ) s( t Ft )
dt Ft
dV V ( t ) V ( t Ft )
(14)
dt Ft
ds s ( t ) s ( t Ft )
dt Ft
One also approximates the block speed as the average speed value at times t and t + t as:
V(t Ft ) V ( t )
V (15)
2
Substituting (14) and (15) into (9), (10), and (11), one obtains:
s( t ) s( t Ft ) V ( t ) V ( t Ft )
Ft 2
V ( t ) V ( t Ft ) (V ( t F t )) 2
g (sin s ( t F t ) o k cos s ( t F t )) ok (16)
Ft r
s ( t ) s ( t Ft ) V ( t ) V ( t Ft )
Ft 2r
Solving for the variables, velocity, position and angle at time t from equations (16), one arrives
at the governing difference equations:
(V ( t Ft )) 2
V(t ) V(t Ft ) Ft g (sin s ( t Ft ) o k cos s ( t Ft )) o k
r
V(t ) V(t Ft )
s( t ) s( t Ft ) Ft (17)
2
V(t ) V(t Ft )
s ( t ) s ( t Ft ) Ft
Page 11.1141.6
2r
The above system of algebraic equations, subject to initial conditions (12), is then solved by
marching through time from initial t = 0, when the block was launched at the top of the cylinder,
until the time t when the block leaves the cylinder surface. The angle and the velocity V are
substituted into equation (13) at the end of each time step to check whether the block has lost
contact with the surface or not. Without going further into the details, we mentioned to our
students the importance of choosing appropriate time steps to obtain a stable solution. A time
step of Ft = 0.1 ms was adopted in this simulation. Appendix A represent the MATLAB
program used to implement this approach. Although the error of these first order difference
operators is O( t), their numerical stability is much better than the higher order ones.
SIMULINK, which is an extension to MATLAB, provides its users with a graphical user
interface that is fun to try and much easier to use than MATLAB itself (or Maple) or any other
traditional command-line programs, such as C, FORTRAN or BASIC. It is used to model
complex nonlinear systems, with a relative ease in comparison with these command-line
software programs, and as a result boosts productivity in a significant way.
Appendix D shows the detailed SIMULINK model of the problem at hand. It is seen in the
d 2s
SIMULINK model that the left hand side of equation (6), namely, the term ( 2 ), after going
dt
Page 11.1141.7
through two integrator blocks (1/s), renders the position of the block. Further elaboration on this
model is presented in the result and discussion part of this document.
Results and Discussions
To check the result of simulation, we study the exact solution to the governing differential
equations of motion for the case of no friction (k = 0). In that case, governing differential
equations of motion reduce to:
dV
g sin s (18)
dt
ds V
(19)
dt r
Subject to initial conditions (12) and condition (13). These can be solved by elementary
techniques. Using equation (19) and the chain rule, equation (18) is written as:
dV dV ds V dV
g sin s (20)
dt ds dt r ds
Which upon separation of variables and integration we obtain:
Upon substituting V from condition (13) into (21) we arrive at the angle at which the block
leaves the surface of the cylinder:
We allotted three 50-minutes class periods to acquaint our students with numerical methods such
as Runge-Kutta, finite difference, and state form of differential equations. Moreover, one of
these class periods was devoted to introducing students to SIMULINK by showing them how to
construct simulation model for the problem at hand. Later on in the semester, students used
MATLAB and SIMULINK to do homework assignments and complete a project that was given
to them to reinforce the ideas and methods presented in this paper. We would also like to point
out that students who go on to take vibrations, system and control, or differential equations
courses will certainly reap great deal of benefit from this first experience in the dynamics class.
Our students who took these subsequent courses further acknowledge this point.
Table 1 next compares all the above cases with the exact solution. As it is evident from the table
Page 11.1141.8
all approaches clearly predict the kinematics values, for the exact solution, with excellent
accuracy, O(10-4).
TABLE 1
Table 2 shows the results for the friction case, where the kinetic friction coefficient k = 0.4.
Again all the approaches renders basically same values. The differences are mainly due to
numerical truncation error.
Appendix D shows the simulation of the exercise for k = 0.4. The kinematical values that are
observed in Table 2 for the SIMULINK model are values taken from the Display Blocks in
Appendix D. The Stop Block used in the model is to terminate the simulation when condition
(13) is met. The Logic Block seen in the model is used to implement condition (13). The model
uses three integrator blocks to arrive at position, velocity and the angle for the block. The
Clock Block on top of the model keeps track of the simulation time. These visual blocks, taken
from block diagram concept9, aid students a great deal to simulate a dynamical system in a
relatively short period of time in comparison with a typical command-line program. As we
mentioned before, there is also no need to convert the second order differential equations of
motion into first order (state form), to arrive at a stable numerical solution, in a SIMULINK
model.
TABLE 2
As it is seen from the results, friction holds the block to the cylinder for a longer time compared
with the no friction case. This is expected as friction lowers the block velocity, which from
equation (13) predicts a bigger contact angle .
Page 11.1141.9
Conclusion
It is the authors belief that with the availability of powerful programming tools such as
MATLAB and SIMULINK, the students of dynamics and differential equations benefit
tremendously from integrating similar models, as the one in the above, in their course work.
SIMULINKsoftware especially looks very promising in dynamics classes, where students do
not have a differential equation course in their background.
This model lead to homework problems and projects which helped students learn how to solve a
system of non-linear, time dependent, governing differential equations of motion in 4 different
ways. It introduced students to the state form of these differential equations, a topic which they
will deal with in their future course work in vibrations and control systems. It also sharpened our
students math and programming skills by extending their differential equation knowledge to new
dimensions; namely, stable numerical methods for solving nonlinear systems. SIMULINK also
helped students to develop block diagram skills. A skill they use in their control course later.
Students feedback regarding this model and its follow-up homework assignment and a project,
was very positive. They indicated that the model, homework and project combination helped
them a great deal to further understand the topics learned in the dynamics and differential
equation classes. They enjoyed, in particular, programming with SIMULINK because of its user
graphical interface character and relative ease to use.
Bibliography
1. Tongue, B.H., and S.D., Sheppard: Dynamics: Analysis and Design of Systems in Motion, John Wiley, 2004.
2. Beer, F. P., and J. E. Russell: Vector Mechanics for Engineers- Dynamics, 6th. Edition, McGraw Hill, 2004.
3. Meriam, J.L., and L.G. Kraige: Engineering Mechanics- Dynamics, 5th. Edition, John Wiley, 2001.
4. Riley, W.F., and L.D. Sturges: Engineering Mechanics- Dynamics, 2nd Edition John Wiley, 1995.
5. Hibbeler, R.C.: Dynamics, 10th Edition, Prentice Hall, 2004.
6. Mohammadzadeh, A.R., and S. Haidar: Analysis and Design of Automotive Suspension System, ASEE Annual
Proceedings, 2006.
7. Ayyub, B.M., and R.H. McCuen: Numerical Methods for Engineers, Prentice Hall, 1996.
8. Chapra, S.C.: Applied Numerical Methods with MATLAB for Engineers and Scientists, McGraw Hill, 2005.
9. Dabney J.B., and T.L. Harman: Mastering SIMULINK, Prentice Hall, 2004.
Page 11.1141.10
APPENDIX A
% Fourth Order Runge Kutta Method for Solving Simultaneous first order
% Differential Equations
function[tvals,yvals]= rkgen(f,tspan,startval,step)
end
Page 11.1141.13
APPENDIX C
Running MATLAB built in Function ode45 Approach for the case k = 0.4
Position = 2.9766 ft
Velocity = 11.5454 ft/s
APPENDIX D
Page 11.1141.15