|
1 | 1 | function [Zlist, MergerRateByRedshiftByZ, SFRfractionZ]=... |
2 | | - CosmicHistoryIntegrator(filename,zlist,metallicitychoice, makeplots) |
| 2 | + CosmicHistoryIntegrator(filename, zlistformation, zlistmerger, makeplots) |
3 | 3 | % Integrator for the binary black hole merger rate over cosmic history |
4 | 4 | % COMPAS (Compact Object Mergers: Population Astrophysics and Statistics) |
5 | 5 | % software package |
6 | 6 | % |
7 | 7 | % USAGE: |
8 | 8 | % [Zlist, MergerRateByRedshiftByZ]=... |
9 | | -% CosmicHistoryIntegrator(filename, zlistformation, zlistmerger, zlistdetection, Msimulated, [,makeplots]) |
| 9 | +% CosmicHistoryIntegrator(filename, zlistformation, zlistmerger, [,makeplots]) |
10 | 10 | % |
11 | 11 | % INPUTS: |
12 | 12 | % filename: name of population synthesis input file |
13 | 13 | % should be in COMPAS output h5 format |
14 | 14 | % zlistformation: vector of redshifts at which the formation rate is |
15 | 15 | % computed |
16 | 16 | % zlistmerger: vector of redshifts at which the merger rate is computed |
17 | | -% zlistdetection: vector of redshifts at which the detection rate is |
18 | | -% computed |
19 | 17 | % Msimulated: total star forming mass represented by the simulation (for |
20 | 18 | % normalisation) |
21 | 19 | % makeplots: if set to 1, generates a set of useful plots (default = 0) |
|
56 | 54 | Mpc=Mpcm/c; %Gpc in seconds |
57 | 55 | yr=3.15569e7; %year in seconds |
58 | 56 |
|
59 | | -if (nargin<2) |
| 57 | +if (nargin<3) |
60 | 58 | error('Not enough input arguments.'); |
61 | 59 | end; |
62 | 60 | if (nargin<4), makeplots=0; end; |
|
95 | 93 | end %end of CosmicHistoryIntegrator |
96 | 94 |
|
97 | 95 |
|
98 | | -%Load the data stored in COMPAS output format from a file |
| 96 | +%Load the data stored in COMPAS .h5 output format from a file |
99 | 97 | %Select only binary black hole mergers of interest, and return the |
100 | 98 | %component masses, metallicities, and star formation to merger delay times |
101 | | -function [M1,M2,Z,Tdelay]=DataRead(filename, tHubble) |
102 | | - global BH |
103 | | - if(exist(filename, 'file')~=2), |
| 99 | +function [M1,M2,Z,Tdelay]=DataRead(file, tHubble) |
| 100 | + if(exist(file, 'file')~=2), |
104 | 101 | error('Input file does not exist'); |
105 | | - end; |
106 | | - data = importdata(filename, '\t', 2); |
107 | | - |
108 | | - colnames=data.textdata(2,:); |
| 102 | + end; |
| 103 | + type1=h5read(file,'/BSE_Double_Compact_Objects/Stellar_Type(1)'); |
| 104 | + type2=h5read(file,'/BSE_Double_Compact_Objects/Stellar_Type(2)'); |
| 105 | + mass1=h5read(file,'/BSE_Double_Compact_Objects/Mass(1)'); |
| 106 | + mass2=h5read(file,'/BSE_Double_Compact_Objects/Mass(2)'); |
| 107 | + seedDCO=h5read(file,'/BSE_Double_Compact_Objects/SEED'); |
| 108 | + merges=h5read(file,'/BSE_Double_Compact_Objects/Merges_Hubble_Time'); |
| 109 | + a=h5read(file,'/BSE_Double_Compact_Objects/SemiMajorAxis@DCO'); |
| 110 | + e=h5read(file,'/BSE_Double_Compact_Objects/Eccentricity@DCO'); |
| 111 | + mergingBBH=(type1==14) & (type2==14) & merges; |
| 112 | + BBH=(type1==14) & (type2==14); |
| 113 | + mergingBNS=(type1==13) & (type2==13) & merges; |
| 114 | + BNS=(type1==13) & (type2==13); |
| 115 | + mergingNSBH=(((type1==13) & (type2==14)) | ((type1==14) & (type2==13))) & merges; |
| 116 | + NSBH=(((type1==13) & (type2==14)) | ((type1==14) & (type2==13))); |
| 117 | + mergingDCO=mergingBNS | mergingNSBH | mergingBBH; |
| 118 | + BNScount=sum(mergingBNS); NSBHcount=sum(mergingNSBH); BBHcount=sum(mergingBBH); |
| 119 | + chirpmass=mass1.^0.6.*mass2.^0.6./(mass1+mass2).^0.2; |
| 120 | + q=mass2./mass1; |
| 121 | + seedCE=h5read(file,'/BSE_Common_Envelopes/SEED'); |
| 122 | + [isCE,CEIndex]=ismember(seedDCO,seedCE); |
| 123 | + optCE=h5read(file,'/BSE_Common_Envelopes/Optimistic_CE'); |
| 124 | + RLOFCE=h5read(file,'/BSE_Common_Envelopes/Immediate_RLOF>CE'); |
| 125 | + OKCE=zeros(size(mergingDCO)); OKCE(CEIndex==0)=1; OKCE(CEIndex>0)=(~optCE(CEIndex(CEIndex>0))) & (~RLOFCE(CEIndex(CEIndex>0))); |
| 126 | + BNSCE=sum(mergingBNS & isCE & OKCE); NSBHCE=sum(mergingNSBH & isCE & OKCE); BBHCE=sum(mergingBBH & isCE & OKCE); |
| 127 | + |
109 | 128 | Z1index=find(strcmp(colnames,'Metallicity1')); |
110 | 129 | M1index=find(strcmp(colnames,'M1')); |
111 | 130 | M2index=find(strcmp(colnames,'M2')); |
|
133 | 152 |
|
134 | 153 | %Compute the star formation rate and lookback time (in years) |
135 | 154 | %for an array of redshifts |
136 | | -function [zvec,tL]=Cosmology() |
| 155 | +function [tL]=Cosmology(zvec) |
137 | 156 | global Mpcm |
138 | 157 | global Mpc |
139 | 158 | global yr |
140 | | - zmax=10; dz=0.001; zvec=0:dz:zmax; |
| 159 | + %zmax=10; dz=0.001; zvec=0:dz:zmax; |
141 | 160 | Nz=length(zvec); |
142 | 161 |
|
143 | 162 | %Planck cosmology |
|
0 commit comments