Exemple #1
0
void Cvode::nocap_v_part1(NrnThread* _nt){
	int i;
	CvodeThreadData& z = ctd_[_nt->id];

	for (i = 0; i < z.no_cap_count_; ++i) { // initialize storage
		Node* nd = z.no_cap_node_[i];
		NODED(nd) = 0;
		NODERHS(nd) = 0;
	}
	// compute the i(vmold) and di/dv
	rhs_memb(z.no_cap_memb_, _nt);
	lhs_memb(z.no_cap_memb_, _nt);

	for (i = 0; i < z.no_cap_count_; ++i) {// parent axial current
		Node* nd = z.no_cap_node_[i];
		// following from global v_parent
		NODERHS(nd) += NODED(nd) * NODEV(nd);
		Node* pnd = _nt->_v_parent[nd->v_node_index];
		if (pnd) {
			NODERHS(nd) -= NODEB(nd) * NODEV(pnd);
			NODED(nd) -= NODEB(nd);
		}
	}		

	for (i = 0; i < z.no_cap_child_count_; ++i) {// child axial current
		Node* nd = z.no_cap_child_[i];
		// following from global v_parent
		Node* pnd = _nt->_v_parent[nd->v_node_index];
		NODERHS(pnd) -= NODEA(nd) * NODEV(nd);
		NODED(pnd) -= NODEA(nd);
	}		
	nrn_multisplit_nocap_v_part1(_nt);
}
Exemple #2
0
void LinearMechanism::create()
{
	int i;
	lmfree();
	i = 0;
	Object* o = *hoc_objgetarg(++i);
	
	if (strcmp(o->ctemplate->sym->name, "PythonObject") == 0) {
	    f_callable_ = o;
    	hoc_obj_ref(o);
	    c_ = matrix_arg(++i);
    } else {
        f_callable_ = NULL;
        c_ = matrix_arg(1);
    }
	g_ = matrix_arg(++i);
	y_ = vector_arg(++i);

	if (ifarg(i + 2) && hoc_is_object_arg(i + 2) && is_vector_arg(i + 2)) {
		y0_ = vector_arg(++i);
	}
	b_ = vector_arg(++i);
    if (ifarg(++i)) {
#if HAVE_IV
	Oc oc;
#endif

	if (hoc_is_double_arg(i)) {
		nnode_ = 1;
		nodes_ = new Node*[1];
		double x = chkarg(i, 0., 1.);
		Section* sec = chk_access();
		nodes_[0] = node_exact(sec, x);
		nrn_notify_when_double_freed(&NODEV(nodes_[0]), this);
	}else{
		Object* o = *hoc_objgetarg(i);
		check_obj_type(o, "SectionList");
		SectionList* sl = new SectionList(o);
		sl->ref();
		Vect* x = vector_arg(i+1);
		Section* sec;
		nnode_ = 0;
		nodes_ = new Node*[x->capacity()];
		for (sec = sl->begin(); sec; sec = sl->next()) {
			nodes_[nnode_] = node_exact(sec, x->elem(nnode_));
			nrn_notify_when_double_freed(&NODEV(nodes_[nnode_]), this);
			++nnode_;
		}
		if (ifarg(i+2)) {
			elayer_ = vector_arg(i+2);
		}
		sl->unref();
	}
    }
 	model_ = new LinearModelAddition(c_, g_, y_, y0_, b_,
		nnode_, nodes_, elayer_, f_callable_);
}
Exemple #3
0
void NonLinImpRep::dsdv() {
	int ieq, i, in, is, iis;
	NrnThread* nt = nrn_threads;
	ieq = neq_ - n_ode_;
	for (NrnThreadMembList* tml = nt->tml; tml; tml = tml->next) {
	  Memb_list* ml = tml->ml;
	  i = tml->index;
	  if (memb_func[i].ode_count && ml->nodecount) {
		int nc = ml->nodecount;
		Pfridot s = (Pfridot)memb_func[i].ode_count;
		int cnt = (*s)(i);
	    if (memb_func[i].current) {
		double* x1 = rv_; // use as temporary storage
		double* x2 = jv_;
		// zero rhs, save v
		for (in = 0; in < ml->nodecount; ++in) { Node* nd = ml->nodelist[in];
			for (is = ieq + in*cnt, iis = 0; iis < cnt; ++iis, ++is) {
				*pvdot_[is] = 0.;
			}
			x1[in] = NODEV(nd);
		}
		// increment v only once in case there are multiple
		// point processes at the same location
		for (in = 0; in < ml->nodecount; ++in) { Node* nd = ml->nodelist[in];
			if (x1[in] == NODEV(nd)) {
				NODEV(nd) += delta_;
			}
		}
		// compute rhs. this is the rhs(v+dv)
		ode(i, ml);
		// save rhs, restore v, and zero rhs
		for (in = 0; in < ml->nodecount; ++in) { Node* nd = ml->nodelist[in];
			for (is = ieq + in*cnt, iis = 0; iis < cnt; ++iis, ++is) {
				x2[is] = *pvdot_[is];
				*pvdot_[is] = 0;
			}
			NODEV(nd) = x1[in];
		}
		// compute the rhs(v)
		ode(i, ml);
		// fill the ds/dv elements
		for (in = 0; in < ml->nodecount; ++in) { Node* nd = ml->nodelist[in];
			for (is = ieq + in*cnt, iis = 0; iis < cnt; ++iis, ++is) {
				double ds = (x2[is] - *pvdot_[is])/delta_;
				if (ds != 0.) {
					double* elm = cmplx_spGetElement(m_, is+1, v_index_[nd->v_node_index]);
					elm[0] = -ds;
				}
			}
		}
	    }
		ieq += cnt*nc;
	  }
	}
}
Exemple #4
0
void LinearMechanism::update_ptrs() {
	if (nodes_) {
		nrn_notify_pointer_disconnect(this);
		for (int i=0; i < nnode_; ++i) {
			double* pd = nrn_recalc_ptr(&(NODEV(nodes_[i])));
			if (pd != &(NODEV(nodes_[i]))) {
				nrn_notify_when_double_freed(pd, this);
			}
		}
	}
}
Exemple #5
0
static void update(NrnThread* _nt)
{
	int i, i1, i2;
	i1 = 0;
	i2 = _nt->end;
#if CACHEVEC
    if (use_cachevec) {
	/* do not need to worry about linmod or extracellular*/
	if (secondorder) {
		for (i=i1; i < i2; ++i) {
			VEC_V(i) += 2.*VEC_RHS(i);
		}
	}else{
		for (i=i1; i < i2; ++i) {
			VEC_V(i) += VEC_RHS(i);
		}
	}
    }else
#endif
    {	/* use original non-vectorized update */
 	if (secondorder) {
#if _CRAY
#pragma _CRI ivdep
#endif
		for (i=i1; i < i2; ++i) {
			NODEV(_nt->_v_node[i]) += 2.*NODERHS(_nt->_v_node[i]);
		}
	}else{
#if _CRAY
#pragma _CRI ivdep
#endif
		for (i=i1; i < i2; ++i) {
			NODEV(_nt->_v_node[i]) += NODERHS(_nt->_v_node[i]);
		}
		if (use_sparse13) {
			nrndae_update();
		}
	}
    } /* end of non-vectorized update */

#if EXTRACELLULAR
	nrn_update_2d(_nt);
#endif

#if I_MEMBRANE
	if (_nt->tml) {
		assert(_nt->tml->index == CAP);
		nrn_capacity_current(_nt, _nt->tml->ml);
	}
#endif

}
Exemple #6
0
double KSSingleTrans::rate(Point_process* pnt) {
	if (kst_->type_ < 2) {
		return rate(NODEV(pnt->node));
	}else{
		return rate(pnt->prop->dparam);
	}
}
Exemple #7
0
static void nrn_state(_NrnThread* _nt, _Memb_list* _ml, int _type) {
 double _break, _save;
double* _p; Datum* _ppvar; Datum* _thread;
Node *_nd; double _v; int* _ni; int _iml, _cntml;
#if CACHEVEC
    _ni = _ml->_nodeindices;
#endif
_cntml = _ml->_nodecount;
_thread = _ml->_thread;
for (_iml = 0; _iml < _cntml; ++_iml) {
 _p = _ml->_data[_iml]; _ppvar = _ml->_pdata[_iml];
 _nd = _ml->_nodelist[_iml];
#if CACHEVEC
  if (use_cachevec) {
    _v = VEC_V(_ni[_iml]);
  }else
#endif
  {
    _nd = _ml->_nodelist[_iml];
    _v = NODEV(_nd);
  }
 _break = t + .5*dt; _save = t;
 v=_v;
{
  ek = _ion_ek;
 { {
 for (; t < _break; t += dt) {
   states(_p, _ppvar, _thread, _nt);
  
}}
 t = _save;
 } }}

}
Exemple #8
0
static void nrn_state(_NrnThread* _nt, _Memb_list* _ml, int _type) {
double* _p; Datum* _ppvar; Datum* _thread;
Node *_nd; double _v = 0.0; int* _ni; int _iml, _cntml;
#if CACHEVEC
    _ni = _ml->_nodeindices;
#endif
_cntml = _ml->_nodecount;
_thread = _ml->_thread;
for (_iml = 0; _iml < _cntml; ++_iml) {
 _p = _ml->_data[_iml]; _ppvar = _ml->_pdata[_iml];
 _nd = _ml->_nodelist[_iml];
#if CACHEVEC
  if (use_cachevec) {
    _v = VEC_V(_ni[_iml]);
  }else
#endif
  {
    _nd = _ml->_nodelist[_iml];
    _v = NODEV(_nd);
  }
 v=_v;
{
  cai = _ion_cai;
 {  _deriv1_advance = 1;
 derivimplicit_thread(2, _slist1, _dlist1, _p, states, _ppvar, _thread, _nt);
_deriv1_advance = 0;
  }   }}

}
Exemple #9
0
static void nrn_cur(_NrnThread* _nt, _Memb_list* _ml, int _type) {
double* _p; Datum* _ppvar; Datum* _thread;
Node *_nd; int* _ni; double _rhs, _v; int _iml, _cntml;
#if CACHEVEC
    _ni = _ml->_nodeindices;
#endif
_cntml = _ml->_nodecount;
_thread = _ml->_thread;
for (_iml = 0; _iml < _cntml; ++_iml) {
 _p = _ml->_data[_iml]; _ppvar = _ml->_pdata[_iml];
#if CACHEVEC
  if (use_cachevec) {
    _v = VEC_V(_ni[_iml]);
  }else
#endif
  {
    _nd = _ml->_nodelist[_iml];
    _v = NODEV(_nd);
  }
 _g = _nrn_current(_p, _ppvar, _thread, _nt, _v + .001);
 	{ _rhs = _nrn_current(_p, _ppvar, _thread, _nt, _v);
 	}
 _g = (_g - _rhs)/.001;
#if CACHEVEC
  if (use_cachevec) {
	VEC_RHS(_ni[_iml]) -= _rhs;
  }else
#endif
  {
	NODERHS(_nd) -= _rhs;
  }
 
}}
Exemple #10
0
static void nrn_state(_NrnThread* _nt, _Memb_list* _ml, int _type){
 double _break, _save;
Node *_nd; double _v; int* _ni; int _iml, _cntml;
#if CACHEVEC
    _ni = _ml->_nodeindices;
#endif
_cntml = _ml->_nodecount;
for (_iml = 0; _iml < _cntml; ++_iml) {
 _p = _ml->_data[_iml]; _ppvar = _ml->_pdata[_iml];
 _nd = _ml->_nodelist[_iml];
#if CACHEVEC
  if (use_cachevec) {
    _v = VEC_V(_ni[_iml]);
  }else
#endif
  {
    _nd = _ml->_nodelist[_iml];
    _v = NODEV(_nd);
  }
 _break = t + .5*dt; _save = t;
 v=_v;
{
  ek = _ion_ek;
 { {
 for (; t < _break; t += dt) {
 error =  states();
 if(error){fprintf(stderr,"at line 64 in file KA_i1.mod:\n  SOLVE states METHOD cnexp\n"); nrn_complain(_p); abort_run(error);}
 
}}
 t = _save;
 } }}

}
static void nrn_init(_NrnThread* _nt, _Memb_list* _ml, int _type){
Node *_nd; double _v; int* _ni; int _iml, _cntml;
#if CACHEVEC
    _ni = _ml->_nodeindices;
#endif
_cntml = _ml->_nodecount;
for (_iml = 0; _iml < _cntml; ++_iml) {
 _p = _ml->_data[_iml]; _ppvar = _ml->_pdata[_iml];
#if CACHEVEC
  if (use_cachevec) {
    _v = VEC_V(_ni[_iml]);
  }else
#endif
  {
    _nd = _ml->_nodelist[_iml];
    _v = NODEV(_nd);
  }
 v = _v;
  cai = _ion_cai;
  cao = _ion_cao;
  cai = _ion_cai;
  ki = _ion_ki;
  ko = _ion_ko;
  nai = _ion_nai;
  nao = _ion_nao;
 initmodel();
   _ion_cai = cai;
  nrn_wrote_conc(_ca_sym, (&(_ion_cai)) - 1, _style_ca);
  }}
