MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
HSolveActive Class Reference

#include <HSolveActive.h>

+ Inheritance diagram for HSolveActive:
+ Collaboration diagram for HSolveActive:

Public Member Functions

 HSolveActive ()
 
void reinit (ProcPtr info)
 
void setup (Id seed, double dt)
 
void step (ProcPtr info)
 Equivalent to process. More...
 
- Public Member Functions inherited from HSolvePassive
void setup (Id seed, double dt)
 
void solve ()
 
- Public Member Functions inherited from HinesMatrix
double getA (unsigned int row, unsigned int col) const
 
double getB (unsigned int row) const
 
unsigned int getSize () const
 
double getVMid (unsigned int row) const
 
 HinesMatrix ()
 
void setup (const vector< TreeNodeStruct > &tree, double dt)
 

Protected Attributes

vector< double > ca_
 Ca conc in each pool. More...
 
vector< double > caActivation_
 calcium pool More...
 
int caAdvance_
 
vector< CaConcStructcaConc_
 Ca pool info. More...
 
vector< IdcaConcId_
 calcium from difshells More...
 
vector< unsigned int > caCount_
 each compartment More...
 
vector< int > caDependIndex_
 depdt channel depend upon? More...
 
int caDiv_
 
double caMax_
 
double caMin_
 
vector< LookupRow * > caRow_
 
vector< LookupRowcaRowCompt_
 
LookupTable caTable_
 
vector< double * > caTarget_
 
vector< unsigned int > chan2compt_
 
vector< unsigned int > chan2state_
 a state index More...
 
vector< ChannelStructchannel_
 to compartment: chan2compt More...
 
vector< int > channelCount_
 compartment More...
 
vector< IdchannelId_
 Used for localIndex-ing. More...
 
vector< LookupColumncolumn_
 to lookup for this species More...
 
vector< CurrentStructcurrent_
 Channel current. More...
 
vector< currentVecItercurrentBoundary_
 
vector< double > externalCalcium_
 
vector< double > externalCurrent_
 
vector< IdgateId_
 Used for localIndex-ing. More...
 
vector< bool > gCaDepend_
 depend on Ca conc? More...
 
vector< unsigned int > outCa_
 
vector< unsigned int > outIk_
 
vector< unsigned int > outVm_
 
vector< SpikeGenStructspikegen_
 
vector< double > state_
 Fraction of gates open. More...
 
vector< SynChanStructsynchan_
 
int vDiv_
 
double vMax_
 
double vMin_
 
LookupTable vTable_
 
- Protected Attributes inherited from HSolvePassive
vector< CompartmentStructcompartment_
 
vector< IdcompartmentId_
 
map< unsigned int, InjectStructinject_
 
vector< TreeNodeStructtree_
 
vector< double > V_
 
- Protected Attributes inherited from HinesMatrix
vector< vdIteratorbackOperand_
 
double dt_
 
vector< double > HJ_
 
vector< double > HJCopy_
 
vector< double > HS_
 
vector< JunctionStructjunction_
 
unsigned int nCompt_
 
vector< vdIteratoroperand_
 
int stage_
 reached. Used in getA. More...
 
vector< double > VMid_
 middle of a time step. More...
 

Private Types

typedef vector< CurrentStruct >
::iterator 
currentVecIter
 

Private Member Functions

void advanceCalcium ()
 
void advanceChannels (double dt)
 
void advanceSynChans (ProcPtr info)
 
void backwardSubstitute ()
 
void calculateChannelCurrents ()
 
void cleanup ()
 
void createLookupTables ()
 
void forwardEliminate ()
 
void manageOutgoingMessages ()
 
void readCalcium ()
 
void readExternalChannels ()
 
void readGates ()
 
void readHHChannels ()
 
void readSynapses ()
 
void reinitCalcium ()
 
void reinitChannels ()
 
void reinitCompartments ()
 
void reinitSpikeGens (ProcPtr info)
 
void sendSpikes (ProcPtr info)
 
void sendValues (ProcPtr info)
 
void updateMatrix ()
 

Static Private Attributes

static const int INSTANT_X = 1
 
static const int INSTANT_Y = 2
 
static const int INSTANT_Z = 4
 

Additional Inherited Members

- Protected Types inherited from HinesMatrix
typedef vector< double >::iterator vdIterator
 
- Protected Member Functions inherited from HSolvePassive
void backwardSubstitute ()
 
void forwardEliminate ()
 
void updateMatrix ()
 

Detailed Description

Definition at line 29 of file HSolveActive.h.

Member Typedef Documentation

typedef vector< CurrentStruct >::iterator HSolveActive::currentVecIter
private

Definition at line 31 of file HSolveActive.h.

Constructor & Destructor Documentation

HSolveActive::HSolveActive ( )

Definition at line 33 of file HSolveActive.cpp.

34 {
35  caAdvance_ = 1;
36 
37  // Default lookup table size
38  //~ vDiv_ = 3000; // for voltage
39  //~ caDiv_ = 3000; // for calcium
40 }

Member Function Documentation

void HSolveActive::advanceCalcium ( )
private

Definition at line 153 of file HSolveActive.cpp.

154 {
155  vector< double* >::iterator icatarget = caTarget_.begin();
156  vector< double >::iterator ivmid = VMid_.begin();
157  vector< CurrentStruct >::iterator icurrent = current_.begin();
158  vector< currentVecIter >::iterator iboundary = currentBoundary_.begin();
159 
160  /*
161  * caAdvance_: This flag determines how current flowing into a calcium pool
162  * is computed. A value of 0 means that the membrane potential at the
163  * beginning of the time-step is used for the calculation. This is how
164  * GENESIS does its computations. A value of 1 means the membrane potential
165  * at the middle of the time-step is used. This is the correct way of
166  * integration, and is the default way.
167  */
168  if ( caAdvance_ == 1 )
169  {
170  for ( ; iboundary != currentBoundary_.end(); ++iboundary )
171  {
172  for ( ; icurrent < *iboundary; ++icurrent )
173  {
174  if ( *icatarget )
175  **icatarget += icurrent->Gk * ( icurrent->Ek - *ivmid );
176 
177  ++icatarget;
178  }
179 
180  ++ivmid;
181  }
182  }
183  else if ( caAdvance_ == 0 )
184  {
185  vector< double >::iterator iv = V_.begin();
186  double v0;
187 
188  for ( ; iboundary != currentBoundary_.end(); ++iboundary )
189  {
190  for ( ; icurrent < *iboundary; ++icurrent )
191  {
192  if ( *icatarget )
193  {
194  v0 = ( 2 * *ivmid - *iv );
195 
196  **icatarget += icurrent->Gk * ( icurrent->Ek - v0 );
197  }
198 
199  ++icatarget;
200  }
201 
202  ++ivmid, ++iv;
203  }
204  }
205 
206  vector< CaConcStruct >::iterator icaconc;
207  vector< double >::iterator icaactivation = caActivation_.begin();
208  vector< double >::iterator ica = ca_.begin();
209  for ( icaconc = caConc_.begin(); icaconc != caConc_.end(); ++icaconc )
210  {
211  *ica = icaconc->process( *icaactivation );
212  ++ica, ++icaactivation;
213  }
214 
215  caActivation_.assign( caActivation_.size(), 0.0 );
216 }
vector< double > VMid_
middle of a time step.
Definition: HinesMatrix.h:83
vector< double > ca_
Ca conc in each pool.
Definition: HSolveActive.h:81
vector< double > caActivation_
calcium pool
Definition: HSolveActive.h:82
vector< double * > caTarget_
Definition: HSolveActive.h:84
vector< double > V_
Definition: HSolvePassive.h:38
vector< CaConcStruct > caConc_
Ca pool info.
Definition: HSolveActive.h:80
vector< currentVecIter > currentBoundary_
Definition: HSolveActive.h:111
vector< CurrentStruct > current_
Channel current.
Definition: HSolveActive.h:73
void HSolveActive::advanceChannels ( double  dt)
private

Definition at line 218 of file HSolveActive.cpp.

References LookupRow::row.

