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
DynLinTimoshenkoModel.m
Go to the documentation of this file.
1 namespace models{
2 namespace beam{
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 {
40  public: /* ( Constant ) */
41 
42  static const withHeat = false;
51  public: /* ( setObservable ) */
52 
100  public: /* ( Dependent, setObservable ) */
101 
103 
104 
106 
107 
108  public:
109 
154 
155 
157 
158 
160 
161 
176 
177 
190 
192 
193 
217  public: /* ( Dependent ) */
218 
233  public:
234 
235  maxTemp = 0;
247  minTemp = 0;
271 
272 
274 
275 
277 
278 
280 
281 
283 
284 
285  public:
286 
287  DynLinTimoshenkoModel(char cfgfile,logical nonlinear) {
288  this = this@models.BaseFullModel;
289 
290  if nargin < 2
291  this.NonlinearModel= false;
292  if nargin < 1
293  /* error('no config file given'); */
294  cfgfile = " Simpel1.txt ";
295  fprintf(" No config file specified, using "" %s "" \n ",cfgfile);
296  end
297  else
298  this.NonlinearModel= nonlinear;
299  end
300  this.Name= " DynLin Timoschenko Beam ";
301 
302  /* % Load geometry from config file */
303  path = fileparts(mfilename(" fullpath "));
304  this.ConfigFile= fullfile(path,cfgfile);
305  [this.Points, this.RO_raw, this.KR_raw, this.FH_raw, raw_mat, this.Supports, this.Loads] = this.read_file(this.ConfigFile);
306 
307  this.Materials= models.beam.Material.empty;
308  for midx = 1:size(raw_mat,1)
309  this.Materials(midx) = models.beam.Material(raw_mat(midx,:));
310  end
311 
312  this.split_RO;
313  this.split_KR;
314  /* Important: call before creating the system! */
315  this.preprocess_data;
316 
317  /* % Model specifics */
318  this.T= 5;
319  this.dt= .05;
321 
322  /* % Internal setup */
323  this.System= models.beam.DynLinTimoshenkoSystem(this);
324 
325  /* Subspace reduction */
326  s = spacereduction.PODGreedy;
327  s.Eps= 1e-7;
328  this.SpaceReducer= s;
329 
330  /* No approximation - core fun is linear */
331  this.Approx= [];
332 
333  /* No Parameters */
334  this.Sampler= sampling.GridSampler;
335  /* this.Sampler.Samples = 20; */
336 
337  /* % ODE solver setup */
338  o = solvers.MLode15i;
339 /* o = solvers.MLWrapper(@ode15i); */
340  o.MaxStep= this.dt;
341  this.ODESolver= o;
342 
343  /* Train with all inputs */
344  this.TrainingInputs= 1:this.System.InputCount;
345 
346  /* Setup JKerMor export */
347  je = JKerMorExport;
348  je.JavaExportPackage= " models.beam.dynlintimo ";
349  je.Short= this.Name;
350  je.GeometryExportCallback= @this.exportGeometry;
351  je.JaRMoSBaseSource= " C:\Users\CreaByte\Documents\Uni\Software\JaRMoSBase\src ";
352  this.JKerMorExport= je;
353  }
365 #if 0 //mtoc++: 'get.ColorMap'
366 function m = ColorMap() {
367  dc = [0:3/this.NumColors:1]^t;
368  m = [0*dc dc 1-dc; dc 0*dc+1 0*dc; 0*dc+1 1-dc 0*dc];
369  }
370 
371 #endif
372 
384  function exportGeometry(handle f,char folder,export.JaRMoSExport export) {
385 
386  fprintf(f," \t<dimension>3</dimension>\n ");
387  fprintf(f," \t<nodes>%d</nodes>\n ",size(this.Points,1));
388 /* fprintf(f,'\t<fieldmapping>VERTEX</fieldmapping>\n'); */
389  fprintf(f," \t<hasFaces>false</hasFaces>\n ");
390 
391  /* % Nodes (including dirichlet points) */
392  usedpts = [];
393  for i=1:length(this.Elements)
394  el = this.Elements[i];
395  usedpts = [usedpts el.PointsIdx];/* #ok */
396 
397  end
398  usedpts = unique(usedpts);
399 
400  vert = single(reshape(this.Points(usedpts,:)^t,1,[]));
401  export.saveRealVector(vert, " vertices.bin ", folder);
402 
403  /* Dirichlet nodes */
404  fprintf(f," \t<hasDirichletNodes>true</hasDirichletNodes>\n ");
405  export.saveRealVector(int16(this.dir_u), " dir_nodes.bin ", folder);
406  export.saveRealVector(this.u_dir, " dir_values.bin ", folder);
407 
408  n = length(this.Elements);
409  edges = int16(2*n);
410  for i=1:n
411  edges((2*i-1):(2*i)) = this.Elements[i].PointsIdx;
412  end
413  export.saveRealVector(edges, " edges.bin ", folder);
414  }
430  function plot(rowvec t,matrix u);
431 
432  function plotSingle(double t,colvec u,handle h);
433 
434  /* % Getter & Setters */
435  public:
436 
437 
438 #if 0 //mtoc++: 'set.BeamRefinementFactor'
439 function BeamRefinementFactor(value) {
440  [this.Points, this.RO_raw, this.KR_raw] = this.read_file(this.ConfigFile);
441  if value ~= this.RO_factor_global
442  this.ModelData.SimCache.clearTrajectories;
443  end
444  this.RO_factor_global= value;
445  this.split_RO;
446  this.split_KR;
447  /* Update model */
448  this.preprocess_data;
449  /* Update system */
450  this.System.buildElementDependentComponents;
451  /* Update core function */
452  this.System.f.initialize;
453  }
454 
455 #endif
456 
457 
458 
459 #if 0 //mtoc++: 'get.BeamRefinementFactor'
460 function value = BeamRefinementFactor() {
461  value = this.RO_factor_global;
462  }
463 
464 #endif
465 
466 
467 
468 #if 0 //mtoc++: 'set.CurvedBeamRefinementFactor'
469 function CurvedBeamRefinementFactor(value) {
470  [this.Points, this.RO_raw, this.KR_raw] = this.read_file(this.ConfigFile);
471  if value ~= this.KR_factor_global
472  this.ModelData.SimCache.clearTrajectories;
473  end
474  this.KR_factor_global= value;
475  this.split_RO;
476  this.split_KR;
477  /* Update model */
478  this.preprocess_data;
479  /* Update system */
480  this.System.buildElementDependentComponents;
481  /* Update core function */
482  this.System.f.initialize;
483  }
484 
485 #endif
486 
487 
488 
489 #if 0 //mtoc++: 'get.CurvedBeamRefinementFactor'
490 function value = CurvedBeamRefinementFactor() {
491  value = this.KR_factor_global;
492  }
493 
494 #endif
495 
496 
497  private:
498 
499  function [Points , RO_raw , KR , FH , mat , lager , lasten ] = read_file(file);
500 
501  function [data , RO , KR , FH , p ] = preprocess_data(RO_raw,KR_raw,FH_raw,c,supports,loads,gravity,RO_factor_global,KR_factor_global);
502 
503  function split_RO();
504 
505  function split_KR();
506 
507  public: /* ( Static ) */
508 
509  static function experiment1() {
510  m = models.beam.DynLinTimoshenkoModel(" Rohrleitungen z.txt ");
511  m.BeamRefinementFactor= 5;
512  m.TrainingInputs= 1:m.System.InputCount;
513  m.T= 10;
514  m.dt= .1;
515  m.System.Params(1).Range = [0 2];
516  m.System.Params(1).Desired = 10;
517  m.System.Params(2).Range = [0 .1];
518  m.System.Params(2).Desired = 10;
519  m.System.Params(3).Range = 20*[-1 1];
520  m.System.Params(3).Desired = 10;
521  m.offlineGenerations;
522  r = m.buildReducedModel;
523  save experiment1 m r;
524  }
525 
526 
527  static function test_TimoshenkoModel() {
528  m = models.beam.DynLinTimoshenkoModel;
529  run(m);
530  /* Nonlinear */
531  m = models.beam.DynLinTimoshenkoModel(" Simpel1.txt ",true);
532  run(m);
533 
534  function run(m)
535  for np = 1:4
536  mu = m.getRandomParam;
537  for in = 1:m.System.InputCount
538  fprintf(" Running with input %d, mu=%s\n ",in,num2str(mu));
539  [t,y] = m.simulate(mu,in);
540  end
541  end
542  end
543  }
564 };
565 }
566 }
567 
function file = save(char directory,char filename)
Saves this instance inside the data.ModelData.DataDirectory folder using the model's SaveTag if set o...
char Name
The name of the Model.
Definition: BaseModel.m:117
matrix ColorMap
The color map to use. Value is hardcoded so far.
static function test_TimoshenkoModel()
Linear.
function useFileTrajectoryData(logical overwrite)
Sets the TrajectoryData and TrajectoryFxiData classes to filesystem based versions.
Definition: ModelData.m:349
double PlotFactor
Plot enhancement factor.
The base class for any KerMor detailed model.
Definition: BaseFullModel.m:18
u_dir
Extracted Dirichlet values full u vector (using dir_u)
A matlab matrix.
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
function plotSingle(double t,colvec u,handle h)
plot_single: Plots a single beam configuration for given time and field data.
Definition: plotSingle.m:20
A double value.
struct Elements
Cell array of all model structure elements.
reshape
hanges the dimensions of the handle object array to the specified dimensions. See the MATLAB reshape ...
An integer value.
f_neum
Vector for neumann boundary conditions.
function plot(rowvec t,matrix u)
plot: Plots the current displacements and heat (u = 4 x numNodes x timesteps matrix) ...
Definition: plot.m:20
JKerMorExport: Export class for JaRMoS model generation from KerMor models.
Definition: JKerMorExport.m:17
Matlab's base handle class (documentation generation substitute)
static const withHeat
No heat modeling at the current stage.
A boolean value.
integer NumColors
Number of colors for plotting.
char ConfigFile
The configuration file used for this model.
maxTemp
Maximum temperature for plotting.
solvers.BaseSolver ODESolver
The solver to use for the ODE. Must be an instance of any solvers.BaseSolver subclass.
Definition: BaseModel.m:315
minTemp
Maximum temperature for plotting.
InputCount
The number of inputs available.
export.JKerMorExport JKerMorExport
Export instance for possible export of this model to JKerMor.
A matlab column vector.
approx.BaseApprox Approx
The approximation method for the CoreFunction.
double BeamLineWidth
The beam line width for plotting.
double T
The final timestep up to which to simulate.
Definition: BaseModel.m:271
data.ModelData Data
The full model's data container. Defaults to an empty container.
function exportGeometry(handle f,char folder,export.JaRMoSExport export)
Exports the model geometry to JKerMor.
matrix Points
3D coordinates of the beam end points
spacereduction.BaseSpaceReducer SpaceReducer
The reduction algorithm for subspaces.
dscomponents.ACoreFun f
The core f function from the dynamical system.
free
The indices in the global state space vector of all points including dirichlet points (dim=7: 3locati...
logical NonlinearModel
Flag that indicates if the nonlinear model is used.
A matlab row vector.
DynLinTimoshenkoModel(char cfgfile,logical nonlinear)
Creates a new timoshenko model.
A MatLab struct.
A MatLab character array.