NEURON
cvodeobj.h
Go to the documentation of this file.
1 #ifndef cvodeobj_h
2 #define cvodeobj_h
3 
4 #include "nrnmpi.h"
5 #include "nrnneosm.h"
6 //#include "shared/nvector_serial.h"
7 #include "shared/nvector.h"
8 #include "membfunc.h"
9 
10 class NetCvode;
11 class Daspk;
12 class TQItem;
13 class TQueue;
14 class PreSynList;
15 struct BAMech;
16 struct NrnThread;
17 class PlayRecList;
18 class PlayRecord;
19 class STEList;
20 class HTList;
21 
22 class CvMembList {
23 public:
24  CvMembList();
25  virtual ~CvMembList();
28  int index;
29 };
30 
31 class BAMechList {
32 public:
37  static void destruct(BAMechList** first);
38 };
39 
40 #define CTD(i) ctd_[((nctd_ > 1) ? (i) : 0)]
42 public:
44  virtual ~CvodeThreadData();
45  void delete_memb_list(CvMembList*);
46 
47  int no_cap_count_; // number of nodes with no capacitance
50  Node** no_cap_child_; // connected to nodes that have no capacitance
53  CvMembList* cmlext_; // used only by daspk
54  CvMembList* no_cap_memb_; // used only by cvode, point processes in the no cap nodes
62  PreSynList* psl_th_; // with a threshold
64  double** pv_;
65  double** pvdot_;
66  int nvoffset_; // beginning of this threads states
67  int nvsize_; // total number of states for this thread
68  int neq_v_; //for daspk, number of voltage states for this thread
69  int nonvint_offset_; // synonym for neq_v_. Beginning of this threads nonvint variables.
70  int nonvint_extra_offset_; // extra states (probably Python). Not scattered or gathered.
71  PlayRecList* record_;
72  PlayRecList* play_;
73 };
74 
75 class Cvode {
76 public:
77  Cvode(NetCvode*);
78  Cvode();
79  virtual ~Cvode();
80 
81  virtual int handle_step(NetCvode*, double);
82  virtual int init(double t);
83  virtual int advance_tn();
84  virtual int interpolate(double t);
85  virtual double tn() { return tn_;} // furthest time of advance
86  virtual double t0() { return t0_;} // beginning of last real step
87  void init_prepare();
88 
89  int solve(); // checks event_flag and init or advance_tn
90  void statistics();
91  double gam();
92  double time() const { return t_; }
93  void free_cvodemem();
94  int order();
95  void maxorder(int), minstep(double), maxstep(double);
96 public:
97  double tn_, t0_, t_;
99  bool can_retreat_; // only true after an integration step
100  // statistics
101  void stat_init();
102  int advance_calls_, interpolate_calls_, init_calls_;
103  int f_calls_, mxb_calls_, jac_calls_, ts_inits_;
104 private:
105  void alloc_cvode();
106  void alloc_daspk();
107  int cvode_init(double);
108  int cvode_advance_tn();
109  int cvode_interpolate(double);
110  int daspk_init(double);
111  int daspk_advance_tn();
112  int daspk_interpolate(double);
113 public:
114  N_Vector nvnew(long);
115  int setup(N_Vector ypred, N_Vector fpred);
116  int solvex_thread(double* b, double* y, NrnThread* nt);
117  int solvex_thread_part1(double* b, NrnThread* nt);
118  int solvex_thread_part2(NrnThread* nt);
119  int solvex_thread_part3(double* b, NrnThread* nt);
120  void fun_thread(double t, double* y, double* ydot, NrnThread* nt);
121  void fun_thread_transfer_part1(double t, double* y, NrnThread* nt);
122  void fun_thread_transfer_part2(double* ydot, NrnThread* nt);
123  void fun_thread_ms_part1(double t, double* y, NrnThread* nt);
124  void fun_thread_ms_part2(NrnThread* nt);
125  void fun_thread_ms_part3(NrnThread* nt);
126  void fun_thread_ms_part4(double* ydot, NrnThread* nt);
127  void fun_thread_ms_part34(double* ydot, NrnThread* nt);
128  bool at_time(double, NrnThread*);
129  void set_init_flag();
130  void check_deliver(NrnThread* nt = 0);
131  void evaluate_conditions(NrnThread* nt = 0);
132  void ste_check();
133  void states(double*);
134  void dstates(double*);
135  void error_weights(double*);
136  void acor(double*);
137  void fill(Cvode* standard);
138  // following 7 crucial for local time step recording, also used by global
139  void delete_prl();
140  void record_add(PlayRecord*);
141  void record_continuous();
142  void record_continuous_thread(NrnThread*);
143  void play_add(PlayRecord*);
144  void play_continuous(double t);
145  void play_continuous_thread(double t, NrnThread*);
146  void do_ode(NrnThread*);
147  void do_nonode(NrnThread* nt = 0);
148  double* n_vector_data(N_Vector, int);
149 private:
150  void cvode_constructor();
151  bool init_global();
152  void init_eqn();
153  void daspk_init_eqn();
154  void matmeth();
155  void nocap_v(NrnThread*);
156  void nocap_v_part1(NrnThread*);
157  void nocap_v_part2(NrnThread*);
158  void nocap_v_part3(NrnThread*);
159  void solvemem(NrnThread*);
160  void atolvec_alloc(int);
161  double h();
162  N_Vector ewtvec();
163  N_Vector acorvec();
164  void new_no_cap_memb(CvodeThreadData&, NrnThread*);
165  void before_after(BAMechList*, NrnThread*);
166 public:
167  // daspk
170  int res(double, double*, double*, double*, NrnThread*);
171  int psol(double, double*, double*, double, NrnThread*);
172  void daspk_scatter_y(N_Vector); // daspk solves vi,vx instead of vm,vx
173  void daspk_gather_y(N_Vector);
174  void daspk_scatter_y(double*, int);
175  void daspk_gather_y(double*, int);
176  void scatter_y(double*, int);
177  void gather_y(N_Vector);
178  void gather_y(double*, int);
179  void scatter_ydot(double*, int);
180  void gather_ydot(N_Vector);
181  void gather_ydot(double*, int);
182 public:
183  void activate_maxstate(bool);
184  void maxstate(double*);
185  void maxstate(bool, NrnThread* nt = 0);
186  void maxacor(double*);
187 public:
188  void* mem_;
189  N_Vector y_;
190  N_Vector atolnvec_;
191  N_Vector maxstate_;
192  N_Vector maxacor_;
193 public:
195 #if USENEOSIM
196  TQueue* neosim_self_events_;
197 #endif
198 public:
200  NrnThread* nth_; // for lvardt
201  int nctd_;
202  long int* nthsizes_; // N_Vector_NrnThread uses this copy of ctd_[i].nvsize_
204  int neq_;
207  double tstop_;
208  double tstop_begin_, tstop_end_;
209 
210 private:
211  void rhs(NrnThread*);
212  void rhs_memb(CvMembList*, NrnThread*);
213  void lhs(NrnThread*);
214  void lhs_memb(CvMembList*, NrnThread*);
215  void triang(NrnThread*);
216  void bksub(NrnThread*);
217 private:
218  // segregation of old vectorized information to per cell info
219  friend class NetCvode;
220  bool is_owner(double*); // for play and record in local step context.
221  bool local_;
222  void daspk_setup1_tree_matrix(); //unused
223  void daspk_setup2_tree_matrix(); //unused
225 private:
227 #if PARANEURON
228 public:
229  bool use_partrans_;
230  int global_neq_;
231  int opmode_; // 1 advance, 2 interpolate, 3 init; for testing
232 #endif // PARANEURON
233 };
234 
235 #endif
int nonvint_extra_offset_
Definition: cvodeobj.h:70
bool initialize_
Definition: cvodeobj.h:98
int prior2init_
Definition: cvodeobj.h:226
virtual ~CvMembList()
Definition: netcvode.cpp:1463
bool local_
Definition: cvodeobj.h:221
order
Definition: multicore.cpp:886
Node ** no_cap_child_
Definition: cvodeobj.h:50
CvodeThreadData * ctd_
Definition: cvodeobj.h:199
int index
Definition: cvodeobj.h:28
TQItem * tqitem_
Definition: cvodeobj.h:224
Represent main neuron object computed by single thread.
Definition: multicore.h:58
int nctd_
Definition: cvodeobj.h:201
static int first
Definition: fmenu.cpp:186
static double minstep(void *v)
Definition: cvodeobj.cpp:249
virtual double t0()
Definition: cvodeobj.h:86
int rootnodecount_
Definition: cvodeobj.h:58
int neq_
Definition: cvodeobj.h:204
static double dstates(void *v)
Definition: cvodeobj.cpp:280
CvMembList * cmlext_
Definition: cvodeobj.h:53
NetCvode * ncv_
Definition: cvodeobj.h:203
CvMembList * no_cap_memb_
Definition: cvodeobj.h:54
static void triang(NrnThread *)
Definition: solve.cpp:391
BAMechList * after_solve_
Definition: cvodeobj.h:56
Definition: bbtqueue.h:6
static void destruct(void *v)
Definition: grglyph.cpp:215
#define bksub
Definition: lineq.h:9
static double statistics(void *v)
Definition: cvodeobj.cpp:115
void init()
Definition: init.cpp:169
Node ** v_node_
Definition: cvodeobj.h:60
void solve(void)
Definition: nonlin.cpp:287
CvMembList * cmlcap_
Definition: cvodeobj.h:52
double ** pv_
Definition: cvodeobj.h:64
bool use_daspk_
Definition: cvodeobj.h:168
double time() const
Definition: cvodeobj.h:92
N_Vector maxstate_
Definition: cvodeobj.h:191
BAMechList * next
Definition: cvodeobj.h:34
Definition: nrndaspk.h:11
Node ** v_parent_
Definition: cvodeobj.h:61
HTList * watch_list_
Definition: cvodeobj.h:63
double next_at_time_
Definition: cvodeobj.h:206
PlayRecList * play_
Definition: cvodeobj.h:72
Node ** no_cap_node_
Definition: cvodeobj.h:49
static double interpolate(double x0, double x1, double y0, double y1, double xnew)
Definition: nrnpy_nrn.cpp:1406
static double acor(void *v)
Definition: cvodeobj.cpp:297
N_Vector atolnvec_
Definition: cvodeobj.h:190
PlayRecList * record_
Definition: cvodeobj.h:71
at_time
Definition: extargs.h:1
static double error_weights(void *v)
Definition: cvodeobj.cpp:291
bool can_retreat_
Definition: cvodeobj.h:99
PreSynList * psl_th_
Definition: cvodeobj.h:62
virtual double tn()
Definition: cvodeobj.h:85
BAMechList * before_breakpoint_
Definition: cvodeobj.h:55
int no_cap_child_count_
Definition: cvodeobj.h:48
Memb_list * ml
Definition: cvodeobj.h:36
CvMembList * next
Definition: cvodeobj.h:26
int no_cap_count_
Definition: cvodeobj.h:47
int interpolate_calls_
Definition: cvodeobj.h:102
#define rhs
Definition: lineq.h:6
double ** pvdot_
Definition: cvodeobj.h:65
Definition: htlist.h:35
Daspk * daspk_
Definition: cvodeobj.h:169
void * mem_
Definition: cvodeobj.h:188
N_Vector maxacor_
Definition: cvodeobj.h:192
Definition: cvodeobj.h:75
NrnThread * nth_
Definition: cvodeobj.h:200
N_Vector y_
Definition: cvodeobj.h:189
int nonvint_offset_
Definition: cvodeobj.h:69
double tn_
Definition: cvodeobj.h:97
long int * nthsizes_
Definition: cvodeobj.h:202
static double maxorder(void *v)
Definition: cvodeobj.cpp:230
int event_flag_
Definition: cvodeobj.h:205
BAMech * bam
Definition: cvodeobj.h:35
double t
Definition: init.cpp:123
Definition: section.h:132
int ts_inits_
Definition: cvodeobj.h:103
CvMembList * cv_memb_list_
Definition: cvodeobj.h:51
bool structure_change_
Definition: cvodeobj.h:194
Memb_list * ml
Definition: cvodeobj.h:27
double tstop_end_
Definition: cvodeobj.h:208
double tstop_
Definition: cvodeobj.h:207
double * states
Definition: rxd.cpp:62
BAMechList * before_step_
Definition: cvodeobj.h:57
static double maxstep(void *v)
Definition: cvodeobj.cpp:257
int v_node_count_
Definition: cvodeobj.h:59