Main Page   Class Hierarchy   Data Structures   File List   Data Fields   Globals  

conv_dyn_to_star.C

Go to the documentation of this file.
00001  
00011 //  SPZ @MIT, August 2001
00012 
00013 #include "dyn.h"
00014 #include "constants.h"
00015 
00016 #ifdef TOOLBOX
00017 
00018 //#else
00019 
00020 #define  FALSE  0
00021 #define  TRUE   1
00022 
00023 main(int argc, char ** argv) {
00024 
00025     int option  = 1;  // conv to cgs
00026 
00027     dyn *root;
00028 
00029     check_help();
00030 
00031     extern char *poptarg;
00032     int c;
00033     char* param_string = "";
00034 
00035     while ((c = pgetopt(argc, argv, param_string)) != -1)
00036         switch(c) {
00037             case '?': params_to_usage(cerr, argv[0], param_string);
00038                       get_help();
00039                       exit(1);
00040         }
00041 
00042     root = get_dyn(cin);
00043     root->log_history(argc, argv);
00044 
00045     real P, K, E;
00046     get_top_level_energies(root, 0.0, P, K);
00047     real r_virial = -0.5*root->get_mass()*root->get_mass()
00048                   / P;
00049     PRL(r_virial);
00050 
00051     real mf = root->get_starbase()->conv_m_star_to_dyn(1);
00052     real rf = root->get_starbase()->conv_r_star_to_dyn(1);
00053     real tf = root->get_starbase()->conv_t_star_to_dyn(1);
00054     PRC(mf);PRC(rf);PRL(tf);
00055     real mtot = 1/mf;
00056     real rvir = cnsts.parameters(Rsun) / (rf * cnsts.parameters(PC));
00057     real tvir = 1/tf;
00058     real vel = rvir/tvir; // [pc/Myr]
00059     real km_sec = cnsts.physics(km_per_s) * cnsts.physics(Myear) 
00060                    / cnsts.parameters(PC);
00061     vel /= km_sec;
00062     PRL(km_sec);
00063     PRC(mtot);PRC(rvir);PRC(tvir);PRL(vel);
00064     real Um = 1/mtot;
00065     real Ul = r_virial/rvir;  // virial radius may be non-unity
00066     real Ut = 1/tvir;
00067     real Uv = 1/vel;
00068 
00069     // Now transform the snapshot
00070     for_all_leaves(dyn, root, bi) {
00071       bi->set_mass(bi->get_mass() / Um);
00072       bi->set_pos(bi->get_pos() / Ul);
00073       bi->set_vel(bi->get_vel() / Uv);
00074     }
00075     root->set_mass(mtot);
00076 
00077     cerr << "Reset the standard starbase units" << endl;
00078     root->get_starbase()->set_stellar_evolution_scaling(-1, -1, -1);
00079     root->get_starbase()->print_stellar_evolution_scaling(cerr);
00080 
00081     put_node(cout, *root);
00082 }
00083 
00084 #endif
00085 
00086 // end of: conv_dyn_to_star.C
00087  
00088 
00089 

Generated at Sun Feb 24 09:56:56 2002 for STARLAB by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001