219 {
220  vector< double >::iterator iv;
221  vector< double >::iterator istate = state_.begin();
222  vector< int >::iterator ichannelcount = channelCount_.begin();
223  vector< ChannelStruct >::iterator ichan = channel_.begin();
224  vector< ChannelStruct >::iterator chanBoundary;
225  vector< unsigned int >::iterator icacount = caCount_.begin();
226  vector< double >::iterator ica = ca_.begin();
227  vector< double >::iterator caBoundary;
228  vector< LookupColumn >::iterator icolumn = column_.begin();
229  vector< LookupRow >::iterator icarowcompt;
230  vector< LookupRow* >::iterator icarow = caRow_.begin();
231  vector< double >::iterator iextca = externalCalcium_.begin();
232 
233  LookupRow vRow;
234  LookupRow dRow;
235  double C1, C2;
236 
237  for ( iv = V_.begin(); iv != V_.end(); ++iv )
238  {
239  vTable_.row( *iv, vRow );
240  icarowcompt = caRowCompt_.begin();
241  caBoundary = ica + *icacount;
242  for ( ; ica < caBoundary; ++ica )
243  {
244  caTable_.row( *ica, *icarowcompt );
245 
246  ++icarowcompt;
247  }
248 
249  /*
250  * Optimize by moving "if ( instant )" outside the loop, because it is
251  * rarely used. May also be able to avoid "if ( power )".
252  *
253  * Or not: excellent branch predictors these days.
254  *
255  * Will be nice to test these optimizations.
256  */
257  chanBoundary = ichan + *ichannelcount;
258  for ( ; ichan < chanBoundary; ++ichan )
259  {
260 
261  caTable_.row( *iextca, dRow );
262 
263  if ( ichan->Xpower_ > 0.0 )
264  {
265  vTable_.lookup( *icolumn, vRow, C1, C2 );
266  //~ *istate = *istate * C1 + C2;
267  //~ *istate = ( C1 + ( 2 - C2 ) * *istate ) / C2;
268  if ( ichan->instant_ & INSTANT_X )
269  *istate = C1 / C2;
270  else
271  {
272  double temp = 1.0 + dt / 2.0 * C2;
273  *istate = ( *istate * ( 2.0 - temp ) + dt * C1 ) / temp;
274  }
275 
276  ++icolumn, ++istate;
277  }
278 
279  if ( ichan->Ypower_ > 0.0 )
280  {
281  vTable_.lookup( *icolumn, vRow, C1, C2 );
282  //~ *istate = *istate * C1 + C2;
283  //~ *istate = ( C1 + ( 2 - C2 ) * *istate ) / C2;
284  if ( ichan->instant_ & INSTANT_Y )
285  *istate = C1 / C2;
286  else
287  {
288  double temp = 1.0 + dt / 2.0 * C2;
289  *istate = ( *istate * ( 2.0 - temp ) + dt * C1 ) / temp;
290 
291 }
292  ++icolumn, ++istate;
293  }
294 
295  if ( ichan->Zpower_ > 0.0 )
296  {
297  LookupRow* caRow = *icarow;
298 
299  if ( caRow )
300  {
301  caTable_.lookup( *icolumn, *caRow, C1, C2 );
302 
303  }
304  else if (*iextca >0)
305 
306  {
307  caTable_.lookup( *icolumn, dRow, C1, C2 );
308  }
309  else
310  {
311  vTable_.lookup( *icolumn, vRow, C1, C2 );
312 
313  }
314 
315  //~ *istate = *istate * C1 + C2;
316  //~ *istate = ( C1 + ( 2 - C2 ) * *istate ) / C2;
317  if ( ichan->instant_ & INSTANT_Z )
318  *istate = C1 / C2;
319  else
320  {
321  double temp = 1.0 + dt / 2.0 * C2;
322  *istate = ( *istate * ( 2.0 - temp ) + dt * C1 ) / temp;
323  }
324 
325  ++icolumn, ++istate, ++icarow;
326 
327  }
328  ++iextca;
329  }
330 
331  ++ichannelcount, ++icacount;
332  }
333 }
vector< double > state_
Fraction of gates open.
Definition: HSolveActive.h:74
static const int INSTANT_X
Definition: HSolveActive.h:172
vector< LookupRow > caRowCompt_
Definition: HSolveActive.h:97
vector< double > ca_
Ca conc in each pool.
Definition: HSolveActive.h:81
static const int INSTANT_Z
Definition: HSolveActive.h:174
void lookup(const LookupColumn &column, const LookupRow &row, double &C1, double &C2)
Actually performs the lookup and the linear interpolation.
Definition: RateLookup.cpp:76
LookupTable caTable_
Definition: HSolveActive.h:88
vector< ChannelStruct > channel_
to compartment: chan2compt
Definition: HSolveActive.h:76
vector< int > channelCount_
compartment
Definition: HSolveActive.h:109
void row(double x, LookupRow &row)
Definition: RateLookup.cpp:62
vector< double > V_
Definition: HSolvePassive.h:38
vector< LookupRow * > caRow_
Definition: HSolveActive.h:104
LookupTable vTable_
Definition: HSolveActive.h:87
vector< double > externalCalcium_
Definition: HSolveActive.h:122
static const int INSTANT_Y
Definition: HSolveActive.h:173
vector< unsigned int > caCount_
each compartment
Definition: HSolveActive.h:91
vector< LookupColumn > column_
to lookup for this species
Definition: HSolveActive.h:95
void HSolveActive::advanceSynChans ( ProcPtr  info)
private

SynChans are currently not under solver's control

Definition at line 338 of file HSolveActive.cpp.

339 {
340  return;
341 }
void HSolveActive::backwardSubstitute ( )
private
void HSolveActive::calculateChannelCurrents ( )
private

Integration: Defined in HSolveActive.cpp

Definition at line 69 of file HSolveActive.cpp.

70 {
71  vector< ChannelStruct >::iterator ichan;
72  vector< CurrentStruct >::iterator icurrent = current_.begin();
73 
74  if ( state_.size() != 0 )
75  {
76  double* istate = &state_[ 0 ];
77 
78  for ( ichan = channel_.begin(); ichan != channel_.end(); ++ichan )
79  {
80  ichan->process( istate, *icurrent );
81  ++icurrent;
82  }
83  }
84 }
vector< double > state_
Fraction of gates open.
Definition: HSolveActive.h:74
vector< ChannelStruct > channel_
to compartment: chan2compt
Definition: HSolveActive.h:76
vector< CurrentStruct > current_
Channel current.
Definition: HSolveActive.h:73
void HSolveActive::cleanup ( )
private

Definition at line 676 of file HSolveActiveSetup.cpp.

References caDependIndex_, and gCaDepend_.

Referenced by setup().

677 {
678 // compartmentId_.clear();
679  gCaDepend_.clear();
680  caDependIndex_.clear();
681 }
vector< bool > gCaDepend_
depend on Ca conc?
Definition: HSolveActive.h:89
vector< int > caDependIndex_
depdt channel depend upon?
Definition: HSolveActive.h:93

+ Here is the caller graph for this function:

void HSolveActive::createLookupTables ( )
private

Definition at line 339 of file HSolveActiveSetup.cpp.

References LookupTable::addColumns(), caCount_, caDependIndex_, caDiv_, caMax_, caMin_, caRow_, caRowCompt_, caTable_, channel_, LookupTable::column(), column_, gateId_, gCaDepend_, Field< A >::get(), HSolveUtils::rates(), HSolveUtils::Grid::size(), vDiv_, vMax_, vMin_, and vTable_.

Referenced by setup().

