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
ReducedSecondOrderSystem.m
Go to the documentation of this file.
1 namespace models{
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 models.ReducedSystem,
28  public:
29 
30 
31  public:
32 
34  this = this@models.BaseSecondOrderSystem(rmodel);
35  this = this@models.ReducedSystem(rmodel);
36  }
45  function build() {
46  build@models.ReducedSystem(this);
47  rm = this.Model;
48  fullsys = rm.FullModel.System;
49  /* Additional steps
50  * Project damping matrix */
51  if ~isempty(fullsys.D)
52  this.D= fullsys.D.project(rm.V,rm.W);
53  end
54  }
55 
56 
57  function J = getJacobian(double t,x_xdot_c) {
58  td = this.NumTotalDofs;
59  sd = this.NumStateDofs;
60  dd = this.NumDerivativeDofs;
61  ad = this.NumAlgebraicDofs;
62  xdotpos = sd+(1:dd);
63  xpos = 1:sd;
64  cpos = sd+dd+(1:ad);
65  x = x_xdot_c(xpos);
66  xdot = x_xdot_c(xdotpos);
67  J = sparse(td,td);
68  I = speye(sd);
70  J(xpos,:) = [sparse(sd,sd) I sparse(sd,ad)];
71  if ~isempty(this.A)
72  J(xdotpos,xpos) = J(xdotpos,xpos) + this.A.getStateJacobian(x, t);
73  end
74  if ~isempty(this.D)
75  J(xdotpos,xdotpos) = J(xdotpos,xdotpos) + this.D.getStateJacobian(xdot, t);
76  end
77  if ~isempty(this.f)
78  J(xdotpos,:) = J(xdotpos,:) + this.f.getStateJacobian(x_xdot_c, t);
79  end
80  if ~isempty(this.g)
81  J(cpos,:) = this.g.getStateJacobian(x_xdot_c,t);
82  end
83  }
93  function dx = ODEFun(double t,colvec<double> x) {
94  est = this.Model.ErrorEstimator;
95  haveest = ~isempty(est) && est.Enabled;
96  if haveest
97  xall = x;
98  x = x(1:end-est.ExtraODEDims,:);
99  end
100 
101  dx = ODEFun@models.BaseSecondOrderSystem(this,t,x);
102 
103  if haveest
104  dx = [dx; est.evalODEPart(xall, t, this.u(t))];
105  end
106  }
107 
108 
109  function z_zdot_c0 = getX0(colvec<double> mu) {
110 
111  z_c0 = getX0@models.BaseFirstOrderSystem(this, mu);
112  num_z_dof = this.NumStateDofs;
113  num_zdot_dof = this.NumDerivativeDofs;
114  z_zdot_c0 = zeros(this.NumTotalDofs,1);
115 
116  /* Insert state initial values */
117  z_zdot_c0(1:num_z_dof) = z_c0(1:num_z_dof);
118 
119  /* Insert zero derivative initial values (xdot0) between */
120  z_zdot_c0(num_z_dof+(1:num_zdot_dof)) = zeros(num_zdot_dof,1);
121 
122  /* Insert alg cond initial values */
123  z_zdot_c0(num_z_dof+num_zdot_dof+1:end) = z_c0(num_z_dof+1:end);
124 
125  m = this.Model;
126  if ~isempty(m.ErrorEstimator) && m.ErrorEstimator.Enabled
127  z_zdot_c0 = [z_zdot_c0; m.ErrorEstimator.getE0(mu)];
128  end
129  }
143  updateSparsityPattern@models.ReducedSystem(this);
144  }
145 
146 
147 
148  protected:
149 
150 
151  function R = compileReconstructionMatrix(V) {
152  R = blkdiag(V,V,eye(this.NumAlgebraicDofs));
153  }
154 
155 
156  function updateDimensions() {
157  updateDimensions@models.ReducedSystem(this);
158  this.NumDerivativeDofs= this.NumStateDofs;
159  this.NumTotalDofs= 2*this.NumStateDofs + this.NumAlgebraicDofs;
160  }
161 
162 
163  function val = getDerivativeDirichletValues(double t) {
164  val = getDerivativeDirichletValues@models.BaseSecondOrderSystem(this, t);
165  }
166 
167 
169  validateModel@models.ReducedSystem(this, model);
170  }
171 
172 
173 
174 };
175 }
176 
177 
178 
function J = getStateJacobian(unused1, unused2, unused3)
The base class for any KerMor detailed model.
Definition: BaseFullModel.m:18
function J = getStateJacobian(x, t)
Default implementation of jacobian matrix evaluation via finite differences.
Definition: ACoreFun.m:395
Model
The Model this System is attached to.
function projected = project(V, W, projected)
Definition: LinearCoreFun.m:66
REDUCEDSECONDORDERSYSTEM Summary of this class goes here Detailed explanation goes here...
ReducedSystem: A KerMor reduced dynamical system.
Definition: ReducedSystem.m:18
The KerMor reduced model class.
Definition: ReducedModel.m:18
function dx = ODEFun(double t,colvec< double > x)
#define I(x, y, z)
Definition: CalcMD5.c:171
function validateModel(models.BaseFullModel model)
Base class for all KerMor second-order dynamical systems.
dscomponents.LinearCoreFun D
The damping matrix of the second order system.
mu
The current parameter for simulations, [] is none used.
DerivativeDirichletPosInStateDofs
A logical column vector containing true at the locations of explicit derivative dirichlet conditions...
ReducedSecondOrderSystem(models.ReducedModel rmodel)
Creates a new base dynamical system class instance.
R
The reduced dof to full dof reconstruction matrix.
Definition: ReducedSystem.m:59
function z_zdot_c0 = getX0(colvec< double > mu)
Gets the initial value of .
function val = getDerivativeDirichletValues(double t)
Computes the derivative dirichlet values dependent on the current time.
dscomponents.ACoreFun f
The core f function from the dynamical system.
dscomponents.ACoreFun g
The system's algebraic constraints function.
function J = getJacobian(double t, x_xdot_c)
Computes the global jacobian of the current RHS system.
u
The current input function as function handle, [] if none used.
dscomponents.LinearCoreFun A
Represents a linear or affine-linear component of the dynamical system.