1 #include <../../nrnconf.h> 50 #include "cvodes/cvodes.h" 51 #include "cvodes/cvodes_impl.h" 52 #include "cvodes/cvdense.h" 53 #include "cvodes/cvdiag.h" 54 #include "shared/dense.h" 59 #define nt_dt nrn_threads->_dt 60 #define nt_t nrn_threads->_t 78 extern void nrn2ncs_netcons();
82 extern N_Vector N_VNew_Parallel(
int comm,
long int local_length,
83 long int global_length);
85 long int local_length,
long int global_length);
95 #define SUCCESS CV_SUCCESS 131 #if BBTQ == 3 || BBTQ == 4 146 hoc_warning(
"CVode.queue_mode with second arg == 1 requires",
147 "configuration --with-mpi or related");
194 hoc_execerror(
"Cannot find the symbol associated with the pointer when called from Python",
"Use a string instead of pointer argument");
228 return double(d->
stiff());
439 if (!ppobj || ppobj->ctemplate->is_point_ <= 0
472 return double( modeltype + 10*
use_sparse13 + 100*methodtype + 1000*localtype );
511 d->
gcv_->use_partrans_ =
true;
537 ExtraScatterList* esl = extra_scatterlist[direction];
540 for (
int i=0;
i < esl->count(); ++
i) {
541 Object* callable = esl->item(
i);
555 esl =
new ExtraScatterList(2);
565 for (
int direction=0; direction < 2; ++direction) {
567 if (esl)
for (
int i = esl->count()-1;
i >= 0; --
i) {
615 "print_event_queue",
peq,
649 if (net_cvode_instance) {
653 net_cvode_instance = d;
670 net_cvode_instance =
new NetCvode(1);
676 static int minit(CVodeMem cv_mem);
677 static int msetup(CVodeMem cv_mem,
int convfail, N_Vector ypred,
678 N_Vector fpred, booleantype *jcurPtr, N_Vector vtemp,
679 N_Vector vtemp2, N_Vector vtemp3);
680 static int msolve(CVodeMem cv_mem, N_Vector b, N_Vector weight, N_Vector ycur,
682 static int msolve_lvardt(CVodeMem cv_mem, N_Vector b, N_Vector weight, N_Vector ycur,
684 static void mfree(CVodeMem cv_mem);
685 static void f_gvardt(realtype
t, N_Vector y, N_Vector ydot,
void *f_data);
686 static void f_lvardt(realtype
t, N_Vector y, N_Vector ydot,
void *f_data);
718 neosim_self_events_ =
nil;
735 use_partrans_ =
false;
743 return ((CVodeMem)
mem_)->cv_gamma;
751 return ((CVodeMem)
mem_)->cv_h;
781 if (te <= tstop_ && te >
t0_) {
783 Printf(
"te-t0_=%g tstop_-te=%g\n", te - t0_,
tstop_ - te);
804 return N_VNew_Parallel(0, n, global_neq_);
830 return N_VNew_Serial(n);
845 if (neosim_self_events_) {
846 delete neosim_self_events_;
920 if (on &&
neq_ > 0) {
977 for (i=0; i <
n; ++
i) {
992 for (i=0; i <
n; ++
i) {
1007 if (
mem_) { CVodeGetLastOrder(
mem_, &i); }
1015 if (
mem_) { CVodeSetMaxOrd(
mem_, maxord); }
1021 CVodeSetMinStep(
mem_, x);
1025 ((CVodeMem)
mem_)->cv_hmin = 0.;
1033 if (
mem_) { CVodeSetMaxStep(
mem_, x); }
1067 CVodeSetFdata(
mem_, (
void*)
this);
1074 mem_ = CVodeCreate(CV_BDF,
ncv_->
stiff() ? CV_NEWTON : CV_FUNCTIONAL);
1079 CVodeSetFdata(
mem_, (
void*)
this);
1090 ((CVodeMem)
mem_)->cv_gamma = 0.;
1091 ((CVodeMem)
mem_)->cv_h = 0.;
1093 (*pf_)(
t_,
y_,
nil, (
void*)
this);
1196 if (use_partrans_) {
1279 Printf(
"Cvode::cvode_advance_tn %p %d initialize_=%d tstop=%.20g t_=%.20g to ",
1292 Printf(
"CVode %p %s advance_tn failed, err=%d.\n",
this,
secname(
ctd_[0].v_node_[
ctd_[0].rootnodecount_]->
sec), err);
1293 (*pf_)(
t_,
y_,
nil, (
void*)
this);
1299 (*pf_)(
t_,
y_,
nil, (
void*)
this);
1304 tn_ = ((CVodeMem)
mem_)->cv_tn;
1315 Printf(
"Cvode::cvode_interpolate %p %d initialize_%d t=%.20g to ",
1322 int err = CVode(
mem_, tout,
y_, &
t_, CV_NORMAL);
1329 Printf(
"CVode %p %s interpolate failed, err=%d.\n",
this,
secname(
ctd_[0].v_node_[
ctd_[0].rootnodecount_]->
sec), err);
1332 (*pf_)(
t_,
y_,
nil, (
void*)
this);
1354 return ((CVodeMem)
mem_)->cv_ewt;
1362 return ((CVodeMem)
mem_)->cv_acor;
1368 Printf(
"\nCvode instance %p %s statistics : %d %s states\n",
1378 Printf(
"\nCVode Statistics.. \n\n");
1379 Printf(
"internal steps = %d\nfunction evaluations = %d\n",
1380 iopt_[NST], iopt_[NFE]);
1381 Printf(
"newton iterations = %d setups = %d\n nonlinear convergence failures = %d\n\ 1382 local error test failures = %ld\n",
1383 iopt_[NNI], iopt_[NSETUPS], iopt_[NCFN], iopt_[NETF]);
1384 Printf(
"order=%d stepsize=%g\n", iopt_[QU],
h());
1399 ((CVodeMem)
mem_)->cv_setupNonNull =
TRUE;
1412 return CV_NO_FAILURES;
1416 N_Vector yp, N_Vector
fp, booleantype* jcurPtr,
1417 N_Vector, N_Vector, N_Vector)
1422 return cv->
setup(yp, fp);
1428 static int msolve(CVodeMem m, N_Vector b, N_Vector weight, N_Vector ycur, N_Vector fcur) {
1433 msolve_cv_ = (
Cvode*)m->cv_f_data;
1434 Cvode& cv = *msolve_cv_;
1436 if (cv.ncv_->stiff() == 0) {
return 0; }
1437 if (cv.gam() == 0.) {
return 0; }
1449 static int msolve_lvardt(CVodeMem m, N_Vector b, N_Vector weight, N_Vector ycur, N_Vector fcur) {
1453 if (cv->
gam() == 0.) {
return 0; }
1498 static void f_gvardt(realtype
t, N_Vector y, N_Vector ydot,
void *f_data) {
1502 f_cv_ = (
Cvode*)f_data;
1514 (*nrnmpi_v_transfer_)();
1523 (*nrnmpi_v_transfer_)();
1533 static void f_lvardt(realtype
t, N_Vector y, N_Vector ydot,
void *f_data) {
static double tstop_event(void *v)
static void * f_thread_transfer_part2(NrnThread *)
int(* nrnpy_hoccommand_exec)(Object *)
static double use_fast_imem(void *v)
void(* nrnthread_v_transfer_)(NrnThread *)
void fun_thread_ms_part4(double *ydot, NrnThread *nt)
static void * msetup_thread(NrnThread *)
int hoc_is_str_arg(int narg)
void nrn_multithread_job(void *(*job)(NrnThread *))
int solvex_thread_part3(double *b, NrnThread *nt)
static double n_remove(void *v)
void re_init(double t0=0.)
void(* nrn_multisplit_setup_)()
double nrn_hoc2fun(void *v)
int solvex_thread_part1(double *b, NrnThread *nt)
static double extra_scatter_gather(void *v)
static Object ** netconlist(void *v)
static void * f_thread_ms_part4(NrnThread *)
short * nrn_is_artificial_
double * n_vector_data(N_Vector, int)
static void * msolve_thread_part3(NrnThread *)
static double states(void *v)
char * hoc_object_name(Object *ob)
static N_Vector msolve_b_
static double rtol(void *v)
Represent main neuron object computed by single thread.
static double use_long_double(void *v)
void fun_thread_ms_part1(double t, double *y, NrnThread *nt)
static double minstep(void *v)
static void * cons(Object *)
check_obj_type(o, "SectionList")
static double dstates(void *v)
void nrn_thread_error(const char *)
static void * f_thread_ms_part1(NrnThread *)
void fun_thread_ms_part2(NrnThread *nt)
char ** hoc_pgargstr(int narg)
static int init_failure_style_
static double dae_init_dteps(void *v)
void scatter_y(double *, int)
void fun_thread(double t, double *y, double *ydot, NrnThread *nt)
static double abstol(void *v)
static double condition_order(void *v)
static double use_parallel(void *v)
static double order(void *v)
double * hoc_pgetarg(int narg)
void fun_thread_transfer_part1(double t, double *y, NrnThread *nt)
static double statistics(void *v)
static double re_init(void *v)
void nrn_extra_scatter_gather(int direction, int tid)
static double stiff(void *v)
void fun_thread_ms_part3(NrnThread *nt)
virtual int init(double t)
#define implementPtrList(PtrList, T)
static double queue_mode(void *v)
void hoc_assign_str(char **cpp, const char *buf)
Symbol * hoc_get_last_pointer_symbol()
void(* nrnmpi_v_transfer_)()
static Member_func members[]
int nrn_vartype(Symbol *sym)
int linmod_extra_eqn_count()
static Cvode * maxstate_cv
static double use_mxb(void *v)
static void * f_thread_ms_part3(NrnThread *)
int const size_t const size_t n
int cvode_interpolate(double)
static double ncs_netcons(void *v)
void class2oc(const char *, void *(*cons)(Object *), void(*destruct)(void *), Member_func *, int(*checkpoint)(void **), Member_ret_obj_func *, Member_ret_str_func *)
void hoc_obj_unref(Object *obj)
int advance_tn(double tstop)
void hoc_event(double, const char *hoc_stmt, Object *ppobj=nil, int reinit=0, Object *pyact=nil)
#define nrn_nonvint_block_ode_reinit(size, y, tid)
static double n_record(void *v)
const char * secname(Section *sec)
void hoc_warning(const char *, const char *)
int solvex_thread(double *b, double *y, NrnThread *nt)
N_Vector N_VNew_NrnSerialLD(long int length)
static void * f_thread(NrnThread *)
static double acor(void *v)
void activate_maxstate(bool)
bool at_time(double, NrnThread *)
static void * msolve_thread_part1(NrnThread *)
static bool le(double x, double y, double e)
void hoc_execerror(const char *, const char *)
static double use_daspk(void *v)
static double peq(void *v)
void nrn_fast_imem_alloc()
static double event_queue_info(void *v)
static double error_weights(void *v)
static void mfree(CVodeMem cv_mem)
static double nrn_atol(void *v)
static double nrn_diam_change_count(void *v)
static void * msolve_thread(NrnThread *)
void hoc_obj_ref(Object *obj)
declarePtrList(ExtraScatterList, Object) implementPtrList(ExtraScatterList
double state_magnitudes()
static bool eq(double x, double y, double e)
static double debug_event(void *v)
static int msolve(CVodeMem cv_mem, N_Vector b, N_Vector weight, N_Vector ycur, N_Vector fcur)
static double current_method(void *v)
double nrn_hoc2gather_y(void *v)
static double simgraph_remove(void *v)
static void * f_thread_transfer_part1(NrnThread *)
static double nrn_structure_change_count(void *v)
struct Symbol::@52::@53 rng
static void f_lvardt(realtype t, N_Vector y, N_Vector ydot, void *f_data)
#define MUTCONSTRUCT(mkmut)
static N_Vector msolve_ycur_
static double solve(void *v)
static double spikestat(void *v)
void do_nonode(NrnThread *nt=0)
static Object ExtraScatterList * extra_scatterlist[2]
double nrn_hoc2scatter_y(void *v)
double nrn_hoc2fixed_step(void *v)
const char * statename(int, int style=1)
static double statename(void *v)
static double eps(double x)
static int msolve_lvardt(CVodeMem cv_mem, N_Vector b, N_Vector weight, N_Vector ycur, N_Vector fcur)
static void destruct(void *v)
void fun_thread_transfer_part2(double *ydot, NrnThread *nt)
Symbol * name2sym(const char *)
N_Vector N_VNew_NrnThreadLD(long int length, int nthread, long int *sizes)
virtual int interpolate(double t)
void fun_thread_ms_part34(double *ydot, NrnThread *nt)
Point_process * ob2pntproc(Object *)
static void * maxstate_thread(NrnThread *nt)
static double maxorder(void *v)
static double state_magnitudes(void *v)
static void * f_thread_ms_part34(NrnThread *)
static void * msolve_thread_part2(NrnThread *)
N_Vector N_VNew_NrnParallelLD(MPI_Comm comm, long int local_length, long int global_length)
void hoc_symbol_tolerance(Symbol *, double)
int hoc_is_object_arg(int narg)
static int msetup(CVodeMem cv_mem, int convfail, N_Vector ypred, N_Vector fpred, booleantype *jcurPtr, N_Vector vtemp, N_Vector vtemp2, N_Vector vtemp3)
static double store_events(void *v)
static int minit(CVodeMem cv_mem)
static Member_ret_obj_func omembers[]
static double cache_efficient(void *v)
static Cvode * msolve_cv_
static void static_mutex_for_at_time(bool b)
Object ** hoc_objgetarg(int)
int(* nrnpy_pysame)(Object *, Object *)
static int first_try_init_failures_
NetCvode * net_cvode_instance
double chkarg(int, double low, double high)
int setup(N_Vector ypred, N_Vector fpred)
int solvex_thread_part2(NrnThread *nt)
static double extra_scatter_gather_remove(void *v)
static double active(void *v)
static void * f_thread_ms_part2(NrnThread *)
static double jacobian(void *v)
static double maxstep(void *v)
int interpolate(double tout)
static double use_local_dt(void *v)
N_Vector N_VNew_NrnThread(long int length, int nthread, long int *sizes)
static void f_gvardt(realtype t, N_Vector y, N_Vector ydot, void *f_data)