MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
HHGate2D.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 "../builtins/Interpol2D.h"
13 #include "HHGate2D.h"
14 
15 static const double SINGULARITY = 1.0e-6;
16 
18 {
20  // Field definitions.
23  A( "A",
24  "lookupA: Look up the A gate value from two doubles, passed"
25  "in as a vector. Uses linear interpolation in the 2D table"
26  "The range of the lookup doubles is predefined based on "
27  "knowledge of voltage or conc ranges, and the granularity "
28  "is specified by the xmin, xmax, and dx field, and their "
29  "y-axis counterparts.",
32  B( "B",
33  "lookupB: Look up B gate value from two doubles in a vector.",
35 
37  "tableA",
38  "Table of A entries",
41  );
42 
44  "tableB",
45  "Table of B entries",
48 
49  static ElementValueFinfo< HHGate2D, double > xminA( "xminA",
50  "Minimum range for lookup",
53  );
54 
55  static ElementValueFinfo< HHGate2D, double > xmaxA( "xmaxA",
56  "Minimum range for lookup",
59  );
60 
61  static ElementValueFinfo< HHGate2D, unsigned int > xdivsA( "xdivsA",
62  "Divisions for lookup. Zero means to use linear interpolation",
65 
66  static ElementValueFinfo< HHGate2D, double > yminA( "yminA",
67  "Minimum range for lookup",
70 
71  static ElementValueFinfo< HHGate2D, double > ymaxA( "ymaxA",
72  "Minimum range for lookup",
75 
76  static ElementValueFinfo< HHGate2D, unsigned int > ydivsA( "ydivsA",
77  "Divisions for lookup. Zero means to use linear interpolation",
80 
81  static ElementValueFinfo< HHGate2D, double > xminB( "xminB",
82  "Minimum range for lookup",
85  );
86 
87  static ElementValueFinfo< HHGate2D, double > xmaxB( "xmaxB",
88  "Minimum range for lookup",
91  );
92 
93  static ElementValueFinfo< HHGate2D, unsigned int > xdivsB( "xdivsB",
94  "Divisions for lookup. Zero means to use linear interpolation",
97  );
98 
99  static ElementValueFinfo< HHGate2D, double > yminB( "yminB",
100  "Minimum range for lookup",
103 
104  static ElementValueFinfo< HHGate2D, double > ymaxB( "ymaxB",
105  "Minimum range for lookup",
108 
109  static ElementValueFinfo< HHGate2D, unsigned int > ydivsB( "ydivsB",
110  "Divisions for lookup. Zero means to use linear interpolation",
113 
115  // DestFinfos
117  static Finfo* HHGate2DFinfos[] =
118  {
119  &A, // ReadOnlyLookupValue
120  &B, // ReadOnlyLookupValue
121  &tableA, // ElementValue
122  &tableB, // ElementValue
123  &xminA,
124  &xmaxA,
125  &xdivsA,
126  &yminA,
127  &ymaxA,
128  &ydivsA,
129  &xminB,
130  &xmaxB,
131  &xdivsB,
132  &yminB,
133  &ymaxB,
134  &ydivsB
135  };
136 
137  static string doc[] =
138  {
139  "Name", "HHGate2D",
140  "Author", "Niraj Dudani, 2009, NCBS. Updated by Subhasis Ray, 2014, NCBS.",
141  "Description", "HHGate2D: Gate for Hodkgin-Huxley type channels, equivalent to the "
142  "m and h terms on the Na squid channel and the n term on K. "
143  "This takes the voltage and state variable from the channel, "
144  "computes the new value of the state variable and a scaling, "
145  "depending on gate power, for the conductance. These two "
146  "terms are sent right back in a message to the channel.",
147  };
148 
149  static Dinfo< HHGate2D > dinfo;
150  static Cinfo HHGate2DCinfo(
151  "HHGate2D",
153  HHGate2DFinfos, sizeof(HHGate2DFinfos)/sizeof(Finfo *),
154  &dinfo,
155  doc,
156  sizeof(doc) / sizeof(string)
157  );
158 
159  return &HHGate2DCinfo;
160 }
161 
165  : originalChanId_(0),
166  originalGateId_(0)
167 {;}
168 
169 HHGate2D::HHGate2D( Id originalChanId, Id originalGateId )
170  :
171  originalChanId_( originalChanId ),
172  originalGateId_( originalGateId )
173 {;}
174 
176 // Field function definitions
178 double HHGate2D::lookupA( vector< double > v ) const
179 {
180  if ( v.size() < 2 ) {
181  cerr << "Error: HHGate2D::getAValue: 2 real numbers needed to lookup 2D table.\n";
182  return 0.0;
183  }
184 
185  if ( v.size() > 2 ) {
186  cerr << "Error: HHGate2D::getAValue: Only 2 real numbers needed to lookup 2D table. "
187  "Using only first 2.\n";
188  }
189 
190  return A_.innerLookup( v[ 0 ], v[ 1 ] );
191 }
192 
193 double HHGate2D::lookupB( vector< double > v ) const
194 {
195  if ( v.size() < 2 ) {
196  cerr << "Error: HHGate2D::getAValue: 2 real numbers needed to lookup 2D table.\n";
197  return 0.0;
198  }
199 
200  if ( v.size() > 2 ) {
201  cerr << "Error: HHGate2D::getAValue: Only 2 real numbers needed to lookup 2D table. "
202  "Using only first 2.\n";
203  }
204 
205  return B_.innerLookup( v[ 0 ], v[ 1 ] );
206 }
207 
208 void HHGate2D::lookupBoth( double v, double c, double* A, double* B ) const
209 {
210  *A = A_.innerLookup( v, c );
211  *B = B_.innerLookup( v, c );
212 }
213 
214 
216 // Access functions for Interpols
218 
219 vector< vector< double > > HHGate2D::getTableA( const Eref& e ) const
220 {
221  return A_.getTableVector();
222 }
223 
224 void HHGate2D::setTableA(const Eref& e, vector< vector< double > > value )
225 {
227 }
228 
229 vector< vector< double > > HHGate2D::getTableB(const Eref& e) const
230 {
231  return B_.getTableVector();
232 }
233 
234 void HHGate2D::setTableB(const Eref& e, vector< vector< double > > value )
235 {
237 }
238 
240 // Functions to check if this is original or copy
243 {
244  return ( id == originalChanId_ );
245 }
246 
247 bool HHGate2D::isOriginalGate( Id id ) const
248 {
249  return ( id == originalGateId_ );
250 }
251 
253 {
254  return originalChanId_;
255 }
256 
257 double HHGate2D::getXminA(const Eref& e) const
258 {
259  return A_.getXmin();
260 }
261 
262 void HHGate2D::setXminA(const Eref& e, double value)
263 {
264  A_.setXmin(value);
265 }
266 
267 double HHGate2D::getXmaxA(const Eref& e) const
268 {
269  return A_.getXmax();
270 }
271 
272 void HHGate2D::setXmaxA(const Eref& e, double value)
273 {
274  A_.setXmax(value);
275 }
276 
277 unsigned int HHGate2D::getXdivsA(const Eref& e) const
278 {
279  return A_.getXdivs();
280 }
281 
282 void HHGate2D::setXdivsA(const Eref& e, unsigned int value)
283 {
284  A_.setXdivs(value);
285 }
286 
287 double HHGate2D::getYminA(const Eref& e) const
288 {
289  return A_.getYmin();
290 }
291 
292 void HHGate2D::setYminA(const Eref& e, double value)
293 {
294  A_.setYmin(value);
295 }
296 
297 double HHGate2D::getYmaxA(const Eref& e) const
298 {
299  return A_.getYmax();
300 }
301 
302 void HHGate2D::setYmaxA(const Eref& e, double value)
303 {
304  A_.setYmax(value);
305 }
306 
307 unsigned int HHGate2D::getYdivsA(const Eref& e) const
308 {
309  return A_.getYdivs();
310 }
311 
312 void HHGate2D::setYdivsA(const Eref& e, unsigned int value)
313 {
314  A_.setYdivs(value);
315 }
316 
317 double HHGate2D::getXminB(const Eref& e) const
318 {
319  return B_.getXmin();
320 }
321 
322 void HHGate2D::setXminB(const Eref& e, double value)
323 {
324  B_.setXmin(value);
325 }
326 
327 double HHGate2D::getXmaxB(const Eref& e) const
328 {
329  return B_.getXmax();
330 }
331 
332 void HHGate2D::setXmaxB(const Eref& e, double value)
333 {
334  B_.setXmax(value);
335 }
336 
337 unsigned int HHGate2D::getXdivsB(const Eref& e) const
338 {
339  return B_.getXdivs();
340 }
341 
342 void HHGate2D::setXdivsB(const Eref& e, unsigned int value)
343 {
344  B_.setXdivs(value);
345 }
346 
347 double HHGate2D::getYminB(const Eref& e) const
348 {
349  return B_.getYmin();
350 }
351 
352 void HHGate2D::setYminB(const Eref& e, double value)
353 {
354  B_.setYmin(value);
355 }
356 
357 double HHGate2D::getYmaxB(const Eref& e) const
358 {
359  return B_.getYmax();
360 }
361 
362 void HHGate2D::setYmaxB(const Eref& e, double value)
363 {
364  B_.setYmax(value);
365 }
366 
367 unsigned int HHGate2D::getYdivsB(const Eref& e) const
368 {
369  return B_.getYdivs();
370 }
371 
372 void HHGate2D::setYdivsB(const Eref& e, unsigned int value)
373 {
374  B_.setYdivs(value);
375 }
376 
378 // Dest function definitions
380 /*
381 void HHGate2D::gateFunc( const Eref& e, const Qinfo* q,
382  double v1, double v2 )
383 {
384 
385  sendBack2< double, double >( c, gateSlot,
386  h->A_.innerLookup( v1, v2 ) , h->B_.innerLookup( v1, v2 ) );
387 }
388 */
389 
uint32_t value
Definition: moosemodule.h:42
void setXminB(const Eref &e, double value)
Definition: HHGate2D.cpp:322
Id originalChannelId() const
Definition: HHGate2D.cpp:252
double getXminB(const Eref &e) const
Definition: HHGate2D.cpp:317
void setXmin(double value)
Definition: Interpol2D.cpp:229
Interpol2D A_
Definition: HHGate2D.h:96
bool isOriginalChannel(Id id) const
Definition: HHGate2D.cpp:242
void setYdivs(unsigned int value)
Definition: Interpol2D.cpp:321
Definition: Dinfo.h:60
void setXdivsA(const Eref &e, unsigned int value)
Definition: HHGate2D.cpp:282
double getYminA(const Eref &e) const
Definition: HHGate2D.cpp:287
void setTableA(const Eref &e, vector< vector< double > > value)
Definition: HHGate2D.cpp:224
void setXmaxA(const Eref &e, double value)
Definition: HHGate2D.cpp:272
Interpol2D B_
Definition: HHGate2D.h:97
void setYdivsA(const Eref &e, unsigned int value)
Definition: HHGate2D.cpp:312
void setYdivsB(const Eref &e, unsigned int value)
Definition: HHGate2D.cpp:372
unsigned int getYdivsB(const Eref &e) const
Definition: HHGate2D.cpp:367
unsigned int getYdivsA(const Eref &e) const
Definition: HHGate2D.cpp:307
void setYmaxB(const Eref &e, double value)
Definition: HHGate2D.cpp:362
double getXmin() const
Definition: Interpol2D.cpp:238
vector< vector< double > > getTableVector() const
Definition: Interpol2D.cpp:379
void setXdivs(unsigned int value)
Definition: Interpol2D.cpp:257
double getYmaxA(const Eref &e) const
Definition: HHGate2D.cpp:297
unsigned int getXdivs() const
Definition: Interpol2D.cpp:262
void setYminB(const Eref &e, double value)
Definition: HHGate2D.cpp:352
double getYmin() const
Definition: Interpol2D.cpp:302
static const Cinfo * hhGate2DCinfo
Definition: HHGate2D.cpp:162
double getXmaxA(const Eref &e) const
Definition: HHGate2D.cpp:267
Id originalGateId_
Definition: HHGate2D.h:100
void setTableVector(vector< vector< double > > value)
Definition: Interpol2D.cpp:420
void setYminA(const Eref &e, double value)
Definition: HHGate2D.cpp:292
static const double SINGULARITY
Definition: HHGate2D.cpp:15
double getYmax() const
Definition: Interpol2D.cpp:316
unsigned int getXdivsA(const Eref &e) const
Definition: HHGate2D.cpp:277
void setYmaxA(const Eref &e, double value)
Definition: HHGate2D.cpp:302
unsigned int getYdivs() const
Definition: Interpol2D.cpp:325
void setYmax(double value)
Definition: Interpol2D.cpp:307
Id originalChanId_
Definition: HHGate2D.h:99
Definition: Eref.h:26
double innerLookup(double x, double y) const
Definition: Interpol2D.cpp:574
vector< vector< double > > getTableA(const Eref &e) const
Definition: HHGate2D.cpp:219
double getXmaxB(const Eref &e) const
Definition: HHGate2D.cpp:327
void setXmaxB(const Eref &e, double value)
Definition: HHGate2D.cpp:332
double getYminB(const Eref &e) const
Definition: HHGate2D.cpp:347
unsigned int getXdivsB(const Eref &e) const
Definition: HHGate2D.cpp:337
double getXminA(const Eref &e) const
Definition: HHGate2D.cpp:257
bool isOriginalGate(Id id) const
Definition: HHGate2D.cpp:247
void setXminA(const Eref &e, double value)
Definition: HHGate2D.cpp:262
void setXdivsB(const Eref &e, unsigned int value)
Definition: HHGate2D.cpp:342
static const Cinfo * initCinfo()
Definition: HHGate2D.cpp:17
vector< vector< double > > getTableB(const Eref &e) const
Definition: HHGate2D.cpp:229
void lookupBoth(double v, double c, double *A, double *B) const
Definition: HHGate2D.cpp:208
void setTableB(const Eref &e, vector< vector< double > > value)
Definition: HHGate2D.cpp:234
Definition: Id.h:17
static const Cinfo * initCinfo()
Definition: Neutral.cpp:16
void setYmin(double value)
Definition: Interpol2D.cpp:293
double lookupA(vector< double > v) const
Definition: HHGate2D.cpp:178
double getXmax() const
Definition: Interpol2D.cpp:252
Definition: Cinfo.h:18
void setXmax(double value)
Definition: Interpol2D.cpp:243
double lookupB(vector< double > v) const
Definition: HHGate2D.cpp:193
double getYmaxB(const Eref &e) const
Definition: HHGate2D.cpp:357
Definition: Finfo.h:12