Sie sind auf Seite 1von 34

SIMULATING SOLUTIONS TO ORDINARY DIFFERENTIAL

EQUATIONS & WAVE PROPAGATION IN MATLAB


This Mini Project Submitted to

TAMILNADU STATE COUNCIL FOR HIGHER EDUCATION


in partial fulfilmenunder the scheme Student Mini Project for the year 2014-2015.

MASTER OF SCIENCE IN MATHEMATICS


Submitted by
P.RADHA
[Reg.No:13PMA2325]
Under the guidance of

Dr.V.GANESAN M.SC.,M.Phil, Ph.d, PGDCA.,


Head,Department of mathematics.

DEPARTMENT OF MATHEMATICS
ARIGNAR ANNA GOVERENMENT ARTS COLLEGE
NAMAKKAL-637 002
2014-2015

CERTIFICATE
This is to certify that the minor project entitled
SIMULATING SOLUTIONS TO ORDINARY DIFFERENTIAL EQUATIONS
&WAVE PROPAGATION IN MATLAB submitted in partial fulfilment
Of the requirement

of

the minor project in mathematics to the

TANSCHE, Chennai is a record of bonafide research work carried out


by P.RADHA,[Reg.No:13PMA2325]

under

my supervision and

Guidance and that no part of the minor project has been submitted
for the ab o v e s aid min o r p r o j ec t o r other similar titles or prizes
and that the work has not been published in part or full in any
scientific or popular journals or magazines.

SIGNATURE OF THE GUIDE

HEAD OF THE DEPARTMENT

ACKNOWLEDGEMENT
First of all, I wish to express my deep sense of gratitude to the Lord
Almighty for his graceful blessings and giving me the good chance to get up on
the better steps.
I

place

on

record

my

heartful

and

sincere

thanks

to

Dr. V.RADHA, M.Com., M.Phil., Ph.D., Principal, Arignar Anna Government Arts
College, Namakkal.
It is my pride and pleasure to express my deep sense of sincere and
profound gratitude to my supervisor Dr. V. GANESAN, M.Sc., M.Phil., B.Ed.,
Ph.D., Head, Department of Mathematics, Arignar Anna Government Arts
College, Namakkal, for his scientific and valuable guidance, readiness and his
perennial interest in the welfare of the students.
I express my thankfulness to the authorities of Periyar University, Salem
and Gandhigram Rural Institute for providing the materials necessary for my
research work.
I would like to express my heartful thanks to my beloved parents, friends
and research scholars from various universities for their encouragement and
constant help which enabled me to complete my mini project.

(P.RADHA)

PREFACE
This mini project presents the salient aspect of the subject
matter in two chapters. simulation solution to ordinary differential
equations in matlab, and film casting, wave propagation with matlab
code,one dimensional wave propagation with matlab code, two
dimensional wave propagation with matlab code, three dimensional
wave propagation with matlab code, some examples are numbered
serially in this project.
we gives the necessary introduction to SIMULATING
SOLUTIONS TO ORDINARY DIFFERENTIAL EQUATIONS &WAVE
PROPAGATION IN MATLAB
Chapter I deals with simulation solution to ordinary differential
equations in matlab.
Chapter II deals with the wave propagation in matlab

CONTENT
CERTIFICATE

ACKNOWLEDGEMENT

PREFACE

CHAPTER NO.

TITLE

INTRODUCTION
I

SIMULATING SOLUTION TO ORDINARY


DIFFERENTIAL EQUATION IN MATLAB

II

PAGE NO.

WAVE PROPAGATION IN MATLAB

16

CONCLUTION

27

REFERENCE

29

BUDGET

30

SIMULATING SOLUTIONS TO ORDINARY


DIFFERENTIAL EQUATIONS &WAVE PROPAGATION IN
MATLAB

