LALInspiral 5.0.3.1-eeff03c
RingUtils.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 Duncan Brown, Jolien Creighton
3*
4* This program is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License as published by
6* the Free Software Foundation; either version 2 of the License, or
7* (at your option) any later version.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with with program; see the file COPYING. If not, write to the
16* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17* MA 02110-1301 USA
18*/
19
20#include <math.h>
21#include <lal/LALStdlib.h>
22#include <lal/LALConstants.h>
23#include <lal/LIGOMetadataTables.h>
24#include <lal/RingUtils.h>
25
27{
28 /* Cardoso's equation from Berti et al. (2008) */
29 /* Define 3 parameters for l=m=2, n=0 */
30 const REAL4 fparam1 = 1.5251;
31 const REAL4 fparam2 = -1.1568;
32 const REAL4 fparam3 = 0.1292;
33
34 return fparam1 + fparam2 * pow( 1.0 - a, fparam3);
35
36 /* Echeverria's equation */
37 /* return 1.0 - 0.63 * pow( 1.0 - a, 3.0/10.0 ); */
38}
39
41{
42 return 1.0 + 7.0/(24.0*Q*Q);
43}
44
45
46/* FIXME Is there already a function*/
47/* in LAL that will return the sign */
48static int SIGN( REAL4 x )
49{
50 if( x > 0 )
51
52 return 1;
53
54 else if( x < 0 )
55
56 return -1;
57
58 else
59
60 return 0;
61}
62
63/*
64 *
65 * XLAL Routines.
66 *
67 */
68
69
70
72
73{
74
75 /* Cardoso's equation from Berti et al. (2008) */
76 /* Define 3 parameters for l=m=2, n=0 */
77 const REAL4 qparam1 = 0.7000;
78 const REAL4 qparam2 = 1.4187;
79 const REAL4 qparam3 = -0.4990;
80
81 return 1.0 - pow( qparam2/(Q - qparam1), -1.0/qparam3 );
82
83 /* Echeverria's equation */
84 /* return 1.0 - pow( 2.0/Q, 20.0/9.0 ); */
85}
86
87
89
90{
91 const REAL4 c = LAL_C_SI;
92 const REAL4 a = XLALBlackHoleRingSpin( Q );
93 const REAL4 g = ring_spin_factor( a );
94 return (c * c * c * g) / ( LAL_TWOPI * LAL_G_SI * LAL_MSUN_SI * f );
95}
96
97
99
100{
101
102 /* Cardoso's equation from Berti et al. (2008) */
103 /* Define 3 parameters for l=m=2, n=0 */
104 const REAL4 qparam1 = 0.7000;
105 const REAL4 qparam2 = 1.4187;
106 const REAL4 qparam3 = -0.4990;
107
108 return qparam1 + (qparam2 * pow( (1.0 - a), qparam3 ));
109
110 /* Echeverria's equation */
111 /* return 2.0 * pow( ( 1.0 - a ), -0.45 ); */
112}
113
114
116
117{
118 const REAL4 c = LAL_C_SI;
119 const REAL4 g = ring_spin_factor( a );
120 return (c * c * c * g) / ( LAL_TWOPI * LAL_G_SI * LAL_MSUN_SI * M );
121}
122
123/* Formulas for final mass and spin of a non-spinning binary */
124/* Spin equation is not used. See XLALSpinBinaryFinalBHSpin() below. */
125/* Buonanno et al arxiv:0706.3732v3 */
126
128
129{
130 return sqrt(12.0) * eta - 2.9 * eta *eta;
131}
132
133
135
136{
137 return ( 1 + ( sqrt(8.0/9.0) - 1) * eta - 0.498 * eta * eta) * (mass1 + mass2);
138}
139
140/* Formulas for final spin of an initially spinning or initially */
141/* non-spinning binary. */
142/* Barausse & Rezzolla arxiv:0904.2577 */
143/* Equations 6, 7, and 10 */
144
145REAL4 XLALSpinBinaryFinalBHSpin( REAL4 eta, REAL4 mass1, REAL4 mass2, REAL4 spin1x, REAL4 spin2x,
146 REAL4 spin1y, REAL4 spin2y, REAL4 spin1z, REAL4 spin2z )
147
148{
149 REAL4 norml;
150 REAL4 cosalpha;
151 REAL4 cosbeta;
152 REAL4 cosgamma;
153 const REAL4 t0 = -2.8904;
154 const REAL4 t2 = -3.5171;
155 const REAL4 t3 = 2.5763;
156 const REAL4 s4 = -0.1229;
157 const REAL4 s5 = 0.4537;
158 const REAL4 q = mass2 / mass1;
159 const REAL4 q2 = q * q;
160 const REAL4 q4 = q2 * q2;
161 const REAL4 q2sum = 1.0 + q2;
162 const REAL4 norma1 = sqrt( spin1x * spin1x + spin1y * spin1y + spin1z * spin1z );
163 const REAL4 norma2 = sqrt( spin2x * spin2x + spin2y * spin2y + spin2z * spin2z );
164 const REAL4 norma12 = norma1 * norma1;
165 const REAL4 norma22 = norma2 * norma2;
166
167 /* FIXME The following calculation for Eq. 7 of arxiv:0904.2577 */
168 /* assumes that we have spin (anti-)aligned PhenomB waveforms */
169 /* aligned in the \hat{z} direction. Furthermore, we assume that */
170 /* the orbital angular momentum L is along the positive \hat{z} */
171 /* direction. For the completely general case, we will need to store */
172 /* the components of \hat{L}. */
173 const int a1sign = SIGN( spin1z );
174 const int a2sign = SIGN( spin2z );
175 cosalpha = (REAL4) a1sign * a2sign;
176 cosbeta = (REAL4) a1sign;
177 cosgamma = (REAL4) a2sign;
178
179 norml = 2.0 * sqrt(3.0) + t2 * eta + t3 * eta * eta + s4 / (q2sum * q2sum) *
180 (norma12 + norma22 * q4 + 2.0 * norma1 * norma2 * q2 * cosalpha) +
181 (s5 * eta + t0 + 2.0) / q2sum * (norma1 * cosbeta + norma2 * q2 * cosgamma);
182
183 return 1.0 / ((1.0 + q) * (1.0 + q)) * sqrt(norma12 + norma22 * q4 + 2.0 * norma1 *
184 norma2 * q2 * cosalpha + 2.0 * (norma1 * cosbeta + norma2 * q2 * cosgamma) * norml *
185 q + norml * norml * q2);
186}
187
188
190
191{
192 const REAL4 c = LAL_C_SI;
193 const REAL4 M = XLALBlackHoleRingMass( f, Q );
194 const REAL4 a = XLALBlackHoleRingSpin( Q );
195 const REAL4 g = ring_spin_factor( a );
196 const REAL4 F = ring_quality_fn( Q );
197
198 return sqrt(5.0/2.0 * epsilon) *
199 ( (LAL_G_SI * M * LAL_MSUN_SI) / ( c * c * r * 1.0e6 * LAL_PC_SI) ) *
200 (1.0 / sqrt( Q * F * g) );
201}
202
203
205
206{
207 const REAL4 c = LAL_C_SI;
208 const REAL4 M = XLALBlackHoleRingMass( f, Q );
209 const REAL4 a = XLALBlackHoleRingSpin( Q );
210 const REAL4 g = ring_spin_factor( a );
211 const REAL4 F = ring_quality_fn( Q );
212
213 return (2.0/5.0 * amplitude * amplitude) *
214 pow( ( c * c * r * 1.0e6 * LAL_PC_SI) / (LAL_G_SI * M * LAL_MSUN_SI), 2 ) *
215 ( Q * F * g );
216}
217
218
219REAL4 XLALBlackHoleRingHRSS( REAL4 f, REAL4 Q, REAL4 amplitude, REAL4 plus, REAL4 cross )
220
221{
222 return amplitude * sqrt( Q * ( (0.5 + Q*Q ) * plus*plus + Q * plus*cross + Q*Q * cross*cross ) / ( 1.0 + 4.0 * Q*Q) / LAL_PI / f );
223}
224
225
227
228{
229 REAL8 Q2 = Qa*Qa;
230 REAL8 gQQ;
231 REAL8 gff;
232 REAL8 gQf;
233
234 gQQ = ( 3.0 + 16.0 * Q2 * Q2) / ( Q2 * ( 1.0 + 4.0 * Q2 ) * ( 1.0 + 4.0 * Q2 ) );
235 gff = ( 3.0 + 8.0 * Q2) / ( fa * fa);
236 gQf = - 2.0 * ( 3.0 + 4.0 * Q2 ) / ( Qa * fa * ( 1.0 + 4.0 * Q2 ));
237
238 return ( 1.0/8.0 * ( gQQ * pow(Qb-Qa,2) + gQf * (Qb-Qa) * (fb-fa) + gff * pow(fb-fa,2) ) );
239}
240
241
243
244{
245 REAL8 gQQ, gff, gtt;
246 REAL8 gQf, gtf, gtQ;
247 REAL8 df, dQ, ds2;
248 REAL8 f = (fa+fb)/2.;
249 REAL8 Q = (Qa+Qb)/2.;
250 REAL8 Q2 = Q*Q;
251
252 gQQ = ( 1. + 28.*Q2*Q2 + 128.*Q2*Q2*Q2 + 64.*Q2*Q2*Q2*Q2) / ( 4. * Q2 * ( 1. + 6.*Q2 + 8.*Q2*Q2 )*( 1. + 6.*Q2 + 8.*Q2*Q2 ) );
253 gff = ( 1. + 6.*Q2 + 16.*Q2*Q2) / ( 4. * f*f * ( 1. + 2.*Q2 ) );
254 gtt = ( LAL_PI*LAL_PI * f*f ) * ( 1. + 4.*Q2 ) / ( Q2 );
255 gQf = - ( 1. + 2.*Q2 + 8.*Q2*Q2 ) / ( 4.*Q*f * ( 1. + 6.*Q2 + 8.*Q2*Q2 ) );
256 gtf = - ( LAL_PI * Q ) * ( 1. + 4.*Q2) / ( 1. + 2.*Q2 );
257 gtQ = ( LAL_PI * f ) * ( 1. - 2.*Q2 ) / ( ( 1. + 2.*Q2 )*( 1. + 2.*Q2 ) );
258
259 df = fa - fb;
260 dQ = Qa - Qb;
261
262 ds2 = ( gQQ * dQ*dQ + gff * df*df + gtt * dt*dt + gQf * 2.*dQ*df + gtf * 2.*dt*df + gtQ * 2.*dt*dQ );
263
264 return ( ds2 );
265}
266
267
268
270
271{
272 REAL8 gtt;
273 REAL8 gtf, gtQ;
274 REAL8 df, dQ, dt;
275 REAL8 f = (fa+fb)/2.;
276 REAL8 Q = (Qa+Qb)/2.;
277 REAL8 Q2 = Q*Q;
278
279 gtt = ( LAL_PI*LAL_PI * f*f ) * ( 1. + 4.*Q2 ) / ( Q2 );
280 gtf = - ( LAL_PI * Q ) * ( 1. + 4.*Q2) / ( 1. + 2.*Q2 );
281 gtQ = ( LAL_PI * f ) * ( 1. - 2.*Q2 ) / ( ( 1. + 2.*Q2 )*( 1. + 2.*Q2 ) );
282
283 df = fa - fb;
284 dQ = Qa - Qb;
285
286 dt = -(gtf * df + gtQ * dQ)/gtt;
287
288 return ( dt );
289}
290
291
293{
294 REAL8 gtt;
295 REAL8 f = table->frequency;
296 REAL8 Q = table->quality;
297 REAL8 Q2 = Q*Q;
298
299 gtt = ( LAL_PI*LAL_PI * f*f ) * ( 1. + 4.*Q2 ) / ( Q2 );
300
301 return ( sqrt( lal_ring_ds_sq / gtt ) );
302}
303
304/**
305 * This routine computes the ringdown waveform
306 * \f{equation}{
307 * r(t) = \left\{
308 * \begin{array}{ll}
309 * e^{-\pi ft/Q}\cos(2\pi ft) & \mbox{for} t\ge0 \\
310 * 0 & \mbox{for} t<0
311 * \end{array}
312 * \right.
313 * \f}
314 * where the parameters \f$f\f$ and \f$Q\f$ are specified in the input structure.
315 * The output must have an appropriate amount of memory allocated, and must
316 * have the desired temporal spacing set. Note: Ref.\ \cite JDECreighton99
317 * used a different convention for the ringdown normlization: there the
318 * ringdown waveform was taken to be \f$q(t)=(2\pi)^{1/2}r(t)\f$.
319 */
321
322{
323 const REAL8 efolds = 10;
324 REAL8 amp = 1.0;
325 REAL8 fac;
326 REAL8 a;
327 REAL8 y;
328 REAL8 yy;
329 UINT4 i;
330 UINT4 n;
331
332 if ( ! output || ! output->data || ! input )
334
335 if ( ! output->data->length )
337
338 if ( output->deltaT <= 0 || input->quality <= 0 || input->frequency <= 0 )
340
341 /* exponential decay variables */
342 fac = exp( - LAL_PI * input->frequency * output->deltaT / input->quality );
343 n = ceil( - efolds / log( fac ) );
344
345 /* oscillator variables */
346 a = 2 * cos( 2 * LAL_PI * input->frequency * output->deltaT );
347 y = sin( -2 * LAL_PI * input->frequency * output->deltaT +
348 0.5 * LAL_PI + input->phase );
349 yy = sin( -4 * LAL_PI * input->frequency * output->deltaT +
350 0.5 * LAL_PI + input->phase );
351
352 if ( n < output->data->length )
353 memset( output->data->data + n, 0,
354 ( output->data->length - n ) * sizeof( *output->data->data ) );
355 else
356 n = output->data->length;
357
358 for ( i = 0; i < n; ++i )
359 {
360 REAL4 tmp = a * y - yy;
361 yy = y;
362 output->data->data[i] = amp * ( y = tmp );
363 amp *= fac;
364 }
365
366 return 0;
367}
368
369/**
370 * This routine computes a waveform for a
371 * black hole with the specified physical parameters (in the input structure).
372 * The parameters are the black hole mass \f$M\f$ (in solar masses \f$M_\odot\f$), the
373 * spin \f$S={\hat{a}}GM^2/c\f$ expressed in terms of the dimensionless mass
374 * parameter \f${\hat{a}}\f$, the fractional mass lost \f$\epsilon\f$ in ringdown
375 * radiation expressed as a percent, and the distance to the typical source
376 * (angle-averaged waveform) \f$r\f$ given in megaparsecs (Mpc). The central
377 * frequency and quality of the ringdown are approximated
378 * as\ \cite EWLeaver85 ,\cite EBertiEtAl06 :
379 * \f{equation}{
380 * f \simeq 32\,\textrm{kHz}\times[f_1+f_2(1-{\hat{a}})^{f_3}](M_\odot/M)
381 * \f}
382 * and
383 * \f{equation}{
384 * Q \simeq q_1+q_2(1-{\hat{a}})^{q_3},
385 * \f}
386 * where the values of the constants (f_1,f_2,f_3) and (q_1,q_2,q_3) are
387 * given for each of (l,m,n) in\ \cite EBertiEtAl06 .
388 * The strain waveform produced is \f$h(t)=A_q q(t)\f$ where the amplitude factor
389 * is\ \cite JDECreighton99
390 * \f{equation}{
391 * A_q = 2.415\times10^{-21}Q^{-1/2}[1-0.63(1-{\hat{a}})^{3/10}]^{-1/2}
392 * \left(\frac{\textrm{Mpc}}{r}\right)
393 * \left(\frac{M}{M_\odot}\right)
394 * \left(\frac{\epsilon}{0.01}\right)^{1/2}.
395 * \f}
396 * Note that this is written \f$A_q\f$ to emphasize that it is the amplitude
397 * factor for \f$q(t)\f$ rather than \f$r(t)\f$.
398 */
400 REAL4TimeSeries *output,
401 SnglRingdownTable *input,
402 REAL4 dynRange
403 )
404
405{
406 const REAL4 amp = dynRange *
408 input->frequency, input->quality, input->eff_dist, input->epsilon );
409 UINT4 i;
410
411 if ( XLALComputeRingTemplate( output, input ) < 0 )
413
414 for ( i = 0; i < output->data->length; ++i )
415 output->data->data[i] *= amp;
416
417 return 0;
418}
419
420
422{
423 UINT4 count = 0;
424 REAL4 dseff = 4 * sqrt( input->maxMismatch );
425 REAL4 minlogf = log( input->minFrequency );
426 REAL4 maxlogf = log( input->maxFrequency );
427 REAL4 q = input->minQuality;
428
429 while ( q < input->maxQuality )
430 {
431 REAL4 q2 = q * q;
432 REAL4 logfreq = minlogf;
433
434 while ( logfreq < maxlogf )
435 {
436 if ( tmplt )
437 {
438 tmplt[count].quality = q;
439 tmplt[count].frequency = exp( logfreq );
440 tmplt[count].phase = input->templatePhase;
441 tmplt[count].epsilon = input->templateEpsilon;
442 tmplt[count].eff_dist = input->templateDistance;
443 }
444 ++count;
445 logfreq += dseff / sqrt( 3 + 8 * q2 );
446 }
447
448 q += dseff * q * ( 1 + 4 * q2 ) / sqrt( 3 + 16 * q2 * q2 );
449 }
450
451 return count;
452}
453
454/**
455 * This routine creates a bank of ringdown
456 * templates that cover a set range in the parameters \f$f\f$ and \f$Q\f$.
457 */
459
460{
461 UINT4 i;
462 RingTemplateBank *bank;
463
464 if ( ! input )
466
467 bank = LALCalloc( 1, sizeof( *bank ) );
468 if ( ! bank )
470
471 bank->numTmplt = MakeBank( NULL, input );
472 bank->tmplt = LALCalloc( bank->numTmplt, sizeof( *bank->tmplt ) );
473 if ( ! bank->tmplt )
474 {
475 LALFree( bank );
477 }
478 for ( i = 0; i < bank->numTmplt - 1; ++i )
479 bank->tmplt[i].next = bank->tmplt + i + 1;
480
481 MakeBank( bank->tmplt, input );
482 return bank;
483}
484
485
486/** Destroys a RingTemplateBank */
488
489{
490 if ( bank )
491 {
492 if ( bank->tmplt )
493 LALFree( bank->tmplt );
494 LALFree( bank );
495 }
496 return;
497}
#define LALCalloc(m, n)
#define LALFree(p)
static REAL4 ring_quality_fn(REAL4 Q)
Definition: RingUtils.c:40
static REAL4 ring_spin_factor(REAL4 a)
Definition: RingUtils.c:26
static int MakeBank(SnglRingdownTable *tmplt, RingTemplateBankInput *input)
Definition: RingUtils.c:421
static int SIGN(REAL4 x)
Definition: RingUtils.c:48
double i
const double Q
sigmaKerr data[0]
#define LAL_C_SI
#define LAL_MSUN_SI
#define LAL_PI
#define LAL_TWOPI
#define LAL_PC_SI
#define LAL_G_SI
double REAL8
uint32_t UINT4
float REAL4
static const INT4 r
static const INT4 q
static const INT4 a
REAL8 XLALRingdownTimeError(const SnglRingdownTable *table, REAL8 lal_ring_ds_sq)
Definition: RingUtils.c:292
int XLALComputeBlackHoleRing(REAL4TimeSeries *output, SnglRingdownTable *input, REAL4 dynRange)
This routine computes a waveform for a black hole with the specified physical parameters (in the inpu...
Definition: RingUtils.c:399
REAL4 XLALNonSpinBinaryFinalBHSpin(REAL4 eta)
Definition: RingUtils.c:127
REAL4 XLALBlackHoleRingHRSS(REAL4 f, REAL4 Q, REAL4 amplitude, REAL4 plus, REAL4 cross)
Definition: RingUtils.c:219
REAL4 XLALBlackHoleRingEpsilon(REAL4 f, REAL4 Q, REAL4 r, REAL4 amplitude)
Definition: RingUtils.c:204
REAL4 XLALBlackHoleRingFrequency(REAL4 M, REAL4 a)
Definition: RingUtils.c:115
REAL4 XLALBlackHoleRingMass(REAL4 f, REAL4 Q)
Definition: RingUtils.c:88
REAL4 XLALBlackHoleRingAmplitude(REAL4 f, REAL4 Q, REAL4 r, REAL4 epsilon)
Definition: RingUtils.c:189
int XLALComputeRingTemplate(REAL4TimeSeries *output, SnglRingdownTable *input)
This routine computes the ringdown waveform.
Definition: RingUtils.c:320
REAL4 XLALBlackHoleRingSpin(REAL4 Q)
Definition: RingUtils.c:71
void XLALDestroyRingTemplateBank(RingTemplateBank *bank)
Destroys a RingTemplateBank.
Definition: RingUtils.c:487
REAL4 XLALSpinBinaryFinalBHSpin(REAL4 eta, REAL4 mass1, REAL4 mass2, REAL4 spin1x, REAL4 spin2x, REAL4 spin1y, REAL4 spin2y, REAL4 spin1z, REAL4 spin2z)
Definition: RingUtils.c:145
REAL4 XLALBlackHoleRingQuality(REAL4 a)
Definition: RingUtils.c:98
REAL8 XLAL2DRingMetricDistance(REAL8 fa, REAL8 fb, REAL8 Qa, REAL8 Qb)
Definition: RingUtils.c:226
REAL4 XLALNonSpinBinaryFinalBHMass(REAL4 eta, REAL4 mass1, REAL4 mass2)
Definition: RingUtils.c:134
RingTemplateBank * XLALCreateRingTemplateBank(RingTemplateBankInput *input)
This routine creates a bank of ringdown templates that cover a set range in the parameters and .
Definition: RingUtils.c:458
REAL8 XLAL3DRingTimeMinimum(REAL8 fa, REAL8 fb, REAL8 Qa, REAL8 Qb)
Definition: RingUtils.c:269
REAL8 XLAL3DRingMetricDistance(REAL8 fa, REAL8 fb, REAL8 Qa, REAL8 Qb, REAL8 dt)
Definition: RingUtils.c:242
#define XLAL_ERROR_NULL(...)
#define XLAL_ERROR(...)
XLAL_EBADLEN
XLAL_ENOMEM
XLAL_EFAULT
XLAL_EFUNC
XLAL_EINVAL
M
list y
c
int n
x
double t0
This structure contains a bank of ringdown waveforms.
Definition: RingUtils.h:140
SnglRingdownTable * tmplt
Array of ringdown templates.
Definition: RingUtils.h:142
UINT4 numTmplt
The number of templates in the bank.
Definition: RingUtils.h:141
This structure contains the parameters required for generating a ringdown template bank.
Definition: RingUtils.h:152
REAL4 templatePhase
The phase of the ringdown templates, in radians; Zero is a cosine-phase template; is a sine-phase te...
Definition: RingUtils.h:158
REAL4 maxMismatch
The maximum mismatch allowed between templates in the bank.
Definition: RingUtils.h:157
REAL4 minFrequency
The minimum central frequency in the bank (in Hz)
Definition: RingUtils.h:155
REAL4 minQuality
The minimum quality factor in the bank.
Definition: RingUtils.h:153
REAL4 maxFrequency
The minimum central frequency in the bank (in Hz)
Definition: RingUtils.h:156
REAL4 templateDistance
UNDOCUMENTED.
Definition: RingUtils.h:162
REAL4 templateEpsilon
UNDOCUMENTED.
Definition: RingUtils.h:163
struct tagSnglRingdownTable * next
char output[FILENAME_MAX]
double df