sff! odes!! and systemsof! odes!people.bu.edu/.../lecturenotes/lecture11_8oct2015.pdf · here e =...

42
S#ff ODEs and Systems of ODEs

Upload: others

Post on 14-Aug-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

 S#ff  ODEs    and    

Systems  of  ODEs  

Page 2: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

Popula#on  Growth  Modeling    Let the number of individuals in a given area at time t be . At time the number is so that

is the number of individuals that have arrived in the area during the time interval Suppose that the change is entirely due to individuals being born. We hypothesize that: •  the more individuals there are at time t, the more births

are likely to occur, •  in a short time interval we would expect about twice as

many births as in a time interval of half its length

Thus we expect that the number of births will be proportio- nal to when is small.

Page 3: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

Popula#on  Growth  Modeling    We define the reproductive rate of the population per unit time by the constant K, where K is positive, so that the actual number of births in the time interval is Hence

or

Letting , equation (11.1) can be approximated by the following ODE:

(11.1)

(11.2)

Page 4: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

Popula#on  Growth  Modeling    Aside from constant, the quantity K may involve both N and t because the production of births may depend on various factors, such as changing environment. When K is constant, the solution of (11.2) is

where is the size of the population at time

Populations that obey equations such as (11.3) are said to be undergoing exponential growth, dramatically increase over time. In any real situation, there will be a limit to the growth because of lack of food, shortage of essential supplies, self-pollution of the environment, etc.

(11.3)

Page 5: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

Popula#on  Growth  Modeling    It is possible to allow for more facets of the population problem. For instance, members may die and we may postulate that the number of deaths in the short time interval is Then

leading to

when

(11.4)

Individuals may enter the given area from outside; say immigrants in the time and some may depart from the area giving rise to emigrants.

Page 6: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

Popula#on  Growth  Modeling    Then

or

Suppose the parameters K, D, I, and E are given as the following:

(11.5)

Page 7: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

S#ffness  of  ODEs  Then the equation (11.5) becomes

If the initial condition is using the integrating factor method where the equation (11.6) is rearranged into

(11.6)

and as the integrating factor, the analytical solution of (11.6) is

(11.7)

Page 8: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

S#ffness  of  ODEs  Insight into the step size required for stability of such a solution can be gained by examining the homogeneous part of equation (11.6),

(11.8)

If , the solution is given by

(11.9)

Using Euler’s forward method to approximate the solution numerically gives

(11.10)

Page 9: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

S#ffness  of  ODEs  The stability of the formula (11.10) clearly depends on the step size h, that is

The absolute inequality is solved as

If

Taking thus

Page 10: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

S#ffness  of  ODEs  

Page 11: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

S#ffness  of  ODEs  As shown in the figure, the solution is initially dominated by the fast exponential term After a short period

dictated by the slow exponential the transient dies out and the solution is

Such ODE given in equation (11.6) is called stiff because it involves rapidly changing components (fast exponential terms) with slowly changing components (slow exponential terms).

Despite above, the phenomenon of stiffness is not precisely defined in literature. Some attempts at describing a stiff problems are:

Page 12: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

S#ffness  of  ODEs  •  A problem is stiff if it contains widely varying time scales,

some components of the solution decay much more rapidly than others. •  A problem is stiff if the step size is dictated by stability

requirements rather than by accuracy requirements. •  A problem is stiff if explicit methods don’t work, or work

only extremely slowly. •  A linear problem is stiff if all of its eigenvalues have

negative real part, and the stiffness ratio (the ratio of the magnitudes of the real parts of the largest and smallest eigenvalues) is large. •  More generally, a problem is stiff if the eigenvalues of the

Jacobian differ greatly in magnitude.

Page 13: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

Heart  Beat  Modeling  

Page 14: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

Heart  Beat  Modeling  The heart is a complicated but robust pump. It consists of four chambers and four valves. There are essentially two circuits for the blood, one which spread through the lungs to pick up oxygen and the other which spreads through the body to deliver the

