HNBody Version 1.0.10

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