int CaGate_Yamada98::updateInternal(void) { // get the static table pointers and store them locally c1=getC1(); c2=getC2(); // allocate memory bool haveToInitTable = 1; if (!c1) { setC1(c1=(double *)malloc(IONGATE_CA_TABLE_SIZE*sizeof(double)));} if (!c2) { setC2(c2=(double *)malloc(IONGATE_CA_TABLE_SIZE*sizeof(double)));} // // set up the look up tables // if ( haveToInitTable ) { int i; double ca; double *p1,*p2; for(ca=IONGATE_CA_MIN,i=0,p1=c1,p2=c2;i<IONGATE_CA_TABLE_SIZE;i++,ca+=IONGATE_CA_INC,p1++,p2++) { (*p1) = exp(-DT/tau(ca)); (*p2) = (1.0-(*p1))*infty(ca); #ifdef _GUN_SOURCE if ( !finite((*p1)) ) { TheCsimError.add("CaGate_Yamada98::reset: There occurred undefined values (NaN or Inf) for C1!\n"); return -1; } if ( !finite((*p2)) ) { TheCsimError.add("CaGate_Yamada98::reset: There occurred undefined values (NaN or Inf) for C2!\n"); return -1; } #endif } } return 0; }
int CaGate_Yamada98::advance(void) { // do the table lookup int i=(int)((*Ca-IONGATE_CA_MIN)/IONGATE_CA_INC + 0.5); // exponential euler integratio step if ( i < 0 ) { // Do the correct calculation: double C1,C2; C1 = exp(-DT/tau(*Ca)); C2 = (1.0-C1)*infty(*Ca); p = C1*p + C2; // Ca < IONGATE_CA_MIN // p = c1[0]*p + c2[0]; // csimPrintf("CaGate_Yamada98::advance: [Ca] concentration (%g Mol) out of range (%g,%g)!\n",*Ca,IONGATE_CA_MIN,IONGATE_CA_MAX); } else if ( i < IONGATE_CA_TABLE_SIZE ) { // IONGATE_CA_MIN <= Ca <= IONGATE_CA_MAX p = c1[i]*p + c2[i]; } else { // Do the correct calculation: double C1,C2; C1 = exp(-DT/tau(*Ca)); C2 = (1.0-C1)*infty(*Ca); p = C1*p + C2; // IONGATE_CA_MAX < Ca // p = c1[IONGATE_CA_TABLE_SIZE-1]*p + c2[IONGATE_CA_TABLE_SIZE-1]; // csimPrintf("CaGate_Yamada98::advance: [Ca] concentration (%g Mol) out of range (%g,%g)!\n",*Ca,IONGATE_CA_MIN,IONGATE_CA_MAX); } // calculate output P = ( k!=1 ) ? pow(p,k) : p; return 1; }
int ConcIonGate::advance(void) { // do the table lookup int i=(int)((*Conc-CONCIONGATE_CONC_MIN)/CONCIONGATE_CONC_INC + 0.5); // exponential euler integratio step if ( i < 0 ) { // Do the correct calculation: double C1,C2; C1 = exp(-DT/tau(*Conc)); C2 = (1.0-C1)*infty(*Conc); p = C1*p + C2; // Conc < CONCIONGATE_CONC_MIN // p = c1[0]*p + c2[0]; // csimPrintf("ConcIonGate::advance: [Conc] concentration (%g Mol) out of range (%g,%g)!\n",*Conc,CONCIONGATE_CONC_MIN,CONCIONGATE_CONC_MAX); } else if ( i < CONCIONGATE_TABLE_SIZE ) { // CONCIONGATE_CONC_MIN <= Conc <= CONCIONGATE_CONC_MAX p = c1[i]*p + c2[i]; } else { // Do the correct calculation: double C1,C2; C1 = exp(-DT/tau(*Conc)); C2 = (1.0-C1)*infty(*Conc); p = C1*p + C2; // CONCIONGATE_CONC_MAX < Conc // p = c1[CONCIONGATE_TABLE_SIZE-1]*p + c2[CONCIONGATE_TABLE_SIZE-1]; // csimPrintf("ConcIonGate::advance: [Conc] concentration (%g Mol) out of range (%g,%g)!\n",*Conc,CONCIONGATE_CONC_MIN,CONCIONGATE_CONC_MAX); } // calculate output P = ( k!=1 ) ? pow(p,k) : p; return 1; }
void ConcIonGate::reset(void) { if ( Conc!=0 ) { // if ( ( *Conc < CONCIONGATE_CONC_MIN ) || ( CONCIONGATE_CONC_MAX < *Conc ) ) { // TheCsimError.add("ConcIonGate::reset: [Conc] concentration (%g Mol) out of range (%g,%g)!\n", // *Conc,CONCIONGATE_CONC_MIN,CONCIONGATE_CONC_MAX); // return; // } // set p to the 'resting value' at time t=0 p = infty(*ConcRest); } else { TheCsimError.add("ConcIonGate::reset: IonGate not connected to any [Conc] concentration!\n"); return; } // calculate output P = ( k!=1 ) ? pow(p,k) : p; }
void CaGate_Yamada98::reset(void) { if ( Ca!=0 ) { // if ( ( *Ca < IONGATE_CA_MIN ) || ( IONGATE_CA_MAX < *Ca ) ) { // TheCsimError.add("CaGate_Yamada98::reset: [Ca] concentration (%g Mol) out of range (%g,%g)!\n", // *Ca,IONGATE_CA_MIN,IONGATE_CA_MAX); // return; // } // set p to the 'resting value' at time t=0 p = infty(*Ca); } else { TheCsimError.add("CaGate_Yamada98::reset: IonGate not connected to any [Ca] concentration!\n"); return; } // calculate output P = ( k!=1 ) ? pow(p,k) : p; }
int VIonGate::updateInternal(void) { // get the static table pointers and store them locally c1=getC1(); c2=getC2(); // printf("VIonGate::updateInternal\n"); // allocate memory bool haveToInitTable = 0; if (!c1) { setC1(c1=(double *)malloc(VIONGATE_TABLE_SIZE*sizeof(double))); haveToInitTable = 1; } if (!c2) { setC2(c2=(double *)malloc(VIONGATE_TABLE_SIZE*sizeof(double))); haveToInitTable = 1; } if (dttable != DT) {haveToInitTable = 1;} // // set up the look up tables // if ( haveToInitTable ) { int i; double v; double *p1,*p2; if (nummethod == 0) { // generate lookup table for exponential euler method // printf("VIonGate::updateInternal Euler gate\n"); for(v=VIONGATE_VM_MIN,i=0,p1=c1,p2=c2;i<VIONGATE_TABLE_SIZE;i++,v+=VIONGATE_VM_INC,p1++,p2++) { (*p1) = exp(-DT/tau(v)); (*p2) = (1.0-(*p1))*infty(v); #ifndef _WIN32 if ( !finite((*p1)) ) { TheCsimError.add("VIonGate::updateInternal: There occurred undefined values (NaN or Inf) for C1!\n"); return -1; } if ( !finite((*p2)) ) { TheCsimError.add("VIonGate::updateInternal: There occurred undefined values (NaN or Inf) for C2!\n"); return -1; } #endif } } else { // printf("VIonGate::updateInternal Crank-Nicolson gate\n"); // generate lookup table for Crank-Nicolson method // See: Methods in Neuronal Modeling: From Ions to Networks // edited by Christof Koch and Idan Segev // Chapter 14: "Numerical Methods for Neuronal Modeling" // by Michael V. Mascagni and Arthur S. Sherman. for(v=VIONGATE_VM_MIN,i=0,p1=c1,p2=c2;i<VIONGATE_TABLE_SIZE;i++,v+=VIONGATE_VM_INC,p1++,p2++) { (*p1) = (1 - DT/2*(alpha(v) + beta(v))) / (1 + DT/2*(alpha(v) + beta(v))); (*p2) = DT*alpha(v)/(1+DT/2*(alpha(v) + beta(v))); #ifndef _WIN32 if ( !finite((*p1)) ) { TheCsimError.add("VIonGate::updateInternal: There occurred undefined values (NaN or Inf) for C1!\n"); return -1; } if ( !finite((*p2)) ) { TheCsimError.add("VIonGate::updateInternal: There occurred undefined values (NaN or Inf) for C2!\n"); return -1; } #endif } } } return 0; }
double ConcIonGate::pInfty(MembranePatchSimple *m) { MembranePatch *mp=(MembranePatch *)m; double *C; mp->buffers[ConcType]->getConc(&C); return infty(*C); }