NEURON
cvodestb.cpp
Go to the documentation of this file.
1 #include <../../nrnconf.h>
2 // solver CVode stub to allow cvode as dll for mswindows version.
3 
4 #include <cmath>
5 #include "classreg.h"
6 #include "cvodeobj.h"
7 #include "nrncvode.h"
8 #include "nrniv_mf.h"
9 #include "nrnoc2iv.h"
10 #include "datapath.h"
11 #if USECVODE
12 #include "cvodeobj.h"
13 #include "netcvode.h"
14 #else
15 class Cvode;
16 #endif
17 
18 void cvode_finitialize(double t0);
19 void nrncvode_set_t(double);
20 
21 extern double dt, t;
22 #define nt_t nrn_threads->_t
23 #define nt_dt nrn_threads->_dt
24 extern int nrn_use_daspk_;
25 
29 void init_net_events();
30 void nrn_record_init();
31 void nrn_play_init();
33 void nrn_solver_prepare();
34 
35 // for fixed step thread
37  if (net_cvode_instance) {
40  }
41 }
42 
43 // handle events during finitialize()
45  double tsav = nt->_t;
46  if (net_cvode_instance) {
48  }
49  nt->_t = tsav;
50 }
51 
53  if (net_cvode_instance) {
55  }
56 }
57 
59  if (net_cvode_instance) {
61  }
62 }
63 
65  if (net_cvode_instance) {
67  }
68 }
69 
71  if (net_cvode_instance) {
73  }
74 }
75 
76 void nrn_play_init() {
77  if (net_cvode_instance) {
79  }
80 }
81 
83  if (net_cvode_instance) {
85  }
86 }
87 
89  if (net_cvode_instance) {
91  }
92 }
93 
95  if (net_cvode_instance) {
97  }
98 }
99 
100 void cvode_fadvance(double tstop) { // tstop = -1 means single step
101 #if USECVODE
102  int err;
103  if (net_cvode_instance) {
106  }
107  nrn_random_play();
108  err = net_cvode_instance->solve(tstop);
109  if (err != 0) {
110  printf("err=%d\n", err);
111  hoc_execerror("variable step integrator error", 0);
112  }
113  t = nt_t;
114  dt = nt_dt;
115  }
116 #endif
117 }
118 
119 void cvode_finitialize(double t0) {
120 #if USECVODE
121  if (net_cvode_instance) {
123  }
124 #endif
125 }
126 
127 bool at_time(NrnThread* nt, double te) {
128 #if USECVODE
129  if (cvode_active_ && nt->_vcv) {
130  return ((Cvode*) nt->_vcv)->at_time(te, nt);
131  }
132 #endif
133  double x = te - 1e-11;
134  return (x <= nt->_t && x > (nt->_t - nt->_dt));
135 }
136 
137 void nrncvode_set_t(double tt) {
139  if (nc->gcv_) {
140  Cvode& cv = *nc->gcv_;
141  cv.tn_ = cv.t_ = cv.t0_ = tt;
142  } else {
143  for (int i = 0; i < nc->pcnt_; ++i) {
144  NetCvodeThreadData& p = nc->p[i];
145  for (int j = 0; j < p.nlcv_; ++j) {
146  Cvode& cv = p.lcv_[j];
147  cv.tn_ = cv.t_ = cv.t0_ = tt;
148  }
149  }
150  }
151 }
int tree_changed
Definition: cabcode.cpp:51
Definition: cvodeobj.h:97
double t_
Definition: cvodeobj.h:126
double t0_
Definition: cvodeobj.h:126
double tn_
Definition: cvodeobj.h:126
virtual double t0()
Definition: cvodeobj.h:110
void deliver_events(double til, NrnThread *)
Definition: netcvode.cpp:2835
NetCvodeThreadData * p
Definition: netcvode.h:249
void play_init()
Definition: netcvode.cpp:4139
Cvode * gcv_
Definition: netcvode.h:243
void check_thresh(NrnThread *)
Definition: netcvode.cpp:5914
void init_events()
Definition: netcvode.cpp:2749
void deliver_net_events(NrnThread *)
Definition: netcvode.cpp:5958
void fixed_record_continuous(neuron::model_sorted_token const &, NrnThread &nt)
Definition: netcvode.cpp:5524
void free_event_pools()
Definition: netcvode.cpp:2735
void clear_events()
Definition: netcvode.cpp:2663
int pcnt_
Definition: netcvode.h:248
void solver_prepare()
Definition: netcvode.cpp:3925
void re_init(double t0=0.)
Definition: netcvode.cpp:3958
int solve(double t)
Definition: netcvode.cpp:1949
void fixed_play_continuous(NrnThread *)
Definition: netcvode.cpp:5534
void record_init()
Definition: netcvode.cpp:4123
#define i
Definition: md1redef.h:19
printf
Definition: extdef.h:5
nrn_random_play
Definition: extdef.h:10
bool cvode_active_
Definition: netcvode.cpp:36
int v_structure_change
Definition: nrnoc_aux.cpp:20
void hoc_execerror(const char *s1, const char *s2)
Definition: nrnoc_aux.cpp:39
int diam_changed
Definition: nrnoc_aux.cpp:21
double dt
Definition: netcvode.cpp:70
void free_event_queues()
Definition: cvodestb.cpp:58
#define nt_dt
Definition: cvodestb.cpp:23
void cvode_fadvance(double tstop)
Definition: cvodestb.cpp:100
bool at_time(NrnThread *nt, double te)
Definition: cvodestb.cpp:127
void nrn_record_init()
Definition: cvodestb.cpp:70
void nrn_play_init()
Definition: cvodestb.cpp:76
double t
Definition: cvodestb.cpp:21
void init_net_events()
Definition: cvodestb.cpp:64
void deliver_net_events(NrnThread *)
Definition: cvodestb.cpp:36
void fixed_play_continuous(NrnThread *nt)
Definition: cvodestb.cpp:82
void nrncvode_set_t(double)
Definition: cvodestb.cpp:137
int nrn_use_daspk_
Definition: treeset.cpp:59
void nrn_solver_prepare()
Definition: cvodestb.cpp:94
void fixed_record_continuous(neuron::model_sorted_token const &cache_token, NrnThread &nt)
Definition: cvodestb.cpp:88
NetCvode * net_cvode_instance
Definition: cvodestb.cpp:26
void nrn_deliver_events(NrnThread *)
Definition: cvodestb.cpp:44
#define nt_t
Definition: cvodestb.cpp:22
void clear_event_queue()
Definition: cvodestb.cpp:52
void cvode_finitialize(double t0)
Definition: cvodestb.cpp:119
size_t p
size_t j
Represent main neuron object computed by single thread.
Definition: multicore.h:58
double _dt
Definition: multicore.h:60
void * _vcv
Definition: multicore.h:97
double _t
Definition: multicore.h:59