Exemple #12
0
static void nrn_init(_NrnThread* _nt, _Memb_list* _ml, int _type){
double* _p; Datum* _ppvar; Datum* _thread;
Node *_nd; double _v; int* _ni; int _iml, _cntml;
#if CACHEVEC
    _ni = _ml->_nodeindices;
#endif
_cntml = _ml->_nodecount;
_thread = _ml->_thread;
for (_iml = 0; _iml < _cntml; ++_iml) {
 _p = _ml->_data[_iml]; _ppvar = _ml->_pdata[_iml];

#if 0
 _check_rates(_p, _ppvar, _thread, _nt);
#endif
#if CACHEVEC
  if (use_cachevec) {
    _v = VEC_V(_ni[_iml]);
  }else
#endif
  {
    _nd = _ml->_nodelist[_iml];
    _v = NODEV(_nd);
  }
 v = _v;
  ena = _ion_ena;
 initmodel(_p, _ppvar, _thread, _nt);
 }}
Exemple #13
0
static void nrn_init(_NrnThread* _nt, _Memb_list* _ml, int _type){
double* _p; Datum* _ppvar; Datum* _thread;
Node *_nd; double _v; int* _ni; int _iml, _cntml;
#if CACHEVEC
    _ni = _ml->_nodeindices;
#endif
_cntml = _ml->_nodecount;
_thread = _ml->_thread;
for (_iml = 0; _iml < _cntml; ++_iml) {
 _p = _ml->_data[_iml]; _ppvar = _ml->_pdata[_iml];
#if CACHEVEC
  if (use_cachevec) {
    _v = VEC_V(_ni[_iml]);
  }else
#endif
  {
    _nd = _ml->_nodelist[_iml];
    _v = NODEV(_nd);
  }
 v = _v;
  iCa = _ion_iCa;
  Cai = _ion_Cai;
  Cai = _ion_Cai;
 initmodel(_p, _ppvar, _thread, _nt);
  _ion_Cai = Cai;
  nrn_wrote_conc(_Ca_sym, (&(_ion_Cai)) - 1, _style_Ca);
}}
Exemple #14
0
void Cvode::nocap_v(NrnThread* _nt){
	int i;
	CvodeThreadData& z = CTD(_nt->id);

	for (i = 0; i < z.no_cap_count_; ++i) { // initialize storage
		Node* nd = z.no_cap_node_[i];
		NODED(nd) = 0;
		NODERHS(nd) = 0;
	}
	// compute the i(vmold) and di/dv
	rhs_memb(z.no_cap_memb_, _nt);
	lhs_memb(z.no_cap_memb_, _nt);

	for (i = 0; i < z.no_cap_count_; ++i) {// parent axial current
		Node* nd = z.no_cap_node_[i];
		// following from global v_parent
		NODERHS(nd) += NODED(nd) * NODEV(nd);
		Node* pnd = _nt->_v_parent[nd->v_node_index];
		if (pnd) {
			NODERHS(nd) -= NODEB(nd) * NODEV(pnd);
			NODED(nd) -= NODEB(nd);
		}
	}		

	for (i = 0; i < z.no_cap_child_count_; ++i) {// child axial current
		Node* nd = z.no_cap_child_[i];
		// following from global v_parent
		Node* pnd = _nt->_v_parent[nd->v_node_index];
		NODERHS(pnd) -= NODEA(nd) * NODEV(nd);
		NODED(pnd) -= NODEA(nd);
	}		

#if PARANEURON
	if (nrn_multisplit_solve_) { // add up the multisplit equations
		nrn_multisplit_nocap_v();
	}
#endif

	for (i = 0; i < z.no_cap_count_; ++i) {
		Node* nd = z.no_cap_node_[i];
		NODEV(nd) = NODERHS(nd) / NODED(nd);
//		printf("%d %d %g v=%g\n", nrnmpi_myid, i, _nt->_t, NODEV(nd));
	}		
	// no_cap v's are now consistent with adjacent v's
}
Exemple #15
0
void Cvode::rhs(NrnThread* _nt) {
	int i;

	CvodeThreadData& z = CTD(_nt->id);
	if (diam_changed) {
		recalc_diam();
	}
	if (z.v_node_count_ == 0) { return; }
	for (i = 0; i < z.v_node_count_; ++i) {
		NODERHS(z.v_node_[i]) = 0.;
	}
	if (_nt->_nrn_fast_imem) {
		double* p = _nt->_nrn_fast_imem->_nrn_sav_rhs;
		for (i = 0; i < z.v_node_count_; ++i) {
			Node* nd = z.v_node_[i];
			p[nd->v_node_index] = 0;
		}
	}

	rhs_memb(z.cv_memb_list_, _nt);
	nrn_nonvint_block_current(_nt->end, _nt->_actual_rhs, _nt->id);

	if (_nt->_nrn_fast_imem) {
		double* p = _nt->_nrn_fast_imem->_nrn_sav_rhs;
		for (i = 0; i < z.v_node_count_; ++i) {
			Node* nd = z.v_node_[i];
			p[nd->v_node_index] -= NODERHS(nd);
		}
	}

	/* at this point d contains all the membrane conductances */
	/* now the internal axial currents.
		rhs += ai_j*(vi_j - vi)
	*/
	for (i = z.rootnodecount_; i < z.v_node_count_; ++i) {
		Node* nd = z.v_node_[i];
		Node* pnd = z.v_parent_[i];
		double dv = NODEV(pnd) - NODEV(nd);
		/* our connection coefficients are negative so */
		NODERHS(nd) -= NODEB(nd)*dv;
		NODERHS(pnd) += NODEA(nd)*dv;
	}
}
Exemple #16
0
void Cvode::nocap_v_part3(NrnThread* _nt){
	int i;
	nrn_multisplit_nocap_v_part3(_nt);
	CvodeThreadData& z = ctd_[_nt->id];
	for (i = 0; i < z.no_cap_count_; ++i) {
		Node* nd = z.no_cap_node_[i];
		NODEV(nd) = NODERHS(nd) / NODED(nd);
//		printf("%d %d %g v=%g\n", nrnmpi_myid, i, t, NODEV(nd));
	}		
	// no_cap v's are now consistent with adjacent v's
}
static void _ode_matsol(_NrnThread* _nt, _Memb_list* _ml, int _type) {
   double* _p; Datum* _ppvar; Datum* _thread;
   Node* _nd; double _v; int _iml, _cntml;
  _cntml = _ml->_nodecount;
  _thread = _ml->_thread;
  for (_iml = 0; _iml < _cntml; ++_iml) {
    _p = _ml->_data[_iml]; _ppvar = _ml->_pdata[_iml];
    _nd = _ml->_nodelist[_iml];
    v = NODEV(_nd);
 _ode_matsol1 (_p, _ppvar, _thread, _nt);
 }}
