Main Page   Class Hierarchy   Data Structures   File List   Data Fields   Globals  

starbase_init.C

Go to the documentation of this file.
00001 #include "starbase.h"
00002 #include "node.h"
00003 
00004 real starbase::m_conv_star_to_dyn = -1; // mass conversion factor
00005 real starbase::r_conv_star_to_dyn = -1; // length conversion factor
00006 real starbase::t_conv_star_to_dyn = -1; // time conversion factor
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     // Set scaling factors from input physical parameters.
00017 
00018     m_conv_star_to_dyn = 1./m_max;      // m_max = total mass in Msun
00019     r_conv_star_to_dyn = Rsun_pc/r_hm;  // r_hm = virial radius in pc
00020     t_conv_star_to_dyn = 1./t_hc;       // t_hc = crossing time in Myr
00021 }
00022 
00023 void starbase::print_stellar_evolution_scaling(ostream & s)
00024 {
00025     // Print current scaling factors.  Note that the mass unit is
00026     // artificial, as it is the initial value of N<m>...
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     // Attempt to read and set scaling factors.
00036     // If they appeared in the input stream, the factors should
00037     // have been set by scan_star_story.  Nevertheless, if they
00038     // not set, check the star story, just in case.
00039 
00040     // Return true iff successful.
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     // Accept scale factors only if all are acceptable.
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;             // 1/total mass in Msun
00063     r_conv_star_to_dyn = l;             // 1/virial radius in Rsun
00064     t_conv_star_to_dyn = t;             // 1/crossing time in Myr
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             // cerr << "using existing star story" << endl;
00076         } else {
00077             star_story = mk_story_chapter();
00078             // cerr << "creating new star story" << endl;
00079         }
00080 
00081         // cerr << "starbase:  node = " << n << " story = "
00082         //      << star_story << endl;
00083 
00084 //      cerr << "About to delete the_node->get_starbase() --1"<<flush <<endl;
00085 //      cerr << the_node->get_starbase() << flush << endl;
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     // use_hdyn = false;
00099 }
00100 
00101 starbase::starbase(starbase& sb)
00102 {
00103     the_node   = sb.the_node;
00104     star_story = sb.star_story;
00105 
00106     // use_hdyn   = sb.use_hdyn;
00107 
00108     sb.star_story = NULL;
00109     the_node->set_starbase(this);
00110 
00111     // Note that sb is likely to be left inaccessible if not
00112     // immediately deleted on return...
00113 
00114 }
00115 
00116 
00117 #else
00118 
00119 void main()
00120 {
00121     cerr << "Seems to work..." << endl;
00122 }
00123   
00124 #endif
00125 

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