18 #include "../biophysics/CompartmentBase.h"
19 #include "../biophysics/Compartment.h"
20 #include "../biophysics/CaConcBase.h"
21 #include "../biophysics/ChanBase.h"
23 using namespace moose;
50 if ( !current_.size() )
52 current_.resize( channel_.size() );
55 advanceChannels( info->
dt );
56 calculateChannelCurrents();
61 advanceSynChans( info );
66 externalCurrent_.assign( externalCurrent_.size(), 0.0 );
71 vector< ChannelStruct >::iterator ichan;
72 vector< CurrentStruct >::iterator icurrent = current_.begin();
74 if ( state_.size() != 0 )
76 double* istate = &state_[ 0 ];
78 for ( ichan = channel_.begin(); ichan != channel_.end(); ++ichan )
80 ichan->process( istate, *icurrent );
92 if ( HJ_.size() != 0 )
93 memcpy( &HJ_[ 0 ], &HJCopy_[ 0 ],
sizeof(
double ) * HJ_.size() );
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();
100 vector< CompartmentStruct >::iterator ic;
101 for ( ic = compartment_.begin(); ic != compartment_.end(); ++ic )
105 for ( ; icurrent < *iboundary; ++icurrent )
107 GkSum += icurrent->Gk;
108 GkEkSum += icurrent->Gk * icurrent->Ek;
111 *ihs = *( 2 + ihs ) + GkSum;
112 *( 3 + ihs ) = *iv * ic->CmByDt + ic->EmByRm + GkEkSum;
114 ++iboundary, ihs += 4, ++iv;
117 map< unsigned int, InjectStruct >::iterator inject;
118 for ( inject = inject_.begin(); inject != inject_.end(); ++inject )
120 unsigned int ic = inject->first;
141 vector< double >::iterator iec;
142 for ( iec = externalCurrent_.begin(); iec != externalCurrent_.end(); iec += 2 )
145 *( 3 + ihs ) += *( iec + 1 );
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();
168 if ( caAdvance_ == 1 )
170 for ( ; iboundary != currentBoundary_.end(); ++iboundary )
172 for ( ; icurrent < *iboundary; ++icurrent )
175 **icatarget += icurrent->Gk * ( icurrent->Ek - *ivmid );
183 else if ( caAdvance_ == 0 )
185 vector< double >::iterator iv = V_.begin();
188 for ( ; iboundary != currentBoundary_.end(); ++iboundary )
190 for ( ; icurrent < *iboundary; ++icurrent )
194 v0 = ( 2 * *ivmid - *iv );
196 **icatarget += icurrent->Gk * ( icurrent->Ek - v0 );
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 )
211 *ica = icaconc->process( *icaactivation );
212 ++ica, ++icaactivation;
215 caActivation_.assign( caActivation_.size(), 0.0 );
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();
237 for ( iv = V_.begin(); iv != V_.end(); ++iv )
239 vTable_.
row( *iv, vRow );
240 icarowcompt = caRowCompt_.begin();
241 caBoundary = ica + *icacount;
242 for ( ; ica < caBoundary; ++ica )
244 caTable_.row( *ica, *icarowcompt );
257 chanBoundary = ichan + *ichannelcount;
258 for ( ; ichan < chanBoundary; ++ichan )
261 caTable_.row( *iextca, dRow );
263 if ( ichan->Xpower_ > 0.0 )
265 vTable_.lookup( *icolumn, vRow, C1, C2 );
268 if ( ichan->instant_ & INSTANT_X )
272 double temp = 1.0 + dt / 2.0 * C2;
273 *istate = ( *istate * ( 2.0 - temp ) + dt * C1 ) / temp;
279 if ( ichan->Ypower_ > 0.0 )
281 vTable_.lookup( *icolumn, vRow, C1, C2 );
284 if ( ichan->instant_ & INSTANT_Y )
288 double temp = 1.0 + dt / 2.0 * C2;
289 *istate = ( *istate * ( 2.0 - temp ) + dt * C1 ) / temp;
295 if ( ichan->Zpower_ > 0.0 )
301 caTable_.lookup( *icolumn, *caRow, C1, C2 );
307 caTable_.lookup( *icolumn, dRow, C1, C2 );
311 vTable_.lookup( *icolumn, vRow, C1, C2 );
317 if ( ichan->instant_ & INSTANT_Z )
321 double temp = 1.0 + dt / 2.0 * C2;
322 *istate = ( *istate * ( 2.0 - temp ) + dt * C1 ) / temp;
325 ++icolumn, ++istate, ++icarow;
331 ++ichannelcount, ++icacount;
345 vector< SpikeGenStruct >::iterator ispike;
346 for ( ispike = spikegen_.begin(); ispike != spikegen_.end(); ++ispike )
347 ispike->send( info );
357 vector< unsigned int >::iterator i;
359 for ( i = outVm_.begin(); i != outVm_.end(); ++i ) {
362 compartmentId_[ *i ].eref(),
367 for ( i = outIk_.begin(); i != outIk_.end(); ++i ){
369 unsigned int comptIndex = chan2compt_[ *i ];
371 assert( comptIndex < V_.size() );
374 (current_[ *i ].Ek - V_[ comptIndex ]) * current_[ *i ].Gk);
378 for ( i = outCa_.begin(); i != outCa_.end(); ++i )
381 caConcId_[ *i ].eref(),
static const int INSTANT_X
static const int INSTANT_Z
void sendValues(ProcPtr info)
static SrcFinfo1< double > * concOut()
void advanceSynChans(ProcPtr info)
void advanceChannels(double dt)
void sendSpikes(ProcPtr info)
void backwardSubstitute()
static SrcFinfo1< double > * IkOut()
static const int INSTANT_Y
static SrcFinfo1< double > * VmOut()
ostream & operator<<(ostream &s, const HinesMatrix &m)
void step(ProcPtr info)
Equivalent to process.
void calculateChannelCurrents()
double * row
Pointer to the first column on a row.