Exemple #18
0
static void _ode_spec(_NrnThread* _nt, _Memb_list* _ml, int _type) {
   Datum* _thread;
   Node* _nd; double _v; int _iml, _cntml;
  _cntml = _ml->_nodecount;
  _thread = _ml->_thread;
  for (_iml = 0; _iml < _cntml; ++_iml) {
    _p = _ml->_data[_iml]; _ppvar = _ml->_pdata[_iml];
    _nd = _ml->_nodelist[_iml];
    v = NODEV(_nd);
  ek = _ion_ek;
     _ode_spec1 ();
  }}
Exemple #19
0
static int _ode_matsol(_NrnThread* _nt, _Memb_list* _ml, int _type) {
   Datum* _thread;
   Node* _nd; double _v; int _iml, _cntml;
  _cntml = _ml->_nodecount;
  _thread = _ml->_thread;
  for (_iml = 0; _iml < _cntml; ++_iml) {
    _p = _ml->_data[_iml]; _ppvar = _ml->_pdata[_iml];
    _nd = _ml->_nodelist[_iml];
    v = NODEV(_nd);
  Cai = _ion_Cai;
  Cao = _ion_Cao;
 _ode_matsol1 ();
 }}
static void nrn_cur(_NrnThread* _nt, _Memb_list* _ml, int _type){
Node *_nd; int* _ni; double _rhs, _v; int _iml, _cntml;
#if CACHEVEC
    _ni = _ml->_nodeindices;
#endif
_cntml = _ml->_nodecount;
for (_iml = 0; _iml < _cntml; ++_iml) {
 _p = _ml->_data[_iml]; _ppvar = _ml->_pdata[_iml];
#if CACHEVEC
  if (use_cachevec) {
    _v = VEC_V(_ni[_iml]);
  }else
#endif
  {
    _nd = _ml->_nodelist[_iml];
    _v = NODEV(_nd);
  }
  cai = _ion_cai;
  cao = _ion_cao;
  cai = _ion_cai;
  ki = _ion_ki;
  ko = _ion_ko;
  nai = _ion_nai;
  nao = _ion_nao;
 _g = _nrn_current(_v + .001);
 	{ double _dina;
 double _dik;
 double _dica;
  _dica = ica;
  _dik = ik;
  _dina = ina;
 _rhs = _nrn_current(_v);
  _ion_dicadv += (_dica - ica)/.001 ;
  _ion_dikdv += (_dik - ik)/.001 ;
  _ion_dinadv += (_dina - ina)/.001 ;
 	}
 _g = (_g - _rhs)/.001;
  _ion_ica += ica ;
  _ion_cai = cai;
  _ion_ik += ik ;
  _ion_ina += ina ;
#if CACHEVEC
  if (use_cachevec) {
	VEC_RHS(_ni[_iml]) -= _rhs;
  }else
#endif
  {
	NODERHS(_nd) -= _rhs;
  }
 
}}
Exemple #21
0
void KSSingle::state(Node* nd, double* p, Datum* pd, NrnThread* nt) {
	// integrate from t-dt to t
	int i;
	double v = NODEV(nd);
	KSSingleNodeData* snd = (KSSingleNodeData*)pd[sndindex_]._pvoid;
	// if truly single channel, as opposed to N single channels
	// then follow the one populated state. Otherwise do the
	// general case
	if (snd->nsingle_ == 1) {
		one(v, snd, nt);
	}else{
		multi(v, snd, nt);
	}
}
Exemple #22
0
static int _ode_spec(_NrnThread* _nt, _Memb_list* _ml, int _type) {
   double* _p; Datum* _ppvar; Datum* _thread;
   Node* _nd; double _v; int _iml, _cntml;
  _cntml = _ml->_nodecount;
  _thread = _ml->_thread;
  for (_iml = 0; _iml < _cntml; ++_iml) {
    _p = _ml->_data[_iml]; _ppvar = _ml->_pdata[_iml];
    _nd = _ml->_nodelist[_iml];
    v = NODEV(_nd);
  iCa = _ion_iCa;
  Cai = _ion_Cai;
  Cai = _ion_Cai;
     _ode_spec1 (_p, _ppvar, _thread, _nt);
  _ion_Cai = Cai;
 }}