340 {
341  std::set< Id > caSet;
342  std::set< Id > vSet;
343  vector< Id > caGate;
344  vector< Id > vGate;
345  map< Id, unsigned int > gateSpecies;
346 
347  for ( unsigned int ig = 0; ig < gateId_.size(); ++ig )
348  if ( gCaDepend_[ ig ] )
349  caSet.insert( gateId_[ ig ] );
350  else
351  vSet.insert( gateId_[ ig ] );
352 
353  caGate.insert( caGate.end(), caSet.begin(), caSet.end() );
354  vGate.insert( vGate.end(), vSet.begin(), vSet.end() );
355 
356  for ( unsigned int ig = 0; ig < caGate.size(); ++ig )
357  gateSpecies[ caGate[ ig ] ] = ig;
358  for ( unsigned int ig = 0; ig < vGate.size(); ++ig )
359  gateSpecies[ vGate[ ig ] ] = ig;
360 
361  /*
362  * Finding the smallest xmin and largest xmax across all gates' lookup
363  * tables.
364  *
365  * # of divs is determined by finding the smallest dx (highest density).
366  */
367  vMin_ = numeric_limits< double >::max();
368  vMax_ = numeric_limits< double >::min();
369  double vDx = numeric_limits< double >::max();
370  caMin_ = numeric_limits< double >::max();
371  caMax_ = numeric_limits< double >::min();
372  double caDx = numeric_limits< double >::max();
373 
374  double min;
375  double max;
376  unsigned int divs;
377  double dx;
378 
379  for ( unsigned int ig = 0; ig < caGate.size(); ++ig )
380  {
381  min = Field< double >::get( caGate[ ig ], "min" );
382  max = Field< double >::get( caGate[ ig ], "max" );
383  divs = Field< unsigned int >::get( caGate[ ig ], "divs" );
384  dx = ( max - min ) / divs;
385 
386  if ( min < caMin_ )
387  caMin_ = min;
388  if ( max > caMax_ )
389  caMax_ = max;
390  if ( dx < caDx )
391  caDx = dx;
392  }
393  double caDiv = ( caMax_ - caMin_ ) / caDx;
394  caDiv_ = static_cast< int >( caDiv + 0.5 ); // Round-off to nearest int.
395 
396  for ( unsigned int ig = 0; ig < vGate.size(); ++ig )
397  {
398  min = Field< double >::get( vGate[ ig ], "min" );
399  max = Field< double >::get( vGate[ ig ], "max" );
400  divs = Field< unsigned int >::get( vGate[ ig ], "divs" );
401  dx = ( max - min ) / divs;
402 
403  if ( min < vMin_ )
404  vMin_ = min;
405  if ( max > vMax_ )
406  vMax_ = max;
407  if ( dx < vDx )
408  vDx = dx;
409  }
410  double vDiv = ( vMax_ - vMin_ ) / vDx;
411  vDiv_ = static_cast< int >( vDiv + 0.5 ); // Round-off to nearest int.
412 
413  caTable_ = LookupTable( caMin_, caMax_, caDiv_, caGate.size() );
414  vTable_ = LookupTable( vMin_, vMax_, vDiv_, vGate.size() );
415 
416  vector< double > A, B;
417  vector< double >::iterator ia, ib;
418  // double a, b;
419  //~ int AMode, BMode;
420  //~ bool interpolate;
421 
422  // Calcium-dependent lookup tables
424  //~ if ( !caGate.empty() ) {
425  //~ grid.resize( 1 + caDiv_ );
426  //~ double dca = ( caMax_ - caMin_ ) / caDiv_;
427  //~ for ( int igrid = 0; igrid <= caDiv_; ++igrid )
428  //~ grid[ igrid ] = caMin_ + igrid * dca;
429  //~ }
430 
431  for ( unsigned int ig = 0; ig < caGate.size(); ++ig )
432  {
433  HSolveUtils::rates( caGate[ ig ], caGrid, A, B );
434  //~ HSolveUtils::modes( caGate[ ig ], AMode, BMode );
435  //~ interpolate = ( AMode == 1 ) || ( BMode == 1 );
436 
437  ia = A.begin();
438  ib = B.begin();
439  for ( unsigned int igrid = 0; igrid < caGrid.size(); ++igrid )
440  {
441  // Use one of the optimized forms below, instead of A and B
442  // directly. Also updated reinit() accordingly (for gate state).
443 // a = *ia;
444 // b = *ib;
445 
446  // *ia = ( 2.0 - dt_ * b ) / ( 2.0 + dt_ * b );
447  // *ib = dt_ * a / ( 1.0 + dt_ * b / 2.0 );
448  // *ia = dt_ * a;
449  // *ib = 1.0 + dt_ * b / 2.0;
450  ++ia, ++ib;
451  }
452 
453  //~ caTable_.addColumns( ig, A, B, interpolate );
454  caTable_.addColumns( ig, A, B );
455  }
456 
457  // Voltage-dependent lookup tables
458  HSolveUtils::Grid vGrid( vMin_, vMax_, vDiv_ );
459  //~ if ( !vGate.empty() ) {
460  //~ grid.resize( 1 + vDiv_ );
461  //~ double dv = ( vMax_ - vMin_ ) / vDiv_;
462  //~ for ( int igrid = 0; igrid <= vDiv_; ++igrid )
463  //~ grid[ igrid ] = vMin_ + igrid * dv;
464  //~ }
465 
466 
467  for ( unsigned int ig = 0; ig < vGate.size(); ++ig )
468  {
469  //~ interpolate = HSolveUtils::get< HHGate, bool >( vGate[ ig ], "useInterpolation" );
470  HSolveUtils::rates( vGate[ ig ], vGrid, A, B );
471  //~ HSolveUtils::modes( vGate[ ig ], AMode, BMode );
472  //~ interpolate = ( AMode == 1 ) || ( BMode == 1 );
473 
474  ia = A.begin();
475  ib = B.begin();
476  for ( unsigned int igrid = 0; igrid < vGrid.size(); ++igrid )
477  {
478  // Use one of the optimized forms below, instead of A and B
479  // directly. Also updated reinit() accordingly (for gate state).
480 // a = *ia;
481 // b = *ib;
482 
483  // *ia = ( 2.0 - dt_ * b ) / ( 2.0 + dt_ * b );
484  // *ib = dt_ * a / ( 1.0 + dt_ * b / 2.0 );
485  // *ia = dt_ * a;
486  // *ib = 1.0 + dt_ * b / 2.0;
487  ++ia, ++ib;
488  }
489 
490  //~ vTable_.addColumns( ig, A, B, interpolate );
491  vTable_.addColumns( ig, A, B );
492  }
493 
494  column_.reserve( gateId_.size() );
495  for ( unsigned int ig = 0; ig < gateId_.size(); ++ig )
496  {
497  unsigned int species = gateSpecies[ gateId_[ ig ] ];
498 
499  LookupColumn column;
500  if ( gCaDepend_[ ig ] )
501  caTable_.column( species, column );
502  else
503  vTable_.column( species, column );
504 
505  column_.push_back( column );
506  }
507 
509  unsigned int maxN = *( max_element( caCount_.begin(), caCount_.end() ) );
510  caRowCompt_.resize( maxN );
511 
512  for ( unsigned int ichan = 0; ichan < channel_.size(); ++ichan )
513  {
514  if ( channel_[ ichan ].Zpower_ > 0.0 )
515  {
516  int index = caDependIndex_[ ichan ];
517 
518  if ( index == -1 )
519  caRow_.push_back( 0 );
520  else
521  caRow_.push_back( &caRowCompt_[ index ] );
522  }
523  }
524 
525 
526 }
vector< LookupRow > caRowCompt_
Definition: HSolveActive.h:97
vector< bool > gCaDepend_
depend on Ca conc?
Definition: HSolveActive.h:89
LookupTable caTable_
Definition: HSolveActive.h:88
vector< ChannelStruct > channel_
to compartment: chan2compt
Definition: HSolveActive.h:76
vector< int > caDependIndex_
depdt channel depend upon?
Definition: HSolveActive.h:93
vector< Id > gateId_
Used for localIndex-ing.
Definition: HSolveActive.h:125
double vMin_
Definition: HSolveActive.h:63
vector< LookupRow * > caRow_
Definition: HSolveActive.h:104
static void rates(Id gate, Grid grid, vector< double > &A, vector< double > &B)
LookupTable vTable_
Definition: HSolveActive.h:87
void addColumns(int species, const vector< double > &C1, const vector< double > &C2)
Adds the columns for a given species. Columns supplied are C1 and C2.
Definition: RateLookup.cpp:31
double caMin_
Definition: HSolveActive.h:66
void column(unsigned int species, LookupColumn &column)
Definition: RateLookup.cpp:56
double caMax_
Definition: HSolveActive.h:67
static A get(const ObjId &dest, const string &field)
Definition: SetGet.h:284
vector< unsigned int > caCount_
each compartment
Definition: HSolveActive.h:91
vector< LookupColumn > column_
to lookup for this species
Definition: HSolveActive.h:95
double vMax_
Definition: HSolveActive.h:64

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void HSolveActive::forwardEliminate ( )
private
void HSolveActive::manageOutgoingMessages ( )
private

Definition at line 598 of file HSolveActiveSetup.cpp.

References caConcId_, channelId_, HSolvePassive::compartmentId_, outCa_, outIk_, outVm_, and HSolveUtils::targets().

Referenced by setup().

