void Cvode::do_ode(NrnThread* _nt){ // all the membrane mechanism ode's CvodeThreadData& z = CTD(_nt->id); CvMembList* cml; Memb_func* mf; for (cml = z.cv_memb_list_; cml; cml = cml->next) { // probably can start at 6 or hh mf = memb_func + cml->index; if (mf->ode_spec) { Pfridot s = (Pfridot)mf->ode_spec; Memb_list* ml = cml->ml; if (mf->hoc_mech) { int j, count; count = ml->nodecount; for (j = 0; j < count; ++j) { Node* nd = ml->nodelist[j]; (*s)(nd, ml->prop[j]); } }else{ (*s)(_nt, ml, cml->index); } if (errno) { if (nrn_errno_check(cml->index)) { hoc_warning("errno set during ode evaluation", (char*)0); } } } } long_difus_solve(1, _nt); }
void Cvode::do_nonode(NrnThread* _nt) { // all the hacked integrators, etc, in SOLVE procedure //almost a verbatim copy of nonvint in fadvance.c if (!_nt) { if (nrn_nthread > 1) { nonode_cv = this; nrn_multithread_job(nonode_thread); return; } _nt = nrn_threads; } CvodeThreadData& z = CTD(_nt->id); CvMembList* cml; for (cml = z.cv_memb_list_; cml; cml = cml->next) { Memb_func* mf = memb_func + cml->index; if (mf->state) { Memb_list* ml = cml->ml; if (!mf->ode_spec){ Pfridot s = (Pfridot)mf->state; (*s)(_nt, ml, cml->index); #if 0 if (errno) { if (nrn_errno_check(cml->index)) { hoc_warning("errno set during calculation of states", (char*)0); } } #endif }else if (mf->singchan_) { Pfridot s = (Pfridot)mf->singchan_; (*s)(_nt, ml, cml->index); } } } }
void Cvode::solvemem(NrnThread* nt) { // all the membrane mechanism matrices CvodeThreadData& z = CTD(nt->id); CvMembList* cml; for (cml = z.cv_memb_list_; cml; cml = cml->next) { // probably can start at 6 or hh Memb_func* mf = memb_func + cml->index; if (mf->ode_matsol) { Memb_list* ml = cml->ml; Pfridot s = (Pfridot)mf->ode_matsol; if (mf->hoc_mech) { int j, count; count = ml->nodecount; for (j = 0; j < count; ++j) { Node* nd = ml->nodelist[j]; (*s)(nd, ml->prop[j]); } }else{ (*s)(nt, ml, cml->index); } if (errno) { if (nrn_errno_check(cml->index)) { hoc_warning("errno set during ode jacobian solve", (char*)0); } } } } long_difus_solve(2, nt); }
void nonvint(NrnThread* _nt) { #if VECTORIZE int i; double w; int measure = 0; NrnThreadMembList* tml; #if 1 || PARANEURON /* nrnmpi_v_transfer if needed was done earlier */ if (nrnthread_v_transfer_) {(*nrnthread_v_transfer_)(_nt);} #endif if (_nt->id == 0 && nrn_mech_wtime_) { measure = 1; } errno = 0; for (tml = _nt->tml; tml; tml = tml->next) if (memb_func[tml->index].state) { Pfri s = memb_func[tml->index].state; if (measure) { w = nrnmpi_wtime(); } (*s)(_nt, tml->ml, tml->index); if (measure) { nrn_mech_wtime_[tml->index] += nrnmpi_wtime() - w; } if (errno) { if (nrn_errno_check(i)) { hoc_warning("errno set during calculation of states", (char*)0); } } } long_difus_solve(0, _nt); /* if any longitudinal diffusion */ nrn_nonvint_block_fixed_step_solve(_nt->id); #endif }
void Cvode::lhs_memb(CvMembList* cmlist, NrnThread* _nt) { CvMembList* cml; for (cml = cmlist; cml; cml = cml->next) { Memb_func* mf = memb_func + cml->index; Memb_list* ml = cml->ml; Pfridot s = (Pfridot)mf->jacob; if (s) { Pfridot s = (Pfridot)mf->jacob; (*s)(_nt, ml, cml->index); if (errno) { if (nrn_errno_check(cml->index)) { hoc_warning("errno set during calculation of di/dv", (char*)0); } } } } activsynapse_lhs(); activclamp_lhs(); }
void Cvode::rhs_memb(CvMembList* cmlist, NrnThread* _nt) { CvMembList* cml; errno = 0; for (cml = cmlist; cml; cml = cml->next) { Memb_func* mf = memb_func + cml->index; Pfridot s = (Pfridot)mf->current; if (s) { Memb_list* ml = cml->ml; (*s)(_nt, ml, cml->index); if (errno) { if (nrn_errno_check(cml->index)) { hoc_warning("errno set during calculation of currents", (char*)0); } } } } activsynapse_rhs(); activstim_rhs(); activclamp_rhs(); }
method3_setup_tree_matrix() /* construct diagonal elements */ { int i; if (diam_changed) { recalc_diam(); } #if _CRAY #pragma _CRI ivdep #endif for (i = 0; i < v_node_count; ++i) { Node* nd = v_node[i]; NODED(nd) = 0.; NODERHS(nd) = 0.; nd->thisnode.GC = 0.; nd->thisnode.EC = 0.; } for (i=0; i < n_memb_func; ++i) if (memb_func[i].current && memb_list[i].nodecount) { if (memb_func[i].vectorized) { memb_func[i].current( memb_list[i].nodecount, memb_list[i].nodelist, memb_list[i].data, memb_list[i].pdata ); }else{ int j, count; Pfrd s = memb_func[i].current; Memb_list* m = memb_list + i; count = m->nodecount; if (memb_func[i].is_point) { for (j = 0; j < count; ++j) { Node* nd = m->nodelist[j]; NODERHS(nd) -= (*s)(m->data[j], m->pdata[j], &NODED(nd),nd->v); }; }else{ for (j = 0; j < count; ++j) { Node* nd = m->nodelist[j]; nd->thisnode.EC -= (*s)(m->data[j], m->pdata[j], &nd->thisnode.GC,nd->v); }; } } if (errno) { if (nrn_errno_check(i)) { hoc_warning("errno set during calculation of currents", (char*)0); } } } #if 0 && _CRAY #pragma _CRI ivdep #endif for (i=rootnodecount; i < v_node_count; ++i) { Node* nd2; Node* nd = v_node[i]; Node* pnd = v_parent[nd->v_node_index]; double dg, de, dgp, dep, fac; #if 0 if (i == rootnodecount) { printf("v0 %g vn %g jstim %g jleft %g jright %g\n", nd->v, pnd->v, nd->fromparent.current, nd->toparent.current, nd[1].fromparent.current); } #endif /* dg and de must be second order when used */ if ((nd2 = nd->toparent.nd2) != (Node*)0) { dgp = -(3*(pnd->thisnode.GC - pnd->thisnode.Cdt) - 4*(nd->thisnode.GC - nd->thisnode.Cdt) +(nd2->thisnode.GC - nd2->thisnode.Cdt))/2 ; dep = -(3*(pnd->thisnode.EC - pnd->thisnode.Cdt * pnd->v) - 4*(nd->thisnode.EC - nd->thisnode.Cdt * nd->v) +(nd2->thisnode.EC - nd2->thisnode.Cdt * nd2->v))/2 ; }else{ dgp = 0.; dep = 0.; } if ((nd2 = pnd->fromparent.nd2) != (Node*)0) { dg = -(3*(nd->thisnode.GC - nd->thisnode.Cdt) - 4*(pnd->thisnode.GC - pnd->thisnode.Cdt) +(nd2->thisnode.GC - nd2->thisnode.Cdt))/2 ; de = -(3*(nd->thisnode.EC - nd->thisnode.Cdt * nd->v) - 4*(pnd->thisnode.EC - pnd->thisnode.Cdt * pnd->v) +(nd2->thisnode.EC - nd2->thisnode.Cdt * nd2->v))/2 ; }else{ dg = 0.; de = 0.; } fac = 1. + nd->toparent.coefjdot * nd->thisnode.GC; nd->toparent.djdv0 = ( nd->toparent.coefj + nd->toparent.coef0 * nd->thisnode.GC + nd->toparent.coefdg * dg )/fac; NODED(nd) += nd->toparent.djdv0; nd->toparent.current = ( - nd->toparent.coef0 * nd->thisnode.EC - nd->toparent.coefn * pnd->thisnode.EC + nd->toparent.coefjdot * nd->thisnode.Cdt * nd->toparent.current - nd->toparent.coefdg * de )/fac; NODERHS(nd) -= nd->toparent.current; NODEB(nd) = ( - nd->toparent.coefj + nd->toparent.coefn * pnd->thisnode.GC )/fac; /* this can break cray vectors */ fac = 1. + nd->fromparent.coefjdot * pnd->thisnode.GC; nd->fromparent.djdv0 = ( nd->fromparent.coefj + nd->fromparent.coef0 * pnd->thisnode.GC + nd->fromparent.coefdg * dgp )/fac; pNODED(nd) += nd->fromparent.djdv0; nd->fromparent.current = ( - nd->fromparent.coef0 * pnd->thisnode.EC - nd->fromparent.coefn * nd->thisnode.EC + nd->fromparent.coefjdot * nd->thisnode.Cdt * nd->fromparent.current - nd->fromparent.coefdg * dep )/fac; pNODERHS(nd) -= nd->fromparent.current; NODEA(nd) = ( - nd->fromparent.coefj + nd->fromparent.coefn * nd->thisnode.GC )/fac; } activstim(); activsynapse(); #if SEJNOWSKI activconnect(); #endif activclamp(); }