1 #include <../../nrnconf.h> 63 hoc_execerror(
"current injection site change not allowed with both gap junctions and nhost > 1", 0);
65 if (curloc != rep_->iloc_) {
68 double x = rep_->rv_[vloc];
69 double y = rep_->jv_[vloc];
74 hoc_execerror(
"not allowed with both gap junctions and nhost>1", 0);
76 if (curloc != rep_->iloc_) {
79 if (curloc < 0) {
return 0.0; }
80 double x = rep_->rv_[curloc];
81 double y = rep_->jv_[curloc];
86 hoc_execerror(
"current injection site change not allowed with both gap junctions and nhost > 1", 0);
88 if (curloc != rep_->iloc_) {
91 double x = rep_->rv_[vloc];
92 double y = rep_->jv_[vloc];
97 hoc_execerror(
"not allowed with both gap junctions and nhost>1", 0);
99 if (curloc != rep_->iloc_) {
102 if (curloc < 0) {
return 0.0; }
103 double x = rep_->rv_[curloc];
104 double y = rep_->jv_[curloc];
109 hoc_execerror(
"not allowed with both gap junctions and nhost>1", 0);
111 if (clmploc < 0) {
return 0.0; }
112 if (clmploc != rep_->iloc_) {
115 double ax,bx,cx, ay,by,cy,bb;
116 ax = rep_->rv_[vloc];
117 ay = rep_->jv_[vloc];
118 bx = rep_->rv_[clmploc];
119 by = rep_->jv_[clmploc];
121 cx = (ax*bx + ay*by)/bb;
122 cy = (ay*bx - ax*by)/bb;
123 return sqrt(cx*cx + cy*cy);
135 rep_->maxiter_ = maxiter;
136 if (rep_->neq_ == 0) {
return; }
138 hoc_execerror(
"Impedance calculation with LinearMechanism not implemented", 0);
141 hoc_execerror(
"Impedance calculation with extracellular not implemented", 0);
144 rep_->omega_ = 1000.* omega;
145 rep_->delta(deltafac);
147 cmplx_spClear(rep_->m_);
150 #if 1 // when 0 equivalent to standard method 159 int e = cmplx_spFactor(rep_->m_);
178 if (rep_->iloc_ != curloc) {
180 rep_->iloc_ = curloc;
181 for (i=0; i < rep_->neq_; ++
i) {
185 if (curloc >= 0) {rep_->rv_[curloc] = 1.e2/
NODEAREA(_nt->
_v_node[curloc]);}
187 rval = rep_->gapsolve();
190 cmplx_spSolve(rep_->m_, rep_->rv_-1, rep_->rv_-1, rep_->jv_-1, rep_->jv_-1);
235 if (
neq_ == 0) {
return; }
236 m_ = cmplx_spCreate(
neq_, 1, &err);
248 for (i=0; i <
n_v_; ++
i) {
255 for (i=0; i <
n_v_; ++
i) {
259 diag_[
i] = cmplx_spGetElement(
m_, i+1, i+1);
277 int i,
j, nc,
cnt, ieq;
279 for (i=0; i <
neq_; ++
i) {
288 if (s && (cnt = (*s)(i)) > 0) {
290 for (j=0; j < nc; ++
j) {
319 for (i=0; i <
n; ++
i) {
320 double* cd = mlc->
data[
i];
337 if (i ==
CAP) {
continue; }
368 int ieq,
i, in, is, iis;
389 for (iis = 0; iis <
cnt; ++iis) {
390 is = ieq + in*cnt + iis;
415 int ieq,
i, in, is, iis;
430 for (is = ieq + in*cnt, iis = 0; iis <
cnt; ++iis, ++is) {
438 if (x1[in] ==
NODEV(nd)) {
446 for (is = ieq + in*cnt, iis = 0; iis <
cnt; ++iis, ++is) {
456 for (is = ieq + in*cnt, iis = 0; iis <
cnt; ++iis, ++is) {
471 int ieq,
i, in, is, iis, ks, kks;
489 for (is = ieq + in*cnt, iis = 0; iis <
cnt; ++iis, ++is) {
498 for (is = ieq + in*cnt, iis = 0; iis <
cnt; ++iis, ++is) {
503 for (kks=0; kks <
cnt; ++kks) {
506 ks = ieq + in*cnt + kks;
507 for (is = ieq + in*cnt, iis = 0; iis <
cnt; ++iis, ++is) {
516 ks = ieq + in*cnt + kks;
517 for (is = ieq + in*cnt, iis = 0; iis <
cnt; ++iis, ++is) {
520 double*
elm = cmplx_spGetElement(
m_, is+1, ks+1);
541 mfake.nodeindices = ml->nodeindices + in;
571 hoc_execerror(
"there can be one and only one impedance stimulus", 0);
578 double *rx, *jx, *rx1, *jx1, *rb, *jb;
580 rx =
new double[
neq_];
581 jx =
new double[
neq_];
582 rx1 =
new double[
neq_];
583 jx1 =
new double[
neq_];
584 rb =
new double[
neq_];
585 jb =
new double[
neq_];
602 for (iter = 1; iter <=
maxiter_; ++iter) {
604 cmplx_spSolve(
m_, rb-1, rx1-1, jb-1, jx1-1);
611 double err =
fabs(rx1[
i] - rx[
i]) +
fabs(jx1[i] - jx[i]);
656 sprintf(buf,
"Impedance calculation did not converge in %d iterations. Max state change on last iteration was %g (Iterations stop at %g)\n",
struct NrnThreadMembList * next
void pargap_jacobi_rhs(double *, double *)
Represent main neuron object computed by single thread.
static int ode_count(int type)
double transfer_amp(int curloc, int vloc)
void ode(int, Memb_list *)
void nrn_rhs(NrnThread *)
sprintf(buf," if (secondorder) {\ " int _i;\" " for(_i=0;_i< %d;++_i) {\" " _p[_slist%d[_i]]+=dt *_p[_dlist%d[_i]];\" " }}\", numeqn, listnum, listnum)
int const size_t const size_t n
Memb_list * _ecell_memb_list
void(* Pvmi)(struct NrnThread *, Memb_list *, int)
void hoc_execerror(const char *, const char *)
void pargap_jacobi_setup(int mode)
Symlist * hoc_built_in_symlist
void compute(double omega, double deltafac, int maxiter)
spREAL * spGetElement(char *, int, int)
double ratio_amp(int clmploc, int vloc)
double input_amp(int curloc)
void current(int, Memb_list *, int)
Symbol * hoc_table_lookup(const char *, Symlist *)
void(* nrnthread_v_transfer_)(NrnThread *)
void(* nrn_ode_map_t)(int, double **, double **, double *, Datum *, double *, int)
double input_phase(int curloc)
int(* nrn_ode_count_t)(int)
double transfer_phase(int curloc, int vloc)
int nrndae_extra_eqn_count()
static double deltafac(void *v)