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
MathMODExperiment.m
Go to the documentation of this file.
1 namespace models{
2 namespace mathmod2012{
3 
4 
5 /* (Autoinserted by mtoc++)
6  * This source code has been filtered by the mtoc++ executable,
7  * which generates code that can be processed by the doxygen documentation tool.
8  *
9  * On the other hand, it can neither be interpreted by MATLAB, nor can it be compiled with a C++ compiler.
10  * Except for the comments, the function bodies of your M-file functions are untouched.
11  * Consequently, the FILTER_SOURCE_FILES doxygen switch (default in our Doxyfile.template) will produce
12  * attached source files that are highly readable by humans.
13  *
14  * Additionally, links in the doxygen generated documentation to the source code of functions and class members refer to
15  * the correct locations in the source code browser.
16  * However, the line numbers most likely do not correspond to the line numbers in the original MATLAB source files.
17  */
18 
20  :public models.BaseFullModel {
29  public: /* ( setObservable ) */
30 
31  dim;
44  public: /* ( setObservable ) */
45 
46 
48  this.registerProps(" dim ");
49 
50  if nargin == 0
51  dims = 100;
52  end
53  this.dim= dims;
54 
55  this.Name= " MathMOD 2012 Experiments ";
56 
57  this.Sampler= [];/* sampling.GridSampler; */
58 
59 
60  /* This class implements a fake Approx subclass to allow access
61  * to the this.Ma property for the error estimator. */
62  this.Approx= [];
63 
64  /* s = solvers.MLWrapper(@ode45); */
65  s = solvers.ExplEuler;
66  s.MaxStep= [];
67  /* s = solvers.Heun; */
68  this.ODESolver= s;
69 
70  /* % System settings */
71  this.System= models.mathmod2012.MathMODSystem(this);
72 
73  this.T= 20;
74  this.dt= 0.05;
75  this.System.MaxTimestep= this.dt;
76 
77  this.Sampler= sampling.GridSampler;
78 
79  e1 = [ones(dims,1) zeros(dims,1)];
80  e2 = [zeros(dims,1) ones(dims,1)];
81 
82  x0 = dscomponents.AffineInitialValue;
83  x0.addMatrix(" mu(3) ", ones(dims,1));
84  /* x0.addMatrix('sum(mu)', e1); */
85  this.System.x0= x0;
86 
87  f = this.System.f.Expansion;
88  f.Ma= repmat(-exp(-f.Centers.xi(1,:)/15),dims,1);
89 
90  this.System.Inputs[1] = @(t)[.4*sin(t/3); exp(-(12-t).^2)];
91  this.System.Inputs[2] = @(t)[.5*sin(t/2); 4*exp(-7*(12-t).^2)-.5*exp(-(5-t).^2)];
92  B = dscomponents.AffLinInputConv;
93  B.addMatrix(" mu(1) ", e1);
94  B.addMatrix(" 1-mu(1) ", e2);
95  /* B.addMatrix('-mu(2)', e2); */
96  this.System.B= B;
97 
98  this.TrainingInputs= 1;
99 
100  this.System.C= dscomponents.LinearOutputConv(ones(1,dims)/dims);
101 
102  V = ones(dims,1)/sqrt(dims);
103  s = spacereduction.ManualReduction(V,V);
104  /* s = spacereduction.PODReducer;
105  * s.Value = 3;
106  * s.Mode = 'abs';
107  * s.UseSVDS = dims > 10000;
108  * this.SpaceReducer = s; */
109 
110  s = spacereduction.RotationDecorator(s);
111  s.Dims= 100;
112  s.Degree= 0.05;
113  this.SpaceReducer= s;
114  }
115 
116 
117  public: /* ( Static ) */ /* ( setObservable ) */
118 
119 
120  static function [d , r , m ] = CreatePlots(dim) {
121 
122  m = models.mathmod2012.MathMODExperiment(dim);
123  s = m.SpaceReducer;
124 
125  d = EstimatorAnalyzer;
126  d.EstimatorIterations= [1 2 5];
127  d.EstimatorVersions= [1 1 0 0 1 0 0 1 1];
128  d.SingleFigures= true;
129 
130  d.setModel(m);
131  r = d.ReducedModel;
132 
133  for mu1 = [0 1]
134  d.start([mu1; 1], 1);
135 
136  /* 1 = full, 7 = LSLE TD */
137  md = d.ModelData(end);
138  absmax = 30*abs(md.ErrT(7)-md.ErrT(1));
139  relmax = 30*abs(md.RelErrT(7)-md.RelErrT(1));
140 
141  f = d.Figures[1];
142  a = gca(f);
143  axis(a,[0 m.T md.MinErr*.9 min(1e4,absmax)]);
144  set(legend(a)," Location "," NorthEast ");
145  fi = fullfile(KerMor.App.DataDirectory," MathMOD ",sprintf(" MathMOD_mu1_%d_deg%f_ ", mu1, s.Degree));
146  Utils.saveFigure(f,[fi " errors "]," fig ");
147  title(a,);
148  Utils.saveFigure(f,[fi " errors "]);
149 
150  f = d.Figures[2]; a = gca(f);
151  axis(a,[0 m.T md.MinRelErr*.9 min(1,relmax)]);
152  set(legend(a)," Location "," NorthEast ");
153  Utils.saveFigure(f,[fi " relerr "]," fig ");
154  title(a,);
155  Utils.saveFigure(f,[fi " relerr "]);
156 
157  f = d.Figures[3]; a = gca(f);
158  Utils.saveFigure(f,[fi " ctimes "]," fig ");
159  title(a,);
160  Utils.saveFigure(f,[fi " ctimes "]);
161 
162  end
163 
164  PlotParamSweep(r,[1; 1],1,1,-.1:.05:1.1);
165  Utils.saveFigure(gcf," mu1_sweep "," png ");
166 
167  d.createStatsTables;
168  }
169 
170 
171 
172 };
173 }
174 }
175 
176 
177 
char Name
The name of the Model.
Definition: BaseModel.m:117
Collection of generally useful functions.
Definition: Utils.m:17
The base class for any KerMor detailed model.
Definition: BaseFullModel.m:18
double dt
The desired time-stepsize for simulations.
Definition: BaseModel.m:291
integer TrainingInputs
The indices of inputs to use for training data generation. Uses the DefaultInput if not set (and Defa...
sampling.BaseSampler Sampler
The sampling strategy the Model uses.
models.BaseFirstOrderSystem System
The actual dynamical system used in the model.
Definition: BaseModel.m:102
dscomponents.AInputConv B
The input conversion.
function registerProps(varargin)
Call this method at any class that defines DPCM observed properties.
Definition: DPCMObject.m:125
rowvec EstimatorIterations
How many estimator iterations should be performed?
dscomponents.AInitialValue x0
Function handle to initial state evaluation.
solvers.BaseSolver ODESolver
The solver to use for the ODE. Must be an instance of any solvers.BaseSolver subclass.
Definition: BaseModel.m:315
static function saveFigure(fig, filename, ext)
Opens a matlab save dialog and saves the given figure to the file selected.
Definition: Utils.m:324
Inputs
The system's possible input functions. A cell array of function handles, each taking a time argument ...
approx.BaseApprox Approx
The approximation method for the CoreFunction.
double T
The final timestep up to which to simulate.
Definition: BaseModel.m:271
Analysis class for the error estimators.
spacereduction.BaseSpaceReducer SpaceReducer
The reduction algorithm for subspaces.
dscomponents.LinearOutputConv C
The output conversion Defaults to an LinearOutputConv instance using a 1-matrix, which just forwards ...
dscomponents.ACoreFun f
The core f function from the dynamical system.
Numerical experiments class for Paper ICIAM.
Global configuration class for all KerMor run-time settings.
Definition: KerMor.m:17
static function KerMor theinstance = App()
The singleton KerMor instance.
Definition: KerMor.m:910
double MaxTimestep
The maximum timestep allowed for any ODE solvers.
static function [ d , r , m ] = CreatePlots(dim)