11classdef 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 % $$
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}
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 )
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