Skip to content

Commit ce30ae6

Browse files
author
Ilya Mandel
committed
CosmicIntegrator cleaning
1 parent c030f64 commit ce30ae6

File tree

1 file changed

+31
-24
lines changed

1 file changed

+31
-24
lines changed

compas_matlab_utils/CosmicHistoryIntegrator.m

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
function [Zlist, MergerRateByRedshiftByZ, MergerRateByRedshiftByMtByEta, Mtlist, etalist, SFR, Rdetections, DetectableMergerRate, zlistdetection, x]=...
1+
function [SFR, Zlist, Mtlist, etalist, FormationRateByRedshiftByZ, FormationRateByRedshiftByMtByEta, ...
2+
MergerRateByRedshiftByZ, MergerRateByRedshiftByMtByEta, zlistdetection, Rdetections, DetectableMergerRate]=...
23
CosmicHistoryIntegrator(filename, zlistformation, zmaxdetection, Msimulated, makeplots)
34
% Integrator for the binary black hole merger rate over cosmic history
45
% COMPAS (Compact Object Mergers: Population Astrophysics and Statistics)
56
% software package
67
%
78
% USAGE:
8-
% [Zlist, MergerRateByRedshiftByZ, SFR, Zweight, Rdetections, DetectableMergerRate, Mtzlist, etalist, zlistdetection]=...
9+
% [SFR, Zlist, Mtlist, etalist, FormationRateByRedshiftByZ, FormationRateByRedshiftByMtByEta, ...
10+
% MergerRateByRedshiftByZ, MergerRateByRedshiftByMtByEta, zlistdetection, Rdetections, DetectableMergerRate]]=...
911
% CosmicHistoryIntegrator(filename, zlistformation, zmaxdetection, Msimulated [,makeplots])
1012
%
1113
% INPUTS:
@@ -19,32 +21,44 @@
1921
% makeplots: if set to 1, generates a set of useful plots (default = 0)
2022
%
2123
% OUTPUTS:
24+
% SFR is a vector of size length(zlistformation) containing the star formation rate
25+
% (solar masses per Mpc^3 of comoving volume per year of source time)
2226
% Zlist is a vector of metallicities, taken from the COMPAS run input file
27+
% Mtlist is a list of total mass bins
28+
% etalist is a list of symmetric mass ratio bins
29+
% FormationRateByRedshiftByZ is a matrix of size length(zformationlist) X length(Zlist)
30+
% which contains a formation rate of merging double compact objects in the given redshift
31+
% and metallicity bin, in units of formed DCOs per Mpc^3 of comoving volume per
32+
% year of source time
33+
% FormationRateByRedshiftByMtByEta is a matrix of size length(zformationlist)
34+
% X length(Mtlist) X length(etalist) which contains a formation rate of merging double compact objects
35+
% in the given redshift, total mass and eta bin, in units of formed DCOs per Mpc^3
36+
% of comoving volume per year of source time
2337
% MergerRateByRedshiftByZ is a matrix of size length(zformationlist) X length(Zlist)
24-
% which contains a merger rate of merging compact objects in the given redshift
38+
% which contains a merger rate of double compact objects in the given redshift
2539
% and metallicity bin, in units of mergers per Mpc^3 of comoving volume per
2640
% 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
41+
% MergerRateByRedshiftByMtByEta is a matrix of size length(zformationlist)
42+
% X length(Mtlist) X length(etalist) which contains a merger rate of double compact objects
2943
% in the given redshift, total mass and eta bin, in units of mergers per Mpc^3
3044
% 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
33-
% SFR is a vector of size length(zlistformation) containing the star formation rate
34-
% (solar masses per Mpc^3 of comoving volume per year of source time)
45+
% zlistdetection is a vector of redshifts at which detection rates are
46+
% computed (a subset of zlistformation going up to zmaxdetection)
3547
% Rdetection is a matrix of size length(zlistdetection) X length(Mtlist) X
3648
% length(etalist) containing the detection rate per year of observer time
3749
% from a given redshift bin and total mass and symmetric mass ratio pixel
3850
% DetectableMergerRate is a matrix of the same size as Rdetection but
3951
% containing the intrinsic rate of detectable mergers per Mpc^3 of comoving
4052
% volume per year of source time
41-
% zlistdetection is a vector of redshifts at which detection rates are
42-
% computed (a subset of zlistformation going up to zmaxdetection)
53+
4354
%
4455
% EXAMPLE:
4556
% zlist=0:0.01:10;
46-
% [Zlist, MergerRateByRedshiftByZ, MergerRateByRedshiftByMtByEta, Mtlist, etalist, SFR, Rdetections, DetectableMergerRate, zlistdetection,] = ...
57+
% [SFR, Zlist, Mtlist, etalist, FormationRateByRedshiftByZ, FormationRateByRedshiftByMtByEta, ...
58+
% MergerRateByRedshiftByZ, MergerRateByRedshiftByMtByEta, zlistdetection, Rdetections, DetectableMergerRate]=...
4759
% CosmicHistoryIntegrator('~/Work/COMPASresults/runs/Zdistalpha1-031803.h5', zlist, 1.5, 90e6, 1);
60+
% figure(10), semilogy(zlist, sum(MergerRateByRedshiftByZ,2)*1e9,'LineWidth',3), set(gca,'FontSize',20),
61+
% xlabel('Redshift z'), ylabel('Formation rate of merging DCO per Gpc^3 per yr')
4862
%
4963

5064

@@ -76,19 +90,23 @@
7690
dz=zlistformation(2)-zlistformation(1);
7791
etalist=0.01:0.01:0.25;
7892
Mtlist=1:1:ceil(max(M1+M2));
93+
FormationRateByRedshiftByZ=zeros(length(zlistformation),length(Zlist));
94+
FormationRateByRedshiftByMtByEta=zeros(length(zlistformation),length(Mtlist),length(etalist));
7995
MergerRateByRedshiftByZ=zeros(length(zlistformation),length(Zlist));
8096
MergerRateByRedshiftByMtByEta=zeros(length(zlistformation),length(Mtlist),length(etalist));
8197
x=zeros(size(M1));
8298
for(i=1:length(M1)),
8399
Zcounter=find(Zlist>=Z(i),1);
84100
eta=M1(i)*M2(i)/(M1(i)+M2(i))^2;
85101
etaindex=ceil(eta*100);
102+
Mtindex=ceil(M1(i)+M2(i));
103+
FormationRateByRedshiftByZ(:,Zcounter)=transpose(SFR).*Zweight(:,Zcounter)/Msimulated;
104+
FormationRateByRedshiftByMtByEta(:,Mtindex,etaindex)=transpose(SFR).*Zweight(:,Zcounter)/Msimulated;
86105
tLform=tL+Tdelay(i); %lookback time of when binary would have to form in order to merge at lookback time tL
87106
firsttooearlyindex=find((tLform)>max(tL),1);
88107
if(isempty(firsttooearlyindex)), firsttooearlyindex=length(tL)+1; end;
89108
zForm=interp1(tL,zlistformation,tLform(1:firsttooearlyindex-1));
90109
zFormindex=ceil((zForm-zlistformation(1))./dz)+1;
91-
Mtindex=ceil(M1(i)+M2(i));
92110
if(~isempty(zFormindex))
93111
x(i)=SFR(zFormindex(1))*Zweight(zFormindex(1),Zcounter)/Msimulated;
94112
MergerRateByRedshiftByZ(1:firsttooearlyindex-1,Zcounter)=...
@@ -98,17 +116,6 @@
98116
MergerRateByRedshiftByMtByEta(1:firsttooearlyindex-1,Mtindex,etaindex) + ...
99117
transpose(SFR(zFormindex)).*Zweight(zFormindex,Zcounter)/Msimulated;
100118
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;
112119
end;
113120

114121
zlistdetection=zlistformation(1:find(zlistformation<=zmaxdetection,1,"last"));

0 commit comments

Comments
 (0)