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
PODReducer.m
Go to the documentation of this file.
1 namespace spacereduction{
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 
18 class PODReducer
20  public general.POD,
42  public:
43 
44  rowvec<double> SingularValues = "[]";
57  public:
58 
59  .false IncludeInitialSpace = false;
70  public:
71 
72  function plotSummary(pm,context) {
73  plotSummary@spacereduction.BaseSpaceReducer(this, pm, context);
74  if ~isempty(this.SingularValues)
75  str = sprintf(" %s: POD singular value decay ",context);
76  h = pm.nextPlot(" podreducer_singvals ",str,...
77  " subspace size "," singular values ");
78  semilogy(h,this.SingularValues," LineWidth ",2);
79 /* h = pm.nextPlot('podreducer_projerr',str,...
80  * 'subspace size','projection error');
81  * semilogy(h,this.SingularValues,'LineWidth',2); */
82  else
83  warning(" spacereduction:PODReducer ",...
84  " Singular value data empty. Not providing summary. ");
85  end
86  end
87  end
88 
89  methods(Access=protected)
90  function [V,W] = generateReducedSpaceImpl(this, model, subset)
91  /* Implements the abstract method from BaseSpaceReducer */
92 
93  /* Compile all trajectories into a large vector */
94  md = model.Data;
95  td = md.TrajectoryData;
96  nt = td.getNumTrajectories;
97  if nt == 0
98  error(" No training data found in ModelData. ");
99  end
100 
101  /* Augment block data with fxi values */
102  if this.IncludeTrajectoryFxiData
103  if isempty(md.TrajectoryFxiData)
104  error(" No training fxi data found in ModelData. ");
105  end
106  td = data.JoinedBlockData(td, md.TrajectoryData);
107  end
108  /* Wrap in finite difference adder */
109  if this.IncludeFiniteDifferences
110  td = data.FinDiffBlockData(td);
111  end
112 
113  Vex = [];
114  if this.IncludeBSpan
115  Vex = md.InputSpaceSpan(subset,:);
116  end
117  if this.IncludeInitialSpace
118  is = this.getInitialSpace(md.TrajectoryData, this, subset);
119  Vex = [Vex is];
120  end
121 
122  [V, this.SingularValues] = this.computePOD(td, Vex, subset);
123  this.ProjectionError= flipud(cumsum(flipud(this.SingularValues)));
124 /* if ~isempty(Vex)
125  * o = general.Orthonormalizer;
126  * V = o.orthonormalize([Vex V]);
127  * end */
128  if ~isempty(Vex)
129  o = general.Orthonormalizer;
130  V = [Vex V];
131  id = speye(size(V,2));
132  while true /* V isn't really orthogonal after orthonormalizing once */
133 
134  diff = max(max(abs(V^t*V-id)));
135  if diff < 1e-9
136  break
137  else
138  V = o.orthonormalize(V);
139  end
140  end
141  end
142  /* Galerkin projection */
143  W = [];
144  end
145  end
146 
147 end
148 
149 
150  }
151 
152 };
IReductionSummaryPlotProvider:
POD: Implements proper orthogonal decomposition.
Definition: POD.m:18
Base class for all space reduction algorithms.