Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

bound3.h

00001 /*
00002        //=======================================================//    _\|/_
00003       //  __  _____           ___                    ___       //      /|\ ~
00004      //  /      |      ^     |   \  |         ^     |   \     //          _\|/_
00005     //   \__    |     / \    |___/  |        / \    |___/    //            /|\ ~
00006    //       \   |    /___\   |  \   |       /___\   |   \   // _\|/_
00007   //     ___/   |   /     \  |   \  |____  /     \  |___/  //   /|\ ~
00008  //                                                       //            _\|/_
00009 //=======================================================//              /|\ ~
00010 */
00011 
00012 /*
00013  *  bound3.h: definitions for bound 3-body experiments
00014  *.............................................................................
00015  *    version 1:  Dec 1993   Piet Hut & Steve McMillan
00016  *    version 2:
00017  *.............................................................................
00018  *     This file includes:
00019  *  1) definition of state structures
00020  *  2) declaration of an integrator
00021  *       ....
00022  *.............................................................................
00023  *
00024  * Note use of C-style comments, as this may conceivably be included in
00025  * C or C++ programs.
00026  */
00027 
00028 #ifndef  STARLAB_BOUND3_H
00029 #  define  STARLAB_BOUND3_H
00030 
00031 #ifndef C_ONLY
00032 #  include  "sdyn3.h"
00033 #else
00034 #  include  "c_stdinc.h"
00035 #endif
00036 
00037 /*---------------------------------------------------------------------------*/
00038 
00039 /* Possible states of a three-body run: */
00040 
00041 #define N_INTER 4
00042 
00043 enum intermediate_descriptor3 {
00044     non_resonance, hierarchical_resonance, democratic_resonance,
00045     unknown_intermediate
00046 };
00047 
00048 #define N_FINAL 14
00049 
00050 enum final_descriptor3 {
00051     preservation, exchange_1, exchange_2, ionization,
00052     merger_binary_1, merger_binary_2, merger_binary_3,
00053     merger_escape_1, merger_escape_2, merger_escape_3,
00054     triple_merger, error, stopped, unknown_final
00055 };
00056 
00057 /*
00058 // The inner binary always lies in the (x-y) plane, with its long
00059 // axis along the x-axis. The normal to the plane of the outer orbit
00060 // makes an angle theta with respect to the z axis; its projection
00061 // onto the (x-y) plane makes an angle phi with the x-axis--that is,
00062 // theta and phi are the usual spherical polar coordinates describing
00063 // the normal vector.
00064 
00065 // All orbital motions are, by definition, counterclockwise around the
00066 // normal vector. Thus, planar prograde orbits have theta = 0, planar
00067 // retrograde orbits have theta = pi.
00068 
00069 // The angle psi measures rotation in the plane of the outer orbit.
00070 // If the outer orbit lies in the (x-y) plane, psi measures the
00071 // the orientation of the periastron, measured counterclockwise from
00072 // to the x-axis. For an outer orbit in the (x-z) plane, psi measures
00073 // angle from x towards -z; for the (y-z) plane, psi is from y towards z.
00074 */
00075 
00076 /* Phase angles defining the bound 3-body configuration: */
00077 
00078 typedef struct {
00079     real cos_theta;
00080     real phi;
00081     real psi;
00082     real mean_anomaly;
00083 } phase3;
00084 
00085 /* Flags to distinguish between random and specific angles: */
00086 
00087 typedef struct {
00088     int  cos_theta;
00089     int  phi;
00090     int  psi;
00091     int  mean_anomaly;
00092 } phase3_flag;
00093 
00094 /*---------------------------------------------------------------------------*/
00095 
00096 /* Integration parameters: */
00097 
00098 #define CHECK_INTERVAL  20
00099 #define DEFAULT_ETA     0.05
00100 
00101 /* 3-body parameters: */
00102 
00103 #define LARGE_SEPARATION 10        /* To be refined (e.g. large mass ratios) */
00104 #define LARGE_SEPARATION_FACTOR 10 /* For all mass ratios */
00105 #define ENERGY_SAFETY_FACTOR 0.01
00106 
00107 #define MIN_INITIAL_SEPARATION    10
00108 #define MAX_INITIAL_SEPARATION    VERY_LARGE_NUMBER
00109 
00110 #define ENERGY_TOLERANCE 1e-4        /* Maximum absolute energy error allowed */
00111 #define MERGER_ENERGY_TOLERANCE 1e-3 /* Relax tolerance for *relative* error */
00112                                      /* in case of merger */
00113 
00114 typedef struct {
00115     real mass;          /* >= 0 for a real particle */
00116     real pos[3];        /* Can't use vectors here because g++ 2.5.8 */
00117     real vel[3];        /* complains that they are improperly initialized... */
00118     int index;          /* > 0 for a real particle */
00119 } body;
00120 
00121 /*
00122 // Structures defining the intermediate, and final states of a
00123 // single bound 3-body system.
00124 */
00125 
00126 typedef struct {
00127     int  n_osc;                 /* number of "oscillations" in min(r)       */
00128     int  n_kepler;              /* number of analytic continuations         */
00129     int  n_stars;               /* final number of stars                    */
00130     int  index[3];              /* final labels                             */
00131     real r_min[3];              /* minimum interparticle separations        */
00132     real r_min_min;             /* absolute minimum separation              */
00133     enum intermediate_descriptor3 descriptor;
00134     body system[3];             /* details of intermediate state            */
00135     int id;                     /* identifier (should agree with init.id)   */
00136 } intermediate_state3;
00137 
00138 typedef struct {
00139     real sma;                   /* final binary semi-major axis             */
00140     real ecc;                   /* final binary eccentricity                */
00141     real outer_separation;      /* final separation between third star      */
00142                                 /* and binary (if any)                      */
00143     enum final_descriptor3 descriptor;    
00144     int  escaper;               /* ID of escaping star (0 if none exists)   */
00145     real error;                 /* rel. energy error (unit=binary energy)   */
00146     xreal time;                 /* termination time                         */
00147     int  n_steps;               /* number of integration steps              */
00148     real virial_ratio;          /* final ratio K.E./|P.E.| of outer orbit   */
00149     body system[3];             /* array giving details of final state      */
00150                                 /* (non-particle <==> index = 0, mass < 0)  */
00151     int id;                     /* identifier (should agree with init.id)   */
00152 } final_state3;
00153 
00154 /*---------------------------------------------------------------------------*/
00155 
00156 #ifndef C_ONLY
00157 
00158 /* Function to perform a single bound 3-body experiment: */
00159 
00160 void  bound3(initial_state3&, intermediate_state3&, final_state3&,
00161                real cpu_time_check = 3600,
00162                real dt_out = VERY_LARGE_NUMBER,
00163                real dt_snap = VERY_LARGE_NUMBER,
00164                real snap_cube_size = 10,
00165                real dt_print = VERY_LARGE_NUMBER,
00166                sdyn3_print_fp p = NULL);
00167 
00168 /* Helpers: */
00169 
00170 char * state_string(intermediate_descriptor3); /* If state is X, print "X" */
00171 char * state_string(final_descriptor3);
00172 
00173 void print_bodies(ostream&, body*, int prec = 6);
00174 void print_initial(ostream&, initial_state3&,
00175                    int bod_flag = 0, int prec = 6);
00176 void print_intermediate(ostream&, intermediate_state3&,
00177                         int bod_flag = 0, int prec = 6);
00178 void print_final(ostream&, final_state3&,
00179                  int bod_flag = 0, int prec = 6);
00180 
00181 void print_bound3_outcome(intermediate_state3&,
00182                             final_state3&,
00183                             ostream& s = cerr);
00184 void print_bound3_summary(intermediate_state3&,
00185                             final_state3&,
00186                             real,
00187                             ostream& s = cerr);
00188 void print_bound3_report(initial_state3&,
00189                            intermediate_state3&,
00190                            final_state3&,
00191                            real cpu = -1,
00192                            bool b = FALSE,
00193                            ostream& s = cerr);
00194 
00195 void initialize_bodies(body *);
00196 void make_standard_init(initial_state3 &);   /* Set up template initial state */
00197 
00198 // In scat_init.C:
00199 
00200 void set_orientation(kepler &k, phase3 &p);
00201 sdyn3 * set_up_dynamics(real m2, real m3, kepler & k1, kepler & k3);
00202 void sdyn3_to_system(sdyn3 * root, body * system);
00203 
00204 // In extend_or_end.C:
00205 
00206 void merge_collisions(sdyn3 * b);
00207 
00208 int extend_or_end(sdyn3 * b,
00209                   initial_state3& init,
00210                   intermediate_state3 * inter = NULL,
00211                   final_state3 * final = NULL);
00212 
00213 #endif
00214 #endif

Generated on Wed Jul 20 12:43:35 2005 for Starlab by  doxygen 1.4.3