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

scatter3.h

00001 /*
00002        //=======================================================//    _\|/_
00003       //  __  _____           ___                    ___       //      /|\ ~
00004      //  /      |      ^     |   \  |         ^     |   \     //          _\|/_
00005     //   \__    |     / \    |___/  |        / \    |___/    //            /|\ ~
00006    //       \   |    /___\   |  \   |       /___\   |   \   // _\|/_
00007   //     ___/   |   /     \  |   \  |____  /     \  |___/  //   /|\ ~
00008  //                                                       //            _\|/_
00009 //=======================================================//              /|\ ~
00010 */
00011 
00012 /*
00013  *  scatter3.h: definitions for scattering 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_SCATTER3_H
00029 #  define  STARLAB_SCATTER3_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 three-body scattering 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 /* Scattering 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 /* Simple structure representing the dynamical state of a particle.
00115  * Place the index at the end for alignment reasons explained in
00116  * .../scatter3/interfaces/f_interface.h.
00117  */
00118 
00119 typedef struct {
00120     real mass;          /* >= 0 for a real particle */
00121     real pos[3];        /* Can't use vectors here because g++ 2.5.8 */
00122     real vel[3];        /* complains that they are improperly initialized... */
00123     int index;          /* > 0 for a real particle */
00124 } body;
00125 
00126 /*
00127 // Structures defining the initial, intermediate, and final states of a
00128 // single scattering.  "Initial" structure now modified to allow dual
00129 // use in both scattering and bound configurations.
00130 */
00131 
00132 typedef struct {
00133     real m2;            /* mass of secondary in target binary (m1 + m2 = 1) */
00134     real m3;            /* mass of incoming projectile                      */
00135     real r1;            /* radius of primary                                */
00136     real r2;            /* radius of secondary                              */
00137     real r3;            /* radius of third star                             */
00138     real sma;           /* inner binary semi-major axis                     */
00139     real ecc;           /* inner binary eccentricity                        */
00140 
00141     /* Outer orbit (unbound): */
00142 
00143     real v_inf;         /* projectile velocity at infinity (unit = v_crit)  */
00144     real rho;           /* projectile impact parameter                      */
00145 
00146     /* Outer orbit (bound): */
00147 
00148     real a_out;         /* outer binary semi-major axis                     */
00149     real e_out;         /* inner binary eccentricity                        */
00150 
00151     real r_init_min;    /* min initial distance from projectile to target   */
00152     real r_init_max;    /* max initial distance from projectile to target   */
00153     real r_init;        /* actual initial separation                        */
00154     real r_stop;        /* max permitted distance from escaper to binary    */
00155     real tidal_tol_factor; /* tidal perturbation at start/stop              */
00156     phase3 phase;       /* phase angles specifying the initial state        */
00157     real eta;           /* accuracy parameter                               */
00158     body system[3];     /* array giving details of initial state            */
00159     int id;             /* identifier                                       */
00160 
00161     real cpu_limit;     /* handy to keep some limits here...                */
00162     int snap_limit;
00163 
00164 } initial_state3;
00165 
00166 typedef struct {
00167     int  n_osc;                 /* number of "oscillations" in min(r)       */
00168     int  n_kepler;              /* number of analytic continuations         */
00169     int  n_stars;               /* final number of stars                    */
00170     int  index[3];              /* final labels                             */
00171     real r_min[3];              /* minimum interparticle separations        */
00172     real r_min_min;             /* absolute minimum separation              */
00173     enum intermediate_descriptor3 descriptor;
00174     body system[3];             /* details of intermediate state            */
00175     int id;                     /* identifier (should agree with init.id)   */
00176     int n_snap;                 /* snapshot counter                         */
00177 } intermediate_state3;
00178 
00179 typedef struct {
00180     real sma;                   /* final binary semi-major axis             */
00181     real ecc;                   /* final binary eccentricity                */
00182     real outer_separation;      /* final separation between third star      */
00183                                 /* and binary (if any)                      */
00184     enum final_descriptor3 descriptor;    
00185     int  escaper;               /* ID of escaping star (0 if none exists)   */
00186     real error;                 /* rel. energy error (unit=binary energy)   */
00187     xreal time;                 /* termination time                         */
00188     int  n_steps;               /* number of integration steps              */
00189     real virial_ratio;          /* final ratio K.E./|P.E.| of outer orbit   */
00190     body system[3];             /* array giving details of final state      */
00191                                 /* (non-particle <==> index = 0, mass < 0)  */
00192     int id;                     /* identifier (should agree with init.id)   */
00193 } final_state3;
00194 
00195 /*---------------------------------------------------------------------------*/
00196 
00197 #ifndef C_ONLY
00198 
00199 /* Function to perform a single scattering experiment: */
00200 
00201 void  scatter3(initial_state3&, intermediate_state3&, final_state3&,
00202                real cpu_time_check = 3600,
00203                real dt_out = VERY_LARGE_NUMBER,
00204                real dt_snap = VERY_LARGE_NUMBER,
00205                real snap_cube_size = 10,
00206                real dt_print = VERY_LARGE_NUMBER,
00207                sdyn3_print_fp p = NULL);
00208 
00209 /* Helpers: */
00210 
00211 char * state_string(intermediate_descriptor3); /* If state is X, print "X" */
00212 char * state_string(final_descriptor3);
00213 
00214 void print_bodies(ostream&, body*, int prec = 6);
00215 void print_initial(ostream&, initial_state3&,
00216                    int bod_flag = 0, int prec = 6);
00217 void print_intermediate(ostream&, intermediate_state3&,
00218                         int bod_flag = 0, int prec = 6);
00219 void print_final(ostream&, final_state3&,
00220                  int bod_flag = 0, int prec = 6);
00221 
00222 void print_scatter3_outcome(intermediate_state3&,
00223                             final_state3&,
00224                             ostream& s = cerr);
00225 void print_scatter3_summary(intermediate_state3&,
00226                             final_state3&,
00227                             real,
00228                             ostream& s = cerr);
00229 void print_scatter3_report(initial_state3&,
00230                            intermediate_state3&,
00231                            final_state3&,
00232                            real cpu = -1,
00233                            int bod = 0,
00234                            ostream& s = cerr);
00235 
00236 void randomize_angles(phase3 &); /* Establish random angles for scattering */
00237 
00238 void initialize_bodies(body *);
00239 void make_standard_init(initial_state3 &);   /* Set up template initial state */
00240 
00241 // In scat_init.C:
00242 
00243 void set_orientation(kepler &k, phase3 &p);
00244 sdyn3 * set_up_dynamics(real m2, real m3, kepler & k1, kepler & k3);
00245 void sdyn3_to_system(sdyn3 * root, body * system);
00246 
00247 // In extend_or_end.C:
00248 
00249 void merge_collisions(sdyn3 * b);
00250 
00251 int extend_or_end_scatter(sdyn3 * b,
00252                           initial_state3& init,
00253                           intermediate_state3 * inter = NULL,
00254                           final_state3 * final = NULL);
00255 
00256 #endif
00257 #endif

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