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
Shorten.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 Shorten
20  :public models.BaseFullModel {
47  public: /* ( Dependent ) */
48 
50 
51 
52  public:
53 
107  public:
108 
109  Shorten(dynamic_ic,logical singlepeakmode,outputscaling) {
110 
111  if nargin < 3
112  outputscaling = true;
113  if nargin < 2
114  singlepeakmode = false;
115  if nargin < 1
116  dynamic_ic = true;
117  end
118  end
119  end
120  this.SinglePeakMode= singlepeakmode;
121  this.DynamicInitialConditions= dynamic_ic;
122  this.SingleTwitchOutputForceScaling= outputscaling;
123 
124  this.dt= .1;
125  if singlepeakmode
126  this.T= 2000; /* [ms] */
127 
128  else
129  this.T= 150; /* [ms] */
130 
131  end
132  /* DO NOT INCREASE! Peaks from Motoneuron are not correctly
133  * resolved (at least visually) if larger timesteps are used. */
134  this.dt= .1; /* [ms] */
135 
136 
137  this.SaveTag= sprintf(" motorunit_shorten_sp%d_dynic%d ",singlepeakmode,dynamic_ic);
138  this.Data= data.ModelData(this);
140 
141  this.Name= sprintf(" Motor unit model: Single peak mode: %d, Dynamic Initial Conditions: %d ",singlepeakmode,dynamic_ic);
142  this.System= models.motorunit.SHSystem(this);
143  this.TrainingInputs= 1;
144  this.EnableTrajectoryCaching= true;
145 
146  s = solvers.MLWrapper(@ode15s);
147  if singlepeakmode
148  sys = this.System;
149  s.odeopts.OutputFcn= @sys.singlePeakModeOutputFcn;
150  end
151  this.ODESolver= s;
152 
153  /* Set parameter domain already */
154  s = sampling.RandomSampler;
155  s.Domain= models.motoneuron.ParamDomain;
156  this.Sampler= s;
157 
158  this.DefaultMu= [.1; 3];
159  this.DefaultInput= 1;
160  }
169 /* mtoc++ warning: Optional parameter 'outputscaling' of method 'Shorten' has no specified default value
170  */
172  x = 0:.1:80;
173  pm = PlotManager;
174  pm.LeaveOpen= true;
175  h = pm.nextPlot(" moto_sarco_link_factor "," Factor for motoneuro to sarcomere link "," Moto V_s "," Factor ");
176  f = this.System.f;
177  fx = f.MSLink_MaxFactor*ones(1,length(x));
178  dynfac = x < f.MSLink_MaxFactorSignal;
179  fx(dynfac) = f.getLinkFactor(x(dynfac));
180  plot(h,x,fx);
181  pm.done;
182  }
183 
184 
186  if nargin < 2
187  x = 0:.01:1;
188  end
189  plot(x,polyval(this.System.ForceOutputScalingPolyCoeff,x));
190  title(" Force scaling curve for different fibre types ");
191  xlabel(" Fibre type parameter ");
192  ylabel(" Peak force for single excitation ");
193  }
194 
195 
196  function pm = plotState(double t,colvec<double> x,pm) {
197  if nargin < 4
198  pm = PlotManager(false,3,1);
199  pm.LeaveOpen= true;
200  end
201  h = pm.nextPlot(" moto "," Motoneuron V_s "," time "," value ");
202  plot(h,t,x(2,:));
203  h = pm.nextPlot(" sarco "," Linked sarcomere: V_s "," time "," V_s ");
204  plot(h,t,x(this.System.dm+1,:));
205  h = pm.nextPlot(" sarco ",sprintf(" Linked sarcomere: A_2\nMu=[%s] ",num2str(this.System.mu" )), "time" , "A_2^t);
206  plot(h,t,x(this.System.dm+53,:));
207 
208  if nargin < 4
209  pm.done;
210  end
211  }
212 
213 
214  function pm = plot(double t,matrix<double> y,pm) {
215  if nargin < 4
216  pm = PlotManager(false,2,1);
217  pm.LeaveOpen= true;
218  end
219  h = pm.nextPlot(" sarco "," Linked sarcomere: V_s "," time "," V_s ");
220  plot(h,t,y(1,:));
221  h = pm.nextPlot(" sarco ",sprintf(" Linked sarcomere: A_2\nMu=[%s] ",num2str(this.System.mu" )), "time" , "A_2^t);
222  plot(h,t,y(2,:));
223 
224  if nargin < 4
225  pm.done;
226  end
227  }
228 
229 
230  public:
231 
232 
233 #if 0 //mtoc++: 'get.UseNoise'
234 function value = UseNoise() {
235  value = ~this.System.noiseGen.DisableNoise;
236  }
237 
238 #endif
239 
240 
241 
242 #if 0 //mtoc++: 'set.UseNoise'
243 function UseNoise(value) {
244  this.System.noiseGen.DisableNoise= ~value;
245  }
246 
247 #endif
248 
249 
250  public: /* ( Static ) */
251 
252  static function res = test_Shorten() {
253  m = models.motorunit.Shorten;
254  [t,y] = m.simulate;
255  m.plot(t,y);
256  res = 1;
257  }
258 
259 
260  protected: /* ( Static ) */
261 
262  static function this = loadobj() {
263  if ~isa(this, " models.motorunit.Shorten ")
264  sobj = this;
265  this = models.motorunit.Shorten;
266  this = loadobj@models.BaseFullModel(this, sobj);
267  else
268  this = loadobj@models.BaseFullModel(this);
269  end
270  }
271 
277 };
278 }
279 }
280 
char Name
The name of the Model.
Definition: BaseModel.m:117
Shorten(dynamic_ic,logical singlepeakmode, outputscaling)
Creates a new motor unit model.
Definition: Shorten.m:109
function useFileTrajectoryData(logical overwrite)
Sets the TrajectoryData and TrajectoryFxiData classes to filesystem based versions.
Definition: ModelData.m:349
* polyval(pol, slen)
The base class for any KerMor detailed model.
Definition: BaseFullModel.m:18
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 pm = plotState(double t,colvec< double > x, pm)
Definition: Shorten.m:196
Shorten: Model for a muscle motor unit composed of motoneuron and a sarcomere.
Definition: Shorten.m:19
logical SingleTwitchOutputForceScaling
Flag to determine if the output force (e.g. calcium concentration) should be re-scaled so that the fo...
Definition: Shorten.m:89
PlotManager: Small class that allows the same plots generated by some script to be either organized a...
Definition: PlotManager.m:17
function pm = plot(double t,matrix< double > y, pm)
Definition: Shorten.m:214
static function this = loadobj()
Definition: Shorten.m:262
A boolean value.
logical LeaveOpen
Flag indicating if the plots should be left open once the PlotManager is deleted (as variable) ...
Definition: PlotManager.m:213
solvers.BaseSolver ODESolver
The solver to use for the ODE. Must be an instance of any solvers.BaseSolver subclass.
Definition: BaseModel.m:315
mu
The current parameter for simulations, [] is none used.
integer DefaultInput
The default input to use if none is given.
Definition: BaseModel.m:189
function pm = plotMotoSacroLinkFactorCurve()
Definition: Shorten.m:171
static function res = test_Shorten()
Definition: Shorten.m:252
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.
ModelData(varargin)
Creates a new container for large full model data.
Definition: ModelData.m:180
logical DynamicInitialConditions
Set this flag to true (in constructor) if you want parameter-dependent initial conditions that have b...
Definition: Shorten.m:68
colvec< double > DefaultMu
The default parameter value if none is given.
Definition: BaseModel.m:355
logical EnableTrajectoryCaching
Flag that enables caching of computed trajectories in a simulation cache stored in KerMor's TempDirec...
dscomponents.ACoreFun f
The core f function from the dynamical system.
function plotOutputForceScaling(colvec< double > x)
Definition: Shorten.m:185
logical SinglePeakMode
Flag that determines if this system is to be run so that only ever one peak/signal will be issued...
Definition: Shorten.m:54
char SaveTag
A custom tag that can be used as a prefix to files for corresponding model identification.