Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit 8c9a8db

Browse files
committed
Added changes in eion.cpp and global_vars.cpp
1 parent 8a7bb60 commit 8c9a8db

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

coreneuron/io/global_vars.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <map>
1212
#include <string>
1313
#include <algorithm>
14+
#include <unordered_map>
1415

1516
#include "coreneuron/utils/randoms/nrnran123.h"
1617
#include "coreneuron/nrnconf.h"
@@ -28,6 +29,8 @@ using N2V = std::map<std::string, PSD>;
2829

2930
static N2V* n2v;
3031

32+
extern std::unordered_map<std::string, double> nrn_ion_init;
33+
3134
void hoc_register_var(DoubScal* ds, DoubVec* dv, VoidFunc*) {
3235
if (!n2v) {
3336
n2v = new N2V();
@@ -62,7 +65,6 @@ void set_globals(const char* path, bool cli_global_seed, int cli_global_seed_val
6265
// will be processed before exit from loop.
6366
if (val) {
6467
N2V::iterator it = n2v->find(name);
65-
printf("Passing from NEURON %s %d %g\n", name, size, *val);
6668
if (it != n2v->end()) {
6769
if (size == 0) {
6870
nrn_assert(it->second.first == 0);
@@ -114,6 +116,8 @@ void set_globals(const char* path, bool cli_global_seed, int cli_global_seed_val
114116
if (it != n2v->end()) {
115117
nrn_assert(it->second.first == 0);
116118
*(it->second.second) = val;
119+
} else if (static_cast<std::string>(name).find("ion") != std::string::npos) {
120+
nrn_ion_init[name] = val;
117121
}
118122
} else if (sscanf(line, "%[^[][%d]\n", name, &n) == 2) {
119123
if (strcmp(name, "0") == 0) {

coreneuron/mechanism/eion.cpp

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ double nrn_ion_charge(int type) {
6060
return global_charge(type);
6161
}
6262

63+
std::unordered_map<std::string, double> nrn_ion_init = {
64+
{"nai0_na_ion", DEF_nai},
65+
{"nao0_na_ion", DEF_nao},
66+
{"ki0_k_ion", DEF_ki},
67+
{"ko0_k_ion", DEF_ko},
68+
{"cai0_ca_ion", DEF_cai},
69+
{"cao0_ca_ion", DEF_cao},
70+
};
71+
6372
void ion_reg(const char* name, double valence) {
6473
char buf[7][50];
6574
#define VAL_SENTINAL -10000.
@@ -109,25 +118,30 @@ void ion_reg(const char* name, double valence) {
109118
sprintf(buf[1], "%so0_%s", name, buf[0]);
110119
if (strcmp("na", name) == 0) {
111120
na_ion = mechtype;
112-
printf("Setting global_conci(na) to %lf and global_conco(na) to %lf\n", DEF_nai, DEF_nao);
113-
global_conci(mechtype) = DEF_nai;
114-
global_conco(mechtype) = DEF_nao;
121+
global_conci(mechtype) = nrn_ion_init["nai0_na_ion"];
122+
global_conco(mechtype) = nrn_ion_init["nao0_na_ion"];
115123
global_charge(mechtype) = 1.;
116124
} else if (strcmp("k", name) == 0) {
117125
k_ion = mechtype;
118-
printf("Setting global_conci(k) to %lf and global_conco(k) to %lf\n",DEF_ki, DEF_ko);
119-
global_conci(mechtype) = DEF_ki;
120-
global_conco(mechtype) = DEF_ko;
126+
global_conci(mechtype) = nrn_ion_init["ki0_k_ion"];
127+
global_conco(mechtype) = nrn_ion_init["ko0_k_ion"];
121128
global_charge(mechtype) = 1.;
122129
} else if (strcmp("ca", name) == 0) {
123130
ca_ion = mechtype;
124-
printf("Setting global_conci(ca) to %lf and global_conco(ca) to %lf\n", DEF_cai, DEF_cao);
125-
global_conci(mechtype) = DEF_cai;
126-
global_conco(mechtype) = DEF_cao;
131+
global_conci(mechtype) = nrn_ion_init["cai0_ca_ion"];
132+
global_conco(mechtype) = nrn_ion_init["cao0_ca_ion"];
127133
global_charge(mechtype) = 2.;
128134
} else {
129-
global_conci(mechtype) = DEF_ioni;
130-
global_conco(mechtype) = DEF_iono;
135+
if (nrn_ion_init[static_cast<std::string>(buf[0])]) {
136+
global_conci(mechtype) = nrn_ion_init[static_cast<std::string>(buf[0])];
137+
} else {
138+
global_conci(mechtype) = DEF_ioni;
139+
}
140+
if (nrn_ion_init[static_cast<std::string>(buf[1])]) {
141+
global_conco(mechtype) = nrn_ion_init[static_cast<std::string>(buf[1])];
142+
} else {
143+
global_conco(mechtype) = DEF_iono;
144+
}
131145
global_charge(mechtype) = VAL_SENTINAL;
132146
}
133147
}

0 commit comments

Comments
 (0)