00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #include "dyn.h"
00040 #include <star/sstar_to_dyn.h>
00041 #include <star/dstar_to_dyn.h>
00042
00043 main(int argc, char **argv)
00044 {
00045
00046
00047 int n = 1;
00048 real m = 1.0;
00049 real t = 0.0, dt = 10.0, t_end = 1000.0;
00050
00051 bool create_system = false;
00052
00053 extern char *poptarg;
00054 int c;
00055 char* param_string = "cd:m:M:n:ct:";
00056
00057 while ((c = pgetopt(argc, argv, param_string)) != -1) {
00058 switch (c) {
00059 case 'c': create_system = true;
00060 break;
00061 case 'd': dt = atof(poptarg);
00062 break;
00063
00064 case 'm':
00065 case 'M': m = atof(poptarg);
00066 break;
00067 case 'n': n = atoi(poptarg);
00068 break;
00069
00070 case 't': t_end = atof(poptarg);
00071 break;
00072 default:
00073 case '?': params_to_usage(cerr, argv[0], param_string);
00074 get_help();
00075 exit(1);
00076 }
00077 }
00078
00079 dyn *b;
00080
00081 if (create_system) {
00082
00083 if (n < 1 || m <= 0.0) err_exit("Need N and M > 0");
00084 b = (dyn*) mknode_mass(n, m);
00085
00086 } else {
00087
00088 b = get_dyn(cin);
00089 if (b == NULL) err_exit("Can't read input snapshot");
00090
00091 n = 0;
00092 m = 0;
00093 b->flatten_node();
00094 for_all_daughters(dyn, b, bb) {
00095 n++;
00096 m += bb->get_mass();
00097 }
00098
00099 }
00100
00101
00102
00103
00104
00105
00106
00107 b->get_starbase()->set_stellar_evolution_scaling(1.0, 1.0, 1.0);
00108
00109
00110
00111 addstar(b, 0.0, Main_Sequence);
00112
00113
00114
00115 while (t < t_end - 0.0001*dt) {
00116
00117 int old_id_sum = 0;
00118 {for_all_daughters(dyn, b, bb) {
00119 star* s = (star*) bb->get_starbase();
00120 old_id_sum += s->get_element_type();
00121 }}
00122
00123
00124
00125
00126
00127
00128 b->set_system_time(t += dt);
00129 stellar_evolution(b);
00130
00131 int new_id_sum = 0;
00132 {for_all_daughters(dyn, b, bb) {
00133
00134 star* s = (star*) bb->get_starbase();
00135 new_id_sum += s->get_element_type();
00136
00137
00138
00139 bb->set_mass(s->get_total_mass());
00140
00141 }}
00142
00143
00144
00145
00146 if (new_id_sum != old_id_sum) cerr << endl;
00147
00148
00149
00150 int count = 0;
00151 {for_all_daughters(dyn, b, bb) {
00152
00153 if (count++ == 0)
00154 fprintf(stderr, "time = %9.2f ", t);
00155 else
00156 fprintf(stderr, " ");
00157
00158 star* s = (star*) bb->get_starbase();
00159 single_star* ss = (single_star*) s;
00160
00161 ss->dump(cerr, false);
00162
00163 cerr << bb->format_label() << " "
00164 << type_string(s->get_element_type())
00165 << " M = " << s->get_total_mass()
00166 << " Mcore = " << s->get_core_mass()
00167 << " L = " << ss->get_luminosity()
00168 << " V = " << ss->magnitude()
00169 << " T = " << ss->temperature()
00170 << " R = " << ss->get_radius()
00171 << endl;
00172 }}
00173
00174 }
00175 }