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

scatter.h

00001 
00002        //=======================================================//    _\|/_
00003       //  __  _____           ___                    ___       //      /|\ ~
00004      //  /      |      ^     |   \  |         ^     |   \     //          _\|/_
00005     //   \__    |     / \    |___/  |        / \    |___/    //            /|\ ~
00006    //       \   |    /___\   |  \   |       /___\   |   \   // _\|/_
00007   //     ___/   |   /     \  |   \  |____  /     \  |___/  //   /|\ ~
00008  //                                                       //            _\|/_
00009 //=======================================================//              /|\ ~
00010 
00011 /*
00012  *  scatter.h: definitions for scattering experiments
00013  *.............................................................................
00014  *    version 1:  Dec 1993   Piet Hut & Steve McMillan
00015  *    version 2:
00016  *.............................................................................
00017  *     This file includes:
00018  *  1) definition of state structures
00019  *  2) declaration of an integrator
00020  *       ....
00021  *.............................................................................
00022  */
00023 
00024 #ifndef  STARLAB_SCATTER_H
00025 #  define  STARLAB_SCATTER_H
00026 
00027 #ifdef USE_MPI
00028 #include  "mpi++.h"
00029 #else
00030 #include  "../src/node/dyn/hdyn/sdyn/evolve/localmpi++.h"
00031 #endif
00032 
00033 #include  "../src/node/dyn/hdyn/sdyn/evolve/scatter_hist.h"
00034 #include  "sdyn.h"
00035 
00036 #define DATA_COMING_TAG    0
00037 #define DATA_REQUEST_TAG   1
00038 #define WRITE_REQUEST_TAG  2
00039 #define WRITE_READY_TAG    3
00040 #define SEND_HOLD_TAG      4
00041 #define STOP_HOLD_TAG      5
00042 
00043 #define N_FINAL 255 // Obscure historical number inherited from scatter3
00044                     // gives now the number of scenarios, which can be large!
00045 #define N_INTER 255 // see N_FINAL
00046 
00047 #define DYNAMICS        1
00048 #define STABILITY       1
00049 #define K_MAX           2
00050 
00051 //-----------------------------------------------------------------------------
00052 
00053 #if 0
00054 enum intermediate_descriptor {
00055     non_resonance=0, hierarchical_resonance, democratic_resonance,
00056     unknown_intermediate, number_of_intermediate_descriptors
00057 };
00058 
00059 enum final_descriptor {
00060   preservation=0, non_preservation, error, stopped, unknown_final,
00061   number_of_final_descriptors
00062 };
00063 #endif
00064 
00065 // Integration parameters:
00066 
00067 #define CHECK_INTERVAL          20.0
00068 #define DEFAULT_ETA             0.05
00069 
00070 // Scattering parameters:
00071 
00072 #define LARGE_SEPARATION 10.0      // To be determined (e.g. large mass ratios)
00073 #define LARGE_SEPARATION_FACTOR 10.0 // For all mass ratios
00074 #define TIDAL_TOL_FACTOR 1e-6
00075 #define ENERGY_SAFETY_FACTOR 0.01
00076 
00077 #define MIN_INITIAL_SEPARATION    10.0
00078 #define MAX_INITIAL_SEPARATION    VERY_LARGE_NUMBER
00079 
00080 #define ENERGY_TOLERANCE 1e-4        // Maximum absolute energy error allowed
00081 #define MERGER_ENERGY_TOLERANCE 1e-3 // Relax tolerance for *relative* error
00082                                      // in case of merger
00083 
00084 
00085 class scatter_input {
00086 public:
00087   char init_string[255];
00088 
00089   real  delta_t;
00090   real  eta;
00091   real  tidal_tol_factor;
00092   real  dt_out;
00093   real  dt_snap;
00094   real  snap_cube_size;
00095   real  cpu_time_check;
00096 
00097   int  n_experiments;
00098   int  seed;
00099   int  n_rand;
00100   int  n_rand_inc;
00101   int  pipe;
00102   int  debug;
00103   int  verbose;
00104 
00105   scatter_input() {
00106 
00107     delta_t = dt_out = dt_snap = VERY_LARGE_NUMBER;
00108     eta = 0.02;    
00109     tidal_tol_factor = 1.e-6;
00110     snap_cube_size = 10;
00111     cpu_time_check = 3600;
00112     n_experiments = 1;
00113     seed = n_rand = n_rand_inc = pipe = debug = 0;
00114     verbose = 0;
00115   }
00116 
00117   friend ostream& operator<<(ostream& s, scatter_input&);
00118 };
00119 
00120 // Structure describing the high-level profile of a scattering experiment:
00121 
00122 typedef struct {
00123     char* init_string;                  // Initialization for mkscat
00124     int n_string;                       
00125     real mt;                            // mass of target binary
00126     real mp;                            // mass of projectile binary
00127     real ap;                            // semi major axis of projectile 
00128     real peri;                          // maximum pericenter distance
00129     real rho;                           // selected impact parameter
00130     real rho_sq_min;                    // minimum impact parameter squared
00131     real rho_sq_max;                    // maximum impact parameter squared
00132     real v_inf;                         // velocity at infinity
00133 
00134     real r1;                            // radius of primary
00135     real r2;                            // radius of secondary
00136     real r3;                            // radius of third star
00137     real tidal_tol_factor;              // tidal perturbation at start/stop
00138     int  rho_flag;                      // choice of random or user-specified
00139                                         //      impact parameter
00140     int  ecc_flag;                      // choice random or user-specified
00141                                         //      eccentricity
00142     real ecc;                           // eccentricity if specified by user
00143   //phase3_flag phase_flag;             // randomization options for angles
00144   //phase3 phase;                       // angles if specified externally
00145     real eta;                           // overall/initial accuracy parameter
00146 
00147   //    intermediate_descriptor3        // specification of the final state
00148   //    intermediate_target;
00149   //    final_descriptor3 final_target1;
00150   //    final_descriptor3 final_target2;
00151 
00152 } scatter_profile;
00153 
00154 // Simple structure representing the dynamical state of a particle:
00155 
00156 typedef struct {
00157     int index;          // > 0 for a real particle
00158     real mass;          // >= 0 for a real particle
00159     vec pos;
00160     vec vel;
00161 } body;
00162 
00163 // Helpers:
00164 
00165 void print_bodies(ostream&, body*, int prec = 6);
00166 
00167 void initialize_bodies(body *);
00168 void set_kepler_from_sdyn(kepler&, sdyn *, sdyn *);
00169 
00170 sdyn* mkscat(int, char**, scatter_profile&);
00171 sdyn* mkscat(char*, scatter_profile&);
00172 sdyn* mkscat(int, char**);
00173 sdyn* mkscat(char*);
00174 
00175 
00176 
00177 // Structures defining the initial, intermediate, and final states of a
00178 // single scattering.  "Initial" structure now modified to allow dual
00179 // use in both scattering and bound configurations.
00180 
00181 typedef struct {
00182 
00183     int  np_star;       // number of stars in projectile
00184     int  nt_star;       // number of stars in target
00185     real v_inf;         // com projectile velocity at infinity (unit = v_crit)
00186     real rho;           // com projectile impact parameter
00187 
00188   //    nbodystate * system;
00189 } initial_state;
00190 
00191 void scatter(sdyn* b, real eta,
00192              real delta_t, real dt_out, real cpu_time_check,
00193              real dt_snap, real ttf, real snap_cube_size,
00194              int debug,
00195              scatter_exp &experiment);
00196 
00197 void scatter(sdyn* b, scatter_input input, 
00198              scatter_exp &experiment);
00199 
00200 int extend_or_end_scatter(sdyn * b, real ttf, bool debug);
00201 void ppn(sdyn* b, ostream & s, int level = 0);
00202 void parse_string(char* s, int& argc, char* argv[]);
00203 
00204 #endif
00205 
00206 

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