@@ -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+
6372void 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