MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
HHChannelBase.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-2007 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 "header.h"
11 #include "ElementValueFinfo.h"
12 #include "HHGate.h"
13 #include "ChanBase.h"
14 #include "HHChannelBase.h"
15 
17 {
19  // Shared messages
21 
23  // Field definitions
25  static ElementValueFinfo< HHChannelBase, double > Xpower( "Xpower",
26  "Power for X gate",
29  );
30  static ElementValueFinfo< HHChannelBase, double > Ypower( "Ypower",
31  "Power for Y gate",
34  );
35  static ElementValueFinfo< HHChannelBase, double > Zpower( "Zpower",
36  "Power for Z gate",
39  );
40  static ElementValueFinfo< HHChannelBase, int > instant( "instant",
41  "Bitmapped flag: bit 0 = Xgate, bit 1 = Ygate, bit 2 = Zgate"
42  "When true, specifies that the lookup table value should be"
43  "used directly as the state of the channel, rather than used"
44  "as a rate term for numerical integration for the state",
47  );
49  "State variable for X gate",
52  );
54  "State variable for Y gate",
57  );
59  "State variable for Y gate",
62  );
63  static ElementValueFinfo< HHChannelBase, int > useConcentration(
64  "useConcentration",
65  "Flag: when true, use concentration message rather than Vm to"
66  "control Z gate",
69  );
70 
72 // MsgSrc definitions
74  // IkOut SrcFinfo defined in base classes.
75 
77 // MsgDest definitions
79  static DestFinfo concen( "concen",
80  "Incoming message from Concen object to specific conc to use"
81  "in the Z gate calculations",
83  );
84  static DestFinfo createGate( "createGate",
85  "Function to create specified gate."
86  "Argument: Gate type [X Y Z]",
88  );
90 // FieldElementFinfo definition for HHGates. Note that these are made
91 // with the deferCreate flag off, so that the HHGates are created
92 // right away even if they are empty.
93 // Assume only a single entry allocated in each gate.
95  static FieldElementFinfo< HHChannelBase, HHGate > gateX( "gateX",
96  "Sets up HHGate X for channel",
101  // 1
102  );
103  static FieldElementFinfo< HHChannelBase, HHGate > gateY( "gateY",
104  "Sets up HHGate Y for channel",
109  // 1
110  );
111  static FieldElementFinfo< HHChannelBase, HHGate > gateZ( "gateZ",
112  "Sets up HHGate Z for channel",
117  // 1
118  );
119 
121  static Finfo* HHChannelBaseFinfos[] =
122  {
123  &Xpower, // Value
124  &Ypower, // Value
125  &Zpower, // Value
126  &instant, // Value
127  &X, // Value
128  &Y, // Value
129  &Z, // Value
130  &useConcentration, // Value
131  &concen, // Dest
132  &createGate, // Dest
133  &gateX, // FieldElement
134  &gateY, // FieldElement
135  &gateZ // FieldElement
136  };
137 
138  static string doc[] =
139  {
140  "Name", "HHChannelBase",
141  "Author", "Upinder S. Bhalla, 2014, NCBS",
142  "Description", "HHChannelBase: Base class for "
143  "Hodgkin-Huxley type voltage-gated Ion channels. Something "
144  "like the old tabchannel from GENESIS, but also presents "
145  "a similar interface as hhchan from GENESIS. ",
146  };
147 
148  static ZeroSizeDinfo< int > dinfo;
149 
150  static Cinfo HHChannelBaseCinfo(
151  "HHChannelBase",
153  HHChannelBaseFinfos,
154  sizeof( HHChannelBaseFinfos )/sizeof(Finfo *),
155  &dinfo,
156  doc,
157  sizeof(doc)/sizeof(string)
158  );
159 
160  return &HHChannelBaseCinfo;
161 }
162 
165 
166 
168 // Constructor
171  :
172  Xpower_( 0.0 ),
173  Ypower_( 0.0 ),
174  Zpower_( 0.0 ),
175  useConcentration_( 0 ),
176  modulation_( 1.0 )
177 {;}
178 
180 {;}
181 
182 bool checkPower( double power )
183 {
184  if ( power < 0.0 ) {
185  cout << "Warning: HHChannelBase::setPower: Cannot be negative\n";
186  return false;
187  }
188  if ( power > 5.0 ) {
189  cout << "Warning: HHChannelBase::setPower: unlikely to be > 5\n";
190  return false;
191  }
192  return true;
193 }
200 void HHChannelBase::setXpower( const Eref& e, double power )
201 {
202  if ( checkPower( power ) )
203  vSetXpower( e, power );
204 }
205 
206 void HHChannelBase::setYpower( const Eref& e, double power )
207 {
208  if ( checkPower( power ) )
209  vSetYpower( e, power );
210 }
211 
212 void HHChannelBase::setZpower( const Eref& e, double power )
213 {
214  if ( checkPower( power ) )
215  vSetZpower( e, power );
216 }
217 
218 void HHChannelBase::createGate( const Eref& e, string gateType )
219 {
220  vCreateGate( e, gateType );
221 }
222 
224 // Field function definitions
226 
227 double HHChannelBase::getXpower( const Eref& e ) const
228 {
229  return Xpower_;
230 }
231 
232 double HHChannelBase::getYpower( const Eref& e ) const
233 {
234  return Ypower_;
235 }
236 
237 double HHChannelBase::getZpower( const Eref& e ) const
238 {
239  return Zpower_;
240 }
241 
242 void HHChannelBase::setInstant( const Eref& e, int instant )
243 {
244  vSetInstant( e, instant );
245 }
246 int HHChannelBase::getInstant( const Eref& e ) const
247 {
248  return vGetInstant( e );
249 }
250 
251 void HHChannelBase::setX( const Eref& e, double X )
252 {
253  vSetX( e, X );
254 }
255 double HHChannelBase::getX( const Eref& e ) const
256 {
257  return vGetX( e );
258 }
259 
260 void HHChannelBase::setY( const Eref& e, double Y )
261 {
262  vSetY( e, Y );
263 }
264 double HHChannelBase::getY( const Eref& e ) const
265 {
266  return vGetY( e );
267 }
268 
269 void HHChannelBase::setZ( const Eref& e, double Z )
270 {
271  vSetZ( e, Z );
272 }
273 double HHChannelBase::getZ( const Eref& e ) const
274 {
275  return vGetZ( e );
276 }
277 
279 {
281  vSetUseConcentration( e, value );
282 }
283 
285 {
286  return useConcentration_;
287 }
288 
289 double HHChannelBase::vGetModulation( const Eref& e) const
290 {
291  return modulation_;
292 }
293 
295 // Dest function definitions
297 
298 void HHChannelBase::handleConc( const Eref& e, double conc )
299 {
300  vHandleConc( e, conc );
301 }
302 
303 
305 // HHGate functions
307 
308 
309 HHGate* HHChannelBase::getXgate( unsigned int i )
310 {
311  return vGetXgate( i );
312 }
313 
314 HHGate* HHChannelBase::getYgate( unsigned int i )
315 {
316  return vGetYgate( i );
317 }
318 
319 HHGate* HHChannelBase::getZgate( unsigned int i )
320 {
321  return vGetZgate( i );
322 }
323 
324 void HHChannelBase::setNumGates( unsigned int num )
325 { ; }
326 
327 unsigned int HHChannelBase::getNumXgates() const
328 {
329  return ( vGetXgate(0) != 0 );
330 }
331 
332 unsigned int HHChannelBase::getNumYgates() const
333 {
334  return ( vGetYgate(0) != 0 );
335 }
336 
337 unsigned int HHChannelBase::getNumZgates() const
338 {
339  return ( vGetZgate(0) != 0 );
340 }
342 // Utility function
344 double HHChannelBase::powerN( double x, double p )
345 {
346  if ( x > 0.0 )
347  return exp( p * log( x ) );
348  return 0.0;
349 }
350 
352 {
353  if ( doubleEq( power, 0.0 ) )
354  return powerN;
355  else if ( doubleEq( power, 1.0 ) )
356  return power1;
357  else if ( doubleEq( power, 2.0 ) )
358  return power2;
359  else if ( doubleEq( power, 3.0 ) )
360  return power3;
361  else if ( doubleEq( power, 4.0 ) )
362  return power4;
363  else
364  return powerN;
365 }
367 // Dummy instantiation, the zombie derivatives make the real function
368 void HHChannelBase::vSetSolver( const Eref& e, Id hsolve )
369 {;}
370 
371 void HHChannelBase::zombify( Element* orig, const Cinfo* zClass, Id hsolve )
372 {
373  if ( orig->cinfo() == zClass )
374  return;
375  unsigned int start = orig->localDataStart();
376  unsigned int num = orig->numLocalData();
377  if ( num == 0 )
378  return;
379  // Parameters are Gbar, Ek, Xpower, Ypower, Zpower, useConcentration
380  // We also want to haul the original gates over, this is done earlier
381  // in the HSolve building process. So just six terms.
382  vector< double > chandata( num * 6, 0.0 );
383  vector< double >::iterator j = chandata.begin();
384 
385  for ( unsigned int i = 0; i < num; ++i ) {
386  Eref er( orig, i + start );
387  const HHChannelBase* hb =
388  reinterpret_cast< const HHChannelBase* >( er.data() );
389  *j = hb->vGetGbar( er );
390  *(j+1) = hb->vGetEk( er);
391  *(j+2) = hb->getXpower( er );
392  *(j+3) = hb->getYpower( er );
393  *(j+4) = hb->getZpower( er );
394  *(j+5) = hb->getUseConcentration( er );
395  j+= 6;
396  }
397  orig->zombieSwap( zClass );
398  j = chandata.begin();
399  for ( unsigned int i = 0; i < num; ++i ) {
400  Eref er( orig, i + start );
401  HHChannelBase* hb = reinterpret_cast< HHChannelBase* >( er.data() );
402  hb->vSetSolver( er, hsolve );
403  hb->vSetGbar( er, *j );
404  hb->vSetEk( er, *(j+1) );
405  hb->vSetXpower( er, *(j+2) );
406  hb->vSetYpower( er, *(j+3) );
407  hb->vSetZpower( er, *(j+4) );
408  // hb->vSetUseConcentration( er, *(j+5) > 0.5 );
409  // Disable this assignment because the Solver already reads the
410  // value, and it triggers an error msg.
411  j+= 6;
412  }
413 }
double getZpower(const Eref &e) const
static const Cinfo * hhChannelCinfo
char * data() const
Definition: Eref.cpp:41
uint32_t value
Definition: moosemodule.h:42
double getYpower(const Eref &e) const
Definition: HHGate.h:31
double modulation_
Value used to scale channel conductance up or down.
virtual void vSetY(const Eref &e, double Y)=0
virtual void vSetEk(const Eref &e, double Ek)=0
virtual HHGate * vGetZgate(unsigned int i) const =0
virtual void vHandleConc(const Eref &e, double conc)=0
unsigned int getNumZgates() const
Returns 1 if Z gate present, otherwise 0.
virtual double vGetGbar(const Eref &e) const =0
double(* PFDD)(double, double)
Definition: HHChannel2D.h:23
virtual void vSetYpower(const Eref &e, double Ypower)=0
Definition: EpFunc.h:64
double Zpower_
Exponent for Z gate.
void setNumGates(unsigned int num)
void setInstant(const Eref &e, int Instant)
double vGetModulation(const Eref &e) const
virtual void zombieSwap(const Cinfo *zCinfo)
virtual func, this base version must be called by all derived classes
Definition: Element.cpp:159
static PFDD selectPower(double power)
void setY(const Eref &e, double Y)
unsigned int getNumYgates() const
Returns 1 if Y gate present, otherwise 0.
virtual void vCreateGate(const Eref &e, string gateType)=0
HHGate * getXgate(unsigned int i)
double getXpower(const Eref &e) const
void setUseConcentration(const Eref &e, int value)
HHGate * getZgate(unsigned int i)
unsigned int getNumXgates() const
virtual void vSetSolver(const Eref &e, Id hsolve)
virtual HHGate * vGetXgate(unsigned int i) const =0
void log(string msg, serverity_level_ type=debug, bool redirectToConsole=true, bool removeTicks=true)
Log to console (and to a log-file)
virtual void vSetX(const Eref &e, double X)=0
double getY(const Eref &e) const
bool doubleEq(double x, double y)
Definition: doubleEq.cpp:16
static double powerN(double x, double p)
void handleConc(const Eref &e, double conc)
static double power2(double x, double p)
void setZ(const Eref &e, double Z)
bool useConcentration_
Flag for use of conc for input to Z gate calculations.
static const Cinfo * initCinfo()
HHGate * getYgate(unsigned int i)
virtual void vSetGbar(const Eref &e, double Gbar)=0
virtual double vGetX(const Eref &e) const =0
static const Cinfo * initCinfo()
Definition: HHGate.cpp:16
void createGate(const Eref &e, string gateType)
static void zombify(Element *orig, const Cinfo *zClass, Id hsolve)
virtual void vSetZpower(const Eref &e, double Zpower)=0
void setYpower(const Eref &e, double Ypower)
virtual void vSetZ(const Eref &e, double Z)=0
Definition: Eref.h:26
virtual double vGetY(const Eref &e) const =0
virtual void vSetInstant(const Eref &e, int Instant)=0
bool checkPower(double power)
const Cinfo * cinfo() const
Definition: Element.cpp:66
void setX(const Eref &e, double X)
double Ypower_
Exponent for Y gate.
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.
static double power4(double x, double p)
int getInstant(const Eref &e) const
int getUseConcentration(const Eref &e) const
static double power1(double x, double p)
virtual void vSetXpower(const Eref &e, double Xpower)=0
Definition: Id.h:17
double getX(const Eref &e) const
void setZpower(const Eref &e, double Zpower)
virtual int vGetInstant(const Eref &e) const =0
virtual double vGetZ(const Eref &e) const =0
virtual HHGate * vGetYgate(unsigned int i) const =0
void setXpower(const Eref &e, double Xpower)
double getZ(const Eref &e) const
virtual void vSetUseConcentration(const Eref &e, int value)=0
Definition: Cinfo.h:18
double Xpower_
Exponent for X gate.
static const Cinfo * initCinfo()
Specify the Class Info static variable for initialization.
Definition: ChanBase.cpp:36
static double power3(double x, double p)
Definition: Finfo.h:12
virtual double vGetEk(const Eref &e) const =0