INTRODUCTION
Differential equations (DEs) play a prominent role in todays
industrial setting. Many physical laws describe the rate of change of
a quantity with respect to other quantities. Since rate of change is
simply another phrase for derivative, these physical laws may be
written as DEs. For example, Newtons Second Law o f Motion states
that the rate of change of momentum of an object is equal to the sum
of the imposed forces. Normally this is written as
F = ma,
where F represents the total imposed force. However, if we let x
denote the position of the object, then this may be rewritten as

F mx
Hence, Newtons Second Law of Motion is a second-order
ordinary differential equation.
There are many applications of DEs. Growth of microorganisms
and Newtons Law of Cooling are examples of ordinary DEs (ODEs),
1

while conservation of mass and the flow of air over a wing are
examples of partial DEs (PDEs). Further, predator-prey models and
the Navier-Stokes equations governing fluid flow are some examples
of systems of DEs.
Many introductory ODE courses are devoted to solution
techniques to determine the analytic solution of a given, normally
linear, ODE.
While these techniques are important, many real-life processes
may be modeled with systems of DEs. Further, these systems may be
nonlinear. Nonlinear systems of DEs may not have exact solutions.
However, we still desire some type of solution.
There

are

many

numerical

techniques

to

obtain

an

approximation to the solution of a DE or system of DEs. Many


scientific packages contain library commands to numerically
approximate the solution of these. In particular, MATLAB contains
the ode45 command which will numerically approximate the solution
to a system of ODEs using a medium order method.
Thus,the scientific package MATLAB may be used to explore
DEs modeling real-world applications that are more complicated than
the DEs presented in a typical introductory course. Using MATLAB
2

also has the advantage that the internal command guide may be used
to create graphical user interfaces (GUIs) to help facilitate this
exploration. The GUIs ensure that the students are not bogged down
with reading and understanding MATLAB code.
In this mini project, we will discuss how to use MATLAB to
simulate the solution to DEs. Then projects the author has assigned
involving real-world applications of DEs will be described.
One project models the industrial process of wave propagation
with matlab code,one dimensional wave propagation with matlab
code,two dimensional wave propagation with matlab code, three
dimensional wave propagation with matlab code, some examples
are numbered.

CHAPTER-I
SIMULATING SOLUTIONS TO ORDINARY
DIFFERENTIAL EQUATIONS IN MATLAB
MATLAB provides many commands to approximate the
solution. Suppose that the system of ODEs is written in the form

y ' f ( y)
Where y represents the vector of dependent variables and f
represents the vector of right-handside functions. All of the
commands require three arguments:
a filename which returns the value of the right-hand-side vector f,
vector representing the domain of the independent variable t
Set of initial conditions

Example of Car Shock Absorber Simulation


Consider the relation to this, suppose that we are interested in
a situation where
Car mass m = 1000kg.
Spring Stiffness ks = 2000 N/m.
Damper Viscosity kd = 500 Ns/m.

Then this can be specified to MATLAB as follows


>> m=1000; ks = 2000; kd = 500;
In turn, this allows the co-efficients in the differential equation
relationship (2) to be computed as
>> a1 = kd/m; a0 = ks/m; b1 = kd/m; b0 = ks/m;
Note that so far, the constant term g in (2) has been ignored.
This is because its only effect is to specify a constant offset to the
final solution, which will be clarified later, but is mentioned now to
explain why it will not be part of the initial simulations to follow.
To continue, we must now specify the exact experiment that we
want to simulate. It is reasonable to expect that the way in which a
shock absorber system handles a sudden bump in the road might be
of interest.
That is, suppose that the road height u(t) signal is a unit step
signals (this would be a 1m high bump!) so that the step actually
occurs at t = 1 second. Suppose further that we are interested in
simulating the resultant y(t) car position signal over a time window
of t 2 [0; 10]s. Then this situation can be specified via
>> t = 0:0.01:10;

where the time points have been spaced 10ms (1=100th s)


