LALSimulation  5.4.0.1-fe68b98
LALSimInspiralSpinTaylorF2.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Andrew Lundgren
3  * Based on code in LALSimInspiralTaylorF2.c
4  * Copyright (C) 2007 Jolien Creighton, B.S. Sathyaprakash, Thomas Cokelaer
5  * Copyright (C) 2012 Leo Singer, Evan Ochsner, Les Wade, Alex Nitz
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with with program; see the file COPYING. If not, write to the
19  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20  * MA 02110-1301 USA
21  */
22 
23 #include <stdlib.h>
24 #include <math.h>
25 #include <lal/Date.h>
26 #include <lal/FrequencySeries.h>
27 #include <lal/LALConstants.h>
28 #include <lal/LALDatatypes.h>
29 #include <lal/LALSimInspiral.h>
30 #include <lal/Units.h>
31 #include <lal/XLALError.h>
33 #include <stdio.h>
34 #include <stdbool.h>
35 
36 #ifndef _OPENMP
37 #define omp ignore
38 #endif
39 
40 typedef struct tagLALSimInspiralSF2Orientation
41 {
42  REAL8 thetaJ, psiJ;
43  REAL8 chi, kappa, alpha0;
46 
47 typedef struct tagLALSimInspiralSF2Coeffs
48 {
49  REAL8 m1, m2, mtot, eta;
50  REAL8 kappa, kappa_perp, gamma0;
52  REAL8 aclog1, aclog2;
53  REAL8 ac[6];
54  REAL8 zc[7];
56 
57 // Prototypes
58 
59 static REAL8 safe_atan2(REAL8 val1, REAL8 val2);
60 
62  LALSimInspiralSF2Orientation *orientation,
63  REAL8 m1, REAL8 m2, REAL8 v_ref,
64  REAL8 lnhatx, REAL8 lnhaty, REAL8 lnhatz,
65  REAL8 s1x, REAL8 s1y, REAL8 s1z);
66 
69  REAL8 m1, REAL8 m2, REAL8 chi, REAL8 kappa);
70 
72 #if 0
73 static REAL8 XLALSimInspiralSF2Beta(REAL8 v, LALSimInspiralSF2Coeffs coeffs);
74 static REAL8 XLALSimInspiralSF2Zeta(REAL8 v, LALSimInspiralSF2Coeffs coeffs);
75 #endif
76 
78  REAL8 thetaJ, REAL8 psiJ, int mm);
79 
80 static void XLALSimInspiralSF2Emission(
81  REAL8 *emission, REAL8 v, LALSimInspiralSF2Coeffs coeffs);
82 
83 static REAL8 safe_atan2(REAL8 val1, REAL8 val2)
84 {
85  if (val1 == 0. && val2 == 0.)
86  { return 0.; }
87  else
88  { return atan2(val1, val2); }
89 }
90 
92  LALSimInspiralSF2Orientation *orientation,
93  REAL8 m1, REAL8 m2, REAL8 v_ref,
94  REAL8 lnhatx, REAL8 lnhaty, REAL8 lnhatz,
95  REAL8 s1x, REAL8 s1y, REAL8 s1z )
96 {
97  orientation->v_ref = v_ref;
98  const REAL8 chi1 = sqrt(s1x*s1x+s1y*s1y+s1z*s1z);
99  orientation->chi = chi1;
100  orientation->kappa = (chi1 > 0.) ? (lnhatx*s1x+lnhaty*s1y+lnhatz*s1z)/chi1 : 1.;
101  const REAL8 Jx0 = m1*m2*lnhatx/v_ref + m1*m1*s1x;
102  const REAL8 Jy0 = m1*m2*lnhaty/v_ref + m1*m1*s1y;
103  const REAL8 Jz0 = m1*m2*lnhatz/v_ref + m1*m1*s1z;
104  const REAL8 thetaJ = acos(Jz0 / sqrt(Jx0*Jx0+Jy0*Jy0+Jz0*Jz0));
105  orientation->thetaJ = thetaJ;
106  const REAL8 psiJ = safe_atan2(Jy0, -Jx0);
107  orientation->psiJ = psiJ;
108 
109  /* Rotate Lnhat back to frame where J is along z, to figure out initial alpha */
110  const REAL8 rotLx = lnhatx*cos(thetaJ)*cos(psiJ) - lnhaty*cos(thetaJ)*sin(psiJ) + lnhatz*sin(thetaJ);
111  const REAL8 rotLy = lnhatx*sin(psiJ) + lnhaty*cos(psiJ);
112  orientation->alpha0 = safe_atan2(rotLy, rotLx);
113 }
114 
116  LALSimInspiralSF2Coeffs *coeffs,
117  REAL8 m1, REAL8 m2, REAL8 chi, REAL8 kappa )
118 {
119  const REAL8 quadparam = 1.;
120  coeffs->m1 = m1;
121  coeffs->m2 = m2;
122  const REAL8 mtot = m1+m2;
123  coeffs->mtot = mtot;
124  const REAL8 eta = m1*m2/(mtot*mtot);
125  coeffs->eta = eta;
126  const REAL8 gamma0 = m1*chi/m2;
127  coeffs->kappa = kappa;
128  coeffs->kappa_perp = sqrt(1.-kappa*kappa);
129  coeffs->gamma0 = gamma0;
130 
131  const REAL8 pn_beta = (113.*m1/(12.*mtot) - 19.*eta/6.)*chi*kappa;
132  const REAL8 pn_sigma = ( (5.*quadparam*(3.*kappa*kappa-1.)/2.)
133  + (7. - kappa*kappa)/96. )
134  * (m1*m1*chi*chi/mtot/mtot);
135  const REAL8 pn_gamma = (5.*(146597. + 7056.*eta)*m1/(2268.*mtot)
136  - 10.*eta*(1276. + 153.*eta)/81.)*chi*kappa;
137 
138  coeffs->prec_fac = 5.*(4. + 3.*m2/m1)/64.;
139  const REAL8 dtdv2 = 743./336. + 11.*eta/4.;
140  const REAL8 dtdv3 = -4.*LAL_PI + pn_beta;
141  const REAL8 dtdv4 = 3058673./1016064. + 5429.*eta/1008. + 617.*eta*eta/144. - pn_sigma;
142  const REAL8 dtdv5 = (-7729./672.+13.*eta/8.)*LAL_PI + 9.*pn_gamma/40.;
143 
144  coeffs->aclog1 = kappa*(1.-kappa*kappa)*gamma0*gamma0*gamma0/2.-dtdv2*kappa*gamma0-dtdv3;
145  coeffs->aclog2 = dtdv2*gamma0+dtdv3*kappa+(1.-kappa*kappa)*(dtdv4-dtdv5*kappa/gamma0)/gamma0/2.;
146  coeffs->ac[0] = -1./3.;
147  coeffs->ac[1] = -gamma0*kappa/6.;
148  coeffs->ac[2] = gamma0*gamma0*(-1./3.+kappa*kappa/2.) - dtdv2;
149  coeffs->ac[3] = dtdv3+dtdv4*kappa/gamma0/2.+dtdv5*(1./3.-kappa*kappa/2.)/gamma0/gamma0;
150  coeffs->ac[4] = dtdv4/2.+dtdv5*kappa/gamma0/6.;
151  coeffs->ac[5] = dtdv5/3.;
152 
153  coeffs->zc[0] = -1./3.;
154  coeffs->zc[1] = -gamma0*kappa/2.;
155  coeffs->zc[2] = -dtdv2;
156  coeffs->zc[3] = dtdv2*gamma0*kappa+dtdv3;
157  coeffs->zc[4] = dtdv3*gamma0*kappa+dtdv4;
158  coeffs->zc[5] = (dtdv4*gamma0*kappa+dtdv5)/2.;
159  coeffs->zc[6] = dtdv5*gamma0*kappa/3.;
160 }
161 
163  REAL8 v, LALSimInspiralSF2Coeffs coeffs)
164 {
165  const REAL8 gam = coeffs.gamma0*v;
166  const REAL8 kappa = coeffs.kappa;
167 
168  const REAL8 sqrtfac = sqrt(1. + 2.*kappa*gam + gam*gam);
169  const REAL8 logfac1 = log((1. + kappa*gam + sqrtfac)/v);
170  const REAL8 logfac2 = log(kappa + gam + sqrtfac);
171 
172  const REAL8 aclog1 = coeffs.aclog1;
173  const REAL8 aclog2 = coeffs.aclog2;
174  const REAL8 *ac = coeffs.ac;
175 
176  return coeffs.prec_fac * (aclog1*logfac1 + aclog2*logfac2 \
177  + (((ac[0]/v+ac[1])/v+ac[2])/v + ac[3] \
178  + (ac[4]+ac[5]*v)*v)*sqrtfac );
179 }
180 
181 #if 0
182 static REAL8 XLALSimInspiralSF2Zeta(
183  REAL8 v, LALSimInspiralSF2Coeffs coeffs)
184 {
185  const REAL8 *zc = coeffs.zc;
186 
187  return coeffs.prec_fac*(((zc[0]/v+zc[1])/v+zc[2])/v + zc[3]*log(v) + \
188  (zc[4]+(zc[5]+zc[6]*v)*v)*v);
189 }
190 
191 static REAL8 XLALSimInspiralSF2Beta(
192  REAL8 v, LALSimInspiralSF2Coeffs coeffs)
193 {
194  const REAL8 kappa = coeffs.kappa;
195  const REAL8 kappa_perp = coeffs.kappa_perp;
196  const REAL8 gamma0 = coeffs.gamma0;
197 
198  REAL8 beta = safe_atan2(gamma0*v*kappa_perp, 1. + kappa*gamma0*v);
199 
200  return beta;
201 }
202 #endif
203 
205  REAL8 thetaJ, REAL8 psiJ, int mm)
206 {
207  COMPLEX16 plus_fac, cross_fac;
208  switch (mm)
209  {
210  case 2:
211  plus_fac = (1.+cos(thetaJ)*cos(thetaJ))/2.;
212  cross_fac = -1.j*cos(thetaJ);
213  break;
214  case 1:
215  plus_fac = sin(2.*thetaJ);
216  cross_fac = -2.j*sin(thetaJ);
217  break;
218  case 0:
219  plus_fac = 3.*sin(thetaJ)*sin(thetaJ);
220  cross_fac = 0.;
221  break;
222  case -1:
223  plus_fac = -sin(2.*thetaJ);
224  cross_fac = -2.j*sin(thetaJ);
225  break;
226  case -2:
227  plus_fac = (1.+cos(thetaJ)*cos(thetaJ))/2.;
228  cross_fac = 1.j*cos(thetaJ);
229  break;
230  default:
231  plus_fac = 0.;
232  cross_fac = 0.;
233  }
234 
235  return plus_fac*cos(2.*psiJ) + cross_fac*sin(2.*psiJ);
236 }
237 
239  REAL8 *emission, REAL8 v, LALSimInspiralSF2Coeffs coeffs)
240 {
241  const REAL8 gam = coeffs.gamma0*v;
242  const REAL8 kappa = coeffs.kappa;
243  const REAL8 kappa_perp = coeffs.kappa_perp;
244 
245  const REAL8 sqrtfac = sqrt(1. + 2.*kappa*gam + gam*gam);
246  const REAL8 cosbeta = (1. + kappa*gam)/sqrtfac;
247  const REAL8 sinbeta = (kappa_perp*gam)/sqrtfac;
248 
249  emission[0] = (1.+cosbeta)*(1.+cosbeta)/4.;
250  emission[1] = (1.+cosbeta)*sinbeta/4.;
251  emission[2] = sinbeta*sinbeta/4.;
252  emission[3] = (1.-cosbeta)*sinbeta/4.;
253  emission[4] = (1.-cosbeta)*(1.-cosbeta)/4.;
254 
255  return;
256 }
257 
258 
259 /* FIXME Is this needed?
260  * Find the least nonnegative integer power of 2 that is
261  * greater than or equal to n. Inspired by similar routine
262  * in gstlal.
263 static size_t CeilPow2(double n) {
264  double signif;
265  int exponent;
266  signif = frexp(n, &exponent);
267  if (signif < 0)
268  return 1;
269  if (signif == 0.5)
270  exponent -= 1;
271  return ((size_t) 1) << exponent;
272 } */
273 
274 /**
275  * @addtogroup LALSimInspiralSpinTaylor_c
276  * @{
277  */
278 
279 /**
280  * Computes the stationary phase approximation to the Fourier transform of
281  * a chirp waveform with phase given by \eqref{eq_InspiralFourierPhase_f2}
282  * and amplitude given by expanding \f$1/\sqrt{\dot{F}}\f$. If the PN order is
283  * set to -1, then the highest implemented order is used.
284  *
285  * See arXiv:0810.5336 and arXiv:astro-ph/0504538 for spin corrections
286  * to the phasing.
287  * See arXiv:1303.7412 for spin-orbit phasing corrections at 3 and 3.5PN order
288  */
290  COMPLEX16FrequencySeries **hplus_out, /**< FD hplus waveform */
291  COMPLEX16FrequencySeries **hcross_out, /**< FD hcross waveform */
292  const REAL8 phi_ref, /**< reference orbital phase (rad) */
293  const REAL8 deltaF, /**< frequency resolution */
294  const REAL8 m1_SI, /**< mass of companion 1 (kg) */
295  const REAL8 m2_SI, /**< mass of companion 2 (kg) */
296  const REAL8 s1x, /**< initial value of S1x */
297  const REAL8 s1y, /**< initial value of S1y */
298  const REAL8 s1z, /**< initial value of S1z */
299  const REAL8 lnhatx, /**< initial value of LNhatx */
300  const REAL8 lnhaty, /**< initial value of LNhaty */
301  const REAL8 lnhatz, /**< initial value of LNhatz */
302  const REAL8 fStart, /**< start GW frequency (Hz) */
303  const REAL8 fEnd, /**< highest GW frequency (Hz) of waveform generation - if 0, end at Schwarzschild ISCO */
304  const REAL8 f_ref, /**< Reference GW frequency (Hz) - if 0 reference point is coalescence */
305  const REAL8 r, /**< distance of source (m) */
306  LALDict *moreParams, /**< Linked list of extra. Pass in NULL (or None in python) for standard waveform. Set "sideband",m to get a single sideband (m=-2..2) */
307  const INT4 phaseO, /**< twice PN phase order */
308  const INT4 amplitudeO /**< twice PN amplitude order */
309  )
310 {
311  /* external: SI; internal: solar masses */
312  const REAL8 m1 = m1_SI / LAL_MSUN_SI;
313  const REAL8 m2 = m2_SI / LAL_MSUN_SI;
314  const REAL8 m = m1 + m2;
315  const REAL8 m_sec = m * LAL_MTSUN_SI; /* total mass in seconds */
316  const REAL8 eta = m1 * m2 / (m * m);
317  const REAL8 piM = LAL_PI * m_sec;
318  const REAL8 vISCO = 1. / sqrt(6.);
319  const REAL8 fISCO = vISCO * vISCO * vISCO / piM;
320  REAL8 shft, amp0, f_max;
321  size_t i, n, iStart;
322  COMPLEX16 *data_plus = NULL;
323  COMPLEX16 *data_cross = NULL;
324  LIGOTimeGPS tC = {0, 0};
325 
326  /* If f_ref = 0, use f_ref = f_low for everything except the phase offset */
327  const REAL8 v_ref = f_ref > 0. ? cbrt(piM*f_ref) : cbrt(piM*fStart);
328 
329  REAL8 alpha, alpha_ref;
330  COMPLEX16 prec_plus, prec_cross, phasing_fac;
331  bool enable_precession = true; /* Handle the non-spinning case separately */
332  int mm;
333 
334  LALSimInspiralSF2Orientation orientation;
335  XLALSimInspiralSF2CalculateOrientation(&orientation, m1, m2, v_ref, lnhatx, lnhaty, lnhatz, s1x, s1y, s1z);
336 
338  XLALSimInspiralSF2CalculateCoeffs(&coeffs, m1, m2, orientation.chi, orientation.kappa);
339  enable_precession = orientation.chi != 0. && orientation.kappa != 1. && orientation.kappa != -1.;
340 
341  alpha_ref = enable_precession ? XLALSimInspiralSF2Alpha(v_ref, coeffs) - orientation.alpha0 : 0.;
342 
343  COMPLEX16 SBplus[5]; /* complex sideband factors for plus pol, mm=2 is first entry */
344  COMPLEX16 SBcross[5]; /* complex sideband factors for cross pol, mm=2 is first entry */
345  REAL8 emission[5]; /* emission factor for each sideband */
347  {
348  for(mm = -2; mm <= 2; mm++)
349  {
350  SBplus[2-mm] = XLALSimInspiralSF2Polarization(orientation.thetaJ, orientation.psiJ, mm);
351  SBcross[2-mm] = XLALSimInspiralSF2Polarization(orientation.thetaJ, orientation.psiJ+LAL_PI/4., mm);
352  }
353  }
354  else
355  {
356  memset(SBplus, 0, 5 * sizeof(COMPLEX16));
357  memset(SBcross, 0, 5 * sizeof(COMPLEX16));
358  mm = (int) XLALSimInspiralWaveformParamsLookupSideband(moreParams);
359  SBplus[2-mm] = XLALSimInspiralSF2Polarization(orientation.thetaJ, orientation.psiJ, mm);
360  SBcross[2-mm] = XLALSimInspiralSF2Polarization(orientation.thetaJ, orientation.psiJ+LAL_PI/4., mm);
361  }
362 
363  const REAL8 chi1L = orientation.chi*orientation.kappa;
364  const REAL8 chi1sq = orientation.chi*orientation.chi;
365  /* FIXME: Cannot yet set QM constant in ChooseFDWaveform interface */
366  /* phasing coefficients */
367  PNPhasingSeries pfa;
368  XLALSimInspiralPNPhasing_F2(&pfa, m1, m2, chi1L, 0., chi1sq, 0., 0., moreParams);
369 
370  REAL8 pfaN = 0.; REAL8 pfa1 = 0.;
371  REAL8 pfa2 = 0.; REAL8 pfa3 = 0.; REAL8 pfa4 = 0.;
372  REAL8 pfa5 = 0.; REAL8 pfl5 = 0.;
373  REAL8 pfa6 = 0.; REAL8 pfl6 = 0.;
374  REAL8 pfa7 = 0.; REAL8 pfa8 = 0.;
375 
376  switch (phaseO)
377  {
378  case -1:
379  case 7:
380  pfa7 = pfa.v[7];
381 #if __GNUC__ >= 7 && !defined __INTEL_COMPILER
382  __attribute__ ((fallthrough));
383 #endif
384  case 6:
385  pfa6 = pfa.v[6];
386  pfl6 = pfa.vlogv[6];
387 #if __GNUC__ >= 7 && !defined __INTEL_COMPILER
388  __attribute__ ((fallthrough));
389 #endif
390  case 5:
391  pfa5 = pfa.v[5];
392  pfl5 = pfa.vlogv[5];
393 #if __GNUC__ >= 7 && !defined __INTEL_COMPILER
394  __attribute__ ((fallthrough));
395 #endif
396  case 4:
397  pfa4 = pfa.v[4];
398 #if __GNUC__ >= 7 && !defined __INTEL_COMPILER
399  __attribute__ ((fallthrough));
400 #endif
401  case 3:
402  pfa3 = pfa.v[3];
403 #if __GNUC__ >= 7 && !defined __INTEL_COMPILER
404  __attribute__ ((fallthrough));
405 #endif
406  case 2:
407  pfa2 = pfa.v[2];
408 #if __GNUC__ >= 7 && !defined __INTEL_COMPILER
409  __attribute__ ((fallthrough));
410 #endif
411  case 1:
412  pfa1 = pfa.v[1];
413 #if __GNUC__ >= 7 && !defined __INTEL_COMPILER
414  __attribute__ ((fallthrough));
415 #endif
416  case 0:
417  pfaN = pfa.v[0];
418  break;
419  default:
420  XLAL_ERROR(XLAL_ETYPE, "Invalid phase PN order %d", phaseO);
421  }
422 
423  /* Add the zeta factor to the phasing, since it looks like a pN series.
424  * This is the third Euler angle after alpha and beta.
425  */
426  if (enable_precession)
427  {
428  pfa2 += 2.*coeffs.prec_fac*coeffs.zc[0];
429  pfa3 += 2.*coeffs.prec_fac*coeffs.zc[1];
430  pfa4 += 2.*coeffs.prec_fac*coeffs.zc[2];
431  pfl5 += 2.*coeffs.prec_fac*coeffs.zc[3];
432  pfa6 += 2.*coeffs.prec_fac*coeffs.zc[4];
433  pfa7 += 2.*coeffs.prec_fac*coeffs.zc[5];
434  pfa8 += 2.*coeffs.prec_fac*coeffs.zc[6];
435  }
436 
437  /* Validate expansion order arguments.
438  * This must be done here instead of in the OpenMP parallel loop
439  * because when OpenMP parallelization is turned on, early exits
440  * from loops (via return or break statements) are not permitted.
441  */
442 
443  /* Validate amplitude PN order. */
444  if (amplitudeO != 0) { XLAL_ERROR(XLAL_ETYPE, "Invalid amplitude PN order %d", amplitudeO); }
445 
446  /* energy coefficients - not currently used, but could for MECO
447  const REAL8 dETaN = 2. * XLALSimInspiralPNEnergy_0PNCoeff(eta);
448  const REAL8 dETa1 = 2. * XLALSimInspiralPNEnergy_2PNCoeff(eta);
449  const REAL8 dETa2 = 3. * XLALSimInspiralPNEnergy_4PNCoeff(eta);
450  const REAL8 dETa3 = 4. * XLALSimInspiralPNEnergy_6PNCoeff(eta);
451  */
452 
454  COMPLEX16FrequencySeries *hcross;
455 
456  /* Perform some initial checks */
457  if (!hplus_out) XLAL_ERROR(XLAL_EFAULT);
458  if (!hcross_out) XLAL_ERROR(XLAL_EFAULT);
459  if (*hplus_out) XLAL_ERROR(XLAL_EFAULT);
460  if (*hcross_out) XLAL_ERROR(XLAL_EFAULT);
461  if (m1_SI <= 0) XLAL_ERROR(XLAL_EDOM);
462  if (m2_SI <= 0) XLAL_ERROR(XLAL_EDOM);
463  if (fStart <= 0) XLAL_ERROR(XLAL_EDOM);
464  if (f_ref < 0) XLAL_ERROR(XLAL_EDOM);
465  if (r <= 0) XLAL_ERROR(XLAL_EDOM);
466 
467  /* allocate htilde */
468  if ( fEnd == 0. ) // End at ISCO
469  f_max = fISCO;
470  else // End at user-specified freq.
471  f_max = fEnd;
472  n = (size_t) (f_max / deltaF + 1);
473  XLALGPSAdd(&tC, -1 / deltaF); /* coalesce at t=0 */
474  /* Allocate hplus and hcross */
475  hplus = XLALCreateCOMPLEX16FrequencySeries("hplus: FD waveform", &tC, 0.0, deltaF, &lalStrainUnit, n);
476  if (!hplus) XLAL_ERROR(XLAL_EFUNC);
477  memset(hplus->data->data, 0, n * sizeof(COMPLEX16));
479  hcross = XLALCreateCOMPLEX16FrequencySeries("hcross: FD waveform", &tC, 0.0, deltaF, &lalStrainUnit, n);
480  if (!hcross) XLAL_ERROR(XLAL_EFUNC);
481  memset(hcross->data->data, 0, n * sizeof(COMPLEX16));
483 
484  /* extrinsic parameters */
485  amp0 = -4. * m1 * m2 / r * LAL_MRSUN_SI * LAL_MTSUN_SI * sqrt(LAL_PI/12.L);
487  shft = LAL_TWOPI * (tC.gpsSeconds + 1e-9 * tC.gpsNanoSeconds);
488 
489  /* Fill with non-zero vals from fStart to f_max */
490  iStart = (size_t) ceil(fStart / deltaF);
491  data_plus = hplus->data->data;
492  data_cross = hcross->data->data;
493 
494  /* Compute the SPA phase at the reference point */
495  REAL8 ref_phasing = 0.;
496  if (f_ref > 0.)
497  {
498  const REAL8 logvref = log(v_ref);
499  const REAL8 v2ref = v_ref * v_ref;
500  const REAL8 v3ref = v_ref * v2ref;
501  const REAL8 v4ref = v_ref * v3ref;
502  const REAL8 v5ref = v_ref * v4ref;
503  ref_phasing = (pfaN + pfa1 * v_ref +pfa2 * v2ref + pfa3 * v3ref + pfa4 * v4ref) / v5ref + (pfa5 + pfl5 * logvref) + (pfa6 + pfl6 * logvref) * v_ref + pfa7 * v2ref + pfa8 * v3ref;
504  } /* end of if (f_ref > 0.) */
505 
506  #pragma omp parallel for
507  for (i = iStart; i < n; i++) {
508  const REAL8 f = i * deltaF;
509  const REAL8 v = cbrt(piM*f);
510  const REAL8 logv = log(v);
511  const REAL8 v2 = v * v;
512  const REAL8 v3 = v * v2;
513  const REAL8 v4 = v * v3;
514  const REAL8 v5 = v * v4;
515  REAL8 phasing = (pfaN + pfa1*v + pfa2 * v2 + pfa3 * v3 + pfa4 * v4) / v5 + (pfa5 + pfl5 * logv) + (pfa6 + pfl6 * logv) * v + pfa7 * v2 + pfa8 * v3;
516  COMPLEX16 amp = amp0 / (v3 * sqrt(v));
517 
518  alpha = enable_precession ? XLALSimInspiralSF2Alpha(v, coeffs) - alpha_ref : 0.;
519 
520  COMPLEX16 u = cos(alpha) + 1.0j*sin(alpha);
521  XLALSimInspiralSF2Emission(emission, v, coeffs);
522  prec_plus = SBplus[0]*emission[0]*u*u
523  + SBplus[1]*emission[1]*u
524  + SBplus[2]*emission[2]
525  + SBplus[3]*emission[3]/u
526  + SBplus[4]*emission[4]/u/u;
527  prec_cross= SBcross[0]*emission[0]*u*u
528  + SBcross[1]*emission[1]*u
529  + SBcross[2]*emission[2]
530  + SBcross[3]*emission[3]/u
531  + SBcross[4]*emission[4]/u/u;
532  // Note the factor of 2 b/c phi_ref is orbital phase
533  phasing += shft * f - 2.*phi_ref - ref_phasing - LAL_PI_4;
534  phasing_fac = cos(phasing) - 1.0j*sin(phasing);
535  data_plus[i] = amp * prec_plus * phasing_fac;
536  data_cross[i] = amp * prec_cross * phasing_fac;
537  }
538 
539  *hplus_out = hplus;
540  *hcross_out = hcross;
541  return XLAL_SUCCESS;
542 }
543 
544 /** @} */
static double beta(const double a, const double b, const sysq *system)
Internal function that computes the spin-orbit couplings.
static REAL8 UNUSED XLALSimInspiralPNFlux_0PNCoeff(REAL8 eta)
Computes the flux PN Coefficients.
static REAL8 UNUSED XLALSimInspiralPNEnergy_0PNCoeff(REAL8 eta)
Computes the PN Coefficients for using in the PN energy equation.
static void UNUSED XLALSimInspiralPNPhasing_F2(PNPhasingSeries *pfa, const REAL8 m1, const REAL8 m2, const REAL8 chi1L, const REAL8 chi2L, const REAL8 chi1sq, const REAL8 chi2sq, const REAL8 chi1dotchi2, LALDict *p)
static REAL8 safe_atan2(REAL8 val1, REAL8 val2)
static void XLALSimInspiralSF2CalculateOrientation(LALSimInspiralSF2Orientation *orientation, REAL8 m1, REAL8 m2, REAL8 v_ref, REAL8 lnhatx, REAL8 lnhaty, REAL8 lnhatz, REAL8 s1x, REAL8 s1y, REAL8 s1z)
static void XLALSimInspiralSF2Emission(REAL8 *emission, REAL8 v, LALSimInspiralSF2Coeffs coeffs)
static REAL8 XLALSimInspiralSF2Alpha(REAL8 v, LALSimInspiralSF2Coeffs coeffs)
static void XLALSimInspiralSF2CalculateCoeffs(LALSimInspiralSF2Coeffs *coeffs, REAL8 m1, REAL8 m2, REAL8 chi, REAL8 kappa)
static COMPLEX16 XLALSimInspiralSF2Polarization(REAL8 thetaJ, REAL8 psiJ, int mm)
int XLALSimInspiralWaveformParamsSidebandIsDefault(LALDict *params)
INT4 XLALSimInspiralWaveformParamsLookupSideband(LALDict *params)
double i
Definition: bh_ringdown.c:118
double e
Definition: bh_ringdown.c:117
const double u
#define __attribute__(x)
COMPLEX16FrequencySeries * XLALCreateCOMPLEX16FrequencySeries(const CHAR *name, const LIGOTimeGPS *epoch, REAL8 f0, REAL8 deltaF, const LALUnit *sampleUnits, size_t length)
#define LAL_MSUN_SI
#define LAL_PI
#define LAL_TWOPI
#define LAL_MTSUN_SI
#define LAL_PI_4
#define LAL_MRSUN_SI
double complex COMPLEX16
double REAL8
int32_t INT4
int XLALSimInspiralSpinTaylorF2(COMPLEX16FrequencySeries **hplus_out, COMPLEX16FrequencySeries **hcross_out, const REAL8 phi_ref, const REAL8 deltaF, const REAL8 m1_SI, const REAL8 m2_SI, const REAL8 s1x, const REAL8 s1y, const REAL8 s1z, const REAL8 lnhatx, const REAL8 lnhaty, const REAL8 lnhatz, const REAL8 fStart, const REAL8 fEnd, const REAL8 f_ref, const REAL8 r, LALDict *moreParams, const INT4 phaseO, const INT4 amplitudeO)
Computes the stationary phase approximation to the Fourier transform of a chirp waveform with phase g...
static const INT4 r
static const INT4 m
const LALUnit lalStrainUnit
const LALUnit lalSecondUnit
LALUnit * XLALUnitMultiply(LALUnit *output, const LALUnit *unit1, const LALUnit *unit2)
#define XLAL_ERROR(...)
XLAL_SUCCESS
XLAL_EFAULT
XLAL_EFUNC
XLAL_EDOM
XLAL_ETYPE
LIGOTimeGPS * XLALGPSAdd(LIGOTimeGPS *epoch, REAL8 dt)
double alpha
Definition: sgwb.c:106
COMPLEX16Sequence * data
COMPLEX16 * data
INT4 gpsNanoSeconds
REAL8 vlogv[PN_PHASING_SERIES_MAX_ORDER+1]
REAL8 v[PN_PHASING_SERIES_MAX_ORDER+1]
double f_max
Definition: unicorn.c:23