00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "node.h"
00012
00013
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
00028
00029
00030
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
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);
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
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 }