Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALApps 10.1.0.1-8a6b96f
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
FindChirpSPTemplate.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 Darren Woods, Drew Keppel, Duncan Brown, Gareth Jones,
3* Jolien Creighton, Patrick Brady, Thomas Cokelaer, Evan Ochsner
4*
5* This program is free software; you can redistribute it and/or modify
6* it under the terms of the GNU General Public License as published by
7* the Free Software Foundation; either version 2 of the License, or
8* (at your option) any later version.
9*
10* This program is distributed in the hope that it will be useful,
11* but WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with with program; see the file COPYING. If not, write to the
17* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18* MA 02110-1301 USA
19*/
20
21/*-----------------------------------------------------------------------
22 *
23 * File Name: FindChirpSPTemplate.c
24 *
25 * Author: Brown D. A.
26 *
27 *-----------------------------------------------------------------------
28 */
29
30/**
31 * \author Brown, D. A.
32 * \file
33 * \ingroup FindChirpSP_h
34 *
35 * \brief Provides functions to create stationary phase inspiral templates in a
36 * form that can be used by the <tt>FindChirpFilter()</tt> function.
37 *
38 * ### Prototypes ###
39 *
40 * The function <tt>LALFindChirpSPTemplate()</tt> creates the stationary phase
41 * template as described by the algorithm below.
42 *
43 * ### Algorithm ###
44 *
45 * Blah.
46 *
47 * ### Uses ###
48 *
49 * \code
50 * LALCalloc()
51 * LALFree()
52 * LALCreateVector()
53 * LALDestroyVector()
54 * \endcode
55 *
56 * ### Notes ###
57 *
58 */
59
60#include <math.h>
61#include <lal/LALStdlib.h>
62#include <lal/AVFactories.h>
63#include <lal/LALInspiral.h>
64#include <lal/FindChirp.h>
65#include "FindChirpDatatypes.h"
66#include "FindChirpSP.h"
67
68static double
70 double m2,
71 double fLower,
72 int order)
73{
74
75 /* variables used to compute chirp time */
76 double c0T, c2T, c3T, c4T, c5T, c6T, c6LogT, c7T;
77 double xT, x2T, x3T, x4T, x5T, x6T, x7T, x8T;
78 double m = m1 + m2;
79 double eta = m1 * m2 / m / m;
80
81 c0T = c2T = c3T = c4T = c5T = c6T = c6LogT = c7T = 0.;
82
83 /* Switch on PN order, set the chirp time coeffs for that order */
84 switch (order)
85 {
86 case 8:
87 case 7:
88 c7T = LAL_PI * (14809.0 * eta * eta / 378.0 - 75703.0 * eta / 756.0 - 15419335.0 / 127008.0);
89#if __GNUC__ >= 7 && !defined __INTEL_COMPILER
90 __attribute__ ((fallthrough));
91#endif
92 case 6:
93 c6T = LAL_GAMMA * 6848.0 / 105.0 - 10052469856691.0 / 23471078400.0 + LAL_PI * LAL_PI * 128.0 / 3.0 + eta * (3147553127.0 / 3048192.0 - LAL_PI * LAL_PI * 451.0 / 12.0) - eta * eta * 15211.0 / 1728.0 + eta * eta * eta * 25565.0 / 1296.0 + log (4.0) * 6848.0 / 105.0;
94 c6LogT = 6848.0 / 105.0;
95#if __GNUC__ >= 7 && !defined __INTEL_COMPILER
96 __attribute__ ((fallthrough));
97#endif
98 case 5:
99 c5T = 13.0 * LAL_PI * eta / 3.0 - 7729.0 * LAL_PI / 252.0;
100#if __GNUC__ >= 7 && !defined __INTEL_COMPILER
101 __attribute__ ((fallthrough));
102#endif
103 case 4:
104 c4T = 3058673.0 / 508032.0 + eta * (5429.0 / 504.0 + eta * 617.0 / 72.0);
105 c3T = -32.0 * LAL_PI / 5.0;
106 c2T = 743.0 / 252.0 + eta * 11.0 / 3.0;
107 c0T = 5.0 * m * LAL_MTSUN_SI / (256.0 * eta);
108 break;
109 default:
110 fprintf (stderr, "ERROR!!!\n");
111 break;
112 }
113
114 /* This is the PN parameter v evaluated at the lower freq. cutoff */
115 xT = pow (LAL_PI * m * LAL_MTSUN_SI * fLower, 1.0 / 3.0);
116 x2T = xT * xT;
117 x3T = xT * x2T;
118 x4T = x2T * x2T;
119 x5T = x2T * x3T;
120 x6T = x3T * x3T;
121 x7T = x3T * x4T;
122 x8T = x4T * x4T;
123
124 /* Computes the chirp time as tC = t(v_low) */
125 /* tC = t(v_low) - t(v_upper) would be more */
126 /* correct, but the difference is negligble. */
127
128 /* This formula works for any PN order, because */
129 /* higher order coeffs will be set to zero. */
130
131 return c0T * (1 + c2T * x2T + c3T * x3T + c4T * x4T + c5T * x5T + (c6T + c6LogT * log (xT)) * x6T + c7T * x7T) / x8T;
132}
133
134
135
136
137void
140 FindChirpTemplate *fcTmplt,
141 InspiralTemplate *tmplt,
143 )
144
145{
146 UINT4 numPoints = 0;
147 REAL4 deltaF = 0.0;
148 REAL4 m = 0.0;
149 REAL4 eta = 0.0;
150 REAL4 mu = 0.0;
151 REAL4 S1z = 0.0;
152 REAL4 S2z = 0.0;
153 REAL4 mass_delta = 0.0;
154 REAL4 chis = 0.0;
155 REAL4 chia = 0.0;
156 REAL4 chi1 = 0.0;
157 REAL4 chi2 = 0.0;
158 REAL4 qm_def1 = 0.0;
159 REAL4 qm_def2 = 0.0;
160 REAL4 pn_beta = 0.0;
161 REAL4 pn_sigma = 0.0;
162 REAL4 pn_gamma = 0.0;
163 COMPLEX8 *expPsi = NULL;
164 REAL4 *xfac = NULL;
165 REAL4 x1 = 0.0;
166 REAL4 psi = 0.0;
167 REAL4 psi0 = 0.0;
168 INT4 k = 0;
169 INT4 f = 0;
170 INT4 kmin = 0;
171 INT4 kmax = 0;
172 REAL4 fLow = -1;
173 CHAR infomsg[512];
174
175 REAL4 distNorm;
176 const REAL4 cannonDist = 1.0; /* Mpc */
177
178 /* pn constants */
179 REAL4 c0, c10, c15, c20, c25, c25Log, c30, c30Log, c35, c40P;
180 REAL4 x;
181
182 /* chebychev coefficents for expansion of sin and cos */
183 const REAL4 s2 = -0.16605;
184 const REAL4 s4 = 0.00761;
185 const REAL4 c2 = -0.49670;
186 const REAL4 c4 = 0.03705;
187
188
191
192
193 /*
194 *
195 * check that the arguments are reasonable
196 *
197 */
198
199
200 /* check that the output structures exist */
201 ASSERT( fcTmplt, status,
202 FINDCHIRPSPH_ENULL, FINDCHIRPSPH_MSGENULL );
203 ASSERT( fcTmplt->data, status,
204 FINDCHIRPSPH_ENULL, FINDCHIRPSPH_MSGENULL );
205 ASSERT( fcTmplt->data->data, status,
206 FINDCHIRPSPH_ENULL, FINDCHIRPSPH_MSGENULL );
207
208 /* check that the parameter structure exists */
210 FINDCHIRPSPH_ENULL, FINDCHIRPSPH_MSGENULL );
211 ASSERT( params->xfacVec, status,
212 FINDCHIRPSPH_ENULL, FINDCHIRPSPH_MSGENULL );
213 ASSERT( params->xfacVec->data, status,
214 FINDCHIRPSPH_ENULL, FINDCHIRPSPH_MSGENULL );
215
216 /* check that the timestep is positive */
217 ASSERT( params->deltaT > 0, status,
218 FINDCHIRPSPH_EDELT, FINDCHIRPSPH_MSGEDELT );
219
220 /* check that the input exists */
221 ASSERT( tmplt, status, FINDCHIRPSPH_ENULL, FINDCHIRPSPH_MSGENULL );
222
223 /* check that the parameter structure is set */
224 /* to the correct waveform approximant */
225 if ( params->approximant != FindChirpSP )
226 {
227 ABORT( status, FINDCHIRPSPH_EMAPX, FINDCHIRPSPH_MSGEMAPX );
228 }
229 LALInfo( status, "Generating template using FindChirpSP" );
230
231
232 /*
233 *
234 * compute the stationary phase template
235 *
236 */
237
238
239 /* set up pointers */
240 expPsi = fcTmplt->data->data;
241 xfac = params->xfacVec->data;
242 numPoints = 2 * (fcTmplt->data->length - 1);
243
244 /* set the waveform approximant */
245 tmplt->approximant = params->approximant;
246
247 /* set the pN order of the template */
248 tmplt->order = params->order;
249
250 /* zero output */
251 memset( expPsi, 0, fcTmplt->data->length * sizeof(COMPLEX8) );
252
253 /* parameters */
254 deltaF = 1.0 / ( (REAL4) params->deltaT * (REAL4) numPoints );
255 m = (REAL4) tmplt->totalMass;
256 eta = (REAL4) tmplt->eta;
257 mu = (REAL4) tmplt->mu;
258 S1z = tmplt->spin1[2];
259 S2z = tmplt->spin2[2];
260 mass_delta = (tmplt->mass1 - tmplt->mass2) / (m);
261 chis = 0.5 * (tmplt->spin1[2] + tmplt->spin2[2]);
262 chia = 0.5 * (tmplt->spin1[2] - tmplt->spin2[2]);
263 chi1 = tmplt->mass1 / m;
264 chi2 = tmplt->mass2 / m;
265 qm_def1 = 1; /* The QM deformability parameters */
266 qm_def2 = 1; /* This is 1 for black holes and larger for neutron stars */
267
268 /* Eq. (6.23) in arXiv:0810.5336 */
269 pn_beta = (113./12.- 19./3. * eta) * chis + 113./12. * mass_delta * chia;
270
271 /* See Eq. (6.24) in arXiv:0810.5336 */
272 /* 9b,c,d in arXiv:astro-ph/0504538 */
273 pn_sigma = eta * (721./48. *S1z*S2z-247./48.*S1z*S2z);
274 pn_sigma += (720*qm_def1 - 1)/96.0 * (chi1*chi1*S1z*S1z);
275 pn_sigma += (720*qm_def2 - 1)/96.0 * (chi2*chi2*S2z*S2z);
276 pn_sigma -= (240*qm_def1 - 7)/96.0 * (chi1*chi1*S1z*S1z);
277 pn_sigma -= (240*qm_def2 - 7)/96.0 * (chi2*chi2*S2z*S2z);
278
279 /* See Eq. (6.25) in arXiv:0810.5336 */
280 pn_gamma = (732985./2268. - 24260./81. * eta - 340./9. * eta * eta ) * chis;
281 pn_gamma += (732985./2268. +140./9.0 * eta) * chia * mass_delta;
282
283 if ( m <= 0 || eta <= 0 || mu <= 0 )
284 {
285 ABORT( status, FINDCHIRPH_EMASS, FINDCHIRPH_MSGEMASS );
286 }
287
288 /* template dependent normalisation */
289 distNorm = 2.0 * LAL_MRSUN_SI / (cannonDist * 1.0e6 * LAL_PC_SI);
290 distNorm *= params->dynRange;
291
292 fcTmplt->tmpltNorm = sqrt( (5.0*mu) / 96.0 ) *
293 pow( m / (LAL_PI*LAL_PI) , 1.0/3.0 ) *
294 pow( LAL_MTSUN_SI / (REAL4) params->deltaT, -1.0/6.0 );
295 fcTmplt->tmpltNorm *= fcTmplt->tmpltNorm;
296 fcTmplt->tmpltNorm *= distNorm * distNorm;
297
298 if ( lalDebugLevel & LALINFO )
299 {
300 snprintf( infomsg, XLAL_NUM_ELEM(infomsg),
301 "tmpltNorm = %e\n", fcTmplt->tmpltNorm );
302 LALInfo( status, infomsg );
303 }
304
305 /* Initialize all PN phase coeffs to zero. */
306 c0 = c10 = c15 = c20 = c25 = c25Log = 0.;
307 c30 = c30Log = c35 = c40P = 0.;
308
309 /* Switch on PN order, set the appropriate phase coeffs for that order */
310 switch( params->order )
311 {
313 c40P = 3923.0;
314#if __GNUC__ >= 7 && !defined __INTEL_COMPILER
315 __attribute__ ((fallthrough));
316#endif
318 c35 = LAL_PI*(77096675.0/254016.0 + eta*378515.0/1512.0
319 - eta*eta*74045.0/756.0);
320#if __GNUC__ >= 7 && !defined __INTEL_COMPILER
321 __attribute__ ((fallthrough));
322#endif
324 c30 = 11583231236531.0/4694215680.0 - LAL_GAMMA*6848.0/21.0
325 - LAL_PI*LAL_PI*640.0/3.0 + eta*(LAL_PI*LAL_PI*2255.0/12.0
326 - 15737765635.0/3048192.0) + eta*eta*76055.0/1728.0
327 - eta*eta*eta*127825.0/1296.0 - 6848.0*log(4.0)/21.0;
328 c30Log = -6848.0/21.0;
329#if __GNUC__ >= 7 && !defined __INTEL_COMPILER
330 __attribute__ ((fallthrough));
331#endif
333 c25 = LAL_PI*38645.0/756.0 - LAL_PI*eta*65.0/9.0 - pn_gamma;
334 c25Log = 3*c25;
335#if __GNUC__ >= 7 && !defined __INTEL_COMPILER
336 __attribute__ ((fallthrough));
337#endif
338 case LAL_PNORDER_TWO:
339 c20 = 15293365.0/508032.0 + eta*(27145.0/504.0 + eta*3085.0/72.0);
340 c20 -= 10. * pn_sigma;
341 c15 = -16*LAL_PI + 4.*pn_beta;
342 c10 = 3715.0/756.0 + eta*55.0/9.0;
343 c0 = 3.0/(eta*128.0);
344 break;
345 default:
346 ABORT( status, FINDCHIRPSPH_EORDR, FINDCHIRPSPH_MSGEORDR );
347 break;
348 }
349
350 /* x1 */
351 x1 = pow( LAL_PI * m * LAL_MTSUN_SI * deltaF, -1.0/3.0 );
352
353 /* frequency cutoffs */
354 if (params->dynamicTmpltFlow)
355 {
356 /* Dynamic lower cutoff
357 * Work out longest length for template
358 * Keep a few extra sample points for safety */
359 REAL4 currTime,maxT;
360 if (params->maxTempLength > 0)
361 {
362 /* If the maximum length is given use that */
363 maxT = params->maxTempLength;
364 }
365 else
366 {
367 /* If not work it out assuming middle of segment is analysed */
368 maxT = ((REAL4) params->deltaT * (REAL4) (numPoints-12))/4.;
369 maxT -= 0.5 * (REAL4) params->invSpecTrunc * (REAL4) params->deltaT;
370 }
371 fLow = -1;
372 for (f=1; f < 100; f++)
373 {
374 currTime = XLALFindChirpChirpTime( tmplt->mass1,
375 tmplt->mass2,
376 (double) f,
377 params->order);
378 if (currTime < maxT)
379 {
380 fLow = (REAL4) f;
381 break;
382 }
383 }
384 /* If nothing passed then fail */
385 if ( fLow < 0)
386 {
387 ABORT( status, FINDCHIRPH_EFLOX, FINDCHIRPH_MSGEFLOX );
388 }
389 }
390 else
391 {
392 fLow = params->fLow;
393 }
394
395 kmin = fLow / deltaF > 1 ? fLow / deltaF : 1;
396 kmax = tmplt->fFinal / deltaF < numPoints/2 ?
397 tmplt->fFinal / deltaF : numPoints/2;
398
399 /* compute psi0: used in range reduction */
400
401 /* This formula works for any PN order, because */
402 /* higher order coeffs will be set to zero. */
403
404 x = x1 * xfac[kmin];
405 psi = c0 * ( x * ( c20 + x * ( c15 + x * (c10 + x * x ) ) )
406 + c25 - c25Log * log(x) + (1.0/x)
407 * ( c30 - c30Log * log(x) + (1.0/x) * ( c35 - (1.0/x)
408 * c40P * log(x) ) ) );
409 psi0 = -2 * LAL_PI * ( floor ( 0.5 * psi / LAL_PI ) );
410
411
412 /*
413 *
414 * calculate the stationary phase chirp
415 *
416 */
417
418 /* This formula works for any PN order, because */
419 /* higher order coeffs will be set to zero. */
420
421 for ( k = kmin; k < kmax ; ++k )
422 {
423 REAL4 x_0 = x1 * xfac[k];
424 REAL4 psi_0 = c0 * ( x_0 * ( c20 + x_0 * ( c15 + x_0 * (c10 + x_0 * x_0 ) ) )
425 + c25 - c25Log * log(x_0) + (1.0/x_0) * ( c30 - c30Log * log(x_0)
426 + (1.0/x_0) * ( c35 - (1.0/x_0) * c40P * log(x_0) ) ) );
427 REAL4 psi1 = psi_0 + psi0;
428 REAL4 psi2;
429
430 /* range reduction of psi1 */
431 while ( psi1 < -LAL_PI )
432 {
433 psi1 += 2 * LAL_PI;
434 psi0 += 2 * LAL_PI;
435 }
436 while ( psi1 > LAL_PI )
437 {
438 psi1 -= 2 * LAL_PI;
439 psi0 -= 2 * LAL_PI;
440 }
441
442 /* compute approximate sine and cosine of psi1 */
443 if ( psi1 < -LAL_PI/2 )
444 {
445 psi1 = -LAL_PI - psi1;
446 psi2 = psi1 * psi1;
447 /* XXX minus sign added because of new sign convention for fft */
448 expPsi[k] = crectf( -1 - psi2 * ( c2 + psi2 * c4 ), - psi1 * ( 1 + psi2 * ( s2 + psi2 * s4 ) ) );
449 }
450 else if ( psi1 > LAL_PI/2 )
451 {
452 psi1 = LAL_PI - psi1;
453 psi2 = psi1 * psi1;
454 /* XXX minus sign added because of new sign convention for fft */
455 expPsi[k] = crectf( -1 - psi2 * ( c2 + psi2 * c4 ), - psi1 * ( 1 + psi2 * ( s2 + psi2 * s4 ) ) );
456 }
457 else
458 {
459 psi2 = psi1 * psi1;
460 /* XXX minus sign added because of new sign convention for fft */
461 expPsi[k] = crectf( 1 + psi2 * ( c2 + psi2 * c4 ), - psi1 * ( 1 + psi2 * ( s2 + psi2 * s4 ) ) );
462 }
463
464 /* if reverse chirp bank option selected, switch sign of imag. part */
465 if ( params->reverseChirpBank )
466 {
467 expPsi[k] = crectf( crealf(expPsi[k]), - cimagf(expPsi[k]) );
468 }
469
470 }
471
472
473 /*
474 *
475 * compute the length of the stationary phase chirp
476 *
477 */
478
479 tmplt->tC = XLALFindChirpChirpTime( tmplt->mass1,
480 tmplt->mass2,
481 fLow,
482 params->order);
483
484 /* copy the template parameters to the findchirp template structure */
485 memcpy( &(fcTmplt->tmplt), tmplt, sizeof(InspiralTemplate) );
486
487 /* normal exit */
489 RETURN( status );
490}
static double XLALFindChirpChirpTime(double m1, double m2, double fLower, int order)
int k
const double c2
const double c0
#define ABORT(statusptr, code, mesg)
#define ATTATCHSTATUSPTR(statusptr)
#define ASSERT(assertion, statusptr, code, mesg)
#define DETATCHSTATUSPTR(statusptr)
#define INITSTATUS(statusptr)
#define RETURN(statusptr)
#define fprintf
REAL4 fLower
Definition: blindinj.c:127
#define __attribute__(x)
#define FINDCHIRPH_EMASS
#define FINDCHIRPH_EFLOX
#define FINDCHIRPSPH_EDELT
deltaT is zero or negative
Definition: FindChirpSP.h:68
#define FINDCHIRPSPH_EORDR
Invalid post-Newtonian order.
Definition: FindChirpSP.h:75
#define FINDCHIRPSPH_ENULL
Null pointer.
Definition: FindChirpSP.h:62
void LALFindChirpSPTemplate(LALStatus *status, FindChirpTemplate *fcTmplt, InspiralTemplate *tmplt, FindChirpTmpltParams *params)
#define FINDCHIRPSPH_EMAPX
Mismatch in waveform approximant.
Definition: FindChirpSP.h:73
#define LAL_PI
#define LAL_MTSUN_SI
#define LAL_PC_SI
#define LAL_GAMMA
#define LAL_MRSUN_SI
#define XLAL_NUM_ELEM(x)
#define crectf(re, im)
char CHAR
uint32_t UINT4
float complex COMPLEX8
int32_t INT4
float REAL4
#define lalDebugLevel
LALINFO
int LALInfo(LALStatus *status, const char *info)
FindChirpSP
LAL_PNORDER_TWO_POINT_FIVE
LAL_PNORDER_THREE
LAL_PNORDER_TWO
LAL_PNORDER_PSEUDO_FOUR
LAL_PNORDER_THREE_POINT_FIVE
static const INT4 m
REAL4 psi
Definition: inspinj.c:519
static LALStatus status
Definition: inspinj.c:552
list mu
f
eta
m2
m1
int deltaF
chi2
chi1
log
kmin
kmax
REAL4 fLow
Definition: randombank.c:83
COMPLEX8 * data
This structure contains a frequency domain template used as input to the FindChirpFilter() routine.
COMPLEX8Vector * data
Vector of length containing the frequency template data ; For a template generated in the frequency ...
InspiralTemplate tmplt
The template parameters of this FindChirpTemplate; In addition to the mass parameters the following f...
REAL4 tmpltNorm
The template dependent normalisation constant ; For the stationary phase template FindChirpSP this is...
This structure contains the parameters for generation of templates by the various template generation...
Approximant approximant
LALPNOrder order
LALPNOrder order
Definition: tmpltbank.c:444
INT4 numPoints
Definition: tmpltbank.c:399