|
1 | | -function [Zlist, MergerRateByRedshiftByZ, SFR, Zweight]=... |
2 | | - CosmicHistoryIntegrator(filename, zlistformation, zlistdetection, Msimulated, makeplots) |
| 1 | +function [Zlist, MergerRateByRedshiftByZ, SFR, Rdetections, DetectableMergerRate, Mtzlist, etalist, zlistdetection]=... |
| 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) |
5 | 5 | % software package |
6 | 6 | % |
7 | 7 | % USAGE: |
8 | | -% [Zlist, MergerRateByRedshiftByZ]=... |
9 | | -% CosmicHistoryIntegrator(filename, zlistformation, zlistmerger, [,makeplots, filename2, name1, name2]) |
| 8 | +% [Zlist, MergerRateByRedshiftByZ, SFR, Zweight, Rdetections, DetectableMergerRate, Mtzlist, etalist, zlistdetection]=... |
| 9 | +% CosmicHistoryIntegrator(filename, zlistformation, zmaxdetection, Msimulated, [,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 | | -% zlistdetection: vector of redshifts at which the detection rate is computed |
| 16 | +% zmaxdetection: maximum redshift to 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) |
20 | 20 | % |
21 | | -% Zlist is a vector of metallicities, taken from input file |
22 | | -% MergerRateByRedshiftByZ is a matrix of size length(Zlist) X length(zlist) |
23 | | -% which contains a merger rate of binary black holes in the given redshift |
24 | | -% and metallicity bin, in units of mergers per Gpc^3 of comoving volume per |
| 21 | +% OUTPUTS: |
| 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) |
| 24 | +% which contains a merger rate of merging compact objects in the given redshift |
| 25 | +% and metallicity bin, in units of mergers per Mpc^3 of comoving volume per |
25 | 26 | % year of source time |
| 27 | +% SFR is a vector of size length(zlistformation) containing the star formation rate |
| 28 | +% (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 |
| 30 | +% 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 |
| 33 | +% DetectableMergerRate is a matrix of the same size as Rdetection but |
| 34 | +% containing the intrinsic rate of detectable mergers per Mpc^3 of comoving |
| 35 | +% 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 | +% zlistdetection is a vector of redshifts at which detection rates are |
| 41 | +% computed (a subset of zlistformation going up to zmaxdetection) |
26 | 42 | % |
27 | 43 | % EXAMPLE: |
28 | 44 | % CosmicHistoryIntegrator('~/Work/COMPASresults/runs/Zdistalpha1-031803.h5', ... |
|
53 | 69 | global yr; |
54 | 70 | Mpcm=1*10^6 * 3.0856775807e16; %Mpc in meters |
55 | 71 | c=299792458; %speed of light, m/s |
56 | | -Mpc=Mpcm/c; %Gpc in seconds |
| 72 | +Mpc=Mpcm/c; %Mpc in seconds |
57 | 73 | yr=3.15569e7; %year in seconds |
58 | 74 |
|
59 | 75 | if (nargin<4) |
|
62 | 78 | if (nargin<5), makeplots=0; end; |
63 | 79 |
|
64 | 80 | %cosmology calculator |
65 | | -[tL]=Cosmology(zlistformation); |
| 81 | +[tL,Dl,dVc]=Cosmology(zlistformation); |
66 | 82 | %load COMPAS data |
67 | | -[M1,M2,Z,Tdelay]=DataRead(filename); |
| 83 | +[M1,M2,Z,Tdelay,maxNS]=DataRead(filename); |
68 | 84 | %metallicity-specific SFR |
69 | 85 | [SFR,Zlist,Zweight]=Metallicity(zlistformation,min(Z),max(Z)); |
70 | 86 |
|
|
75 | 91 | %metallicity-specific star formation rate |
76 | 92 | dz=zlistformation(2)-zlistformation(1); |
77 | 93 | tLmerge=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 |
78 | 96 | MergerRateByRedshiftByZ=zeros(length(zlistformation),length(Zlist)); |
| 97 | +MergerRateByRedshiftByMtzByEta=zeros(length(zlistformation),length(etavec),length(Mtzvec)); |
79 | 98 | for(i=1:length(M1)), |
| 99 | + i, M1(i), M2(i) |
80 | 100 | Zcounter=find(Zlist>=Z(i),1); |
81 | 101 | zformindex=find(tL>=Tdelay(i),1); |
| 102 | + etaindex=M1(i)^0.6*M2(i)^0.6/(M1(i)+M2(i))^0.2; |
82 | 103 | for(k=1:length(zlistformation)), |
83 | | - zformindex=find(tL>=(Tdelay(i)+tLmerge(k)),1); |
| 104 | + zformindex=find(tL>=(Tdelay(i)+tLmerge(k)),1) |
| 105 | + Mtzindex=ceil((M1(i)+M2(i))*zlistformation(k)) |
84 | 106 | MergerRateByRedshiftByZ(k,Zcounter)=... |
85 | 107 | MergerRateByRedshiftByZ(k,Zcounter)+... |
86 | | - SFR(zformindex)*Zweight(zformindex,Zcounter)/Msimulated; |
| 108 | + SFR(zformindex)*Zweight(zformindex,Zcounter)/Msimulated; |
| 109 | + MergerRateByRedshiftByMtzByEta(k,Mtzindex,etaindex) =... |
| 110 | + MergerRateByRedshiftByMtzByEta(k,Mtzindex,etaindex) + ... |
| 111 | + SFR(zformindex)*Zweight(zformindex,Zcounter)/Msimulated; |
87 | 112 | end; |
88 | 113 | end; |
89 | 114 |
|
| 115 | +zlistdetection=zlistformation(1:find(zlistformation<=zmaxdetection,1,"last")); |
| 116 | +fin=load('~/Work/Rai/LIGOfuture_data/freqVector.txt'); |
| 117 | +%noise=load('~/Work/Rai/LIGOfuture_data/dataNomaLIGO.txt'); |
| 118 | +noise=load('~/Work/Rai/LIGOfuture_data/dataEarly_low.txt'); |
| 119 | +[Rdetections,DetectableMergerRate]=... |
| 120 | + DetectionRate(zlistformation,Mtzlist,etalist,MergerRateByRedshiftByMtzByEta,zlistdetection,fin,noise,Dl,dVc) |
| 121 | + |
90 | 122 | if(makeplots==1), %make a set of default plots |
91 | 123 | MakePlots(M1,M2,Z,Tdelay,zlistformation,Zlist,SFR,Zweight,... |
92 | | - MergerRateByRedshiftByZ, 1); |
| 124 | + MergerRateByRedshiftByZ, Rdetections, DetectableMergerRate, Mtzlist, etalist, 1); |
93 | 125 | end; |
94 | 126 |
|
95 | 127 | end %end of CosmicHistoryIntegrator |
|
98 | 130 | %Load the data stored in COMPAS .h5 output format from a file |
99 | 131 | %Select only double compact object mergers of interest, and return the |
100 | 132 | %component masses, metallicities, and star formation to merger delay times |
101 | | -function [M1,M2,Z,Tdelay]=DataRead(file) |
| 133 | +function [M1,M2,Z,Tdelay, maxNS]=DataRead(file) |
102 | 134 | if(exist(file, 'file')~=2), |
103 | 135 | error('Input file does not exist'); |
104 | 136 | end; |
|
119 | 151 | %NSBH=(((type1==13) & (type2==14)) | ((type1==14) & (type2==13))); |
120 | 152 | %mergingDCO=mergingBNS | mergingNSBH | mergingBBH; |
121 | 153 | %BNScount=sum(mergingBNS); NSBHcount=sum(mergingNSBH); BBHcount=sum(mergingBBH); |
| 154 | + maxNS=max(max(mass1(type1==13)), max(mass2(type2==13))); |
122 | 155 | chirpmass=mass1.^0.6.*mass2.^0.6./(mass1+mass2).^0.2; |
123 | 156 | q=mass2./mass1; |
124 | 157 | seedCE=h5read(file,'/BSE_Common_Envelopes/SEED'); |
|
135 | 168 | M1=mass1(mergingDCO); M2=mass2(mergingDCO); Z=Zdco(mergingDCO); Tdelay=Ttotal(mergingDCO); |
136 | 169 | end %end of DataRead |
137 | 170 |
|
138 | | -%Compute the star formation rate and lookback time (in years) |
139 | | -%for an array of redshifts |
140 | | -function [tL]=Cosmology(zvec) |
| 171 | +%Compute the lookback time (yr), lumionosity distance (Mpc), and comoving |
| 172 | +%volume (Mpc^3) for an array of redshifts |
| 173 | +function [tL, Dl, dVc]=Cosmology(zvec) |
141 | 174 | global Mpcm |
142 | 175 | global Mpc |
143 | 176 | global yr |
|
152 | 185 | E=sqrt(OmegaM.*(1+zvec).^3+OmegaL); %Hogg, astro-ph/9905116, Eq. 14 |
153 | 186 | Dc=Dh*dz*cumsum(1./E); %Hogg, Eq. 15 |
154 | 187 | Dm=Dc; %Hogg, Eq. 16, k=0; |
155 | | - Dl=(1+zvec).*Dm; %Hogg, Eq. 20 |
| 188 | + Dl=(1+zvec).*Dm/Mpc; %Hogg, Eq. 20 |
156 | 189 | %see also Eq. (1.5.46) in Weinberg, "Cosmology", 2008 |
157 | 190 | dVc=4*pi*Dh^3*(OmegaM*(1+zvec).^3+OmegaL).^(-0.5).*(Dc/Dh).^2*dz/Mpc^3; |
158 | 191 | Vc=cumsum(dVc); |
|
193 | 226 | end %end of Metallicity |
194 | 227 |
|
195 | 228 |
|
| 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]=... |
| 232 | + DetectionRate(zlistformation,Mtzlist,etalist,MergerRateByRedshiftByMtzByEta,zlistdetection,freqfile,noisefile,Dl,dVc) |
| 233 | + fin=load('~/Work/Rai/LIGOfuture_data/freqVector.txt'); |
| 234 | + noise=load('~/Work/Rai/LIGOfuture_data/dataEarly_low.txt'); |
| 235 | + |
| 236 | + flow=10; |
| 237 | + df=1; |
| 238 | + f=flow:df:500; %BBH focussed |
| 239 | + Sf=interp1(fin, noise.^2, f); |
| 240 | + |
| 241 | + Ntheta=1e6; |
| 242 | + psi=rand(1,Ntheta)*pi; |
| 243 | + phi=rand(1,Ntheta)*2*pi; |
| 244 | + costh=rand(1,Ntheta); |
| 245 | + cosiota=rand(1,Ntheta); |
| 246 | + sinth=sqrt(1-costh.^2); |
| 247 | + siniota=sqrt(1-cosiota.^2); |
| 248 | + Fplus=1/2*(1+costh.^2).*cos(2*phi).*cos(2*psi)-costh.*sin(2*phi).*sin(2*psi); |
| 249 | + Fcross=1/2*(1+costh.^2).*cos(2*phi).*sin(2*psi)+costh.*sin(2*phi).*cos(2*psi); |
| 250 | + Theta=1/2*sqrt(Fplus.^2.*(1+cosiota.^2).^2+4*Fcross.^2.*cosiota.^2); |
| 251 | + Thetas=sort(Theta); |
| 252 | + |
| 253 | + |
| 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); |
| 258 | + integral=sum(4*Am.^2./Sf*df); |
| 259 | + SNRat1Mpc(i,j)=sqrt(integral); |
| 260 | + end; |
| 261 | + end; |
| 262 | + |
| 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 | + |
| 267 | + |
| 268 | + SNR8pre=0.1:0.1:1000; |
| 269 | + theta=1./SNR8pre; |
| 270 | + pdetect=1-interp1([0,Thetas,1],[(0:Ntheta)/Ntheta,1],theta); |
| 271 | + |
| 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 |
| 274 | + SNR8=SNR/8; |
| 275 | + 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); |
| 280 | + |
| 281 | +end %end of DetectionRate |
| 282 | + |
196 | 283 | %Make a set of default plots |
197 | | -function MakePlots(M1,M2,Z,Tdelay,zvec,Zlist,SFR,Zweight,... |
198 | | - MergerRateByRedshiftByZ, fignumber) |
| 284 | +function MakePlots(M1,M2,Z,Tdelay,zformationlist,Zlist,SFR,Zweight,... |
| 285 | + MergerRateByRedshiftByZ, Rdetections, DetectableMergerRate, zdetectionlist, Mtzlist, etazlist, fignumber) |
| 286 | + |
| 287 | + zvec=zformationlist; |
199 | 288 |
|
200 | 289 | figure(fignumber), clf(fignumber); %,colormap jet; |
201 | 290 | plot(zvec, sum(MergerRateByRedshiftByZ,2)*1e9, 'LineWidth', 3), hold on; |
|
0 commit comments