apart. The unit step at t = 1 second with respect to this time scale
vector t can then be specified as u = [zeros(1,100),ones(1,length(t)100)];
Notice the use of the length operator (that returns the length of
a vector) to ensure that the vectors t and u are of the same length.
We are now ready to simulate the shock absorber by dictating the
vectors a and b that specify the left and right-hand side co-efficients
of the differential equation (1)
>> a = [1,a1,a0]; b= [b1,b0];
and then running the simulation to calculate the car height signal
y(t) in the vector y:
>> y = lsim(b,a,u,t);
To evaluate this response, lets plot the input bump signal u(t) and
the car height response signal y(t) on
the same set of axes
>> plot(t,y)
>> plot(t,y,b-,t,u,r-.)
>> legend(Car height y,road height u)

>> xlabel(Time (s))


>> ylabel(height)
>> title(Road height and car height)
>> grid on
If you have copied the preceding commands into a MATLAB
command window, you should now see a plot in front of you that is
the same as shown in figure 1.
Note that a plot can be generated much more simply than this
by avoiding telling lsim to pass out the solution vector y by simply
typing l sim(b,a,u,t);
In this case, lsim

automatically generates a plot to

communicate the simulation result, but it choses axes labels


automatically rather than the custom ones we have been specifying.
Clearly our initial shock absorber design is terrible.
The oscillation following a bump is very pronounced, and it is
precisely the job of a shock absorber to avoid this sort of response;
the car height should settle quickly.
The remainder of this course is aimed at providing insight into
responses of systems governed by differential equations. This insight
will make it clear why the design flaw shown in figure 1 has occurred
7

and how to fix it.However, even without this sort of expertise,


intuitively it might seem reasonable to increase thestrength of the
damper; say double it

Figure 1: Simulation of shock absorber performance with m =


1000kg, ks = 2000 N/m, kd = 500 Ns/m.
>> kd = 2*kd
kd =1000

and then explore the effect of this by simulation, first by recalculating the differential equation specification (this would be

achieved by using the uparrow key " to recall the previously typed
expressions, there is no need to physically re-type them)
>> a1 = kd/m; a0 = ks/m; b1 = kd/m; b0 = ks/m;
>> a = [1,a1,a0]; b= [b1,b0];
and then re-running the simulation and plotting the results (again,
use the uparrow key to repeat these already-typed commands)
>> y = lsim(b,a,u,t);
>> plot(t,y,b-,t,u,r-.)
>> legend(Car height y,road height u)
>> xlabel(Time (s))
>> ylabel(height)
>> title(Road height and car height)
>> grid on

The results of this simulation experiment are shown in figure 2, and


are clearly superior to those shown in figure 1, but still the
response appears quite nausea-inducing for passengers. Double
again?
>> kd = 2*kd

Figure 2: Simulation of shock absorber performance with m =


1000kg, ks = 2000 N/m, kd = 1000 Ns/m.
kd =2000
>> a1 = kd/m; a0 = ks/m; b1 = kd/m; b0 = ks/m;
>> a = [1,a1,a0]; b= [b1,b0];
>> y = lsim(b,a,u,t);
>> plot(t,y,b-,t,u,r-.)
>> legend(Car height y,road height u)
>> xlabel(Time (s))
>> ylabel(height)
10

>> title(Road height and car height)


>> grid on

The performance of this final design is shown in figure 3, and it now


appears acceptable, so we could supply these design parameters of
ks = 2000; kd = 2000 as a specification for a shock absorber suitable
for a 1000kg car. However, what if someone tries to mistakenly use
this shock absorber on a much larger 2000kg car? Of course, this
scenario can be simulated
>> m = 2000;
>> a1 = kd/m; a0 = ks/m; b1 = kd/m; b0 = ks/m;
>> a = [1,a1,a0]; b= [b1,b0];
>> y = lsim(b,a,u,t);
>> plot(t,y,b-,t,u,r-.)
>> legend(Car height y,road height u)
>> xlabel(Time (s))
>> ylabel(height)