599 {
600  vector< Id > targets;
601  vector< string > filter;
602 
603  /*
604  * Going through all comparments, and finding out which ones have external
605  * targets through the VmOut msg. External refers to objects that do not
606  * belong the cell being managed by this HSolve. We find these by excluding
607  * any HHChannels and SpikeGens from the VmOut targets. These will then
608  * be used in HSolveActive::sendValues() to send out the messages behalf of
609  * the original objects.
610  */
611  filter.push_back( "HHChannel" );
612  filter.push_back( "SpikeGen" );
613  for ( unsigned int ic = 0; ic < compartmentId_.size(); ++ic )
614  {
615  targets.clear();
616 
617  int nTargets = HSolveUtils::targets(
618  compartmentId_[ ic ],
619  "VmOut",
620  targets,
621  filter,
622  false // include = false. That is, use filter to exclude.
623  );
624 
625  if ( nTargets )
626  outVm_.push_back( ic );
627  }
628 
629  /*
630  * As before, going through all CaConcs, and finding any which have external
631  * targets.
632  */
633  filter.clear();
634  filter.push_back( "HHChannel" );
635  for ( unsigned int ica = 0; ica < caConcId_.size(); ++ica )
636  {
637  targets.clear();
638 
639  int nTargets = HSolveUtils::targets(
640  caConcId_[ ica ],
641  "concOut",
642  targets,
643  filter,
644  false // include = false. That is, use filter to exclude.
645  );
646 
647  if ( nTargets )
648  outCa_.push_back( ica );
649  }
650 
651  filter.clear();
652  filter.push_back( "CaConc" );
653 
654  for ( unsigned int ik = 0; ik < channelId_.size(); ++ik )
655  {
656  targets.clear();
657 
658  int nTargets = HSolveUtils::targets(
659  channelId_[ ik ],
660  "IkOut",
661  targets,
662  filter,
663  false // include = false. That is, use filter to exclude.
664  );
665 
666  if ( nTargets )
667  outIk_.push_back( ik );
668 
669 
670  }
671 
672 
673 
674 }
vector< unsigned int > outCa_
Definition: HSolveActive.h:131
vector< unsigned int > outVm_
Definition: HSolveActive.h:127
vector< Id > compartmentId_
Definition: HSolvePassive.h:37
static int targets(Id object, string msg, vector< Id > &target, string filter="", bool include=true)
vector< unsigned int > outIk_
Definition: HSolveActive.h:135
vector< Id > channelId_
Used for localIndex-ing.
Definition: HSolveActive.h:124
vector< Id > caConcId_
calcium from difshells
Definition: HSolveActive.h:123

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void HSolveActive::readCalcium ( )
private

Definition at line 252 of file HSolveActiveSetup.cpp.

References ca_, caActivation_, caConc_, caConcId_, caCount_, HSolveUtils::caDepend(), caDependIndex_, HSolveUtils::caTarget(), caTarget_, channel_, channelCount_, channelId_, HinesMatrix::dt_, externalCalcium_, Field< A >::get(), and HinesMatrix::nCompt_.

Referenced by setup().

253 {
254  double Ca, CaBasal, tau, B, ceiling, floor;
255  vector< Id > caConcId;
256  vector< int > caTargetIndex;
257  map< Id, int > caConcIndex;
258  int nTarget, nDepend = 0;
259  vector< Id >::iterator iconc;
260 
261  caCount_.resize( nCompt_ );
262  unsigned int ichan = 0;
263 
264  for ( unsigned int ic = 0; ic < nCompt_; ++ic )
265  {
266 
267  unsigned int chanBoundary = ichan + channelCount_[ ic ];
268  unsigned int nCa = caConc_.size();
269 
270  for ( ; ichan < chanBoundary; ++ichan )
271  {
272  caConcId.clear();
273 
274  nTarget = HSolveUtils::caTarget( channelId_[ ichan ], caConcId );
275  if ( nTarget == 0 )
276  // No calcium pools fed by this channel.
277  caTargetIndex.push_back( -1 );
278 
279  nDepend = HSolveUtils::caDepend( channelId_[ ichan ], caConcId );
280 
281  if ( nDepend == 0)
282  // Channel does not depend on calcium.
283 
284  caDependIndex_.push_back( -1 );
285 
286 
287  externalCalcium_.push_back(0);
288 
289  for ( iconc = caConcId.begin(); iconc != caConcId.end(); ++iconc )
290  if ( caConcIndex.find( *iconc ) == caConcIndex.end() )
291  {
292  caConcIndex[ *iconc ] = caCount_[ ic ];
293  ++caCount_[ ic ];
294 
295  Ca = Field< double >::get( *iconc, "Ca" );
296  CaBasal = Field< double >::get( *iconc, "CaBasal" );
297  tau = Field< double >::get( *iconc, "tau" );
298  B = Field< double >::get( *iconc, "B" );
299  ceiling = Field< double >::get( *iconc, "ceiling" );
300  floor = Field< double >::get( *iconc, "floor" );
301 
302  caConc_.push_back(
303  CaConcStruct(
304  Ca, CaBasal,
305  tau, B,
306  ceiling, floor,
307  dt_
308  )
309  );
310  caConcId_.push_back( *iconc );
311  }
312 
313  if ( nTarget != 0 )
314  caTargetIndex.push_back( caConcIndex[ caConcId.front() ] + nCa );
315  if ( nDepend != 0 )
316  caDependIndex_.push_back( caConcIndex[ caConcId.back() ] );
317 
318 
319  }
320  }
321 
322 
323 
324  caTarget_.resize( channel_.size() );
325  ca_.resize( caConc_.size() );
326  caActivation_.resize( caConc_.size() );
327 
328  for ( unsigned int ichan = 0; ichan < channel_.size(); ++ichan )
329  {
330  if ( caTargetIndex[ ichan ] == -1 )
331  caTarget_[ ichan ] = 0;
332  else
333  caTarget_[ ichan ] = &caActivation_[ caTargetIndex[ ichan ] ];
334  }
335 
336 
337 }
static int caDepend(Id channel, vector< Id > &ret)
vector< double > ca_
Ca conc in each pool.
Definition: HSolveActive.h:81
static int caTarget(Id channel, vector< Id > &ret)
vector< double > caActivation_
calcium pool
Definition: HSolveActive.h:82
vector< ChannelStruct > channel_
to compartment: chan2compt
Definition: HSolveActive.h:76
vector< int > channelCount_
compartment
Definition: HSolveActive.h:109
unsigned int nCompt_
Definition: HinesMatrix.h:70
vector< int > caDependIndex_
depdt channel depend upon?
Definition: HSolveActive.h:93
vector< double * > caTarget_
Definition: HSolveActive.h:84
vector< CaConcStruct > caConc_
Ca pool info.
Definition: HSolveActive.h:80
vector< double > externalCalcium_
Definition: HSolveActive.h:122
static A get(const ObjId &dest, const string &field)
Definition: SetGet.h:284
vector< Id > channelId_
Used for localIndex-ing.
Definition: HSolveActive.h:124
vector< unsigned int > caCount_
each compartment
Definition: HSolveActive.h:91
vector< Id > caConcId_
calcium from difshells
Definition: HSolveActive.h:123
double dt_
Definition: HinesMatrix.h:71

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void HSolveActive::readExternalChannels ( )
private

Definition at line 579 of file HSolveActiveSetup.cpp.

References HSolvePassive::compartmentId_, and externalCurrent_.

Referenced by setup().

580 {
581  vector< string > filter;
582  filter.push_back( "HHChannel" );
583  //~ filter.push_back( "SynChan" );
584 
585  //~ externalChannelId_.resize( compartmentId_.size() );
586  externalCurrent_.resize( 2 * compartmentId_.size(), 0.0 );
587 
588  //~ for ( unsigned int ic = 0; ic < compartmentId_.size(); ++ic )
589  //~ HSolveUtils::targets(
590  //~ compartmentId_[ ic ],
591  //~ "channel",
592  //~ externalChannelId_[ ic ],
593  //~ filter,
594  //~ false // include = false. That is, use filter to exclude.
595  //~ );
596 }
vector< Id > compartmentId_
Definition: HSolvePassive.h:37
vector< double > externalCurrent_
Definition: HSolveActive.h:119

+ Here is the caller graph for this function:

void HSolveActive::readGates ( )
private

Definition at line 237 of file HSolveActiveSetup.cpp.

References channelId_, gateId_, HSolveUtils::gates(), gCaDepend_, and Field< A >::get().

