|
1 | | -function [Zlist, MergerRateByRedshiftByZ, SFR, Rdetections, DetectableMergerRate, Mtzlistdetection, etalist, zlistdetection]=... |
| 1 | +function [Zlist, MergerRateByRedshiftByZ, MergerRateByRedshiftByMtByEta, Mtlist, etalist, SFR, Rdetections, DetectableMergerRate, zlistdetection, x]=... |
2 | 2 | CosmicHistoryIntegrator(filename, zlistformation, zmaxdetection, 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) |
|
20 | 20 | % |
21 | 21 | % OUTPUTS: |
22 | 22 | % Zlist is a vector of metallicities, taken from the COMPAS run input file |
23 | | -% MergerRateByRedshiftByZ is a matrix of size length(Zlist) X length(zformationlist) |
| 23 | +% MergerRateByRedshiftByZ is a matrix of size length(zformationlist) X length(Zlist) |
24 | 24 | % which contains a merger rate of merging compact objects in the given redshift |
25 | 25 | % and metallicity bin, in units of mergers per Mpc^3 of comoving volume per |
26 | 26 | % year of source time |
| 27 | +% MergerRateByRedshiftByMtByEta is a matrix of size llength(zformationlist) |
| 28 | +% X length(Mtlist) X length(etalist) which contains a merger rate of merging compact objects |
| 29 | +% in the given redshift, total mass and eta bin, in units of mergers per Mpc^3 |
| 30 | +% of comoving volume per year of source time |
| 31 | +% Mtlist is a list of total mass bins |
| 32 | +% etalist is a list of symmetric mass ratio bins |
27 | 33 | % SFR is a vector of size length(zlistformation) containing the star formation rate |
28 | 34 | % (solar masses per Mpc^3 of comoving volume per year of source time) |
29 | | -% Rdetection is a matrix of size length(zlistdetection) X length Mtzlist X |
| 35 | +% Rdetection is a matrix of size length(zlistdetection) X length(Mtlist) X |
30 | 36 | % length(etalist) containing the detection rate per year of observer time |
31 | | -% from a given redshift bin and redshifted total mass and symmetric mass |
32 | | -% ratio pixel |
| 37 | +% from a given redshift bin and total mass and symmetric mass ratio pixel |
33 | 38 | % DetectableMergerRate is a matrix of the same size as Rdetection but |
34 | 39 | % containing the intrinsic rate of detectable mergers per Mpc^3 of comoving |
35 | 40 | % volume per year of source time |
36 | | -% Mtzlist is a list of redshifted total mass bins (for computational |
37 | | -% efficiency, very rare sources with Mtz>200 Msun are folded into the |
38 | | -% last bin) |
39 | | -% etalist is a list of symmetric mass ratio bins |
40 | 41 | % zlistdetection is a vector of redshifts at which detection rates are |
41 | 42 | % computed (a subset of zlistformation going up to zmaxdetection) |
42 | 43 | % |
43 | 44 | % EXAMPLE: |
44 | 45 | % zlist=0:0.01:10; |
45 | | -% [Zlist, MergerRateByRedshiftByZ, SFR, Rdetections, DetectableMergerRate, |
46 | | -% Mtzlistdetection, etalist, zlistdetection] = ... |
| 46 | +% [Zlist, MergerRateByRedshiftByZ, MergerRateByRedshiftByMtByEta, Mtlist, etalist, SFR, Rdetections, DetectableMergerRate, zlistdetection,] = ... |
47 | 47 | % CosmicHistoryIntegrator('~/Work/COMPASresults/runs/Zdistalpha1-031803.h5', zlist, 1.5, 90e6, 1); |
48 | 48 | % |
49 | | -% |
50 | | -% zlist=0:0.1:5; |
51 | | -% filename=['~/Work/COMPASresults/popsynth/runs/',... |
52 | | -% '20170628-Coen-Pessimistic/AllMergers.dat']; |
53 | | -% [Zlist,MergerRateByRedshiftByZ]=CosmicHistoryIntegrator(filename,zlist); |
54 | | -% figure(1),colormap jet; |
55 | | -% plot(zlist, MergerRateByRedshiftByZ, 'LineWidth', 2), |
56 | | -% legend(num2str(Zlist)), |
57 | | -% set(gca, 'FontSize', 20); %for labels |
58 | | -% xlabel('z'), |
59 | | -% ylabel('Pessimistic non-RLOF BBH merger rate, per Gpc^3 per yr') |
60 | | -% sum(MergerRateByRedshiftByZ(:,1)) %Total BBH merger rate at z=0 |
61 | | -% [Zlist,MergerRateByRedshiftByZLanger]=CosmicHistoryIntegrator(filename,zlist,1); |
62 | | -% [Zlist,MergerRateByRedshiftByZLambert]=CosmicHistoryIntegrator(filename,zlist,2); |
63 | | -% plot(zlist, sum(MergerRateByRedshiftByZLambert,2), 'r', ... |
64 | | -% zlist, sum(MergerRateByRedshiftByZLanger,2), 'b', 'LineWidth', 2), |
65 | | -% set(gca, 'FontSize', 20), xlabel('z'), legend('Langer & Norman','Lambert') |
66 | | -% ylabel('Pessimistic non-RLOF BBH merger rate, per Gpc^3 per yr'), |
67 | | - |
68 | 49 |
|
69 | 50 |
|
70 | 51 | %define constants |
|
88 | 69 | %metallicity-specific SFR |
89 | 70 | [SFR,Zlist,Zweight]=Metallicity(zlistformation,min(Z),max(Z)); |
90 | 71 |
|
91 | | - |
92 | 72 | %Consider the contribution of every simulated binary to the merger rate |
93 | 73 | %in every redshift bin by considering when it would have to be formed to |
94 | 74 | %merge at that redshift and normalizing by the relevant |
95 | 75 | %metallicity-specific star formation rate |
96 | 76 | dz=zlistformation(2)-zlistformation(1); |
97 | | -tLmerge=tL(floor(zlistformation/dz)+1); |
98 | 77 | etalist=0.01:0.01:0.25; |
99 | | -Mtzlist=1:1:ceil(max(M1+M2)*(1+max(zlistformation))); |
| 78 | +Mtlist=1:1:ceil(max(M1+M2)); |
100 | 79 | MergerRateByRedshiftByZ=zeros(length(zlistformation),length(Zlist)); |
101 | | -MergerRateByRedshiftByMtzByEta=zeros(length(zlistformation),length(Mtzlist),length(etalist)); |
| 80 | +MergerRateByRedshiftByMtByEta=zeros(length(zlistformation),length(Mtlist),length(etalist)); |
| 81 | +x=zeros(size(M1)); |
102 | 82 | for(i=1:length(M1)), |
103 | 83 | Zcounter=find(Zlist>=Z(i),1); |
104 | 84 | eta=M1(i)*M2(i)/(M1(i)+M2(i))^2; |
105 | 85 | etaindex=ceil(eta*100); |
106 | | - for(k=1:length(zlistformation)), %merger redshift index |
107 | | - if((Tdelay(i)+tLmerge(k)) > max(tL)), continue; end; %binary can't merge this early |
108 | | - zformindex=find(tL>=(Tdelay(i)+tLmerge(k)),1); |
109 | | - Mtzindex=ceil((M1(i)+M2(i))*(1+zlistformation(k))); |
110 | | - MergerRateByRedshiftByZ(k,Zcounter)=... |
111 | | - MergerRateByRedshiftByZ(k,Zcounter)+... |
112 | | - SFR(zformindex)*Zweight(zformindex,Zcounter)/Msimulated; |
113 | | - MergerRateByRedshiftByMtzByEta(k,Mtzindex,etaindex) =... |
114 | | - MergerRateByRedshiftByMtzByEta(k,Mtzindex,etaindex) + ... |
115 | | - SFR(zformindex)*Zweight(zformindex,Zcounter)/Msimulated; |
| 86 | + tLform=tL+Tdelay(i); %lookback time of when binary would have to form in order to merge at lookback time tL |
| 87 | + firsttooearlyindex=find((tLform)>max(tL),1); |
| 88 | + if(isempty(firsttooearlyindex)), firsttooearlyindex=length(tL)+1; end; |
| 89 | + zForm=interp1(tL,zlistformation,tLform(1:firsttooearlyindex-1)); |
| 90 | + zFormindex=ceil((zForm-zlistformation(1))./dz)+1; |
| 91 | + Mtindex=ceil(M1(i)+M2(i)); |
| 92 | + if(~isempty(zFormindex)) |
| 93 | + x(i)=SFR(zFormindex(1))*Zweight(zFormindex(1),Zcounter)/Msimulated; |
| 94 | + MergerRateByRedshiftByZ(1:firsttooearlyindex-1,Zcounter)=... |
| 95 | + MergerRateByRedshiftByZ(1:firsttooearlyindex-1,Zcounter)+... |
| 96 | + transpose(SFR(zFormindex)).*Zweight(zFormindex,Zcounter)/Msimulated; |
| 97 | + MergerRateByRedshiftByMtByEta(1:firsttooearlyindex-1,Mtindex,etaindex) =... |
| 98 | + MergerRateByRedshiftByMtByEta(1:firsttooearlyindex-1,Mtindex,etaindex) + ... |
| 99 | + transpose(SFR(zFormindex)).*Zweight(zFormindex,Zcounter)/Msimulated; |
116 | 100 | end; |
| 101 | + %for(k=1:length(zlistformation)), %merger redshift index |
| 102 | + % if((Tdelay(i)+tL(k)) > max(tL)), continue; end; %binary can't merge this early |
| 103 | + % zformindex=find(tL>=(Tdelay(i)+tL(k)),1); |
| 104 | + % Mtzindex=ceil((M1(i)+M2(i))*(1+zlistformation(k))); |
| 105 | + % MergerRateByRedshiftByZ(k,Zcounter)=... |
| 106 | + % MergerRateByRedshiftByZ(k,Zcounter)+... |
| 107 | + % SFR(zformindex)*Zweight(zformindex,Zcounter)/Msimulated; |
| 108 | + % MergerRateByRedshiftByMtzByEta(k,Mtzindex,etaindex) =... |
| 109 | + % MergerRateByRedshiftByMtzByEta(k,Mtzindex,etaindex) + ... |
| 110 | + % SFR(zformindex)*Zweight(zformindex,Zcounter)/Msimulated; |
| 111 | + %end; |
117 | 112 | end; |
118 | 113 |
|
119 | 114 | zlistdetection=zlistformation(1:find(zlistformation<=zmaxdetection,1,"last")); |
120 | 115 | fin=load('~/Work/Rai/LIGOfuture_data/freqVector.txt'); |
121 | 116 | %noise=load('~/Work/Rai/LIGOfuture_data/dataNomaLIGO.txt'); |
122 | 117 | noise=load('~/Work/Rai/LIGOfuture_data/dataEarly_low.txt'); |
123 | | -[Mtzlistdetection, Rdetections,DetectableMergerRate]=... |
124 | | - DetectionRate(zlistformation,Mtzlist,etalist,MergerRateByRedshiftByMtzByEta,zlistdetection,fin,noise,Dl,dVc); |
| 118 | +[Rdetections,DetectableMergerRate]=... |
| 119 | + DetectionRate(zlistformation,Mtlist,etalist,MergerRateByRedshiftByMtByEta,zlistdetection,fin,noise,Dl,dVc); |
125 | 120 |
|
126 | 121 | if(makeplots==1), %make a set of default plots |
127 | 122 | MakePlots(M1,M2,Z,Tdelay,zlistformation,Zlist,SFR,Zweight,... |
128 | | - MergerRateByRedshiftByZ, Rdetections, DetectableMergerRate, zlistdetection, Mtzlistdetection, etalist, 1); |
| 123 | + MergerRateByRedshiftByZ, Rdetections, DetectableMergerRate, zlistdetection, Mtlist, etalist, 1); |
129 | 124 | end; |
130 | 125 |
|
131 | 126 | end %end of CosmicHistoryIntegrator |
|
208 | 203 | Zmu=log(Zmean)-0.39^2/2; |
209 | 204 | dlogZ=0.1; |
210 | 205 | logZvec=-12:dlogZ:0; %natural log |
211 | | - dPdlogZ=1/0.39/sqrt(2*pi)*exp(-(logZvec'-Zmu).^2/2/0.39^2); |
| 206 | + dPdlogZ=1/0.39/sqrt(2*pi)*exp(-(logZvec'-Zmu).^2/2/0.39^2); %size length(logZvec) x length(zvec) |
212 | 207 | dPdlogZ=dPdlogZ./(sum(dPdlogZ,1)*dlogZ); %normalise |
213 | 208 | minlogZindex=find(exp(logZvec)>=minZ,1, 'first'); |
214 | 209 | maxlogZindex=find(exp(logZvec)>=maxZ,1, 'first'); |
215 | 210 | Zrange=logZvec(maxlogZindex)-logZvec(minlogZindex); %ugly correction for not including tails |
216 | 211 | PdrawZ=1/Zrange; |
217 | 212 | Zvec=exp(logZvec(minlogZindex:maxlogZindex)); |
218 | | - dPdlogZ(minlogZindex,:)=dPdlogZ(minlogZindex,:)+sum(dPdlogZ(1:minlogZindex,:),1)*dlogZ/(sum(Zvec==min(Zvec))/length(Zvec))*PdrawZ; |
219 | | - dPdlogZ(maxlogZindex,:)=dPdlogZ(maxlogZindex,:)+sum(dPdlogZ(maxlogZindex:end,:),1)*dlogZ/(sum(Zvec==max(Zvec))/length(Zvec))*PdrawZ; |
220 | | - dPdlogZ(1:minlogZindex,:)=0; dPdlogZ(maxlogZindex:size(dPdlogZ,1),:)=0; |
| 213 | + Zweight=zeros(length(zvec),length(Zvec)); |
| 214 | + dPdlogZ(minlogZindex,:)=dPdlogZ(minlogZindex,:)+sum(dPdlogZ(1:minlogZindex-1,:),1)*dlogZ/dlogZ; |
| 215 | + dPdlogZ(maxlogZindex,:)=dPdlogZ(maxlogZindex,:)+sum(dPdlogZ(maxlogZindex+1:end,:),1)*dlogZ/dlogZ; |
| 216 | + dPdlogZ(1:minlogZindex-1,:)=0; dPdlogZ(maxlogZindex+1:size(dPdlogZ,1),:)=0; |
221 | 217 | dPdlogZ=dPdlogZ./(sum(dPdlogZ,1)*dlogZ); %normalise |
222 | 218 | for(i=1:length(Zvec)) |
223 | 219 | index=find(exp(logZvec)>=Zvec(i), 1, 'first'); |
|
231 | 227 |
|
232 | 228 |
|
233 | 229 | %Compute detection rates per year of observer time and per year of source time |
234 | | -%per Mpc^3 of comoving volume as a function of redshifted total mass and eta |
235 | | -function [Mtzlistdetection, Rdetections, DetectableMergerRate]=... |
236 | | - DetectionRate(zlistformation,Mtzlist,etalist,MergerRateByRedshiftByMtzByEta,zlistdetection,freqfile,noisefile,Dl,dVc) |
| 230 | +%per Mpc^3 of comoving volume as a function of total mass and eta |
| 231 | +function [Rdetections, DetectableMergerRate]=... |
| 232 | + DetectionRate(zlistformation,Mtlist,etalist,MergerRateByRedshiftByMtByEta,zlistdetection,freqfile,noisefile,Dl,dVc) |
237 | 233 |
|
238 | 234 | fin=load('~/Work/Rai/LIGOfuture_data/freqVector.txt'); |
239 | | - noise=load('~/Work/Rai/LIGOfuture_data/dataEarly_low.txt'); |
| 235 | + noise=load('~/Work/Rai/LIGOfuture_data/dataMid_low.txt'); |
240 | 236 |
|
241 | 237 | flow=10; |
242 | 238 | df=1; |
|
258 | 254 |
|
259 | 255 | %save time by not doing calculations beyond maximum redshifted total |
260 | 256 | %mass corresponding to detection redshift threshold |
261 | | - Mtzlistdetection=Mtzlist(1:ceil(length(Mtzlist)*max(zlistdetection)/max(zlistformation))); |
| 257 | + Mtzlistdetection=1:1:ceil(max(Mtlist)*(1+max(zlistdetection))); |
262 | 258 | SNRat1Mpc=zeros(length(Mtzlistdetection),length(etalist)); |
263 | 259 | for(i=1:length(Mtzlistdetection)), |
264 | 260 | for(j=1:length(etalist)), |
|
267 | 263 | SNRat1Mpc(i,j)=sqrt(integral); |
268 | 264 | end; |
269 | 265 | end; |
270 | | - SNRat1Mpc(1,25) |
271 | 266 |
|
272 | | - SNR=zeros(length(zlistdetection),length(Mtzlistdetection),length(etalist)); |
273 | | - for(i=1:length(zlistdetection)), SNR(i,:,:)=SNRat1Mpc./Dl(i); end; |
| 267 | + SNR=zeros(length(zlistdetection),length(Mtlist),length(etalist)); |
| 268 | + |
| 269 | + for(i=1:length(zlistdetection)), |
| 270 | + for(j=1:length(Mtlist)), |
| 271 | + SNR(i,j,:)=SNRat1Mpc(ceil(j*(zlistdetection(i)+1)),:)./Dl(i); |
| 272 | + end; |
| 273 | + end; |
| 274 | + %for(i=1:length(zlistdetection)), SNR(i,:,:)=SNRat1Mpc./Dl(i); end; |
274 | 275 |
|
275 | 276 | SNR8pre=1:0.1:1000; |
276 | 277 | theta=1./SNR8pre; |
277 | 278 | pdetect=1-interp1([0,Thetas,1],[(0:Ntheta)/Ntheta,1],theta); |
278 | 279 | pdetect(1)=0; %set of measure zero to exceed threshold, but enforce just in case |
279 | 280 |
|
280 | | - Rdetections=zeros(length(zlistdetection),length(Mtzlistdetection),length(etalist)); %Detections per unit observer time |
281 | | - DetectableMergerRate=zeros(length(zlistdetection),length(Mtzlistdetection),length(etalist)); %Detections per unit source time per unit Vc |
| 281 | + Rdetections=zeros(length(zlistdetection),length(Mtlist),length(etalist)); %Detections per unit observer time |
| 282 | + DetectableMergerRate=zeros(length(zlistdetection),length(Mtlist),length(etalist)); %Detections per unit source time per unit Vc |
282 | 283 | SNR8=SNR/8; |
283 | 284 | pdetection=zeros(size(Rdetections)); |
284 | 285 | pdetection=pdetect(max(min(floor(SNR8*10),length(pdetect)),1)); |
285 | | - DetectableMergerRate=MergerRateByRedshiftByMtzByEta(1:length(zlistdetection),1:length(Mtzlistdetection),:).*pdetection; |
| 286 | + |
| 287 | + DetectableMergerRate=MergerRateByRedshiftByMtByEta(1:length(zlistdetection),:,:).*pdetection; |
286 | 288 | Rdetections=DetectableMergerRate.*transpose(dVc(1:length(zlistdetection)))./(1+zlistdetection'); |
287 | 289 |
|
288 | 290 | end %end of DetectionRate |
289 | 291 |
|
290 | 292 | %Make a set of default plots |
291 | 293 | function MakePlots(M1,M2,Z,Tdelay,zlistformation,Zlist,SFR,Zweight,... |
292 | | - MergerRateByRedshiftByZ, Rdetections, DetectableMergerRate, zlistdetection, Mtzlistdetection, etazlist, fignumber) |
| 294 | + MergerRateByRedshiftByZ, Rdetections, DetectableMergerRate, zlistdetection, Mtlist, etazlist, fignumber) |
293 | 295 |
|
294 | 296 | zvec=zlistformation; |
295 | 297 |
|
@@ -332,12 +334,12 @@ function MakePlots(M1,M2,Z,Tdelay,zlistformation,Zlist,SFR,Zweight,... |
332 | 334 |
|
333 | 335 |
|
334 | 336 | figure(fignumber+4), clf(fignumber+4); |
335 | | - RdetectionsByzMtz=sum(Rdetections,3); %sum across eta |
336 | | - plot(zlistdetection, cumsum(sum(RdetectionsByzMtz,2)), 'LineWidth', 3), hold on; |
337 | | - plot(zlistdetection, cumsum(sum(RdetectionsByzMtz(:,Mtzlistdetection<=5),2)), 'LineWidth', 1); |
338 | | - plot(zlistdetection, cumsum(sum(RdetectionsByzMtz(:,Mtzlistdetection>5 & Mtzlistdetection<20),2)), 'LineWidth', 1); |
339 | | - plot(zlistdetection, cumsum(sum(RdetectionsByzMtz(:,Mtzlistdetection>=20),2)), 'LineWidth', 1); hold off; |
340 | | - legend('Total rate', 'From M_t(1+z)<=5 M_o', 'From 5<M_t(1+z)/M_o<20', 'From M_t(1+z)>=20 M_o'), |
| 337 | + RdetectionsByzMt=sum(Rdetections,3); %sum across eta |
| 338 | + semilogy(zlistdetection, cumsum(sum(RdetectionsByzMt,2)), 'LineWidth', 3), hold on; |
| 339 | + semilogy(zlistdetection, cumsum(sum(RdetectionsByzMt(:,Mtlist<=5),2)), 'LineWidth', 1); |
| 340 | + semilogy(zlistdetection, cumsum(sum(RdetectionsByzMt(:,Mtlist>5 & Mtlist<20),2)), 'LineWidth', 1); |
| 341 | + semilogy(zlistdetection, cumsum(sum(RdetectionsByzMt(:,Mtlist>=20),2)), 'LineWidth', 1); hold off; |
| 342 | + legend('Total rate', 'From M_t<=5 M_o', 'From 5<M_t/M_o<20', 'From M_t>=20 M_o'), |
341 | 343 | set(gca, 'FontSize', 20); %for labels |
342 | 344 | xlabel('z'), |
343 | 345 | ylabel('cumulative detection rate per observer yr') |
|
0 commit comments