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
SHSystem.m
Go to the documentation of this file.
1 namespace models{
2 namespace motorunit{
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 
19 class SHSystem
38  public: /* ( Transient ) */
39 
40  d = "[]";
52  public: /* ( Constant ) */
53 
54  static const dm = 6;
63  static const dsa = 56;
72  static const .double C_m_slow = 0.58;
85  static const C_m_fast = 1;
86 
87 
88  static const .rowvec<double> ForceOutputScalingPolyCoeff = 1e5*"[0.072141692014344 -0.456658053996476 1.274105896595146 -2.041231359447655 2.058191740934228 -1.353159489096666 0.584711952400098 -0.164458365881107 0.029358733675881 -0.003174883073694 0.000165817182406 0.000048348565452 0.000012193246968]";
108  public:
109 
121  public:
122 
145  private: /* ( Transient ) */
146 
147  peakstart = false;
148 
149 
150  public: /* ( Transient ) */
151 
153  this = this@models.BaseFirstOrderSystem(model);
154 
155  this.addParam(" fibre_type ", 0, " Range ", [0 1]);
156  this.addParam(" mean_current_factor ", 3, " Range ", [0 9]);
157 
158  this.NumStateDofs= this.dm+this.dsa;
159  this.updateDimensions;
160 
161  /* % Set system components
162  * Core nonlinearity */
163  this.f= models.motorunit.SHDynamics(this);
164 
165  /* Load mean current limiting polynomial */
166  s = load(models.motoneuron.Model.FILE_UPPERLIMITPOLY);
167  this.upperlimit_poly= s.upperlimit_poly;
168 
169  /* Setup noise input */
170  ng = models.motoneuron.NoiseGenerator;
171  this.noiseGen= ng;
172  this.Inputs[1] = @ng.getInput;
173 
174  /* Linear input B for motoneuron */
175  this.B= this.assembleB;
176 
177  /* Affine-Linear output C */
178  this.C= this.assembleC;
179 
180  /* Constant initial values
181  * See also: models.motorunit.experiment.InitialConditions */
182  if model.DynamicInitialConditions
183  this.x0= this.assembleX0;
184  else
185  this.x0= dscomponents.ConstInitialValue(this.getConstInitialStates);
186  end
187 
189  }
201 
202  /* Limit mean current depending on fibre type */
203  mu(2) = min(polyval(this.upperlimit_poly,mu(1)),mu(2));
204 
205  prepareSimulation@models.BaseFirstOrderSystem(this, mu, inputidx);
206  }
221  setConfig@models.BaseFirstOrderSystem(this, mu, inputidx);
222  this.noiseGen.setFibreType(mu(1));
223  this.MaxTimestep= this.Model.dt*100;
224  /* Helper method to reset the "peak counter" of the dynamics. */
225  if this.Model.SinglePeakMode
226  this.peakstart= false;
227  end
228  }
239  function status = singlePeakModeOutputFcn(unused1,matrix<double> y,flag) {
240  if ~strcmp(flag," done ")
241  if y(this.dm+1) > -20 && ~this.peakstart
242  this.peakstart= true;
243  elseif y(this.dm+1) < -20 && this.peakstart
244  this.peakstart= false;
245  this.f.hadpeak= true;
246  end
247  end
248  status = 0;
249  }
250 
251 
252  private: /* ( Transient ) */
253 
254 
255  function x0 = assembleX0() {
256  mc = metaclass(this);
257  s = load(fullfile(fileparts(which(mc.Name))," x0coeff.mat "));
258  x0 = dscomponents.AffineInitialValue;
259  m = size(s.coeff,1);
260  for k=1:m
261  x0.addMatrix(sprintf(" polyval([%s],mu(1)) ",...
262  sprintf(" %g ",s.coeff(k,:))),full(sparse(k,1,1,m,1)));
263  end
264  }
277  function B = assembleB() {
278  B = dscomponents.AffLinInputConv;
279  /* Base noise input mapping */
280  B.addMatrix(" 1./(pi*(exp(log(100)*mu(1,:))*3.55e-05 + 77.5e-4).^2) ",...
281  sparse(2,1,1,this.dm+this.dsa,2));
282  /* Independent noise input mapping with ยต_2 as mean current factor */
283  B.addMatrix(" mu(2,:)./(pi*(exp(log(100)*mu(1,:))*3.55e-05 + 77.5e-4).^2) ",...
284  sparse(2,2,1,this.dm+this.dsa,2));
285  }
297  function C = assembleC() {
298  C = dscomponents.AffLinOutputConv;
299  /* Extract V_s */
300  C.addMatrix(" 1 ",sparse(1,7,1,2,this.dm+this.dsa));
301  /* Add scaling for force output A_s */
302  str = " 1 ";
303  if this.Model.SingleTwitchOutputForceScaling
304  str = [" polyval([ " sprintf(" %g ",this.ForceOutputScalingPolyCoeff) " ],mu(1)) "];
305  end
306  C.addMatrix(str, sparse(2,59,1,2,this.dm+this.dsa));
307  }
316  function x0 = getConstInitialStates() {
317  x0_sarc = zeros(56,1);
318  x0_sarc(1:14) = [-79.974; -80.2; 5.9; 150.9; 5.9; 12.7; 133;...
319  133; 0.009466; 0.9952; 0.0358; 0.4981; 0.581; 0.009466];
320  x0_sarc(15:37) = [0.9952; 0.0358; 0.4981; 0.581; 0; 0; 0; 0; 0; 1;...
321  0; 0; 0; 0; 0.1; 1500; 0.1; 1500; 25; 615; 615; 811; 811];
322  x0_sarc(38:45) = [16900; 16900; 0.4; 0.4; 7200; 7200; 799.6; 799.6];
323  x0_sarc(46:54) = [1000; 1000; 3; 0.8; 1.2; 3; 0.3; 0.23; 0.23];
324  x0_sarc(55:56) = [0.23; 0.23]; /* 0.0; 0.05 */
325 
326  x0 = [zeros(6,1); x0_sarc];
327  }
337 };
338 }
339 }
340 
341 
function prepareSimulation(colvec< double > mu,integer inputidx)
Limits the mean input current to a maximum value depending on the fibre type, so that the frequency o...
Definition: SHSystem.m:200
* polyval(pol, slen)
The base class for any KerMor detailed model.
Definition: BaseFullModel.m:18
static const .double C_m_slow
Membrane capacitance. Different values for different fibre types, due to different action potential p...
Definition: SHSystem.m:72
dscomponents.AInputConv B
The input conversion.
Model
The Model this System is attached to.
SHSystem(models.BaseFullModel model)
Call superclass constructor.
Definition: SHSystem.m:152
An integer value.
inputidx
The current inputindex of the function .
static const dm
Dimension of motoneuron part.
Definition: SHSystem.m:54
static const dsa
Dimension of single sarcomer cell part.
Definition: SHSystem.m:63
dscomponents.AInitialValue x0
Function handle to initial state evaluation.
mu
The current parameter for simulations, [] is none used.
function setConfig(colvec< double > mu,integer inputidx)
Sets the configuration for the upcoming simulation of the model.
Definition: SHSystem.m:220
Inputs
The system's possible input functions. A cell array of function handles, each taking a time argument ...
SHSystem: The global dynamical system used within the Shorten motorunit model.
Definition: SHSystem.m:19
dscomponents.LinearOutputConv C
The output conversion Defaults to an LinearOutputConv instance using a 1-matrix, which just forwards ...
dscomponents.ACoreFun f
The core f function from the dynamical system.
upperlimit_poly
The upper limit polynomial for maximum mean current dependent on the fibre type.
Definition: SHSystem.m:123
function status = singlePeakModeOutputFcn(unused1,matrix< double > y, flag)
Definition: SHSystem.m:239
static const .rowvec< double > ForceOutputScalingPolyCoeff
Coefficients of the polynomial used for force output scaling.
Definition: SHSystem.m:88
noiseGen
The NoiseGenerator to obtain the inputs u(t)
Definition: SHSystem.m:110
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.
static const C_m_fast
Definition: SHSystem.m:85