Referenced by setup().

238 {
239  vector< Id >::iterator ichan;
240  unsigned int nGates = 0;
241  int useConcentration = 0;
242  for ( ichan = channelId_.begin(); ichan != channelId_.end(); ++ichan )
243  {
244  nGates = HSolveUtils::gates( *ichan, gateId_ );
245  gCaDepend_.insert( gCaDepend_.end(), nGates, 0 );
246  useConcentration = Field< int >::get( *ichan, "useConcentration" );
247  if ( useConcentration )
248  gCaDepend_.back() = 1;
249  }
250 }
vector< bool > gCaDepend_
depend on Ca conc?
Definition: HSolveActive.h:89
static int gates(Id channel, vector< Id > &ret, bool getOriginals=true)
Definition: HSolveUtils.cpp:75
vector< Id > gateId_
Used for localIndex-ing.
Definition: HSolveActive.h:125
static A get(const ObjId &dest, const string &field)
Definition: SetGet.h:284
vector< Id > channelId_
Used for localIndex-ing.
Definition: HSolveActive.h:124

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void HSolveActive::readHHChannels ( )
private

Setting up of data structures: Defined in HSolveActiveSetup.cpp

Definition at line 162 of file HSolveActiveSetup.cpp.

References chan2compt_, chan2state_, channel_, channelCount_, channelId_, HSolvePassive::compartmentId_, current_, currentBoundary_, CurrentStruct::Ek, ChannelStruct::Gbar_, Field< A >::get(), HSolveUtils::hhchannels(), ChannelStruct::instant_, ChannelStruct::modulation_, HinesMatrix::nCompt_, ChannelStruct::setPowers(), and state_.

Referenced by setup().

163 {
164  vector< Id >::iterator icompt;
165  vector< Id >::iterator ichan;
166  int nChannel = 0;
167  double Gbar = 0.0, Ek = 0.0;
168  double X = 0.0, Y = 0.0, Z = 0.0;
169  double Xpower = 0.0, Ypower = 0.0, Zpower = 0.0;
170  int instant = 0;
171 
172  for ( icompt = compartmentId_.begin(); icompt != compartmentId_.end(); ++icompt )
173  {
174  nChannel = HSolveUtils::hhchannels( *icompt, channelId_ );
175 
176  // todo: discard channels with Gbar = 0.0
177  channelCount_.push_back( nChannel );
178 
179  ichan = channelId_.end() - nChannel;
180  for ( ; ichan != channelId_.end(); ++ichan )
181  {
182  channel_.resize( channel_.size() + 1 );
183  ChannelStruct& channel = channel_.back();
184 
185  current_.resize( current_.size() + 1 );
186  CurrentStruct& current = current_.back();
187 
188  Gbar = Field< double >::get( *ichan, "Gbar" );
189  Ek = Field< double >::get( *ichan, "Ek" );
190  X = Field< double >::get( *ichan, "X" );
191  Y = Field< double >::get( *ichan, "Y" );
192  Z = Field< double >::get( *ichan, "Z" );
193  Xpower = Field< double >::get( *ichan, "Xpower" );
194  Ypower = Field< double >::get( *ichan, "Ypower" );
195  Zpower = Field< double >::get( *ichan, "Zpower" );
196  instant = Field< int >::get( *ichan, "instant" );
197  double modulation = Field< double >::get( *ichan, "modulation");
198 
199  current.Ek = Ek;
200 
201  channel.Gbar_ = Gbar;
202  channel.setPowers( Xpower, Ypower, Zpower );
203  channel.instant_ = instant;
204  channel.modulation_ = modulation;
205 
206  /*
207  * Map channel index to state index. This is useful in the
208  * interface to find gate values.
209  */
210  chan2state_.push_back( state_.size() );
211 
212  if ( Xpower > 0.0 )
213  state_.push_back( X );
214  if ( Ypower > 0.0 )
215  state_.push_back( Y );
216  if ( Zpower > 0.0 )
217  state_.push_back( Z );
218 
219  /*
220  * Map channel index to compartment index. This is useful in the
221  * interface to generate channel Ik values (since we then need the
222  * compartment Vm).
223  */
224  chan2compt_.push_back( icompt - compartmentId_.begin() );
225  }
226  }
227 
228  int nCumulative = 0;
229  currentBoundary_.resize( nCompt_ );
230  for ( unsigned int ic = 0; ic < nCompt_; ++ic )
231  {
232  nCumulative += channelCount_[ ic ];
233  currentBoundary_[ ic ] = current_.begin() + nCumulative;
234  }
235 }
vector< double > state_
Fraction of gates open.
Definition: HSolveActive.h:74
vector< unsigned int > chan2state_
a state index
Definition: HSolveActive.h:117
vector< ChannelStruct > channel_
to compartment: chan2compt
Definition: HSolveActive.h:76
vector< int > channelCount_
compartment
Definition: HSolveActive.h:109
vector< Id > compartmentId_
Definition: HSolvePassive.h:37
unsigned int nCompt_
Definition: HinesMatrix.h:70
void setPowers(double Xpower, double Ypower, double Zpower)
vector< currentVecIter > currentBoundary_
Definition: HSolveActive.h:111
vector< unsigned int > chan2compt_
Definition: HSolveActive.h:114
static int hhchannels(Id compartment, vector< Id > &ret)
Definition: HSolveUtils.cpp:64
static A get(const ObjId &dest, const string &field)
Definition: SetGet.h:284
vector< Id > channelId_
Used for localIndex-ing.
Definition: HSolveActive.h:124
vector< CurrentStruct > current_
Channel current.
Definition: HSolveActive.h:73
double modulation_
Definition: HSolveStruct.h:77

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void HSolveActive::readSynapses ( )
private

Reads in SynChans and SpikeGens.

Unlike Compartments, HHChannels, etc., neither of these are zombified. In other words, their fields are not managed by HSolve, and their "process" functions are invoked to do their calculations. For SynChans, the process calls are made by their respective clocks, and hence the process message is not dropped. On the other hand, we drop the SpikeGen process messages here, and explicitly call the SpikeGen process() from the HSolve via a pointer.

Definition at line 538 of file HSolveActiveSetup.cpp.

References ObjId::bad(), HSolvePassive::compartmentId_, SynChanStruct::compt_, Msg::deleteMsg(), SynChanStruct::elm_, Cinfo::findFinfo(), DestFinfo::getFid(), SpikeGen::initCinfo(), HinesMatrix::nCompt_, spikegen_, HSolveUtils::spikegens(), synchan_, HSolveUtils::synchans(), and HSolvePassive::V_.

Referenced by setup().

539 {
540  vector< Id > spikeId;
541  vector< Id > synId;
542  vector< Id >::iterator syn;
543  vector< Id >::iterator spike;
544  SynChanStruct synchan;
545 
546  for ( unsigned int ic = 0; ic < nCompt_; ++ic )
547  {
548  synId.clear();
549  HSolveUtils::synchans( compartmentId_[ ic ], synId );
550  for ( syn = synId.begin(); syn != synId.end(); ++syn )
551  {
552  synchan.compt_ = ic;
553  synchan.elm_ = *syn;
554  synchan_.push_back( synchan );
555  }
556 
557  static const Finfo* procDest = SpikeGen::initCinfo()->findFinfo( "process");
558  assert( procDest );
559  const DestFinfo* df = dynamic_cast< const DestFinfo* >( procDest );
560  assert( df );
561 
562  spikeId.clear();
563  HSolveUtils::spikegens( compartmentId_[ ic ], spikeId );
564  // Very unlikely that there will be >1 spikegens in a compartment,
565  // but lets take care of it anyway.
566  for ( spike = spikeId.begin(); spike != spikeId.end(); ++spike )
567  {
568  spikegen_.push_back(
569  SpikeGenStruct( &V_[ ic ], spike->eref() )
570  );
571 
572  ObjId mid = spike->element()->findCaller( df->getFid() );
573  if ( ! mid.bad() )
574  Msg::deleteMsg( mid );
575  }
576  }
577 }
unsigned int compt_
Definition: HSolveStruct.h:133
bool bad() const
Definition: ObjId.cpp:18
static int spikegens(Id compartment, vector< Id > &ret)
Definition: ObjId.h:20
vector< Id > compartmentId_
Definition: HSolvePassive.h:37
unsigned int nCompt_
Definition: HinesMatrix.h:70
static const Cinfo * initCinfo()
Definition: SpikeGen.cpp:22
vector< double > V_
Definition: HSolvePassive.h:38
static void deleteMsg(ObjId mid)
Definition: Msg.cpp:52
FuncId getFid() const
Definition: DestFinfo.cpp:45
static int synchans(Id compartment, vector< Id > &ret)
vector< SynChanStruct > synchan_
Definition: HSolveActive.h:79
vector< SpikeGenStruct > spikegen_
Definition: HSolveActive.h:78
const Finfo * findFinfo(const string &name) const
Definition: Cinfo.cpp:224
Definition: Finfo.h:12

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void HSolveActive::reinit ( ProcPtr  info)

