Skip to content

Commit

Permalink
Update references for nonspecific current (#9)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Luc Grosheintz <[email protected]>
  • Loading branch information
JCGoran and 1uc authored May 7, 2024
1 parent ed7a740 commit 763ca26
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
2 changes: 1 addition & 1 deletion cnexp_array/coreneuron/leonhard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ namespace coreneuron {


static inline int float_variables_size() {
return 7;
return 11;
}


Expand Down
2 changes: 1 addition & 1 deletion cnexp_array/neuron/leonhard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ namespace neuron {
_nrn_mechanism_field<double>{"g_unused"} /* 6 */
);

hoc_register_prop_size(mech_type, 7, 0);
hoc_register_prop_size(mech_type, 11, 0);
hoc_register_var(hoc_scalar_double, hoc_vector_double, hoc_intfunc);
hoc_register_npy_direct(mech_type, npy_direct_func_proc);
}
Expand Down
13 changes: 8 additions & 5 deletions nonspecific_current/coreneuron/leonhard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ namespace coreneuron {
static const char *mechanism_info[] = {
"7.7.0",
"leonhard",
"c_leonhard",
0,
"il_leonhard",
0,
Expand All @@ -60,6 +61,7 @@ namespace coreneuron {

/** all mechanism instance variables and global variables */
struct leonhard_Instance {
const double* c{};
double* il{};
double* v_unused{};
double* g_unused{};
Expand Down Expand Up @@ -90,7 +92,7 @@ namespace coreneuron {


static inline int float_variables_size() {
return 3;
return 4;
}


Expand Down Expand Up @@ -165,9 +167,10 @@ namespace coreneuron {
assert(ml->global_variables_size == sizeof(leonhard_Store));
int pnodecount = ml->_nodecount_padded;
Datum* indexes = ml->pdata;
inst->il = ml->data+0*pnodecount;
inst->v_unused = ml->data+1*pnodecount;
inst->g_unused = ml->data+2*pnodecount;
inst->c = ml->data+0*pnodecount;
inst->il = ml->data+1*pnodecount;
inst->v_unused = ml->data+2*pnodecount;
inst->g_unused = ml->data+3*pnodecount;
}


Expand Down Expand Up @@ -236,7 +239,7 @@ namespace coreneuron {

inline double nrn_current_leonhard(int id, int pnodecount, leonhard_Instance* inst, double* data, const Datum* indexes, ThreadDatum* thread, NrnThread* nt, double v) {
double current = 0.0;
inst->il[id] = 0.005 * (v - 1.5);
inst->il[id] = inst->c[id] * (v - 1.5);
current += inst->il[id];
return current;
}
Expand Down
21 changes: 13 additions & 8 deletions nonspecific_current/neuron/leonhard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ NMODL Compiler : VERSION
#define NRN_VECTORIZED 1

static constexpr auto number_of_datum_variables = 0;
static constexpr auto number_of_floating_point_variables = 3;
static constexpr auto number_of_floating_point_variables = 4;

namespace {
template <typename T>
Expand Down Expand Up @@ -54,6 +54,7 @@ namespace neuron {
static const char *mechanism_info[] = {
"7.7.0",
"leonhard",
"c_leonhard",
0,
"il_leonhard",
0,
Expand Down Expand Up @@ -84,6 +85,7 @@ namespace neuron {

/** all mechanism instance variables and global variables */
struct leonhard_Instance {
double* c{};
double* il{};
double* v_unused{};
double* g_unused{};
Expand All @@ -104,7 +106,8 @@ namespace neuron {
return leonhard_Instance {
_ml.template fpfield_ptr<0>(),
_ml.template fpfield_ptr<1>(),
_ml.template fpfield_ptr<2>()
_ml.template fpfield_ptr<2>(),
_ml.template fpfield_ptr<3>()
};
}

Expand All @@ -126,8 +129,9 @@ namespace neuron {
_nrn_mechanism_cache_instance _ml_real{_prop};
auto* const _ml = &_ml_real;
size_t const _iml{};
assert(_nrn_mechanism_get_num_vars(_prop) == 3);
assert(_nrn_mechanism_get_num_vars(_prop) == 4);
/*initialize range parameters*/
_ml->template fpfield<0>(_iml) = 0.005; /* c */
}


Expand Down Expand Up @@ -184,7 +188,7 @@ namespace neuron {

inline double nrn_current_leonhard(size_t id, leonhard_Instance& inst, leonhard_NodeData& node_data, double v) {
double current = 0.0;
inst.il[id] = 0.005 * (v - 1.5);
inst.il[id] = inst.c[id] * (v - 1.5);
current += inst.il[id];
return current;
}
Expand Down Expand Up @@ -252,12 +256,13 @@ namespace neuron {

mech_type = nrn_get_mechtype(mechanism_info[1]);
_nrn_mechanism_register_data_fields(mech_type,
_nrn_mechanism_field<double>{"il"} /* 0 */,
_nrn_mechanism_field<double>{"v_unused"} /* 1 */,
_nrn_mechanism_field<double>{"g_unused"} /* 2 */
_nrn_mechanism_field<double>{"c"} /* 0 */,
_nrn_mechanism_field<double>{"il"} /* 1 */,
_nrn_mechanism_field<double>{"v_unused"} /* 2 */,
_nrn_mechanism_field<double>{"g_unused"} /* 3 */
);

hoc_register_prop_size(mech_type, 3, 0);
hoc_register_prop_size(mech_type, 4, 0);
hoc_register_var(hoc_scalar_double, hoc_vector_double, hoc_intfunc);
hoc_register_npy_direct(mech_type, npy_direct_func_proc);
}
Expand Down

0 comments on commit 763ca26

Please sign in to comment.