oxygenated blood. The first circuit (vein to lungs + right auricle + right ventricle + vein from body) is a low-pressure circuit so as not to damage the delicate membrane in the lungs, whereas the second (vein to body + left auricle + left ventricle + vein from lungs) is a high-pressure circuit in order for the blood to get down to the feet and up again.

Page 15: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

Heart  Beat  Modeling  Each pump has a main pumping chamber called the ventricle with an inlet and an outlet valve. The purpose of the inlet valve is to prevent flow back up the veins while pumping, and the outlet valve is to prevent flow back from the arteries while filling.

Since the heart is made of non-rigid material, it only has the power to push out and no power to suck in. Thus, to get a good pump it is necessary to fill the ventricle completely, and to aid this there is a small chamber called the auricle/atrium whose job is to pump gently beforehand, just enough to fill the ventricle but not enough to cause any flow back.

Page 16: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

Heart  Beat  Modeling  During the heart beat cycle, there are two extreme equilibrium states: •  Diastole à the relaxed state •  Systole à the contracted state

What makes the heart beat is the presence of a pacemaker which is located on the top of the atrium. The pacemaker causes the heart to contract into systole. That is, it triggers off an electrochemical wave which spreads slowly over the atria causing the muscle fibers to contract and push blood into the ventricles.

Page 17: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

Heart  Beat  Modeling  The electrochemical wave then spreads rapidly over the ventricles causing the whole ventricle to contract into systole and deliver a big pump of blood down the arteries. The muscle fibers then rapidly relax and return the heart to diastole; the process is then repeated.

In order to develop a mathematical model which reflects the behavior of the heart beat action described above, we choose to single out the following features: •  The model should exhibit an equilibrium state, corres- ponding to diastole.

Page 18: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

Heart  Beat  Modeling  •  There must be a threshold for

triggering the electrochemical wave emanating from the pacemaker causing the heart to contract into systole. •  The model must reflect the rapid

return to the equilibrium state.

Suppose we let: F denote muscle fiber length referred to some convenient

origin, say F = 0, which corresponds to the equilibrium state. E be an electrical control variable which governs the

electrochemical wave.

Page 19: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

Heart  Beat  Modeling  As far as the muscle fibers are concerned, we are to look for a differential equation which has F = 0 as an equilibrium state and at least for small times has a rapidly decreasing solution. An appropriate equation is

where ℇ is a small positive parameter. When the velocity of the fiber is zero, that is

we have the equilibrium state F = 0.

(11.11)

Page 20: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

Heart  Beat  Modeling  Equation (11.11) has the general solution:

which is rapidly decreasing in time. This represents the behavior initially of the muscle fibers causing contraction into systole.

For the electrochemical wave, we need to control E to represent initially the relatively slow spread of this wave over the atria. A simple model which does this is:

(11.12)

(11.13)

Page 21: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

Heart  Beat  Modeling  Here E = 0 is an equilibrium state, and (11.13) has the general solution

which, in comparison with (11.12), represents a relatively slow decay in time.

Thus, we obtain a system of ODEs consisting of simple equations (11.11) and (11.13) to model heart beats. To make the model more realistic, thhe features we need to add to this simple model are: •  The threshold or trigger •  The rapid return to equilibrium

(11.14)

Page 22: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

Heart  Beat  Modeling  The model which incorporates the desired features is the coupled nonlinear 1st order ODE system:

where: F = the length of the muscle fiber a = tension E = the chemical control Fa = a typical fiber length when the heart is in diastole

(11.15)

Page 23: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

S#ff  ODE  Systems  Since the parameter ℇ is very small, the first ODE of the system (11.15) reacts/decays much faster than the second one. We can observe this by multiplying the first ODE with ℇ, then:

Hence, this gives us a system of stiff ODEs.

Page 24: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

Van  der  Pol  Equa#on  Another example of system of ODE can be written from the (2nd order) van der Pol equation:

where µ is a scalar parameter. By making the substitution

(11.16)

the resulting system of 1st order ODE is

(11.17)

The stiffness of the van der Pol equation is determined by the scalar parameter 𝜇. .

Page 25: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

MATLAB  Implementa#ons  

function dydt = vdp1(t,y)

dydt = [y(2); (1-y(1)^2)*y(2)-y(1)];