Definition at line 43 of file HSolveActiveSetup.cpp.

References externalCurrent_, reinitCalcium(), reinitChannels(), reinitCompartments(), reinitSpikeGens(), and sendValues().

Referenced by HSolve::reinit().

44 {
45  externalCurrent_.assign( externalCurrent_.size(), 0.0 );
46 
47  reinitSpikeGens( info );
49  reinitCalcium();
51  sendValues( info );
52 }
void sendValues(ProcPtr info)
void reinitSpikeGens(ProcPtr info)
vector< double > externalCurrent_
Definition: HSolveActive.h:119

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void HSolveActive::reinitCalcium ( )
private

Definition at line 67 of file HSolveActiveSetup.cpp.

References ca_, caActivation_, and caConc_.

Referenced by reinit().

68 {
69  caActivation_.assign( caActivation_.size(), 0.0 );
70 
71  for ( unsigned int i = 0; i < ca_.size(); ++i )
72  {
73  caConc_[ i ].c_ = 0.0;
74  ca_[ i ] = caConc_[ i ].CaBasal_;
75  }
76 }
vector< double > ca_
Ca conc in each pool.
Definition: HSolveActive.h:81
vector< double > caActivation_
calcium pool
Definition: HSolveActive.h:82
vector< CaConcStruct > caConc_
Ca pool info.
Definition: HSolveActive.h:80

+ Here is the caller graph for this function:

void HSolveActive::reinitChannels ( )
private

Definition at line 78 of file HSolveActiveSetup.cpp.

References ca_, caCount_, caRow_, caRowCompt_, caTable_, channel_, channelCount_, column_, externalCalcium_, LookupTable::lookup(), LookupTable::row(), state_, HSolvePassive::V_, and vTable_.

Referenced by reinit().

79 {
80  vector< double >::iterator iv;
81  vector< double >::iterator istate = state_.begin();
82  vector< int >::iterator ichannelcount = channelCount_.begin();
83  vector< ChannelStruct >::iterator ichan = channel_.begin();
84  vector< ChannelStruct >::iterator chanBoundary;
85  vector< unsigned int >::iterator icacount = caCount_.begin();
86  vector< double >::iterator ica = ca_.begin();
87  vector< double >::iterator caBoundary;
88  vector< LookupColumn >::iterator icolumn = column_.begin();
89  vector< LookupRow >::iterator icarowcompt;
90  vector< LookupRow* >::iterator icarow = caRow_.begin();
91  vector< double>::iterator iextca = externalCalcium_.begin();
92 
93  LookupRow vRow;
94  LookupRow dRow;
95  double C1, C2;
96  for ( iv = V_.begin(); iv != V_.end(); ++iv )
97  {
98 
99  vTable_.row( *iv, vRow );
100  icarowcompt = caRowCompt_.begin();
101 
102  caBoundary = ica + *icacount;
103  for ( ; ica < caBoundary; ++ica )
104  {
105  caTable_.row( *ica, *icarowcompt );
106 
107  ++icarowcompt;
108 
109  }
110 
111  chanBoundary = ichan + *ichannelcount;
112  for ( ; ichan < chanBoundary; ++ichan )
113  {
114 
115  caTable_.row( *iextca, dRow );
116 
117  if ( ichan->Xpower_ > 0.0 )
118  {
119  vTable_.lookup( *icolumn, vRow, C1, C2 );
120 
121  *istate = C1 / C2;
122 
123  ++icolumn, ++istate;
124  }
125 
126  if ( ichan->Ypower_ > 0.0 )
127  {
128  vTable_.lookup( *icolumn, vRow, C1, C2 );
129 
130  *istate = C1 / C2;
131 
132  ++icolumn, ++istate;
133  }
134 
135  if ( ichan->Zpower_ > 0.0 )
136  {
137  LookupRow* caRow = *icarow;
138 
139  if ( caRow )
140  {
141  caTable_.lookup( *icolumn, *caRow, C1, C2 );
142  }
143  else if (*iextca>0)
144  caTable_.lookup( *icolumn, dRow, C1, C2 );
145  else
146  {
147  vTable_.lookup( *icolumn, vRow, C1, C2 );
148  }
149 
150  *istate = C1 / C2;
151 
152  ++icolumn, ++istate, ++icarow;
153  }
154 
155  ++iextca;
156  }
157 
158  ++ichannelcount, ++icacount;
159  }
160 }
vector< double > state_
Fraction of gates open.
Definition: HSolveActive.h:74
vector< LookupRow > caRowCompt_
Definition: HSolveActive.h:97
vector< double > ca_
Ca conc in each pool.
Definition: HSolveActive.h:81
void lookup(const LookupColumn &column, const LookupRow &row, double &C1, double &C2)
Actually performs the lookup and the linear interpolation.
Definition: RateLookup.cpp:76
LookupTable caTable_
Definition: HSolveActive.h:88
vector< ChannelStruct > channel_
to compartment: chan2compt
Definition: HSolveActive.h:76
vector< int > channelCount_
compartment
Definition: HSolveActive.h:109
void row(double x, LookupRow &row)
Definition: RateLookup.cpp:62
vector< double > V_
Definition: HSolvePassive.h:38
vector< LookupRow * > caRow_
Definition: HSolveActive.h:104
LookupTable vTable_
Definition: HSolveActive.h:87
vector< double > externalCalcium_
Definition: HSolveActive.h:122
vector< unsigned int > caCount_
each compartment
Definition: HSolveActive.h:91
vector< LookupColumn > column_
to lookup for this species
Definition: HSolveActive.h:95

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void HSolveActive::reinitCompartments ( )
private

Definition at line 61 of file HSolveActiveSetup.cpp.

References HinesMatrix::nCompt_, HSolvePassive::tree_, and HSolvePassive::V_.

Referenced by reinit().

62 {
63  for ( unsigned int ic = 0; ic < nCompt_; ++ic )
64  V_[ ic ] = tree_[ ic ].initVm;
65 }
unsigned int nCompt_
Definition: HinesMatrix.h:70
vector< double > V_
Definition: HSolvePassive.h:38
vector< TreeNodeStruct > tree_
Definition: HSolvePassive.h:41

+ Here is the caller graph for this function:

void HSolveActive::reinitSpikeGens ( ProcPtr  info)
private

Reinit code: Defined in HSolveActiveSetup.cpp

Definition at line 54 of file HSolveActiveSetup.cpp.

References spikegen_.

Referenced by reinit().

55 {
56  vector< SpikeGenStruct >::iterator ispike;
57  for ( ispike = spikegen_.begin(); ispike != spikegen_.end(); ++ispike )
58  ispike->reinit( info );
59 }
vector< SpikeGenStruct > spikegen_
Definition: HSolveActive.h:78

+ Here is the caller graph for this function:

void HSolveActive::sendSpikes ( ProcPtr  info)
private

Definition at line 343 of file HSolveActive.cpp.

344 {
345  vector< SpikeGenStruct >::iterator ispike;
346  for ( ispike = spikegen_.begin(); ispike != spikegen_.end(); ++ispike )
347  ispike->send( info );
348 }
vector< SpikeGenStruct > spikegen_
Definition: HSolveActive.h:78
void HSolveActive::sendValues ( ProcPtr  info)
private

This function dispatches state values via any source messages on biophysical objects which have been taken over.

Definition at line 355 of file HSolveActive.cpp.

References CaConcBase::concOut(), ChanBase::IkOut(), and moose::CompartmentBase::VmOut().

Referenced by reinit().

