Skip to content

Commit 3cfaec9

Browse files
committed
up Ascher docs re code review
1 parent 427216d commit 3cfaec9

File tree

4 files changed

+23
-24
lines changed

4 files changed

+23
-24
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
classdef Canonical < otp.ascherlineardae.AscherLinearDAEProblem
22
% The problem defined by Uri Ascher in :cite:p:`Asc89` (sec. 2)
3-
% which uses timespan $t \in [0, 1]$ and $\beta = 1 $.
3+
% which uses timespan $t \in [0, 1]$ and intial condition $[y_0, z_0]^T = [1, \beta]^T $.
44
%
55
methods
66
function obj = Canonical(varargin)

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
classdef Petzold < otp.ascherlineardae.AscherLinearDAEProblem
2-
% The Petzold DAE example :cite:p:`Pet86` as a variant of the
3-
% Ascher linear DAE problem
4-
% which uses timespan $t \in [0, 1]$ and $\beta = 0 $.
2+
% The Petzold DAE example :cite:p:`Pet86` as a special case of the
3+
% Ascher linear DAE problem.
4+
% This preset uses timespan $t \in [0, 1]$ and $\beta = 0 $ with the initial condition $[y_0, z_0]^T = [1, 0]^T $.
55
%
66
methods
77
function obj = Petzold

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
classdef Stiff < otp.ascherlineardae.AscherLinearDAEProblem
2-
% The Stiff example from :cite:p:`Asc89` (sec. 2. A variant of the
2+
% The Stiff example from :cite:p:`Asc89`. A variant of the
33
% Ascher linear DAE problem
4-
% which uses timespan $t \in [0, 1]$ and $\beta = 100 $.
4+
% which uses timespan $t \in [0, 1]$ and $\beta = 100 $ with the initial condition $[y_0, z_0]^T = [1, 100]^T $.
55
%
66
methods
77
function obj = Stiff
88
% Create the stiff example of the Ascher linear DAE problem object.
9-
109
params = otp.ascherlineardae.AscherLinearDAEParameters;
1110
params.Beta = 100;
1211

toolbox/+otp/+ascherlineardae/AscherLinearDAEProblem.m

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
classdef AscherLinearDAEProblem < otp.Problem
2-
% A simple linear differential algebraic 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
4+
% The Ascher linear DAE Problem :cite:p:`Asc89` is an index-1 differential-agebraic
55
% equation given by
66
%
77
% $$
@@ -17,7 +17,7 @@
1717
% \end{bmatrix}.
1818
% $$
1919
%
20-
% The problem has the following closed-form solution when the initial condition $y(0) = 1 , z(0) = \beta$ is used:
20+
% When the initial condition $y(0) = 1 , z(0) = \beta$ is used, the problem has the following closed-form solution:
2121
%
2222
% $$
2323
% \begin{bmatrix} y(t)\\ z(t) \end{bmatrix} = \begin{bmatrix}
@@ -43,14 +43,9 @@
4343
% Example
4444
% -------
4545
% >>> problem = otp.ascherlineardae.presets.Canonical('Beta', 50);
46-
% >>> t = linspace(0,1,100);
47-
% >>> sol = problem.solveExcatly(t);
48-
% >>> problem.plot(sol);
49-
50-
properties (Access = private, Constant)
51-
NumComps = 2
52-
VarNames = 'yz'
53-
end
46+
% >>> t = linspace(0,1);
47+
% >>> sol = problem.solveExactly(t);
48+
% >>> problem.plot(t, sol);
5449

5550
methods
5651
function obj = AscherLinearDAEProblem(timeSpan, y0, parameters)
@@ -61,7 +56,7 @@
6156
% timeSpan : numeric(1, 2)
6257
% The start and final time.
6358
% y0 : numeric(2, 1)
64-
% The initial conditions.
59+
% The initial condition.
6560
% parameters : AscherLinearDAEParameters
6661
% The parameters.
6762
obj@otp.Problem('Ascher Linear DAE', 2, timeSpan, y0, parameters);
@@ -78,9 +73,16 @@ function onSettingsChanged(obj)
7873
'MStateDependence', 'none', ...
7974
'MassSingular', 'yes');
8075
end
81-
82-
function sol = internalSolveExactly(obj, t)
83-
sol = [];
76+
77+
function label = internalIndex2label(~, index)
78+
if index == 1
79+
label = 'Differential Variable';
80+
else
81+
label = 'Algebraic Variable';
82+
end
83+
end
84+
85+
function y = internalSolveExactly(obj, t)
8486
beta = obj.Parameters.Beta;
8587
if ~isequal(obj.Y0, [1; beta])
8688
error('OTP:noExactSolution', ...
@@ -89,8 +91,6 @@ function onSettingsChanged(obj)
8991

9092
y = [t .* sin(t) + (1 + beta * t) .* exp(-t); ...
9193
beta * exp(-t) + sin(t)];
92-
sol.x = t;
93-
sol.y = y;
9494
end
9595

9696
function sol = internalSolve(obj, varargin)

0 commit comments

Comments
 (0)