00001 #include "starbase.h"
00002 #include "node.h"
00003 
00004 real starbase::m_conv_star_to_dyn = -1; 
00005 real starbase::r_conv_star_to_dyn = -1; 
00006 real starbase::t_conv_star_to_dyn = -1; 
00007 
00008 bool starbase::use_hdyn = true;
00009  
00010 #define Rsun_pc 2.255e-8                // R_sun/1 parsec = 6.960e+10/3.086e+18;
00011 
00012 #ifndef TOOLBOX
00013 
00014 void starbase::set_stellar_evolution_scaling(real m_max, real r_hm, real t_hc)
00015 {
00016     
00017 
00018     m_conv_star_to_dyn = 1./m_max;      
00019     r_conv_star_to_dyn = Rsun_pc/r_hm;  
00020     t_conv_star_to_dyn = 1./t_hc;       
00021 }
00022 
00023 void starbase::print_stellar_evolution_scaling(ostream & s)
00024 {
00025     
00026     
00027 
00028     cerr << "    [m]: " << 1. / m_conv_star_to_dyn  << " M_sun\n";
00029     cerr << "    [R]: " << Rsun_pc / r_conv_star_to_dyn << " pc\n";
00030     cerr << "    [T]: " << 1. / t_conv_star_to_dyn << " Myr\n";
00031 }
00032 
00033 bool starbase::get_stellar_evolution_scaling()
00034 {
00035     
00036     
00037     
00038     
00039 
00040     
00041 
00042     if (m_conv_star_to_dyn > 0
00043         && r_conv_star_to_dyn > 0
00044         && t_conv_star_to_dyn > 0) return true;
00045 
00046     if (star_story == NULL) return false;
00047 
00048     if (!find_qmatch(star_story, "mass_scale")) return false;
00049     if (!find_qmatch(star_story, "size_scale")) return false;
00050     if (!find_qmatch(star_story, "time_scale")) return false;
00051 
00052     real m = getrq(star_story, "mass_scale");
00053     real l = getrq(star_story, "size_scale");
00054     real t = getrq(star_story, "time_scale");
00055 
00056     
00057 
00058     if (m == -VERY_LARGE_NUMBER) return false;
00059     if (l == -VERY_LARGE_NUMBER) return false;
00060     if (t == -VERY_LARGE_NUMBER) return false;
00061 
00062     m_conv_star_to_dyn = m;             
00063     r_conv_star_to_dyn = l;             
00064     t_conv_star_to_dyn = t;             
00065 
00066     return true;
00067 }
00068 
00069 starbase::starbase(node* n)
00070 {
00071     if (n) {
00072         the_node = n;
00073         if (the_node->get_star_story()) {
00074             star_story = the_node->get_star_story();
00075             
00076         } else {
00077             star_story = mk_story_chapter();
00078             
00079         }
00080 
00081         
00082         
00083 
00084 
00085 
00086         if (the_node->get_starbase())
00087            delete the_node->get_starbase();
00088         else 
00089             cerr << "No the_node->get_starbase() in starbase::starbase(node*)" << endl;
00090 
00091         the_node->set_starbase(this);
00092     }
00093     else {
00094         the_node = NULL;
00095         star_story = mk_story_chapter();
00096     }
00097 
00098     
00099 }
00100 
00101 starbase::starbase(starbase& sb)
00102 {
00103     the_node   = sb.the_node;
00104     star_story = sb.star_story;
00105 
00106     
00107 
00108     sb.star_story = NULL;
00109     the_node->set_starbase(this);
00110 
00111     
00112     
00113 
00114 }
00115 
00116 
00117 #else
00118 
00119 void main()
00120 {
00121     cerr << "Seems to work..." << endl;
00122 }
00123   
00124 #endif
00125