Main Page   Class Hierarchy   Data Structures   File List   Data Fields   Globals  

mass.C

Go to the documentation of this file.
00001 
00002        //=======================================================//    _\|/_
00003       //  __  _____           ___                    ___       //      /|\
00004      //  /      |      ^     |   \  |         ^     |   \     //          _\|/_
00005     //   \__    |     / \    |___/  |        / \    |___/    //            /|\
00006    //       \   |    /___\   |  \   |       /___\   |   \   // _\|/_
00007   //     ___/   |   /     \  |   \  |____  /     \  |___/  //   /|\     
00008  //                                                       //            _\|/_
00009 //=======================================================//              /|\
00010 
00011 #include "node.h"
00012 
00013 //see: Eggleton, Fitchet & Tout 1989, ApJ 347, 998
00014 
00015 local real mf_Miller_Scalo(real m_lower, real m_upper)
00016 {
00017     real m, rnd;
00018     do {
00019         rnd = randinter(0,1);
00020         m = 0.19*rnd
00021             / (pow(1-rnd, 0.75) + 0.032*pow(1-rnd, 0.25));
00022     }
00023     while(m_lower>m || m>m_upper); 
00024     return m;
00025 }
00026 
00027 // see: de la Fuente Marcos, Aarseth, Kiseleva, Eggleton 
00028 // 1997, in Docobo, Elipe, McAlister (eds.), Visual Double
00029 // Stars: Formation, dynamics and Evolutionary Tracks, KAP: ASSL
00030 // Series vol. 223,  165
00031 
00032 local real mf_Scalo(real m_lower, real m_upper) {
00033     real m, rnd;
00034     do {
00035         rnd = randinter(0,1);
00036         m = 0.3*rnd
00037             / pow(1-rnd, 0.55);
00038     }
00039     while(m_lower>m || m>m_upper); 
00040     return m;
00041 }
00042 
00043 real get_random_stellar_mass(real m_lower, real m_upper) 
00044 {
00045     //return mf_Miller_Scalo(m_lower, m_upper);
00046     return mf_Scalo(m_lower, m_upper);
00047 }
00048 
00049 void main(int argc, char ** argv)
00050 {
00051     int n = 1000;
00052     int count = 0, countNS = 0, countBH = 0;
00053     int visible = 0, OBvisible = 0;
00054     real mlimit = 20;
00055 
00056     if (argc > 1) n = atoi(argv[1]);
00057     if (argc > 2) mlimit = atof(argv[2]);
00058     srandinter(0);
00059 
00060     for (int i = 0; i < n; i++) {
00061 
00062         real m = get_random_stellar_mass(0.1, 100);
00063 
00064         real t = randinter(0, 12);      // Gyr in past
00065         real lifetime = 12;
00066         if (m > 1) {
00067             lifetime *= pow(m, -2.5);
00068             if (lifetime < 0.01) lifetime = 0.01;
00069         }
00070         
00071         count++;
00072         if (m > mlimit)
00073             countBH++;
00074         else if (m > 8)
00075             countNS++;
00076 
00077         if (lifetime >= t) {
00078             visible++;
00079             if (m > 5) OBvisible++;
00080         }
00081 
00082 //      cerr << m << endl;
00083 
00084     }
00085     cerr << "BH prog. frac = " << countBH / ((real) count)
00086          << "  NS prog. frac = " << countNS / ((real) count) << endl;
00087     PRC(n), PRC(visible), PRL(OBvisible);
00088 }

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