@@ -60,6 +60,15 @@ double nrn_ion_charge(int type) {
60
60
return global_charge (type);
61
61
}
62
62
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
+
63
72
void ion_reg (const char * name, double valence) {
64
73
char buf[7 ][50 ];
65
74
#define VAL_SENTINAL -10000 .
@@ -109,25 +118,30 @@ void ion_reg(const char* name, double valence) {
109
118
sprintf (buf[1 ], " %so0_%s" , name, buf[0 ]);
110
119
if (strcmp (" na" , name) == 0 ) {
111
120
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" ];
115
123
global_charge (mechtype) = 1 .;
116
124
} else if (strcmp (" k" , name) == 0 ) {
117
125
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" ];
121
128
global_charge (mechtype) = 1 .;
122
129
} else if (strcmp (" ca" , name) == 0 ) {
123
130
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" ];
127
133
global_charge (mechtype) = 2 .;
128
134
} 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
+ }
131
145
global_charge (mechtype) = VAL_SENTINAL;
132
146
}
133
147
}
0 commit comments