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
SHDynamics.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 
20  :public dscomponents.ACoreFun {
37  public:
38 
77  public:
78 
118  .-dependent SarcoConst_dynpos;
131  private:
132 
133  spm;
134 
135 
136  public: /* ( Transient ) */
137 
138  hadpeak = false;
139 
141 
143 
145 
146 
147  public: /* ( Transient ) */
148 
149  SHDynamics(sys) {
150  this = this@dscomponents.ACoreFun(sys);
151 
152  this.initSarcoConst;
154  this.fDim= sys.dsa + sys.dm;
155  this.xDim= this.fDim;
156  this.spm= sys.Model.SinglePeakMode;
157  }
158 
159 
161  prepareSimulation@dscomponents.ACoreFun(this, mu);
162 
163  /* Precompute motoneuron/sarcomere constants */
164  this.motoconst= this.getMotoConst(mu(1));
165  this.sarcoconst= this.getSarcoConst(mu(1));
166 
167  this.hadpeak= false;
168  }
169 
170 
172 
173  dm = this.System.dm;
174 
175  /* % Inner dynamics (with partial nonlinear linking) */
176  dy = zeros(size(y));
177 
178  /* % Neuro dynamics (last 2 arguments are 2 phases: phase_prim, phase_sec) */
179  c = this.motoconst;
180  /* dendrites */
181  dy(1) = (-c(1)*(y(1)-c(11))-c(5)*(y(1)-y(2)))/c(7);
182  /* soma */
183  dy(2) = (-c(6)*(y(2)-c(11))-c(5)*(y(2)-y(1))...
184  -c(4)*y(3).^3*y(4)*(y(2)-c(9))...
185  -c(2)*y(5).^4*(y(2)-c(10))...
186  -c(3)*y(6).^2*(y(2)-c(10)))/c(8);
187  /* the four gating variables */
188  dy(3) = 0.32*(13-y(2))/(exp((13-y(2))/5)-1)*(1-y(3))...
189  -0.28*(y(2)-40)/(exp((y(2)-40)/5)-1)*(y(3));
190  dy(4) = 0.128*(exp((17-y(2))/18))*(1-y(4))-4/(exp((40-y(2))/5)+1)*(y(4));
191  dy(5) = 0.032*(15-y(2))/(exp((15-y(2))/5)-1)*(1-y(5))...
192  -0.5*(exp((10-y(2))/40))*(y(5));
193  dy(6) = 3.5/(exp((55-y(2))/4)+1)*(1-y(6))-0.025*(y(6));
194 
195  /* % Sarcomere dynamics */
196  dy(dm+1:end) = this.dydt_sarcomere(y(dm+1:end),t);
197 
198  /* % Link of motoneuron to sarcomer cell */
199  if this.spm && this.hadpeak
200  signal = 0;
201  else
202  fac = this.MSLink_MaxFactor;
203  if y(2) < this.MSLink_MaxFactorSignal
204  fac = this.getLinkFactor(y(2));
205  end
206  /* "Link" at the only sarcomere */
207  signal = fac*y(2)/this.sarcoconst(1);
208  end
209 
210  dy(dm+1,:) = dy(dm+1,:) + signal;
211  }
230  error(" evaluate is overridden directly. ");
231  }
232 
233 
235 
236  s = this.System;
237  dm = s.dm;
238  dsa = s.dsa;
239  bs = dm + dsa;
240  J = spalloc(bs,bs,45+303); /* 45: 40 entries in motoneuron and spindle part + reserve, 303: entries per single sarcomere */
241 
242 
243  /* % Neuron jacobian */
244  c = this.motoconst;
245  JN = zeros(6,6);
246  JN(1,1) = -(c(1) + c(5))/c(7);
247  JN(2,1) = c(5)/c(8);
248  JN(1,2) = c(5)/c(7);
249  JN(2,2) = -(c(4)*y(4)*y(3)^3 + c(2)*y(5)^4 + c(3)*y(6)^2 + c(5) + c(6))/c(8);
250  JN(3,2) = (8*(y(3) - 1))/(25*(exp(13/5 - y(2)/5) - 1)) - (7*y(3))/(25*(exp(y(2)/5 - 8) - 1)) + (y(3)*exp(y(2)/5 - 8)*((7*y(2))/25 - 56/5))/(5*(exp(y(2)/5 - 8) - 1)^2) + (exp(13/5 - y(2)/5)*((8*y(2))/25 - 104/25)*(y(3) - 1))/(5*(exp(13/5 - y(2)/5) - 1)^2);
251  JN(4,2) = (8*exp(17/18 - y(2)/18)*(y(4) - 1))/1125 - (4*y(4)*exp(8 - y(2)/5))/(5*(exp(8 - y(2)/5) + 1)^2);
252  JN(5,2) = (y(5)*exp(1/4 - y(2)/40))/80 + (4*(y(5) - 1))/(125*(exp(3 - y(2)/5) - 1)) + (exp(3 - y(2)/5)*((4*y(2))/125 - 12/25)*(y(5) - 1))/(5*(exp(3 - y(2)/5) - 1)^2);
253  JN(6,2) = -(7*exp(55/4 - y(2)/4)*(y(6) - 1))/(8*(exp(55/4 - y(2)/4) + 1)^2);
254  JN(2,3) = (3*c(4)*y(3)^2*y(4)*(c(9) - y(2)))/c(8);
255  JN(3,3) = ((8*y(2))/25 - 104/25)/(exp(13/5 - y(2)/5) - 1) - ((7*y(2))/25 - 56/5)/(exp(y(2)/5 - 8) - 1);
256  JN(2,4) = (c(4)*y(3)^3*(c(9) - y(2)))/c(8);
257  JN(4,4) = - (16*exp(17/18 - y(2)/18))/125 - 4/(exp(8 - y(2)/5) + 1);
258  JN(2,5) = (4*c(2)*y(5)^3*(c(10) - y(2)))/c(8);
259  JN(5,5) = ((4*y(2))/125 - 12/25)/(exp(3 - y(2)/5) - 1) - exp(1/4 - y(2)/40)/2;
260  JN(2,6) = (2*c(3)*y(6)*(c(10) - y(2)))/c(8);
261  JN(6,6) = - 7/(2*(exp(55/4 - y(2)/4) + 1)) - 1/40;
262  J(1:6,1:6) = JN;
263 
264  /* % Sarcomere jacobian */
265  J(dm+1:bs,dm+1:bs) = this.Jac_Sarco(y(dm+1:end), t);
266  fac = this.MSLink_MaxFactor;
267  if (y(2) < this.MSLink_MaxFactorSignal)
268  fac = this.getLinkFactor(y(2));
269  end
270  /* link position is dm+1 */
271  J(dm+1,2) = fac/this.sarcoconst(1);
272  }
284  function copy = clone() {
285  copy = models.motorunit.Dynamics(this.System);
286 
287  /* Call superclass clone (for deep copy) */
288  copy = clone@dscomponents.ACompEvalCoreFun(this, copy);
289 
290  /* Copy local properties
291  * No local properties are to be copied here, as so far
292  * everything is done in the constructor. */
293  }
301  function initJSparsityPattern() {
302  s = this.System;
303  dm = s.dm; dsa = s.dsa;
304  size = dm + dsa;
305  J = sparse(size,size);
306 
307  /* Neuro */
308  i = [1,1,2,2,2,2,2,2,3,3,4,4,5,5,6,6];
309  j = [1,2,1,2,3,4,5,6,2,3,2,4,2,5,2,6];
310  J(1:dm,1:dm) = sparse(i,j,true,6,6);
311 
312  /* Sarco */
313  mc = metaclass(this);
314  s = load(fullfile(fileparts(which(mc.Name))," JSparsityPattern "));
315  J(dm+1:size,dm+1:size) = s.JP;
316 
317  linkpos = dm+1;
318  J(linkpos,2) = true;
319  this.JSparsityPattern= logical(J);
320  }
327  function f = getLinkFactor(rowvec<double> y) {
328  f = this.MSLink_MinFactor + exp(-(y-this.MSLink_MaxFactorSignal).^2/150)...
329  *(this.MSLink_MaxFactor-this.MSLink_MinFactor);
330  }
343  private: /* ( Transient ) */
344 
345  function sc = getSarcoConst(mu_fibretype) {
346  sc = this.SarcoConst_base;
347  sc(this.SarcoConst_dynpos) = (1-mu_fibretype(1))*this.SarcoConst_slow + mu_fibretype(1)*this.SarcoConst_fast;
348  }
357  function c = getMotoConst(mu_fibretype) {
358 
359  /* Membrane capacitance (NOT to be confused with Cm of the
360  * sarcomere model!) */
361  Cm=1;
362 
363  Ri=70/1000;
364  c = zeros(11,length(mu_fibretype));
365  /* cf. Cisi and Kohn 2008, Table 2, page 7 */
366  Rmd = 14.4+6.05-coolExp(6.05,14.4,mu_fibretype);
367  Rms=1.15+0.65-coolExp(0.65,1.15,mu_fibretype);
368 
369  ld=coolExp(0.55,1.06,mu_fibretype);
370  ls=coolExp(77.5e-6*100,113e-6*100,mu_fibretype);
371 
372  rd=coolExp(41.5e-6*100,92.5e-6*100,mu_fibretype)/2;
373  rs=coolExp(77.5e-6*100,113e-6*100,mu_fibretype)/2;
374 
375  c(1,:) = 2*pi*rd.*ld./Rmd; /* para.Gld */
376 
377  c(2,:) = 4*2*pi*rs.*ls; /* para.Gkf */
378 
379  c(3,:) = 16*2*pi*rs.*ls; /* para.Gks */
380 
381  c(4,:) = 30*2*pi*rs.*ls; /* para.Gna */
382 
383  c(5,:) = 2./(Ri*ld./(pi*rd.^2)+Ri*ls./(pi*rs.^2)); /* para.Gc */
384 
385  c(6,:) = 2*pi*rs.*ls./Rms; /* para.Gls */
386 
387  c(7,:) = 2*pi*rd.*ld*Cm; /* para.Cd */
388 
389  c(8,:) = 2*pi*rs.*ls*Cm; /* para.Cs */
390 
391  s = ones(size(mu_fibretype));
392  c(9,:) = 120*s; /* para.Vna */
393 
394  c(10,:) = -10*s; /* para.Vk */
395 
396  c(11,:) = 0*s; /* para.Vl */
397 
398 
399  function v = coolExp(a,b,mu)
400  v = exp(log(100)*mu)*(b-a)/100 + a;
401  end
402  }
414  function dy = dydt_sarcomere(matrix<double> y,rowvec<double> t);
415 
416  function initSarcoConst();
417 
418  function J = Jac_Sarco(matrix<double> y,rowvec<double> t);
419 
420 };
421 }
422 }
423 
424 
integer fDim
The current output dimension of the function.
Definition: ACoreFun.m:171
SarcoConst_base
basis constant set for sarcomere submodel
Definition: SHDynamics.m:105
function prepareSimulation(colvec< double > mu)
Definition: SHDynamics.m:160
double MSLink_MinFactor
The minimal factor at which the value of the motoneuron should be amplified when added to the sarcom...
Definition: SHDynamics.m:60
double MSLink_MaxFactorSignal
The value of the motoneuron input at which the MSLink_MaxFactor should be attained.
Definition: SHDynamics.m:39
A double value.
dependent SarcoConst_dynpos
Positions constants.
Definition: SHDynamics.m:118
SarcoConst_slow
constants for sarcomere submodel specific for slow twitch fibre
Definition: SHDynamics.m:79
function copy = clone()
Create new instance.
Definition: SHDynamics.m:284
double MSLink_MaxFactor
The maximal factor with which the value of the motoneuron should be amplified when added to the sarc...
Definition: SHDynamics.m:49
A boolean value.
Basic interface for all dynamical system's core functions Inherits the AProjectable interface...
Definition: ACoreFun.m:18
function J = getStateJacobian(matrix< double >, y,rowvec< double > t)
Evaluates the full Jacobian of the nonlinear core function.
Definition: SHDynamics.m:234
integer xDim
The current state space dimension of the function's argument .
Definition: ACoreFun.m:151
models.BaseFirstOrderSystem System
The system associated with the current ACoreFun.
Definition: ACoreFun.m:193
colvec< double > mu
The current model parameter mu for evaluations. Will not be persisted as only valid for runtime durin...
Definition: ACoreFun.m:208
function dy = evaluate(matrix< double >, y,rowvec< double > t)
Evaluates the nonlinear core function at given time and state. Can evaluate vectorized arguments...
Definition: SHDynamics.m:171
sparse< logical > JSparsityPattern
Sparsity pattern for the jacobian matrix.
Definition: ACoreFun.m:127
function dy = evaluateCoreFun(matrix< double > y,double t,colvec< double > mu)
Definition: SHDynamics.m:229
SarcoConst_fast
constants for sarcomere submodel specific for fast twitch fibre
Definition: SHDynamics.m:92
SHDynamics: Class for nonlinear dynamics of shorten motorunit model.
Definition: SHDynamics.m:19
function initJSparsityPattern()
Initializes the Sparsity pattern of the Jacobian.
Definition: SHDynamics.m:301
function f = getLinkFactor(rowvec< double > y)
scalar link factor motoneuron to middle sarcomere
Definition: SHDynamics.m:327