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
BasePCDSystem.m
Go to the documentation of this file.
1 namespace models{
2 namespace pcd{
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 
60  public: /* ( Dependent, setObservable ) */
61 
62  h;
94  private:
95 
96  fh = "[]";
97 
98  fOmega = "[]";
99 
100 
101  public:
102 
114  hs;
147  public:
148 
150  this = this@models.BaseFirstOrderSystem(model);
151 
152  /* Scale diffusion coefficients */
153  m = this.Model;
154  this.Diff= [m.d2/m.d1 m.d3/m.d1 m.d4/m.d1];
155 
156  this.registerProps(" h "," Omega ");
157 
158  this.ReacCoeff= [m.Kc1_real m.Kc2_real m.Kd1_real ...
159  m.Kd2_real m.Kd3_real m.Kd4_real ...
160  m.Kp1_real m.Kp2_real]^t * m.tau;
161 
162  /* Add parameters
163  * Activation area */
164  p = this.addParam(" area ", .1, " Range ", [.01, 1], " Desired ", 10);
165  p.Spacing= " lin ";
166 
167  /* Activation rate */
168  p = this.addParam(" rate ", .001, " Range ", [0.0005, 1], " Desired ", 15);
169  p.Spacing= " log ";
170 
171  /* Activation time */
172  p = this.addParam(" atime ", .5, " Range ", [0, 1], " Desired ", 5);
173  p.Spacing= " lin ";
174 
175  /* Exponent */
176  p = this.addParam(" exponent ", 2, " Range ", [1, 4], " Desired ", 5);
177  p.Spacing= " lin ";
178  }
179 
180 
181 
182 #if 0 //mtoc++: 'get.h'
183 function h = h() {
184  h = this.fh;
185  }
186 
187 #endif
188 
189 
190 
191 #if 0 //mtoc++: 'set.h'
192 function h(value) {
193  if any(value >= this.fOmega(:,2))
194  error(" Cannot choose a step size h=%e value larger or equal to the geometry [%s]. ",...
195  value,Utils.implode(this.fOmega(:)," , "," %g "));
196  end
197  this.fh= value;
198  this.hs= value / this.Model.L;
199  this.updateDimensions;
200 
201  m = this.Model;
202  this.MaxTimestep= [];
203  if ~isa(m.ODESolver," solvers.IImplSolver ") && ~isa(m.ODESolver," solvers.SemiImplicitEuler ")
204  maxdt = .95*(value^2/max([m.d1 m.d2 m.d3 m.d4]));
205  maxdtsc = .95*(this.hs^2/max([1 this.Diff]));
206 
207  if (maxdtsc - maxdt/this.Model.tau) / maxdtsc > 1e-15
208  error(" Inconsistent scaling. Please check. ");
209  end
210  /* Set max timestep value (scaled!) */
211  this.MaxTimestep= maxdtsc;
212 
213  if maxdt < m.dt
214  warning(" models:pcd:CFL "," CFL condition violated with h=%e and current dt=%e.\nSetting System.MaxTimestep=%e (scaled, effective value %e)\n ", value, m.dt, maxdtsc, maxdt);
215  end
216  end
217  }
218 
219 #endif
220 
221 
222 
223 #if 0 //mtoc++: 'get.Omega'
224 function v = Omega() {
225  v = this.fOmega;
226  }
227 
228 #endif
229 
230 
231 
232 #if 0 //mtoc++: 'set.Omega'
233 function Omega(value) {
234  if size(value,2) ~= 2
235  error(" Omega needs to be a dim x 2 matrix with the spatial extend for each dimension in a row. ");
236  end
237  this.fOmega= value;
238 
239  /* Update the dimensions */
240  this.updateDimensions;
241  }
242 
243 #endif
244 
245 
247  setConfig@models.BaseFirstOrderSystem(this, mu, inputidx);
248  m = this.Model;
249  this.ReacCoeff= [m.Kc1_real m.Kc2_real m.Kd1_real ...
250  m.Kd2_real m.Kd3_real m.Kd4_real ...
251  m.Kp1_real m.Kp2_real]^t * m.tau;
252  }
253 
254 
255  protected:
256 
257 
258  function updateDimensions() {
259  if ~isempty(this.fh) && ~isempty(this.fOmega)
260  nd = size(this.fOmega,1);
261  this.Dims= zeros(1,nd);
262  for d=1:nd
263  this.Dims(d) = length(this.fOmega(d,1):this.h:this.fOmega(d,2));
264  end
265  m = prod(this.Dims);
266 
267  this.NumStateDofs= 4*m;
268  updateDimensions@models.BaseFirstOrderSystem(this);
269 
270  /* Set state scaling */
271  ss = zeros(4*m,1);
272  ss(1:m) = this.Model.xa0;
273  ss(m+1:2*m) = this.Model.ya0;
274  ss(2*m+1:3*m) = this.Model.xi0;
275  ss(3*m+1:end) = this.Model.yi0;
276  this.StateScaling= ss;
277 
278  /* Set new initial values and output in 1D-3D systems */
279  this.newSysDimension;
280 
281  /* Call template method for custom actions in the core
282  * functions (diffusion matrix comp) */
283  this.f.newSysDimension;
284  end
285  }
286 
287 
288  protected: /* ( Abstract ) */
289 
290  virtual function newSysDimension() = 0;
306 };
307 }
308 }
309 
310 
311 
312 
313 
Collection of generally useful functions.
Definition: Utils.m:17
h
Spatial stepwidth (in unscaled size units!) is set in subclasses.
Definition: BasePCDSystem.m:62
The base class for any KerMor detailed model.
Definition: BaseFullModel.m:18
Model
The Model this System is attached to.
hs
scaled spatial stepwidth
Dims
The system's dimensions.
function registerProps(varargin)
Call this method at any class that defines DPCM observed properties.
Definition: DPCMObject.m:125
An integer value.
inputidx
The current inputindex of the function .
mu
The current parameter for simulations, [] is none used.
colvec StateScaling
The scaling for the state vectors.
virtual function newSysDimension()
Custom updates for new system dimension.
BasePCDSystem(models.BaseFullModel model)
ReacCoeff
The reaction coefficients.
function setConfig(colvec< double > mu,integer inputidx)
dscomponents.ACoreFun f
The core f function from the dynamical system.
dscomponents.ACoreFun g
The system's algebraic constraints function.
Omega
The spatial width/area/region (in unscaled size units!)
Definition: BasePCDSystem.m:78
double MaxTimestep
The maximum timestep allowed for any ODE solvers.
function ModelParam p = addParam(char name, default, varargin)
Adds a parameter with the given values to the parameter collection of the current dynamical system...
Base class for all KerMor first-order dynamical systems.
PCDSYSTEM The 2D dynamical system of the Programmed Cell Death Model by Markus Daub.
Definition: BasePCDSystem.m:19
Diff
Relative diffusion coefficients ([d2/d1, d3/d1, d4/d1])