11

as a specification for a shock absorber suitable for a 1000kg car.


However, what if someone tries to mistakenly use this shock absorber
on a much larger 2000kg car? Of course, this scenario can be
simulated.
>> m = 2000;
>> a1 = kd/m; a0 = ks/m; b1 = kd/m; b0 = ks/m;
>> a = [1,a1,a0]; b= [b1,b0];
>> y = lsim(b,a,u,t);
>> plot(t,y,b-,t,u,r-.)
>> legend(Car height y,road height u)
>> xlabel(Time (s))
>> ylabel(height)

12

Figure 3: Simulation of shock absorber performance with m = 1000kg,


ks = 2000 N/m, kd = 2000 Ns/m.
Some notes are in order here.
The internal commands ode45, ode15s,ode 23 etc. only
accept first-order DEs.
Many higher-order DEs may be transformed into systems
of first-order DEs.
The order of the formal arguments in SpringMass is
important.
T represents the values of the independent variable t
generated by ode45.
13

Each row in X represents the value of X corresponding to


the associated time value in T.
The natural next step is to provide students with this code and
ask questions. For example, one could ask students what is the effect
of changing the damping coefficient.
In order for the students to answer this question, they are
required to determine the line(s) in the code where the damping
coefficient is defined, appropriately change those, and rerun the code.
This process demonstrates a drawback to using this approach:
it is difficult for the students to read and understand code.
One solution to this problem is the use of GUIs. They provide a
means of introducing students to scientific packages without entirely
involving the students within the code. Instead of expecting students
to modify code, they may simply edit text and click a button.
The required calculations are then accomplished for the
students without being visible. The MATLAB internal command
guide is the GUI development interface. It enables simplified
arrangement and sizing of GUI components as well as autogeneration of code for these components.

14

Examples of GUI components would be push buttons, axes,


sliders, pop-up menus, among others. Figure 3 displays an example
GUI for the spring-mass system.

Figure 3: Example GUI for the spring-mass system.


The students may change the quantities by simply typing the
new value in the edit text boxes and rerun the code by pressing the
push button.
With this GUI, it is easier for students to answer questions
related to changing system parameters. Now the students may
explore the particular model by being provided with the GUI and
some auxiliary files.

15

CHAPTER-II
WAVE PROPAGATION IN MATLAB
The final project explored the propagation of waves on a taut
string This process is governed by the following PDE.
2
2u
2 u
c
t 2
x 2

Here c represents the propagation speed of the wave. The


following boundary and initial conditions are enforced.

u 0, t 0
u L, t 0

u x,0 f x
u
x, 0 g x
t

Figure 1 displays the GUI provided to the students as well as an


example solution profile.

Figure 1: GUI and solution profile for wave propagation on a taut


string.
16

Students were asked to change the initial displacement of the string


and the propagation speed to determine the effect on the solution
profile.
2.1. ONE&TWO DIMENSIONAL WAVE PROPAGATION
The propagation of energy on a 2D plane is also quite simple to
program by extending the concepts of the 1D program. The twodimensional wave equation,

2 p(x, z, t) 2 p(x, z, t) 1 2 p(x, z, t)

2
x 2
z 2
v
t 2

(1)

becomes the finite difference equation,

pi 1, j ,k 2 pi , j ,k pi 1, j ,k

x2

pi , j 1,k 2 pi , j ,k pi , j 1,k

z2

1 pi , j ,k 1 2 pi , j ,k pi , j ,k 1
(2)
v2
t2

Solving for the single time sample at k+1 we get:

2 pi , j ,k pi 1, j ,k pi , j 1,k 2 pi , j ,k pi , j 1,k
p
pi 1, j ,k 2 pi , j ,k pi , j ,k 1 v 2 t 2 i 1, j ,k

(3)
2

x
z2

This difference equation is illustrated in Figure 1. A plane through


the central points represents time at the kth level and the one sample
point below this plane is a sample on the previous time layer at k-1.

