|
1 | 1 | function [Zlist, MergerRateByRedshiftByZ, SFRfractionZ]=... |
2 | | - CosmicHistoryIntegrator(filename, zlistformation, zlistmerger, makeplots) |
| 2 | + CosmicHistoryIntegrator(filename, zlistformation, zlistdetection, Msimulated, 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 |
|
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 | | -% zlistmerger: vector of redshifts at which the merger rate is computed |
| 16 | +% zlistdetection: vector of redshifts at which the detection rate is computed |
17 | 17 | % Msimulated: total star forming mass represented by the simulation (for |
18 | 18 | % normalisation) |
19 | 19 | % makeplots: if set to 1, generates a set of useful plots (default = 0) |
|
54 | 54 | Mpc=Mpcm/c; %Gpc in seconds |
55 | 55 | yr=3.15569e7; %year in seconds |
56 | 56 |
|
57 | | -if (nargin<3) |
| 57 | +if (nargin<4) |
58 | 58 | error('Not enough input arguments.'); |
59 | 59 | end; |
60 | | -if (nargin<4), makeplots=0; end; |
| 60 | +if (nargin<5), makeplots=0; end; |
61 | 61 |
|
62 | 62 | %cosmology calculator |
63 | | -[zvec,tL]=Cosmology(); |
| 63 | +[tL]=Cosmology(zlistformation); |
64 | 64 | %load COMPAS data |
65 | | -[M1,M2,Z,Tdelay]=DataRead(filename, max(tL)); |
| 65 | +[M1,M2,Z,Tdelay]=DataRead(filename); |
| 66 | +Zlist=unique(Z); |
66 | 67 | %metallicity-specific SFR |
67 | | -[Zlist,SFR,SFRfractionZ]=Metallicity(Z,zvec,metallicitychoice); |
| 68 | +[SFR,Zweight]=Metallicity(Zlist,zlistformation); |
68 | 69 |
|
69 | 70 |
|
70 | 71 | %Consider the contribution of every simulated binary to the merger rate |
71 | 72 | %in every redshift bin by considering when it would have to be formed to |
72 | 73 | %merge at that redshift and normalizing by the relevant |
73 | 74 | %metallicity-specific star formation rate |
74 | | -dz=zvec(2)-zvec(1); |
75 | | -tLmerge=tL(floor(zlist/(zvec(2)-zvec(1)))+1); |
76 | | -MergerRateByRedshiftByZ=zeros(length(zlist),length(Zlist)); |
| 75 | +dz=zlistformation(2)-zlistformation(1); |
| 76 | +tLmerge=tL(floor(zlistformation/dz)+1); |
| 77 | +MergerRateByRedshiftByZ=zeros(length(zlistformation),length(Zlist)); |
77 | 78 | for(i=1:length(M1)), |
78 | 79 | Zcounter=find(Zlist==Z(i)); |
79 | 80 | zformindex=find(tL>=Tdelay(i),1); |
80 | | - for(k=1:length(zlist)), |
| 81 | + for(k=1:length(zlistformation)), |
81 | 82 | zformindex=find(tL>=(Tdelay(i)+tLmerge(k)),1); |
82 | 83 | MergerRateByRedshiftByZ(k,Zcounter)=... |
83 | 84 | MergerRateByRedshiftByZ(k,Zcounter)+... |
84 | | - SFR(zformindex)*SFRfractionZ(zformindex,Zcounter)/Msimulated; |
| 85 | + SFR(zformindex)*Zweight(zformindex,Zcounter)/Msimulated; |
85 | 86 | end; |
86 | 87 | end; |
87 | 88 |
|
88 | 89 | if(makeplots==1), %make a set of default plots |
89 | | - MakePlots(M1,M2,Z,Tdelay,zvec,SFR,SFRfractionZ,... |
90 | | - zlist,Zlist,MergerRateByRedshiftByZ); |
| 90 | + MakePlots(M1,M2,Z,Tdelay,zlistformation,Zlist,SFR,Zweight,... |
| 91 | + MergerRateByRedshiftByZ); |
91 | 92 | end; |
92 | 93 |
|
93 | 94 | end %end of CosmicHistoryIntegrator |
94 | 95 |
|
95 | 96 |
|
96 | 97 | %Load the data stored in COMPAS .h5 output format from a file |
97 | | -%Select only binary black hole mergers of interest, and return the |
| 98 | +%Select only double compact object mergers of interest, and return the |
98 | 99 | %component masses, metallicities, and star formation to merger delay times |
99 | | -function [M1,M2,Z,Tdelay]=DataRead(file, tHubble) |
| 100 | +function [M1,M2,Z,Tdelay]=DataRead(file) |
100 | 101 | if(exist(file, 'file')~=2), |
101 | 102 | error('Input file does not exist'); |
102 | 103 | end; |
|
108 | 109 | merges=h5read(file,'/BSE_Double_Compact_Objects/Merges_Hubble_Time'); |
109 | 110 | a=h5read(file,'/BSE_Double_Compact_Objects/SemiMajorAxis@DCO'); |
110 | 111 | 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); |
| 112 | + Ttotal=(h5read(file,'/BSE_Double_Compact_Objects/Time')+h5read(file,'/BSE_Double_Compact_Objects/Coalescence_Time'))*1e6; %to years |
| 113 | + %mergingBBH=(type1==14) & (type2==14) & merges; |
| 114 | + %BBH=(type1==14) & (type2==14); |
| 115 | + %mergingBNS=(type1==13) & (type2==13) & merges; |
| 116 | + %BNS=(type1==13) & (type2==13); |
| 117 | + %mergingNSBH=(((type1==13) & (type2==14)) | ((type1==14) & (type2==13))) & merges; |
| 118 | + %NSBH=(((type1==13) & (type2==14)) | ((type1==14) & (type2==13))); |
| 119 | + %mergingDCO=mergingBNS | mergingNSBH | mergingBBH; |
| 120 | + %BNScount=sum(mergingBNS); NSBHcount=sum(mergingNSBH); BBHcount=sum(mergingBBH); |
119 | 121 | chirpmass=mass1.^0.6.*mass2.^0.6./(mass1+mass2).^0.2; |
120 | 122 | q=mass2./mass1; |
121 | 123 | seedCE=h5read(file,'/BSE_Common_Envelopes/SEED'); |
122 | 124 | [isCE,CEIndex]=ismember(seedDCO,seedCE); |
123 | 125 | optCE=h5read(file,'/BSE_Common_Envelopes/Optimistic_CE'); |
124 | 126 | 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 | | - |
128 | | - Z1index=find(strcmp(colnames,'Metallicity1')); |
129 | | - M1index=find(strcmp(colnames,'M1')); |
130 | | - M2index=find(strcmp(colnames,'M2')); |
131 | | - tcindex=find(strcmp(colnames,'tc')); |
132 | | - tformindex=find(strcmp(colnames,'tform')); |
133 | | - type1index=find(strcmp(colnames,'stellarType1')); |
134 | | - type2index=find(strcmp(colnames,'stellarType2')); |
135 | | - nonRLOF=data.data(:,find(strcmp(colnames,'RLOFSecondaryAfterCEE')))==0; |
136 | | - Pessimistic=data.data(:,find(strcmp(colnames,'optimisticCEFlag')))==0; |
137 | | - tc=data.data(:,tcindex); |
138 | | - tform=data.data(:,tformindex); |
139 | | - Ttotal=(tc+tform)*1e6; %convert Megayears to years |
140 | | - %select only binaries where both members are black holes at the last |
141 | | - %step, the total delay time is less than the age of the Universe, there |
142 | | - %is no Roche-lobe overflow immediately after the common-envelope phase, |
143 | | - %and the Pessimistic common-envelope conditions are met |
144 | | - select=Ttotal<tHubble & nonRLOF & Pessimistic & ... |
145 | | - data.data(:,type1index)==14 & data.data(:,type2index)==14; |
146 | | - |
147 | | - M1=data.data(select,M1index); |
148 | | - M2=data.data(select,M2index); |
149 | | - Z=data.data(select,Z1index); |
150 | | - Tdelay=Ttotal(select); |
| 127 | + OKCE=zeros(size(seedDCO)); OKCE(CEIndex==0)=1; OKCE(CEIndex>0)=(~optCE(CEIndex(CEIndex>0))) & (~RLOFCE(CEIndex(CEIndex>0))); |
| 128 | + %BNSCE=sum(mergingBNS & isCE & OKCE); NSBHCE=sum(mergingNSBH & isCE & OKCE); BBHCE=sum(mergingBBH & isCE & OKCE); |
| 129 | + mergingDCO=merges & OKCE; |
| 130 | + Zsys=h5read(file,'/BSE_System_Parameters/Metallicity@ZAMS(1)'); |
| 131 | + seedsys=h5read(file,'/BSE_System_Parameters/SEED'); |
| 132 | + [blah,sysIndex]=ismember(seedDCO,seedsys); |
| 133 | + Zdco=Zsys(sysIndex); |
| 134 | + M1=mass1(mergingDCO); M2=mass2(mergingDCO); Z=Zdco(mergingDCO); Tdelay=Ttotal(mergingDCO); |
151 | 135 | end %end of DataRead |
152 | 136 |
|
153 | 137 | %Compute the star formation rate and lookback time (in years) |
|
157 | 141 | global Mpc |
158 | 142 | global yr |
159 | 143 | %zmax=10; dz=0.001; zvec=0:dz:zmax; |
160 | | - Nz=length(zvec); |
| 144 | + Nz=length(zvec); dz=zvec(2)-zvec(1); |
161 | 145 |
|
162 | 146 | %Planck cosmology |
163 | 147 | OmegaM=0.236+0.046; %2012arXiv1212.5226H |
|
176 | 160 | end %end of Cosmology |
177 | 161 |
|
178 | 162 |
|
179 | | -%Compute the fraction of star formation that happens in a given metallicity |
180 | | -%bin as a function of redshift |
181 | | -function [Zlist,SFR,SFRfractionZ]=Metallicity(zvec,Z) |
| 163 | +%Compute the weight of each star-forming metallicity as a function of redshift |
| 164 | +function [SFR,Zweight]=Metallicity(Zvec, zvec) |
182 | 165 | %M_/odot per Mpc^3 per year -- Neijssel+ 2019 preferred model |
183 | 166 | %would be SFR=0.015*(1+zvec).^2.7./(1+((1+zvec)/2.9).^5.6) in Madau & Dickinson, 2014, (15) |
184 | 167 | SFR=0.01*(1+zvec).^2.77./(1+((1+zvec)/2.9).^4.7); |
185 | | - Zmean=0.035.*10.^(-0.23*zvec); |
186 | | - Zmu=log(Zmean)-0.39^2/2; |
187 | | - dlogZ=0.01; |
188 | | - logZvec=-12:dlogZ:0; %natural log |
189 | | - dPdlogZ=1/0.39/sqrt(2*pi)*exp(-(logZvec'-Zmu).^2/2/0.39^2); |
190 | | - dPdlogZ=dPdlogZ./(sum(dPdlogZ,1)*dlogZ); %normalise |
191 | | - Zrange=log(max(Z))-log(min(Z)); %ugly correction for not including tails |
192 | | - PdrawZ=1/Zrange; |
193 | | - minlogZindex=find(exp(logZvec)>=min(Z),1, 'first'); |
194 | | - maxlogZindex=find(exp(logZvec)<=max(Z),1, 'last'); |
195 | | - dPdlogZ(minlogZindex,:)=dPdlogZ(minlogZindex,:)+sum(dPdlogZ(1:minlogZindex,:),1)*dlogZ/(sum(Z==min(Z))/length(Z))*PdrawZ; |
196 | | - dPdlogZ(maxlogZindex,:)=dPdlogZ(maxlogZindex,:)+sum(dPdlogZ(maxlogZindex:end,:),1)*dlogZ/(sum(Z==max(Z))/length(Z))*PdrawZ; |
197 | | - dPdlogZ=dPdlogZ./(sum(dPdlogZ,1)*dlogZ); %normalise |
| 168 | + if(length(Zvec)>1), |
| 169 | + Zmean=0.035.*10.^(-0.23*zvec); |
| 170 | + Zmu=log(Zmean)-0.39^2/2; |
| 171 | + dlogZ=0.01; |
| 172 | + logZvec=-12:dlogZ:0; %natural log |
| 173 | + dPdlogZ=1/0.39/sqrt(2*pi)*exp(-(logZvec'-Zmu).^2/2/0.39^2); |
| 174 | + dPdlogZ=dPdlogZ./(sum(dPdlogZ,1)*dlogZ); %normalise |
| 175 | + Zrange=log(max(Zvec))-log(min(Zvec)); %ugly correction for not including tails |
| 176 | + PdrawZ=1/Zrange; |
| 177 | + minlogZindex=find(exp(logZvec)>=min(Zvec),1, 'first'); |
| 178 | + maxlogZindex=find(exp(logZvec)>=max(Zvec),1, 'last'); |
| 179 | + dPdlogZ(minlogZindex,:)=dPdlogZ(minlogZindex,:)+sum(dPdlogZ(1:minlogZindex,:),1)*dlogZ/(sum(Zvec==min(Zvec))/length(Zvec))*PdrawZ; |
| 180 | + dPdlogZ(maxlogZindex,:)=dPdlogZ(maxlogZindex,:)+sum(dPdlogZ(maxlogZindex:end,:),1)*dlogZ/(sum(Zvec==max(Zvec))/length(Zvec))*PdrawZ; |
| 181 | + dPdlogZ(1:minlogZindex,:)=0; dPdlogZ(maxlogZindex:size(dPdlogZ,1),:)=0; |
| 182 | + dPdlogZ=dPdlogZ./(sum(dPdlogZ,1)*dlogZ); %normalise |
| 183 | + for(i=1:length(Zvec)) |
| 184 | + index=find(exp(logZvec)>=Zvec(i), 1, 'first'); |
| 185 | + Zweight(:,i)=dPdlogZ(index,:)*dlogZ; |
| 186 | + end; |
| 187 | + else %relevant for single-metallicity runs -- just give all binaries the same unit weight |
| 188 | + Zweight(1:length(zvec),1:length(Zvec))=1; |
| 189 | + end; |
198 | 190 | end %end of Metallicity |
199 | 191 |
|
200 | 192 |
|
201 | 193 | %Make a set of default plots |
202 | | -function MakePlots(M1,M2,Z,Tdelay,zvec,SFR,SFRfractionZ,... |
203 | | - zlist,Zlist,MergerRateByRedshiftByZ) |
| 194 | +function MakePlots(M1,M2,Z,Tdelay,zvec,Zlist,SFR,Zweight,... |
| 195 | + MergerRateByRedshiftByZ) |
204 | 196 |
|
205 | 197 | figure(1),colormap jet; |
206 | | - plot(zlist, MergerRateByRedshiftByZ, 'LineWidth', 2), |
| 198 | + plot(zvec, MergerRateByRedshiftByZ*1e9, 'LineWidth', 2), |
207 | 199 | legend(num2str(Zlist)), |
208 | 200 | set(gca, 'FontSize', 20); %for labels |
209 | 201 | xlabel('z'), |
210 | | - ylabel('Pessimistic non-RLOF BBH merger rate, per Gpc^3 per yr') |
211 | | - disp(['Total BBH merger rate at z=0: ', ... |
| 202 | + ylabel('DCO merger rate per Gpc^3 per yr') |
| 203 | + disp(['Total DCO merger rate at z=0: ', ... |
212 | 204 | num2str(sum(MergerRateByRedshiftByZ(:,1))),... |
213 | 205 | ' per Gpc^3 per year']); |
214 | 206 |
|
215 | | - |
216 | 207 | figure(2), colormap jet; |
217 | 208 | scatter(M1,M2,20,log(Z)/log(10),'filled'); |
218 | 209 | set(gca, 'FontSize', 20); %for labels |
219 | 210 | H=colorbar; H.Label.String='log_{10} metallicity'; |
220 | | - xlabel('Primary BH mass [M_o]'), ylabel('Secondary BH mass [M_o]'); |
| 211 | + xlabel('Primary mass [M_o]'), ylabel('Secondary mass [M_o]'); |
221 | 212 |
|
222 | 213 | figure(3), colormap jet; |
223 | | - scatter(M1+M2,log(Tdelay/1e6)/log(10),20,log(Z)/log(10),'filled'); |
| 214 | + scatter(M1+M2,log10(Tdelay/1e6),20,log10(Z),'filled'); |
224 | 215 | set(gca, 'FontSize', 20); %for labels |
225 | 216 | H=colorbar; H.Label.String='log_{10} metallicity'; |
226 | | - xlabel('Total BBH mass [M_o]'), ylabel('log(Tdelay/Myr)'); |
| 217 | + xlabel('Total DCO mass [M_o]'), ylabel('log_{10}(Tdelay/Myr)'); |
227 | 218 |
|
228 | 219 | figure(4), colormap jet; |
229 | | - plot(zvec, SFR) |
| 220 | + plot(zvec, SFR*1e9) |
230 | 221 | set(gca, 'FontSize', 20); %for labels |
231 | 222 | xlabel('z'), ylabel('Star-formation rate, M_o per Gpc^3 per yr'); |
232 | | - |
233 | 223 |
|
234 | 224 | figure(5), colormap jet; |
235 | | - plot(zvec, SFRfractionZ) |
| 225 | + plot(zvec, Zweight) |
236 | 226 | set(gca, 'FontSize', 20); %for labels |
237 | 227 | legend(num2str(Zlist)) |
238 | | - xlabel('z'), ylabel('Z-specific SFR fraction'); |
| 228 | + xlabel('z'), ylabel('Z-specific SFR weight'); |
239 | 229 |
|
240 | 230 | end %end of MakePlots |
241 | 231 |
|
|
0 commit comments