58 if ~isa(model.
System,
" models.BaseFirstOrderSystem ")
59 error(
" Solver not implemented for non-first order systems. ");
61 this.
Name=
" Semi-implicit euler method ";
69 s = this.model.System;
71 error(
" This solver requires an (affine) linear system component A. ");
81 if ~isempty(find((abs(
t(2:end)-
t(1:end-1) - dt)) / dt > 1e-6,1))
83 error(
" non-equidistant dt timesteps. ");
90 ed = solvers.SolverEventData;
93 effsteps = length(outputtimes);
95 x = [x0 zeros(size(x0,1),effsteps-1)];
98 oldex = []; newex = []; edim = 0; est = [];
99 if isa(this.model,
" models.ReducedModel ")
100 est = this.model.ErrorEstimator;
101 if ~isempty(est) && est.Enabled
102 edim = est.ExtraODEDims;
103 oldex = x0(end-edim+1:end);
114 fdep = s.A.TimeDependent;
117 A = s.A.getStateJacobian;
122 [
l, u] = lu(M - dt * A);
126 oldx = x0(1:end-edim);
130 RHS = RHS + dt*s.f.evaluate(oldx,
t(idx-1));
133 RHS = RHS + dt*s.B.evaluate(
t(idx-1), s.mu)*s.u(
t(idx-1));
142 A = s.A.evaluate(1,
t(idx));
145 M = s.M.evaluate(
t(idx));
147 newx = (M - dt * A)\RHS;
160 odepart = est.evalODEPart([newx; oldex],
t(idx-1), ut);
161 newex = oldex + dt * odepart;
173 if outputtimes(outidx) == idx
177 ed.States= [newx; newex];
178 this.
notify(
" StepPerformed ",ed);
181 x(:,outidx) = [newx; newex];
notify
Broadcast a notice that a specific event is occurring on a specified handle object or array of handle...
The base class for any KerMor detailed model.
logical RealTimeMode
Determines if the solver's StepPerformed event should be used upon solving instead of returning the f...
models.BaseFirstOrderSystem System
The actual dynamical system used in the model.
BaseCustomSolver: Base class for all self-implemented solvers.
SemiImplicitEuler(models.BaseFullModel model)
logical TimeDependent
Flag that indicates time-dependency of the Mass Matrix.
SemiImplicitEuler: Solves ODEs in KerMor using implicit euler for the linear part and explicit euler ...
solvers.SolverTypes SolverType
The type of the solver.
dscomponents.AMassMatrix M
The mass matrix of the ODE .
function matrix< double > x = customSolve(unused1,rowvec< double > t,colvec< double > x0,rowvec< integer > outputtimes)
Implements the actual semi-implicit solving of the given ODE system.