gstlal-inspiral  1.9.2
 All Classes Namespaces Files Functions
spawaveform.py
1 # Copyright (C) 2010 Kipp Cannon, Drew Keppel
2 #
3 # This program is free software; you can redistribute it and/or modify it
4 # under the terms of the GNU General Public License as published by the
5 # Free Software Foundation; either version 2 of the License, or (at your
6 # option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful, but
9 # WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11 # Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License along
14 # with this program; if not, write to the Free Software Foundation, Inc.,
15 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 
17 
18 #
19 # =============================================================================
20 #
21 # Preamble
22 #
23 # =============================================================================
24 #
25 
26 
27 """
28 This module is a wrapper of the _spawaveform module, supplementing the C
29 code in that module with additional features that are more easily
30 implemented in Python. It is recommended that you import this module
31 rather than importing _spawaveform directly.
32 """
33 
34 
35 import math
36 
37 
38 import lal
39 from ._spawaveform import *
40 
41 
42 __author__ = "Kipp Cannon <kipp.cannon@ligo.org>"
43 
44 
45 #
46 # =============================================================================
47 #
48 # Empty
49 #
50 # =============================================================================
51 #
52 
53 
54 def imrchirptime(m1, m2, fLower, chi, a_hat = 0.98, e_folds = 10):
55  """
56  An approximate IMR chirptime in seconds.
57 
58  FIXME this should be replaced by something better
59 
60  1) compute the SPA chirptime up to ringdown frequency at 3.5 PN, verify that it is nonnegative
61  2) then add efolds worth of ringdown time
62 
63  Ringdown decay time forumla in solar masses is:
64 
65  tau = 2 * (m1+m2) * 5e-6 * (0.7 + 1.4187 * (1-a_hat)**-0.4990) / (1.5251 - 1.1568 * (1-a_hat)**0.1292)
66 
67  from (7-9) of LIGO-P1300156.
68 
69  @param m1 Mass 1
70  @param m2 Mass 2
71  @param fLower the starting frequency
72  @param chi the effective spin parameter from computechi()
73  @param e_folds The number of efolds to use in the ringdown signal duration, default 10
74  @param a_hat The dimensionless spin of the final black hole, default 0.98
75  """
76 
77  assert (a_hat < 0.9999999999999999) # demand spin less than 1 (or approximately the closest floating point representation of 1)
78  fFinal = imrffinal(m1, m2, chi, 'ringdown')
79  assert (fFinal > fLower) # demand that the low frequency comes before the ringdown frequency
80  tau = 2 * (m1+m2) * 5e-6 * (0.7 + 1.4187 * (1-a_hat)**-0.4990) / (1.5251 - 1.1568 * (1-a_hat)**0.1292)
81  inspiral_time = chirptime(m1, m2, 7, fLower, fFinal, chi)
82  if inspiral_time < 0:
83  raise ValueError("Inspiral time is negative: m1 = %e, m2 = %e, flow = %e, chi = %e" % (m1, m2, fLower, chi)) # demand positive inspiral times
84  return inspiral_time + e_folds * tau
85 
86 
87 def eta(m1, m2):
88  """
89  Compute the symmetric mass ratio, eta.
90  """
91  return m1*m2/(m1+m2)**2.
92 
93 
94 def chirpmass(m1, m2):
95  """
96  Compute the chirp mass in seconds.
97  """
98  return lal.MTSUN_SI * (m1+m2) * eta(m1, m2)**.6
99 
100 
101 def ms2taus(m1, m2, f0 = 40.0):
102  """
103  Solve for tau_0 and tau_3 from m1 and m2.
104  """
105  tau0 = 5./256./(math.pi*f0)**(8./3.) * chirpmass(m1,m2)**(-5./3.)
106  tau3 = math.pi/8./eta(m1,m2)**.6/(math.pi*f0)**(5./3.) * chirpmass(m1,m2)**(-2./3.)
107  return tau0, tau3
108 
109 
110 def taus2ms(tau0, tau3, f0 = 40.0):
111  """
112  Solve for m1 and m2 from tau_0 and tau_3.
113  """
114  Mc = (5./256./(math.pi*f0)**(8./3.) / tau0)**(3./5.)
115  eta = (math.pi/8./(math.pi*f0)**(5./3.) / tau3 / Mc**(2./3.))**(5./3.)
116 
117  M = Mc / eta**(3./5.)
118 
119  m1 = (1. + abs(1. - 4.*eta)**.5) * M / 2.
120  m2 = M - m1
121 
122  return m1 / lal.MTSUN_SI, m2 / lal.MTSUN_SI