00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00017
00018 #include "dyn.h"
00019 #include "util_io.h"
00020
00021 #ifndef TOOLBOX
00022
00023
00024
00025 xreal dyn::system_time = 0.0;
00026 real dyn::real_system_time = 0.0;
00027 bool dyn::use_sstar = false;
00028
00029 bool dyn::ignore_internal = false;
00030
00031 unsigned int dyn::external_field = 0;
00032
00033 int dyn::tidal_type = 0;
00034 real dyn::omega = 0;
00035 real dyn::omega_sq = 0;
00036 real dyn::alpha1 = 0;
00037 real dyn::alpha3 = 0;
00038 vector dyn::tidal_center = vector(0,0,0);
00039
00040 real dyn::p_mass = 0;
00041 real dyn::p_scale_sq = 0;
00042 vector dyn::p_center = vector(0,0,0);
00043
00044 real dyn::pl_coeff = 0;
00045 real dyn::pl_scale_sq = 0;
00046 real dyn::pl_exponent = 0;
00047 vector dyn::pl_center = vector(0,0,0);
00048 real dyn::pl_cutoff = 0;
00049 real dyn::pl_cutoff_sq = 0;
00050 real dyn::pl_mass = 0;
00051 real dyn::pl_softening_sq = 0;
00052
00053 void dyn::print_static(ostream& s)
00054 {
00055 node::print_static(s);
00056
00057 s << "system_time = " << system_time << endl;
00058 s << "real_system_time = " << real_system_time << endl;
00059
00060 s << "use_sstar = " << use_sstar << endl;
00061 s << "ignore_internal = " << ignore_internal << endl;
00062
00063 s << "external_field = " << external_field << endl;
00064 s << "tidal_type = " << tidal_type << endl;
00065
00066 s << "omega = " << omega << endl;
00067 s << "omega_sq = " << omega_sq << endl;
00068 s << "alpha1 = " << alpha1 << endl;
00069 s << "alpha3 = " << alpha3 << endl;
00070 s << "tidal_center = " << tidal_center << endl;
00071
00072 s << "p_mass = " << p_mass << endl;
00073 s << "p_scale_sq = " << p_scale_sq << endl;
00074 s << "p_center = " << p_center << endl;
00075
00076 s << "pl_coeff = " << pl_coeff << endl;
00077 s << "pl_scale_sq = " << pl_scale_sq << endl;
00078 s << "pl_exponent = " << pl_exponent << endl;
00079 s << "pl_center = " << pl_center << endl;
00080
00081 s << "pl_cutoff = " << pl_cutoff << endl;
00082 s << "pl_cutoff_sq = " << pl_cutoff_sq << endl;
00083 s << "pl_mass = " << pl_mass << endl;
00084 s << "pl_softening_sq = " << pl_softening_sq << endl;
00085 }
00086
00087 static bool read_xreal = false;
00088
00089 istream & dyn::scan_dyn_story(istream& s)
00090 {
00091 char input_line[MAX_INPUT_LINE_LENGTH];
00092 real last_real = false;
00093
00094 while (get_line(s,input_line), !matchbracket(END_DYNAMICS, input_line)) {
00095
00096 char keyword[MAX_INPUT_LINE_LENGTH];
00097 const char *val = getequals(input_line, keyword);
00098
00099 if (!strcmp("real_system_time", keyword)) {
00100
00101 read_xreal = true;
00102 last_real = true;
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115 } else if (!strcmp("system_time", keyword)) {
00116
00117
00118
00119 if (!last_real) read_xreal = false;
00120
00121 if (read_xreal) {
00122
00123
00124
00125
00126
00127
00128
00129 set_system_time(get_xreal_from_input_line(input_line));
00130
00131 } else {
00132
00133
00134
00135
00136
00137 real_system_time = system_time = strtod(val, NULL);
00138 }
00139 } else {
00140
00141 last_real = false;
00142
00143 if (!strcmp("m", keyword))
00144 mass = strtod(val, NULL);
00145 else if (!strcmp("r", keyword))
00146 set_vector_from_input_line(pos, input_line);
00147 else if (!strcmp("v", keyword))
00148 set_vector_from_input_line(vel, input_line);
00149 else
00150 add_story_line(dyn_story, input_line);
00151 }
00152 }
00153
00154 return s;
00155 }
00156
00157 ostream& dyn::print_dyn_story(ostream& s,
00158 bool print_xreal,
00159 int short_output)
00160 {
00161
00162
00163
00164
00165 if (!parent) {
00166
00167 #ifdef USE_XREAL
00168 if (print_xreal) {
00169
00170
00171
00172
00173
00174
00175 put_real_number(s, " real_system_time = ", (real)system_time);
00176 put_real_number(s, " system_time = ", system_time);
00177
00178 } else
00179
00180 put_real_number(s, " system_time = ", (real)system_time);
00181 #else
00182
00183 put_real_number(s, " system_time = ", system_time);
00184
00185 #endif
00186 }
00187
00188
00189
00190 node::print_dyn_story(s, print_xreal, short_output);
00191
00192 put_real_vector(s, " r = ", pos);
00193 put_real_vector(s, " v = ", vel);
00194
00195 return s;
00196 }
00197
00198 #else
00199 main(int argc, char** argv)
00200 {
00201 dyn * b;
00202 check_help();
00203
00204 while (b = (dyn *) get_node(cin, new_dyn)) {
00205 cout << "TESTING put_dyn:" << endl;
00206 put_node(cout,*b);
00207 cout << "TESTING pp2() :" << endl;
00208 pp2(b);
00209 delete b;
00210 }
00211 cerr << "Normal exit\n";
00212 }
00213 #endif