1- function [Zlist , MergerRateByRedshiftByZ , SFR , Rdetections , DetectableMergerRate , Mtzlist , etalist , zlistdetection ]=...
1+ function [Zlist , MergerRateByRedshiftByZ , SFR , Rdetections , DetectableMergerRate , Mtzlistdetection , etalist , zlistdetection ]=...
22 CosmicHistoryIntegrator(filename , zlistformation , zmaxdetection , Msimulated , makeplots )
33% Integrator for the binary black hole merger rate over cosmic history
44% COMPAS (Compact Object Mergers: Population Astrophysics and Statistics)
55% software package
66%
77% USAGE:
88% [Zlist, MergerRateByRedshiftByZ, SFR, Zweight, Rdetections, DetectableMergerRate, Mtzlist, etalist, zlistdetection]=...
9- % CosmicHistoryIntegrator(filename, zlistformation, zmaxdetection, Msimulated, [,makeplots])
9+ % CosmicHistoryIntegrator(filename, zlistformation, zmaxdetection, Msimulated [,makeplots])
1010%
1111% INPUTS:
1212% filename: name of population synthesis input file
4141% computed (a subset of zlistformation going up to zmaxdetection)
4242%
4343% EXAMPLE:
44- % CosmicHistoryIntegrator('~/Work/COMPASresults/runs/Zdistalpha1-031803.h5', ...
45- % zlist, zlist, 90e6, 1, '~/Work/COMPASresults/runs/Zdist2stage-031803.h5', 'Default', '2 Stage')
44+ % zlist=0:0.01:10;
45+ % [Zlist, MergerRateByRedshiftByZ, SFR, Rdetections, DetectableMergerRate,
46+ % Mtzlistdetection, etalist, zlistdetection] = ...
47+ % CosmicHistoryIntegrator('~/Work/COMPASresults/runs/Zdistalpha1-031803.h5', zlist, 1.5, 90e6, 1);
48+ %
49+ %
4650% zlist=0:0.1:5;
4751% filename=['~/Work/COMPASresults/popsynth/runs/',...
4852% '20170628-Coen-Pessimistic/AllMergers.dat'];
9195% metallicity-specific star formation rate
9296dz= zlistformation(2 )-zlistformation(1 );
9397tLmerge= tL(floor(zlistformation / dz )+1 );
94- etavec = 0.01 : 0.01 : 0.25 ;
95- Mtzvec = 1 : 1 : 200 ; % ignore things on wrong side of mass gap, go up to z=1
98+ etalist = 0.01 : 0.01 : 0.25 ;
99+ Mtzlist = 1 : 1 : ceil(max( M1 + M2 )*( 1 + max( zlistformation )));
96100MergerRateByRedshiftByZ= zeros(length(zlistformation ),length(Zlist ));
97- MergerRateByRedshiftByMtzByEta= zeros(length(zlistformation ),length(etavec ),length(Mtzvec ));
101+ MergerRateByRedshiftByMtzByEta= zeros(length(zlistformation ),length(Mtzlist ),length(etalist ));
98102for (i = 1 : length(M1 )),
99- i , M1(i ), M2(i )
100103 Zcounter= find(Zlist >= Z(i ),1 );
101- zformindex= find(tL >= Tdelay(i ),1 );
102- etaindex= M1(i )^0.6 * M2(i )^0.6 /(M1(i )+M2(i ))^0.2 ;
103- for (k = 1 : length(zlistformation )),
104- zformindex= find(tL >=(Tdelay(i )+tLmerge(k )),1 )
105- Mtzindex= ceil((M1(i )+M2(i ))*zlistformation(k ))
104+ eta= M1(i )*M2(i )/(M1(i )+M2(i ))^2 ;
105+ 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 )));
106110 MergerRateByRedshiftByZ(k ,Zcounter )=...
107111 MergerRateByRedshiftByZ(k ,Zcounter )+...
108112 SFR(zformindex )*Zweight(zformindex ,Zcounter )/Msimulated ;
116120fin= load(' ~/Work/Rai/LIGOfuture_data/freqVector.txt' );
117121% noise=load('~/Work/Rai/LIGOfuture_data/dataNomaLIGO.txt');
118122noise= load(' ~/Work/Rai/LIGOfuture_data/dataEarly_low.txt' );
119- [Rdetections ,DetectableMergerRate ]=...
120- DetectionRate(zlistformation ,Mtzlist ,etalist ,MergerRateByRedshiftByMtzByEta ,zlistdetection ,fin ,noise ,Dl ,dVc )
123+ [Mtzlistdetection , Rdetections ,DetectableMergerRate ]=...
124+ DetectionRate(zlistformation ,Mtzlist ,etalist ,MergerRateByRedshiftByMtzByEta ,zlistdetection ,fin ,noise ,Dl ,dVc );
121125
122126if (makeplots == 1 ), % make a set of default plots
123127 MakePlots(M1 ,M2 ,Z ,Tdelay ,zlistformation ,Zlist ,SFR ,Zweight ,...
124- MergerRateByRedshiftByZ , Rdetections , DetectableMergerRate , Mtzlist , etalist , 1 );
128+ MergerRateByRedshiftByZ , Rdetections , DetectableMergerRate , zlistdetection , Mtzlistdetection , etalist , 1 );
125129end ;
126130
127131end % end of CosmicHistoryIntegrator
217221 dPdlogZ= dPdlogZ ./(sum(dPdlogZ ,1 )*dlogZ ); % normalise
218222 for (i = 1 : length(Zvec ))
219223 index= find(exp(logZvec )>=Zvec(i ), 1 , ' first' );
220- Zweight(: ,i )=dPdlogZ(index ,: )* dlogZ ;
224+ Zweight(: ,i )=dPdlogZ(index ,: )./ PdrawZ ; % weight is desired over sampled probabiluty
221225 end ;
222226 else % relevant for single-metallicity runs -- just give all binaries the same unit weight
223227 Zvec= minZ ;
226230end % end of Metallicity
227231
228232
229- % Compute detection rates per unit observer time and per unit source time
230- % per unit comoving volume as a function of redshifted total mass and eta
231- function [Rdetections ,DetectableMergerRate ]=...
233+ % 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 ]=...
232236 DetectionRate(zlistformation ,Mtzlist ,etalist ,MergerRateByRedshiftByMtzByEta ,zlistdetection ,freqfile ,noisefile ,Dl ,dVc )
237+
233238 fin= load(' ~/Work/Rai/LIGOfuture_data/freqVector.txt' );
234239 noise= load(' ~/Work/Rai/LIGOfuture_data/dataEarly_low.txt' );
235240
251256 Thetas= sort(Theta );
252257
253258
254- SNRat1Mpc= zeros(length(Mtzvec ),length(etavec ));
255- for (i = 1 : length(Mtzvec )),
256- for (j = 1 : length(etavec )),
257- [h ,Am ,psi ]=IMRSAWaveform(f , Mtzvec(i ), etavec(j ), 0 , 0 , 0 , 1 , flow );
259+ % save time by not doing calculations beyond maximum redshifted total
260+ % mass corresponding to detection redshift threshold
261+ Mtzlistdetection= Mtzlist(1 : ceil(length(Mtzlist )*max(zlistdetection )/max(zlistformation )));
262+ SNRat1Mpc= zeros(length(Mtzlistdetection ),length(etalist ));
263+ for (i = 1 : length(Mtzlistdetection )),
264+ for (j = 1 : length(etalist )),
265+ [h ,Am ,psi ]=IMRSAWaveform(f , Mtzlistdetection(i ), etalist(j ), 0 , 0 , 0 , 1 , flow );
258266 integral= sum(4 * Am .^ 2 ./ Sf * df );
259267 SNRat1Mpc(i ,j )=sqrt(integral );
260268 end ;
261269 end ;
270+ SNRat1Mpc(1 ,25 )
262271
263- SNR= zeros(length(zlistdetection ),length(Mtzlist ),length(etalist ));
264- for (i = 1 : length(zlistdetection )), SNR(i ,: ,: )=1 ./(Dl(i )./Mpc ); end ;
265- SNR= SNR .* SNRat1Mpc ;
266-
272+ SNR= zeros(length(zlistdetection ),length(Mtzlistdetection ),length(etalist ));
273+ for (i = 1 : length(zlistdetection )), SNR(i ,: ,: )=SNRat1Mpc ./ Dl(i ); end ;
267274
268- SNR8pre= 0. 1: 0.1 : 1000 ;
275+ SNR8pre= 1 : 0.1 : 1000 ;
269276 theta= 1 ./ SNR8pre ;
270277 pdetect= 1 - interp1([0 ,Thetas ,1 ],[(0 : Ntheta )/Ntheta ,1 ],theta );
278+ pdetect(1 )=0 ; % set of measure zero to exceed threshold, but enforce just in case
271279
272- Rdetections= zeros(length(zlistdetection ),length(Mtzlist ),length(etalist )); % Detections per unit observer time
273- DetectableMergerRate= zeros(length(zlistdetection ),length(Mtzlist ),length(etalist )); % Detections per unit source time per unit Vc
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
274282 SNR8= SNR / 8 ;
275283 pdetection= zeros(size(Rdetections ));
276- pdetection(SNR8 > 1)=pdetect(floor(SNR8(SNR8 > 1 & SNR8 < max(SNR8pre ))*10 ));
277- pdetection(SNR8 > max(SNR8pre ))=1 ;
278- DetectableMergerRate= MergerRateByRedshiftByMtzByEta(i ,1 : length(zlistdetection )).*pdetection ;
279- Rdetections(i ,: )=MergerRateByRedshiftByMtzByEta(i ,1 : length(zlistdetection )).*pdetection .* dVc(1 : maxzdetindex )./(1 + zlistdetection );
284+ pdetection= pdetect(max(min(floor(SNR8 * 10 ),length(pdetect )),1 ));
285+ DetectableMergerRate= MergerRateByRedshiftByMtzByEta(1 : length(zlistdetection ),1 : length(Mtzlistdetection ),: ).*pdetection ;
286+ Rdetections= DetectableMergerRate .* transpose(dVc(1 : length(zlistdetection )))./(1 + zlistdetection ' );
280287
281288end % end of DetectionRate
282289
283290% Make a set of default plots
284- function MakePlots(M1 ,M2 ,Z ,Tdelay ,zformationlist ,Zlist ,SFR ,Zweight ,...
285- MergerRateByRedshiftByZ , Rdetections , DetectableMergerRate , zdetectionlist , Mtzlist , etazlist , fignumber )
291+ function MakePlots(M1 ,M2 ,Z ,Tdelay ,zlistformation ,Zlist ,SFR ,Zweight ,...
292+ MergerRateByRedshiftByZ , Rdetections , DetectableMergerRate , zlistdetection , Mtzlistdetection , etazlist , fignumber )
286293
287- zvec= zformationlist ;
294+ zvec= zlistformation ;
288295
289296 figure(fignumber ), clf(fignumber ); % ,colormap jet;
290297 plot(zvec , sum(MergerRateByRedshiftByZ ,2 )*1e9 , ' LineWidth' , 3 ), hold on ;
291298 plot(zvec , sum(MergerRateByRedshiftByZ(: ,Zlist <= 0.001 ),2 )*1e9 , ' LineWidth' , 1 );
292299 plot(zvec , sum(MergerRateByRedshiftByZ(: ,Zlist > 0.001 & Zlist < 0.01),2 )*1e9 , ' LineWidth' , 1 );
293300 plot(zvec , sum(MergerRateByRedshiftByZ(: ,Zlist >= 0.01 ),2 )*1e9 , ' LineWidth' , 1 ); hold off ;
294- legend(' Total rate' , ' From Z<=0.001' , ' From 0.001<Z<0.01' , ' From Z>=0.01' ),
295301 set(gca , ' FontSize' , 20 ); % for labels
296302 xlabel(' z' ),
297303 ylabel(' DCO merger rate per Gpc^3 per yr' )
304+ legend(' Total rate' , ' From Z<=0.001' , ' From 0.001<Z<0.01' , ' From Z>=0.01' ),
298305 disp([' Total DCO merger rate at z=0: ' , ...
299306 num2str(1e9 * sum(MergerRateByRedshiftByZ(1 ,: ))),...
300307 ' per Gpc^3 per year' ]);
@@ -316,18 +323,25 @@ function MakePlots(M1,M2,Z,Tdelay,zformationlist,Zlist,SFR,Zweight,...
316323
317324 figure(fignumber + 3 ), clf(fignumber + 3 );
318325 plot(zvec , SFR * 1e9 , ' LineWidth' , 3 ); hold on ;
319- plot(zvec , SFR ' .*sum(Zweight(: ,Zlist <= 0.001 ),2 )*1e9 , ' LineWidth' , 1 );
320- plot(zvec , SFR ' .*sum(Zweight(: ,Zlist > 0.001& Zlist < 0.01),2 )*1e9 , ' LineWidth' , 1 );
321- plot(zvec , SFR ' .*sum(Zweight(: ,Zlist >= 0.01 ),2 )*1e9 , ' LineWidth' , 1 ); hold off ;
322- legend(' Total rate' , ' From Z<=0.001' , ' From 0.001<Z<0.01' , ' From Z>=0.01' ),
326+ plot(zvec , SFR ' .*sum(Zweight(: ,Zlist <= 0.001 ),2 )./sum(Zweight ,2 )*1e9 , ' LineWidth' , 1 );
327+ plot(zvec , SFR ' .*sum(Zweight(: ,Zlist > 0.001& Zlist < 0.01),2 )./sum(Zweight ,2 )*1e9 , ' LineWidth' , 1 );
328+ plot(zvec , SFR ' .*sum(Zweight(: ,Zlist >= 0.01 ),2 )./sum(Zweight ,2 )*1e9 , ' LineWidth' , 1 ); hold off ;
323329 set(gca , ' FontSize' , 20 ); % for labels
324330 xlabel(' z' ), ylabel(' Star-formation rate, M_o per Gpc^3 per yr' );
325-
326- figure(5 ), colormap jet ;
327- plot(zvec , Zweight , ' LineWidth' , 3 )
331+ legend(' Total rate' , ' From Z<=0.001' , ' From 0.001<Z<0.01' , ' From Z>=0.01' ),
332+
333+
334+ 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' ),
328341 set(gca , ' FontSize' , 20 ); % for labels
329- legend(num2str(Zlist ))
330- xlabel(' z' ), ylabel(' Z-specific SFR weight' );
342+ xlabel(' z' ),
343+ ylabel(' cumulative detection rate per observer yr' )
344+
331345
332346end % end of MakePlots
333347
0 commit comments