1 #include <../../nrnconf.h>
15 extern double chkarg(
int,
double low,
double high);
47 extern "C" double nrn_nernst(
double,
double,
double),
nrn_ghk(
double,
double,
double,
double);
57 #define global_conci(type) ion_global_map[type][0]
58 #define global_conco(type) ion_global_map[type][1]
59 #define global_charge(type) ion_global_map[type][2]
85 hoc_execerr_ext(
"%s already defined with charge %g, cannot redefine with charge %g",
124 if (strcmp(
name,
"ca") == 0 &&
charge != 2.0) {
130 hoc_execerr_ext(
"ca_ion already defined with charge 2, cannot redefine with charge %g\n",
159 #define VAL_SENTINAL -10000.
162 int n = 2 * strlen(
name) + 10;
163 for (
i = 0;
i < 7; ++
i) {
173 for (
i = 0;
i < 7;
i++) {
192 if (ion_global_map_size <= s->
subtype) {
207 if (strcmp(
"na",
name) == 0) {
212 }
else if (strcmp(
"k",
name) == 0) {
217 }
else if (strcmp(
"ca",
name) == 0) {
227 for (
i = 0;
i < 3; ++
i) {
234 "%s ion charge defined differently in\n\
235 two USEION statements (%g and %g)\n",
250 for (
i = 0;
i < 7; ++
i) {
263 "%s USEION CHARGE (or VALENCE) must be defined in\n\
264 at least one model using this ion\n",
271 #define FARADAY _faraday_[_nrnunit_use_legacy_]
273 #define gasconstant _gasconstant_[_nrnunit_use_legacy_]
276 #define ktf (1000. * gasconstant * (celsius + 273.15) / FARADAY)
284 }
else if (co <= 0.) {
287 return ktf / z *
log(co / ci);
306 double *ci, *co, *
e, x;
315 switch (s->
u.
rng.index) {
321 val = *co *
exp(-z /
ktf * *
e);
340 if (
fabs(x) < 1
e-4) {
343 return x / (
exp(x) - 1);
347 extern "C" double nrn_ghk(
double v,
double ci,
double co,
double z) {
348 double eco, eci, temp;
350 eco = co *
efun(temp);
351 eci = ci *
efun(-temp);
352 return (.001) * z *
FARADAY * (eci - eco);
361 #define erev pd[i][0]
362 #define conci pd[i][1]
363 #define conco pd[i][2]
365 #define dcurdv pd[i][4]
382 #define iontype ppd[i][0].i
393 #define charge global_charge(type)
394 #define conci0 global_conci(type)
395 #define conco0 global_conco(type)
406 static long *chk_conc_, *ion_bit_, size_;
426 chk_conc_[2 *
j] = 0;
427 chk_conc_[2 *
j + 1] = 0;
435 ion_bit_[
j] = (1 <<
k);
441 chk_conc_[2 * p_ok->
type +
i] |= ion_bit_[pion->
type];
442 if (pion->
dparam[0].
i & flag) {
444 for (
p = pion->
next;
p;
p =
p->next) {
448 if (chk_conc_[2 *
p->type +
i] & ion_bit_[pion->
type]) {
451 "%.*s%c is being written at the same location by %s and %s",
454 ((
i == 1) ?
'i' :
'o'),
466 int istyle,
i, oldstyle;
479 oldstyle =
p->dparam[0].i;
483 istyle = (int)
chkarg(2, 0., 3.);
484 istyle += 010 * (int)
chkarg(3, 0., 3.);
485 istyle += 040 * (int)
chkarg(4, 0., 1.);
486 istyle += 0100 * (int)
chkarg(5, 0., 1.);
487 istyle += 04 * (int)
chkarg(6, 0., 1.);
496 for (
i=0;
i < count; ++
i) {
502 for (
i = 0;
i <
sec->nnode; ++
i) {
505 p->dparam[0].i &= (0200 + 0400);
506 p->dparam[0].i += istyle;
527 int it =
p->dparam[0].i;
528 if (sym->
u.
rng.index == 0) {
541 int* it = &
p->dparam[0].i;
542 oldconc = (*it & 03);
543 oldrev = (*it & 030) >> 3;
545 if (oldconc < conc) {
552 if (oldconc > 0 && oldrev < 2) {
556 *it += oldconc + 010 * oldrev;
563 if (oldconc > 0 && oldrev == 2) {
572 double** pd = ml->
data;
579 for (
i = 0;
i < count; ++
i) {
594 double** pd = ml->
data;
601 for (
i = 0;
i < count; ++
i) {
610 for (
i = 0;
i < count; ++
i) {
630 }
else if (
p->type ==
k_ion) {
634 }
else if (
p->type ==
ca_ion) {
657 for (tml = nt->
tml; tml; tml = tml->
next)
661 for (
i = 0;
i < i2; ++
i) {
Prop * nrn_mechanism(int type, Node *nd)
int nrn_get_mechtype(const char *mechname)
double * nrn_rangepointer(Section *sec, Symbol *s, double d)
Section * chk_access(void)
Datum * nrn_prop_datum_alloc(int type, int count, Prop *p)
double * nrn_prop_data_alloc(int type, int count, Prop *p)
sprintf(buf, " if (secondorder) {\n" " int _i;\n" " for (_i = 0; _i < %d; ++_i) {\n" " _p[_slist%d[_i]] += dt*_p[_dlist%d[_i]];\n" " }}\n", numeqn, listnum, listnum)
static void ion_cur(NrnThread *, Memb_list *, int)
static double ** ion_global_map
double nrn_ghk(double, double, double, double)
double chkarg(int, double low, double high)
void register_mech(const char **, Pvmp, Pvmi, Pvmi, Pvmi, Pvmi, int, int)
double nrn_ion_charge(Symbol *sym)
void nrn_verify_ion_charge_defined()
void second_order_cur(NrnThread *nt)
#define global_conco(type)
Section * nrn_noerr_access()
static double efun(double x)
void nrn_promote(Prop *p, int conc, int rev)
static int ion_global_map_size
void nrn_wrote_conc(Symbol *sym, double *pe, int it)
double nrn_nernst(double, double, double)
#define global_charge(type)
void hoc_register_prop_size(int, int, int)
static double _gasconstant_[2]
static void ion_init(NrnThread *, Memb_list *, int)
static void ion_alloc(Prop *)
int nrn_vartype(Symbol *sym)
void nrn_check_conc_write(Prop *p_ok, Prop *pion, int i)
static double _faraday_[2]
double nrn_nernst_coef(int type)
static const char * mechanism[]
void ion_reg(const char *name, double valence)
#define global_conci(type)
void hoc_execerror(const char *, const char *)
void hoc_execerr_ext(const char *fmt,...)
printf style specification of hoc_execerror message.
int hoc_is_str_arg(int narg)
void hoc_register_var(DoubScal *scdoub, DoubVec *vdoub, VoidFunc *fn)
void hoc_warning(const char *, const char *)
void hoc_retpushx(double x)
void hoc_symbol_limits(Symbol *sym, float low, float high)
Symbol * hoc_lookup(const char *)
void * erealloc(void *ptr, size_t n)
void * ecalloc(size_t n, size_t size)
Symlist * hoc_top_level_symlist
Symlist * hoc_built_in_symlist
char * hoc_symbol_units(Symbol *, const char *)
void(* Pvmi)(struct NrnThread *, Memb_list *, int)
char * emalloc(unsigned n)
int const size_t const size_t n
void nrn_writes_conc(int type, int unused)
void hoc_register_dparam_semantics(int type, int ix, const char *name)
static philox4x32_key_t k
#define _gasconstant_codata2018
#define _faraday_codata2018
Represent main neuron object computed by single thread.
struct NrnThreadMembList * next
HocStruct Symbol ** ppsym
struct Symbol::@37::@38 rng