|
1 | | -function [Zlist, MergerRateByRedshiftByZ, SFRfractionZ]=... |
| 1 | +function [Zlist, MergerRateByRedshiftByZ, SFR, Zweight]=... |
2 | 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 |
6 | 6 | % |
7 | 7 | % USAGE: |
8 | 8 | % [Zlist, MergerRateByRedshiftByZ]=... |
9 | | -% CosmicHistoryIntegrator(filename, zlistformation, zlistmerger, [,makeplots]) |
| 9 | +% CosmicHistoryIntegrator(filename, zlistformation, zlistmerger, [,makeplots, filename2, name1, name2]) |
10 | 10 | % |
11 | 11 | % INPUTS: |
12 | 12 | % filename: name of population synthesis input file |
|
25 | 25 | % year of source time |
26 | 26 | % |
27 | 27 | % EXAMPLE: |
| 28 | +% CosmicHistoryIntegrator('~/Work/COMPASresults/runs/Zdistalpha1-031803.h5', ... |
| 29 | +% zlist, zlist, 90e6, 1, '~/Work/COMPASresults/runs/Zdist2stage-031803.h5', 'Default', '2 Stage') |
28 | 30 | % zlist=0:0.1:5; |
29 | 31 | % filename=['~/Work/COMPASresults/popsynth/runs/',... |
30 | 32 | % '20170628-Coen-Pessimistic/AllMergers.dat']; |
|
60 | 62 | if (nargin<5), makeplots=0; end; |
61 | 63 |
|
62 | 64 | %cosmology calculator |
63 | | -[tL]=Cosmology(zlistformation); |
| 65 | +[tL]=Cosmology(zlistformation); |
64 | 66 | %load COMPAS data |
65 | 67 | [M1,M2,Z,Tdelay]=DataRead(filename); |
66 | | -Zlist=unique(Z); |
67 | 68 | %metallicity-specific SFR |
68 | | -[SFR,Zweight]=Metallicity(Zlist,zlistformation); |
| 69 | +[SFR,Zlist,Zweight]=Metallicity(zlistformation,min(Z),max(Z)); |
69 | 70 |
|
70 | 71 |
|
71 | 72 | %Consider the contribution of every simulated binary to the merger rate |
|
76 | 77 | tLmerge=tL(floor(zlistformation/dz)+1); |
77 | 78 | MergerRateByRedshiftByZ=zeros(length(zlistformation),length(Zlist)); |
78 | 79 | for(i=1:length(M1)), |
79 | | - Zcounter=find(Zlist==Z(i)); |
| 80 | + Zcounter=find(Zlist>=Z(i),1); |
80 | 81 | zformindex=find(tL>=Tdelay(i),1); |
81 | 82 | for(k=1:length(zlistformation)), |
82 | 83 | zformindex=find(tL>=(Tdelay(i)+tLmerge(k)),1); |
|
88 | 89 |
|
89 | 90 | if(makeplots==1), %make a set of default plots |
90 | 91 | MakePlots(M1,M2,Z,Tdelay,zlistformation,Zlist,SFR,Zweight,... |
91 | | - MergerRateByRedshiftByZ); |
| 92 | + MergerRateByRedshiftByZ, 1); |
92 | 93 | end; |
93 | 94 |
|
94 | 95 | end %end of CosmicHistoryIntegrator |
|
161 | 162 |
|
162 | 163 |
|
163 | 164 | %Compute the weight of each star-forming metallicity as a function of redshift |
164 | | -function [SFR,Zweight]=Metallicity(Zvec, zvec) |
| 165 | +function [SFR,Zvec,Zweight]=Metallicity(zvec,minZ,maxZ) |
165 | 166 | %M_/odot per Mpc^3 per year -- Neijssel+ 2019 preferred model |
166 | 167 | %would be SFR=0.015*(1+zvec).^2.7./(1+((1+zvec)/2.9).^5.6) in Madau & Dickinson, 2014, (15) |
167 | 168 | SFR=0.01*(1+zvec).^2.77./(1+((1+zvec)/2.9).^4.7); |
168 | | - if(length(Zvec)>1), |
| 169 | + if(maxZ>minZ), |
169 | 170 | Zmean=0.035.*10.^(-0.23*zvec); |
170 | 171 | Zmu=log(Zmean)-0.39^2/2; |
171 | | - dlogZ=0.01; |
| 172 | + dlogZ=0.1; |
172 | 173 | logZvec=-12:dlogZ:0; %natural log |
173 | 174 | dPdlogZ=1/0.39/sqrt(2*pi)*exp(-(logZvec'-Zmu).^2/2/0.39^2); |
174 | 175 | dPdlogZ=dPdlogZ./(sum(dPdlogZ,1)*dlogZ); %normalise |
175 | | - Zrange=log(max(Zvec))-log(min(Zvec)); %ugly correction for not including tails |
| 176 | + minlogZindex=find(exp(logZvec)>=minZ,1, 'first'); |
| 177 | + maxlogZindex=find(exp(logZvec)>=maxZ,1, 'first'); |
| 178 | + Zrange=logZvec(maxlogZindex)-logZvec(minlogZindex); %ugly correction for not including tails |
176 | 179 | PdrawZ=1/Zrange; |
177 | | - minlogZindex=find(exp(logZvec)>=min(Zvec),1, 'first'); |
178 | | - maxlogZindex=find(exp(logZvec)>=max(Zvec),1, 'last'); |
| 180 | + Zvec=exp(logZvec(minlogZindex:maxlogZindex)); |
179 | 181 | dPdlogZ(minlogZindex,:)=dPdlogZ(minlogZindex,:)+sum(dPdlogZ(1:minlogZindex,:),1)*dlogZ/(sum(Zvec==min(Zvec))/length(Zvec))*PdrawZ; |
180 | 182 | dPdlogZ(maxlogZindex,:)=dPdlogZ(maxlogZindex,:)+sum(dPdlogZ(maxlogZindex:end,:),1)*dlogZ/(sum(Zvec==max(Zvec))/length(Zvec))*PdrawZ; |
181 | 183 | dPdlogZ(1:minlogZindex,:)=0; dPdlogZ(maxlogZindex:size(dPdlogZ,1),:)=0; |
|
185 | 187 | Zweight(:,i)=dPdlogZ(index,:)*dlogZ; |
186 | 188 | end; |
187 | 189 | else %relevant for single-metallicity runs -- just give all binaries the same unit weight |
188 | | - Zweight(1:length(zvec),1:length(Zvec))=1; |
| 190 | + Zvec=minZ; |
| 191 | + Zweight=ones(length(zvec),1); |
189 | 192 | end; |
190 | 193 | end %end of Metallicity |
191 | 194 |
|
192 | 195 |
|
193 | 196 | %Make a set of default plots |
194 | 197 | function MakePlots(M1,M2,Z,Tdelay,zvec,Zlist,SFR,Zweight,... |
195 | | - MergerRateByRedshiftByZ) |
196 | | - |
197 | | - figure(1),colormap jet; |
198 | | - plot(zvec, MergerRateByRedshiftByZ*1e9, 'LineWidth', 2), |
199 | | - legend(num2str(Zlist)), |
| 198 | + MergerRateByRedshiftByZ, fignumber) |
| 199 | + |
| 200 | + figure(fignumber), clf(fignumber); %,colormap jet; |
| 201 | + plot(zvec, sum(MergerRateByRedshiftByZ,2)*1e9, 'LineWidth', 3), hold on; |
| 202 | + plot(zvec, sum(MergerRateByRedshiftByZ(:,Zlist<=0.001),2)*1e9, 'LineWidth', 1); |
| 203 | + plot(zvec, sum(MergerRateByRedshiftByZ(:,Zlist>0.001 & Zlist<0.01),2)*1e9, 'LineWidth', 1); |
| 204 | + plot(zvec, sum(MergerRateByRedshiftByZ(:,Zlist>=0.01),2)*1e9, 'LineWidth', 1); hold off; |
| 205 | + legend('Total rate', 'From Z<=0.001', 'From 0.001<Z<0.01', 'From Z>=0.01'), |
200 | 206 | set(gca, 'FontSize', 20); %for labels |
201 | 207 | xlabel('z'), |
202 | 208 | ylabel('DCO merger rate per Gpc^3 per yr') |
203 | 209 | disp(['Total DCO merger rate at z=0: ', ... |
204 | | - num2str(sum(MergerRateByRedshiftByZ(:,1))),... |
| 210 | + num2str(1e9*sum(MergerRateByRedshiftByZ(1,:))),... |
205 | 211 | ' per Gpc^3 per year']); |
206 | 212 |
|
207 | | - figure(2), colormap jet; |
208 | | - scatter(M1,M2,20,log(Z)/log(10),'filled'); |
| 213 | + figure(2); |
| 214 | + colormap jet; |
| 215 | + scatter(log10(M1),log10(M2),20,log(Z)/log(10),'filled'); |
209 | 216 | set(gca, 'FontSize', 20); %for labels |
210 | 217 | H=colorbar; H.Label.String='log_{10} metallicity'; |
211 | | - xlabel('Primary mass [M_o]'), ylabel('Secondary mass [M_o]'); |
| 218 | + xlabel('log_{10}(M_1/M_o)'), ylabel('log_{10}(M_2/M_o)'); |
212 | 219 |
|
213 | | - figure(3), colormap jet; |
| 220 | + figure(3); |
| 221 | + colormap jet; |
214 | 222 | scatter(M1+M2,log10(Tdelay/1e6),20,log10(Z),'filled'); |
215 | 223 | set(gca, 'FontSize', 20); %for labels |
216 | 224 | H=colorbar; H.Label.String='log_{10} metallicity'; |
217 | 225 | xlabel('Total DCO mass [M_o]'), ylabel('log_{10}(Tdelay/Myr)'); |
| 226 | + |
218 | 227 |
|
219 | | - figure(4), colormap jet; |
220 | | - plot(zvec, SFR*1e9) |
| 228 | + figure(fignumber+3), clf(fignumber+3); |
| 229 | + plot(zvec, SFR*1e9, 'LineWidth', 3); hold on; |
| 230 | + plot(zvec, SFR'.*sum(Zweight(:,Zlist<=0.001),2)*1e9, 'LineWidth', 1); |
| 231 | + plot(zvec, SFR'.*sum(Zweight(:,Zlist>0.001&Zlist<0.01),2)*1e9, 'LineWidth', 1); |
| 232 | + plot(zvec, SFR'.*sum(Zweight(:,Zlist>=0.01),2)*1e9, 'LineWidth', 1); hold off; |
| 233 | + legend('Total rate', 'From Z<=0.001', 'From 0.001<Z<0.01', 'From Z>=0.01'), |
221 | 234 | set(gca, 'FontSize', 20); %for labels |
222 | 235 | xlabel('z'), ylabel('Star-formation rate, M_o per Gpc^3 per yr'); |
223 | 236 |
|
224 | 237 | figure(5), colormap jet; |
225 | | - plot(zvec, Zweight) |
| 238 | + plot(zvec, Zweight, 'LineWidth', 3) |
226 | 239 | set(gca, 'FontSize', 20); %for labels |
227 | 240 | legend(num2str(Zlist)) |
228 | 241 | xlabel('z'), ylabel('Z-specific SFR weight'); |
|
0 commit comments