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
Activation.m
Go to the documentation of this file.
1 namespace models{
2 namespace muscle{
3 namespace tests{
4 
5 
6 /* (Autoinserted by mtoc++)
7  * This source code has been filtered by the mtoc++ executable,
8  * which generates code that can be processed by the doxygen documentation tool.
9  *
10  * On the other hand, it can neither be interpreted by MATLAB, nor can it be compiled with a C++ compiler.
11  * Except for the comments, the function bodies of your M-file functions are untouched.
12  * Consequently, the FILTER_SOURCE_FILES doxygen switch (default in our Doxyfile.template) will produce
13  * attached source files that are highly readable by humans.
14  *
15  * Additionally, links in the doxygen generated documentation to the source code of functions and class members refer to
16  * the correct locations in the source code browser.
17  * However, the line numbers most likely do not correspond to the line numbers in the original MATLAB source files.
18  */
19 
34  public:
35 
36  Activation(version) {
37  if nargin < 1
38  version = 1;
39  end
40  /* Creates a Debug simple muscle model configuration. */
41  this = this@models.muscle.AMuscleConfig;
42  this.addOption(" Version ",version);
43  this.init;
44 
45  /* Use classical FL function with fl(1)=1 */
46  this.Options.FL= 3;
47  }
48 
49 
50  function configureModel(m) {
51  configureModel@models.muscle.AMuscleConfig(this, m);
52 /* sys = m.System;
53  *f = sys.f; */
54  m.T= 15;
55  m.dt= 1;
56  /* Activate over 50ms */
57  m.DefaultMu(2) = 10;
58  m.ODESolver.RelTol= 1e-10;
59  m.ODESolver.AbsTol= 1e-10;
60  }
61 
62 
63  protected:
64 
65 
66  function geo = getGeometry() {
67  geo = fem.geometry.RegularHex8Grid([0 2],[0 1],[0 1]);
68  if this.Options.Version == 2
69  geo = fem.geometry.RegularHex8Grid([0:.5:1],[0:1:2],[0:.5:1]);
70  end
71  geo = geo.toCube27Node;
72  }
80  function displ_dir = setPositionDirichletBC(displ_dir) {
81  geo = this.FEM.Geometry;
82  /* Always fix back side */
83  switch this.Options.Version
84  case 1
85  displ_dir(:,geo.Elements(1,geo.MasterFaces(1:2,:))) = true;
86  case 2
87  displ_dir(:,geo.Elements(1:4,geo.MasterFaces(1,:))) = true;
88  displ_dir(:,geo.Elements(5:8,geo.MasterFaces(2,:))) = true;
89 /* otherwise
90  * displ_dir(:,geo.Elements(1,geo.MasterFaces(1,:))) = true;
91  *displ_dir(:,geo.Elements(1:4,geo.MasterFaces(1,:))) = true; */
92  end
93  }
94 
95 
96  function anull = seta0(anull) {
97  anull(1,:,:) = 1;
98  }
99 
100 
101  public: /* ( Static ) */
102 
103  static function res = test_Activation() {
104  for version = 1:2
105  a = models.muscle.tests.Activation(version);
106  m = a.createModel;
107  if version == 1
108  f1 = m.getPositionDirichletBCFaceIdx(1,1);
109  f2 = m.getPositionDirichletBCFaceIdx(1,2);
110  m.setGaussIntegrationRule(4);
111  else
112  f1 = m.getPositionDirichletBCFaceIdx(1:4,1);
113  f2 = m.getPositionDirichletBCFaceIdx(5:8,2);
114  end
115 
116  mu = m.DefaultMu;
117  maxp = [1 rand(1,5)*10];
118  res = true;
119  for k=1:length(maxp)
120  mu(13) = maxp(k);
121  [t,y] = m.simulate(mu);
122  pdf = m.getResidualForces(t,y);
123  /* Check overall zero force
124  *max(abs(sum(pdf))) */
125  res = res && all(abs(sum(pdf)) < 1e-8);
126 
127  force_l = sum(pdf(f1,end),1);
128  force_r = sum(pdf(f2,end),1);
129  fprintf(" P_{max}=%g => Force left %gN, right %gN\n ",...
130  maxp(k),force_l,force_r);
131  /* norm(maxp(k)-force_l) */
132  res = res && norm(version*maxp(k)-force_l) < 1e-8;
133  end
134  end
135  }
145 };
146 }
147 }
148 }
149 
150 
151 
function geo = getGeometry()
Single cube with same config as reference element.
Definition: Activation.m:66
function addOption(name, default, varargin)
Definition: AFEMConfig.m:219
static function res = test_Activation()
Version 2 has 2mm^2 area,so double force is expected!
Definition: Activation.m:103
Tests the force generated by an isometrically fixed muscle.
Definition: Activation.m:20
Speed test * all(1:3)
function displ_dir = setPositionDirichletBC(displ_dir)
Definition: Activation.m:80
function anull = seta0(anull)
Definition: Activation.m:96