38
39
The "Beginners Guide" is intended for users who are new to OdePkg and
39
40
who want to solve differential equations with the Octave language and
40
41
the package OdePkg. In this section it will be explained what OdePkg is
41
about in *note About OdePkg:: and how OdePkg grew up from the beginning
42
in *note OdePkg history and roadmap::. In *note Installation and
42
about in *Note About OdePkg:: and how OdePkg grew up from the beginning
43
in *Note OdePkg history and roadmap::. In *Note Installation and
43
44
deinstallation:: it is explained how OdePkg can be installed in Octave
44
45
and how it can later be removed from Octave if it is not needed
45
46
anymore. If you encounter problems while using OdePkg then have a look
46
at *note Reporting Bugs:: how these bugs can be reported. In the *note
47
at *Note Reporting Bugs:: how these bugs can be reported. In the *Note
47
48
The "foo" example:: a first example is explained.
258
259
The options structure `A' that can be set up with with the command
259
260
`odeset' must always be the fourth input argument when using the ODE
260
261
solvers and the DAE solvers but if you are using an IDE solver then `A'
261
must be the fifth input argument (cf. *note Solver families::). The
262
must be the fifth input argument (cf. *Note Solver families::). The
262
263
various options that can be set with the command `odeset' are described
263
in *note ODE/DAE/IDE/DDE options::.
264
in *Note ODE/DAE/IDE/DDE options::.
265
266
Further examples have also been implemented. These example files and
266
267
functions are of the form `odepkg_examples_*'. Different testsuite
288
289
The "Users Guide" is intended for trained users who already know in
289
290
principal how to solve differential equations with the Octave language
290
291
and OdePkg. In this chapter it will be explained which equations can be
291
solved with OdePkg in *note Differential Equations::. It will be
292
solved with OdePkg in *Note Differential Equations::. It will be
292
293
explained which solvers can be used for the different kind of equations
293
in *note Solver families:: and which options can be set for the
294
optimization of the solving process in *note ODE/DAE/IDE/DDE options::.
294
in *Note Solver families:: and which options can be set for the
295
optimization of the solving process in *Note ODE/DAE/IDE/DDE options::.
295
296
The help text of all M-file functions and all Oct-file functions have
296
been extracted and are displayed in the sections *note M-File Function
297
Reference:: and *note Oct-File Function Reference::.
297
been extracted and are displayed in the sections *Note M-File Function
298
Reference:: and *Note Oct-File Function Reference::.
313
314
In this section the different kind of differential equations that can
314
315
be solved with OdePkg are explained. The formulation of ordinary
315
differential equations is described in section *note ODE equations::
316
differential equations is described in section *Note ODE equations::
316
317
followed by the description of explicetly formulated differential
317
algebraic equations in section *note DAE equations::, implicetely
318
formulated differential algebraic equations in section *note IDE
319
equations:: and delay differential algebraic equations in section *note
318
algebraic equations in section *Note DAE equations::, implicetely
319
formulated differential algebraic equations in section *Note IDE
320
equations:: and delay differential algebraic equations in section *Note
336
337
be a scalar or vector of derivatives. The variable t always is a scalar
337
338
describing one point of time and the variable y(t) is a scalar or
338
339
vector of solutions from the last time step of the set of ordinary
339
differential equations. If the equation is non-stiff then the *note
340
differential equations. If the equation is non-stiff then the *Note
340
341
Runge-Kutta solvers:: can be used to solve such kind of differential
341
342
equations but if the equation is stiff then it is recommended to use
342
the *note Hairer-Wanner solvers::. An ODE equation definition in Octave
343
the *Note Hairer-Wanner solvers::. An ODE equation definition in Octave
344
345
function [dy] = ODEequation (t, y, varargin)
359
360
equation. If it does not depend on time then it can be defined as a
360
361
constant matrix or a function. If it does depend on time then it must
361
362
be defined as a function. Use the command `odeset' to pass the mass
362
matrix information to the solver function (cf. *note ODE/DAE/IDE/DDE
363
options::). If the equation is non-stiff then the *note Runge-Kutta
363
matrix information to the solver function (cf. *Note ODE/DAE/IDE/DDE
364
options::). If the equation is non-stiff then the *Note Runge-Kutta
364
365
solvers:: can be used to solve such kind of differential equations but
365
if the equation is stiff then it is recommended to use the *note
366
if the equation is stiff then it is recommended to use the *Note
366
367
Hairer-Wanner solvers::. A DAE equation definition in Octave must look
368
369
function [dy] = DAEequation (t, y, varargin)
369
370
and the mass matrix definition can either be a constant mass matrix
370
371
or a valid function handle to a mass matrix calculation function that
371
372
can be set with the command `odeset' (cf. option `Mass' of section
372
*note ODE/DAE/IDE/DDE options::).
373
*Note ODE/DAE/IDE/DDE options::).
375
376
File: odepkg.info, Node: IDE equations, Next: DDE equations, Prev: DAE equations, Up: Differential Equations
381
382
may be a scalar or vector of derivatives. The variable t always is a
382
383
scalar describing one point of time and the variable y(t) is a scalar
383
384
or vector of solutions from the set of implicit differential equations.
384
Only IDE solvers from section *note Cash modified BDF solvers:: or
385
section *note DDaskr direct method solver:: can be used to solve such
385
Only IDE solvers from section *Note Cash modified BDF solvers:: or
386
section *Note DDaskr direct method solver:: can be used to solve such
386
387
kind of differential equations. A DAE equation definition in Octave
388
389
function [residual] = IDEequation (t, y, dy, varargin)
397
398
f(t,y(t),y(t-\tau_1),...,y(t-\tau_n)) where y'(t) may be a scalar or
398
399
vector of derivatives. The variable t always is a scalar describing one
399
400
point of time and the variables y(t-\tau_i) are scalars or vectors from
400
the past. Only DDE solvers from section *note Modified Runge-Kutta
401
the past. Only DDE solvers from section *Note Modified Runge-Kutta
401
402
solvers:: can be used to solve such kind of differential equations. A
402
403
DDE equation definition in Octave must look like
403
404
function [dy] = DDEequation (t, y, z, varargin)
413
414
In this section the different kind of solvers are introduced that have
414
415
been implemented in OdePkg. This section starts with the basic
415
Runge-Kutta solvers in section *note Runge-Kutta solvers:: and is
416
continued with the Mex-file Hairer-Wanner solvers in section *note
416
Runge-Kutta solvers in section *Note Runge-Kutta solvers:: and is
417
continued with the Mex-file Hairer-Wanner solvers in section *Note
417
418
Hairer-Wanner solvers::. Performance tests have also been added to the
418
419
OdePkg. Some of these performance results have been added to section
419
*note ODE solver performances::.
420
*Note ODE solver performances::.
608
609
The modified Runge-Kutta solvers are written in the Octave language and
609
610
that are saved as m-files. There have been implemented four different
610
611
solvers that do have a very similiar structure to that solvers found in
611
section *note Runge-Kutta solvers::. Their names are `ode23d',
612
section *Note Runge-Kutta solvers::. Their names are `ode23d',
612
613
`ode45d', `ode54d' and `ode78d'. The modified Runge-Kutta solvers have
613
614
been added to the OdePkg to solve non-stiff DDEs with constant delays
614
615
only, stiff equations of that form cannot be solved with these solvers.
615
616
For further information about the error estimation of these solvers cf.
616
section *note Runge-Kutta solvers::.
617
section *Note Runge-Kutta solvers::.
618
619
Note: The four DDE solvers of OdePkg are not syntax compatible to
619
620
propietary solvers. The reason is that the input arguments of the
1483
1490
vlag = interp1 (vsol.x, vsol.y, vsol.x - 2);
1484
1491
plot (vsol.y, vlag); legend ("fcao (t,y,z)");
1493
-- Function File: [] = odebwe (@FUN, SLOT, INIT, [OPT], [PAR1, PAR2,
1495
-- Command: [SOL] = odebwe (@FUN, SLOT, INIT, [OPT], [PAR1, PAR2, ...])
1496
-- Command: [T, Y, [XE, YE, IE]] = odebwe (@FUN, SLOT, INIT, [OPT],
1498
This function file can be used to solve a set of stiff ordinary
1499
differential equations (stiff ODEs) or stiff differential
1500
algebraic equations (stiff DAEs) with the Backward Euler method.
1502
If this function is called with no return argument then plot the
1503
solution over time in a figure window while solving the set of
1504
ODEs that are defined in a function and specified by the function
1505
handle @FUN. The second input argument SLOT is a double vector
1506
that defines the time slot, INIT is a double vector that defines
1507
the initial values of the states, OPT can optionally be a
1508
structure array that keeps the options created with the command
1509
`odeset' and PAR1, PAR2, ... can optionally be other input
1510
arguments of any type that have to be passed to the function
1513
If this function is called with one return argument then return
1514
the solution SOL of type structure array after solving the set of
1515
ODEs. The solution SOL has the fields X of type double column
1516
vector for the steps chosen by the solver, Y of type double column
1517
vector for the solutions at each time step of X, SOLVER of type
1518
string for the solver name and optionally the extended time stamp
1519
information XE, the extended solution information YE and the
1520
extended index information IE all of type double column vector
1521
that keep the informations of the event function if an event
1522
function handle is set in the option argument OPT.
1524
If this function is called with more than one return argument then
1525
return the time stamps T, the solution values Y and optionally the
1526
extended time stamp information XE, the extended solution
1527
information YE and the extended index information IE all of type
1528
double column vector.
1530
For example, solve an anonymous implementation of the Van der Pol
1533
fvdb = @(vt,vy) [vy(2); (1 - vy(1)^2) * vy(2) - vy(1)];
1534
vjac = @(vt,vy) [0, 1; -1 - 2 * vy(1) * vy(2), 1 - vy(1)^2];
1535
vopt = odeset ("RelTol", 1e-3, "AbsTol", 1e-3, \
1536
"NormControl", "on", "OutputFcn", @odeplot, \
1538
odebwe (fvdb, [0 20], [2 0], vopt);
1486
1540
-- Function File: [] = odeexamples ()
1487
1541
Open the differential equations examples menu and allow the user
1488
1542
to select a submenu of ODE, DAE, IDE or DDE examples.
2344
2398
* ode23: M-File Function Reference.
2346
2400
* ode23d: M-File Function Reference.
2348
2402
* ode2r: Oct-File Function Reference.
2350
2404
* ode45: M-File Function Reference.
2352
2406
* ode45d: M-File Function Reference.
2354
2408
* ode54: M-File Function Reference.
2356
2410
* ode54d: M-File Function Reference.
2358
2412
* ode5r: Oct-File Function Reference.
2360
2414
* ode78: M-File Function Reference.
2362
2416
* ode78d: M-File Function Reference.
2364
2418
* odebda: Oct-File Function Reference.
2366
2420
* odebdi: Oct-File Function Reference.
2422
* odebwe: M-File Function Reference.
2368
2424
* odeexamples: M-File Function Reference.
2370
2426
* odeget: M-File Function Reference.
2372
2428
* odekdi: Oct-File Function Reference.
2374
2430
* odephas2: M-File Function Reference.
2376
2432
* odephas3: M-File Function Reference.
2378
2434
* odepkg: M-File Function Reference.
2380
2436
* odepkg_event_handle: M-File Function Reference.
2382
2438
* odepkg_examples_dae: M-File Function Reference.
2384
2440
* odepkg_examples_dde: M-File Function Reference.
2386
2442
* odepkg_examples_ide: M-File Function Reference.
2388
2444
* odepkg_examples_ode: M-File Function Reference.
2390
2446
* odepkg_structure_check: M-File Function Reference.
2392
2448
* odepkg_testsuite_calcmescd: M-File Function Reference.
2394
2450
* odepkg_testsuite_calcscd: M-File Function Reference.
2396
2452
* odepkg_testsuite_chemakzo: M-File Function Reference.
2398
2454
* odepkg_testsuite_hires: M-File Function Reference.
2400
2456
* odepkg_testsuite_implakzo: M-File Function Reference.
2402
2458
* odepkg_testsuite_implrober: M-File Function Reference.
2404
2460
* odepkg_testsuite_oregonator: M-File Function Reference.
2406
2462
* odepkg_testsuite_pollution: M-File Function Reference.
2408
2464
* odepkg_testsuite_robertson: M-File Function Reference.
2410
2466
* odepkg_testsuite_transistor: M-File Function Reference.
2412
2468
* odeplot: M-File Function Reference.
2414
2470
* odeprint: M-File Function Reference.
2416
2472
* oders: Oct-File Function Reference.
2418
2474
* odeset: M-File Function Reference.
2420
2476
* odesx: Oct-File Function Reference.
2528
Node: Beginners Guide1172
2529
Node: About OdePkg2337
2530
Node: OdePkg history and roadmap3445
2531
Node: Installation and deinstallation7978
2532
Node: Reporting Bugs8854
2533
Node: The "foo" example9530
2534
Node: Users Guide14575
2535
Node: Differential Equations15817
2536
Node: ODE equations16776
2537
Node: DAE equations17563
2538
Node: IDE equations19047
2539
Node: DDE equations19768
2540
Node: Solver families20484
2541
Node: Runge-Kutta solvers21534
2542
Ref: Runge-Kutta solvers-Footnote-125449
2543
Node: Hairer-Wanner solvers25901
2544
Node: Cash modified BDF solvers27728
2545
Node: DDaskr direct method solver29369
2546
Node: Modified Runge-Kutta solvers31038
2547
Node: ODE solver performances32838
2548
Node: ODE/DAE/IDE/DDE options38508
2549
Node: M-File Function Reference56310
2550
Node: Oct-File Function Reference96627
2551
Node: Programmers Guide115183
2552
Node: Missing features115401
2553
Node: Function Index118916
2588
Node: Beginners Guide1175
2589
Node: About OdePkg2340
2590
Node: OdePkg history and roadmap3448
2591
Node: Installation and deinstallation7981
2592
Node: Reporting Bugs8857
2593
Node: The "foo" example9533
2594
Node: Users Guide14578
2595
Node: Differential Equations15820
2596
Node: ODE equations16779
2597
Node: DAE equations17566
2598
Node: IDE equations19050
2599
Node: DDE equations19771
2600
Node: Solver families20487
2601
Node: Runge-Kutta solvers21537
2602
Ref: Runge-Kutta solvers-Footnote-125452
2603
Node: Hairer-Wanner solvers25904
2604
Node: Cash modified BDF solvers27731
2605
Node: DDaskr direct method solver29372
2606
Node: Modified Runge-Kutta solvers31041
2607
Node: ODE solver performances32841
2608
Node: ODE/DAE/IDE/DDE options38511
2609
Node: M-File Function Reference56367
2610
Node: Oct-File Function Reference99188
2611
Node: Programmers Guide117744
2612
Node: Missing features117962
2613
Node: Function Index121477