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
Dynamics.m
Go to the documentation of this file.
1 namespace models{
2 namespace motoneuron{
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 Dynamics
20  :public dscomponents.ACoreFun {
37  private:
38 
39  mc;
47  public:
48 
49  Dynamics(sys) {
50  this = this@dscomponents.ACoreFun(sys);
52  this.fDim= 6;
53  this.xDim= this.fDim;
54  }
55 
56 
58  if this.System.Model.FibreTypeDepMaxMeanCurrent
59  mu(2) = min(polyval(this.System.upperlimit_poly,mu(1)),mu(2));
60  end
61  prepareSimulation@dscomponents.ACoreFun(this, mu);
62  this.mc= this.getMotoConst(mu(1));
63  }
64 
65 
66  function dy = evaluate(matrix<double>, y,unused1,unused2) {
67 
68  c = this.mc;
69 
70  dy = zeros(size(y));
71 
72  /* dendrites */
73  dy(1,:) = (-c(1,:).*(y(1,:)-c(11,:))-c(5,:).*(y(1,:)-y(2,:)))./c(7,:);
74 
75  /* soma */
76  dy(2,:) = (-c(6,:).*(y(2,:)-c(11,:))-c(5,:).*(y(2,:)-y(1,:))...
77  -c(4,:).*y(3,:).^3.*y(4,:).*(y(2,:)-c(9,:))...
78  -c(2,:).*y(5,:).^4.*(y(2,:)-c(10,:))...
79  -c(3,:).*y(6,:).^2.*(y(2,:)-c(10,:)))./c(8,:);
80 
81  /* the four gating variables */
82  dy(3,:) = 0.32*(13-y(2,:))./(exp((13-y(2,:))/5)-1).*(1-y(3,:))...
83  -0.28*(y(2,:)-40)./(exp((y(2,:)-40)/5)-1).*(y(3,:));
84  dy(4,:) = 0.128*(exp((17-y(2,:))/18)).*(1-y(4,:))-4./(exp((40-y(2,:))/5)+1).*(y(4,:));
85  dy(5,:) = 0.032*(15-y(2,:))./(exp((15-y(2,:))/5)-1).*(1-y(5,:))...
86  -0.5*(exp((10-y(2,:))/40)).*(y(5,:));
87  dy(6,:) = 3.5./(exp((55-y(2,:))/4)+1).*(1-y(6,:))-0.025*(y(6,:));
88  }
109  error(" evaluate is overridden directly. ");
110  }
111 
112 
113  function J = getStateJacobian(matrix<double>, y,unused1,unused2) {
114 
115  c = this.mc;
116  J = sparse(6, 6);
117 
118  J(1,1:6:end) = -(c(1,:) + c(5,:))./c(7,:);
119  J(2,1:6:end) = c(5,:)./c(8,:);
120  J(1,2:6:end) = c(5,:)./c(7,:);
121  J(2,2:6:end) = -(c(4,:).*y(4,:).*y(3,:)^3 + c(2,:).*y(5,:)^4 + c(3,:).*y(6,:)^2 + c(5,:) + c(6,:))./c(8,:);
122  J(3,2:6:end) = (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);
123  J(4,2:6:end) = (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);
124  J(5,2:6:end) = (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);
125  J(6,2:6:end) = -(7.*exp(55./4 - y(2,:)./4).*(y(6,:) - 1))./(8.*(exp(55./4 - y(2,:)./4) + 1)^2);
126  J(2,3:6:end) = (3.*c(4,:).*y(3,:)^2.*y(4,:).*(c(9,:) - y(2,:)))./c(8,:);
127  J(3,3:6:end) = ((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);
128  J(2,4:6:end) = (c(4,:).*y(3,:)^3.*(c(9,:) - y(2,:)))./c(8,:);
129  J(4,4:6:end) = - (16.*exp(17./18 - y(2,:)./18))./125 - 4./(exp(8 - y(2,:)./5) + 1);
130  J(2,5:6:end) = (4.*c(2,:).*y(5,:)^3.*(c(10,:) - y(2,:)))./c(8,:);
131  J(5,5:6:end) = ((4.*y(2,:))./125 - 12./25)./(exp(3 - y(2,:)./5) - 1) - exp(1./4 - y(2,:)./40)./2;
132  J(2,6:6:end) = (2.*c(3,:).*y(6,:).*(c(10,:) - y(2,:)))./c(8,:);
133  J(6,6:6:end) = - 7./(2.*(exp(55./4 - y(2,:)./4) + 1)) - 1./40;
134  }
149  function copy = clone() {
150  copy = models.motoneuron.Dynamics(this.System);
151 
152  /* Call superclass clone (for deep copy) */
153  copy = clone@dscomponents.ACoreFun(this, copy);
154 
155  /* Copy local properties */
156  copy.mc= this.mc;
157  }
167  function initJSparsityPattern() {
168  i = [1,1,2,2,2,2,2,2,3,3,4,4,5,5,6,6];
169  j = [1,2,1,2,3,4,5,6,2,3,2,4,2,5,2,6];
170  this.JSparsityPattern= logical(sparse(i,j,true,6,6));
171  }
178  private:
179 
180  function c = getMotoConst(moto_mu) {
181 
182 
183  Cm=1;
184  Ri=70/1000;
185  c = zeros(11,length(moto_mu));
186  Rmd = 14.4+6.05-coolExp(6.05,14.4,moto_mu); /* cf. Cisi and Kohn 2008, Table 2, page 7 */
187 
188  Rms=1.15+0.65-coolExp(0.65,1.15,moto_mu);
189 
190  ld=coolExp(0.55,1.06,moto_mu);
191  ls=coolExp(77.5e-6*100,113e-6*100,moto_mu);
192 
193  rd=coolExp(41.5e-6*100,92.5e-6*100,moto_mu)/2;
194  rs=coolExp(77.5e-6*100,113e-6*100,moto_mu)/2;
195 
196  c(1,:) = 2*pi*rd.*ld./Rmd; /* para.Gld */
197 
198  c(2,:) = 4*2*pi*rs.*ls; /* para.Gkf */
199 
200  c(3,:) = 16*2*pi*rs.*ls; /* para.Gks */
201 
202  c(4,:) = 30*2*pi*rs.*ls; /* para.Gna */
203 
204  c(5,:) = 2./(Ri*ld./(pi*rd.^2)+Ri*ls./(pi*rs.^2)); /* para.Gc */
205 
206  c(6,:) = 2*pi*rs.*ls./Rms; /* para.Gls */
207 
208  c(7,:) = 2*pi*rd.*ld*Cm; /* para.Cd */
209 
210  c(8,:) = 2*pi*rs.*ls*Cm; /* para.Cs */
211 
212  s = ones(size(moto_mu));
213  c(9,:) = 120*s; /* para.Vna */
214 
215  c(10,:) = -10*s; /* para.Vk */
216 
217  c(11,:) = 0*s; /* para.Vl */
218 
219 
220  function v = coolExp(a,b,mu)
221  v = exp(log(100)*mu)*(b-a)/100 + a;
222  end
223  }
234 };
235 }
236 }
237 
238 
integer fDim
The current output dimension of the function.
Definition: ACoreFun.m:171
* polyval(pol, slen)
function dy = evaluateCoreFun(matrix< double > y,double t,colvec< double > mu)
Definition: Dynamics.m:108
Model
The Model this System is attached to.
function dy = evaluate(matrix< double >, y, unused1, unused2)
Evaluates the nonlinear core function at given time and state. Can evaluate vectorized arguments...
Definition: Dynamics.m:66
A boolean value.
Basic interface for all dynamical system's core functions Inherits the AProjectable interface...
Definition: ACoreFun.m:18
integer xDim
The current state space dimension of the function's argument .
Definition: ACoreFun.m:151
colvec< double > mu
The current model parameter mu for evaluations. Will not be persisted as only valid for runtime durin...
Definition: ACoreFun.m:208
MotoSystem: The global dynamical system used within the MotoModel.
Definition: System.m:19
function initJSparsityPattern()
Initializes the Sparsity pattern of the Jacobian.
Definition: Dynamics.m:167
FibreDynamics: Class for nonlinear dynamics of muscle fibre compound.
Definition: Dynamics.m:19
sparse< logical > JSparsityPattern
Sparsity pattern for the jacobian matrix.
Definition: ACoreFun.m:127
function J = getStateJacobian(matrix< double >, y, unused1, unused2)
Evaluates the full Jacobian of the nonlinear core function. Vectorized evaluation is not tested yet...
Definition: Dynamics.m:113
upperlimit_poly
The upper limit polynomial for maximum mean current dependent on the fibre type.
Definition: System.m:92
function prepareSimulation(colvec< double > mu)
Definition: Dynamics.m:57
function copy = clone()
Create new instance.
Definition: Dynamics.m:149