@@ -59,6 +59,8 @@ static const char* mechanism[] = {"0", "capacitance", "cm", 0, "i_cap", 0, 0};
5959void nrn_alloc_capacitance (double *, Datum*, int );
6060void nrn_init_capacitance (NrnThread*, Memb_list*, int );
6161void nrn_jacob_capacitance (NrnThread*, Memb_list*, int );
62+ void nrn_div_capacity (NrnThread*, Memb_list*, int );
63+ void nrn_mul_capacity (NrnThread*, Memb_list*, int );
6264
6365#define nparm 2
6466
@@ -179,4 +181,56 @@ void nrn_alloc_capacitance(double* data, Datum* pdata, int type) {
179181 (void )type; /* unused */
180182 data[0 ] = DEF_cm; /* default capacitance/cm^2*/
181183}
184+
185+ void nrn_div_capacity (NrnThread* _nt, Memb_list* ml, int type) {
186+ (void )type;
187+ int _cntml_actual = ml->nodecount ;
188+ int _cntml_padded = ml->_nodecount_padded ;
189+ int _iml;
190+ double * vdata;
191+ (void )_nt;
192+ (void )type;
193+ (void )_cntml_padded; /* unused */
194+
195+ int * ni = ml->nodeindices ;
196+
197+ #if LAYOUT == 1 /* AoS*/
198+ for (_iml = 0 ; _iml < _cntml_actual; _iml++) {
199+ vdata = ml->data + _iml * nparm;
200+ #else
201+ vdata = ml->data ;
202+ _PRAGMA_FOR_INIT_ACC_LOOP_
203+ for (_iml = 0 ; _iml < _cntml_actual; _iml++) {
204+ #endif
205+ i_cap = VEC_RHS (ni[_iml]);
206+ VEC_RHS (ni[_iml]) /= 1 .e -3 * cm;
207+ // fprintf(stderr, "== nrn_div_cap: RHS[%d]=%.12f\n", ni[_iml], VEC_RHS(ni[_iml])) ;
208+ }
209+ }
210+
211+ void nrn_mul_capacity (NrnThread* _nt, Memb_list* ml, int type) {
212+ (void )type;
213+ int _cntml_actual = ml->nodecount ;
214+ int _cntml_padded = ml->_nodecount_padded ;
215+ int _iml;
216+ double * vdata;
217+ (void )_nt;
218+ (void )type;
219+ (void )_cntml_padded; /* unused */
220+
221+ int * ni = ml->nodeindices ;
222+
223+ const double cfac = .001 * _nt->cj ;
224+
225+ #if LAYOUT == 1 /* AoS*/
226+ for (_iml = 0 ; _iml < _cntml_actual; _iml++) {
227+ vdata = ml->data + _iml * nparm;
228+ #else
229+ vdata = ml->data ;
230+ _PRAGMA_FOR_INIT_ACC_LOOP_
231+ for (_iml = 0 ; _iml < _cntml_actual; _iml++) {
232+ #endif
233+ VEC_RHS (ni[_iml]) *= cfac * cm;
234+ }
235+ }
182236} // namespace coreneuron
0 commit comments