Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALSimulation 6.2.0.1-8a6b96f
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
PhenomPTest.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2013 Michael Puerrer
3 * Test code for LALSimIMRPhenomP(v1)
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#include <stdio.h>
22#include <stdlib.h>
23#include <math.h>
24#include <float.h>
25
26#include <lal/Units.h>
27#include <lal/LALAdaptiveRungeKuttaIntegrator.h>
28#include <lal/LALConstants.h>
29#include <lal/FindRoot.h>
30#include <lal/SeqFactories.h>
31#include <lal/LALSimInspiral.h>
32#include <lal/LALSimIMR.h>
33
34#include <lal/LALSimNoise.h>
35#include <lal/ComplexFFT.h>
36
37#include <lal/ComplexFFT.h>
38#include <gsl/gsl_errno.h>
39#include <gsl/gsl_spline.h>
40#include <gsl/gsl_math.h>
41
42#include <LALSimIMRPhenomP.c> /* Include source directly so we can carry out unit tests for internal functions */
43
44#define MYUNUSED(expr) do { (void)(expr); } while (0)
45
46void prC(const char *name, COMPLEX16 x);
47void prC(const char *name, COMPLEX16 x) {
48 printf("%s: %g + I %g\n", name, creal(x), cimag(x));
49}
50
51REAL8 sqr(REAL8 x);
52REAL8 sqr(REAL8 x) { return x*x; }
53
56 // Frequencies are in Hz!
57
58 // Assume that waveforms use same frequency points
59 int len1 = (*htilde1)->data->length;
60 int len2 = (*htilde1)->data->length;
61 if (len1 != len2) {
62 XLALPrintError("Length of waveforms differs!\n");
63 XLAL_ERROR(XLAL_EDOM); // FIXME
64 }
65 int n = len1;
66
68 REAL8 PSDfact = XLALSimNoisePSDaLIGOZeroDetHighPower((fMax-fMin)/4.);
69 REAL8 tableS;
70 COMPLEX16 h1,h2;
71
72 REAL8 norm1 = 0.0;
73 REAL8 norm2 = 0.0;
74 int iStart = (int)(fMin / df);
75 int iStop = (int)(fMax / df);
76 iStart = (iStart < 1) ? 1 : iStart;
77 iStop = (iStop > n) ? n : iStop;
78 for (int i=iStart; i<iStop; i++) {
79 REAL8 f = i*df;
80 tableS = PSDfact / XLALSimNoisePSDaLIGOZeroDetHighPower(f);
81 h1 = ((*htilde1)->data->data)[i];
82 h2 = ((*htilde2)->data->data)[i];
83 integrand->data[i] = h1 * conj(h2) * tableS;
84 norm1 += sqr(cabs(h1)) * tableS;
85 norm2 += sqr(cabs(h2)) * tableS;
86 // printf("f = %g\tnoise(f) = %g\ttableS[i] = %g\tintegrand[i] = %g\n", f, XLALSimNoisePSDaLIGOZeroDetHighPower(f), tableS, creal(integrand[i]));
87 // printf("{norm1, norm2} = {%g,%g}\t{%g,%g}\n", norm1,norm2, cabs(h1)*tableS, cabs(h2)*tableS);
88 }
89
90 n = iStop-iStart;
91 int zpf = 10;
92 int m = n + 2*zpf*n; // zero-pad on both sides
93 //printf("Total length %d\n", m);
94
95 COMPLEX16FFTPlan *myplan = XLALCreateForwardCOMPLEX16FFTPlan(m, 0);
98
99 // fill input array
100 for (int i=0; i<zpf*n; i++)
101 array_in->data[i] = 0.0;
102 for (int i=zpf*n; i<(zpf*n + n); i++)
103 array_in->data[i] = integrand->data[iStart + i-zpf*n];
104 for (int i=zpf*n + n; i<m; i++)
105 array_in->data[i] = 0.0;
106
107 XLALCOMPLEX16VectorFFT(array_out, array_in, myplan);
108
109 REAL8 match=0; REAL8 val;
110 for (int i=0; i<m; i++) {
111 val = cabs(array_out->data[i]);
112 if (val > match)
113 match = val;
114 }
115
116 XLALFree(array_in);
117 XLALFree(array_out);
119
120 return match / sqrt(norm1*norm2);
121}
122
123void dump_file(const char *filename, COMPLEX16FrequencySeries *hptilde, COMPLEX16FrequencySeries *hctilde, REAL8 M);
124void dump_file(const char *filename, COMPLEX16FrequencySeries *hptilde, COMPLEX16FrequencySeries *hctilde, REAL8 M) {
125 COMPLEX16 hp;
126 COMPLEX16 hc;
127 REAL8 f;
128 FILE *out;
129 REAL8 f_max_prime = 0;
130 int wflen = hptilde->data->length;
131 REAL8 deltaF = hptilde->deltaF;
132 out = fopen(filename, "w");
133 for (int i=1;i<wflen;i++) {
134 f = i*deltaF;
135 hp = (hptilde->data->data)[i];
136 hc = (hctilde->data->data)[i];
137 if (!(creal(hp) == 0 && cimag(hp) == 0 && creal(hc) == 0 && cimag(hc) == 0)) {
138 f_max_prime = (f > f_max_prime) ? f : f_max_prime;
139 fprintf(out, "%.15g\t%.15g\t%.15g\t%.15g\t%.15g\n", f*LAL_MTSUN_SI*M, creal(hp), cimag(hp), creal(hc), cimag(hc));
140 }
141 }
142 fclose(out);
143}
144
145bool approximatelyEqual(REAL8 a, REAL8 b, REAL8 epsilon);
147
149 return !gsl_fcmp(a, b, epsilon); // gsl_fcmp() returns 0 if the numbers a, b are approximately equal to a relative accuracy epsilon.
150}
151
153 return approximatelyEqual(creal(a), creal(b), epsilon) && approximatelyEqual(cimag(a), cimag(b), epsilon);
154}
155
156void print_difference(const char *name, REAL8 u, REAL8 u_expected);
157void print_difference(const char *name, REAL8 u, REAL8 u_expected) {
158 printf("%-8s: %-20.17g\t%-20.17g\t%-20.17g\n", name, u, u_expected, u - u_expected);
159}
160
161static void Test_alpha_epsilon(void);
162static void Test_alpha_epsilon(void) {
163 printf("\n** Test_alpha_epsilon: **\n");
164 const REAL8 f = 0.01;
165 const REAL8 q = 4;
166 const REAL8 chil = 0.5625;
167 const REAL8 chip = 0.18;
168
169 NNLOanglecoeffs angcoeffs;
170 ComputeNNLOanglecoeffs(&angcoeffs,q,chil,chip);
171
172 const REAL8 omega = LAL_PI * f;
173 const REAL8 logomega = log(omega);
174 const REAL8 omega_cbrt = cbrt(omega);
175 const REAL8 omega_cbrt2 = omega_cbrt*omega_cbrt;
176 const REAL8 alpha = (angcoeffs.alphacoeff1/omega
177 + angcoeffs.alphacoeff2/omega_cbrt2
178 + angcoeffs.alphacoeff3/omega_cbrt
179 + angcoeffs.alphacoeff4*logomega
180 + angcoeffs.alphacoeff5*omega_cbrt);
181
182 const REAL8 epsilon = (angcoeffs.epsiloncoeff1/omega
183 + angcoeffs.epsiloncoeff2/omega_cbrt2
184 + angcoeffs.epsiloncoeff3/omega_cbrt
185 + angcoeffs.epsiloncoeff4*logomega
186 + angcoeffs.epsiloncoeff5*omega_cbrt);
187
188 const REAL8 alpha_expected = -11.8195574;
189 const REAL8 epsilon_expected = -11.9359726;
190
191 print_difference("alpha", alpha, alpha_expected);
192 print_difference("epsilon", epsilon, epsilon_expected);
193
194 const REAL8 eps = 1e-5;
195
197 approximatelyEqual(alpha, alpha_expected, eps)
198 && approximatelyEqual(epsilon, epsilon_expected, eps)
199 && "Test_alpha_epsilon()"
200 );
201}
202
205 printf("\n** Test_XLALSimIMRPhenomPCalculateModelParameters: **\n");
206
207 REAL8 chi1_l, chi2_l, chi_eff, chip, thetaJ, alpha0;
208
209 REAL8 m1_SI = 10 * LAL_MSUN_SI;
210 REAL8 m2_SI = 40 * LAL_MSUN_SI;
211 REAL8 s1x = 0.3;
212 REAL8 s1y = 0;
213 REAL8 s1z = 0.45;
214 REAL8 s2x = 0;
215 REAL8 s2y = 0;
216 REAL8 s2z = 0.45;
217 REAL8 lnhatx = sin(0.4);
218 REAL8 lnhaty = 0;
219 REAL8 lnhatz = cos(0.4);
220 REAL8 f_min = 20;
221 REAL8 f_ref = f_min;
223
225 &chi1_l, /**< Output: aligned spin on companion 1 */
226 &chi2_l, /**< Output: aligned spin on companion 2 */
227 &chip, /**< Output: Effective spin in the orbital plane */
228 &thetaJ, /**< Output: Angle between J0 and line of sight (z-direction) */
229 &alpha0, /**< Output: Initial value of alpha angle (azimuthal precession angle) */
230 m1_SI, /**< Mass of companion 1 (kg) */
231 m2_SI, /**< Mass of companion 2 (kg) */
232 f_ref, /**< Reference GW frequency (Hz) */
233 lnhatx, /**< Initial value of LNhatx: orbital angular momentum unit vector */
234 lnhaty, /**< Initial value of LNhaty */
235 lnhatz, /**< Initial value of LNhatz */
236 s1x, /**< Initial value of s1x: dimensionless spin of larger BH */
237 s1y, /**< Initial value of s1y: dimensionless spin of larger BH */
238 s1z, /**< Initial value of s1z: dimensionless spin of larger BH */
239 s2x, /**< Initial value of s2x: dimensionless spin of larger BH */
240 s2y, /**< Initial value of s2y: dimensionless spin of larger BH */
241 s2z, /**< Initial value of s2z: dimensionless spin of larger BH */
242 version);
243
244 chi_eff = (m1_SI*chi1_l + m2_SI*chi2_l) / (m1_SI + m2_SI); /* Effective aligned spin */
245
246 REAL8 chi_eff_expected = 0.4378425478398173;
247 REAL8 chip_expected = 0.1752382540388927;
248 REAL8 thetaJ_expected = 0.29197409372473093;
249 REAL8 alpha0_expected = LAL_PI;
250
251 print_difference("chi_eff", chi_eff, chi_eff_expected);
252 print_difference("chip", chip, chip_expected);
253 print_difference("thetaJ", thetaJ, thetaJ_expected);
254 print_difference("alpha0", alpha0, alpha0_expected);
255
256 //const REAL8 eps = DBL_EPSILON;
257 const REAL8 eps = 1e-5;
258
259 XLAL_CHECK_EXIT(approximatelyEqual(chi_eff, chi_eff_expected, eps)
260 && approximatelyEqual(chip, chip_expected, eps)
261 && approximatelyEqual(thetaJ, thetaJ_expected, eps)
262 && approximatelyEqual(alpha0, alpha0_expected, eps)
263 && "Test_XLALSimIMRPhenomPCalculateModelParameters()"
264 );
265}
266
267
268#if 0
269static void Test_PhenomC(void);
270static void Test_PhenomC(void) {
271 printf("\n** Test_PhenomC: **\n");
272 const REAL8 fHz = 40.6051;
273 const REAL8 eta = 0.16;
274 const REAL8 m1 = 10;
275 const REAL8 m2 = 40;
276 const REAL8 chi = 0.45;
277 const REAL8 chip = 0.18;
278 const REAL8 M = (m1+m2);
279 const REAL8 distance = 100 * 1e6 * LAL_PC_SI;
280 const REAL8 phic = 0;
281 REAL8 phPhenomC = 0.0;
282 REAL8 aPhenomC = 0.0;
283
285 m1, /**< mass of companion 1 (solar masses) */
286 m2, /**< mass of companion 2 (solar masses) */
287 chi, /**< Reduced aligned spin of the binary chi = (m1*chi1 + m2*chi2)/M */
288 chip, /**< Dimensionless spin in the orbial plane */
289 NULL); /**< No testing GR parameters */
290
291 int errcode = IMRPhenomCGenerateAmpPhase( &aPhenomC, &phPhenomC, fHz, eta, PCparams );
292 if( errcode != XLAL_SUCCESS )
293 exit(-1);
294 phPhenomC -= 2.*phic; /* Note: phic is orbital phase */
295 REAL8 amp0 = 2. * sqrt(5. / (64.*LAL_PI)) * M * LAL_MRSUN_SI * M * LAL_MTSUN_SI / distance;
296 printf("test %g\n", M* LAL_MRSUN_SI * M* LAL_MTSUN_SI / distance);
297 COMPLEX16 hPC = amp0 * aPhenomC * cexp(-I*phPhenomC); /* Assemble PhenomC waveform. */
298 printf("phPhenomC: %g\n", phPhenomC);
299 printf("aPhenomC: %g\tamp0: %g\n", aPhenomC, amp0);
300 printf("LAL_MRSUN_SI, LAL_MTSUN_SI, LAL_PC_SI: %g\t%g\t%g\n",LAL_MRSUN_SI, LAL_MTSUN_SI, LAL_PC_SI);
301 prC("hPC", hPC);
302
303 COMPLEX16 hPC_expected = -4.08291e-23 - I * 8.89596e-23;
304
305 const REAL8 eps = 1e-5;
306
308 approximatelyEqualC(hPC, hPC_expected, eps)
309 && "Test_PhenomC()"
310 );
311}
312#endif
313
314#if 0
315static void Test_PhenomPCore(void);
316static void Test_PhenomPCore(void) {
317 printf("\n** Test_PhenomPCore: **\n");
318 BBHPhenomCParams *PCparams = ComputeIMRPhenomCParamsRDmod(10, 40, 0.45, 0.18, NULL);
319 REAL8 q = 4;
320 REAL8 chi_eff = 0.45;
321 const REAL8 chil = (1.0+q)/q * chi_eff; /* dimensionless aligned spin of the largest BH */
322 printf("chil %g\n", chil);
323 REAL8 chip = 0.18;
324 NNLOanglecoeffs angcoeffs;
325 ComputeNNLOanglecoeffs(&angcoeffs,q,chil,chip);
326 const REAL8 m_sec = 50 * LAL_MTSUN_SI; /* Total mass in seconds */
327 const REAL8 piM = LAL_PI * m_sec;
328 const REAL8 omega_ref = piM * 20;
329 const REAL8 logomega_ref = log(omega_ref);
330 const REAL8 omega_ref_cbrt = cbrt(omega_ref);
331 const REAL8 omega_ref_cbrt2 = omega_ref_cbrt*omega_ref_cbrt;
332 const REAL8 alphaNNLOoffset = (angcoeffs.alphacoeff1/omega_ref
333 + angcoeffs.alphacoeff2/omega_ref_cbrt2
334 + angcoeffs.alphacoeff3/omega_ref_cbrt
335 + angcoeffs.alphacoeff4*logomega_ref
336 + angcoeffs.alphacoeff5*omega_ref_cbrt);
337 printf("alphaNNLOoffset %g\n", alphaNNLOoffset);
338
340 const REAL8 ytheta = 0.279523;
341 const REAL8 yphi = alphaNNLOoffset - 0.0234206;
342 printf("yphi %g\n", alphaNNLOoffset - 0.0234206);
343 Y2m.Y2m2 = XLALSpinWeightedSphericalHarmonic(ytheta, yphi, -2, 2, -2);
344 Y2m.Y2m1 = XLALSpinWeightedSphericalHarmonic(ytheta, yphi, -2, 2, -1);
345 Y2m.Y20 = XLALSpinWeightedSphericalHarmonic(ytheta, yphi, -2, 2, 0);
346 Y2m.Y21 = XLALSpinWeightedSphericalHarmonic(ytheta, yphi, -2, 2, 1);
347 Y2m.Y22 = XLALSpinWeightedSphericalHarmonic(ytheta, yphi, -2, 2, 2);
348
349 COMPLEX16 hp, hc;
350 REAL8 phasing;
351 REAL8 fHz = 40.6051; // Mf = 0.01 for M=50Msun
352 const UINT4 version = 1;
354 IMRPhenomDPhaseCoefficients *pPhi = NULL;
355 PNPhasingSeries *PNparams = NULL;
356 AmpInsPrefactors * amp_prefactors = NULL;
357 PhiInsPrefactors * phi_prefactors = NULL;
358
359 int ret = PhenomPCoreOneFrequency(
360 fHz, /**< frequency (Hz) */
361 0.16, /**< symmetric mass ratio */
362 0.45, /**< dimensionless effective total aligned spin */
363 0.18, /**< dimensionless spin in the orbial plane */
364 100 * 1e6 * LAL_PC_SI, /**< distance of source (m) */
365 50, /**< total mass (Solar masses) */
366 0, /**< orbital coalescence phase (rad) */
367 pAmp, /**< Internal IMRPhenomD amplitude coefficients */
368 pPhi, /**< Internal IMRPhenomD phase coefficients */
369 PCparams, /**< internal PhenomC parameters */
370 PNparams, /**< PN inspiral phase coefficients */
371 &angcoeffs, /**< struct with PN coeffs for the NNLO angles */
372 &Y2m, /**< struct of l=2 spherical harmonics of spin weight -2 */
373 0,0,
374 &hp, /**< output: \f$\tilde h_+\f$ */
375 &hc, /**< output: \f$\tilde h_+\f$ */
376 &phasing, /**< Output: overall phasing */
377 version,
378 amp_prefactors,
379 phi_prefactors
380);
381
382 MYUNUSED(ret);
383 prC("hp", hp);
384 prC("hc", hc);
385
386 COMPLEX16 hp_expected = 2.06975e-23 - I * 9.29353e-23;
387 COMPLEX16 hc_expected = -9.29441e-23 - I * 2.06616e-23;
388 const REAL8 eps = 1e-5;
389
391 approximatelyEqualC(hp, hp_expected, eps)
392 && approximatelyEqualC(hc, hc_expected, eps)
393 && "Test_PhenomPCore()"
394 );
395}
396#endif
397
398static void Test_XLALSimIMRPhenomP(void);
399static void Test_XLALSimIMRPhenomP(void) {
400 printf("\n** Test_XLALSimIMRPhenomP: **\n");
401
402 REAL8 chi1_l, chi2_l, chip, thetaJ, alpha0;
403
404 REAL8 m1 = 10;
405 REAL8 m2 = 40;
406 REAL8 m1_SI = m1 * LAL_MSUN_SI;
407 REAL8 m2_SI = m2 * LAL_MSUN_SI;
408 REAL8 s1x = 0.3;
409 REAL8 s1y = 0;
410 REAL8 s1z = 0.45;
411 REAL8 s2x = 0;
412 REAL8 s2y = 0;
413 REAL8 s2z = 0.45;
414 REAL8 lnhatx = sin(0.4);
415 REAL8 lnhaty = 0;
416 REAL8 lnhatz = cos(0.4);
417 REAL8 f_min = 20;
418 REAL8 f_ref = f_min;
421
423 &chi1_l, /**< Output: aligned spin on companion 1 */
424 &chi2_l, /**< Output: aligned spin on companion 2 */
425 &chip, /**< Output: Effective spin in the orbital plane */
426 &thetaJ, /**< Output: Angle between J0 and line of sight (z-direction) */
427 &alpha0, /**< Output: Initial value of alpha angle (azimuthal precession angle) */
428 m1_SI, /**< Mass of companion 1 (kg) */
429 m2_SI, /**< Mass of companion 2 (kg) */
430 f_ref, /**< Reference GW frequency (Hz) */
431 lnhatx, /**< Initial value of LNhatx: orbital angular momentum unit vector */
432 lnhaty, /**< Initial value of LNhaty */
433 lnhatz, /**< Initial value of LNhatz */
434 s1x, /**< Initial value of s1x: dimensionless spin of larger BH */
435 s1y, /**< Initial value of s1y: dimensionless spin of larger BH */
436 s1z, /**< Initial value of s1z: dimensionless spin of larger BH */
437 s2x, /**< Initial value of s2x: dimensionless spin of larger BH */
438 s2y, /**< Initial value of s2y: dimensionless spin of larger BH */
439 s2z, /**< Initial value of s2z: dimensionless spin of larger BH */
440 version);
441
442 COMPLEX16FrequencySeries *hptilde = NULL;
443 COMPLEX16FrequencySeries *hctilde = NULL;
444 REAL8 phic = 0;
445 REAL8 deltaF = 0.06;
446 REAL8 f_max = 0; // 8000;
447 REAL8 distance = 100 * 1e6 * LAL_PC_SI;
448
449 int ret = XLALSimIMRPhenomP(
450 &hptilde, /**< Frequency-domain waveform h+ */
451 &hctilde, /**< Frequency-domain waveform hx */
452 chi1_l, /**< aligned spin on companion 1 */
453 chi2_l, /**< aligned spin on companion 2 */
454 chip, /**< Effective spin in the orbital plane */
455 thetaJ, /**< Angle between J0 and line of sight (z-direction) */
456 m1_SI, /**< mass of companion1 (kg) */
457 m2_SI, /**< mass of companion1 (kg) */
458 distance, /**< Distance of source (m) */
459 alpha0, /**< Initial value of alpha angle */
460 phic, /**< Orbital coalescence phase (rad) */
461 deltaF, /**< Sampling frequency (Hz) */
462 f_min, /**< Starting GW frequency (Hz) */
463 f_max, /**< End frequency; 0 defaults to ringdown cutoff freq */
464 f_ref, /**< Reference frequency */
465 version,
466 NRTv,
467 NULL); /**<linked list containing the extra testing GR parameters */
468
469 dump_file("PhenomP_Test1.dat", hptilde, hctilde, m1+m2);
470 MYUNUSED(ret);
471 COMPLEX16 hp = (hptilde->data->data)[1000];
472 COMPLEX16 hc = (hctilde->data->data)[1000];
473 prC("hp", hp);
474 prC("hc", hc);
475
476 COMPLEX16 hp_expected = -5.17642e-23 + I * 2.60463e-23;
477 COMPLEX16 hc_expected = 2.6046e-23 + I * 5.17592e-23;
478 const REAL8 eps = 1e-5;
479
481 approximatelyEqualC(hp, hp_expected, eps)
482 && approximatelyEqualC(hc, hc_expected, eps)
483 && "XLALSimIMRPhenomP()"
484 );
485
486}
487
488#if 0
489static void Test_PhenomC_PhenomP(void);
490static void Test_PhenomC_PhenomP(void) {
491 printf("\n** Test_PhenomC_PhenomP: **\n");
492 REAL8 eta = 0.16;
493 REAL8 chi = 0.45;
494 REAL8 q = (1 + sqrt(1 - 4*eta) - 2*eta)/(2.*eta);
495 REAL8 M = 50;
496
497 // Parameters for XLALSimIMRPhenomPCalculateModelParameters
498 COMPLEX16FrequencySeries *hptilde = NULL;
499 COMPLEX16FrequencySeries *hctilde = NULL;
500 REAL8 phic = 0;
501 REAL8 deltaF = 0.06;
502 REAL8 m1_SI = M * q/(1+q) * LAL_MSUN_SI;
503 REAL8 m2_SI = M * 1.0/(1+q) * LAL_MSUN_SI;
504 REAL8 f_min = 10;
505 REAL8 f_ref = f_min;
506 REAL8 f_max = 0; // 8000;
507 REAL8 distance = 100 * 1e6 * LAL_PC_SI;
508 REAL8 s1x = 0;
509 REAL8 s1y = 0;
510 REAL8 s1z = chi;
511 REAL8 s2x = 0;
512 REAL8 s2y = 0;
513 REAL8 s2z = chi;
514 REAL8 lnhatx = 0;
515 REAL8 lnhaty = 0;
516 REAL8 lnhatz = 1;
517 const UINT4 version = 1;
518 const LALSimInspiralTestGRParam *nonGR = NULL;
519
520 REAL8 chi1_l, chi2_l, chip, thetaJ, alpha0;
521
522 XLALSimIMRPhenomPCalculateModelParameters(
523 &chi1_l, /**< Output: aligned spin on companion 1 */
524 &chi2_l, /**< Output: aligned spin on companion 2 */
525 &chip, /**< Output: Effective spin in the orbital plane */
526 &thetaJ, /**< Output: Angle between J0 and line of sight (z-direction) */
527 &alpha0, /**< Output: Initial value of alpha angle (azimuthal precession angle) */
528 m1_SI, /**< Mass of companion 1 (kg) */
529 m2_SI, /**< Mass of companion 2 (kg) */
530 f_ref, /**< Starting GW frequency (Hz) */
531 lnhatx, /**< Initial value of LNhatx: orbital angular momentum unit vector */
532 lnhaty, /**< Initial value of LNhaty */
533 lnhatz, /**< Initial value of LNhatz */
534 s1x, /**< Initial value of s1x: dimensionless spin of larger BH */
535 s1y, /**< Initial value of s1y: dimensionless spin of larger BH */
536 s1z, /**< Initial value of s1z: dimensionless spin of larger BH */
537 s2x, /**< Initial value of s2x: dimensionless spin of larger BH */
538 s2y, /**< Initial value of s2y: dimensionless spin of larger BH */
539 s2z); /**< Initial value of s2z: dimensionless spin of larger BH */
540
541// printf("chi_eff = %g\n", chi_eff);
542 printf("chip = %g\n", chip);
543 printf("eta = %g\n", eta);
544 printf("thetaJ = %g\n", thetaJ);
545
546 int ret = XLALSimIMRPhenomP(
547 &hptilde, /**< Frequency-domain waveform h+ */
548 &hctilde, /**< Frequency-domain waveform hx */
549 chi1_l, /**< aligned spin on companion 1 */
550 chi2_l, /**< aligned spin on companion 2 */
551 chip, /**< Effective spin in the orbital plane */
552 thetaJ, /**< Angle between J0 and line of sight (z-direction) */
553 m1_SI, /**< Mass of companion 1 (kg) */
554 m2_SI, /**< Mass of companion 2 (kg) */
555 distance, /**< Distance of source (m) */
556 alpha0, /**< Initial value of alpha angle (azimuthal precession angle) */
557 phic, /**< Orbital coalescence phase (rad) */
558 deltaF, /**< Sampling frequency (Hz) */
559 f_min, /**< Starting GW frequency (Hz) */
560 f_max, /**< End frequency; 0 defaults to ringdown cutoff freq */
561 f_ref, /**< Reference frequency */
562 version,
563 nonGR);
564
565 int wflen = hptilde->data->length;
566 REAL8 f_max_prime = 0;
567 FILE *out;
568 out = fopen("XLALSimIMRPhenomP.dat", "w");
569 for (int i=1;i<wflen;i++) {
570 REAL8 f = i*deltaF;
571 COMPLEX16 hp = (hptilde->data->data)[i];
572 COMPLEX16 hc = (hctilde->data->data)[i];
573 if (!(creal(hp) == 0 && cimag(hp) == 0 && creal(hc) == 0 && cimag(hc) == 0)) {
574 f_max_prime = (f > f_max_prime) ? f : f_max_prime;
575 fprintf(out, "%.15g\t%.15g\t%.15g\t%.15g\t%.15g\n", f*LAL_MTSUN_SI*M, creal(hp), cimag(hp), creal(hc), cimag(hc));
576 }
577 }
578 fclose(out);
579 printf("f_max_prime = %g\n", f_max_prime);
580
581
582 COMPLEX16FrequencySeries *htildePC = NULL;
584 &htildePC, /**< FD waveform */
585 phic, /**< orbital phase at peak (rad) */
586 deltaF, /**< sampling interval (Hz) */
587 m1_SI, /**< mass of companion 1 (kg) */
588 m2_SI, /**< mass of companion 2 (kg) */
589 chi, /**< mass-weighted aligned-spin parameter */
590 f_min, /**< starting GW frequency (Hz) */
591 f_max, /**< end frequency; 0 defaults to ringdown cutoff freq */
592 distance, /**< distance of source (m) */
593 nonGR
594 );
595
596 out = fopen("XLALSimIMRPhenomC.dat", "w");
597 wflen = hptilde->data->length;
598 for (int i=1;i<wflen;i++) {
599 REAL8 f = i*deltaF;
600 COMPLEX16 hp = (htildePC->data->data)[i];
601 if (!(creal(hp) == 0 && cimag(hp) == 0))
602 fprintf(out, "%.15g\t%.15g\t%.15g\n", f*LAL_MTSUN_SI*M, creal(hp), cimag(hp));
603 }
604 fclose(out);
605
606 // Now compute match between PhenomC and PhenomP for this aligned configuration
607 REAL8 match = MatchSI(&hptilde, &htildePC, f_min, f_max_prime, deltaF);
608 REAL8 match_expected = 0.999465;
609
610 const REAL8 eps = 1e-5;
611
613 approximatelyEqualC(match, match_expected, eps)
614 && "Test_PhenomC_PhenomP()"
615 );
616
617 printf("match(PhenomP_aligned, PhenomC) = %g\n", match);
618 MYUNUSED(ret);
619}
620#endif
621
622static void Test_XLALSimIMRPhenomP_f_ref(void);
624 // For aligned spins f_ref should not change the waveform
625 printf("\n** Test_XLALSimIMRPhenomP_f_ref: **\n");
626
627 REAL8 chi1_l, chi2_l, chip, thetaJ, alpha0;
628
629 REAL8 m1 = 10;
630 REAL8 m2 = 40;
631 REAL8 m1_SI = m1 * LAL_MSUN_SI;
632 REAL8 m2_SI = m2 * LAL_MSUN_SI;
633 REAL8 s1x = 0.45*sin(0.4);
634 REAL8 s1y = 0;
635 REAL8 s1z = 0.45*cos(0.4);
636 REAL8 s2x = 0.45*sin(0.4);
637 REAL8 s2y = 0;
638 REAL8 s2z = 0.45*cos(0.4);
639 REAL8 lnhatx = sin(0.4);
640 REAL8 lnhaty = 0;
641 REAL8 lnhatz = cos(0.4);
642 REAL8 f_min = 20;
643 REAL8 f_ref = f_min;
646
648 &chi1_l, /**< Output: aligned spin on companion 1 */
649 &chi2_l, /**< Output: aligned spin on companion 2 */
650 &chip, /**< Output: Effective spin in the orbital plane */
651 &thetaJ, /**< Output: Angle between J0 and line of sight (z-direction) */
652 &alpha0, /**< Output: Initial value of alpha angle (azimuthal precession angle) */
653 m1_SI, /**< Mass of companion 1 (kg) */
654 m2_SI, /**< Mass of companion 2 (kg) */
655 f_ref, /**< Reference GW frequency (Hz) */
656 lnhatx, /**< Initial value of LNhatx: orbital angular momentum unit vector */
657 lnhaty, /**< Initial value of LNhaty */
658 lnhatz, /**< Initial value of LNhatz */
659 s1x, /**< Initial value of s1x: dimensionless spin of larger BH */
660 s1y, /**< Initial value of s1y: dimensionless spin of larger BH */
661 s1z, /**< Initial value of s1z: dimensionless spin of larger BH */
662 s2x, /**< Initial value of s2x: dimensionless spin of larger BH */
663 s2y, /**< Initial value of s2y: dimensionless spin of larger BH */
664 s2z, /**< Initial value of s2z: dimensionless spin of larger BH */
665 version);
666
667 COMPLEX16FrequencySeries *hptilde = NULL;
668 COMPLEX16FrequencySeries *hctilde = NULL;
669 REAL8 phic = 0;
670 REAL8 deltaF = 0.06;
671 REAL8 f_max = 0; // 8000;
672 REAL8 distance = 100 * 1e6 * LAL_PC_SI;
673
674 int ret = XLALSimIMRPhenomP(
675 &hptilde, /**< Frequency-domain waveform h+ */
676 &hctilde, /**< Frequency-domain waveform hx */
677 chi1_l, /**< aligned spin on companion 1 */
678 chi2_l, /**< aligned spin on companion 2 */
679 chip, /**< Effective spin in the orbital plane */
680 thetaJ, /**< Angle between J0 and line of sight (z-direction) */
681 m1_SI, /**< mass of companion1 (kg) */
682 m2_SI, /**< mass of companion1 (kg) */
683 distance, /**< Distance of source (m) */
684 alpha0, /**< Initial value of alpha angle (azimuthal precession angle) */
685 phic, /**< Orbital coalescence phase (rad) */
686 deltaF, /**< Sampling frequency (Hz) */
687 f_min, /**< Starting GW frequency (Hz) */
688 f_max, /**< End frequency; 0 defaults to ringdown cutoff freq */
689 f_ref, /**< Reference frequency */
690 version,
691 NRTv,
692 NULL);
693
694 dump_file("PhenomP_Test_f_ref1.dat", hptilde, hctilde, m1+m2);
695 MYUNUSED(ret);
696 COMPLEX16 hp = (hptilde->data->data)[1000];
697 COMPLEX16 hc = (hctilde->data->data)[1000];
698 printf("f_ref = %g\n", f_ref);
699 prC("hp", hp);
700 prC("hc", hc);
701
702 // Now repeat for a different f_ref
703 f_ref = 5;
704
706 &chi1_l, /**< Output: aligned spin on companion 1 */
707 &chi2_l, /**< Output: aligned spin on companion 2 */
708 &chip, /**< Output: Effective spin in the orbital plane */
709 &thetaJ, /**< Output: Angle between J0 and line of sight (z-direction) */
710 &alpha0, /**< Output: Initial value of alpha angle (azimuthal precession angle) */
711 m1_SI, /**< Mass of companion 1 (kg) */
712 m2_SI, /**< Mass of companion 2 (kg) */
713 f_ref, /**< Reference GW frequency (Hz) */
714 lnhatx, /**< Initial value of LNhatx: orbital angular momentum unit vector */
715 lnhaty, /**< Initial value of LNhaty */
716 lnhatz, /**< Initial value of LNhatz */
717 s1x, /**< Initial value of s1x: dimensionless spin of larger BH */
718 s1y, /**< Initial value of s1y: dimensionless spin of larger BH */
719 s1z, /**< Initial value of s1z: dimensionless spin of larger BH */
720 s2x, /**< Initial value of s2x: dimensionless spin of larger BH */
721 s2y, /**< Initial value of s2y: dimensionless spin of larger BH */
722 s2z, /**< Initial value of s2z: dimensionless spin of larger BH */
723 version);
724
725 COMPLEX16FrequencySeries *hptilde2 = NULL;
726 COMPLEX16FrequencySeries *hctilde2 = NULL;
727
728 ret = XLALSimIMRPhenomP(
729 &hptilde2, /**< Frequency-domain waveform h+ */
730 &hctilde2, /**< Frequency-domain waveform hx */
731 chi1_l, /**< aligned spin on companion 1 */
732 chi2_l, /**< aligned spin on companion 2 */
733 chip, /**< Effective spin in the orbital plane */
734 thetaJ, /**< Angle between J0 and line of sight (z-direction) */
735 m1_SI, /**< mass of companion1 (kg) */
736 m2_SI, /**< mass of companion1 (kg) */
737 distance, /**< Distance of source (m) */
738 alpha0, /**< Initial value of alpha angle (azimuthal precession angle) */
739 phic, /**< Orbital coalescence phase (rad) */
740 deltaF, /**< Sampling frequency (Hz) */
741 f_min, /**< Starting GW frequency (Hz) */
742 f_max, /**< End frequency; 0 defaults to ringdown cutoff freq */
743 f_ref, /**< Reference frequency */
744 version,
745 NRTv,
746 NULL);
747
748
749 dump_file("PhenomP_Test_f_ref2.dat", hptilde2, hctilde2, m1+m2);
750 MYUNUSED(ret);
751 COMPLEX16 hp2 = (hptilde2->data->data)[1000];
752 COMPLEX16 hc2 = (hctilde2->data->data)[1000];
753 printf("f_ref = %g\n", f_ref);
754 prC("hp", hp2);
755 prC("hc", hc2);
756
757 const REAL8 eps = 1e-5;
758
760 approximatelyEqualC(hp, hp2, eps)
761 && approximatelyEqualC(hc, hc2, eps)
762 && "XLALSimIMRPhenomP_f_ref()"
763 );
764}
765
766int main(int argc, char *argv[]) {
767 MYUNUSED(argc);
768 MYUNUSED(argv);
769
770#ifndef _OPENMP
773 //Test_PhenomC();
774 //Test_PhenomPCore();
776 //Test_PhenomC_PhenomP();
778#else
781 //MYUNUSED(Test_PhenomC);
782 //MYUNUSED(Test_PhenomPCore);
784 //MYUNUSED(Test_PhenomC_PhenomP);
786#endif
787
788 printf("\nAll done!\n");
789 return 0;
790}
static int IMRPhenomCGenerateAmpPhase(REAL8 *amplitude, REAL8 *phasing, REAL8 f, REAL8 eta, const BBHPhenomCParams *params)
static void ComputeNNLOanglecoeffs(NNLOanglecoeffs *angcoeffs, const REAL8 q, const REAL8 chil, const REAL8 chip)
Next-to-next-to-leading order PN coefficients for Euler angles and .
static int PhenomPCoreOneFrequency(const REAL8 fHz, const REAL8 eta, const REAL8 distance, const REAL8 M, const REAL8 phic, IMRPhenomDAmplitudeCoefficients *pAmp, IMRPhenomDPhaseCoefficients *pPhi, BBHPhenomCParams *PCparams, PNPhasingSeries *PNparams, COMPLEX16 *hPhenom, REAL8 *phasing, IMRPhenomP_version_type IMRPhenomP_version, AmpInsPrefactors *amp_prefactors, PhiInsPrefactors *phi_prefactors)
static UNUSED BBHPhenomCParams * ComputeIMRPhenomCParamsRDmod(const REAL8 m1, const REAL8 m2, const REAL8 chi, const REAL8 chip, LALDict *extraParams)
PhenomC parameters for modified ringdown, uses final spin formula of:
const char * name
bool approximatelyEqual(REAL8 a, REAL8 b, REAL8 epsilon)
Definition: PhenomPTest.c:148
int main(int argc, char *argv[])
Definition: PhenomPTest.c:766
static void Test_alpha_epsilon(void)
Definition: PhenomPTest.c:162
#define MYUNUSED(expr)
Definition: PhenomPTest.c:44
REAL8 sqr(REAL8 x)
Definition: PhenomPTest.c:52
void print_difference(const char *name, REAL8 u, REAL8 u_expected)
Definition: PhenomPTest.c:157
REAL8 MatchSI(COMPLEX16FrequencySeries **htilde1, COMPLEX16FrequencySeries **htilde2, REAL8 fMin, REAL8 fMax, REAL8 df)
Definition: PhenomPTest.c:55
static void Test_XLALSimIMRPhenomP(void)
Definition: PhenomPTest.c:399
void prC(const char *name, COMPLEX16 x)
Definition: PhenomPTest.c:47
static void Test_XLALSimIMRPhenomP_f_ref(void)
Definition: PhenomPTest.c:623
void dump_file(const char *filename, COMPLEX16FrequencySeries *hptilde, COMPLEX16FrequencySeries *hctilde, REAL8 M)
Definition: PhenomPTest.c:124
static void Test_XLALSimIMRPhenomPCalculateModelParameters(void)
Definition: PhenomPTest.c:204
bool approximatelyEqualC(COMPLEX16 a, COMPLEX16 b, REAL8 epsilon)
Definition: PhenomPTest.c:152
#define fprintf
REAL8 M
Definition: bh_qnmode.c:133
double i
Definition: bh_ringdown.c:118
double e
Definition: bh_ringdown.c:117
const double u
COMPLEX16FFTPlan * XLALCreateForwardCOMPLEX16FFTPlan(UINT4 size, int measurelvl)
void XLALDestroyCOMPLEX16FFTPlan(COMPLEX16FFTPlan *plan)
int XLALCOMPLEX16VectorFFT(COMPLEX16Vector *_LAL_RESTRICT_ output, const COMPLEX16Vector *_LAL_RESTRICT_ input, const COMPLEX16FFTPlan *plan)
#define LAL_MSUN_SI
#define LAL_PI
#define LAL_MTSUN_SI
#define LAL_PC_SI
#define LAL_MRSUN_SI
double complex COMPLEX16
double REAL8
uint32_t UINT4
void XLALFree(void *p)
IMRPhenomP_version_type
Definition: LALSimIMR.h:73
NRTidal_version_type
Definition: LALSimIMR.h:80
@ IMRPhenomPv2_V
version 2: based on IMRPhenomD
Definition: LALSimIMR.h:75
@ NoNRT_V
special case for PhenomPv2 BBH baseline
Definition: LALSimIMR.h:87
int XLALSimIMRPhenomP(COMPLEX16FrequencySeries **hptilde, COMPLEX16FrequencySeries **hctilde, const REAL8 chi1_l, const REAL8 chi2_l, const REAL8 chip, const REAL8 thetaJ, const REAL8 m1_SI, const REAL8 m2_SI, const REAL8 distance, const REAL8 alpha0, const REAL8 phic, const REAL8 deltaF, const REAL8 f_min, const REAL8 f_max, const REAL8 f_ref, IMRPhenomP_version_type IMRPhenomP_version, NRTidal_version_type NRTidal_version, LALDict *extraParams)
Driver routine to compute the precessing inspiral-merger-ringdown phenomenological waveform IMRPhenom...
int XLALSimIMRPhenomPCalculateModelParametersOld(REAL8 *chi1_l, REAL8 *chi2_l, REAL8 *chip, REAL8 *thetaJ, REAL8 *alpha0, const REAL8 m1_SI, const REAL8 m2_SI, const REAL8 f_ref, const REAL8 lnhatx, const REAL8 lnhaty, const REAL8 lnhatz, const REAL8 s1x, const REAL8 s1y, const REAL8 s1z, const REAL8 s2x, const REAL8 s2y, const REAL8 s2z, IMRPhenomP_version_type IMRPhenomP_version)
Deprecated : used the old convention (view frame for the spins) Function to map LAL parameters (masse...
int XLALSimIMRPhenomCGenerateFD(COMPLEX16FrequencySeries **htilde, const REAL8 phiPeak, const REAL8 deltaF, const REAL8 m1_SI, const REAL8 m2_SI, const REAL8 chi, const REAL8 f_min, const REAL8 f_max, const REAL8 distance, LALDict *extraParams)
Driver routine to compute the spin-aligned, inspiral-merger-ringdown phenomenological waveform IMRPhe...
double XLALSimNoisePSDaLIGOZeroDetHighPower(double f)
Provides the noise power spectrum for aLIGO under the high-power broad-band signal recycling (no detu...
static const INT4 m
static const INT4 q
static const REAL4 eps
static const INT4 a
COMPLEX16 XLALSpinWeightedSphericalHarmonic(REAL8 theta, REAL8 phi, int s, int l, int m)
COMPLEX16Vector * XLALCreateCOMPLEX16Vector(UINT4 length)
#define XLAL_ERROR(...)
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
#define XLAL_CHECK_EXIT(assertion)
XLAL_SUCCESS
XLAL_EDOM
string version
filename
x
double alpha
Definition: sgwb.c:106
used to cache the recurring (frequency-independent) prefactors of AmpInsAnsatz.
COMPLEX16Sequence * data
COMPLEX16 * data
Structure holding all coefficients for the amplitude.
Structure holding all coefficients for the phase.
Linked list of any number of parameters for testing GR.
used to cache the recurring (frequency-independent) prefactors of PhiInsAnsatzInt.
double f_min
Definition: unicorn.c:22
double f_max
Definition: unicorn.c:23