17

The single point to be computed (the circle) lies on the upper plane
at time k+1.

FIGURE 2
Schematic representation of the three-dimensional (x, z, t) operator.
We therefore need two planes of the wavefield (at k-1, and k) to
start the propagation. As in the 1D case, it is critical that the first
two planes represent the desired initial conditions. In Figure 3a
below, the initial wavefield starts at the centre of the plane and then,
after 80 time iteration of computing the wavefield, we get the
wavefield shifted to the left as evident in part (b). Note that the
amplitude and shape of the wave field has been preserved.

18

(a)

(b)

FIG 3: A plane wave designed to propagate to the left, a) at time zero,


and b) at after 80 time Increments.
APPENDIX A
MATLAB code for modelling 2D data. The two parts encircled contain
the wavepropagation code and the function call to plot the v iew of the
full movement of the waveform.
% Wave on string
clear
v = 1000.0; % Velocity
dx = 1.0; % x increment
dt = 0.001; % time increment

19

nx = 100; %Number of x samples


nt = 100; %Number of z samples
p = zeros(nt,nx); % Matrix for string
s1 = zeros(nx); % String at time 1
s2 = zeros(nx); % String at time 2
s40= zeros(nx); % String at time 50
xary=zeros(nx); % Plot axis
% Define the position of the string at the first two times
for ix = -10:10
p(1, ix+20 ) = 100*exp(-(ix^2 )/16.0 );
p(2, ix+21 ) = 100*exp(-(ix^2 )/16.0 );
end
% Loop for each time increment: limit time to prevent
distortion due to boundary reflection
for it = 3: nt-55
for ix = 2:99
p(it,ix) = 2*p(it-1,ix) - p( it-2, ix) +
((v*dt/dx)^2)*(p(it-1,ix-1)-2*p(it-1,ix)+p(it-1,ix+1));
end

20

end
% Get singel copies of the two excitation arrays and one
latter array.
for ix = 1:nx
xary(ix)=ix;
s1(ix) = p(1, ix);
s2(ix) = p(2, ix);
s40(ix) = p(40, ix);
end
% Plot the data
figure (1); plot(xary,s2,'r--',xary,s1,'b','LineWidth',3);
xlabel('x','FontSize',20), ylabel('Amp','FontSize',20)
title(' \it{ Wave on string}', 'FontSize',20)
figure (2); plot(xary,s40,'g:',xary,s2,'r-',xary,s1,'b','LineWidth',3);
xlabel('x','FontSize',20), ylabel('Amp','FontSize',20)
title(' \it{ Wave on string}', 'FontSize',20)

21

FIG A1: MATLAB windows with results of the 1D modelling code


showing: a) the initial conditions on a string; b) initial conditions on
a string and the wave after 40 time increments; and c) all 40 time
increments on the string.

22

2.2. THREE DIMENSIONAL GAUSSIAN-SHAPED WAVELET


Figure 4 contains two images that result from a 3-D Gaussianshaped wavelet that is circular in (x, z) as displayed in Figure 5a.
The circular wavefront in part (a) in Figure 4 was excited by keeping
the two excitation wavelets at the same location, while part (b) was
excited by moving the second wavelet to the left with the propagation
velocity. Note that even though the wavelet was initially propagated
to the left, some energy also moves in the opposite direction.Figure
5 displays three additional wavelets in (b), (c), and (d) that are
truncated to widths of five, three, and one sample. The intent of these
wavelets is to represent some form of decomposition of a plane wave:
i.e. part (d) is just one slice from the wavefront. This slice is definitely
aliased in the direction parallel to the wavefront and we should expect
some form of dispersion during propagation.

23

(a)

(b)

FIG 4: Two wavefront responses from a Gaussian shaped wavelet at


the centre with different initial conditions; with a) the initial wavelets
at the same location, and b) when the second initial wavelet is shifted
to the left with the medium.s velocity.

