HNBody Version 1.0.10

- 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 ModKick=64,
48 Order4mk=Order4+ModKick,
50 Integrator=Coordinates+Splitting+Order,
53 Corrected=128+256+512,
55 Reverse=1024,
56 Uncorrected=0,
57 Corrected2=128,
58 Corrected4=256,
59 Corrected6=512,
60 Corrector=Reverse+Corrected,
63 Gravity=2048,
64 Newtonian=0,
65 PostNewtonian=Gravity,
68 Kernel=4096,
69 PolyKernel=0,
70 TanhKernel=Kernel,
72 SplitI=8192
73 } hnb_integcoord_t;
74
76 typedef enum hnb_integ_enum {
77 Symplectic,
78 BulirschStoer,
79 RungeKutta
80 } hnb_integ_t;
81
83 typedef enum LWP_enum {
84 LWP_NONE,
85 LWP_ZWP
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
109 int (*hnb_derivs_t)(hnb_vector_t dxdt, hnb_vector_t dvdt,
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,
235 hnb_integcoord_t itH, hnb_integcoord_t itZ,
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 */
RegBarycentric
Definition: kernel.h:30
TanhKernel
Definition: kernel.h:70
LWP_NONE
Definition: kernel.h:84
hnb_integcoord_enum
hnb_integcoord_enum
Symplectic integration scheme variations (bit-mask layout).
Definition: kernel.h:22
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:100
Splitting
Definition: kernel.h:39
Kick_Drift
Definition: kernel.h:40
ModBodycentric
Definition: kernel.h:34
Corrected4
Definition: kernel.h:58
PolyKernel
Definition: kernel.h:69
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:105
PostNewtonian
Definition: kernel.h:65
Shift_Drift
Definition: kernel.h:42
Corrected6
Definition: kernel.h:59
Gravity
Definition: kernel.h:63
LWP_ZWP
Definition: kernel.h:85
Order4mk
Definition: kernel.h:48
Corrected2
Definition: kernel.h:57
Newtonian
Definition: kernel.h:64
Reverse
Definition: kernel.h:55
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_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:72
hnb_website
DLLSPEC const char * hnb_website(void)
Definition: version.c:41
util.h
Header file for library management and other miscellaneous utilities.
Regularized
Definition: kernel.h:28
BulirschStoer
Definition: kernel.h:78
Barycentric
Definition: kernel.h:24
RungeKutta
Definition: kernel.h:79
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:109
ModKick
Definition: kernel.h:47
LWP_enum
LWP_enum
Choices for LWP perturbations type.
Definition: kernel.h:83
Integrator
Definition: kernel.h:50
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:96
hnb_integ_enum
hnb_integ_enum
Integration scheme choices.
Definition: kernel.h:76
hnb_data_struct
Main HNBody system data structure.
Definition: kernel.h:115
Order2
Definition: kernel.h:45
Coordinates
Definition: kernel.h:36
RegJacobi
Definition: kernel.h:32
Drift_Kick
Definition: kernel.h:41
Kernel
Definition: kernel.h:68
Symplectic
Definition: kernel.h:77
hnb_vector_t
double(* hnb_vector_t)[3]
System particle 3-vector type.
Definition: kernel.h:89
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:60
hnb_integ_t
enum hnb_integ_enum hnb_integ_t
Integration scheme choices.
Corrected
Definition: kernel.h:53
Uncorrected
Definition: kernel.h:56
TWform
Definition: kernel.h:29