Академический Документы
Профессиональный Документы
Культура Документы
L.F. Shampine Department of Mathematics Southern Methodist University Dallas, Texas 75275 shampine@smu.edu www.faculty.smu.edu/shampine
An early model of the El Nio/Southern Oscillation phenomenon with a physical parameter > 0 is
T (t) = T (t) T (t )
Example
Substituting y(t) = et into the neutral DDE
y (t) = y (t 1) + y(t) y(t 1)
leads rst to
et = et + et et
History
An initial value y(a) = (a) is not enough to dene a unique solution of
y (t) = f (t, y(t), y(t 1 ), . . . , y(t k ))
on an interval a t b. We must specify y(t) = (t) for t a so that y(t j ) is dened when a t a + j . The function (t) is called the history of the solution. The Fortran 90 program dde_solver and the two M ATLAB programs allow the history argument to be provided as either a constant vector or a function.
T (t) = T (t) 2 T (t 1)
function Ex1 lags = 1; tspan = [0 6]; sol1 = dde23(@dde,lags,@history,tspan); sol2 = dde23(@dde,lags,1,tspan); tplot = linspace(0,6,100); T1 = deval(sol1,tplot); T2 = deval(sol2,tplot); tplot = [-1 tplot]; T1 = [1 T1]; T2 = [2 T2]; plot(tplot,T1,tplot,T2,0,1,o) %--Subfunctions--------------------function dydt = dde(t,T,Z) dydt = T - 2*Z; function s = history(t) s = 1 - t;
Output of Program
25
20
15
10
10 1
ezdde23 is a variant of dde23 with a different syntax for evaluation of the equations: function dydt = ddes(t,y,ylag1,...,ylagk) The d 1 vector ylagj approximates y(t j ).
Method of Steps
For simplicity we discuss the rst-order system
y (t) = f (t, y(t), y(t )), y(t) = (t) for t a
With mild assumptions on f there is a unique solution. On [a + , a + 2 ], the term y(t ) in f is known and the initial value y(a + ) is known. Repetition shows the existence, uniqueness, and continuous dependence on the data of a solution for all of [a, b].
Propagation of Discontinuities
Generally the solution y(t) of
y (t) = f (t, y(t), y(t )), y(t) = (t) for t 0
The initial discontinuity propagates. The second derivative has a jump at , the third derivative has a jump at 2 , etc. Discontinuities increase in order for retarded DDEs, but generally they do not if there are delayed terms involving derivatives, neutral DDEs.
Discontinuity Tree
Because discontinuities in y (m) (t) affect numerical methods greatly, it is important to track them. Multiple lags interact.
0 {1 , 2 } {21 , 1 + 2 , 22 } {31 , 21 + 2 , 1 + 22 , 32 } . . .
Numerical methods do not see discontinuities with m sufciently big, so when solving retarded DDEs, we can cut off branches in the tree of discontinuities. On entry, dde23 works out the tree for its low order RK formulas. It merges values that are close, e.g., lags 2/3 and 2 lead to discontinuities at 2/3 + 2/3 + 2/3 and 2 that are not quite the same.
Special Discontinuities
Hairer, Nrsett, Wanner discuss Marchuks immunology model with
(t) = max(0, 106 + t)
for t 0
They ignore the discontinuity in (t), but dde23 provides for discontinuities in (t). It tracks them into [a, b].
dde23 assumes that y(a) = (a), but sometimes we need a different value for y(a). An example will be discussed later. dde23 provides for y(a) = (a). The jump in y(a) takes longer to smooth out than the usual jump in y (a).
yn,j = yn + hn
k=1
j,k fn,k ,
Finally, yn+1 = yn + hn
s j=1 j fn,j .
If f is smooth enough on [tn , tn+1 ], a formula of order p has y(tn+1 ) = yn+1 + O(hp+1 ). Step to discontinuities so that f is n smooth.
Continuous Extensions
Apply a method for ODEs to y (t) = f (t, y(t), y(t )). Explicit RK deals well with discontinuities, but how do we approximate the solution at arguments that are not mesh points in terms like y(tn + m hn )? Continuous extensions provide values on tn t tn+1 . Cubic Hermite interpolation to yn , yn , yn+1 , yn+1 in ode23 is C 1 [a, b] and preserves order of accuracy.
dde_solver uses yn+ = yn + hn to approximate y(tn + hn ). The stages fn,j are reused, but a few more are needed to preserve the accuracy of higher order formulas. Its continuous extension is C 1 [a, b].
s j ()fn,j j=1
Short Lags
For efciency, we want to use the biggest step size hn that will provide an accurate result. If hn is bigger than a lag j , one of the arguments of y(tn + m hn j ) may be bigger than tn . The term is then not dened and the explicit RK formula is implicit. Some codes limit hn to make the formula explicit, but this can be very inefcient. Predict values for the delayed terms using the continuous extension of the last step. Use them to evaluate the formula and form the continuous extension for the current step. Use it to correct the delayed terms. Iterate as needed.
Solution Structure
A structure (M ATLAB) or derived type (Fortran 90) is used to hold all the information needed to evaluate y(t) anywhere from the initial point a to the current point. In dde23, this is just {tn , yn , yn }. This is used for delayed terms during the integration and on return, for evaluating y(t) with deval. Saaty discusses a model of biological reaction to x-rays that has the form y (t) = ay(t) + b[c y(t )] for 0 t T and the form y (t) = b[c y(t )] for T t. A good way to deal with this is to restart the integration at t = T . By saving the history function (vector), a solution structure can be used as the history argument of dde23. The matter is handled with an auxiliary function in dde_solver.
Rocking Suitcase
A twowheeled suitcase often starts to rock from side to side as it is pulled. You try to return it to the vertical by twisting the handle, but your response is delayed. This is modeled as a second order equation in the angle (t) of the suitcase to the vertical. Write as a rst order system with y1 (t) = (t) and y2 (t) = (t),
y1 (t) = y2 (t) y2 (t) = sin(y1 (t)) sign(y1 (t)) cos(y1 (t)) y1 (t ) + A sin(t + )
Event Location
A wheel hits the ground (the suitcase is vertical) when y1 (t) = 0. The integration is then to be restarted with y1 (t) = 0 and y2 (t) multiplied by a coefcient of restitution, here 0.913. The suitcase is considered to have fallen over when |y1 (t)| = /2. Like the ODE solvers, dde23 has event location. This means that during an integration, you can locate solutions of a collection of algebraic equations 0 = gi (t, y, Z) by testing for a change of sign and calculating roots with y(t), y(t 1 ), . . . , y(t k ) evaluated using continuous extensions.
Program, Part I
Just like odeset, the function ddeset is used to set options, here events and a more stringent relative error tolerance.
function suitcase state = +1; opts = ddeset(Events,@events, ... RelTol,1e-5); sol = dde23(@ddes,0.1,[0; 0],[0 12],opts); fprintf([Kind of Event:,... time\n]);
Program, Part II
while sol.x(end) < 12 if sol.ie(end) == 1 fprintf([A wheel hit the ground.,... %10.4f\n],sol.x(end)); state = - state; opts = ddeset(opts,InitialY,... [ 0; 0.913*sol.y(2,end)]); sol = dde23(@ddes,0.1,sol,... [sol.x(end) 12],opts); else fprintf([The suitcase fell over.,... %10.4f\n],sol.x(end)); break end end
Output
Kind of Event: A wheel hit the ground. A wheel hit the ground. The suitcase fell over.
1
0.5
0.5
0.5 (t)
1.5