1 #include <../../nrnconf.h>
51 #include "cvodes/cvodes.h"
52 #include "cvodes/cvodes_impl.h"
53 #include "cvodes/cvdense.h"
54 #include "cvodes/cvdiag.h"
55 #include "shared/dense.h"
60 #define nt_dt nrn_threads->_dt
61 #define nt_t nrn_threads->_t
79 extern void nrn2ncs_netcons();
83 extern N_Vector N_VNew_Parallel(
int comm,
long int local_length,
long int global_length);
94 #define SUCCESS CV_SUCCESS
130 #if BBTQ == 3 || BBTQ == 4
145 hoc_warning(
"CVode.queue_mode with second arg == 1 requires",
146 "configuration --with-mpi or related");
194 "Cannot find the symbol associated with the pointer when called from Python",
195 "Use a string instead of pointer argument");
229 return double(d->
stiff());
306 int i = (int)
chkarg(1, 0, 1e9);
309 style = (int)
chkarg(3, 0, 2);
392 int i = (int)
chkarg(1, 0, 10);
438 if (!ppobj || ppobj->ctemplate->is_point_ <= 0 ||
442 reinit = int(
chkarg(4, 0, 1));
469 return double(modeltype + 10 *
use_sparse13 + 100 * methodtype + 1000 * localtype);
508 d->
gcv_->use_partrans_ =
true;
536 for (
Object* callable: *esl) {
545 int direction = int(
chkarg(1, 0, 1));
560 for (
int direction = 0; direction < 2; ++direction) {
563 for (
auto it = esl->begin(); it != esl->end();) {
623 {
"print_event_queue",
peq},
681 static int minit(CVodeMem cv_mem);
682 static int msetup(CVodeMem cv_mem,
686 booleantype* jcurPtr,
690 static int msolve(CVodeMem cv_mem, N_Vector b, N_Vector weight, N_Vector ycur, N_Vector fcur);
696 static void mfree(CVodeMem cv_mem);
697 static void f_gvardt(realtype
t, N_Vector y, N_Vector ydot,
void* f_data);
698 static void f_lvardt(realtype
t, N_Vector y, N_Vector ydot,
void* f_data);
729 neosim_self_events_ =
nil;
746 use_partrans_ =
false;
754 return ((CVodeMem)
mem_)->cv_gamma;
762 return ((CVodeMem)
mem_)->cv_h;
794 if (te <= tstop_ && te >
t0_) {
817 return N_VNew_Parallel(0,
n, global_neq_);
845 return N_VNew_Serial(
n);
860 if (neosim_self_events_) {
861 delete neosim_self_events_;
934 if (on &&
neq_ > 0) {
992 for (
i = 0;
i <
n; ++
i) {
1007 for (
i = 0;
i <
n; ++
i) {
1024 CVodeGetLastOrder(
mem_, &
i);
1036 CVodeSetMaxOrd(
mem_, maxord);
1043 CVodeSetMinStep(
mem_, x);
1047 ((CVodeMem)
mem_)->cv_hmin = 0.;
1058 CVodeSetMaxStep(
mem_, x);
1092 CVodeSetFdata(
mem_, (
void*)
this);
1095 Printf(
"Cvode %p %s CVReInit error %d\n",
1102 mem_ = CVodeCreate(CV_BDF,
ncv_->
stiff() ? CV_NEWTON : CV_FUNCTIONAL);
1110 CVodeSetFdata(
mem_, (
void*)
this);
1112 Printf(
"Cvode %p %s CVodeMalloc error %d\n",
1121 ((CVodeMem)
mem_)->cv_gamma = 0.;
1122 ((CVodeMem)
mem_)->cv_h = 0.;
1125 (*pf_)(
t_,
y_,
nil, (
void*)
this);
1238 if (use_partrans_) {
1296 Printf(
"Cvode::interpolate assert error t0=%g tout-t0=%g eps*t_=%g\n",
1304 Printf(
"Cvode::interpolate assert error tn=%g tn-tout=%g eps*t_=%g\n",
1330 Printf(
"Cvode::cvode_advance_tn %p %d initialize_=%d tstop=%.20g t_=%.20g to ",
1347 Printf(
"CVode %p %s advance_tn failed, err=%d.\n",
1351 (*pf_)(
t_,
y_,
nil, (
void*)
this);
1357 (*pf_)(
t_,
y_,
nil, (
void*)
this);
1362 tn_ = ((CVodeMem)
mem_)->cv_tn;
1374 Printf(
"Cvode::cvode_interpolate %p %d initialize_%d t=%.20g to ",
1384 int err = CVode(
mem_, tout,
y_, &
t_, CV_NORMAL);
1391 Printf(
"CVode %p %s interpolate failed, err=%d.\n",
1397 (*pf_)(
t_,
y_,
nil, (
void*)
this);
1421 return ((CVodeMem)
mem_)->cv_ewt;
1429 return ((CVodeMem)
mem_)->cv_acor;
1435 Printf(
"\nCvode instance %p %s statistics : %d %s states\n",
1440 Printf(
" %d advance_tn, %d interpolate, %d init (%d due to at_time)\n",
1445 Printf(
" %d function evaluations, %d mx=b solves, %d jacobian setups\n",
1454 Printf(
"\nCVode Statistics.. \n\n");
1455 Printf(
"internal steps = %d\nfunction evaluations = %d\n", iopt_[NST], iopt_[NFE]);
1457 "newton iterations = %d setups = %d\n nonlinear convergence failures = %d\n\
1458 local error test failures = %ld\n",
1463 Printf(
"order=%d stepsize=%g\n", iopt_[QU],
h());
1477 if (((CVodeMem)
mem_)->cv_lfree) {
1478 ((CVodeMem)
mem_)->cv_lfree((CVodeMem)
mem_);
1479 ((CVodeMem)
mem_)->cv_lfree =
NULL;
1484 ((CVodeMem)
mem_)->cv_setupNonNull =
TRUE;
1497 return CV_NO_FAILURES;
1504 booleantype* jcurPtr,
1517 static int msolve(CVodeMem m, N_Vector b, N_Vector weight, N_Vector ycur, N_Vector fcur) {
1525 if (cv.ncv_->stiff() == 0) {
1528 if (cv.gam() == 0.) {
1542 static int msolve_lvardt(CVodeMem m, N_Vector b, N_Vector weight, N_Vector ycur, N_Vector fcur) {
1548 if (cv->
gam() == 0.) {
1592 static void f_gvardt(realtype
t, N_Vector y, N_Vector ydot,
void* f_data) {
1608 (*nrnmpi_v_transfer_)();
1617 (*nrnmpi_v_transfer_)();
1627 static void f_lvardt(realtype
t, N_Vector y, N_Vector ydot,
void* f_data) {
const char * secname(Section *sec)
void fun_thread_ms_part2(NrnThread *nt)
void do_nonode(NrnThread *nt=0)
int solvex_thread_part2(NrnThread *nt)
bool at_time(double, NrnThread *)
void fun_thread_transfer_part1(double t, double *y, NrnThread *nt)
int setup(N_Vector ypred, N_Vector fpred)
void fun_thread_ms_part4(double *ydot, NrnThread *nt)
void fun_thread_transfer_part2(double *ydot, NrnThread *nt)
void fun_thread_ms_part34(double *ydot, NrnThread *nt)
void fun_thread_ms_part1(double t, double *y, NrnThread *nt)
int solvex_thread_part3(double *b, NrnThread *nt)
void fun_thread(double t, double *y, double *ydot, NrnThread *nt)
void fun_thread_ms_part3(NrnThread *nt)
void scatter_y(double *, int)
virtual int init(double t)
double * n_vector_data(N_Vector, int)
virtual int interpolate(double t)
void activate_maxstate(bool)
int solvex_thread_part1(double *b, NrnThread *nt)
int cvode_interpolate(double)
int solvex_thread(double *b, double *y, NrnThread *nt)
int interpolate(double tout)
static int first_try_init_failures_
int advance_tn(double tstop)
static int init_failure_style_
static bool le(double x, double y, double e)
static bool eq(double x, double y, double e)
double state_magnitudes()
static double eps(double x)
void hoc_event(double, const char *hoc_stmt, Object *ppobj=nil, int reinit=0, Object *pyact=nil)
const char * statename(int, int style=1)
void re_init(double t0=0.)
Symbol * name2sym(const char *)
void(* nrn_multisplit_setup_)()
static void mfree(CVodeMem cv_mem)
Point_process * ob2pntproc(Object *)
double nrn_hoc2scatter_y(void *v)
static void f_lvardt(realtype t, N_Vector y, N_Vector ydot, void *f_data)
static double statistics(void *v)
void(* nrnthread_v_transfer_)(NrnThread *)
static double n_remove(void *v)
static double ncs_netcons(void *v)
static double extra_scatter_gather_remove(void *v)
static double nrn_diam_change_count(void *v)
static void * f_thread_ms_part2(NrnThread *)
Symbol * hoc_get_last_pointer_symbol()
static double solve(void *v)
static double state_magnitudes(void *v)
static double tstop_event(void *v)
static double poolshrink(void *)
static double store_events(void *v)
static Cvode * msolve_cv_
static void * f_thread_ms_part1(NrnThread *)
double nrn_hoc2gather_y(void *v)
static double debug_event(void *v)
static Member_func members[]
static void * cons(Object *)
static void * msolve_thread_part3(NrnThread *)
static double event_queue_info(void *v)
static double condition_order(void *v)
static void * msolve_thread_part1(NrnThread *)
static double error_weights(void *v)
static double use_daspk(void *v)
static void * msolve_thread(NrnThread *)
static void destruct(void *v)
static double extra_scatter_gather(void *v)
static int minit(CVodeMem cv_mem)
short * nrn_is_artificial_
static double order(void *v)
static double nrn_atol(void *v)
static ExtraScatterList * extra_scatterlist[2]
static double use_local_dt(void *v)
double nrn_hoc2fun(void *v)
static double states(void *v)
static void * maxstate_thread(NrnThread *nt)
int linmod_extra_eqn_count()
static double maxorder(void *v)
static double acor(void *v)
static double statename(void *v)
static double stiff(void *v)
static double cache_efficient(void *v)
static void * msolve_thread_part2(NrnThread *)
double nrn_hoc2fixed_step(void *v)
static double peq(void *v)
static double use_long_double(void *v)
static Member_ret_obj_func omembers[]
static double use_mxb(void *v)
static void * f_thread(NrnThread *)
static int msolve(CVodeMem cv_mem, N_Vector b, N_Vector weight, N_Vector ycur, N_Vector fcur)
void hoc_symbol_tolerance(Symbol *, double)
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 void * f_thread_ms_part4(NrnThread *)
static void * f_thread_transfer_part1(NrnThread *)
static double abstol(void *v)
static N_Vector msolve_ycur_
static double dstates(void *v)
static Cvode * maxstate_cv
static double minstep(void *v)
static int msolve_lvardt(CVodeMem cv_mem, N_Vector b, N_Vector weight, N_Vector ycur, N_Vector fcur)
static void * f_thread_ms_part34(NrnThread *)
std::vector< Object * > ExtraScatterList
static double nrn_structure_change_count(void *v)
static N_Vector msolve_b_
static void static_mutex_for_at_time(bool b)
static double jacobian(void *v)
static double current_method(void *v)
void nrn_extra_scatter_gather(int direction, int tid)
static double use_parallel(void *v)
static double re_init(void *v)
NetCvode * net_cvode_instance
int(* nrnpy_pysame)(Object *, Object *)
static double dae_init_dteps(void *v)
static Object ** netconlist(void *v)
static void * f_thread_transfer_part2(NrnThread *)
static void f_gvardt(realtype t, N_Vector y, N_Vector ydot, void *f_data)
static void * f_thread_ms_part3(NrnThread *)
static double use_fast_imem(void *v)
static double spikestat(void *v)
static double n_record(void *v)
static double active(void *v)
static double simgraph_remove(void *v)
static double queue_mode(void *v)
int(* nrnpy_hoccommand_exec)(Object *)
static double rtol(void *v)
static double maxstep(void *v)
void(* nrnmpi_v_transfer_)()
void nrn_poolshrink(int shrink)
double chkarg(int, double low, double high)
int nrn_vartype(Symbol *sym)
void hoc_execerror(const char *, const char *)
int hoc_is_object_arg(int narg)
int hoc_is_str_arg(int narg)
void hoc_assign_str(char **cpp, const char *buf)
void hoc_warning(const char *, const char *)
void hoc_obj_ref(Object *obj)
char * hoc_object_name(Object *ob)
double * hoc_pgetarg(int narg)
void hoc_obj_unref(Object *obj)
char ** hoc_pgargstr(int narg)
Object ** hoc_objgetarg(int)
void nrn_thread_error(const char *)
void nrn_multithread_job(void *(*job)(NrnThread *))
void nrn_fast_imem_alloc()
#define nrn_nonvint_block_ode_reinit(size, y, tid)
int const size_t const size_t n
#define MUTCONSTRUCT(mkmut)
void class2oc(const char *, void *(*cons)(Object *), void(*destruct)(void *), Member_func *, int(*checkpoint)(void **), Member_ret_obj_func *, Member_ret_str_func *)
N_Vector N_VNew_NrnParallelLD(MPI_Comm comm, long int local_length, long int global_length)
N_Vector N_VNew_NrnSerialLD(long int length)
N_Vector N_VNew_NrnThread(long int length, int nthread, long int *sizes)
N_Vector N_VNew_NrnThreadLD(long int length, int nthread, long int *sizes)
check_obj_type(o, "SectionList")
Represent main neuron object computed by single thread.
struct Symbol::@37::@38 rng