HNBody Version 1.2.1

- Main Page
- Related Pages
- Data Structures
- Files

- File List
- Globals

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