(a)

(b)

(c)

(d)

FIG 5: Wavelet sources with a) the full circular wavelet, b) truncated


to five points wide, c) three points wide and d) one point wide.
24

APPENDIX B
Portion of MATLAB code for modelling 3D data that propagates the
wave.
figure(3); mesh( p);
xlabel('x','FontSize',20), ylabel('t','FontSize',20),
zlabel('Amp','FontSize',20)
title(' \it{ Wave on string}', 'FontSize',20)
Portion of MATLAB code for modelling 3D data that
propagates the wave.
%*********************************************************
% Compute each time layer
for it = 3:ntd
it
% Compute each x trace
for ix = 2:nx-1
%Compute each sample in trace
for iz = 2:nz-1
p = vol(ix, iz, it-1);
ptm1 = vol(ix, iz, it-2);

25

pzm1 = vol(ix, iz-1, it-1);


pzp1 = vol(ix, iz+1, it-1);
pxm1 = vol(ix-1, iz, it-1);
pxp1 = vol(ix+1, iz, it-1);
%solve wave-equation
ptp1 = 2.0*p - ptm1 + V^2*dt^2*( (pxm1 -2*p
+pxp1)/dx^2 + (pzm1 -2*p + pzp1)/dz^2 );
vol(ix, iz, it) = vol(ix, iz, it) + ptp1;
end
end
%********************************************************

26

CONCLUSIONS
SIMULATING

SOLUTIONS

TO

ORDINARY

DIFFERENTIAL

EQUATIONS & WAVE PROPAGATION can be illustrated using Simple


programs written and displayed in MATLAB.

27

REFERENCES:
[1] Acierno, D., L. Di Maio, C. Ammirati, Film Casting of Polyethylene
Terephthalate: Experiments and Model Comparisons, Polymer
Engineering and Science, Vol. 40, pp. 108-117, 2000.
[2] Advani, S., C. Tucker III, The Use of Tensors to Describe and
Predict Fiber Orientation In Short Fiber Composites, Journal of
Rheology, Vol. 31, pp. 751-784, 1987.
[3] Baird, D., D. Collais, Polymer Processing, John Wiley and Sons,
New York, 1998.
[4] Denn, M., Process Modeling, Longman Inc., New York, 1986.
[5] Doufas, A., A, McHugh, C. Miller, Simulation of Melt Spinning
Including Flow-Induced Crystallization Part I: Model Development
and Predictions, Journal of Non-Newtonian Fluid Mechanics, Vol. 92,
pp. 27-66, 2000.
[6] Eisele, P., R. Killpack, Propene, Ullmans Encyclopedia of
Industrial Chemistry, 1993 ed.
[7] Fisher, R., M. Denn, Mechanics of Nonisothermal Polymer Melt
Spinning, American Institute of Chemical Engineers Journal, Vol. 23,
No. 1, pp. 23-28.

28

[8] Haberman, R., Elementary Applied Partial Differential Equations,


Prentice Hall, New Jersey,1987.
[9] Lide, D., ed. CRC Handbook of Chemistry and Physics, CRC Press,
New York, 2001.
[10] Mark, J., ed. Physical Properties of Polymers Handbook, AIP Press
New York 1996.
[11] Smith, S., D. Stolle, Nonisothermal Two-Dimensional Film
Casting of a ViscousPolymer, Polymer Engineering and Science, Vol.
40, pp. 1870-1877, 2000.
[12] Vargaftik, N., Tables on the Thermophysical Properties of Liquids
and Gases, John Wiley and Sons, New York, 1975.
[13] Ziabicki, A., Fundamentals of Fibre Formation, John Wiley and
Sons, New York, 1976.
[14] Ziabicki, A., L. Jarecki, A. Waiak, Dynamic Modelling of Melt
Spinning,Computational and Theoretical Polymer Science, Vol. 8, pp.
143-157, 1998.

29

Das könnte Ihnen auch gefallen