- Main Page
- Related Pages
- Data Structures
- Files

- File List
- Globals

# hnbody/kernel.h

Go to the documentation of this file.

    00001 #ifndef HNBODY_KERNEL_H
    00002 #define HNBODY_KERNEL_H
    00003
    00013 #include <mutils/util.h>
    00014
    00015 #ifdef __cplusplus
    00016 extern "C" {
    00017 namespace HNBODY {
    00018 #endif
    00019
    00020
    00022 typedef enum hnb_integcoord_enum {
    00023   Origin=1+2,
    00024   Barycentric=0,
    00025   Bodycentric=1,
    00026   Jacobi=2,
    00028   Regularized=4,
    00029   TWform=Regularized,
    00030   RegBarycentric=Regularized+Barycentric,
    00032   RegJacobi=Regularized+Jacobi,
    00034   ModBodycentric=TWform+Bodycentric,
    00036   Coordinates=Origin+Regularized,
    00039   Splitting=8+16,
    00040   Kick_Drift=0,
    00041   Drift_Kick=8,
    00042   Shift_Drift=16,
    00044   Order=32+64,
    00045   Order2=0,
    00046   Order4=32,
    00047   ModKick=64,
    00048   Order4mk=Order4+ModKick,
    00050   Integrator=Coordinates+Splitting+Order,
    00053   Corrected=128+256+512,
    00055   Reverse=1024,
    00056   Uncorrected=0,
    00057   Corrected2=128,
    00058   Corrected4=256,
    00059   Corrected6=512,
    00060   Corrector=Reverse+Corrected,
    00063   Gravity=2048,
    00064   Newtonian=0,
    00065   PostNewtonian=Gravity,
    00068   Kernel=4096,
    00069   PolyKernel=0,
    00070   TanhKernel=Kernel,
    00072   SplitI=8192
    00073 } hnb_integcoord_t;
    00074
    00076 typedef enum hnb_integ_enum {
    00077   Symplectic,
    00078   BulirschStoer,
    00079   RungeKutta
    00080 } hnb_integ_t;
    00081
    00083 typedef enum LWP_enum {
    00084   LWP_NONE,
    00085   LWP_ZWP
    00086 } hnb_LWP_t;
    00087
    00089 typedef double (*hnb_vector_t)[3];
    00090
    00091 /* Forward reference. */
    00092 struct hnb_data_struct;
    00093
    00094 typedef
    00096   void (*hnb_extra_t)(hnb_vector_t, double t, hnb_vector_t, const double m[],
    00097          int nHL, int n, double dt, const struct hnb_data_struct *sys);
    00098 typedef
    00100   void (*hnb_drift_t)(hnb_vector_t dx, hnb_vector_t dv, double t,
    00101          hnb_vector_t x, hnb_vector_t v, const double m[],
    00102          int nHL, int n, double dt, const struct hnb_data_struct *sys);
    00103 typedef
    00105   double (*hnb_energy_t)(double t, hnb_vector_t x, hnb_vector_t v,
    00106          const double m[], int nHL, const struct hnb_data_struct *sys);
    00107 typedef
    00109   int  (*hnb_derivs_t)(hnb_vector_t dxdt, hnb_vector_t dvdt,
    00110          double t, hnb_vector_t x, hnb_vector_t v,
    00111          const double m[], int nHL, int n, const struct hnb_data_struct *sys);
    00112
    00113
    00115 typedef struct hnb_data_struct {
    00116   /* "Public" data. */
    00117   double G, c, Msun, dm, J2, J4, J6, obRad, dzH, dzZ, eps, tinit,
    00118       tH[2], dtH[2], tZ[2], dtZ[2];
    00119   int nH, nHL, n, fixedH, enc, prune;
    00120   hnb_vector_t x0, dx0, v0, dv0, x1, dx1, v1, dv1;
    00121   double *m, *rcapt, *renc;
    00122   hnb_integ_t integ;
    00123   hnb_integcoord_t itH, itZ;
    00124   hnb_LWP_t Ltype;
    00125   int *id, *imap, *jindex;
    00126   FILE *log;
    00127
    00128   hnb_extra_t extra_kick, extra_shift;
    00129   hnb_drift_t extra_drift;
    00130   hnb_derivs_t extra_derivs;
    00131   hnb_energy_t extra_energy;
    00132
    00133   /* "Private" data from here onward... */
    00134   hnb_vector_t x00;
    00135   int pindex;
    00136
    00137   /* Volatile, driver-related data. */
    00138   volatile int halt;
    00139   const char *recover;
    00140
    00141   /* Temporary system vector cache. */
    00142   hnb_vector_t *tmpvec;
    00143   int ntmp, tmpmax;
    00144
    00145   /* Output file pointer cache. */
    00146   FILE *body[512];
    00147   int bopen;
    00148
    00149   /* Data used only with certain integrations. */
    00150   double dzODE, *tmpODE;
    00151   double *deta, *ieta, *dsZ, *E0, *E1, *t, *tt;
    00152   hnb_vector_t xH, vH, xt, vt, xHtab, vHtab;
    00153   int iZ0, ntab, maxtab, itmax;
    00154   unsigned char *ace;
    00155   double dtdz, ttab0;
    00156
    00157   hnb_vector_t xh0, xh1, xha, xhb, vh0, vh1, vha, vhb, xa, xb, va, vb;
    00158 } hnb_data_t;
    00159
    00160
    00161 /* User-callable functions. */
    00162 DLLSPEC extern void
    00163   hnb_angmom(double L[], hnb_vector_t x, hnb_vector_t v, hnb_data_t *sys),
    00164   hnb_calcCoord(hnb_vector_t xNew, hnb_vector_t vNew,
    00165     hnb_integcoord_t newFrame, const hnb_data_t *sys),
    00166   hnb_checkpoint(hnb_data_t *sys, const char *file, int halt),
    00167   hnb_free_data(hnb_data_t *sys),
    00168   hnb_write(hnb_data_t *sys, const char *file),
    00169   hnb_util_version(FILE *f, const char *name, const char *revision,
    00170     const char *prefix),
    00171   hnb_print_info(FILE *f, void (*custom)(FILE *f, const char *prefix),
    00172     const char *prefix),
    00173   hnb_step(hnb_data_t *sys);
    00174
    00175 DLLSPEC extern const char
    00176  *hnb_contact(void), *hnb_version(void), *hnb_website(void);
    00177
    00178 DLLSPEC extern const int
    00179  *hnb_idtags(const hnb_data_t *sys),
    00180  *hnb_jacmap(const hnb_data_t *sys);
    00181
    00182 DLLSPEC extern int
    00183   hnb_N(const hnb_data_t *sys),
    00184   hnb_hwp_N(const hnb_data_t *sys),
    00185   hnb_lwp_N(const hnb_data_t *sys),
    00186   hnb_zwp_N(const hnb_data_t *sys),
    00187   hnb_save(const char *save, double key, hnb_data_t *sys),
    00188   hnb_restore(double *key, const char *save, hnb_data_t *sys),
    00189   hnb_argv_driver(int argc, char *argv[], hnb_extra_t kick,
    00190     hnb_extra_t shift, hnb_drift_t drift, hnb_derivs_t derivs,
    00191     hnb_energy_t energy, void (*custom)(FILE *f, const char *prefix));
    00192
    00193 DLLSPEC extern hnb_integcoord_t
    00194   hnb_integcoord(const hnb_data_t *sys),
    00195   hnb_zwp_integcoord(const hnb_data_t *sys);
    00196
    00197 DLLSPEC extern const double
    00198  *hnb_masses(const hnb_data_t *sys),
    00199  *hnb_enc_radii(const hnb_data_t *sys),
    00200  *hnb_capt_radii(const hnb_data_t *sys);
    00201
    00202 DLLSPEC extern double
    00203   hnb_G(const hnb_data_t *sys), hnb_c(const hnb_data_t *sys),
    00204   hnb_Msun(const hnb_data_t *sys), hnb_M(const hnb_data_t *sys),
    00205   hnb_tinit(const hnb_data_t *sys),
    00206   hnb_stepsize(const hnb_data_t *sys),
    00207   hnb_zwp_stepsize(const hnb_data_t *sys),
    00208   hnb_eff_stepsize(const hnb_data_t *sys),
    00209   hnb_output(double *t, double (**x)[3], double (**v)[3], hnb_data_t *sys);
    00210
    00211
    00212 DLLSPEC extern hnb_data_t
    00213  *hnb_read(const char *file),
    00214  *hnb_init_file(const char *hnbfile, FILE *logfile),
    00215  *hnb_init_extra(const char *hnbfile, FILE *logfile, hnb_extra_t extra_kick,
    00216      hnb_extra_t extra_shift, hnb_drift_t extra_drift,
    00217      hnb_derivs_t extra_derivs, hnb_energy_t extra_energy),
    00218
    00219  *hnb_ode_init(double tinit, const double xinit[][3], const double vinit[][3],
    00220      const double m[], const int id[],
    00221      int nH, int nL, int nZ, hnb_LWP_t ltype, int fixedH,
    00222      int enc, const double rcapt[], double G, double c, double Msun,
    00223      double J2, double J4, double J6, double obRadius,
    00224      double dt, double eps,
    00225      hnb_integ_t integ, hnb_integcoord_t icoord,
    00226      hnb_derivs_t extra_derivs, hnb_energy_t extra_energy, int nthreads),
    00227
    00228  *hnb_init(double tinit, const double xinit[][3], const double vinit[][3],
    00229      const double m[], const int id[], const int jindex[],
    00230      int nH, int nL, int nZ, hnb_LWP_t ltype, int fixedH,
    00231      int enc, int prune,
    00232      const double renc[], const double rcapt[], double G, double c, double Msun,
    00233      double J2, double J4, double J6, double obRadius,
    00234      double dm, double dzH, double dzZ,
    00235      hnb_integcoord_t itH, hnb_integcoord_t itZ,
    00236      hnb_extra_t extra_kick, hnb_extra_t extra_shift, hnb_drift_t extra_drift,
    00237      hnb_energy_t extra_energy, int nthreads);
    00238
    00239
    00240 #ifdef __cplusplus
    00241 }  // namespace HNBODY
    00242 }  // extern "C"
    00243 #endif
    00244
    00245 #endif  /* HNBODY_KERNEL_H */