Main Page   Class Hierarchy   Data Structures   File List   Data Fields   Globals  

rs_findtype.C

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 
00039 
00040 
00041 
00042 //----------------------------------------------------------------------------
00043 //   version 1:  Sept 1998   Simon Portegies Zwart   spz@grape.c.u-tokyo.ac.jp
00044 //                                                   University of Tokyo
00045 //   version 2:  July 2000  Simon Portegies Zwart   spz@mit.edu
00046 //                          Gijs Nelemans           gijsn@astro.uva.nl
00047 //............................................................................
00048 //   non-local functions: 
00049 //----------------------------------------------------------------------------
00050 
00051 #include "SeBa_hist.h"
00052 
00053 #ifdef TOOLBOX
00054 
00055 
00056 local void extract_binary_on_stellar_types(SeBa_hist *ha,
00057                                            char* prim_string,
00058                                            char* sec_string,
00059                                            binary_type bt,
00060                                            real a_min, real a_max,
00061                                            real m_min, real m_max,
00062                                            real e_min, real e_max,
00063                                            real q_min, real q_max,
00064                                            real dt,
00065                                            bool first_occasion,
00066                                            bool R_flag) {
00067 
00068   if (!strcmp(prim_string, sec_string)) {
00069     for_all_SeBa_hist(SeBa_hist, ha, hi) {
00070        if (hi->binary_contains(prim_string, sec_string, bt) &&
00071            hi->binary_limits(semi_major_axis, a_min, a_max) &&
00072            hi->binary_limits(primary_mass, m_min, m_max) &&
00073            hi->binary_limits(mass_ratio, q_min, q_max) &&
00074            hi->binary_limits(eccentricity, e_min, e_max)) {
00075          
00076          if (R_flag) {
00077            for_all_SeBa_hist(SeBa_hist, ha, ho) cout << *ho;       
00078          } 
00079          else if (!strcmp(prim_string, "any")) {
00080            
00081            cout << *hi->get_first();
00082            cout << *hi;
00083          } else {
00084 
00085            hi->put_first_formed_left(prim_string, dt);
00086          }
00087 
00088          if (first_occasion) 
00089            return;
00090        }
00091      }
00092   }
00093   else {
00094     for_all_SeBa_hist(SeBa_hist, ha, hi) {
00095       if ((hi->binary_limits(semi_major_axis, a_min, a_max) &&
00096            hi->binary_limits(eccentricity, e_min, e_max))) {
00097         
00098         if ((hi->binary_contains(prim_string, sec_string, bt) &&
00099              hi->binary_limits(mass_ratio, q_min, q_max) &&
00100              hi->binary_limits(primary_mass, m_min, m_max))) {
00101           
00102 
00103           if (R_flag) {
00104             for_all_SeBa_hist(SeBa_hist, ha, ho) cout << *ho;      
00105           } 
00106           else {
00107             cout << *hi->get_first();
00108             cout << *hi;
00109           }
00110 
00111           if (first_occasion) 
00112             return;
00113 
00114         } else if ((hi->binary_contains(sec_string, prim_string, bt) &&
00115                     hi->binary_limits(mass_ratio, 1/q_max, 1/q_min) &&
00116                     hi->binary_limits(secondary_mass, m_min, m_max))) {
00117           
00118           if (R_flag) {
00119             for_all_SeBa_hist(SeBa_hist, ha, ho) cout << *ho;      
00120           } 
00121           else {
00122             hi->get_first()->put_single_reverse(cout);
00123             hi->put_single_reverse(cout);
00124           }
00125 
00126           if (first_occasion) 
00127             return;
00128 
00129         }       
00130       }
00131     }
00132   }
00133 
00134 }
00135 
00136 //-----------------------------------------------------------------------------
00137 //  main  --  driver to reduce SeBa short dump data
00138 //-----------------------------------------------------------------------------
00139 
00140 
00141 main(int argc, char ** argv) {
00142 
00143     bool  c_flag = false;
00144     bool  v_flag = false;
00145     bool  R_flag = false;
00146     bool  first_occasion = true;
00147     
00148     char * primary_type_string = "bla";
00149     char * secondary_type_string = "bla";
00150 
00151     binary_type bt = Detached;
00152 
00153     real a_max = VERY_LARGE_NUMBER;
00154     real a_min = 0;
00155     real m_max = VERY_LARGE_NUMBER;
00156     real m_min = 0;
00157     real e_max = 1;
00158     real e_min = 0;
00159     real q_max = VERY_LARGE_NUMBER;
00160     real q_min = 0;
00161     real dt = 1.e4;
00162 
00163     real snap_time = -1;
00164     bool T_flag = false;
00165 
00166     int binaries_read = 0;
00167 
00168     check_help();
00169 
00170     extern char *poptarg;
00171     int c;
00172     char* param_string = "P:p:S:s:B:A:a:M:m:E:e:Q:q:ft:vR";
00173 
00174     while ((c = pgetopt(argc, argv, param_string)) != -1)
00175         switch(c)
00176             {
00177             case 'A': a_max = atof(poptarg);
00178                       break;
00179             case 'a': a_min = atof(poptarg);
00180                       break;
00181             case 'M': m_max = atof(poptarg);
00182                       break;
00183             case 'm': m_min = atof(poptarg);
00184                       break;
00185             case 'E': e_max = atof(poptarg);
00186                       break;
00187             case 'e': e_min = atof(poptarg);
00188                       break;
00189             case 'Q': q_max = atof(poptarg);
00190                       break;
00191             case 'q': q_min = atof(poptarg);
00192                       break;
00193             case 'f': first_occasion = !first_occasion;
00194                       break;
00195             case 'p':
00196             case 'P': primary_type_string = poptarg;
00197                       break;
00198             case 's':
00199             case 'S': secondary_type_string = poptarg;
00200                       break;
00201             case 'B': bt = extract_binary_type_string(poptarg);
00202                       break;
00203             case 't': dt = atof(poptarg);
00204                       break;
00205             case 'R': R_flag = true;
00206                       break;
00207             case 'v': v_flag = true;
00208                       break;
00209             case '?': params_to_usage(cerr, argv[0], param_string);
00210                       get_help();
00211                       exit(1);
00212             }            
00213 
00214     SeBa_hist* hi = new SeBa_hist;
00215     if (!hi->read_SeBa_hist(cin))
00216       exit(-1);
00217 
00218 
00219     // (GN+SPZ Dec 13 1999) disrupted has e = 1
00220     if (bt == Disrupted) e_max = 2.;
00221 
00222     int mergers = 0;    
00223     SeBa_hist* next_hi = get_history(hi, cin);
00224     do {
00225 
00226       binaries_read++;
00227 
00228       if (hi->get_last()->get_binary_type() == Merged) 
00229         mergers++;
00230 
00231         extract_binary_on_stellar_types(hi, primary_type_string,
00232                                         secondary_type_string,
00233                                         bt,
00234                                         a_min, a_max, m_min, m_max,
00235                                         e_min, e_max, q_min, q_max,
00236                                         dt, first_occasion,
00237                                         R_flag);
00238 
00239       if (v_flag)
00240         hi->put_history(cout, v_flag);
00241       
00242 
00243       delete hi;
00244       
00245       hi = next_hi;
00246       next_hi = get_history(hi, cin);
00247     }
00248     while (next_hi);
00249 
00250      extract_binary_on_stellar_types(hi->get_last(), primary_type_string,
00251                                      secondary_type_string,
00252                                      bt,
00253                                      a_min, a_max, m_min, m_max,
00254                                      e_min, e_max, q_min, q_max, 
00255                                      dt, first_occasion,
00256                                      R_flag);
00257 
00258      if (v_flag) {
00259        hi->put_history(cout, v_flag);
00260        cerr <<"Number of Mergers: " << mergers << endl;
00261      }
00262 
00263     cerr << "Total number of binaries read: " << binaries_read << endl;
00264 }
00265 
00266 #endif // endof: TOOLBOX
00267 
00268 
00269 
00270 
00271 

Generated at Sun Feb 24 09:57:13 2002 for STARLAB by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001