Main Page   Class Hierarchy   Data Structures   File List   Data Fields   Globals  

tripev.C

Go to the documentation of this file.
00001 /*
00002  *  tripev.C: evolves triple system
00003  *.............................................................................
00004  *    version 1:  Okt 1993   Simon F. Portegies Zwart 
00005  *.............................................................................
00006  */
00007 #include "stdinc.h"
00008 #include "double_star.h"
00009 #include "single_star.h"
00010 #include "main_sequence.h"
00011 #include <stdlib.h>
00012 #include <fstream.h>
00013 
00014 #define FULL_OUTPUT
00015 
00016 #  define  FALSE  0
00017 #  define  TRUE   1
00018 
00019 /*-----------------------------------------------------------------------------
00020  *  main  --
00021  *      usage:
00022  *              tripev -t # [options]  ,
00023  *
00024  *              where # is the initial age of the cluster.
00025  *      options:
00026  *              The following options are allowed:
00027  *      cluster age:
00028  *              -t #    Where # stands for the initial age of the
00029  *                      in Myear.
00030  *
00031  *              At present the running time of the integrator correspnds
00032  *              to the stellar age an a one by 10e6year basis.
00033  *              This however should be scaled to the cluster parameters.
00034  *-----------------------------------------------------------------------------
00035  */
00036 
00037 /*-----------------------------------------------------------------------------
00038  *  binev  --
00039  *-----------------------------------------------------------------------------
00040  */
00041 local void  binev(double_star * b, real start_time, real end_time, 
00042                   int n_steps) {
00043 
00044 //              Setup star from input data.
00045     real ageint = (end_time - start_time)/n_steps;
00046 
00047     real time_done, until_time, dt;
00048     for(int j = 0; j<n_steps; j++) {
00049            b->evolve_element(start_time+ageint*(j+1));
00050            cout << b->get_binary_age() <<":";
00051            b->put_appeal();
00052 #ifdef FULL_OUTPUT
00053     b->print_status();
00054 #endif
00055     }
00056 
00057 /*
00058 cout << "result: " << type_string(b->get_bin_type()) 
00059                   << " (" << type_string(b->get_primary()->get_element_type())
00060                   << ", " << type_string(b->get_secondary()->get_element_type())
00061                   << ")         Random seed: " << seed << endl; 
00062 cout <<"M = "<<b->get_primary()->get_total_mass()<<"\t"
00063      <<"R = "<<b->get_primary()->get_radius()<<endl;
00064 cout <<"m = "<<b->get_secondary()->get_total_mass()<<"\t"
00065      <<"r = "<<b->get_secondary()->get_radius()<<endl;
00066 cout <<"a = "<<b->get_semi()<<endl;
00067 cout <<"e = "<<b->get_eccentricity()<<endl;
00068 */
00069 }     
00070 
00071 /* endof: addstar.C */
00072 
00073 void main(int argc, char ** argv)
00074     {
00075 /*
00076     main_sequence * m = new main_sequence();
00077     single_star * p = new single_star(m);
00078     main_sequence * n = new main_sequence();
00079     single_star * s = new single_star(n);
00080     double_star * b = new double_star(p, s);
00081 */
00082 
00083     star_appeal primary, secondary;
00084 //    double_star * b = new double_star();
00085     double_init inner;
00086     double_init outer;
00087     int  c;
00088     bool  M_flag = FALSE;
00089     bool  Q_flag = FALSE;
00090     bool  c_flag = FALSE;
00091     bool  f_flag = FALSE;
00092     inner.start_time = outer.start_time = 0;           // default value;
00093     inner.end_time = outer.end_time = 23;
00094     inner.n_steps = outer.n_steps = 1;
00095     inner.mass_prim = 12;
00096     inner.q = 0.75;
00097     outer.mass_prim = (1+inner.q) * inner.mass_prim;
00098     outer.q = 0.2;
00099     inner.semi = 250;
00100     outer.semi = 1000;
00101     inner.eccentricity = 0.2;
00102     outer.eccentricity = 0.1;
00103     int   id = 1;
00104     char  *comment;
00105     int   seed = 0;
00106     int   srandinter(int);
00107     extern char *poptarg;
00108     int   pgetopt(int, char **, char *);
00109 //    local void  binev(double_star *, real, real, int);
00110     
00111     if (argc <= 1)
00112        cerr <<"Default: binev -t 0 -T 23 -a 250 -e 0.25 -M 12 -m 10 -n 1 \n";
00113  
00114     while ((c = pgetopt(argc, argv, "t:n:M:Q:q:A:a:E:e:T:fs:c:")) != -1)
00115         switch(c)
00116             {
00117             case 't': inner.start_time = 
00118                       outer.start_time = atof(poptarg);
00119                       break;
00120             case 'n': inner.n_steps = 
00121                       outer.n_steps = atoi(poptarg);
00122                       break;
00123             case 'M': M_flag = TRUE;
00124                       inner.mass_prim = 
00125                       outer.mass_prim = atof(poptarg);
00126                       break;
00127             case 'Q': Q_flag = TRUE;
00128                       inner.q = atof(poptarg);
00129                       break;
00130             case 'q': outer.q = atof(poptarg);
00131                       break;
00132             case 'A': inner.semi   = atof(poptarg);
00133                       break;
00134             case 'a': outer.semi   = atof(poptarg);
00135                       break;
00136             case 'E': inner.eccentricity = atof(poptarg);
00137                       break;
00138             case 'e': outer.eccentricity = atof(poptarg);
00139                       break;
00140             case 'T': inner.end_time = 
00141                       outer.end_time = atof(poptarg);
00142                       break;
00143             case 'f': f_flag = TRUE;
00144                       break;
00145             case 's': seed = atoi(poptarg);
00146                       break;
00147             case 'c': c_flag = TRUE;
00148                       comment = poptarg;
00149                       break;
00150             case '?': cerr <<"usage: binev [-t #] [-T #] "
00151                            <<             "[-M #] [-n #] "
00152                            <<             "[-Q #] [-q #] "
00153                            <<             "[-A #] [-a #] "
00154                            <<             "[-E #] [-e #] "
00155                            <<             "[-s #] [-c \"..\"] "
00156                            <<             "[-f < filename] \n";
00157                       exit(1);
00158             }
00159 
00160     if (inner.end_time<=inner.start_time) {
00161        cerr << "time of final stage should exceed initial stage time" 
00162             << " (" << inner.start_time << ">" << inner.end_time << ")" << endl;
00163        exit(1);
00164     }
00165 
00166     if (M_flag || Q_flag)
00167        outer.mass_prim = (1+inner.q) * inner.mass_prim;
00168 
00169     double_star * t = triple_star(inner, outer);
00170 /*
00171 //    main_sequence * m = new main_sequence();
00172     single_star * p = new single_star();
00173     p->initialize(m_prim, id, t_start);
00174 //    main_sequence * n = new main_sequence();
00175     single_star * s = new single_star();
00176     s->initialize(m_sec, id, t_start);
00177     double_star * b = new double_star(p, s, semi, ecc, t_start);
00178    
00179 //    main_sequence * o = new main_sequence();
00180     single_star * d = new single_star();
00181     d->initialize(m_tert, id, t_start);
00182     double_star * t = new double_star(b, d, a2, e2, t_start);
00183 
00184     int random_seed = srandinter(seed);
00185     cout << "Random seed: " << random_seed << endl;
00186 */
00187 /*
00188     int id = 1;
00189     if(!f_flag)
00190        b->initialize(m_prim, m_sec, semi, ecc, id, t_start);
00191     else
00192        b->initialize(id, t_start);
00193 */
00194 
00195 //    primary.init_star_appeal((star*)b->get_primary());
00196 //    secondary.init_star_appeal((star*)b->get_primary());
00197 #ifdef FULL_OUTPUT
00198     t->put_element();
00199     t->print_status();
00200 #endif
00201 
00202     binev(t, inner.start_time, inner.end_time, inner.n_steps);
00203 
00204 /*
00205     if (primary.identity == t->get_primary()->get_identity()) {
00206        primary.make_star_appeal((star*)t->get_primary());
00207        secondary.make_star_appeal((star*)t->get_secondary());
00208        primary.put_star_appeal();
00209        cout <<", ";
00210        secondary.put_star_appeal();
00211     }
00212     else {
00213        secondary.make_star_appeal((star*)b->get_primary());
00214        primary.make_star_appeal((star*)b->get_secondary());
00215        secondary.put_star_appeal();
00216        cout <<", ";
00217        primary.put_star_appeal();
00218     }
00219 */
00220 
00221  }

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