Exemple #23
0
void KSSingleNodeData::deliver(double tt, NetCvode* nc, NrnThread* nt) {
	++KSSingle::singleevent_deliver_;
	Cvode* cv = (Cvode*)((*ppnt_)->nvi_);
	if (cv) {
		nc->retreat(tt, cv);
		cv->set_init_flag();
	}
	assert(nt->_t == tt);
	vlast_ = NODEV((*ppnt_)->node);
	if (nsingle_ == 1) {
		kss_->do1trans(this);
	}else{
		kss_->doNtrans(this);
	}
	qi_ = nc->event(t1_, this, nt);
}
static void nrn_state(_NrnThread* _nt, _Memb_list* _ml, int _type){
 double _break, _save;
Node *_nd; double _v; int* _ni; int _iml, _cntml;
#if CACHEVEC
    _ni = _ml->_nodeindices;
#endif
_cntml = _ml->_nodecount;
for (_iml = 0; _iml < _cntml; ++_iml) {
 _p = _ml->_data[_iml]; _ppvar = _ml->_pdata[_iml];
 _nd = _ml->_nodelist[_iml];
#if CACHEVEC
  if (use_cachevec) {
    _v = VEC_V(_ni[_iml]);
  }else
#endif
  {
    _nd = _ml->_nodelist[_iml];
    _v = NODEV(_nd);
  }
 _break = t + .5*dt; _save = t;
 v=_v;
{
  ica = _ion_ica;
  cai = _ion_cai;
  cai = _ion_cai;
 { {
 for (; t < _break; t += dt) {
 error = _deriv1_advance = 1;
 derivimplicit(_ninits, 1, _slist1, _dlist1, _p, &t, dt, state, &_temp1);
_deriv1_advance = 0;
 if(error){fprintf(stderr,"at line 72 in file cad_0403.mod:\n    SOLVE state METHOD derivimplicit\n"); nrn_complain(_p); abort_run(error);}
 
}}
 t = _save;
 } {
   
/*VERBATIM*/
    /*    printf("CAD.MOD cai:%.10lf\t",cai);*/

 }
  _ion_cai = cai;
}}

}
static void nrn_cur(_NrnThread* _nt, _Memb_list* _ml, int _type){
Node *_nd; int* _ni; double _rhs, _v; int _iml, _cntml;
#if CACHEVEC
    _ni = _ml->_nodeindices;
#endif
_cntml = _ml->_nodecount;
for (_iml = 0; _iml < _cntml; ++_iml) {
 _p = _ml->_data[_iml]; _ppvar = _ml->_pdata[_iml];
#if CACHEVEC
  if (use_cachevec) {
    _v = VEC_V(_ni[_iml]);
  }else
#endif
  {
    _nd = _ml->_nodelist[_iml];
    _v = NODEV(_nd);
  }
 
}}
Exemple #26
0
void KSSingle::cv_update(Node* nd, double* p, Datum* pd, NrnThread* nt) {
	// if v changed then need to move the outstanding
	// single channel event time to a recalculated time
	int i;
	double v = NODEV(nd);
	KSSingleNodeData* snd = (KSSingleNodeData*)pd[sndindex_]._pvoid;
	if (uses_ligands_ || !vsame(v, snd->vlast_)) {
		assert(nt->_t < snd->t1_);
		snd->vlast_ = v;
		snd->t0_ = nt->_t;
		if (snd->nsingle_ == 1) {
			next1trans(snd);
		}else{
			nextNtrans(snd);
		}
		net_cvode_instance->move_event(snd->qi_, snd->t1_, nt);
		++KSSingle::singleevent_move_;
	}
}
Exemple #27
0
static void nrn_state(_NrnThread* _nt, _Memb_list* _ml, int _type) {
 double _break, _save;
double* _p; Datum* _ppvar; Datum* _thread;
Node *_nd; double _v; int* _ni; int _iml, _cntml;
#if CACHEVEC
    _ni = _ml->_nodeindices;
#endif
_cntml = _ml->_nodecount;
_thread = _ml->_thread;
for (_iml = 0; _iml < _cntml; ++_iml) {
 _p = _ml->_data[_iml]; _ppvar = _ml->_pdata[_iml];
 _nd = _ml->_nodelist[_iml];
#if CACHEVEC
  if (use_cachevec) {
    _v = VEC_V(_ni[_iml]);
  }else
#endif
  {
    _nd = _ml->_nodelist[_iml];
    _v = NODEV(_nd);
  }
 _break = t + .5*dt; _save = t;
 v=_v;
{
  ik = _ion_ik;
  ko = _ion_ko;
  ina = _ion_ina;
  nai = _ion_nai;
 { {
 for (; t < _break; t += dt) {
  _deriv1_advance = 1;
 derivimplicit_thread(2, _slist1, _dlist1, _p, state, _ppvar, _thread, _nt);
_deriv1_advance = 0;
  
}}
 t = _save;
 } {
   }
  _ion_ko = ko;
  _ion_nai = nai;
}}

}
static void nrn_state(_NrnThread* _nt, _Memb_list* _ml, int _type){
 double _break, _save;
Node *_nd; double _v; int* _ni; int _iml, _cntml;
#if CACHEVEC
    _ni = _ml->_nodeindices;
#endif
_cntml = _ml->_nodecount;
for (_iml = 0; _iml < _cntml; ++_iml) {
 _p = _ml->_data[_iml]; _ppvar = _ml->_pdata[_iml];
 _nd = _ml->_nodelist[_iml];
#if CACHEVEC
  if (use_cachevec) {
    _v = VEC_V(_ni[_iml]);
  }else
#endif
  {
    _nd = _ml->_nodelist[_iml];
    _v = NODEV(_nd);
  }
 _break = t + .5*dt; _save = t;
 v=_v;
{
  cai = _ion_cai;
  cao = _ion_cao;
  cai = _ion_cai;
  ki = _ion_ki;
  ko = _ion_ko;
  nai = _ion_nai;
  nao = _ion_nao;
 { {
 for (; t < _break; t += dt) {
 error =  states();
 if(error){fprintf(stderr,"at line 131 in file pGPeA_fukuda.mod:\n    \n"); nrn_complain(_p); abort_run(error);}
 
}}
 t = _save;
 }   _ion_cai = cai;
  }}

}
static void nrn_state(_NrnThread* _nt, _Memb_list* _ml, int _type){
 double _break, _save;
Node *_nd; double _v; int* _ni; int _iml, _cntml;
#if CACHEVEC
    _ni = _ml->_nodeindices;
#endif
_cntml = _ml->_nodecount;
for (_iml = 0; _iml < _cntml; ++_iml) {
 _p = _ml->_data[_iml]; _ppvar = _ml->_pdata[_iml];
 _nd = _ml->_nodelist[_iml];
#if CACHEVEC
  if (use_cachevec) {
    _v = VEC_V(_ni[_iml]);
  }else
#endif
  {
    _nd = _ml->_nodelist[_iml];
    _v = NODEV(_nd);
  }
 _break = t + .5*dt; _save = t;
 v=_v;
{
  ica = _ion_ica;
  cai = _ion_cai;
  cai = _ion_cai;
 { {
 for (; t < _break; t += dt) {
 error =  euler(_ninits, 1, _slist1, _dlist1, _p, &t, dt, state, &_temp1);
 if(error){fprintf(stderr,"at line 87 in file capump.mod:\n	SOLVE state METHOD euler\n"); nrn_complain(_p); abort_run(error);}
 
}}
 t = _save;
  state();
 } {
   }
  _ion_cai = cai;
}}

}
Exemple #30
0
static void nrn_cur(_NrnThread* _nt, _Memb_list* _ml, int _type){
Node *_nd; int* _ni; double _rhs, _v; int _iml, _cntml;
#if CACHEVEC
    _ni = _ml->_nodeindices;
#endif
_cntml = _ml->_nodecount;
for (_iml = 0; _iml < _cntml; ++_iml) {
 _p = _ml->_data[_iml]; _ppvar = _ml->_pdata[_iml];
#if CACHEVEC
  if (use_cachevec) {
    _v = VEC_V(_ni[_iml]);
  }else
#endif
  {
    _nd = _ml->_nodelist[_iml];
    _v = NODEV(_nd);
  }
  Cai = _ion_Cai;
  Cao = _ion_Cao;
 _g = _nrn_current(_v + .001);
 	{ double _diCa;
  _diCa = iCa;
 _rhs = _nrn_current(_v);
  _ion_diCadv += (_diCa - iCa)/.001 ;
 	}
 _g = (_g - _rhs)/.001;
  _ion_iCa += iCa ;
#if CACHEVEC
  if (use_cachevec) {
	VEC_RHS(_ni[_iml]) -= _rhs;
  }else
#endif
  {
	NODERHS(_nd) -= _rhs;
  }
 
}}