HNBody Version 1.2.1

- Main Page
- Related Pages
- Data Structures
- Files

- File List
- Globals

expert.h
Go to the documentation of this file.
1 #ifndef HNBODY_EXPERT_H
2 #define HNBODY_EXPERT_H
3
14 #include <mutils/platform.h>
15
16 #include "hnbody/kernel.h"
17
18 #ifdef __cplusplus
19 extern "C" {
20 namespace HNBODY {
21 #endif
22
23
24 #define vecsize (3*sizeof(double))
25 #define ACE_MAX 32
26
27 /* Constants to implement 4th order composition step. */
28 #define CS_A 1.3512071919596576
29 #define CS_B -1.7024143839193153
30 #define CS_BA -1.2599210498948732
31
32 /* Constants to implement 6th order composition step. */
33 #define CS_W0 1.3151863206839112188842497282388625143519535061590
34 #define CS_W1 -1.1776799841788710069464156809643157346392692526343
35 #define CS_W2 0.2355732133593581336847931829785346016864680821033
36 #define CS_W3 0.7845136104775572638194976338663498757768244174514
37
38 /* Number of ZWP-perturbing H&Ls. */
39 #define NZP(sys) (sys->Ltype==LWP_ZWP ? sys->nHL : sys->nH)
40
41 /* Number of planets contributing to the "effective" center of mass. */
42 #define NCM(sys) (sys->fixedH>0 ? sys->nH : sys->nHL)
43
44 /* Are all (Z-perturbing) H&Ls fixed? */
45 #define FIXEDH(sys) (sys->fixedH && sys->nH==sys->nHL)
46 #define FIXEDZP(sys) ( sys->fixedH && \
47 (sys->nH==sys->nHL || sys->Ltype==LWP_NONE))
48
49 /* Tests whether coordinates are heliocentric, regularized, etc. */
50 #define IS_BARY(it) (((it)&Origin)==Barycentric)
51 #define IS_BODY(it) (((it)&Origin)==Bodycentric)
52 #define IS_JACOBI(it) (((it)&Origin)==Jacobi)
53 #define IS_REG(it) (((it)&Regularized)!=0)
54 #define IS_MOD(it) (((it)&TWform)!=0)
55 #define IS_4TH(it) (((it)&Order)==Order4)
56 #define IS_PN(it) (((it)&Gravity)==PostNewtonian)
57 #define IS_CS(it) (((it)&Order)!=0)
58 #define IS_KD(it) (((it)&Splitting)==Kick_Drift)
59 #define IS_DK(it) (((it)&Splitting)==Drift_Kick)
60 #define IS_SD(it) (((it)&Splitting)==Shift_Drift)
61
62 /* Array index i corresponding to Jacobi index j. */
63 #define IMAP(j, nL, nHL) ((j)<=(nL) ? ((j) ? (nHL)-(j) : 0) : (j)-(nL))
64
65 /* Magnitude inequality operators. */
66 #define ABSLT(x, y) (fabs(x)<fabs(y))
67 #define ABSLE(x, y) (fabs(x)<=fabs(y))
68 #define ABSGT(x, y) (fabs(x)>fabs(y))
69 #define ABSGE(x, y) (fabs(x)>=fabs(y))
70
71 /* Procedure to zero double array of length n---assumes 0 bits --> float=0. */
72 #define memzero(x, n) memset(x, 0, (n)*sizeof(double))
73
74 /* Kahan summation formula---all arguments should be *variables*. */
75 #define hnb_ksum(S, C, Xj) do {double Y=Xj-C, T=S+Y; C=(T-S)-Y; S=T;} while (0)
76
77
95 typedef struct hnb_ctrl_struct {
96 int *prune;
97 } hnb_ctrl_t;
98
99 DLLSPEC extern hnb_ctrl_t hnb_user_ctrl_data;
100
101 /*
102 Extra user-defined initialization; init_step overrides built-in action and
103 half_step replaces default action in hnb_halfstep(). If defined,
104 save_func and rest_func are called each time hnb_save() and hnb_restore()
105 are called, respectively.
106 */
107 DLLSPEC extern void
108 (*hnb_user_exam_func)(hnb_ctrl_t *ctrl, double t,
109 const double x[][3], const double v[][3],
110 const double m[], int n, const hnb_data_t *sys),
111 (*hnb_user_prune_func)(hnb_data_t *sys, int index),
112 (*hnb_user_init_func)(hnb_data_t *sys, const char *file),
113 (*hnb_user_exit_func)(hnb_data_t *sys, const char *file),
114 (*hnb_user_save_func)(hnb_data_t *sys, double key),
115 (*hnb_user_rest_func)(hnb_data_t *sys, double key),
116 (*hnb_user_init_step)(hnb_data_t *sys),
117 (*hnb_user_half_step)(hnb_data_t *sys);
118
119 DLLSPEC extern const char *hnb_user_init_file;
120
121 hnb_vector_t
122 hnb_newvec(hnb_data_t *sys),
123 hnb_newvec_unlocked(hnb_data_t *sys);
124
125 DLLSPEC extern hnb_data_t
126 *hnb_raw_init(double tinit, const double xinit[][3], const double vinit[][3],
127 const double m[], const int id[], const int jindex[], const int smult[],
128 int nH, int nL, int nZ, hnb_LWP_t ltype, int fixedH,
129 int enc, int prune,
130 const double renc[], const double rcapt[], double G, double c, double Msun,
131 double J2, double J4, double J6, double obRadius,
132 double dm, double dzH, double dzZ, double eps,
133 hnb_integ_t integ, hnb_integcoord_t itH, hnb_integcoord_t itZ,
134 hnb_extra_t extra_kick, hnb_extra_t extra_shift, hnb_drift_t extra_drift,
135 hnb_derivs_t extra_derivs, hnb_energy_t extra_energy, int nthreads);
136
137 DLLSPEC extern void
138 hnb_setup_output(hnb_data_t *sys),
139 hnb_drift(hnb_data_t *sys, double dz, int output),
140 hnb_kick( hnb_data_t *sys, double dz, int output),
141 hnb_shift(hnb_data_t *sys, double dz, int output),
142
143 *hnb_mtsort(void *vsys),
144 hnb_init_threads(hnb_data_t *sys, int npart),
145 hnb_delvec(hnb_vector_t vec, hnb_data_t *sys),
146 hnb_delvec_unlocked(hnb_vector_t vec, hnb_data_t *sys),
147
148 hnb_halfstep(hnb_data_t *sys),
149
150 ode_step(hnb_data_t *sys),
151
152 zwp_iostep(hnb_data_t *, int), zwp_step(hnb_data_t *),
153 zwp_regdata(double *, double *, double *,
154 const double *, const double *, hnb_data_t *),
155
156 hcoord_to_zcoord(double (*)[3], double (*)[3], hnb_data_t *),
157 hl_dkick(double dv[][3], double x[][3], double dt, hnb_data_t *sys),
158 hl_drift(hnb_data_t *sys, double dz),
159 hl_kick0(hnb_data_t *sys, double dz),
160 hl_shift(hnb_data_t *sys, double dz),
161 hl_sync(hnb_data_t *, double), hl_reinit(hnb_data_t *, int),
162 hl_etas(double *, double *, const double *, const int *, int),
163 hl_iostep(hnb_data_t *, int), hl_step0(hnb_data_t *, double, int),
164 hl_inter(double [], double [], double, int, hnb_data_t *),
165
166 hnb_normalize(double x[][3], double dx[][3], int n),
167 hnb_partition(int *imin, int *imax, int ipart, int npart),
168
169 oblate_kick(double (*dv)[3], double (*x)[3], const double m[],
170 int n, double dt, hnb_data_t *sys),
171
172 postn_bary2pseudo(double (*vpseudo)[3], double (*xbody)[3],
173 double (*vbary)[3], const double m[], int n, double G, double c2),
174 postn_pseudo2bary(double (*vbary)[3], double (*xbody)[3],
175 double (*vpseudo)[3], const double m[], int n, double G, double c2),
176 postn_jacobi2pseudo(double (*dv)[3], double (*x)[3], double (*v)[3],
177 const double ieta[], const int imap[], int n, double GM, double c2),
178 postn_pseudo2jacobi(double (*dv)[3], double (*x)[3], double (*v)[3],
179 const double ieta[], const int imap[], int n, double GM, double c2),
180 postn_shift(double (*dx)[3], double (*v)[3], const double m[],
181 int n, double dt, double G, double c2, hnb_integcoord_t it),
182 postn_kick(double (*dv)[3], double (*x)[3],
183 const double m[], const double ieta[], const int imap[],
184 int n, double dt, double G, double c2, hnb_integcoord_t it);
185
186 DLLSPEC extern double
187 oblate_energy(double (*x)[3], const double m[], int n, hnb_data_t *sys),
188 postn_energy(double (*x)[3], double (*v)[3], hnb_data_t *sys);
189
190 DLLSPEC extern int
191 hnb_extra_index(const hnb_data_t *),
192
193 create_imap(int imap[], const int jindex[], int nhl),
194
195 hl_filltab(hnb_data_t *, double),
196 close_enc(const double xc0[], const double vc0[], const double xc1[],
197 const double vc1[], const double xp0[], const double vp0[],
198 const double xp1[], const double vp1[], double renc, double GM, double dt);
199
200 DLLSPEC extern double encke_g(double);
201
202
203 #ifdef __cplusplus
204 } // namespace HNBODY
205 } // extern "C"
206 #endif
207
208 #endif /* HNBODY_EXPERT_H */
encke_g
DLLSPEC double encke_g(double)
Computes 1-(1+2*q)^-3/2, maintaining relative precision for |q|<<1.
Definition: zwp.c:27
hnb_ctrl_t
struct hnb_ctrl_struct hnb_ctrl_t
User control callback information.
kernel.h
Core user-visible package declarations for the HNBody library.
hnb_raw_init
DLLSPEC hnb_data_t * hnb_raw_init(double tinit, const double xinit[][3], const double vinit[][3], const double m[], const int id[], const int jindex[], const int smult[], int nH, int nL, int nZ, hnb_LWP_t ltype, int fixedH, int enc, int prune, const double renc[], const double rcapt[], double G, double c, double Msun, double J2, double J4, double J6, double obRadius, double dm, double dzH, double dzZ, double eps, hnb_integ_t integ, hnb_integcoord_t itH, hnb_integcoord_t itZ, hnb_extra_t extra_kick, hnb_extra_t extra_shift, hnb_drift_t extra_drift, hnb_derivs_t extra_derivs, hnb_energy_t extra_energy, int nthreads)
Allocates and initializes a system data structure.
Definition: init.c:330
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
platform.h
MathUtils platform identification macros.
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).
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_user_ctrl_data
DLLSPEC hnb_ctrl_t hnb_user_ctrl_data
Passed to hnb_user_exam_func to allow increased user integration control.
Definition: init.c:28
hnb_ctrl_struct
User control callback information.
Definition: expert.h:95
hnb_user_exam_func
DLLSPEC void(* hnb_user_exam_func)(hnb_ctrl_t *ctrl, double t, const double x[][3], const double v[][3], const double m[], int n, const hnb_data_t *sys)
Definition: init.c:36
hnb_ctrl_struct::prune
int * prune
Definition: expert.h:96
hnb_data_struct
Main HNBody system data structure.
Definition: kernel.h:118
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
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
hnb_vector_t
double(* hnb_vector_t)[3]
System particle 3-vector type.
Definition: kernel.h:92
hnb_integ_t
enum hnb_integ_enum hnb_integ_t
Integration scheme choices.