00001
00002
00003
00004 #include "dstar_to_dyn.h"
00005
00006 #include "hdyn.h"
00007
00008
00009 #ifndef TOOLBOX
00010
00011 struct pop {
00012 int stypes[no_of_stellar_type];
00013
00014 pop() {
00015 for (int i=0; i<no_of_stellar_type; i++)
00016 stypes[i]=0;
00017 }
00018 };
00019
00020
00021 struct nm_bin {
00022 int no_of_stars;
00023 real mass_limit;
00024 real total_mass;
00025 nm_bin() {
00026 no_of_stars=0;
00027 mass_limit=total_mass=0;
00028 }
00029 };
00030
00031 local void print_binary_content(dyn* b, binary_type which) {
00032
00033 pop *content = new pop[no_of_stellar_type-1];
00034
00035 int N_total = 0;
00036 double_state bst;
00037 for_all_daughters(dyn, b, bi)
00038
00039
00040
00041 if (bi->get_oldest_daughter() != NULL &&
00042 has_dstar(bi->get_oldest_daughter())) {
00043
00044 bst = make_state(bi);
00045 if(bst.type==which) {
00046 N_total++;
00047 content[bst.primary.type].stypes[bst.secondary.type]++;
00048 }
00049 }
00050
00051 int N_row = 0;
00052 if(N_total>0) {
00053
00054 cerr << " ";
00055 for (int j=0; j<no_of_stellar_type-1; j++)
00056 cerr << " " << type_short_string((stellar_type)j);
00057 cerr << endl;
00058
00059 for (int k = 0; k < no_of_stellar_type-1; k++) {
00060 N_row = 0;
00061 for (int i = 0; i < no_of_stellar_type-1; i++)
00062 N_row += content[i].stypes[k];
00063
00064 if(N_row>0) {
00065 cerr << " " << type_short_string((stellar_type)k);
00066
00067 for (int i = 0; i < no_of_stellar_type-1; i++)
00068 cerr << " " << content[i].stypes[k];
00069 cerr << endl;
00070 }
00071 }
00072 }
00073 else
00074 cerr << " ---No "<< type_string(which) << " binaries---" <<endl;
00075
00076 delete []content;
00077 }
00078
00079 void dstar_stats(dyn* b, bool mass_spectrum, vector center,
00080 bool verbose) {
00081
00082 sstar_stats(b, mass_spectrum, center, verbose);
00083
00084 if (verbose)
00085 cerr << "\n Detached binary content: (Primary)\n";
00086 print_binary_content(b, Detached);
00087
00088 if (verbose)
00089 cerr << "\n Synchronized binary content: (Primary)\n";
00090 print_binary_content(b, Synchronized);
00091
00092 if (verbose)
00093 cerr << "\n Semi-detached binary content: (Primary)\n";
00094 print_binary_content(b, Semi_Detached);
00095
00096 if (verbose)
00097 cerr << "\n Contact binary content: (Primary)\n";
00098 print_binary_content(b, Contact);
00099
00100 }
00101
00102 #else
00103
00104 main(int argc, char **argv)
00105 {
00106 bool binaries = true, verbose = true, out = false,
00107 n_sq = true, calc_e = true;
00108 int which_lagr = 0;
00109
00110 extern char *poptarg;
00111 int c;
00112 char* param_string = "bneost";
00113
00114
00115 while ((c = pgetopt(argc, argv, param_string)) != -1)
00116 switch(c) {
00117
00118 case 'b': binaries = !binaries;
00119 break;
00120 case 'e': calc_e = !calc_e;
00121 break;
00122 case 'n': n_sq = !n_sq;
00123 break;
00124 case 'o': out = !out;
00125 break;
00126 case 's': which_lagr = 2;
00127 break;
00128 case 't': which_lagr = 1;
00129 break;
00130 case 'v': verbose = !verbose;
00131 break;
00132 case '?': params_to_usage(cerr, argv[0], param_string);
00133 exit(1);
00134 }
00135
00136
00137
00138 hdyn *b;
00139 int i = 0;
00140 vector zero = 0;
00141 bool mass_spectrum = true;
00142 while (b = get_hdyn(cin)) {
00143
00144 if(find_qmatch(b->get_oldest_daughter()
00145 ->get_starbase()->get_star_story(), "Type")) {
00146 addstar(b,
00147 b->get_system_time(),
00148 Main_Sequence,
00149 true);
00150
00151 b->set_use_sstar(true);
00152
00153 adddouble(b, b->get_system_time());
00154
00155 b->set_use_dstar(true);
00156 }
00157
00158 if (i++ > 0) cerr << endl;
00159 dstar_stats(b, mass_spectrum, zero, verbose);
00160
00161 if (out) put_hdyn(cout, *b);
00162 rmtree(b);
00163 }
00164 }
00165
00166 #endif