356 {
357  vector< unsigned int >::iterator i;
358 
359  for ( i = outVm_.begin(); i != outVm_.end(); ++i ) {
360  Compartment::VmOut()->send(
361  //~ ZombieCompartment::VmOut()->send(
362  compartmentId_[ *i ].eref(),
363  V_[ *i ]
364  );
365  }
366 
367  for ( i = outIk_.begin(); i != outIk_.end(); ++i ){
368 
369  unsigned int comptIndex = chan2compt_[ *i ];
370 
371  assert( comptIndex < V_.size() );
372 
373  ChanBase::IkOut()->send(channelId_[*i].eref(),
374  (current_[ *i ].Ek - V_[ comptIndex ]) * current_[ *i ].Gk);
375 
376  }
377 
378  for ( i = outCa_.begin(); i != outCa_.end(); ++i )
379  //~ CaConc::concOut()->send(
380  CaConcBase::concOut()->send(
381  caConcId_[ *i ].eref(),
382  ca_[ *i ]
383  );
384 }
vector< unsigned int > outCa_
Definition: HSolveActive.h:131
vector< double > ca_
Ca conc in each pool.
Definition: HSolveActive.h:81
vector< unsigned int > outVm_
Definition: HSolveActive.h:127
vector< Id > compartmentId_
Definition: HSolvePassive.h:37
static SrcFinfo1< double > * concOut()
Definition: CaConcBase.cpp:25
vector< double > V_
Definition: HSolvePassive.h:38
static SrcFinfo1< double > * IkOut()
Definition: ChanBase.cpp:28
vector< unsigned int > chan2compt_
Definition: HSolveActive.h:114
static SrcFinfo1< double > * VmOut()
vector< unsigned int > outIk_
Definition: HSolveActive.h:135
vector< Id > channelId_
Used for localIndex-ing.
Definition: HSolveActive.h:124
vector< CurrentStruct > current_
Channel current.
Definition: HSolveActive.h:73
vector< Id > caConcId_
calcium from difshells
Definition: HSolveActive.h:123

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void HSolveActive::setup ( Id  seed,
double  dt 
)

Definition at line 17 of file HSolveActiveSetup.cpp.

References cleanup(), createLookupTables(), manageOutgoingMessages(), readCalcium(), readExternalChannels(), readGates(), readHHChannels(), readSynapses(), and HSolvePassive::setup().

Referenced by HSolve::setup().

18 {
19  //~ cout << ".. HA.setup()" << endl;
20 
21  this->HSolvePassive::setup( seed, dt );
22 
24  readGates();
25  readCalcium();
27  readSynapses(); // Reads SynChans, SpikeGens. Drops process msg for SpikeGens.
29  manageOutgoingMessages(); // Manages messages going out from the cell's components.
30 
31  //~ reinit();
32  cleanup();
33 
34  //~ cout << "# of compartments: " << compartmentId_.size() << "." << endl;
35  //~ cout << "# of channels: " << channelId_.size() << "." << endl;
36  //~ cout << "# of gates: " << gateId_.size() << "." << endl;
37  //~ cout << "# of states: " << state_.size() << "." << endl;
38  //~ cout << "# of Ca pools: " << caConc_.size() << "." << endl;
39  //~ cout << "# of SynChans: " << synchan_.size() << "." << endl;
40  //~ cout << "# of SpikeGens: " << spikegen_.size() << "." << endl;
41 }
void setup(Id seed, double dt)
void manageOutgoingMessages()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void HSolveActive::step ( ProcPtr  info)

Equivalent to process.

Definition at line 45 of file HSolveActive.cpp.

References HSolvePassive::backwardSubstitute(), ProcInfo::dt, and HSolvePassive::forwardEliminate().

Referenced by HSolve::process().

46 {
47  if ( nCompt_ <= 0 )
48  return;
49 
50  if ( !current_.size() )
51  {
52  current_.resize( channel_.size() );
53  }
54 
55  advanceChannels( info->dt );
57  updateMatrix();
61  advanceSynChans( info );
62 
63  sendValues( info );
64  sendSpikes( info );
65 
66  externalCurrent_.assign( externalCurrent_.size(), 0.0 );
67 }
vector< ChannelStruct > channel_
to compartment: chan2compt
Definition: HSolveActive.h:76
void sendValues(ProcPtr info)
unsigned int nCompt_
Definition: HinesMatrix.h:70
void advanceSynChans(ProcPtr info)
void forwardEliminate()
void advanceChannels(double dt)
void sendSpikes(ProcPtr info)
void backwardSubstitute()
double dt
Definition: ProcInfo.h:18
void advanceCalcium()
vector< double > externalCurrent_
Definition: HSolveActive.h:119
void calculateChannelCurrents()
vector< CurrentStruct > current_
Channel current.
Definition: HSolveActive.h:73
void updateMatrix()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void HSolveActive::updateMatrix ( )
private

Definition at line 86 of file HSolveActive.cpp.

References InjectStruct::injectBasal, InjectStruct::injectVarying, and value.

87 {
88  /*
89  * Copy contents of HJCopy_ into HJ_. Cannot do a vector assign() because
90  * iterators to HJ_ get invalidated in MS VC++
91  */
92  if ( HJ_.size() != 0 )
93  memcpy( &HJ_[ 0 ], &HJCopy_[ 0 ], sizeof( double ) * HJ_.size() );
94 
95  double GkSum, GkEkSum; vector< CurrentStruct >::iterator icurrent = current_.begin();
96  vector< currentVecIter >::iterator iboundary = currentBoundary_.begin();
97  vector< double >::iterator ihs = HS_.begin();
98  vector< double >::iterator iv = V_.begin();
99 
100  vector< CompartmentStruct >::iterator ic;
101  for ( ic = compartment_.begin(); ic != compartment_.end(); ++ic )
102  {
103  GkSum = 0.0;
104  GkEkSum = 0.0;
105  for ( ; icurrent < *iboundary; ++icurrent )
106  {
107  GkSum += icurrent->Gk;
108  GkEkSum += icurrent->Gk * icurrent->Ek;
109  }
110 
111  *ihs = *( 2 + ihs ) + GkSum;
112  *( 3 + ihs ) = *iv * ic->CmByDt + ic->EmByRm + GkEkSum;
113 
114  ++iboundary, ihs += 4, ++iv;
115  }
116 
117  map< unsigned int, InjectStruct >::iterator inject;
118  for ( inject = inject_.begin(); inject != inject_.end(); ++inject )
119  {
120  unsigned int ic = inject->first;
121  InjectStruct& value = inject->second;
122 
123  HS_[ 4 * ic + 3 ] += value.injectVarying + value.injectBasal;
124 
125  value.injectVarying = 0.0;
126  }
127 
128  // Synapses are being handled as external channels.
129  //~ double Gk, Ek;
130  //~ vector< SynChanStruct >::iterator isyn;
131  //~ for ( isyn = synchan_.begin(); isyn != synchan_.end(); ++isyn ) {
132  //~ get< double >( isyn->elm_, synGkFinfo, Gk );
133  //~ get< double >( isyn->elm_, synEkFinfo, Ek );
134  //~
135  //~ unsigned int ic = isyn->compt_;
136  //~ HS_[ 4 * ic ] += Gk;
137  //~ HS_[ 4 * ic + 3 ] += Gk * Ek;
138  //~ }
139 
140  ihs = HS_.begin();
141  vector< double >::iterator iec;
142  for ( iec = externalCurrent_.begin(); iec != externalCurrent_.end(); iec += 2 )
143  {
144  *ihs += *iec;
145  *( 3 + ihs ) += *( iec + 1 );
146 
147  ihs += 4;
148  }
149 
150  stage_ = 0; // Update done.
151 }
uint32_t value
Definition: moosemodule.h:42
double injectBasal
Definition: HSolveStruct.h:41
vector< double > V_
Definition: HSolvePassive.h:38
vector< CompartmentStruct > compartment_
Definition: HSolvePassive.h:36
int stage_
reached. Used in getA.
Definition: HinesMatrix.h:87
map< unsigned int, InjectStruct > inject_
Definition: HSolvePassive.h:45
double injectVarying
Definition: HSolveStruct.h:40
vector< currentVecIter > currentBoundary_
Definition: HSolveActive.h:111
vector< double > HJCopy_
Definition: HinesMatrix.h:82
vector< double > HS_
Definition: HinesMatrix.h:74
vector< double > externalCurrent_
Definition: HSolveActive.h:119
vector< CurrentStruct > current_
Channel current.
Definition: HSolveActive.h:73
vector< double > HJ_
Definition: HinesMatrix.h:79

Member Data Documentation

vector< double > HSolveActive::ca_
protected

