find numerical solution of ordinary differential-algebraic initial value problems
dsolve(daesys, numeric, vars, method=meth, options)
set or list; ordinary differential equation(s), algebraic equation(s) and initial conditions
literal; instruct dsolve to find a numerical solution
(optional) dependent variable or a set or list of dependent variables for daesys
literal; keyword for specification of the method
name; specification of the method, rkf45_dae, ck45_dae, or rosenbrock_dae
(optional) equations of the form keyword = value
The dsolve DAE extension methods are standard numerical methods designed for ODE IVP that have been extended to the solution of DAE problems.
Specifically, the solvers have been extended to the solution of regular ODE and limited index 1 DAE (that can be isolated for a required dependent variable). The system is reduced to this specific index 1 system via index reduction.
Note: The index can be thought of as how far the DAE system is from being an ODE system.
The DAE extension methods then use the modified solver at each step. At the end of each step, the solution is projected back so that it satisfies any additional constraints of the problem. These additional constraints arise in the process of index reduction, and will only be present for systems for which index reduction is required.
dsolve has three extension methods, rkf45_dae, which is an extension of the rkf45 method, ck45_dae, which is an extension of the ck45 method, and rosenbrock_dae, which is an extension of the rosenbrock method.
As extensions, these methods retain many of the features of the original solvers, for example, events and range solutions. This page is concerned only with highlighting the differences between these methods, and any extension specific options.
One difference is that, by default, optimization is active for the extension methods, as the system is usually quite complex after relevant postprocessing has occurred.
For setup of the problem, it is required that the initial conditions are consistent, that is, that they satisfy any hidden constraints of the problem. In any cases where the constraints are not sufficiently satisfied, an error results, and the violated condition(s) are printed, allowing adjustment of the initial data to satisfy them.
In addition, if differential is false, it is possible to automatically compute values for any of the index 1 variables of the problem. Initial conditions for these variables need not be provided.
There are two major differences between the capabilities of the extension solvers and their original counterparts: the extension solvers can only be used with real valued problems and the initial values for the problem cannot be changed interactively.
Three options are specific to the DAE extension solvers:
This option specifies whether, after each step, the solution is projected back onto the set of constraints that are not in direct use by the solver. This is true by default. If the DAE IVP is highly stable, and speed is an issue, setting this to false can provide a reasonable solution in less time.
This option specifies that index reduction be performed until the system is fully differential (that is, does not take advantage of the index 1 capabilities of the modified solvers). This is false by default. The use of the index 1 capabilities of the solvers often provides a more stable and less stiff system than the full index reduction, and is usually faster.
This option specifies that parts of the extended system can be left in unsolved (implicit) form until they are evaluated. The solver determines which parts of the system must be put into solved form, in order to render the DAE problem numerically solvable, and which parts can be left in implicit form. This is essentially a smart form of the implicit option used for IVP problems (see dsolve[numeric,IVP]). This is a helpful option. It reduces the complication of the system derived quantities that must be computed to perform the numerical integration. The cost, though, is a linear solve every time the expressions must be evaluated. For problems in which the system is nearly in solved form with respect to the leading derivatives, this is somewhat slower than the direct method. For problems that are dense in the leading derivatives, this can be significantly faster.
Other issues are also discussed in the dsolve[numeric,DAE] page.
The simple pendulum problem in natural coordinates:
dsys ≔ ⅆ2ⅆt2⁢x⁡t=−2⁢λ⁡t⁢x⁡t,ⅆ2ⅆt2⁢y⁡t=−2⁢λ⁡t⁢y⁡t−Pi2,x⁡t2+y⁡t2=1,x⁡0=0,D⁡x⁡0=110,y⁡0=−1,D⁡y⁡0=0,λ⁡0=1200+Pi22
dsol1 ≔ dsolve⁡dsys,numeric,method=rkf45_dae,abserr=1.⁢10-7,relerr=1.⁢10-7,maxfun=0
dsol1 ≔ procx_rkf45_dae...end proc
t1 ≔ time⁡:
r1 ≔ dsol1⁡2000
t1 ≔ time⁡−t1
Compare with projection=false:
dsol2 ≔ dsolve⁡dsys,numeric,method=rkf45_dae,projection=false,abserr=1.⁢10-7,relerr=1.⁢10-7,maxfun=0
dsol2 ≔ procx_rkf45_dae...end proc
t2 ≔ time⁡:
r2 ≔ dsol2⁡2000
t2 ≔ time⁡−t2:
Compare time with differential=true:
dsol3 ≔ dsolve⁡dsys,numeric,method=rkf45_dae,differential=true,abserr=1.⁢10-7,relerr=1.⁢10-7,maxfun=0
dsol3 ≔ procx_rkf45_dae...end proc
t3 ≔ time⁡:
r3 ≔ dsol3⁡2000
t3 ≔ time⁡−t3:
The Chemical Akzo Nobel problem
This DAE system describes a chemical process in which FLB and ZHU are mixed while carbon dioxide is added over time. The ZLA concentration is of interest.
The rate equations for each reaction are given by:
rates ≔ r1⁡t=k1⁢FLB⁡t4⁢CO2⁡t,r2⁡t=k2⁢FLBT⁡t⁢ZHU⁡t,r3⁡t=k2⁢FLB⁡t⁢ZLA⁡tK,r4⁡t=k3⁢FLB⁡t⁢ZHU⁡t2,r5⁡t=k4⁢FLB_ZHU⁡t2⁢CO2⁡t,Ks=FLB_ZHU⁡tFLB⁡t⁢ZHU⁡t:
The carbon dioxide inflow is governed by
inflow ≔ FIn⁡t=klA⁢pCO2H−CO2⁡t:
The concentrations are described by the following differential equations
conc ≔ ⅆⅆt⁢FLB⁡t=−2⁢r1⁡t+r2⁡t−r3⁡t−r4⁡t,ⅆⅆt⁢CO2⁡t=−0.5⁢r1⁡t−r4⁡t−0.5⁢r5⁡t+FIn⁡t,ⅆⅆt⁢FLBT⁡t=r1⁡t−r2⁡t+r3⁡t,ⅆⅆt⁢ZHU⁡t=−r2⁡t+r3⁡t−2⁢r4⁡t,ⅆⅆt⁢ZLA⁡t=r2⁡t−r3⁡t+r5⁡t:
and the Initial values are given by:
ics ≔ FLB⁡0=0.444,CO2⁡0=0.00123,FLBT⁡0=0,ZHU⁡0=0.007,ZLA⁡0=0:
The parameters are as follows:
pars ≔ k1=18.7,k2=0.58,k3=0.09,k4=0.42,K=34.4,klA=3.3,Ks=115.83,pCO2=0.9,H=737:
To begin, we apply the parameters to the rates and inflow:
rates ≔ eval⁡rates,pars:
inflow ≔ eval⁡inflow,pars:
then pass all equations and initial conditions to dsolve with moderately tight tolerances choosing the rosenbrock_dae method, as the problem is known to be stiff:
dsol4 ≔ dsolve⁡conc,rates,inflow,ics,numeric,method=rosenbrock_dae,abserr=1.⁢10-10,relerr=1.⁢10-10
dsol4 ≔ procx_rosenbrock_dae...end proc
The period of interest is t=0..180, but the CO2 concentration shows some interesting behavior in the first 0.5s:
The values at t=180 show perfect comparison to the 6-digit accurate benchmark results (CO2(180)=1.20383e-3, ZLA(180)=1.70801e-2):
And we plot the CO2 and ZLA concentrations as a function of time over the entire range of interest (adjusting CO2 by a factor of 10 for scale):
Download Help Document
What kind of issue would you like to report? (Optional)