Skip to content

Commit af1f458

Browse files
authored
Merge pull request #117 from ComputationalScienceLaboratory/docs/ascherDAE
Docs/ascher DAE
2 parents fb2d7e7 + f05b7e7 commit af1f458

File tree

7 files changed

+204
-24
lines changed

7 files changed

+204
-24
lines changed

docs/references.bib

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,28 @@ @article{GW82
155155
year = {1982},
156156
doi = {10.1177/003754978203800206}
157157
}
158+
159+
160+
@article{Asc89,
161+
author = {Ascher, Uri},
162+
title = {On Symmetric Schemes and Differential-Algebraic Equations},
163+
journal = {SIAM Journal on Scientific and Statistical Computing},
164+
volume = {10},
165+
number = {5},
166+
pages = {937-949},
167+
year = {1989},
168+
doi = {10.1137/0910054}
169+
}
170+
171+
@article{Pet86,
172+
author = {L. R. Petzold},
173+
journal = {SIAM Journal on Numerical Analysis},
174+
number = {4},
175+
pages = {837--852},
176+
publisher = {Society for Industrial and Applied Mathematics},
177+
title = {Order Results for Implicit Runge-Kutta Methods Applied to Differential/ Algebraic Systems},
178+
volume = {23},
179+
year = {1986},
180+
url = {https://www.jstor.org/stable/2157625}
181+
}
182+

notebooks/quick-start.ipynb

Lines changed: 58 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

toolbox/+otp/+ascherlineardae/+presets/Canonical.m

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
classdef Canonical < otp.ascherlineardae.AscherLinearDAEProblem
2-
%CANONICAL The problem formulation of the linear DAE from the literature
3-
%
4-
% See
5-
% Ascher, Uri. "On symmetric schemes and differential-algebraic equations."
6-
% SIAM journal on scientific and statistical computing 10.5 (1989): 937-949.
7-
2+
% The problem defined by Uri Ascher in :cite:p:`Asc89` (sec. 2) which uses time span $t \in [0, 1]$ and intial
3+
% condition $[y_0, z_0]^T = [1, β]^T$.
4+
%
85
methods
9-
function obj = Canonical(beta)
10-
tspan = [0.0; 1];
6+
function obj = Canonical(varargin)
7+
% Create the Canonical CUSP problem object.
8+
%
9+
% Parameters
10+
% ----------
11+
% varargin
12+
% A variable number of name-value pairs. The accepted names are
13+
%
14+
% - ``Beta`` – Value of $β$.
1115

12-
if nargin < 1
13-
beta = 0.5;
14-
end
16+
p = inputParser;
17+
p.addParameter('beta', 1);
18+
p.parse(varargin{:});
19+
opts = p.Results;
1520

16-
params = otp.ascherlineardae.AscherLinearDAEParameters;
17-
params.Beta = beta;
21+
params = otp.ascherlineardae.AscherLinearDAEParameters;
22+
params.Beta = opts.beta;
1823

19-
y0 = [1; beta];
24+
y0 = [1; params.Beta];
25+
tspan = [0.0; 1.0];
2026

2127
obj = obj@otp.ascherlineardae.AscherLinearDAEProblem(tspan, y0, params);
2228
end
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
classdef Petzold < otp.ascherlineardae.AscherLinearDAEProblem
2+
% The Petzold DAE example :cite:p:`Pet86` as a special case of the Ascher linear DAE problem. This preset uses time
3+
% span $t \in [0, 1]$ and $β = 0 $ with the initial condition $[y_0, z_0]^T = [1, 0]^T $.
4+
%
5+
methods
6+
function obj = Petzold
7+
% Create the Petzold example of the Ascher linear DAE problem object.
8+
9+
params = otp.ascherlineardae.AscherLinearDAEParameters;
10+
params.Beta = 0;
11+
12+
y0 = [1; params.Beta];
13+
tspan = [0.0; 1.0];
14+
15+
obj = obj@otp.ascherlineardae.AscherLinearDAEProblem(tspan, y0, params);
16+
end
17+
end
18+
end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
classdef Stiff < otp.ascherlineardae.AscherLinearDAEProblem
2+
% The Stiff example from :cite:p:`Asc89`. A variant of the Ascher linear DAE problem which uses time span
3+
% $t \in [0, 1]$ and $β = 100$ with the initial condition $[y_0, z_0]^T = [1, 100]^T$.
4+
%
5+
methods
6+
function obj = Stiff
7+
% Create the stiff example of the Ascher linear DAE problem object.
8+
params = otp.ascherlineardae.AscherLinearDAEParameters;
9+
params.Beta = 100;
10+
11+
y0 = [1; params.Beta];
12+
tspan = [0.0; 1.0];
13+
14+
obj = obj@otp.ascherlineardae.AscherLinearDAEProblem(tspan, y0, params);
15+
end
16+
end
17+
end
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
classdef AscherLinearDAEParameters
2-
%ASCHERLINEARDAEPARAMETERS
2+
% Parameters for Ascher Linear DAE problem
33
properties
4-
%Beta is an arbitrary scalar parameter
5-
Beta %MATLAB ONLY: (1,1) {mustBeNumeric} = 0.5
4+
% A scalar parameter $β$ in the linear model. It affects the stifness of the problem.
5+
Beta %MATLAB ONLY: (1,1) {mustBeNumeric} = 1
66
end
77
end

toolbox/+otp/+ascherlineardae/AscherLinearDAEProblem.m

Lines changed: 63 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,61 @@
11
classdef AscherLinearDAEProblem < otp.Problem
2-
%ASCHERLINEARDAEPROBLEM This is an Index-1 DAE problem
2+
% A linear differential-algebraic problem with time-dependant mass matrix.
33
%
4+
% The Ascher linear DAE Problem :cite:p:`Asc89` is an index-1 differential-agebraic equation given by
5+
%
6+
% $$
7+
% \begin{bmatrix}
8+
% 1 & -t \\
9+
% 0 & 0
10+
% \end{bmatrix} \begin{bmatrix} y'(t) \\ z'(t) \end{bmatrix} = \left[ \begin{array}{cc}
11+
% -1 & 1+t \\
12+
% β & -1-β t
13+
% \end{array}\right] \begin{bmatrix} y(t) \\ z(t) \end{bmatrix} + \begin{bmatrix}
14+
% 0 \\
15+
% \sin(t)
16+
% \end{bmatrix}.
17+
% $$
18+
%
19+
% When the initial condition $y(0) = 1 , z(0) = β$ is used, the problem has the following closed-form solution:
20+
%
21+
% $$
22+
% \begin{bmatrix} y(t)\\ z(t) \end{bmatrix} = \begin{bmatrix}
23+
% t \sin(t) + (1 + β t) e^{-t}\\
24+
% β e^{-t} + \sin(t)
25+
% \end{bmatrix}.
26+
% $$
27+
% This DAE problem can be used to investigate the convergence of implcit time-stepping methods due to its stiffness
28+
% and time-dependant mass matrix.
29+
%
30+
% Notes
31+
% -----
32+
% +---------------------+-----------------------------------------+
33+
% | Type | DAE |
34+
% +---------------------+-----------------------------------------+
35+
% | Number of Variables | 2 |
36+
% +---------------------+-----------------------------------------+
37+
% | Stiff | possibly, depending on $β$ |
38+
% +---------------------+-----------------------------------------+
39+
%
40+
% Example
41+
% -------
42+
% >>> problem = otp.ascherlineardae.presets.Canonical('Beta', 50);
43+
% >>> t = linspace(0, 1);
44+
% >>> sol = problem.solveExactly(t);
45+
% >>> problem.plot(t, sol);
46+
447
methods
548
function obj = AscherLinearDAEProblem(timeSpan, y0, parameters)
49+
% Create an Ascher linear DAE problem object.
50+
%
51+
% Parameters
52+
% ----------
53+
% timeSpan : numeric(1, 2)
54+
% The start and final time.
55+
% y0 : numeric(2, 1)
56+
% The initial condition.
57+
% parameters : AscherLinearDAEParameters
58+
% The parameters.
659
obj@otp.Problem('Ascher Linear DAE', 2, timeSpan, y0, parameters);
760
end
861
end
@@ -17,7 +70,15 @@ function onSettingsChanged(obj)
1770
'MStateDependence', 'none', ...
1871
'MassSingular', 'yes');
1972
end
20-
73+
74+
function label = internalIndex2label(~, index)
75+
if index == 1
76+
label = 'Differential';
77+
else
78+
label = 'Algebraic';
79+
end
80+
end
81+
2182
function y = internalSolveExactly(obj, t)
2283
beta = obj.Parameters.Beta;
2384
if ~isequal(obj.Y0, [1; beta])
@@ -35,4 +96,3 @@ function onSettingsChanged(obj)
3596
end
3697
end
3798
end
38-

0 commit comments

Comments
 (0)