From ed86fa7cd8fa204e8d17e18a8260f9a68a580246 Mon Sep 17 00:00:00 2001 From: Aleyna Akyuz Date: Wed, 7 Aug 2024 14:49:25 -0400 Subject: [PATCH 1/8] adding delta_lambda_tilde and conversions --- pycbc/conversions.py | 53 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/pycbc/conversions.py b/pycbc/conversions.py index 3daf5c8a1b0..815a11ba112 100644 --- a/pycbc/conversions.py +++ b/pycbc/conversions.py @@ -435,6 +435,55 @@ def lambda_tilde(mass1, mass2, lambda1, lambda2): p2 = (1 - 4 * eta)**0.5 * (1 + 9 * eta - 11 * eta ** 2.0) * (ldiff) return formatreturn(8.0 / 13.0 * (p1 + p2), input_is_array) +def delta_lambda_tilde(mass1, mass2, lambda1, lambda2): + m1, m2, lambda1, lambda2, input_is_array = ensurearray( + mass1, mass2, lambda1, lambda2) + lsum = lambda1 + lambda2 + ldiff, _ = ensurearray(lambda1 - lambda2) + mask = m1 < m2 + ldiff[mask] = -ldiff[mask] + eta = eta_from_mass1_mass2(m1, m2) + p1 = numpy.sqrt(1 - 4*eta) * (1 - (13272/1319)*eta + (8944/1319)*eta**2) * lsum + p2 = (1 - (15910/1319)*eta + (32850/1319)*eta**2 + (3380/1319)*eta**3) * ldiff + return formatreturn(1 / 2 * (p1 + p2), input_is_array) + +def lambda1_from_delta_lambda_tilde_lambda_tilde(delta_lambda_tilde, lambda_tilde, mass1, mass2): + m1, m2, delta_lambda_tilde, lambda_tilde, input_is_array = ensurearray( + mass1, mass2, delta_lambda_tilde, lambda_tilde) + + eta = eta_from_mass1_mass2(m1, m2) + + p1 = 1 + 7.0*eta - 31*eta**2.0 + p2 = (1 - 4*eta)**0.5 * (1 + 9*eta - 11*eta**2.0) + p3 = (1 - 4*eta)**0.5 * (1 - 13272/1319*eta + 8944/1319*eta**2) + p4 = 1 - (15910/1319)*eta + (32850/1319)*eta**2 + (3380/1319)*eta**3 + + amp = 1/((p1*p4)-(p2*p3)) + + l_tilde_lambda1 = 13/16 * (p3-p4) * lambda_tilde + l_delta_tilde_lambda1 = (p1-p2) * delta_lambda_tilde + + lambda1 = formatreturn(amp * (l_delta_tilde_lambda1 - l_tilde_lambda1), input_is_array) + return lambda1 + +def lambda2_from_delta_lambda_tilde_lambda_tilde(delta_lambda_tilde, lambda_tilde, mass1, mass2): + m1, m2, delta_lambda_tilde, lambda_tilde, input_is_array = ensurearray( + mass1, mass2, delta_lambda_tilde, lambda_tilde) + + eta = eta_from_mass1_mass2(m1, m2) + + p1 = 1 + 7.0*eta - 31*eta**2.0 + p2 = (1 - 4*eta)**0.5 * (1 + 9*eta - 11*eta**2.0) + p3 = (1 - 4*eta)**0.5 * (1 - 13272/1319*eta + 8944/1319*eta**2) + p4 = 1 - (15910/1319)*eta + (32850/1319)*eta**2 + (3380/1319)*eta**3 + + amp = 1/((p1*p4)-(p2*p3)) + + l_tilde_lambda2 = 13/16 * (p3+p4) * lambda_tilde + l_delta_tilde_lambda2 = (p1+p2) * delta_lambda_tilde + + lambda2 = formatreturn(amp * (l_tilde_lambda2 - l_delta_tilde_lambda2), input_is_array) + return lambda2 def lambda_from_mass_tov_file(mass, tov_file, distance=0.): """Return the lambda parameter(s) corresponding to the input mass(es) @@ -1774,5 +1823,7 @@ def nltides_gw_phase_diff_isco(f_low, f0, amplitude, n, m1, m2): 'nltides_gw_phase_diff_isco', 'spin_from_pulsar_freq', 'freqlmn_from_other_lmn', 'taulmn_from_other_lmn', 'remnant_mass_from_mass1_mass2_spherical_spin_eos', - 'remnant_mass_from_mass1_mass2_cartesian_spin_eos' + 'remnant_mass_from_mass1_mass2_cartesian_spin_eos', + 'lambda1_from_delta_lambda_tilde_lambda_tilde', + 'lambda2_from_delta_lambda_tilde_lambda_tilde' ] From baeabcc21ca31c01c33726774d6399f60f9d1a05 Mon Sep 17 00:00:00 2001 From: Aleyna Akyuz Date: Mon, 2 Sep 2024 10:39:59 -0400 Subject: [PATCH 2/8] style fixes --- pycbc/conversions.py | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/pycbc/conversions.py b/pycbc/conversions.py index 815a11ba112..8fbd0bff032 100644 --- a/pycbc/conversions.py +++ b/pycbc/conversions.py @@ -443,46 +443,56 @@ def delta_lambda_tilde(mass1, mass2, lambda1, lambda2): mask = m1 < m2 ldiff[mask] = -ldiff[mask] eta = eta_from_mass1_mass2(m1, m2) - p1 = numpy.sqrt(1 - 4*eta) * (1 - (13272/1319)*eta + (8944/1319)*eta**2) * lsum - p2 = (1 - (15910/1319)*eta + (32850/1319)*eta**2 + (3380/1319)*eta**3) * ldiff + p1 = ( + numpy.sqrt(1 - 4*eta) * + (1 - (13272/1319)*eta + + (8944/1319)*eta**2) * lsum + ) + p2 = ( + (1 - (15910/1319)*eta + + (32850/1319)*eta**2 + + (3380/1319)*eta**3) * ldiff + ) return formatreturn(1 / 2 * (p1 + p2), input_is_array) -def lambda1_from_delta_lambda_tilde_lambda_tilde(delta_lambda_tilde, lambda_tilde, mass1, mass2): +def lambda1_from_delta_lambda_tilde_lambda_tilde( + delta_lambda_tilde, + lambda_tilde, + mass1, + mass2): m1, m2, delta_lambda_tilde, lambda_tilde, input_is_array = ensurearray( mass1, mass2, delta_lambda_tilde, lambda_tilde) - eta = eta_from_mass1_mass2(m1, m2) - p1 = 1 + 7.0*eta - 31*eta**2.0 p2 = (1 - 4*eta)**0.5 * (1 + 9*eta - 11*eta**2.0) p3 = (1 - 4*eta)**0.5 * (1 - 13272/1319*eta + 8944/1319*eta**2) p4 = 1 - (15910/1319)*eta + (32850/1319)*eta**2 + (3380/1319)*eta**3 - amp = 1/((p1*p4)-(p2*p3)) - l_tilde_lambda1 = 13/16 * (p3-p4) * lambda_tilde l_delta_tilde_lambda1 = (p1-p2) * delta_lambda_tilde - lambda1 = formatreturn(amp * (l_delta_tilde_lambda1 - l_tilde_lambda1), input_is_array) return lambda1 -def lambda2_from_delta_lambda_tilde_lambda_tilde(delta_lambda_tilde, lambda_tilde, mass1, mass2): +def lambda2_from_delta_lambda_tilde_lambda_tilde( + delta_lambda_tilde, + lambda_tilde, + mass1, + mass2): m1, m2, delta_lambda_tilde, lambda_tilde, input_is_array = ensurearray( mass1, mass2, delta_lambda_tilde, lambda_tilde) - - eta = eta_from_mass1_mass2(m1, m2) - + eta = eta_from_mass1_mass2(m1, m2) p1 = 1 + 7.0*eta - 31*eta**2.0 p2 = (1 - 4*eta)**0.5 * (1 + 9*eta - 11*eta**2.0) p3 = (1 - 4*eta)**0.5 * (1 - 13272/1319*eta + 8944/1319*eta**2) p4 = 1 - (15910/1319)*eta + (32850/1319)*eta**2 + (3380/1319)*eta**3 - amp = 1/((p1*p4)-(p2*p3)) - l_tilde_lambda2 = 13/16 * (p3+p4) * lambda_tilde l_delta_tilde_lambda2 = (p1+p2) * delta_lambda_tilde - - lambda2 = formatreturn(amp * (l_tilde_lambda2 - l_delta_tilde_lambda2), input_is_array) + lambda2 = ( + formatreturn(amp * + (l_tilde_lambda2 - l_delta_tilde_lambda2), + input_is_array) + ) return lambda2 def lambda_from_mass_tov_file(mass, tov_file, distance=0.): From 46f0234ed82887ab1c22bda9c29e5cbb12002b52 Mon Sep 17 00:00:00 2001 From: Aleyna Akyuz Date: Wed, 4 Sep 2024 07:49:38 -0400 Subject: [PATCH 3/8] adding documentation --- pycbc/conversions.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/pycbc/conversions.py b/pycbc/conversions.py index 8fbd0bff032..a381643b9bf 100644 --- a/pycbc/conversions.py +++ b/pycbc/conversions.py @@ -436,6 +436,10 @@ def lambda_tilde(mass1, mass2, lambda1, lambda2): return formatreturn(8.0 / 13.0 * (p1 + p2), input_is_array) def delta_lambda_tilde(mass1, mass2, lambda1, lambda2): + """ Delta lambda tilde parameter defined as + equation 15 in + https://journals.aps.org/prd/pdf/10.1103/PhysRevD.91.043002 + """ m1, m2, lambda1, lambda2, input_is_array = ensurearray( mass1, mass2, lambda1, lambda2) lsum = lambda1 + lambda2 @@ -455,11 +459,13 @@ def delta_lambda_tilde(mass1, mass2, lambda1, lambda2): ) return formatreturn(1 / 2 * (p1 + p2), input_is_array) -def lambda1_from_delta_lambda_tilde_lambda_tilde( - delta_lambda_tilde, - lambda_tilde, - mass1, - mass2): +def lambda1_from_delta_lambda_tilde_lambda_tilde(delta_lambda_tilde, + lambda_tilde, + mass1, + mass2): + """ Returns lambda1 parameter by using delta lambda tilde, + lambda tilde, mass1 and mass2. + """ m1, m2, delta_lambda_tilde, lambda_tilde, input_is_array = ensurearray( mass1, mass2, delta_lambda_tilde, lambda_tilde) eta = eta_from_mass1_mass2(m1, m2) @@ -478,6 +484,9 @@ def lambda2_from_delta_lambda_tilde_lambda_tilde( lambda_tilde, mass1, mass2): + """ Returns lambda2 parameter by using delta lambda tilde, + lambda tilde, mass1 and mass2. + """ m1, m2, delta_lambda_tilde, lambda_tilde, input_is_array = ensurearray( mass1, mass2, delta_lambda_tilde, lambda_tilde) eta = eta_from_mass1_mass2(m1, m2) @@ -1835,5 +1844,6 @@ def nltides_gw_phase_diff_isco(f_low, f0, amplitude, n, m1, m2): 'remnant_mass_from_mass1_mass2_spherical_spin_eos', 'remnant_mass_from_mass1_mass2_cartesian_spin_eos', 'lambda1_from_delta_lambda_tilde_lambda_tilde', - 'lambda2_from_delta_lambda_tilde_lambda_tilde' + 'lambda2_from_delta_lambda_tilde_lambda_tilde', + 'delta_lambda_tilde' ] From fff9464b76eecebd28f4c2b0ed7085a768ec05cb Mon Sep 17 00:00:00 2001 From: Aleyna Akyuz Date: Wed, 4 Sep 2024 09:40:38 -0400 Subject: [PATCH 4/8] style fixes --- pycbc/conversions.py | 51 ++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/pycbc/conversions.py b/pycbc/conversions.py index a381643b9bf..42f32a28e4e 100644 --- a/pycbc/conversions.py +++ b/pycbc/conversions.py @@ -431,13 +431,13 @@ def lambda_tilde(mass1, mass2, lambda1, lambda2): mask = m1 < m2 ldiff[mask] = -ldiff[mask] eta = eta_from_mass1_mass2(m1, m2) - p1 = (lsum) * (1 + 7. * eta - 31 * eta ** 2.0) - p2 = (1 - 4 * eta)**0.5 * (1 + 9 * eta - 11 * eta ** 2.0) * (ldiff) + p1 = lsum * (1 + 7. * eta - 31 * eta ** 2.0) + p2 = (1 - 4 * eta)**0.5 * (1 + 9 * eta - 11 * eta ** 2.0) * ldiff return formatreturn(8.0 / 13.0 * (p1 + p2), input_is_array) def delta_lambda_tilde(mass1, mass2, lambda1, lambda2): """ Delta lambda tilde parameter defined as - equation 15 in + equation 15 in https://journals.aps.org/prd/pdf/10.1103/PhysRevD.91.043002 """ m1, m2, lambda1, lambda2, input_is_array = ensurearray( @@ -447,21 +447,18 @@ def delta_lambda_tilde(mass1, mass2, lambda1, lambda2): mask = m1 < m2 ldiff[mask] = -ldiff[mask] eta = eta_from_mass1_mass2(m1, m2) - p1 = ( - numpy.sqrt(1 - 4*eta) * - (1 - (13272/1319)*eta + - (8944/1319)*eta**2) * lsum - ) - p2 = ( - (1 - (15910/1319)*eta + - (32850/1319)*eta**2 + - (3380/1319)*eta**3) * ldiff - ) + p1 = numpy.sqrt(1 - 4 * eta) * ( + 1 - (13272 / 1319) * eta + + (8944 / 1319) * eta ** 2 + ) * lsum + p2 = (1 - (15910 / 1319) * eta + + (32850 / 1319) * eta ** 2 + + (3380 / 1319) * eta ** 3) * ldiff return formatreturn(1 / 2 * (p1 + p2), input_is_array) -def lambda1_from_delta_lambda_tilde_lambda_tilde(delta_lambda_tilde, - lambda_tilde, - mass1, +def lambda1_from_delta_lambda_tilde_lambda_tilde(delta_lambda_tilde, + lambda_tilde, + mass1, mass2): """ Returns lambda1 parameter by using delta lambda tilde, lambda tilde, mass1 and mass2. @@ -476,20 +473,23 @@ def lambda1_from_delta_lambda_tilde_lambda_tilde(delta_lambda_tilde, amp = 1/((p1*p4)-(p2*p3)) l_tilde_lambda1 = 13/16 * (p3-p4) * lambda_tilde l_delta_tilde_lambda1 = (p1-p2) * delta_lambda_tilde - lambda1 = formatreturn(amp * (l_delta_tilde_lambda1 - l_tilde_lambda1), input_is_array) + lambda1 = formatreturn( + amp * (l_delta_tilde_lambda1 - l_tilde_lambda1), + input_is_array + ) return lambda1 def lambda2_from_delta_lambda_tilde_lambda_tilde( - delta_lambda_tilde, - lambda_tilde, - mass1, + delta_lambda_tilde, + lambda_tilde, + mass1, mass2): """ Returns lambda2 parameter by using delta lambda tilde, lambda tilde, mass1 and mass2. """ m1, m2, delta_lambda_tilde, lambda_tilde, input_is_array = ensurearray( mass1, mass2, delta_lambda_tilde, lambda_tilde) - eta = eta_from_mass1_mass2(m1, m2) + eta = eta_from_mass1_mass2(m1, m2) p1 = 1 + 7.0*eta - 31*eta**2.0 p2 = (1 - 4*eta)**0.5 * (1 + 9*eta - 11*eta**2.0) p3 = (1 - 4*eta)**0.5 * (1 - 13272/1319*eta + 8944/1319*eta**2) @@ -497,11 +497,10 @@ def lambda2_from_delta_lambda_tilde_lambda_tilde( amp = 1/((p1*p4)-(p2*p3)) l_tilde_lambda2 = 13/16 * (p3+p4) * lambda_tilde l_delta_tilde_lambda2 = (p1+p2) * delta_lambda_tilde - lambda2 = ( - formatreturn(amp * - (l_tilde_lambda2 - l_delta_tilde_lambda2), - input_is_array) - ) + lambda2 = formatreturn( + amp * (l_tilde_lambda2 - l_delta_tilde_lambda2), + input_is_array + ) return lambda2 def lambda_from_mass_tov_file(mass, tov_file, distance=0.): From f57ac3b664888e10ab5ad3ab53932737f6de03f9 Mon Sep 17 00:00:00 2001 From: Aleyna Akyuz Date: Wed, 4 Sep 2024 10:33:00 -0400 Subject: [PATCH 5/8] style fixes --- pycbc/conversions.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pycbc/conversions.py b/pycbc/conversions.py index 42f32a28e4e..32b2636d4c2 100644 --- a/pycbc/conversions.py +++ b/pycbc/conversions.py @@ -452,14 +452,14 @@ def delta_lambda_tilde(mass1, mass2, lambda1, lambda2): (8944 / 1319) * eta ** 2 ) * lsum p2 = (1 - (15910 / 1319) * eta + - (32850 / 1319) * eta ** 2 + - (3380 / 1319) * eta ** 3) * ldiff + (32850 / 1319) * eta ** 2 + + (3380 / 1319) * eta ** 3) * ldiff return formatreturn(1 / 2 * (p1 + p2), input_is_array) def lambda1_from_delta_lambda_tilde_lambda_tilde(delta_lambda_tilde, - lambda_tilde, - mass1, - mass2): + lambda_tilde, + mass1, + mass2): """ Returns lambda1 parameter by using delta lambda tilde, lambda tilde, mass1 and mass2. """ From 2fd1eb9541d975efe5ad0eb2bb48601109f52485 Mon Sep 17 00:00:00 2001 From: Aleyna Akyuz Date: Wed, 4 Sep 2024 11:26:17 -0400 Subject: [PATCH 6/8] style fixes --- pycbc/conversions.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pycbc/conversions.py b/pycbc/conversions.py index 32b2636d4c2..9aa161c610a 100644 --- a/pycbc/conversions.py +++ b/pycbc/conversions.py @@ -453,7 +453,8 @@ def delta_lambda_tilde(mass1, mass2, lambda1, lambda2): ) * lsum p2 = (1 - (15910 / 1319) * eta + (32850 / 1319) * eta ** 2 + - (3380 / 1319) * eta ** 3) * ldiff + (3380 / 1319) * eta ** 3 + ) * ldiff return formatreturn(1 / 2 * (p1 + p2), input_is_array) def lambda1_from_delta_lambda_tilde_lambda_tilde(delta_lambda_tilde, From 5fa4dd896bded711595e1adeee432dbea06614c4 Mon Sep 17 00:00:00 2001 From: Aleyna Akyuz Date: Wed, 4 Sep 2024 14:07:51 -0400 Subject: [PATCH 7/8] style fixes --- pycbc/conversions.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pycbc/conversions.py b/pycbc/conversions.py index 9aa161c610a..a5bab75bc7e 100644 --- a/pycbc/conversions.py +++ b/pycbc/conversions.py @@ -451,9 +451,10 @@ def delta_lambda_tilde(mass1, mass2, lambda1, lambda2): 1 - (13272 / 1319) * eta + (8944 / 1319) * eta ** 2 ) * lsum - p2 = (1 - (15910 / 1319) * eta + - (32850 / 1319) * eta ** 2 + - (3380 / 1319) * eta ** 3 + p2 = ( + 1 - (15910 / 1319) * eta + + (32850 / 1319) * eta ** 2 + + (3380 / 1319) * eta ** 3 ) * ldiff return formatreturn(1 / 2 * (p1 + p2), input_is_array) From e58d38070ae2e6a75be2325cc24db636380ae660 Mon Sep 17 00:00:00 2001 From: Aleyna Akyuz Date: Thu, 5 Sep 2024 15:45:01 -0400 Subject: [PATCH 8/8] documentation --- pycbc/conversions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pycbc/conversions.py b/pycbc/conversions.py index a5bab75bc7e..94d7bac27d2 100644 --- a/pycbc/conversions.py +++ b/pycbc/conversions.py @@ -463,7 +463,7 @@ def lambda1_from_delta_lambda_tilde_lambda_tilde(delta_lambda_tilde, mass1, mass2): """ Returns lambda1 parameter by using delta lambda tilde, - lambda tilde, mass1 and mass2. + lambda tilde, mass1, and mass2. """ m1, m2, delta_lambda_tilde, lambda_tilde, input_is_array = ensurearray( mass1, mass2, delta_lambda_tilde, lambda_tilde) @@ -487,7 +487,7 @@ def lambda2_from_delta_lambda_tilde_lambda_tilde( mass1, mass2): """ Returns lambda2 parameter by using delta lambda tilde, - lambda tilde, mass1 and mass2. + lambda tilde, mass1, and mass2. """ m1, m2, delta_lambda_tilde, lambda_tilde, input_is_array = ensurearray( mass1, mass2, delta_lambda_tilde, lambda_tilde)