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

Commit 513e648

Browse files
brunomagapramodk
authored andcommitted
capac functions for CVODE (#98)
* capac functions for CVODE
1 parent b74fb9f commit 513e648

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

coreneuron/nrnoc/capac.cpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ static const char* mechanism[] = {"0", "capacitance", "cm", 0, "i_cap", 0, 0};
5959
void nrn_alloc_capacitance(double*, Datum*, int);
6060
void nrn_init_capacitance(NrnThread*, Memb_list*, int);
6161
void 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

Comments
 (0)