end

(a) Choosing 𝜇 = 1 (non-stiff), we code the system of the 1st = 1 (non-stiff), we code the system of the 1st order ODE:

(b) Apply a MATLAB solver to the problem. For the van der Pol system, you can use ode45 on time interval [0 20] with initial values y(1) = 2 and y(2) = 0:

[t,y] = ode45(@vdp1,[0 20],[2; 0]);

Page 26: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

MATLAB  Implementa#ons  

plot(t,y(:,1),'-',t,y(:,2),'--')title('Solution of van der Pol Equation, \mu = 1');xlabel('time t');ylabel('solution y');legend('y_1','y_2')

(c) View the solver ouput:

Page 27: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

MATLAB  Implementa#ons  

plot(t,y(:,1),'-',t,y(:,2),'--')title('Solution of van der Pol Equation, \mu = 1000');xlabel('time t');ylabel('solution y');legend('y_1','y_2')

For stiff van der Pol equation, we set 𝜇 = 1000 and choose = 1000 and choose ode15s solver:

function dydt = vdp1000(t,y)

dydt = [y(2); 1000*(1-y(1)^2)*y(2)-y(1)];

end

[t,y] = ode15s(@vdp1000,[0 3000],[2; 0]);

Page 28: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

MATLAB  Implementa#ons  Plot of stiff van der Pol equation:

Page 29: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

MATLAB  ODE  Solvers  Solver   Problem  Type   Order  of  Accuracy   When  to  Use  

ode45   Nons*ff   Medium   Most  of  the  *me.  This  should  be  the  first  solver  you  try.  

ode23   Nons*ff   Low   For  problems  with  crude  error  tolerances  or  for  solving  moderately  s*ff  problems.  

ode113   Nons*ff   Low  to  high   For  problems  with  strict  error  tolerances  or  for  solving  computa*onally  intensive  problems.  

ode15s   S*ff   Low  to  medium   If  ode45  is  slow  because  the  problem  is  s*ff.  

ode23s   S*ff   Low   If  using  crude  error  tolerances  to  solve  s*ff  systems  and  the  mass  matrix  is  constant.  

ode23t   Moderately  s*ff   Low   For  moderately  s*ff  problems  if  you  need  a  solu*on  without  numerical  damping.  

ode23tb   S*ff   Low   If  using  crude  error  tolerances  to  solve  s*ff  systems.  

Page 30: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

MATLAB  ODE  Solvers  Solver   Algorithm  

ode45   is  based  on  an  explicit  Runge-­‐KuKa  (4,5)  formula,  the  Dormand-­‐Prince  pair.  It  is  a  one-­‐step  solver  –  in  compu*ng  y(tn),  it  needs  only  the  solu*on  at  the  immediately  preceding  *me  point,  y(tn-­‐1).  In  general,  ode45  is  the  best  func*on  to  apply  as  a  first  try  for  most  problems.    

ode23   is  an  implementa*on  of  an  explicit  Runge-­‐KuKa  (2,3)  pair  of  Bogacki  and  Shampine.  It  may  be  more  efficient  than  ode45  at  crude  tolerances  and  in  the  presence  of  moderate  s*ffness.  Like  ode45,  ode23  is  a  one-­‐step  solver.    

ode113   is  a  variable  order  Adams-­‐Bashforth-­‐Moulton  PECE  solver.  It  may  be  more  efficient  than  ode45  at  stringent  tolerances  and  when  the  ODE  file  func*on  is  par*cularly  expensive  to  evaluate.  ode113  is  a  mul0step  solver  —  it  normally  needs  the  solu*ons  at  several  preceding  *me  points  to  compute  the  current  solu*on.  

