00001 00002 // Counters for kira: 00003 00004 typedef unsigned long step_t; 00005 00006 #define SLOW_BINS 20 00007 00008 class kira_counters { 00009 00010 public: 00011 00012 real cpu_time; // CPU time since this process started 00013 real total_cpu_time; // total CPU time for the calculation 00014 00015 // These should eventually be #ifdefed to avoid 00016 // taking too much CPU time. 00017 00018 real cpu_time_predict; // updated in kira_ev.C 00019 real cpu_time_top_level_force; // updated in kira_ev.C 00020 real cpu_time_low_level_force; // updated in kira_ev.C 00021 real cpu_time_external_force; // updated in kira_ev.C 00022 real cpu_time_total_force; // updated in kira.C 00023 real cpu_time_correct; // updated in kira.C 00024 real cpu_time_unperturbed; // updated in kira.C 00025 real cpu_time_final_step; // updated in kira.C 00026 real cpu_time_tree_check; // updated in kira.C 00027 real cpu_time_integrate; // updated in kira.C 00028 real cpu_time_other; // updated in kira.C 00029 00030 step_t step_top_single; // top-level single steps 00031 step_t step_top_cm; // top-level CM steps 00032 step_t step_low_level; // low-level steps 00033 step_t force_correction; // force corrections 00034 00035 step_t pert_step; // low-level perturbed steps 00036 step_t pert_with_list; // low-level *interparticle force* 00037 // calculations using perturber list 00038 step_t pert_without_list; // low-level *force* calculations 00039 // without perturber list 00040 step_t perturber_overflow; // perturber list overflows 00041 00042 step_t full_unpert_step; // full unperturbed steps 00043 step_t full_unpert_orbit; // full unperturbed orbits 00044 step_t partial_unpert_orbit; // partial unperturbed orbits 00045 00046 step_t tree_change; // changes in tree structure 00047 00048 step_t top_level_combine; // top-level combines within tree 00049 step_t low_level_combine; // low-level combines within tree 00050 step_t top_level_split; // top-level splits within tree 00051 00052 step_t leaf_merge; // physical mergers between stars 00053 step_t total_kick; // number of kicks 00054 step_t step_stellar; // number of stellar evolution steps 00055 step_t step_dmslow; // number of slow mass loss events 00056 step_t step_dmfast; // number of fast mass loss events 00057 step_t step_correct; // number stellar evolution corrections 00058 00059 step_t step_slow[SLOW_BINS]; // slow binary steps [slowdown factor] 00060 00061 real dm_escapers; // total mass loss in escapers (>0) 00062 real dm_massloss; // total mass loss by stellar evolution 00063 00064 real initial_etot; // total energy at t = 0 00065 real de_total; // total energy change (subdivided:) 00066 00067 real de_merge; // energy change by mergers 00068 real de_tidal_diss; // energy change by tidal dissipation 00069 real de_massloss; // energy change by stellar mass loss 00070 real de_kick; // energy change by supernova kicks 00071 00072 kira_counters () { 00073 00074 cpu_time = 00075 total_cpu_time = 00076 cpu_time_predict = 00077 cpu_time_top_level_force = 00078 cpu_time_low_level_force = 00079 cpu_time_external_force = 00080 cpu_time_total_force = 00081 cpu_time_correct = 00082 cpu_time_unperturbed = 00083 cpu_time_final_step = 00084 cpu_time_tree_check = 00085 cpu_time_integrate = 00086 cpu_time_other = 0; 00087 00088 step_top_single = 00089 step_top_cm = 00090 step_low_level = 00091 force_correction = 00092 pert_step = 00093 pert_with_list = 00094 pert_without_list = 00095 perturber_overflow = 00096 full_unpert_step = 00097 full_unpert_orbit = 00098 partial_unpert_orbit = 00099 tree_change = 00100 top_level_combine = 00101 low_level_combine = 00102 top_level_split = 00103 leaf_merge = 00104 step_stellar = 00105 step_dmslow = 00106 step_dmfast = 00107 step_correct = 00108 total_kick = 0; 00109 00110 for (int i = 0; i < SLOW_BINS; i++) step_slow[i] = 0; 00111 00112 dm_escapers = 00113 dm_massloss = 00114 de_kick = 00115 de_massloss = 00116 de_merge = 00117 de_tidal_diss = 00118 de_total = 00119 initial_etot = 0; 00120 } 00121 00122 void inc_slow(int kappa) { 00123 if (kappa > 1) { 00124 int k = 0, k2 = 2; 00125 while (k2 < kappa && k < SLOW_BINS-1) {k++; k2 *= 2;} 00126 step_slow[k]++; 00127 } 00128 } 00129 }; 00130 00131 // Runtime options and switches: 00132 00133 class kira_options { 00134 00135 public: 00136 00137 // Used in several references to put_node: 00138 00139 bool print_xreal; 00140 00141 // Used in hdyn_inline.C: 00142 00143 int perturber_criterion; 00144 00145 // Used in hdyn_unpert.C (see source for description): 00146 00147 bool optimize_scheduling; 00148 bool optimize_block; 00149 bool allow_unperturbed; 00150 bool allow_multiples; 00151 00152 int min_unpert_steps; 00153 real full_merge_tolerance; 00154 real relax_factor; 00155 real partial_merge_factor; 00156 real full_merge_tol_for_close_binary; 00157 real multiple_merge_tolerance; 00158 real unconditional_stable_fac; 00159 bool use_aarseth_criterion; 00160 real aarseth_stable_fac; 00161 real partial_stable_fac; 00162 00163 // Used in hdyn_tree.C: 00164 00165 int close_criterion; 00166 00167 // Used in hdyn_ev.C: 00168 00169 bool allow_keplstep; 00170 00171 // Used in kira_ev.C: 00172 00173 bool use_old_correct_acc_and_jerk; 00174 00175 // Used in hdyn_grape4/6.C: 00176 00177 int grape_check_count; 00178 real grape_max_cpu; 00179 real grape_last_cpu; // (not really an option, but 00180 // convenient to keep it here) 00181 00182 int grape_coll_freq; 00183 int grape_pert_freq; 00184 00185 // Used in perturbed_list.C: 00186 00187 bool use_perturbed_list; 00188 00189 // In kira_options.C: 00190 00191 kira_options(); 00192 void print(ostream & s = cerr); 00193 }; 00194 00195 // Diagnostic/debugging flags (may be changed during a run): 00196 // Warning: these can produce a *lot* of output! 00197 // 00198 // Currently, only the following diag elements allow the possibility 00199 // of diag->check_diag(): 00200 // 00201 // ev_function_id 00202 // ev 00203 // timestep_check 00204 00205 class kira_diag { 00206 00207 private: 00208 00209 char *name; 00210 real t1, t2; 00211 00212 public: 00213 00214 // Generic debugging (general -- for short-term use only): 00215 00216 int kira_runtime_flag; 00217 00218 // Used in kira.C: 00219 00220 bool kira_main; 00221 bool check_heartbeat; 00222 int n_check_heartbeat; 00223 int n_check_runtime; 00224 00225 // Used in hdyn_unpert.C: 00226 00227 bool unpert_function_id; 00228 bool report_start_unperturbed; 00229 bool report_continue_unperturbed; 00230 bool report_end_unperturbed; 00231 bool report_pericenter_reflection; 00232 bool report_impending_multiple_status; 00233 bool report_zero_unpert_steps; 00234 bool report_multiple; 00235 int unpert_report_level; 00236 int end_unpert_report_level; 00237 int multiple_report_level; 00238 00239 // Used in hdyn_tree.C and hdyn_merge.C: 00240 00241 bool tree; 00242 int tree_level; 00243 00244 // Used in hdyn_ev.C: 00245 00246 bool ev_function_id; 00247 bool ev; 00248 bool grape; 00249 int grape_level; // (also in kira.C) 00250 bool timestep_check; 00251 bool correct; 00252 bool slow_perturbed; // (also in hdyn_slow.C) 00253 00254 // Used in kira_ev.C: 00255 00256 bool kira_ev; 00257 00258 // Used in hdyn_slow.C: 00259 00260 bool slow; 00261 int slow_level; 00262 00263 // Used in kira_stellar.C: 00264 00265 bool report_stellar_evolution; 00266 bool report_stellar_mass_loss; 00267 bool report_binary_mass_loss; 00268 00269 // Used in perturbed_list.C: 00270 00271 bool report_adjust_perturbed_list; 00272 00273 // Used in correct_perturbers.C: 00274 00275 bool report_correct_perturber_list; 00276 00277 // Used in kira_encounter.C: 00278 00279 int report_close_encounters; 00280 00281 // Passed to kepler.C: 00282 00283 bool report_kepler_trig_error; 00284 00285 void set_name(char *n) {name = n;} 00286 char *get_name() {return name;} 00287 void clear_name() {if (name) delete [] name; 00288 name = NULL;} 00289 00290 void set_t1(real t) {t1 = t;} 00291 void set_t2(real t) {t2 = t;} 00292 void set_range(real tt1, real tt2) {t1 = tt1, t2 = tt2;} 00293 real get_t1() {return t1;} 00294 real get_t2() {return t2;} 00295 00296 // In kira_diag.C: 00297 00298 kira_diag(); 00299 bool check_diag(hdyn *b); 00300 void print(ostream & s = cerr); 00301 };