Commit a5cdfb71 authored by Francesco Zappa's avatar Francesco Zappa

More documentation, separate mass for alignes spin and mass for precessing binaries

parent b52703d0
......@@ -443,10 +443,13 @@ def m1m2_to_mnu(m1, m2):
nu = np.maximum(nu, 0.0)
return m,nu
def BHNS_mass(m1, m2, chi1, lam, beta=np.zeros(0)):
def BHNS_mass_precessing(m1, m2, chi1, lam, beta):
"""
Compute mass
beta: angle between orb. ang. mom. and BH spin (degrees)
Compute final black hole mass for precessing binaries
m1, m2 : respectively black hole and neutron star masses
chi1 : modulus of the dimensionless spin
lam : neutron star tidal polarizability
beta : angle between orb. ang. mom. and BH spin (degrees)
"""
## Vectorization
......@@ -454,9 +457,6 @@ def BHNS_mass(m1, m2, chi1, lam, beta=np.zeros(0)):
m2 = np.vectorize(float)(np.array(m2))
chi1 = np.vectorize(float)(np.array(chi1))
lam = np.vectorize(float)(np.array(lam))
if len(beta) == 0:
beta = np.zeros_like(lam)
beta = np.vectorize(float)(np.array(beta))
## Initial checks
......@@ -464,8 +464,8 @@ def BHNS_mass(m1, m2, chi1, lam, beta=np.zeros(0)):
raise ValueError("m1 must not be negative")
if np.any(m2<0):
raise ValueError("m2 must not be negative")
if np.any(abs(chi1)>1):
raise ValueError("chi1 has to be in [-1, 1]")
if np.any(chi1>1) or np.any(chi1<0):
raise ValueError("chi1 has to be in [0, 1], for spin below the orbital plane specify 90 < beta < 180.")
if np.any(lam<0):
raise ValueError("Lambda must not be negative")
......@@ -489,6 +489,48 @@ def BHNS_mass(m1, m2, chi1, lam, beta=np.zeros(0)):
return bbh_final_mass_non_precessing_UIB2016(m1, m2, chi1, 0.)[1]*model
def BHNS_mass_aligned(m1, m2, chi1, lam):
"""
Compute final black hole mass for aligned black hole spin
m1, m2 : respectively black hole and neutron star masses
chi1 : dimensionless spin, [-1,1] where negative value means antialigned to the orbital ang. mom.
lam : neutron star tidal polarizability
"""
## Vectorization
m1 = np.vectorize(float)(np.array(m1))
m2 = np.vectorize(float)(np.array(m2))
chi1 = np.vectorize(float)(np.array(chi1))
lam = np.vectorize(float)(np.array(lam))
## Initial checks
if np.any(m1<0):
raise ValueError("m1 must not be negative")
if np.any(m2<0):
raise ValueError("m2 must not be negative")
if np.any(abs(chi1)>1):
raise ValueError("chi1 has to be in [-1, 1]")
if np.any(lam<0):
raise ValueError("Lambda must not be negative")
## Fit parameters
massc = [-1.83417425e-03, 2.39226041e-03, 4.29407902e-03, 9.79775571e-03,
2.33868869e-07, -8.28090025e-07, -1.64315549e-06, 8.08340931e-06,
-2.00726981e-02, 1.31986011e-01, 6.50754064e-02, -1.42749961e-01]
m, nu = m1m2_to_mnu(m1, m2)
## Enforce BBH values
mask1 = np.logical_and(chi1<0, nu<0.188)
mask2 = chi1<-0.5
model = model3a(nu, chi1, lam, massc)
model[model > 1] = 1
model[mask1] = 1
model[mask2] = 1
return bbh_final_mass_non_precessing_UIB2016(m1, m2, chi1, 0.)[1]*model
def final_angle(m1, chi1, beta, momega_0):
'''Compute approximate final angle for precessing spin using Keplerian formulas as
the initial angle between the total initial ang. mom. J and the initial orb. ang. mom. L
......@@ -502,15 +544,14 @@ def final_angle(m1, chi1, beta, momega_0):
def BHNS_spin_precessing(m1, m2, chi1, lam, beta, momega_0):
"""
Compute final spin
Compute final black hole spin for precessing binaries
m1, m2 : respectively black hole and neutron star masses
chi1 : black hole dimensionless spin
lam : neutron star tidal polarizability
chi1 : modulus of the dimensionless spin
beta : angle between orb. ang. mom. and BH dimensionless spin (degrees)
chi1 : modulus of the dimensionless spin
lam : neutron star tidal polarizability
beta : angle between orb. ang. mom. and BH spin (degrees)
momega_0: initial orbital frequency multiplied by the total mass of the binary
"""
## Vectorization
degr_conv = 180./np.pi
m1 = np.vectorize(float)(np.array(m1))
......@@ -553,10 +594,10 @@ def BHNS_spin_precessing(m1, m2, chi1, lam, beta, momega_0):
def BHNS_spin_aligned(m1, m2, chi1, lam):
"""
Compute final spin, for aligned black hole spin
Compute final black hole spin for aligned black hole spin
m1, m2 : respectively black hole and neutron star masses
chi1 : black hole dimensionless spin
lam : neutron star tidal polarizability
chi1 : dimensionless spin, [-1,1] where negative value means antialigned to the orbital ang. mom.
lam : neutron star tidal polarizability
"""
## Vectorization
......@@ -594,10 +635,10 @@ def BHNS_spin_aligned(m1, m2, chi1, lam):
def BHNS_luminosity(m1, m2, chi1, lam):
"""
Compute peak luminosity, for aligned black hole spin
Compute GW peak luminosity for aligned black hole spin
m1, m2 : respectively black hole and neutron star masses
chi1 : black hole dimensionless spin
lam : neutron star tidal polarizability
chi1 : dimensionless spin, [-1,1] where negative value means antialigned to the orbital ang. mom.
lam : neutron star tidal polarizability
"""
## Vectorization
......@@ -640,8 +681,18 @@ if __name__=='__main__':
beta = np.array([80., 80., 80.])
M_omega0 = np.array([0.025, 0.025, 0.025])
'''Small examples'''
print BHNS_mass(m1, m2, chi1, lam)
print BHNS_mass(m1, m2, chi1, lam, beta)
## Final BH mass for aligned BH initial spins
print BHNS_mass_aligned(m1, m2, chi1, lam)
## Final BH mass for precessing binaries
print BHNS_mass_precessing(m1, m2, chi1, lam, beta)
## Final BH spin for aligned BH initial spins
print BHNS_spin_aligned(m1, m2, chi1, lam)
## Final BH spin for precessing binaries
print BHNS_spin_precessing(m1, m2, chi1, lam, beta, M_omega0)
## GW luminosity
print BHNS_luminosity(m1, m2, chi1, lam)
......@@ -462,10 +462,13 @@
" nu = np.maximum(nu, 0.0)\n",
" return m,nu\n",
"\n",
"def BHNS_mass(m1, m2, chi1, lam, beta=np.zeros(0)):\n",
"def BHNS_mass_precessing(m1, m2, chi1, lam, beta):\n",
" \"\"\"\n",
" Compute mass\n",
" beta: angle between orb. ang. mom. and BH spin (degrees)\n",
" Compute final black hole mass for precessing binaries\n",
" m1, m2 : respectively black hole and neutron star masses\n",
" chi1 : modulus of the dimensionless spin \n",
" lam : neutron star tidal polarizability \n",
" beta : angle between orb. ang. mom. and BH spin (degrees)\n",
" \"\"\"\n",
" \n",
" ## Vectorization\n",
......@@ -473,9 +476,6 @@
" m2 = np.vectorize(float)(np.array(m2))\n",
" chi1 = np.vectorize(float)(np.array(chi1))\n",
" lam = np.vectorize(float)(np.array(lam))\n",
" \n",
" if len(beta) == 0:\n",
" beta = np.zeros_like(lam) \n",
" beta = np.vectorize(float)(np.array(beta))\n",
" \n",
" ## Initial checks\n",
......@@ -483,8 +483,8 @@
" raise ValueError(\"m1 must not be negative\")\n",
" if np.any(m2<0):\n",
" raise ValueError(\"m2 must not be negative\")\n",
" if np.any(abs(chi1)>1):\n",
" raise ValueError(\"chi1 has to be in [-1, 1]\")\n",
" if np.any(chi1>1) or np.any(chi1<0):\n",
" raise ValueError(\"chi1 has to be in [0, 1], for spin below the orbital plane specify 90 < beta < 180.\")\n",
" if np.any(lam<0):\n",
" raise ValueError(\"Lambda must not be negative\")\n",
" \n",
......@@ -508,6 +508,48 @@
" \n",
" return bbh_final_mass_non_precessing_UIB2016(m1, m2, chi1, 0.)[1]*model\n",
"\n",
"def BHNS_mass_aligned(m1, m2, chi1, lam):\n",
" \"\"\"\n",
" Compute final black hole mass for aligned black hole spin\n",
" m1, m2 : respectively black hole and neutron star masses\n",
" chi1 : dimensionless spin, [-1,1] where negative value means antialigned to the orbital ang. mom. \n",
" lam : neutron star tidal polarizability \n",
" \"\"\"\n",
"\n",
"\n",
" ## Vectorization\n",
" m1 = np.vectorize(float)(np.array(m1))\n",
" m2 = np.vectorize(float)(np.array(m2))\n",
" chi1 = np.vectorize(float)(np.array(chi1))\n",
" lam = np.vectorize(float)(np.array(lam))\n",
"\n",
" ## Initial checks\n",
" if np.any(m1<0):\n",
" raise ValueError(\"m1 must not be negative\")\n",
" if np.any(m2<0):\n",
" raise ValueError(\"m2 must not be negative\")\n",
" if np.any(abs(chi1)>1):\n",
" raise ValueError(\"chi1 has to be in [-1, 1]\")\n",
" if np.any(lam<0):\n",
" raise ValueError(\"Lambda must not be negative\")\n",
"\n",
" ## Fit parameters\n",
" massc = [-1.83417425e-03, 2.39226041e-03, 4.29407902e-03, 9.79775571e-03,\n",
" 2.33868869e-07, -8.28090025e-07, -1.64315549e-06, 8.08340931e-06,\n",
" -2.00726981e-02, 1.31986011e-01, 6.50754064e-02, -1.42749961e-01]\n",
"\n",
" m, nu = m1m2_to_mnu(m1, m2)\n",
"\n",
" ## Enforce BBH values\n",
" mask1 = np.logical_and(chi1<0, nu<0.188)\n",
" mask2 = chi1<-0.5\n",
" model = model3a(nu, chi1, lam, massc)\n",
" model[model > 1] = 1\n",
" model[mask1] = 1\n",
" model[mask2] = 1\n",
"\n",
" return bbh_final_mass_non_precessing_UIB2016(m1, m2, chi1, 0.)[1]*model\n",
"\n",
"def final_angle(m1, chi1, beta, momega_0):\n",
" '''Compute approximate final angle for precessing spin using Keplerian formulas as\n",
" the initial angle between the total initial ang. mom. J and the initial orb. ang. mom. L \n",
......@@ -521,15 +563,14 @@
" \n",
"def BHNS_spin_precessing(m1, m2, chi1, lam, beta, momega_0):\n",
" \"\"\"\n",
" Compute final spin \n",
" Compute final black hole spin for precessing binaries\n",
" m1, m2 : respectively black hole and neutron star masses\n",
" chi1 : black hole dimensionless spin\n",
" lam : neutron star tidal polarizability\n",
" chi1 : modulus of the dimensionless spin\n",
" beta : angle between orb. ang. mom. and BH dimensionless spin (degrees)\n",
" chi1 : modulus of the dimensionless spin \n",
" lam : neutron star tidal polarizability \n",
" beta : angle between orb. ang. mom. and BH spin (degrees)\n",
" momega_0: initial orbital frequency multiplied by the total mass of the binary\n",
" \"\"\"\n",
" \n",
"\n",
" ## Vectorization\n",
" degr_conv = 180./np.pi\n",
" m1 = np.vectorize(float)(np.array(m1))\n",
......@@ -572,10 +613,10 @@
"\n",
"def BHNS_spin_aligned(m1, m2, chi1, lam):\n",
" \"\"\"\n",
" Compute final spin, for aligned black hole spin\n",
" Compute final black hole spin for aligned black hole spin\n",
" m1, m2 : respectively black hole and neutron star masses\n",
" chi1 : black hole dimensionless spin\n",
" lam : neutron star tidal polarizability\n",
" chi1 : dimensionless spin, [-1,1] where negative value means antialigned to the orbital ang. mom. \n",
" lam : neutron star tidal polarizability \n",
" \"\"\"\n",
" \n",
" ## Vectorization\n",
......@@ -613,10 +654,10 @@
"\n",
"def BHNS_luminosity(m1, m2, chi1, lam):\n",
" \"\"\"\n",
" Compute peak luminosity, for aligned black hole spin\n",
" Compute GW peak luminosity for aligned black hole spin\n",
" m1, m2 : respectively black hole and neutron star masses\n",
" chi1 : black hole dimensionless spin\n",
" lam : neutron star tidal polarizability\n",
" chi1 : dimensionless spin, [-1,1] where negative value means antialigned to the orbital ang. mom. \n",
" lam : neutron star tidal polarizability \n",
" \"\"\"\n",
" \n",
" ## Vectorization\n",
......@@ -649,12 +690,12 @@
" model[mask1] = 1\n",
" model[mask2] = 1\n",
" \n",
" return LpeakUIB2016(m1, m2, chi1, 0)[0]*model\n"
" return LpeakUIB2016(m1, m2, chi1, 0)[0]*model"
]
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 5,
"metadata": {},
"outputs": [
{
......@@ -663,7 +704,8 @@
"text": [
"[3.83408237 6.02286119 6.91767975]\n",
"[4.01880681 6.35220114 7.30659329]\n",
"(array([0.80178672, 0.8681759 , 0.90833044]), array([6.66613655, 5.43639423, 2.05333033]))\n",
"[0.94431687 0.92332301 0.91443582]\n",
"(array([0.67288684, 0.60139493, 0.54997457]), array([2.55650024, 2.55650024, 2.55650024]))\n",
"[1.06117197e-04 7.91427714e-05 1.07641419e-04]\n"
]
}
......@@ -673,14 +715,32 @@
"m2 = np.array([1.4, 1.6, 1.5])\n",
"chi1 = np.array([0.9, 0.9, 0.9])\n",
"lam = np.array([500., 1000., 1000.])\n",
"beta = np.array([80., 80., 80.])\t\n",
"M_omega0 = np.array([0.025, 0.025, 0.025])\n",
"\n",
"'''Small examples'''\n",
"## Final BH mass for aligned BH initial spins\n",
"print BHNS_mass_aligned(m1, m2, chi1, lam)\n",
"\n",
"## Final BH mass for precessing binaries\n",
"print BHNS_mass_precessing(m1, m2, chi1, lam, beta)\n",
"\n",
"## Final BH spin for aligned BH initial spins\n",
"print BHNS_spin_aligned(m1, m2, chi1, lam)\n",
"\n",
"print BHNS_mass(m1, m2, chi1, lam)\n",
"print BHNS_mass(m1, m2, chi1, lam, np.array([80., 80., 80.]))\n",
"print BHNS_spin_precessing(m1, m2, chi1, lam, np.array([50., 30., 10.]), np.array([0.025, 0.025, 0.025]))\n",
"print BHNS_luminosity(m1, m2, chi1, lam)"
"## Final BH spin for precessing binaries\n",
"print BHNS_spin_precessing(m1, m2, chi1, lam, beta, M_omega0)\n",
"\n",
"## GW luminosity \n",
"print BHNS_luminosity(m1, m2, chi1, lam)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment