MOOSE - Multiscale Object Oriented Simulation Environment
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
CaConcBase.cpp
Go to the documentation of this file.
1 /**********************************************************************
2  ** This program is part of 'MOOSE', the
3  ** Messaging Object Oriented Simulation Environment.
4  ** Copyright (C) 2003-2014 Upinder S. Bhalla. and NCBS
5  ** It is made available under the terms of the
6  ** GNU Lesser General Public License version 2.1
7  ** See the file COPYING.LIB for the full notice.
8  **********************************************************************/
9 
10 // #include <cfloat>
11 #include "header.h"
12 #include "ElementValueFinfo.h"
13 #include "CaConcBase.h"
14 
16 // MsgSrc definitions
18 /*
19  * This Finfo is used to send out Ca concentration to channels.
20  *
21  * It is exposed here so that HSolve can also use it to send out
22  * Ca concentration to the recipients.
23  */
24 // Static function.
26  static SrcFinfo1< double > concOut( "concOut",
27  "Concentration of Ca in pool" );
28  return &concOut;
29 }
30 
32 {
34  // Shared message definitions
36  static DestFinfo process( "process",
37  "Handles process call",
39  static DestFinfo reinit( "reinit",
40  "Handles reinit call",
42 
43  static Finfo* processShared[] =
44  {
45  &process, &reinit
46  };
47 
48  static SharedFinfo proc( "proc",
49  "Shared message to receive Process message from scheduler",
50  processShared, sizeof( processShared ) / sizeof( Finfo* ) );
51 
53  // Field definitions
56  "Calcium concentration.",
59  );
60  static ElementValueFinfo< CaConcBase, double > CaBasal( "CaBasal",
61  "Basal Calcium concentration.",
64  );
65  static ElementValueFinfo< CaConcBase, double > Ca_base( "Ca_base",
66  "Basal Calcium concentration, synonym for CaBasal",
69  );
71  "Settling time for Ca concentration",
74  );
76  "Volume scaling factor. "
77  "Deprecated. This is a legacy field from GENESIS and exposes "
78  "internal calculations. Please do not use. \n"
79  "B = 1/(vol * F) so that it obeys:\n"
80  "dC/dt = B*I_Ca - C/tau",
83  );
84  static ElementValueFinfo< CaConcBase, double > thick( "thick",
85  "Thickness of Ca shell, assumed cylindrical. Legal range is between 0 \n"
86  "and the radius. If outside this range it is taken as the radius. \n"
87  " Default zero, ie, the shell is the entire thickness of the cylinder \n",
90  );
91  static ElementValueFinfo< CaConcBase, double > length( "length",
92  "Length of Ca shell, assumed cylindrical",
95  );
96  static ElementValueFinfo< CaConcBase, double > diameter( "diameter",
97  "Diameter of Ca shell, assumed cylindrical",
100  );
101  static ElementValueFinfo< CaConcBase, double > ceiling( "ceiling",
102  "Ceiling value for Ca concentration. If Ca > ceiling, Ca = ceiling. \n"
103  "If ceiling <= 0.0, there is no upper limit on Ca concentration value.",
106  );
107  static ElementValueFinfo< CaConcBase, double > floor( "floor",
108  "Floor value for Ca concentration. If Ca < floor, Ca = floor",
111  );
112 
114  // MsgDest definitions
116 
117  static DestFinfo current( "current",
118  "Calcium Ion current, due to be converted to conc.",
120  );
121 
122  static DestFinfo currentFraction( "currentFraction",
123  "Fraction of total Ion current, that is carried by Ca2+.",
125  );
126 
127  static DestFinfo increase( "increase",
128  "Any input current that increases the concentration.",
130  );
131 
132  static DestFinfo decrease( "decrease",
133  "Any input current that decreases the concentration.",
135  );
136 
137  static DestFinfo basal( "basal",
138  "Synonym for assignment of basal conc.",
140  );
141 
142  static Finfo* CaConcBaseFinfos[] =
143  {
144  &proc, // Shared
145  concOut(), // Src
146  &Ca, // Value
147  &CaBasal, // Value
148  &Ca_base, // Value
149  &tau, // Value
150  &B, // Value
151  &thick, // Value
152  &diameter, // Value
153  &length, // Value
154  &ceiling, // Value
155  &floor, // Value
156  &current, // Dest
157  &currentFraction, // Dest
158  &increase, // Dest
159  &decrease, // Dest
160  &basal, // Dest
161  };
162 
163  // We want the Ca updates before channel updates, so along with compts.
164  // static SchedInfo schedInfo[] = { { process, 0, 0 } };
165 
166  static string doc[] =
167  {
168  "Name", "CaConcBase",
169  "Author", "Upinder S. Bhalla, 2014, NCBS",
170  "Description",
171  "CaConcBase: Base class for Calcium concentration pool. \n"
172  "Takes current from a channel and keeps track of calcium buildup and \n"
173  " depletion by a single exponential process. ",
174  };
175 
176  static ZeroSizeDinfo< int > dinfo;
177 
178  static Cinfo CaConcBaseCinfo(
179  "CaConcBase",
181  CaConcBaseFinfos,
182  sizeof( CaConcBaseFinfos )/sizeof(Finfo *),
183  &dinfo,
184  doc,
185  sizeof(doc)/sizeof(string)
186  );
187 
188  return &CaConcBaseCinfo;
189 }
191 
193 
195  :
196  thickness_( 0.0 )
197 {;}
198 
200 // Field function definitions
202 
203 void CaConcBase::setCa( const Eref& e, double Ca )
204 {
205  vSetCa( e, Ca );
206 }
207 double CaConcBase::getCa( const Eref& e ) const
208 {
209  return vGetCa( e );
210 }
211 
212 void CaConcBase::setCaBasal( const Eref& e, double CaBasal )
213 {
214  vSetCaBasal( e, CaBasal );
215 }
216 double CaConcBase::getCaBasal( const Eref& e ) const
217 {
218  return vGetCaBasal( e );
219 }
220 
221 void CaConcBase::setTau( const Eref& e, double tau )
222 {
223  vSetTau( e, tau );
224 }
225 double CaConcBase::getTau( const Eref& e ) const
226 {
227  return vGetTau( e );
228 }
229 
230 void CaConcBase::setB( const Eref& e, double B )
231 {
232  vSetB( e, B );
233 }
234 double CaConcBase::getB( const Eref& e ) const
235 {
236  return vGetB( e );
237 }
238 void CaConcBase::setCeiling( const Eref& e, double ceiling )
239 {
240  vSetCeiling( e, ceiling );
241 }
242 double CaConcBase::getCeiling( const Eref& e ) const
243 {
244  return vGetCeiling( e );
245 }
246 
247 void CaConcBase::setFloor( const Eref& e, double floor )
248 {
249  vSetFloor( e, floor );
250 }
251 double CaConcBase::getFloor( const Eref& e ) const
252 {
253  return vGetFloor( e );
254 }
255 
257 {
258  double vol = PI * diameter_ * diameter_ * length_ * 0.25;
259  if ( thickness_ > 0 && thickness_ < diameter_/2.0 ) {
260  double coreRadius = diameter_ / 2.0 - thickness_;
261  vol -= PI * coreRadius * coreRadius * length_;
262  }
263  double B = 1.0 / ( FaradayConst * vol );
264  vSetB( e, B );
265 }
266 
267 void CaConcBase::setThickness( const Eref& e, double thickness )
268 {
269  thickness_ = thickness;
270  updateDimensions( e );
271 }
272 
273 double CaConcBase::getThickness( const Eref& e ) const
274 {
275  return thickness_;
276 }
277 
278 void CaConcBase::setDiameter( const Eref& e, double diameter )
279 {
280  diameter_ = diameter;
281  updateDimensions( e );
282 }
283 
284 double CaConcBase::getDiameter( const Eref& e ) const
285 {
286  return diameter_;
287 }
288 
289 void CaConcBase::setLength( const Eref& e, double length )
290 {
291  length_ = length;
292  updateDimensions( e );
293 }
294 double CaConcBase::getLength( const Eref& e ) const
295 {
296  return length_;
297 }
298 
300 // Dest function definitions
302 
303 void CaConcBase::reinit( const Eref& e, ProcPtr p )
304 {
305  vReinit( e, p );
306 }
307 
308 void CaConcBase::process( const Eref& e, ProcPtr p )
309 {
310  vProcess( e, p );
311 }
312 
313 void CaConcBase::current( const Eref& e, double I )
314 {
315  vCurrent( e, I );
316 }
317 
318 void CaConcBase::currentFraction( const Eref& e, double I, double fraction )
319 {
320  vCurrentFraction( e, I, fraction );
321 }
322 
323 void CaConcBase::increase( const Eref& e, double I )
324 {
325  vIncrease( e, I );
326 }
327 
328 void CaConcBase::decrease( const Eref& e, double I )
329 {
330  vDecrease( e, I );
331 }
332 
334 // Zombify
336 
337 
338 // Dummy instantiation of vSetSolve, does nothing
339 void CaConcBase::vSetSolver( const Eref& e, Id hsolve )
340 {;}
341 
342 // static func
343 void CaConcBase::zombify( Element* orig, const Cinfo* zClass,
344  Id hsolve )
345 {
346  if ( orig->cinfo() == zClass )
347  return;
348  unsigned int start = orig->localDataStart();
349  unsigned int num = orig->numLocalData();
350  if ( num == 0 )
351  return;
352  vector< double > data( num * 9 );
353 
354  unsigned int j = 0;
355  for ( unsigned int i = 0; i < num; ++i ) {
356  Eref er( orig, i + start );
357  const CaConcBase* cb =
358  reinterpret_cast< const CaConcBase* >( er.data() );
359  data[j + 0] = cb->getCa( er );
360  data[j + 1] = cb->getCaBasal( er );
361  data[j + 2] = cb->getTau( er );
362  data[j + 3] = cb->getB( er );
363  data[j + 4] = cb->getCeiling( er );
364  data[j + 5] = cb->getFloor( er );
365  data[j + 6] = cb->getThickness( er );
366  data[j + 7] = cb->getLength( er );
367  data[j + 8] = cb->getDiameter( er );
368  j += 9;
369  }
370  orig->zombieSwap( zClass );
371  j = 0;
372  for ( unsigned int i = 0; i < num; ++i ) {
373  Eref er( orig, i + start );
374  CaConcBase* cb = reinterpret_cast< CaConcBase* >( er.data() );
375  cb->vSetSolver( er, hsolve );
376  cb->setCa( er, data[j + 0] );
377  cb->setCaBasal( er, data[j + 1] );
378  cb->setTau( er, data[j + 2] );
379  cb->setB( er, data[j + 3] );
380  cb->setCeiling( er, data[j + 4] );
381  cb->setFloor( er, data[j + 5] );
382  cb->setThickness( er, data[j + 6] );
383  cb->setLength( er, data[j + 7] );
384  cb->setDiameter( er, data[j + 8] );
385  j += 9; //was 7?
386  }
387 }
void increase(const Eref &e, double I)
Definition: CaConcBase.cpp:323
double diameter_
Definition: CaConcBase.h:123
double getLength(const Eref &e) const
Definition: CaConcBase.cpp:294
char * data() const
Definition: Eref.cpp:41
virtual void vSetFloor(const Eref &e, double val)=0
void setDiameter(const Eref &e, double val)
Definition: CaConcBase.cpp:278
double getCa(const Eref &e) const
Definition: CaConcBase.cpp:207
static const Cinfo * caConcCinfo
Definition: CaConcBase.cpp:192
virtual void vSetCeiling(const Eref &e, double val)=0
double getThickness(const Eref &e) const
Definition: CaConcBase.cpp:273
void currentFraction(const Eref &e, double I, double fraction)
Definition: CaConcBase.cpp:318
virtual void vProcess(const Eref &, ProcPtr info)=0
virtual void vSetSolver(const Eref &e, Id hsolve)
Used to set up the solver. Dummy for regular classes.
Definition: CaConcBase.cpp:339
Definition: EpFunc.h:64
double getTau(const Eref &e) const
Definition: CaConcBase.cpp:225
virtual double vGetCa(const Eref &e) const =0
virtual void vSetCaBasal(const Eref &e, double val)=0
void setTau(const Eref &e, double val)
Definition: CaConcBase.cpp:221
void setCa(const Eref &e, double val)
Definition: CaConcBase.cpp:203
virtual void zombieSwap(const Cinfo *zCinfo)
virtual func, this base version must be called by all derived classes
Definition: Element.cpp:159
const double FaradayConst
Definition: consts.cpp:17
static void zombify(Element *orig, const Cinfo *zClass, Id hsolve)
Definition: CaConcBase.cpp:343
virtual double vGetCaBasal(const Eref &e) const =0
virtual double vGetFloor(const Eref &e) const =0
virtual double vGetB(const Eref &e) const =0
double getDiameter(const Eref &e) const
Definition: CaConcBase.cpp:284
void updateDimensions(const Eref &e)
Definition: CaConcBase.cpp:256
static SrcFinfo1< double > * concOut()
Definition: CaConcBase.cpp:25
virtual double vGetCeiling(const Eref &e) const =0
double getCaBasal(const Eref &e) const
Definition: CaConcBase.cpp:216
double getFloor(const Eref &e) const
Definition: CaConcBase.cpp:251
double thickness_
Definition: CaConcBase.h:122
virtual void vSetCa(const Eref &e, double val)=0
void setCaBasal(const Eref &e, double val)
Definition: CaConcBase.cpp:212
void setFloor(const Eref &e, double val)
Definition: CaConcBase.cpp:247
void setCeiling(const Eref &e, double val)
Definition: CaConcBase.cpp:238
virtual void vSetTau(const Eref &e, double val)=0
virtual void vIncrease(const Eref &e, double I)=0
void setLength(const Eref &e, double val)
Definition: CaConcBase.cpp:289
Definition: Eref.h:26
const Cinfo * cinfo() const
Definition: Element.cpp:66
double length_
Definition: CaConcBase.h:124
virtual void vDecrease(const Eref &e, double I)=0
static const Cinfo * initCinfo()
Definition: CaConcBase.cpp:31
virtual unsigned int localDataStart() const =0
Returns index of first data entry on this node.
virtual unsigned int numLocalData() const =0
Returns number of local data entries on this node.
double getCeiling(const Eref &e) const
Definition: CaConcBase.cpp:242
virtual void vCurrent(const Eref &e, double I)=0
virtual void vCurrentFraction(const Eref &e, double I, double fraction)=0
void current(const Eref &e, double I)
Definition: CaConcBase.cpp:313
void setB(const Eref &e, double val)
Definition: CaConcBase.cpp:230
void reinit(const Eref &, ProcPtr info)
Definition: CaConcBase.cpp:303
virtual double vGetTau(const Eref &e) const =0
double getB(const Eref &e) const
Definition: CaConcBase.cpp:234
const double PI
Definition: consts.cpp:12
Definition: Id.h:17
static const Cinfo * initCinfo()
Definition: Neutral.cpp:16
void setThickness(const Eref &e, double val)
Definition: CaConcBase.cpp:267
virtual void vReinit(const Eref &, ProcPtr info)=0
Definition: Cinfo.h:18
void decrease(const Eref &e, double I)
Definition: CaConcBase.cpp:328
Definition: EpFunc.h:79
virtual void vSetB(const Eref &e, double val)=0
Definition: Finfo.h:12
void process(const Eref &, ProcPtr info)
Definition: CaConcBase.cpp:308