00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "scatter3.h"
00010
00011 local real energy(sdyn3 * b)
00012 {
00013 real k = 0, u = 0;
00014
00015 for_all_daughters(sdyn3, b, bi) {
00016 k += bi->get_mass() * bi->get_vel() * bi->get_vel();
00017 for (sdyn3 * bj = bi->get_younger_sister(); bj != NULL;
00018 bj = bj->get_younger_sister())
00019 u -= bi->get_mass() * bj->get_mass()
00020 / abs(bi->get_pos() - bj->get_pos());
00021 }
00022 return 0.5*k + u;
00023 }
00024
00025 local void print_debug(sdyn3 *s)
00026
00027
00028
00029
00030
00031 {
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 cout << "ssd = " << s->get_ssd()
00056 << " n_osc = " << s->get_n_ssd_osc();
00057 cout << " T = " << s->get_time() + s->get_time_offset();
00058
00059
00060 cout << " E = " << energy(s) << endl;
00061
00062 cout.precision(p);
00063 }
00064
00065
00066
00067
00068
00069 main(int argc, char **argv)
00070 {
00071
00072 initial_state3 init;
00073 make_standard_init(init);
00074
00075 int seed = 0;
00076 int n_rand = 0;
00077 int n_experiments = 1;
00078 real dt_out =
00079 VERY_LARGE_NUMBER;
00080 real dt_snap =
00081 VERY_LARGE_NUMBER;
00082 real dt_print =
00083 VERY_LARGE_NUMBER;
00084
00085 real cpu_time_check = 3600;
00086 real snap_cube_size = 10;
00087
00088 bool b_flag = FALSE;
00089 bool q_flag = FALSE;
00090
00091 extern char *poptarg;
00092 int c;
00093 char* param_string = "A:bc:C:d:D:e:L:m:M:nN::qp:r:s:U:v:x:y:z:";
00094
00095 while ((c = pgetopt(argc, argv, param_string)) != -1)
00096 switch(c)
00097 {
00098 case 'A': init.eta = atof(poptarg);
00099 break;
00100 case 'b': b_flag = 1 - b_flag;
00101 break;
00102 case 'c': cpu_time_check = 3600*atof(poptarg);
00103 break;
00104 case 'C': snap_cube_size = atof(poptarg);
00105 break;
00106 case 'd': dt_out = atof(poptarg);
00107 break;
00108 case 'D': dt_snap = atof(poptarg);
00109 break;
00110 case 'e': init.ecc = atof(poptarg);
00111 break;
00112 case 'L': init.r_init_min = atof(poptarg);
00113 break;
00114 case 'm': init.m2 = atof(poptarg);
00115 break;
00116 case 'M': init.m3 = atof(poptarg);
00117 break;
00118 case 'N': n_rand = atoi(poptarg);
00119 break;
00120 case 'n': n_experiments = atoi(poptarg);
00121 break;
00122 case 'p': dt_print = atof(poptarg);
00123 break;
00124 case 'q': q_flag = 1 - q_flag;
00125 break;
00126 case 'r': init.rho = atof(poptarg);
00127 break;
00128 case 's': seed = atoi(poptarg);
00129 break;
00130 case 'U': init.r_init_max = atof(poptarg);
00131 break;
00132 case 'v': init.v_inf = atof(poptarg);
00133 break;
00134 case 'x': init.r1 = atof(poptarg);
00135 break;
00136 case 'y': init.r2 = atof(poptarg);
00137 break;
00138 case 'z': init.r3 = atof(poptarg);
00139 break;
00140 case '?': params_to_usage(cerr, argv[0], param_string);
00141 exit(1);
00142 }
00143
00144 if (init.m2 > 1)
00145 {
00146 cerr << "sigma3: initial.m2 = " << init.m2 << " > 1" << endl;
00147 exit(1);
00148 }
00149
00150 int random_seed = srandinter(seed, n_rand);
00151
00152 while (n_experiments--)
00153 {
00154 int initial_seed = get_initial_seed();
00155 int n_rand = get_n_rand();
00156
00157 randomize_angles(init.phase);
00158
00159 intermediate_state3 inter;
00160 final_state3 final;
00161
00162 scatter3(init, inter, final, cpu_time_check,
00163 dt_out, dt_snap, snap_cube_size,
00164 dt_print, print_debug);
00165
00166 cerr << "result: " << state_string(inter.descriptor) << " "
00167 << state_string(final.descriptor)
00168 << " Random seed = " << initial_seed
00169 << " n_rand = " << n_rand << endl;
00170
00171 if (!q_flag)
00172 {
00173 print_initial(cerr, init, b_flag);
00174 print_intermediate(cerr, inter, b_flag);
00175 print_final(cerr, final, b_flag);
00176 }
00177 }
00178 }
00179