ode15s   is  a  variable  order  solver  based  on  the  numerical  differen*a*on  formulas  (NDFs).  Op*onally,  it  uses  the  backward  differen*a*on  formulas  (BDFs,  also  known  as  Gear's  method)  that  are  usually  less  efficient.  Like  ode113,  ode15s  is  a  mul*step  solver.  Try  ode15s  when  ode45  fails,  or  is  very  inefficient,  and  you  suspect  that  the  problem  is  s*ff,  or  when  solving  a  differen*al-­‐algebraic  problem.    

ode23s   is  based  on  a  modified  Rosenbrock  formula  of  order  2.  Because  it  is  a  one-­‐step  solver,  it  may  be  more  efficient  than  ode15s  at  crude  tolerances.  It  can  solve  some  kinds  of  s*ff  problems  for  which  ode15s  is  not  effec*ve.    

ode23t   is  an  implementa*on  of  the  trapezoidal  rule  using  a  "free"  interpolant.  Use  this  solver  if  the  problem  is  only  moderately  s*ff  and  you  need  a  solu*on  without  numerical  damping.  ode23t  can  solve  DAEs.  

ode23tb   is  an  implementa*on  of  TR-­‐BDF2,  an  implicit  Runge-­‐KuKa  formula  with  a  first  stage  that  is  a  trapezoidal  rule  step  and  a  second  stage  that  is  a  backward  differen*a*on  formula  of  order  two.  By  construc*on,  the  same  itera*on  matrix  is  used  in  evalua*ng  both  stages.  Like  ode23s,  this  solver  may  be  more  efficient  than  ode15s  at  crude  tolerances.  

Page 31: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

Eigenvalues  of  Linear  Systems  of  ODEs  

Linear Systems of ODEs are given by

(11.18)

Differentiating both sides of the first ODE in (11.18) with respect to time gives:

Substitute the second ODE:

Page 32: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

Eigenvalues  of  Linear  Systems  of  ODEs  

Further working on the equation:

(11.19)

Using the definitions of matrix trace and determinant:

(11.20)

Page 33: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

Eigenvalues  of  Linear  Systems  of  ODEs  

We write the system (11.18) in matrix notation:

where

To solve (11.20), we try the exponential function

Page 34: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

Eigenvalues  of  Linear  Systems  of  ODEs  

From :

Substituting these into (11.20) we get:

Therefore, is a solution to (11.20) if

Thus, the eigenvalues of the linear systems of ODEs:

(11.22)

(11.21)

Page 35: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

Eigenvalues  of  Nonlinear  Systems  of  ODEs  We consider a nonlinear system of ODEs

(11.23)

First, we require that system (11.23) has a unique steady state solution that occurs by setting

from which we get a steady state point

Page 36: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

Eigenvalues  of  Nonlinear  Systems  of  ODEs  Second, we determine the stability of the steady state (or equilibrium state) by adding small perturbations , hence the solutions of the system (11.23) should satisfy

(11.24)

The common form of perturbations is an exponential growth with respect to time perturbation, that is

where A0 and B0 are constants.

(11.25)

Page 37: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

Eigenvalues  of  Nonlinear  Systems  of  ODEs  Next, we linearise the system (11.23) by approximating the perturbations around the steady state point Using

If the steady state and consequently

Taylor’s theorem for functions with 2 variables, the approximations are:

Page 38: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

Eigenvalues  of  Nonlinear  Systems  of  ODEs  So, the linear approximation to system (11.23) is

(11.26) where a Jacobian matrix J is defined:

Page 39: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

Eigenvalues  of  Nonlinear  Systems  of  ODEs  Using (11.25), system (11.26) becomes

(11.27)

By solving (11.27), we obtain the eigenvalues which are determined from

Page 40: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

Eigenvalues  of  Nonlinear  Systems  of  ODEs  Example: Consider a system of ODEs

(11.28)

We first find the steady state points, by

which imply This leads to , which is the only stead state point.

Page 41: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

Eigenvalues  of  Nonlinear  Systems  of  ODEs  Next, we find the linearization. Here

and by the steady state point,

Thus, the Jacobian matrix

Page 42: Sff! ODEs!! and Systemsof! ODEs!people.bu.edu/.../LectureNotes/Lecture11_8Oct2015.pdf · Here E = 0 is an equilibrium state, and (11.13) has the general solution which, in comparison

Eigenvalues  of  Nonlinear  Systems  of  ODEs  Applying the perturbations given in (11.25) to the system (11.28) by using (11.26):

or,

From which, the eigenvalues