Skip to content

Commit

Permalink
References for 'BlueBrain/nmodl#1434'.
Browse files Browse the repository at this point in the history
  • Loading branch information
GitHub Actions Bot committed Sep 18, 2024
1 parent 61e41f2 commit 07c2a0c
Show file tree
Hide file tree
Showing 15 changed files with 153 additions and 153 deletions.
8 changes: 4 additions & 4 deletions global/neuron/thread_newton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,8 +603,8 @@ namespace neuron {
const double* nmodl_eigen_x = nmodl_eigen_xm.data();
double* nmodl_eigen_j = nmodl_eigen_jm.data();
double* nmodl_eigen_f = nmodl_eigen_fm.data();
nmodl_eigen_f[static_cast<int>(0)] = ( -nmodl_eigen_x[static_cast<int>(0)] + nt->_dt * source0_ + old_X) / nt->_dt;
nmodl_eigen_j[static_cast<int>(0)] = -1.0 / nt->_dt;
nmodl_eigen_f[0] = ( -nmodl_eigen_x[0] + nt->_dt * source0_ + old_X) / nt->_dt;
nmodl_eigen_j[0] = -1.0 / nt->_dt;
}

void finalize() {
Expand Down Expand Up @@ -689,13 +689,13 @@ namespace neuron {

Eigen::Matrix<double, 1, 1> nmodl_eigen_xm;
double* nmodl_eigen_x = nmodl_eigen_xm.data();
nmodl_eigen_x[static_cast<int>(0)] = inst.X[id];
nmodl_eigen_x[0] = inst.X[id];
// call newton solver
functor_thread_newton_0 newton_functor(_lmc, inst, node_data, id, _ppvar, _thread, _thread_vars, nt, v);
newton_functor.initialize();
int newton_iterations = nmodl::newton::newton_solver(nmodl_eigen_xm, newton_functor);
if (newton_iterations < 0) assert(false && "Newton solver did not converge!");
inst.X[id] = nmodl_eigen_x[static_cast<int>(0)];
inst.X[id] = nmodl_eigen_x[0];
newton_functor.initialize(); // TODO mimic calling F again.
newton_functor.finalize();

Expand Down
8 changes: 4 additions & 4 deletions global/neuron/thread_variable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ namespace neuron {
inline double sum_arr_shared_global(_nrn_mechanism_cache_range& _lmc, shared_global_Instance& inst, shared_global_NodeData& node_data, size_t id, Datum* _ppvar, Datum* _thread, shared_global_ThreadVariables& _thread_vars, NrnThread* nt) {
double ret_sum_arr = 0.0;
auto v = node_data.node_voltages[node_data.nodeindices[id]];
ret_sum_arr = (_thread_vars.g_arr_ptr(id))[static_cast<int>(0)] + (_thread_vars.g_arr_ptr(id))[static_cast<int>(1)] + (_thread_vars.g_arr_ptr(id))[static_cast<int>(2)];
ret_sum_arr = (_thread_vars.g_arr_ptr(id))[0] + (_thread_vars.g_arr_ptr(id))[1] + (_thread_vars.g_arr_ptr(id))[2];
return ret_sum_arr;
}

Expand All @@ -478,9 +478,9 @@ namespace neuron {
auto v = node_data.node_voltages[node_id];
_thread_vars.g_w(id) = 48.0;
_thread_vars.g_v1(id) = 0.0;
(_thread_vars.g_arr_ptr(id))[static_cast<int>(0)] = 10.0 + inst.z[id];
(_thread_vars.g_arr_ptr(id))[static_cast<int>(1)] = 10.1;
(_thread_vars.g_arr_ptr(id))[static_cast<int>(2)] = 10.2;
(_thread_vars.g_arr_ptr(id))[0] = 10.0 + inst.z[id];
(_thread_vars.g_arr_ptr(id))[1] = 10.1;
(_thread_vars.g_arr_ptr(id))[2] = 10.2;
inst.y[id] = 10.0;
}
}
Expand Down
20 changes: 10 additions & 10 deletions kinetic/coreneuron/X2Y.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -640,12 +640,12 @@ namespace coreneuron {
const double* nmodl_eigen_x = nmodl_eigen_xm.data();
double* nmodl_eigen_j = nmodl_eigen_jm.data();
double* nmodl_eigen_f = nmodl_eigen_fm.data();
nmodl_eigen_f[static_cast<int>(0)] = ( -nmodl_eigen_x[static_cast<int>(0)] + nt->_dt * ( -nmodl_eigen_x[static_cast<int>(0)] * kf0_ + nmodl_eigen_x[static_cast<int>(1)] * kb0_) + old_X) / nt->_dt;
nmodl_eigen_j[static_cast<int>(0)] = -kf0_ - 1.0 / nt->_dt;
nmodl_eigen_j[static_cast<int>(2)] = kb0_;
nmodl_eigen_f[static_cast<int>(1)] = ( -nmodl_eigen_x[static_cast<int>(1)] + nt->_dt * (nmodl_eigen_x[static_cast<int>(0)] * kf0_ - nmodl_eigen_x[static_cast<int>(1)] * kb0_) + old_Y) / nt->_dt;
nmodl_eigen_j[static_cast<int>(1)] = kf0_;
nmodl_eigen_j[static_cast<int>(3)] = -kb0_ - 1.0 / nt->_dt;
nmodl_eigen_f[0] = ( -nmodl_eigen_x[0] + nt->_dt * ( -nmodl_eigen_x[0] * kf0_ + nmodl_eigen_x[1] * kb0_) + old_X) / nt->_dt;
nmodl_eigen_j[0] = -kf0_ - 1.0 / nt->_dt;
nmodl_eigen_j[2] = kb0_;
nmodl_eigen_f[1] = ( -nmodl_eigen_x[1] + nt->_dt * (nmodl_eigen_x[0] * kf0_ - nmodl_eigen_x[1] * kb0_) + old_Y) / nt->_dt;
nmodl_eigen_j[1] = kf0_;
nmodl_eigen_j[3] = -kb0_ - 1.0 / nt->_dt;
}

void finalize() {
Expand Down Expand Up @@ -757,15 +757,15 @@ namespace coreneuron {

Eigen::Matrix<double, 2, 1> nmodl_eigen_xm;
double* nmodl_eigen_x = nmodl_eigen_xm.data();
nmodl_eigen_x[static_cast<int>(0)] = inst->X[id];
nmodl_eigen_x[static_cast<int>(1)] = inst->Y[id];
nmodl_eigen_x[0] = inst->X[id];
nmodl_eigen_x[1] = inst->Y[id];
// call newton solver
functor_X2Y_0 newton_functor(nt, inst, id, pnodecount, v, indexes, data, thread);
newton_functor.initialize();
int newton_iterations = nmodl::newton::newton_solver(nmodl_eigen_xm, newton_functor);
if (newton_iterations < 0) assert(false && "Newton solver did not converge!");
inst->X[id] = nmodl_eigen_x[static_cast<int>(0)];
inst->Y[id] = nmodl_eigen_x[static_cast<int>(1)];
inst->X[id] = nmodl_eigen_x[0];
inst->Y[id] = nmodl_eigen_x[1];
newton_functor.initialize(); // TODO mimic calling F again.
newton_functor.finalize();

Expand Down
20 changes: 10 additions & 10 deletions kinetic/coreneuron/side_effects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,12 +639,12 @@ namespace coreneuron {
const double* nmodl_eigen_x = nmodl_eigen_xm.data();
double* nmodl_eigen_j = nmodl_eigen_jm.data();
double* nmodl_eigen_f = nmodl_eigen_fm.data();
nmodl_eigen_f[static_cast<int>(0)] = ( -nmodl_eigen_x[static_cast<int>(0)] + nt->_dt * ( -nmodl_eigen_x[static_cast<int>(0)] * kf0_ + nmodl_eigen_x[static_cast<int>(1)] * kb0_) + old_X) / nt->_dt;
nmodl_eigen_j[static_cast<int>(0)] = -kf0_ - 1.0 / nt->_dt;
nmodl_eigen_j[static_cast<int>(2)] = kb0_;
nmodl_eigen_f[static_cast<int>(1)] = ( -nmodl_eigen_x[static_cast<int>(1)] + nt->_dt * (nmodl_eigen_x[static_cast<int>(0)] * kf0_ - nmodl_eigen_x[static_cast<int>(1)] * kb0_) + old_Y) / nt->_dt;
nmodl_eigen_j[static_cast<int>(1)] = kf0_;
nmodl_eigen_j[static_cast<int>(3)] = -kb0_ - 1.0 / nt->_dt;
nmodl_eigen_f[0] = ( -nmodl_eigen_x[0] + nt->_dt * ( -nmodl_eigen_x[0] * kf0_ + nmodl_eigen_x[1] * kb0_) + old_X) / nt->_dt;
nmodl_eigen_j[0] = -kf0_ - 1.0 / nt->_dt;
nmodl_eigen_j[2] = kb0_;
nmodl_eigen_f[1] = ( -nmodl_eigen_x[1] + nt->_dt * (nmodl_eigen_x[0] * kf0_ - nmodl_eigen_x[1] * kb0_) + old_Y) / nt->_dt;
nmodl_eigen_j[1] = kf0_;
nmodl_eigen_j[3] = -kb0_ - 1.0 / nt->_dt;
}

void finalize() {
Expand Down Expand Up @@ -746,15 +746,15 @@ namespace coreneuron {

Eigen::Matrix<double, 2, 1> nmodl_eigen_xm;
double* nmodl_eigen_x = nmodl_eigen_xm.data();
nmodl_eigen_x[static_cast<int>(0)] = inst->X[id];
nmodl_eigen_x[static_cast<int>(1)] = inst->Y[id];
nmodl_eigen_x[0] = inst->X[id];
nmodl_eigen_x[1] = inst->Y[id];
// call newton solver
functor_side_effects_0 newton_functor(nt, inst, id, pnodecount, v, indexes, data, thread);
newton_functor.initialize();
int newton_iterations = nmodl::newton::newton_solver(nmodl_eigen_xm, newton_functor);
if (newton_iterations < 0) assert(false && "Newton solver did not converge!");
inst->X[id] = nmodl_eigen_x[static_cast<int>(0)];
inst->Y[id] = nmodl_eigen_x[static_cast<int>(1)];
inst->X[id] = nmodl_eigen_x[0];
inst->Y[id] = nmodl_eigen_x[1];
newton_functor.initialize(); // TODO mimic calling F again.
newton_functor.finalize();

Expand Down
20 changes: 10 additions & 10 deletions kinetic/neuron/X2Y.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -599,12 +599,12 @@ namespace neuron {
const double* nmodl_eigen_x = nmodl_eigen_xm.data();
double* nmodl_eigen_j = nmodl_eigen_jm.data();
double* nmodl_eigen_f = nmodl_eigen_fm.data();
nmodl_eigen_f[static_cast<int>(0)] = ( -nmodl_eigen_x[static_cast<int>(0)] + nt->_dt * ( -nmodl_eigen_x[static_cast<int>(0)] * kf0_ + nmodl_eigen_x[static_cast<int>(1)] * kb0_) + old_X) / nt->_dt;
nmodl_eigen_j[static_cast<int>(0)] = -kf0_ - 1.0 / nt->_dt;
nmodl_eigen_j[static_cast<int>(2)] = kb0_;
nmodl_eigen_f[static_cast<int>(1)] = ( -nmodl_eigen_x[static_cast<int>(1)] + nt->_dt * (nmodl_eigen_x[static_cast<int>(0)] * kf0_ - nmodl_eigen_x[static_cast<int>(1)] * kb0_) + old_Y) / nt->_dt;
nmodl_eigen_j[static_cast<int>(1)] = kf0_;
nmodl_eigen_j[static_cast<int>(3)] = -kb0_ - 1.0 / nt->_dt;
nmodl_eigen_f[0] = ( -nmodl_eigen_x[0] + nt->_dt * ( -nmodl_eigen_x[0] * kf0_ + nmodl_eigen_x[1] * kb0_) + old_X) / nt->_dt;
nmodl_eigen_j[0] = -kf0_ - 1.0 / nt->_dt;
nmodl_eigen_j[2] = kb0_;
nmodl_eigen_f[1] = ( -nmodl_eigen_x[1] + nt->_dt * (nmodl_eigen_x[0] * kf0_ - nmodl_eigen_x[1] * kb0_) + old_Y) / nt->_dt;
nmodl_eigen_j[1] = kf0_;
nmodl_eigen_j[3] = -kb0_ - 1.0 / nt->_dt;
}

void finalize() {
Expand Down Expand Up @@ -748,15 +748,15 @@ namespace neuron {

Eigen::Matrix<double, 2, 1> nmodl_eigen_xm;
double* nmodl_eigen_x = nmodl_eigen_xm.data();
nmodl_eigen_x[static_cast<int>(0)] = inst.X[id];
nmodl_eigen_x[static_cast<int>(1)] = inst.Y[id];
nmodl_eigen_x[0] = inst.X[id];
nmodl_eigen_x[1] = inst.Y[id];
// call newton solver
functor_X2Y_0 newton_functor(_lmc, inst, node_data, id, _ppvar, _thread, nt, v);
newton_functor.initialize();
int newton_iterations = nmodl::newton::newton_solver(nmodl_eigen_xm, newton_functor);
if (newton_iterations < 0) assert(false && "Newton solver did not converge!");
inst.X[id] = nmodl_eigen_x[static_cast<int>(0)];
inst.Y[id] = nmodl_eigen_x[static_cast<int>(1)];
inst.X[id] = nmodl_eigen_x[0];
inst.Y[id] = nmodl_eigen_x[1];
newton_functor.initialize(); // TODO mimic calling F again.
newton_functor.finalize();

Expand Down
20 changes: 10 additions & 10 deletions kinetic/neuron/side_effects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,12 +600,12 @@ namespace neuron {
const double* nmodl_eigen_x = nmodl_eigen_xm.data();
double* nmodl_eigen_j = nmodl_eigen_jm.data();
double* nmodl_eigen_f = nmodl_eigen_fm.data();
nmodl_eigen_f[static_cast<int>(0)] = ( -nmodl_eigen_x[static_cast<int>(0)] + nt->_dt * ( -nmodl_eigen_x[static_cast<int>(0)] * kf0_ + nmodl_eigen_x[static_cast<int>(1)] * kb0_) + old_X) / nt->_dt;
nmodl_eigen_j[static_cast<int>(0)] = -kf0_ - 1.0 / nt->_dt;
nmodl_eigen_j[static_cast<int>(2)] = kb0_;
nmodl_eigen_f[static_cast<int>(1)] = ( -nmodl_eigen_x[static_cast<int>(1)] + nt->_dt * (nmodl_eigen_x[static_cast<int>(0)] * kf0_ - nmodl_eigen_x[static_cast<int>(1)] * kb0_) + old_Y) / nt->_dt;
nmodl_eigen_j[static_cast<int>(1)] = kf0_;
nmodl_eigen_j[static_cast<int>(3)] = -kb0_ - 1.0 / nt->_dt;
nmodl_eigen_f[0] = ( -nmodl_eigen_x[0] + nt->_dt * ( -nmodl_eigen_x[0] * kf0_ + nmodl_eigen_x[1] * kb0_) + old_X) / nt->_dt;
nmodl_eigen_j[0] = -kf0_ - 1.0 / nt->_dt;
nmodl_eigen_j[2] = kb0_;
nmodl_eigen_f[1] = ( -nmodl_eigen_x[1] + nt->_dt * (nmodl_eigen_x[0] * kf0_ - nmodl_eigen_x[1] * kb0_) + old_Y) / nt->_dt;
nmodl_eigen_j[1] = kf0_;
nmodl_eigen_j[3] = -kb0_ - 1.0 / nt->_dt;
}

void finalize() {
Expand Down Expand Up @@ -698,15 +698,15 @@ namespace neuron {

Eigen::Matrix<double, 2, 1> nmodl_eigen_xm;
double* nmodl_eigen_x = nmodl_eigen_xm.data();
nmodl_eigen_x[static_cast<int>(0)] = inst.X[id];
nmodl_eigen_x[static_cast<int>(1)] = inst.Y[id];
nmodl_eigen_x[0] = inst.X[id];
nmodl_eigen_x[1] = inst.Y[id];
// call newton solver
functor_side_effects_0 newton_functor(_lmc, inst, node_data, id, _ppvar, _thread, nt, v);
newton_functor.initialize();
int newton_iterations = nmodl::newton::newton_solver(nmodl_eigen_xm, newton_functor);
if (newton_iterations < 0) assert(false && "Newton solver did not converge!");
inst.X[id] = nmodl_eigen_x[static_cast<int>(0)];
inst.Y[id] = nmodl_eigen_x[static_cast<int>(1)];
inst.X[id] = nmodl_eigen_x[0];
inst.Y[id] = nmodl_eigen_x[1];
newton_functor.initialize(); // TODO mimic calling F again.
newton_functor.finalize();

Expand Down
12 changes: 6 additions & 6 deletions solve/coreneuron/cnexp_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,11 @@ namespace coreneuron {
(inst->s+id*2)[0] = inst->global->s0;
(inst->s+id*2)[1] = inst->global->s0;
inst->x[id] = 42.0;
(inst->s+id*2)[static_cast<int>(0)] = 0.1;
(inst->s+id*2)[static_cast<int>(1)] = -1.0;
(inst->z+id*3)[static_cast<int>(0)] = 0.7;
(inst->z+id*3)[static_cast<int>(1)] = 0.8;
(inst->z+id*3)[static_cast<int>(2)] = 0.9;
(inst->s+id*2)[0] = 0.1;
(inst->s+id*2)[1] = -1.0;
(inst->z+id*3)[0] = 0.7;
(inst->z+id*3)[1] = 0.8;
(inst->z+id*3)[2] = 0.9;
}
}
}
Expand All @@ -276,7 +276,7 @@ namespace coreneuron {
#if NRN_PRCELLSTATE
inst->v_unused[id] = v;
#endif
inst->x[id] = inst->x[id] + (1.0 - exp(nt->_dt * ((((inst->s+id*2)[static_cast<int>(0)] + (inst->s+id*2)[static_cast<int>(1)]) * ((inst->z+id*3)[static_cast<int>(0)] * (inst->z+id*3)[static_cast<int>(1)] * (inst->z+id*3)[static_cast<int>(2)])) * (1.0)))) * ( -(0.0) / (((((inst->s+id*2)[static_cast<int>(0)] + (inst->s+id*2)[static_cast<int>(1)])) * (((((inst->z+id*3)[static_cast<int>(0)]) * ((inst->z+id*3)[static_cast<int>(1)])) * ((inst->z+id*3)[static_cast<int>(2)])))) * (1.0)) - inst->x[id]);
inst->x[id] = inst->x[id] + (1.0 - exp(nt->_dt * ((((inst->s+id*2)[0] + (inst->s+id*2)[1]) * ((inst->z+id*3)[0] * (inst->z+id*3)[1] * (inst->z+id*3)[2])) * (1.0)))) * ( -(0.0) / (((((inst->s+id*2)[0] + (inst->s+id*2)[1])) * (((((inst->z+id*3)[0]) * ((inst->z+id*3)[1])) * ((inst->z+id*3)[2])))) * (1.0)) - inst->x[id]);
}
}

Expand Down
12 changes: 6 additions & 6 deletions solve/coreneuron/derivimplicit_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ namespace coreneuron {
auto const& slist1 = inst->global->slist1;
auto const& dlist1 = inst->global->dlist1;
double* dlist2 = static_cast<double*>(thread[dith1()].pval) + (1*pnodecount);
inst->Dx[id] = ((inst->s+id*2)[static_cast<int>(0)] + (inst->s+id*2)[static_cast<int>(1)]) * ((inst->z+id*3)[static_cast<int>(0)] * (inst->z+id*3)[static_cast<int>(1)] * (inst->z+id*3)[static_cast<int>(2)]) * inst->x[id];
inst->Dx[id] = ((inst->s+id*2)[0] + (inst->s+id*2)[1]) * ((inst->z+id*3)[0] * (inst->z+id*3)[1] * (inst->z+id*3)[2]) * inst->x[id];
int counter = -1;
for (int i=0; i<1; i++) {
if (*deriv1_advance(thread)) {
Expand Down Expand Up @@ -326,11 +326,11 @@ namespace coreneuron {
(inst->s+id*2)[0] = inst->global->s0;
(inst->s+id*2)[1] = inst->global->s0;
inst->x[id] = 42.0;
(inst->s+id*2)[static_cast<int>(0)] = 0.1;
(inst->s+id*2)[static_cast<int>(1)] = -1.0;
(inst->z+id*3)[static_cast<int>(0)] = 0.7;
(inst->z+id*3)[static_cast<int>(1)] = 0.8;
(inst->z+id*3)[static_cast<int>(2)] = 0.9;
(inst->s+id*2)[0] = 0.1;
(inst->s+id*2)[1] = -1.0;
(inst->z+id*3)[0] = 0.7;
(inst->z+id*3)[1] = 0.8;
(inst->z+id*3)[2] = 0.9;
}
}
deriv_advance_flag = 1;
Expand Down
12 changes: 6 additions & 6 deletions solve/neuron/cnexp_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,11 @@ namespace neuron {
(inst.s+id*2)[0] = inst.global->s0;
(inst.s+id*2)[1] = inst.global->s0;
inst.x[id] = 42.0;
(inst.s+id*2)[static_cast<int>(0)] = 0.1;
(inst.s+id*2)[static_cast<int>(1)] = -1.0;
(inst.z+id*3)[static_cast<int>(0)] = 0.7;
(inst.z+id*3)[static_cast<int>(1)] = 0.8;
(inst.z+id*3)[static_cast<int>(2)] = 0.9;
(inst.s+id*2)[0] = 0.1;
(inst.s+id*2)[1] = -1.0;
(inst.z+id*3)[0] = 0.7;
(inst.z+id*3)[1] = 0.8;
(inst.z+id*3)[2] = 0.9;
}
}

Expand All @@ -240,7 +240,7 @@ namespace neuron {
int node_id = node_data.nodeindices[id];
auto* _ppvar = _ml_arg->pdata[id];
auto v = node_data.node_voltages[node_id];
inst.x[id] = inst.x[id] + (1.0 - exp(nt->_dt * ((((inst.s+id*2)[static_cast<int>(0)] + (inst.s+id*2)[static_cast<int>(1)]) * ((inst.z+id*3)[static_cast<int>(0)] * (inst.z+id*3)[static_cast<int>(1)] * (inst.z+id*3)[static_cast<int>(2)])) * (1.0)))) * ( -(0.0) / (((((inst.s+id*2)[static_cast<int>(0)] + (inst.s+id*2)[static_cast<int>(1)])) * (((((inst.z+id*3)[static_cast<int>(0)]) * ((inst.z+id*3)[static_cast<int>(1)])) * ((inst.z+id*3)[static_cast<int>(2)])))) * (1.0)) - inst.x[id]);
inst.x[id] = inst.x[id] + (1.0 - exp(nt->_dt * ((((inst.s+id*2)[0] + (inst.s+id*2)[1]) * ((inst.z+id*3)[0] * (inst.z+id*3)[1] * (inst.z+id*3)[2])) * (1.0)))) * ( -(0.0) / (((((inst.s+id*2)[0] + (inst.s+id*2)[1])) * (((((inst.z+id*3)[0]) * ((inst.z+id*3)[1])) * ((inst.z+id*3)[2])))) * (1.0)) - inst.x[id]);
}
}

Expand Down
Loading

0 comments on commit 07c2a0c

Please sign in to comment.