HNBody  Version 1.0.10
kernel.h
Go to the documentation of this file.
1 #ifndef HNBODY_KERNEL_H
2 #define HNBODY_KERNEL_H
3 
13 #include <mutils/util.h>
14 
15 #ifdef __cplusplus
16 extern "C" {
17 namespace HNBODY {
18 #endif
19 
20 
22 typedef enum hnb_integcoord_enum {
23  Origin=1+2,
26  Jacobi=2,
39  Splitting=8+16,
44  Order=32+64,
45  Order2=0,
46  Order4=32,
47  ModKick=64,
53  Corrected=128+256+512,
55  Reverse=1024,
57  Corrected2=128,
58  Corrected4=256,
59  Corrected6=512,
63  Gravity=2048,
68  Kernel=4096,
72  SplitI=8192
74 
76 typedef enum hnb_integ_enum {
80 } hnb_integ_t;
81 
83 typedef enum LWP_enum {
86 } hnb_LWP_t;
87 
89 typedef double (*hnb_vector_t)[3];
90 
91 /* Forward reference. */
92 struct hnb_data_struct;
93 
94 typedef
96  void (*hnb_extra_t)(hnb_vector_t, double t, hnb_vector_t, const double m[],
97  int nHL, int n, double dt, const struct hnb_data_struct *sys);
98 typedef
100  void (*hnb_drift_t)(hnb_vector_t dx, hnb_vector_t dv, double t,
101  hnb_vector_t x, hnb_vector_t v, const double m[],
102  int nHL, int n, double dt, const struct hnb_data_struct *sys);
103 typedef
105  double (*hnb_energy_t)(double t, hnb_vector_t x, hnb_vector_t v,
106  const double m[], int nHL, const struct hnb_data_struct *sys);
107 typedef
110  double t, hnb_vector_t x, hnb_vector_t v,
111  const double m[], int nHL, int n, const struct hnb_data_struct *sys);
112 
113 
115 typedef struct hnb_data_struct {
116  /* "Public" data. */
117  double G, c, Msun, dm, J2, J4, J6, obRad, dzH, dzZ, eps, tinit,
118  tH[2], dtH[2], tZ[2], dtZ[2];
119  int nH, nHL, n, fixedH, enc, prune;
120  hnb_vector_t x0, dx0, v0, dv0, x1, dx1, v1, dv1;
121  double *m, *rcapt, *renc;
122  hnb_integ_t integ;
123  hnb_integcoord_t itH, itZ;
124  hnb_LWP_t Ltype;
125  int *id, *imap, *jindex, *prune_ctrl;
126  FILE *log;
127 
128  hnb_extra_t extra_kick, extra_shift;
129  hnb_drift_t extra_drift;
130  hnb_derivs_t extra_derivs;
131  hnb_energy_t extra_energy;
132 
133  /* "Private" data from here onward... */
134  hnb_vector_t x00;
135  int pindex;
136 
137  /* Volatile, driver-related data. */
138  volatile int halt;
139  const char *recover;
140 
141  /* Temporary system vector cache. */
142  hnb_vector_t *tmpvec;
143  int ntmp, tmpmax;
144 
145  /* Output file pointer cache. */
146  FILE *body[512];
147  int bopen;
148 
149  /* Data used only with certain integrations. */
150  double dzODE, *tmpODE;
151  double *deta, *ieta, *dsZ, *E0, *E1, *t, *tt;
152  hnb_vector_t xH, vH, xt, vt, xHtab, vHtab;
153  int iZ0, ntab, maxtab, itmax;
154  unsigned char *ace;
155  double dtdz, ttab0;
156 
157  hnb_vector_t xh0, xh1, xha, xhb, vh0, vh1, vha, vhb, xa, xb, va, vb;
158 } hnb_data_t;
159 
160 
161 /* User-callable functions. */
162 DLLSPEC extern void
163  hnb_angmom(double L[], hnb_vector_t x, hnb_vector_t v, hnb_data_t *sys),
164  hnb_calcCoord(hnb_vector_t xNew, hnb_vector_t vNew,
165  hnb_integcoord_t newFrame, const hnb_data_t *sys),
166  hnb_checkpoint(hnb_data_t *sys, const char *file, int halt),
167  hnb_free_data(hnb_data_t *sys),
168  hnb_write(hnb_data_t *sys, const char *file),
169  hnb_util_version(FILE *f, const char *name, const char *revision,
170  const char *prefix),
171  hnb_print_info(FILE *f, void (*custom)(FILE *f, const char *prefix),
172  const char *prefix),
173  hnb_step(hnb_data_t *sys);
174 
175 DLLSPEC extern const char
176  *hnb_contact(void), *hnb_version(void), *hnb_website(void);
177 
178 DLLSPEC extern const int
179  *hnb_idtags(const hnb_data_t *sys),
180  *hnb_jacmap(const hnb_data_t *sys);
181 
182 DLLSPEC extern int
183  hnb_N(const hnb_data_t *sys),
184  hnb_hwp_N(const hnb_data_t *sys),
185  hnb_lwp_N(const hnb_data_t *sys),
186  hnb_zwp_N(const hnb_data_t *sys),
187  hnb_save(const char *save, double key, hnb_data_t *sys),
188  hnb_restore(double *key, const char *save, hnb_data_t *sys),
189  hnb_argv_driver(int argc, char *argv[], hnb_extra_t kick,
190  hnb_extra_t shift, hnb_drift_t drift, hnb_derivs_t derivs,
191  hnb_energy_t energy, void (*custom)(FILE *f, const char *prefix));
192 
193 DLLSPEC extern hnb_integcoord_t
194  hnb_integcoord(const hnb_data_t *sys),
195  hnb_zwp_integcoord(const hnb_data_t *sys);
196 
197 DLLSPEC extern const double
198  *hnb_masses(const hnb_data_t *sys),
199  *hnb_enc_radii(const hnb_data_t *sys),
200  *hnb_capt_radii(const hnb_data_t *sys);
201 
202 DLLSPEC extern double
203  hnb_G(const hnb_data_t *sys), hnb_c(const hnb_data_t *sys),
204  hnb_Msun(const hnb_data_t *sys), hnb_M(const hnb_data_t *sys),
205  hnb_tinit(const hnb_data_t *sys),
206  hnb_stepsize(const hnb_data_t *sys),
207  hnb_zwp_stepsize(const hnb_data_t *sys),
208  hnb_eff_stepsize(const hnb_data_t *sys),
209  hnb_output(double *t, double (**x)[3], double (**v)[3], hnb_data_t *sys);
210 
211 
212 DLLSPEC extern hnb_data_t
213  *hnb_read(const char *file),
214  *hnb_init_file(const char *hnbfile, FILE *logfile),
215  *hnb_init_extra(const char *hnbfile, FILE *logfile, hnb_extra_t extra_kick,
216  hnb_extra_t extra_shift, hnb_drift_t extra_drift,
217  hnb_derivs_t extra_derivs, hnb_energy_t extra_energy),
218 
219  *hnb_ode_init(double tinit, const double xinit[][3], const double vinit[][3],
220  const double m[], const int id[],
221  int nH, int nL, int nZ, hnb_LWP_t ltype, int fixedH,
222  int enc, const double rcapt[], double G, double c, double Msun,
223  double J2, double J4, double J6, double obRadius,
224  double dt, double eps,
225  hnb_integ_t integ, hnb_integcoord_t icoord,
226  hnb_derivs_t extra_derivs, hnb_energy_t extra_energy, int nthreads),
227 
228  *hnb_init(double tinit, const double xinit[][3], const double vinit[][3],
229  const double m[], const int id[], const int jindex[],
230  int nH, int nL, int nZ, hnb_LWP_t ltype, int fixedH,
231  int enc, int prune,
232  const double renc[], const double rcapt[], double G, double c, double Msun,
233  double J2, double J4, double J6, double obRadius,
234  double dm, double dzH, double dzZ,
236  hnb_extra_t extra_kick, hnb_extra_t extra_shift, hnb_drift_t extra_drift,
237  hnb_energy_t extra_energy, int nthreads);
238 
239 
240 #ifdef __cplusplus
241 } // namespace HNBODY
242 } // extern "C"
243 #endif
244 
245 #endif /* HNBODY_KERNEL_H */
Definition: kernel.h:30
Definition: kernel.h:70
Definition: kernel.h:84
hnb_integcoord_enum
Symplectic integration scheme variations (bit-mask layout).
Definition: kernel.h:22
void(* hnb_drift_t)(hnb_vector_t dx, hnb_vector_t dv, double t, hnb_vector_t x, hnb_vector_t v, const double m[], int nHL, int n, double dt, const struct hnb_data_struct *sys)
Prototype for extra_drift() functions.
Definition: kernel.h:100
Definition: kernel.h:39
Definition: kernel.h:40
Definition: kernel.h:34
Definition: kernel.h:58
Definition: kernel.h:69
double(* hnb_energy_t)(double t, hnb_vector_t x, hnb_vector_t v, const double m[], int nHL, const struct hnb_data_struct *sys)
Prototype for extra_energy() functions.
Definition: kernel.h:105
Definition: kernel.h:65
Definition: kernel.h:42
Definition: kernel.h:59
Definition: kernel.h:63
Definition: kernel.h:85
Definition: kernel.h:48
Definition: kernel.h:57
Definition: kernel.h:64
Definition: kernel.h:55
Definition: kernel.h:23
enum LWP_enum hnb_LWP_t
Choices for LWP perturbations type.
enum hnb_integcoord_enum hnb_integcoord_t
Symplectic integration scheme variations (bit-mask layout).
Definition: kernel.h:44
void hnb_checkpoint(hnb_data_t *sys, const char *file, int halt)
Sets on-demand checkpointing of an integration.
Definition: driver.c:55
struct hnb_data_struct hnb_data_t
Main HNBody system data structure.
Definition: kernel.h:26
Definition: kernel.h:25
Definition: kernel.h:72
DLLSPEC const char * hnb_website(void)
Definition: version.c:41
Header file for library management and other miscellaneous utilities.
Definition: kernel.h:28
Definition: kernel.h:78
Definition: kernel.h:24
Definition: kernel.h:79
int(* hnb_derivs_t)(hnb_vector_t dxdt, hnb_vector_t dvdt, double t, hnb_vector_t x, hnb_vector_t v, const double m[], int nHL, int n, const struct hnb_data_struct *sys)
Prototype for extra_derivs() functions.
Definition: kernel.h:109
Definition: kernel.h:47
LWP_enum
Choices for LWP perturbations type.
Definition: kernel.h:83
Definition: kernel.h:50
void(* hnb_extra_t)(hnb_vector_t, double t, hnb_vector_t, const double m[], int nHL, int n, double dt, const struct hnb_data_struct *sys)
Prototype for extra_kick() and extra_shift() functions.
Definition: kernel.h:96
hnb_integ_enum
Integration scheme choices.
Definition: kernel.h:76
Main HNBody system data structure.
Definition: kernel.h:115
Definition: kernel.h:45
Definition: kernel.h:36
Definition: kernel.h:32
Definition: kernel.h:41
Definition: kernel.h:68
Definition: kernel.h:77
double(* hnb_vector_t)[3]
System particle 3-vector type.
Definition: kernel.h:89
Definition: kernel.h:46
DLLSPEC int hnb_argv_driver(int argc, char *argv[], hnb_extra_t kick, hnb_extra_t shift, hnb_drift_t drift, hnb_derivs_t derivs, hnb_energy_t energy, void(*custom)(FILE *f, const char *prefix))
Performs an integration given a set of command line arguments.
Definition: driver.c:337
Definition: kernel.h:60
enum hnb_integ_enum hnb_integ_t
Integration scheme choices.
Definition: kernel.h:53
Definition: kernel.h:56
Definition: kernel.h:29