1 #include <../../nrnconf.h> 15 extern double chkarg(
int,
double low,
double high);
25 "ena",
"nao",
"nai", 0,
41 extern "C" double nrn_nernst(
double,
double,
double),
nrn_ghk(
double,
double,
double,
double);
51 #define global_conci(type) ion_global_map[type][0] 52 #define global_conco(type) ion_global_map[type][1] 53 #define global_charge(type) ion_global_map[type][2] 72 buf =
static_cast<char *
>(
emalloc(strlen(name) + 10));
103 if (strcmp(name,
"ca") == 0 && charge != 2.0) {
109 hoc_execerr_ext(
"ca_ion already defined with charge 2, cannot redefine with charge %g\n", charge);
137 #define VAL_SENTINAL -10000. 140 int n = 2 * strlen(name) + 10;
141 for (i = 0; i < 7; ++
i) {
142 buf[
i] =
static_cast<char *
>(
emalloc(n));
145 Sprintf(buf[0],
"%s_ion", name);
150 Sprintf(buf[6],
"di%s_dv_", name);
151 for (i = 0; i < 7; i++) {
156 if (!s || s->
type != MECHANISM
171 if (ion_global_map_size <= s->
subtype) {
178 scdoub[0].
name = buf[0];
181 scdoub[1].
name = buf[1];
186 if (strcmp(
"na", name) == 0) {
191 }
else if (strcmp(
"k", name) == 0) {
196 }
else if (strcmp(
"ca", name) == 0) {
206 for (i = 0; i < 3; ++
i) {
212 fprintf(stderr,
"%s ion charge defined differently in\n\ 213 two USEION statements (%g and %g)\n",
226 for (i = 0; i < 7; ++
i) {
238 Fprintf(stderr,
"%s USEION CHARGE (or VALENCE) must be defined in\n\ 239 at least one model using this ion\n", s->
name);
245 #define FARADAY _faraday_[_nrnunit_use_legacy_] 247 #define gasconstant _gasconstant_[_nrnunit_use_legacy_] 250 #define ktf (1000.*gasconstant*(celsius + 273.15)/FARADAY) 258 }
else if (co <= 0.) {
261 return ktf / z *
log(co / ci);
280 double *ci, *co, *
e, x;
289 switch (s->
u.
rng.index) {
295 val = *co *
exp(-z /
ktf * *e);
299 val = *ci *
exp(z /
ktf * *e);
314 if (
fabs(x) < 1
e-4) {
317 return x / (
exp(x) - 1);
321 extern "C" double nrn_ghk(
double v,
double ci,
double co,
double z) {
322 double eco, eci, temp;
324 eco = co *
efun(temp);
325 eci = ci *
efun(-temp);
326 return (.001) * z *
FARADAY * (eci - eco);
335 #define erev pd[i][0] 336 #define conci pd[i][1] 337 #define conco pd[i][2] 339 #define dcurdv pd[i][4] 356 #define iontype ppd[i][0].i 367 #define charge global_charge(type) 368 #define conci0 global_conci(type) 369 #define conco0 global_conco(type) 380 static long *chk_conc_, *ion_bit_, size_;
400 chk_conc_[2 *
j] = 0;
401 chk_conc_[2 * j + 1] = 0;
409 ion_bit_[
j] = (1 <<
k);
411 assert(k <
sizeof(
long) * 8);
415 chk_conc_[2 * p_ok->
type +
i] |= ion_bit_[pion->
type];
416 if (pion->
dparam[0].
i & flag) {
418 for (p = pion->
next; p; p = p->
next) {
422 if (chk_conc_[2 * p->
type + i] & ion_bit_[pion->
type]) {
424 sprintf(buf,
"%.*s%c is being written at the same location by %s and %s",
427 ((i == 1) ?
'i' :
'o'),
439 int istyle,
i, oldstyle;
459 istyle += 0100 * (
int)
chkarg(5, 0., 1.);
469 for (i=0; i < count; ++
i) {
475 for (i = 0; i < sec->
nnode; ++
i) {
478 p->
dparam[0].
i &= (0200 + 0400);
501 if (sym->
u.
rng.index == 0) {
515 oldconc = (*it & 03);
516 oldrev = (*it & 030) >> 3;
518 if (oldconc < conc) {
525 if (oldconc > 0 && oldrev < 2) {
529 *it += oldconc + 010 * oldrev;
536 if (oldconc > 0 && oldrev == 2) {
545 double **pd = ml->
data;
552 for (i = 0; i < count; ++
i) {
567 double **pd = ml->
data;
574 for (i = 0; i < count; ++
i) {
583 for (i = 0; i < count; ++
i) {
629 if (secondorder == 2) {
630 for (tml = nt->
tml; tml; tml = tml->
next)
634 for (i = 0; i < i2; ++
i) {
void * ecalloc(size_t n, size_t size)
void nrn_verify_ion_charge_defined()
int hoc_is_str_arg(int narg)
void * erealloc(void *ptr, size_t n)
void hoc_symbol_limits(Symbol *sym, float low, float high)
static int ion_global_map_size
struct NrnThreadMembList * next
void nrn_writes_conc(int type, int unused)
Symbol * hoc_lookup(const char *)
Represent main neuron object computed by single thread.
void hoc_register_prop_size(int, int, int)
void nrn_promote(Prop *p, int conc, int rev)
static double ** ion_global_map
static philox4x32_key_t k
sprintf(buf," if (secondorder) {\ " int _i;\" " for(_i=0;_i< %d;++_i) {\" " _p[_slist%d[_i]]+=dt *_p[_dlist%d[_i]];\" " }}\", numeqn, listnum, listnum)
double nrn_nernst_coef(int type)
static const char * mechanism[]
void nrn_wrote_conc(Symbol *sym, double *pe, int it)
Symlist * hoc_top_level_symlist
int nrn_vartype(Symbol *sym)
void hoc_execerr_ext(const char *fmt,...)
printf style specification of hoc_execerror message.
static void ion_init(NrnThread *, Memb_list *, int)
int nrn_get_mechtype(const char *mechname)
int const size_t const size_t n
HocStruct Symbol ** ppsym
#define global_charge(type)
void(* Pvmi)(struct NrnThread *, Memb_list *, int)
char * hoc_symbol_units(Symbol *, const char *)
void hoc_warning(const char *, const char *)
static void ion_cur(NrnThread *, Memb_list *, int)
void hoc_execerror(const char *, const char *)
static double _gasconstant_[2]
fprintf(stderr, "Don't know the location of params at %p\, pp)
static double _faraday_[2]
#define _gasconstant_codata2018
Prop * nrn_mechanism(int type, Node *nd)
#define global_conco(type)
char * emalloc(unsigned n)
double nrn_nernst(double, double, double)
Symlist * hoc_built_in_symlist
void ion_reg(const char *name, double valence)
void hoc_register_dparam_semantics(int type, int ix, const char *name)
static double efun(double x)
struct Symbol::@52::@53 rng
#define global_conci(type)
double nrn_ion_charge(Symbol *sym)
double nrn_ghk(double, double, double, double)
void register_mech(const char **, Pvmp, Pvmi, Pvmi, Pvmi, Pvmi, int, int)
void hoc_register_var(DoubScal *scdoub, DoubVec *vdoub, VoidFunc *fn)
double * nrn_prop_data_alloc(int type, int count, Prop *p)
#define _faraday_codata2018
Datum * nrn_prop_datum_alloc(int type, int count, Prop *p)
void nrn_check_conc_write(Prop *p_ok, Prop *pion, int i)
double * nrn_rangepointer(Section *sec, Symbol *s, double d)
static void ion_alloc(Prop *)
Section * nrn_noerr_access()
Section * chk_access(void)
double chkarg(int, double low, double high)
void second_order_cur(NrnThread *nt)