KerMor  0.9
Model order reduction for nonlinear dynamical systems and nonlinear approximation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BaseSolver.m
Go to the documentation of this file.
1 namespace solvers{
2 
3 
4 /* (Autoinserted by mtoc++)
5  * This source code has been filtered by the mtoc++ executable,
6  * which generates code that can be processed by the doxygen documentation tool.
7  *
8  * On the other hand, it can neither be interpreted by MATLAB, nor can it be compiled with a C++ compiler.
9  * Except for the comments, the function bodies of your M-file functions are untouched.
10  * Consequently, the FILTER_SOURCE_FILES doxygen switch (default in our Doxyfile.template) will produce
11  * attached source files that are highly readable by humans.
12  *
13  * Additionally, links in the doxygen generated documentation to the source code of functions and class members refer to
14  * the correct locations in the source code browser.
15  * However, the line numbers most likely do not correspond to the line numbers in the original MATLAB source files.
16  */
17 
19  :public KerMorObject {
46  public: /* ( setObservable ) */
47 
48  double MaxStep = "[]";
114  public:
115 
116  Name = "KerMor BaseSolver class";
130  solvers.SolverTypes SolverType = solvers.SolverTypes.Unknown;
149  public:
150 
152  this = this@KerMorObject;
153  this.registerProps(" MaxStep "," InitialStep "," Name "," RealTimeMode "," SolverType ");
154  }
155 
156 
157  public: /* ( Abstract ) */
158 
159  virtual function [rowvect , matrixx ] = solve(odefun,rowvec t,colvec x0) = 0;
181  /* % Getter & Setter */
182  public:
183 
184 
185 #if 0 //mtoc++: 'set.MaxStep'
186 function MaxStep(value) {
187  if isempty(value)
188  this.MaxStep= value;
189  return;
190  elseif ~isposrealscalar(value)
191  error(" Positive real scalar expected. ");
192  elseif value == 0
193  error(" Maximum time step must be greater than zero. Use [] to unset. ");
194  end
195  this.MaxStep= value;
196  }
197 
198 #endif
199 
200 
201 
202 #if 0 //mtoc++: 'set.SolverType'
203 function SolverType(value) {
204  if ~isa(value," solvers.SolverTypes ")
205 /* error('Solver type must be a solvers.SolverTypes') */
206  value = solvers.SolverTypes.Unknown;
207  end
208  this.SolverType= value;
209  }
210 
211 #endif
212 
213 
214 
215 #if 0 //mtoc++: 'set.InitialStep'
216 function InitialStep(value) {
217  if ~isempty(value) && ~isposrealscalar(value)
218  error(" Positive real scalar expected. ");
219  end
220  this.InitialStep= value;
221  }
222 
223 #endif
224 
225 
226 
227 #if 0 //mtoc++: 'set.M'
228 function M(value) {
229  if ~isempty(value) && ~isa(value," dscomponents.AMassMatrix ")
230  error(" Mass matrix must be a dscomponents.AMassMatrix subclass ");
231  end
232  this.M= value;
233  }
234 
235 #endif
236 
237 
238  public:
239 
251  public: /* ( Static ) */
252 
253 
254  static function res = test_SolverSpeedTest() {
255  m = models.synth.KernelTest(200);
256  m.ErrorEstimator= [];
257  m.offlineGenerations;
258  perform(solvers.ExplEuler);
259  perform(solvers.MLWrapper(@ode23));
260  perform(solvers.MLWrapper(@ode45));
261  perform(solvers.Heun);
262  perform(solvers.FullyImplEuler(m));
263 
264  res = 1;
265 
266  function perform(solver)
267  m.ODESolver= solver;
268  tic;
269  r = m.buildReducedModel;
270  t = toc;
271  fprintf(" Using solver %s (red. model build time %gs)\n ",solver.Name,t);
272  ma = ModelAnalyzer(r);
273  ma.compareRedFull(r.getRandomParam);
274 /* [~,~,~,t,tr,tr_noerr] = r.getTrajectories;
275  * fprintf('Online simulations time\nFull detail: %fs\nReduced with error estimator: %fs\nReduced without error estimation:%fs\n\n',t,tr,tr_noerr); */
276  end
277  }
278 
279 
280 
298 };
299 }
300 
301 
302 
ModelAnalyzer: Analysis tools for reduced models and approximations.
Definition: ModelAnalyzer.m:17
SolverTypes: Enumeration class classifying a ode solver type as explicit solver, implicit solver or M...
Definition: SolverTypes.m:18
A matlab matrix.
logical RealTimeMode
Determines if the solver's StepPerformed event should be used upon solving instead of returning the f...
Definition: BaseSolver.m:85
A double value.
Base class for any KerMor class.
Definition: KerMorObject.m:17
Name
The solver's name.
Definition: BaseSolver.m:116
virtual function [ rowvec t , matrix x ] = solve(odefun,rowvec t,colvec x0)
The abstract solve function for the ODE solver.
function registerProps(varargin)
Call this method at any class that defines DPCM observed properties.
Definition: DPCMObject.m:125
double InitialStep
The initial step size for the solver. So far only used by the MLWrapper class for the native matlab s...
Definition: BaseSolver.m:68
EVENT StepPerformed
Gets fired when an ODE solver performs an intermediate step.
Definition: BaseSolver.m:240
A boolean value.
KerMorObject()
Constructs a new KerMor object.
Definition: KerMorObject.m:55
solvers.SolverTypes SolverType
The type of the solver.
Definition: BaseSolver.m:130
double MaxStep
Maximum time step for solver.
Definition: BaseSolver.m:48
dscomponents.AMassMatrix M
The mass matrix of the ODE .
Definition: BaseSolver.m:101
A matlab column vector.
A matlab row vector.
Base class for all KerMor ODE solvers.
Definition: BaseSolver.m:18
static function res = test_SolverSpeedTest()
Definition: BaseSolver.m:254
function res = isposrealscalar(value)
isposintscalar: Backwards-compatibility function for matlab versions greater than 2012a ...