Ca conc in each pool.

Definition at line 81 of file HSolveActive.h.

Referenced by HSolve::getCa(), readCalcium(), reinitCalcium(), reinitChannels(), and HSolve::setCa().

vector< double > HSolveActive::caActivation_
protected

calcium pool

Ca current entering each

Definition at line 82 of file HSolveActive.h.

Referenced by HSolve::iCa(), readCalcium(), and reinitCalcium().

int HSolveActive::caAdvance_
protected

Solver parameters: exposed as fields in MOOSE caAdvance_: This flag determines how current flowing into a calcium pool is computed. A value of 0 means that the membrane potential at the beginning of the time-step is used for the calculation. This is how GENESIS does its computations. A value of 1 means the membrane potential at the middle of the time-step is used. This is the correct way of integration, and is the default way.

Definition at line 53 of file HSolveActive.h.

Referenced by HSolve::getCaAdvance(), and HSolve::setCaAdvance().

vector< Id > HSolveActive::caConcId_
protected

calcium from difshells

Used for localIndex-ing.

Definition at line 123 of file HSolveActive.h.

Referenced by manageOutgoingMessages(), HSolve::mapIds(), readCalcium(), HSolve::unzombify(), and HSolve::zombify().

vector< unsigned int > HSolveActive::caCount_
protected

each compartment

Number of calcium pools in

Definition at line 91 of file HSolveActive.h.

Referenced by createLookupTables(), readCalcium(), and reinitChannels().

vector< int > HSolveActive::caDependIndex_
protected

depdt channel depend upon?

Which pool does each Ca

Definition at line 93 of file HSolveActive.h.

Referenced by cleanup(), createLookupTables(), and readCalcium().

int HSolveActive::caDiv_
protected

Definition at line 68 of file HSolveActive.h.

Referenced by createLookupTables(), HSolve::getCaDiv(), and HSolve::setCaDiv().

double HSolveActive::caMax_
protected

Definition at line 67 of file HSolveActive.h.

Referenced by createLookupTables(), HSolve::getCaMax(), and HSolve::setCaMax().

double HSolveActive::caMin_
protected

Definition at line 66 of file HSolveActive.h.

Referenced by createLookupTables(), HSolve::getCaMin(), and HSolve::setCaMin().

vector< LookupRow* > HSolveActive::caRow_
protected

Points into caRowCompt. For each channel, points to the appropriate pool's LookupRow in the caRowCompt vector. This value is then used by the channel. Also happens in HSolveActive::advanceChannels

Definition at line 104 of file HSolveActive.h.

Referenced by createLookupTables(), and reinitChannels().

vector< LookupRow > HSolveActive::caRowCompt_
protected

Lookup row buffer. For each compartment, the lookup rows for calcium dependent channels are loaded into this vector before being used. The vector is then reused for the next compartment. This vector therefore has a size equal to the maximum number of calcium pools across all compartments. This is done in HSolveActive::advanceChannels

Definition at line 97 of file HSolveActive.h.

Referenced by createLookupTables(), and reinitChannels().

LookupTable HSolveActive::caTable_
protected

Definition at line 88 of file HSolveActive.h.

Referenced by createLookupTables(), and reinitChannels().

vector< double* > HSolveActive::caTarget_
protected

For each channel, which calcium pool is being fed? Points into caActivation.

Definition at line 84 of file HSolveActive.h.

Referenced by readCalcium().

vector< unsigned int > HSolveActive::chan2compt_
protected

Index of the compt to which a given (index) channel belongs.

Definition at line 114 of file HSolveActive.h.

Referenced by HSolve::getIk(), and readHHChannels().

vector< unsigned int > HSolveActive::chan2state_
protected

a state index

Converts a chnnel index to

Definition at line 117 of file HSolveActive.h.

Referenced by HSolve::getX(), HSolve::getY(), HSolve::getZ(), readHHChannels(), HSolve::setX(), HSolve::setY(), and HSolve::setZ().

vector< int > HSolveActive::channelCount_
protected

compartment

Number of channels in each

Definition at line 109 of file HSolveActive.h.

Referenced by readCalcium(), readHHChannels(), and reinitChannels().

vector< Id > HSolveActive::channelId_
protected
vector< LookupColumn > HSolveActive::column_
protected

to lookup for this species

Which column in the table

Definition at line 95 of file HSolveActive.h.

Referenced by createLookupTables(), and reinitChannels().

vector< CurrentStruct > HSolveActive::current_
protected

Channel current.

Internal data structures. Will also be accessed in derived class HSolve.

Definition at line 73 of file HSolveActive.h.

Referenced by HSolve::getEk(), HSolve::getGk(), HSolve::getIk(), HSolve::getIm(), readHHChannels(), HSolve::setEk(), and HSolve::setGk().

vector< currentVecIter > HSolveActive::currentBoundary_
protected

Used to designate compt boundaries in the current_ vector.

Definition at line 111 of file HSolveActive.h.

Referenced by HSolve::getIm(), and readHHChannels().

vector< double > HSolveActive::externalCalcium_
protected

Definition at line 122 of file HSolveActive.h.

Referenced by HSolve::addConc(), readCalcium(), and reinitChannels().

vector< double > HSolveActive::externalCurrent_
protected

External currents from channels that HSolve cannot internalize.

Definition at line 119 of file HSolveActive.h.

Referenced by HSolve::addGkEk(), readExternalChannels(), and reinit().

vector< Id > HSolveActive::gateId_
protected

Used for localIndex-ing.

Definition at line 125 of file HSolveActive.h.

Referenced by createLookupTables(), and readGates().

vector< bool > HSolveActive::gCaDepend_
protected

depend on Ca conc?

Does the conductance

Definition at line 89 of file HSolveActive.h.

Referenced by cleanup(), createLookupTables(), and readGates().

const int HSolveActive::INSTANT_X = 1
staticprivate

Definition at line 172 of file HSolveActive.h.

const int HSolveActive::INSTANT_Y = 2
staticprivate

Definition at line 173 of file HSolveActive.h.

const int HSolveActive::INSTANT_Z = 4
staticprivate

Definition at line 174 of file HSolveActive.h.

vector< unsigned int > HSolveActive::outCa_
protected

concOut info. Tells you which compartments have external calcium-dependent channels so that you can send out Calcium concentrations in only those compartments.

Definition at line 131 of file HSolveActive.h.

Referenced by manageOutgoingMessages().

vector< unsigned int > HSolveActive::outIk_
protected

Definition at line 135 of file HSolveActive.h.

Referenced by manageOutgoingMessages().

vector< unsigned int > HSolveActive::outVm_
protected

VmOut info. Tells you which compartments have external voltage-dependent channels (if any), so that you can send out Vm values only in those places

Definition at line 127 of file HSolveActive.h.

Referenced by manageOutgoingMessages().

vector< SpikeGenStruct > HSolveActive::spikegen_
protected

Definition at line 78 of file HSolveActive.h.

Referenced by readSynapses(), and reinitSpikeGens().

vector< double > HSolveActive::state_
protected

Fraction of gates open.

Definition at line 74 of file HSolveActive.h.

Referenced by HSolve::getX(), HSolve::getY(), HSolve::getZ(), readHHChannels(), reinitChannels(), HSolve::setX(), HSolve::setY(), and HSolve::setZ().

vector< SynChanStruct > HSolveActive::synchan_
protected

Definition at line 79 of file HSolveActive.h.

Referenced by readSynapses().

int HSolveActive::vDiv_
protected

Definition at line 65 of file HSolveActive.h.

Referenced by createLookupTables(), HSolve::getVDiv(), and HSolve::setVDiv().

double HSolveActive::vMax_
protected

Definition at line 64 of file HSolveActive.h.

Referenced by createLookupTables(), HSolve::getVMax(), and HSolve::setVMax().

double HSolveActive::vMin_
protected

vMin_, vMax_, vDiv_, caMin_, caMax_, caDiv_:

These are the parameters for the lookup tables for rate constants. 'min' and 'max' are the boundaries within which the function is defined. 'div' is the number of divisions between min and max.

Definition at line 63 of file HSolveActive.h.

Referenced by createLookupTables(), HSolve::getVMin(), and HSolve::setVMin().

LookupTable HSolveActive::vTable_
protected

Definition at line 87 of file HSolveActive.h.

Referenced by createLookupTables(), and reinitChannels().


The documentation for this class was generated from the following files: