def plot_pbh_per_mass(redshift): """Plot the PBH merger rate per unit volume as a function of halo mass""" mass = np.logspace(2, 15) hh = NFWHalo(redshift, conc_model="ludlow") hh.conc_model = concentration.LudlowConcentration(hh.overden.Dofz) plt.loglog(mass, hh.halomergerratepervolume(mass), ls='-', label="Ludlow concentration") hh.conc_model = concentration.PradaConcentration(hh.overden.omega_matter0) plt.loglog(mass, hh.halomergerratepervolume(mass), ls='--', label="Prada concentration") hh.conc_model = concentration.LudlowConcentration(hh.overden.Dofz) hh.mass_function = hh.press_schechter plt.loglog(mass, hh.halomergerratepervolume(mass), ls=':', label="Press-Schechter m.f.") hh.mass_function = hh.jenkins plt.loglog(mass, hh.halomergerratepervolume(mass), ls='-.', label="Jenkins m.f.") plt.xlim(500, 1e15) plt.xticks(np.logspace(3, 15, 5)) plt.xlabel(r"$M_\mathrm{vir}$ ($M_\odot/h$)") plt.ylabel(r"Merger rate (yr$^{-1}$ Gpc$^{-3}$)") plt.ylim(1e-8, 1) #plt.title("Total mergers is area under this curve") plt.legend(loc=0) plt.savefig("volumemergerrate.pdf") plt.clf()
def __init__(self, *args, conc_model="ludlow", conc_value=1., hubble=0.67, **kwargs): self.ureg = pint.UnitRegistry() self.ureg.define("Msolar = 1.98855*10**30 * kilogram") #Mpc newton's constant and light speed are already defined. #Hubble constant and related objects! #The try except is because the method names change between pint 0.6 and pint 0.8 try: self.ureg.define( pint.unit.UnitDefinition('hub', '', (), pint.unit.ScaleConverter(hubble))) except AttributeError: self.ureg.define( pint.definitions.UnitDefinition( 'hub', '', (), pint.converters.ScaleConverter(hubble))) self.ureg.define("Msolarh = Msolar / hub") self.ureg.define("Mpch = Mpc / hub") #Factor of R_s at which the maximum circular velocity of the halo is reached. self.dmax = 2.1626 super().__init__(*args, **kwargs) if conc_model == "ludlow": self.conc_model = concentration.LudlowConcentration( self.overden.Dofz) elif conc_model == "prada": self.conc_model = concentration.PradaConcentration( self.overden.omega_matter0) else: self.conc_model = concentration.ConstantConcentration(conc_value)
def plot_concentration_vs_mass(redshift): """Plot the concentration as a function of halo mass""" mass = np.logspace(2,16) hh = NFWHalo(redshift) plt.loglog(mass, hh.concentration(mass), ls='-', label="Ludlow concentration") hh.conc_model = concentration.PradaConcentration(hh.overden.omega_matter0) plt.loglog(mass, hh.concentration(mass), ls='--', label="Prada concentration") plt.xlim(500,1e16) plt.xticks(np.logspace(3,15,5)) plt.xlabel(r"$M_\mathrm{vir}$ ($M_\odot/h$)") plt.ylabel(r"Concentration") plt.ylim(1e-8, 1) plt.legend(loc=0) plt.savefig("concentration.pdf") plt.clf()
def merger_at_z(z, conc="Ludlow", halo="Einasto"): """Compute the merger rate at a given redshift""" if halo=="Einasto": hh = EinastoHalo(z) else: hh = NFWHalo(z) if conc=="Ludlow": hh.conc_model = concentration.LudlowConcentration(hh.overden.Dofz) else: hh.conc_model = concentration.PradaConcentration(hh.overden.omega_matter0) merg = hh.mergerpervolume(400) #Note that this is Gpc/yr in #the rest frame of the event. #For the rest frame of the observer, #you need to account for time dilation. return merg.to('Gpc**(-3) year**(-1)') / (1+z)
def plot_pbh_halo(redshift): """Plot the PBH merger rate as a function of halo mass.""" mass = np.logspace(2, 15) hh = NFWHalo(redshift) hh.conc_model = concentration.LudlowConcentration(hh.overden.Dofz) pbhrate = hh.pbhpbhrate(mass) hh.conc_model = concentration.PradaConcentration(hh.overden.omega_matter0) pbhrate_prada = hh.pbhpbhrate(mass) plt.loglog(mass, pbhrate, ls='-', label="Ludlow") plt.loglog(mass, pbhrate_prada, ls='--', label="Prada") plt.loglog(mass, hh.pbhpbhrate(1e9) * mass / 1e9, ls='-.', color="black") plt.xlabel(r"$M_\mathrm{vir}$ ($M_\odot/h$)") plt.ylabel(r"Merger rate per halo (yr$^{-1}$)") plt.xlim(300, 1e15) plt.ylim(1e-15, 1e-10) plt.xticks(np.logspace(3, 15, 5)) plt.legend(loc=0) plt.savefig("halomergerrate.pdf") plt.clf()