1 #include <../../nrnconf.h>
33 extern double chkarg(
int,
double low,
double high);
35 #if !defined(NRNMPI) || NRNMPI == 0
58 #define UPDATE_VEC_AREA(nd) \
59 if (nd->_nt && nd->_nt->_actual_area) { \
60 nd->_nt->_actual_area[(nd)->v_node_index] = NODEAREA(nd); \
364 i2 = i1 + _nt->
ncell;
384 for (
i = i1;
i < i3; ++
i) {
390 for (
i = i1;
i < i3; ++
i) {
396 for (
i = i1;
i < i3; ++
i) {
403 for (tml = _nt->
tml; tml; tml = tml->
next)
412 (*s)(_nt, tml->
ml, tml->
index);
419 hoc_warning(
"errno set during calculation of currents", (
char*) 0);
431 for (
i = i1;
i < i3; ++
i) {
435 for (
i = i1;
i < i3; ++
i) {
463 for (
i = i2;
i < i3; ++
i) {
472 for (
i = i2;
i < i3; ++
i) {
496 i2 = i1 + _nt->
ncell;
510 for (
i = i1;
i < i3; ++
i) {
516 for (
i = i1;
i < i3; ++
i) {
523 for (
i = i1;
i < i3; ++
i) {
529 for (tml = _nt->
tml; tml; tml = tml->
next)
535 (*s)(_nt, tml->
ml, tml->
index);
539 hoc_warning(
"errno set during calculation of jacobian", (
char*) 0);
560 for (
i = i1;
i < i3; ++
i) {
565 for (
i = i1;
i < i3; ++
i) {
569 for (
i = i1;
i < i3; ++
i) {
593 for (
i = i2;
i < i3; ++
i) {
599 for (
i = i2;
i < i3; ++
i) {
605 for (
i = i2;
i < i3; ++
i) {
612 for (
i = i2;
i < i3; ++
i) {
650 "You can not locate a point process at\n\
651 position 0 or 1 if it needs an ion\n");
716 p->param = (
double*) 0;
774 #define PI 3.14159265358979323846
781 double ra, dx, diam, rright, rleft;
789 sec->prop->dparam[2].val =
sec->pt3d[
sec->npt3d - 1].arc;
795 for (
j = 0;
j <
sec->nnode - 1;
j++) {
797 for (
p = nd->
prop;
p;
p =
p->next) {
804 if (
sec->npt3d > 1) {
824 rleft = 1
e-2 * ra * (dx / 2) / (
PI * diam * diam / 4.);
825 NODERINV(nd) = 1. / (rleft + rright);
834 sec->recalc_area_ = 0;
845 double dx, diam,
area, ra;
850 extern int nrn_ra_set;
864 hoc_warning(
"Don't forget to set Ra in every section",
"eg. forall Ra=35.4");
887 if (!
sec->parentsec) {
908 for (
j = 1;
j <
sec->nnode;
j++) {
918 for (
j = 0;
j <
sec->nnode;
j++) {
969 if (x == 0. || x == 1.) {
973 if (
sec->recalc_area_) {
1007 if (
sec->logical_connection) {
1008 free(
sec->logical_connection);
1009 sec->logical_connection = (
Pt3d*) 0;
1044 if ((
int)
chkarg(1, 0., 1.) == 1) {
1070 req =
chkarg(1, 0., 30000.);
1079 if (
n >
sec->pt3d_bsize) {
1080 sec->pt3d_bsize =
n;
1083 sec->pt3d_bsize = 0;
1094 sec->recalc_area_ = 1;
1098 if (
sec->pt3d[i0].d < 0.) {
1103 sec->pt3d[0].arc = 0.;
1106 for (
i = i0;
i <
n; ++
i) {
1109 t1 =
sec->pt3d[
i].x -
p->x;
1110 t2 =
sec->pt3d[
i].y -
p->y;
1111 t3 =
sec->pt3d[
i].z -
p->z;
1112 sec->pt3d[
i].arc =
p->arc +
sqrt(t1 * t1 + t2 * t2 + t3 * t3);
1114 sec->prop->dparam[2].val =
sec->pt3d[
n - 1].arc;
1119 if (req !=
sec->pt3d_bsize) {
1121 free((
char*) (
sec->pt3d));
1123 sec->pt3d_bsize = 0;
1127 sec->pt3d_bsize = req;
1139 for (
i =
n - 1;
i >= i0; --
i) {
1141 p->x =
sec->pt3d[
i].x;
1142 p->y =
sec->pt3d[
i].y;
1143 p->z =
sec->pt3d[
i].z;
1144 p->d =
sec->pt3d[
i].d;
1146 sec->pt3d[i0].x = x;
1147 sec->pt3d[i0].y = y;
1148 sec->pt3d[i0].z = z;
1149 sec->pt3d[i0].d = d;
1158 i0 = (int)
chkarg(1, 0., (
double) (
n));
1167 sec->recalc_area_ = 1;
1174 sec->pt3d[
i].d = diam;
1182 i = (int)
chkarg(1, 0., (
double) (
n - 1));
1194 for (
i = i0 + 1;
i <
n; ++
i) {
1196 p->x =
sec->pt3d[
i].x;
1197 p->y =
sec->pt3d[
i].y;
1198 p->z =
sec->pt3d[
i].z;
1199 p->d =
sec->pt3d[
i].d;
1209 i0 = (int)
chkarg(1, 0., (
double) (
n - 1));
1220 if (
fabs(L -
sec->pt3d[
sec->npt3d - 1].arc) > .001) {
1223 for (
i = 0;
i <
sec->npt3d; ++
i) {
1224 x =
sec->pt3d[
i].arc / L;
1241 x0 =
sec->pt3d[0].x;
1242 y0 =
sec->pt3d[0].y;
1243 z0 =
sec->pt3d[0].z;
1244 l =
sec->pt3d[
sec->npt3d - 1].arc;
1247 for (
i = 0;
i <
sec->npt3d; ++
i) {
1248 sec->pt3d[
i].arc =
sec->pt3d[
i].arc * fac;
1249 sec->pt3d[
i].x = x0 + (
sec->pt3d[
i].x - x0) * fac;
1250 sec->pt3d[
i].y = y0 + (
sec->pt3d[
i].y - y0) * fac;
1251 sec->pt3d[
i].z = z0 + (
sec->pt3d[
i].z - z0) * fac;
1271 for (
i = 0;
i <
n;
i++) {
1272 sec->pt3d[
i].x = x[
i];
1273 sec->pt3d[
i].y = y[
i];
1274 sec->pt3d[
i].z = z[
i];
1275 sec->pt3d[
i].d = d[
i];
1343 d = (double)
sec->pt3d[
i].d;
1354 d = (double)
sec->pt3d[
i].d;
1398 if (
sec->logical_connection) {
1407 dx = x -
sec->pt3d[0].x;
1408 dy = y -
sec->pt3d[0].y;
1409 dz = z -
sec->pt3d[0].z;
1412 for (
i = 0;
i <
sec->npt3d; ++
i) {
1413 sec->pt3d[
i].x += dx;
1414 sec->pt3d[
i].y += dy;
1415 sec->pt3d[
i].z += dz;
1420 static int changed_;
1423 float x, y, z, dz, x1, y1;
1424 float nch, ich = 0.0, angle;
1434 if ((psec =
sec->parentsec) == (
Section*) 0) {
1452 x = psec->
pt3d[psec->
npt3d - 1].
x * arc1 + psec->
pt3d[0].
x * (1 - arc1);
1453 y = psec->
pt3d[psec->
npt3d - 1].
y * arc1 + psec->
pt3d[0].
y * (1 - arc1);
1454 z = psec->
pt3d[psec->
npt3d - 1].
z * arc1 + psec->
pt3d[0].
z * (1 - arc1);
1463 Printf(
"nrn_define_shape: %s first and last 3-d point at same (x,y)\n",
secname(psec));
1466 angle =
atan2(y1, x1);
1468 if (arc > 0. && arc < 1.) {
1469 angle += 3.14159265358979323846 / 2.;
1482 angle += ich / (nch - 1.) * .8 - .4;
1485 x1 = x + len *
cos(angle);
1486 y1 = y + len *
sin(angle);
1488 for (
j = 0;
j <
sec->nnode - 1; ++
j) {
1489 double frac = ((double)
j + .5) / (double) (
sec->nnode - 1);
1491 x * (1 - frac) + x1 * frac,
1492 y * (1 - frac) + y1 * frac,
1498 sec->pt3d[
sec->npt3d - 1].arc = len;
1499 sec->prop->dparam[2].val = len;
1523 static double x1, y1, ds;
1526 double diam, delta, temp,
ri,
area, ra, rleft = 0.0;
1532 x1 =
sec->pt3d[
j].arc;
1534 ds =
sec->pt3d[
sec->npt3d - 1].arc / ((double) (
sec->nnode - 1));
1536 si = (double) inode * ds;
1542 for (ihalf = 0; ihalf < 2; ihalf++) {
1547 double x2, y2, xj, xjp;
1549 xj =
sec->pt3d[
j].arc;
1551 if (
sec->pt3d[
j].d < 0 && xj >= si && xj < sip) {
1555 xjp =
sec->pt3d[jp].arc;
1556 if (xjp > sip || jp == npt - 1) {
1558 if (
fabs(xjp - xj) < 1
e-10) {
1561 frac = (sip - xj) / (xjp - xj);
1564 y2 = (1. - frac) *
fabs(
sec->pt3d[
j].d) + frac *
fabs(
sec->pt3d[jp].d);
1574 diam += (y2 + y1) * delta;
1575 if (delta < 1
e-15) {
1578 if ((temp = y2 * y1 / delta) == 0) {
1583 temp = .5 * (y2 - y1);
1584 temp =
sqrt(delta * delta + temp * temp);
1589 area += (y2 + y1) * temp;
1600 rleft =
ri * ra /
PI * (4. * .01);
1602 ri =
ri * ra /
PI * (4. * .01);
1608 NODERINV(
sec->pnode[inode]) = 1. / (rparent + rleft);
1610 if (
fabs(diam -
p->param[0]) > 1
e-9 || diam < 1
e-5) {
1617 if (inode ==
sec->nnode - 2 &&
sec->pt3d[npt - 1].d < 0.) {
1725 for (inode = 0; inode < _nt->
end; inode++) {
1799 #define P fprintf(fnd,
1801 #define Pd(arg) P "%d\n", arg)
1802 #define Pg(arg) P "%g\n", arg)
1804 void node_data_scaffolding(
void) {
1814 void node_data_structure(
void) {
1821 for (
i = 0;
i < v_node_count; ++
i) {
1822 Pd(v_parent[
i]->v_node_index);
1834 void node_data_values(
void) {
1837 for (
i = 0;
i < v_node_count; ++
i) {
1855 for (
k = 0;
k <
cnt; ++
k) {
1876 node_data_scaffolding();
1877 node_data_structure();
1900 for (
j = 0;
j <
sec->nnode; ++
j) {
1902 for (
p = nd->
prop;
p;
p =
p->next) {
1903 if (
p->param == pp) {
1905 "Error at section location %s(%g)\n",
1913 fprintf(stderr,
"Don't know the location of params at %p\n", pp);
2056 int in, err, extn,
neqn,
j;
2070 for (in = 0,
i = 1; in < nt->
end; ++in, ++
i) {
2076 for (in = 0; in < nt->
end; ++in) {
2087 for (ie = 0; ie <
nlayer; ++ie) {
2100 for (ie = 0; ie <
nlayer; ++ie) {
2101 int kp =
j + ie + 1;
2118 for (
i = 0;
i < nt->
end; ++
i) {
2169 for (
i = 0;
i <
n; ++
i) {
2177 static double* (*recalc_ptr_)(
double*);
2187 int k = (int) (*old);
2197 Printf(
"More than 20 recalc_ptr_callback functions\n");
2247 *nd->
_v = (double) ii;
2257 for (
p = nd->
prop;
p;
p =
p->next) {
2263 double*
pval =
p->dparam[
j].pval;
const char * secname(Section *sec)
Node * node_ptr(Section *sec, double x, double *parea)
double nrn_arc_position(Section *sec, Node *node)
Prop * nrn_mechanism(int type, Node *nd)
double section_length(Section *sec)
double nrn_connection_position(Section *sec)
int arc0at0(Section *sec)
Section * chk_access(void)
double nrn_diameter(Node *nd)
void nrn_recalc_ptrvector()
void nrn_cap_jacob(NrnThread *_nt, Memb_list *ml)
void activclamp_lhs(void)
void activclamp_rhs(void)
void nrn_cache_prop_realloc()
void nrn_prop_datum_free(int type, Datum *ppd)
void nrn_prop_data_free(int type, double *pd)
void nrn_rhs_ext(NrnThread *_nt)
void nrn_setup_ext(NrnThread *_nt)
void hoc_execerror(const char *, const char *)
int hoc_is_object_arg(int narg)
void nrn_register_recalc_ptr_callback(Pfrv f)
void hoc_free_val_array(double *, size_t)
void notify_freed_val_array(double *p, size_t size)
double * nrn_recalc_ptr(double *old)
void hoc_warning(const char *, const char *)
void hoc_retpushx(double x)
int hoc_is_pdouble_arg(int narg)
double * hoc_pgetarg(int narg)
void hoc_obj_unref(Object *obj)
void * ecalloc(size_t n, size_t size)
hoc_List * hoc_l_newlist()
hoc_Item * hoc_l_lappendsec(hoc_List *, struct Section *)
int vector_capacity(Vect *v)
double * vector_vec(Vect *v)
void(* Pvmi)(struct NrnThread *, Memb_list *, int)
#define BEFORE_BREAKPOINT
#define ITERATE(itm, lst)
char * emalloc(unsigned n)
void nrn_thread_error(const char *)
static void nrn_thread_memblist_setup()
static void reorder_secorder()
double * nrn_classicalNodeA(Node *nd)
double * nrn_classicalNodeB(Node *nd)
#define ClassicalNODEB(n)
#define ClassicalNODEA(n)
int nrn_isdouble(double *, double, double)
static void phase_begin(const char *name)
static void phase_end(const char *name)
void nrn_ba(NrnThread *, int)
int nrndae_extra_eqn_count()
#define nrn_nonvint_block_ode_count(offset, tid)
#define nrn_nonvint_block_current(size, rhs, tid)
#define nrn_nonvint_block_setup()
#define nrn_nonvint_block_conductance(size, d, tid)
void activsynapse_rhs(void)
void synapse_prepare(void)
void clear_point_process_struct(Prop *p)
void activsynapse_lhs(void)
int nrndae_list_is_empty()
int const size_t const size_t n
void * hoc_Erealloc(void *buf, size_t size)
static philox4x32_key_t k
void long_difus_solve(int, NrnThread *)
struct Node * _classical_parent
Represent main neuron object computed by single thread.
_nrn_Fast_Imem * _nrn_fast_imem
Memb_list * _ecell_memb_list
struct NrnThreadMembList * next
static int * old_actual_v_size_
static void(* recalc_ptr_callback[20])()
void nrn_matrix_node_free(void)
static double ** old_actual_area_
void stor_pt3d(Section *sec, double x, double y, double z, double d)
void nrn_pt3dremove(Section *sec, int i0)
Section * nrn_pnt_sec_for_need_
short * nrn_is_artificial_
void(* nrn_multisplit_setup_)()
void nrn_pt3dinsert(Section *sec, int i0, double x, double y, double z, double d)
void * setup_tree_matrix(NrnThread *_nt)
double chkarg(int, double low, double high)
int nrn_method_consistent(void)
void nrn_recalc_ptrs(double *(*r)(double *))
Prop * prop_alloc_disallow(Prop **pp, short type, Node *nd)
Node * nrn_parent_node(Node *nd)
static double *(* recalc_ptr_)(double *)
static void nrn_recalc_node_ptrs()
static Prop ** current_prop_list
#define UPDATE_VEC_AREA(nd)
int nrn_node_ptr_change_cnt_
static double ** old_actual_v_
static void nrn_translate_shape(Section *sec, float x, float y, float z)
int can_change_morph(Section *sec)
void nrn_area_ri(Section *sec)
static void stor_pt3d_vec(Section *sec, IvocVect *xv, IvocVect *yv, IvocVect *zv, IvocVect *dv)
static int disallow_needmemb
Prop * need_memb(Symbol *sym)
cTemplate ** nrn_pnt_template_
static double diam_from_list(Section *sec, int inode, Prop *p, double rparent)
void nrn_partrans_update_ptrs()
static void nrn_pt3dmodified(Section *sec, int i0)
void nrn_pt3dchange2(Section *sec, int i, double x, double y, double z, double diam)
Prop * prop_alloc(Prop **, int, Node *)
void connection_coef(void)
void nrn_complain(double *pp)
void nrn_shape_update(void)
void nrn_pt3dstyle1(Section *sec, double x, double y, double z)
static int n_recalc_ptr_callback
void nrn_pt3dchange1(Section *sec, int i, double d)
static void nrn_matrix_node_alloc(void)
int * nrn_dparam_ptr_start_
static double ** recalc_ptr_old_vp_
void nrn_shape_update_always(void)
void nrn_pt3dclear(Section *sec, int req)
void nrn_old_thread_save(void)
int * nrn_prop_dparam_size_
void nrn_diam_change(Section *sec)
void nrn_lhs(NrnThread *_nt)
void nrn_length_change(Section *sec, double d)
spREAL * spGetElement(char *, int, int)
int * nrn_dparam_ptr_end_
void nrn_pt3dstyle0(Section *sec)
void single_prop_free(Prop *p)
Symlist * hoc_built_in_symlist
void nrn_rhs(NrnThread *_nt)
void prop_free(Prop **pp)
void v_setup_vectors(void)
static double ** recalc_ptr_new_vp_
static void nrn_pt3dbufchk(Section *sec, int n)