LALSimulation  5.4.0.1-fe68b98
LALSimIMRSpinEOBHamiltonian.c
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2011 Craig Robinson, Enrico Barausse, Yi Pan
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 /**
21  * \author Craig Robinson, Yi Pan, Andrea Taracchini
22  *
23  * Functions for calculating the effective one-body Hamiltonian for
24  * spinning binaries, as described in
25  * Taracchini et al. ( PRD 86, 024011 (2012), arXiv 1202.0790 ).
26  * All equation numbers in this file refer to equations of this paper,
27  * unless otherwise specified.
28  * This code borrows hugely from a C implementation originally written
29  * by Enrico Barausse, following Barausse and Buonanno
30  * PRD 81, 084024 (2010) and PRD 84, 104027 (2011), henceforth BB1 and BB2
31  */
32 
33 #ifndef _LALSIMIMRSPINEOBHAMILTONIAN_C
34 #define _LALSIMIMRSPINEOBHAMILTONIAN_C
35 
36 #include <stdio.h>
37 #include <math.h>
38 
39 #include <lal/LALSimInspiral.h>
40 #include <lal/LALSimIMR.h>
41 
42 #include "LALSimIMRSpinEOB.h"
43 
45 
46 #include <math.h>
47 
48 #define TwoToOneThird 1.25992104989487316476721060728
49 #define ThreeToOneThird 1.44224957030740838232163831078
50 
51 static const REAL8 STEP_SIZE_CALCOMEGA = 1.0e-4;
52 
53 static const double sqrt_pi_2 = 1.2533141373155002512078826424; /* sqrt(pi/2) */
54 static const double sqrt_2_pi = 0.7978845608028653558798921199; /* sqrt(2/pi) */
55 static const double _1_sqrt_2pi = 0.3989422804014326779399460599; /* 1/sqrt(2*pi) */
56 static const double pi_2 = 1.5707963267948966192313216916; /* pi/2 */
57 
58 static const double f_data_a[18] =
59 {
60  0.76435138664186000189,
61  -0.43135547547660179313,
62  0.43288199979726653054,
63  -0.26973310338387111029,
64  0.08416045320876935378,
65  -0.01546524484461381958,
66  0.00187855423439822018,
67  -0.00016264977618887547,
68  0.00001057397656383260,
69  -0.00000053609339889243,
70  0.00000002181658454933,
71  -0.00000000072901621186,
72  0.00000000002037332546,
73  -0.00000000000048344033,
74  0.00000000000000986533,
75  -0.00000000000000017502,
76  0.00000000000000000272,
77  -0.00000000000000000004
78 };
79 
80 /* List of coefficients for Fresnel sine function. Note that the final element is initialized
81  to zero for consistency with f_data_a (used for Fresnel cosine function), so that the
82  Fresnel sine and cosine can be computed simultaneously
83  */
84 static const double f_data_b2[18] =
85 {
86  0.63041404314570539241,
87  -0.42344511405705333544,
88  0.37617172643343656625,
89  -0.16249489154509567415,
90  0.03822255778633008694,
91  -0.00564563477132190899,
92  0.00057454951976897367,
93  -0.00004287071532102004,
94  0.00000245120749923299,
95  -0.00000011098841840868,
96  0.00000000408249731696,
97  -0.00000000012449830219,
98  0.00000000000320048425,
99  -0.00000000000007032416,
100  0.00000000000000133638,
101  -0.00000000000000002219,
102  0.00000000000000000032,
103  0.0
104 };
105 
106 /* Optimized Fresnel function, computes both sine and cosine simultaneously, for significant speed-up */
107 /* This function computes sine and cosine if input x is between 0 and 8 */
108 /* Based on separate GSL Fresnel sine/cosine functions. Optimizations courtesy Zachariah B. Etienne */
109 static void fresnel_sincos_0_8(double x, double output[2])
110 {
111  double x_8 = x/8.0;
112  double xx = 2.0*x_8*x_8 - 1.0;
113  double t0 = 1.;
114  double t1 = xx;
115  double ot1 = x_8;
116  double ot2 = 2.0*x_8*t1 - ot1;
117  double sumS = f_data_b2[0]*ot1 + f_data_b2[1]*ot2;
118 
119  double sumC = f_data_a[0] + f_data_a[1]*t1;
120 
121  int n;
122  double t2;
123  for (n=2; n < 18; n++)
124  {
125  t2 = 2.0*xx*t1 - t0;
126  sumC += f_data_a[n]*t2;
127  ot1 = ot2;
128  ot2 = 2.0*x_8*t2 - ot1;
129  sumS += f_data_b2[n]*ot2;
130  t0 = t1; t1 = t2;
131  }
132  double sqrtx=sqrt(x);
133  output[0] = _1_sqrt_2pi*sqrtx*sumS;
134  output[1] = _1_sqrt_2pi*sqrtx*sumC;
135 }
136 
137 static double f_data_e[41] =
138 {
139  0.97462779093296822410,
140  -0.02424701873969321371,
141  0.00103400906842977317,
142  -0.00008052450246908016,
143  0.00000905962481966582,
144  -0.00000131016996757743,
145  0.00000022770820391497,
146  -0.00000004558623552026,
147  0.00000001021567537083,
148  -0.00000000251114508133,
149  0.00000000066704761275,
150  -0.00000000018931512852,
151  0.00000000005689898935,
152  -0.00000000001798219359,
153  0.00000000000594162963,
154  -0.00000000000204285065,
155  0.00000000000072797580,
156  -0.00000000000026797428,
157  0.00000000000010160694,
158  -0.00000000000003958559,
159  0.00000000000001581262,
160  -0.00000000000000646411,
161  0.00000000000000269981,
162  -0.00000000000000115038,
163  0.00000000000000049942,
164  -0.00000000000000022064,
165  0.00000000000000009910,
166  -0.00000000000000004520,
167  0.00000000000000002092,
168  -0.00000000000000000982,
169  0.00000000000000000467,
170  -0.00000000000000000225,
171  0.00000000000000000110,
172  -0.00000000000000000054,
173  0.00000000000000000027,
174  -0.00000000000000000014,
175  0.00000000000000000007,
176  -0.00000000000000000004,
177  0.00000000000000000002,
178  -0.00000000000000000001,
179  0.00000000000000000001
180 };
181 
182 static double f_data_f[35] =
183 {
184  0.99461545179407928910,
185  -0.00524276766084297210,
186  0.00013325864229883909,
187  -0.00000770856452642713,
188  0.00000070848077032045,
189  -0.00000008812517411602,
190  0.00000001359784717148,
191  -0.00000000246858295747,
192  0.00000000050925789921,
193  -0.00000000011653400634,
194  0.00000000002906578309,
195  -0.00000000000779847361,
196  0.00000000000222802542,
197  -0.00000000000067239338,
198  0.00000000000021296411,
199  -0.00000000000007041482,
200  0.00000000000002419805,
201  -0.00000000000000861080,
202  0.00000000000000316287,
203  -0.00000000000000119596,
204  0.00000000000000046444,
205  -0.00000000000000018485,
206  0.00000000000000007527,
207  -0.00000000000000003131,
208  0.00000000000000001328,
209  -0.00000000000000000574,
210  0.00000000000000000252,
211  -0.00000000000000000113,
212  0.00000000000000000051,
213  -0.00000000000000000024,
214  0.00000000000000000011,
215  -0.00000000000000000005,
216  0.00000000000000000002,
217  -0.00000000000000000001,
218  0.00000000000000000001
219 };
220 
221 /* Optimized Fresnel function, computes both sine and cosine simultaneously, for significant speed-up */
222 /* This function computes sine and cosine if input x is between 8 and infinity */
223 /* Based on separate GSL Fresnel sine/cosine functions. Optimizations courtesy Zachariah B. Etienne */
224 static void fresnel_sincos_8_inf(double x, double output[2])
225 {
226 
227  double xx = 128.0/(x*x) - 1.0; /* 2.0*(8/x)^2 - 1 */
228  double t0 = 1.0;
229  double t1 = xx;
230  double sumP = f_data_e[0] + f_data_e[1]*t1;
231  double sumQ = f_data_f[0] + f_data_f[1]*t1;
232  double t2;
233  int n;
234  double cosx = cos(x);
235  double sinx = sin(x);
236  double oneoversqrtx = 1.0/sqrt(x);
237  double oneoverx = oneoversqrtx*oneoversqrtx;
238  for(n = 2; n < 35; n++)
239  {
240  t2 = 2.0*xx*t1 - t0;
241  sumP += f_data_e[n]*t2; /* sumP += f_data_e[n]*ChebyshevT(n,xx) */
242  sumQ += f_data_f[n]*t2; /* sumQ += f_data_f[n]*ChebyshevT(n,xx) */
243  t0 = t1; t1 = t2;
244  }
245  for(n = 35; n < 41; n++)
246  {
247  t2 = 2.0*xx*t1 - t0;
248  sumP += f_data_e[n]*t2; /* sumP += f_data_e[n]*ChebyshevT(n,xx) */
249  t0 = t1; t1 = t2;
250  }
251 
252  output[0] = 0.5 - _1_sqrt_2pi*(0.5*sumP*sinx*oneoverx + sumQ*cosx)*oneoversqrtx;
253  output[1] = 0.5 - _1_sqrt_2pi*(0.5*sumP*cosx*oneoverx - sumQ*sinx)*oneoversqrtx;
254 }
255 
256 /* Optimized Fresnel function, computes both sine and cosine simultaneously, for significant speed-up */
257 /* Based on separate GSL Fresnel sine/cosine functions. Optimizations courtesy Zachariah B. Etienne */
258 static void fresnel_sc(double x, double output[2])
259 {
260  double xx = x*x*pi_2;
261  if(xx<=8.0) {
263  output[0] = (x<0.0) ? -output[0] : output[0];
264  output[1] = (x<0.0) ? -output[1] : output[1];
265  }
266  else {
268  output[0] = (x<0.0) ? -output[0] : output[0];
269  output[1] = (x<0.0) ? -output[1] : output[1];
270  }
271 }
272 
273 /**
274  * Function to compute k2tidal, k3tidal: resonant terms
275  * f(x) with x=omega0l/(m*Omega) (with m=l here) is the sum of first two terms of the bracket in (11) of https://arxiv.org/pdf/1702.02053.pdf (note typo: mOmega^2->(mOmega)^2)
276  */
277 /* List of coefficients for the near-resonance expansion of the resonant terms in tidal keff */
278 /* Function f(x) - to be used only away from resonance x=1 */
279 static double f_keffresonant(double x, double x5_3)
280 {
281  double x2 = x*x;
282  return x2*( 1./(x2 - 1.) + 5./6./(1. - x5_3));
283 }
284 /* Derivative f'(x) - to be used only away from resonance x=1 */
285 static double df_keffresonant(double x, double x5_3)
286 {
287  double x2 = x*x;
288  return 2.*x*( -1./(x2 - 1.)/(x2 - 1.) + 5./6.*(1. - 1./6.*x5_3)/(1. - x5_3)/(1. - x5_3));
289 }
290 /* Perturbative expansion for function f(x) near x=1 */
291 static const double f_keffresonant_pertdata[5] =
292 {
293  -0.0833333333333333,
294  -0.1157407407407407,
295  -0.006944444444444445,
296  0.01122256515775034,
297  -0.007120198902606311
298 };
299 static double f_keffresonant_pert(REAL8 x)
300 {
301  double xi = x - 1.;
302  double f = 0;
303  for(int i=0; i<5; i++) {
304  f = xi*f + f_keffresonant_pertdata[4-i];
305  }
306  return f;
307 }
308 /* Perturbative expansion for derivative f'(x) near x=1 */
309 static const double df_keffresonant_pertdata[5] =
310 {
311  -0.1157407407407407,
312  -0.01388888888888889,
313  0.03366769547325102,
314  -0.02848079561042524,
315  0.01919764200071127
316 };
317 static double df_keffresonant_pert(REAL8 x)
318 {
319  double xi = x - 1.;
320  double df = 0;
321  for(int i=0; i<5; i++) {
322  df = xi*df + df_keffresonant_pertdata[4-i];
323  }
324  return df;
325 }
326 
327 /*------------------------------------------------------------------------------------------
328  *
329  * Prototypes of functions defined in this code.
330  *
331  *------------------------------------------------------------------------------------------
332  */
333 
334 /**
335  * This function calculates the DeltaR potential function in the spin EOB Hamiltonian
336  */
338  /**<< Pre-computed coefficients which appear in the function */
339  const REAL8 r,
340  /**<< Current orbital radius (in units of total mass) */
341  const REAL8 eta,
342  /**<< Symmetric mass ratio */
343  const REAL8 a
344  /**<< Normalized deformed Kerr spin */
345  );
346 
348  REAL8Vector * restrict x,
349  REAL8Vector * restrict p,
350  REAL8Vector * restrict s1Vec,
351  REAL8Vector * restrict s2Vec,
352  REAL8Vector * restrict sigmaKerr,
353  REAL8Vector * restrict sigmaStar,
354  int tortoise,
355  SpinEOBHCoeffs * coeffs);
356 
358  const REAL8 eta,
359  const REAL8 a,
360  const UINT4
361  SpinAlignedEOBversion);
362 
364  const REAL8 r,
365  const REAL8 eta,
366  const REAL8 a);
367 
368 static REAL8 XLALSimIMRSpinAlignedEOBCalcOmega (const REAL8 values[],
369  SpinEOBParams * funcParams, REAL8 STEP_SIZE);
370 
371 static REAL8 XLALSimIMRSpinAlignedEOBNonKeplerCoeff (const REAL8 values[],
372  SpinEOBParams *
373  funcParams);
374 
375 static double GSLSpinAlignedHamiltonianWrapper (double x, void *params);
376 
377 
378 /*------------------------------------------------------------------------------------------
379  *
380  * Defintions of functions.
381  *
382  *------------------------------------------------------------------------------------------
383  */
384 
385 /**
386  * Function to compute the enhancement of kltidal due to the presence of f-mode resonance
387  * Implements (11) of https://arxiv.org/pdf/1702.02053.pdf (note typo: mOmega^2->(mOmega)^2)
388  * f(x) with x=omega0l/(m*Omega) (with m=l here) is the sum of first two terms of the bracket there
389  * Near resonance (x-1<1e-2) f(x) is replaced by a perturbative expansion
390  * Expected numerical precision: |Deltaf/f| normal: 1e-10 | perturbative: 1e-10
391  */
393  INT4 l, /**<< Mode number l - the function is valid only for l=2 or l=3 and for m=l */
394  REAL8 u, /**<< Inverse of radial separation in units of M */
395  REAL8 eta, /**<< Symmetric mass ratio */
396  TidalEOBParams * tidal /**<< Tidal parameters */
397 )
398 {
399  /* Function only valid for l=2 or l=3 and for m=l */
400  REAL8 al, bl, w0l;
401  switch(l) {
402  case 2:
403  al = 1./4.;
404  bl = 3./4.;
405  w0l = tidal->omega02Tidal;
406  break;
407  case 3:
408  al = 3./8.;
409  bl = 5./8.;
410  w0l = tidal->omega03Tidal;
411  break;
412  default:
413  XLALPrintError("XLAL Error - %s: mode number l must be 2 or 3!\n", __func__);
415  break;
416  }
417  /* NOTE: the function is valid only for m=l */
418  INT4 m = l;
419  REAL8 Omega = pow(u, 1.5);
420  REAL8 x = w0l/(m*Omega);
421  REAL8 x2 = x*x;
422  REAL8 x5_3 = pow(x, 5./3.);
423  REAL8 sqrtepsm = sqrt(256./5.*eta*pow(w0l/m, 5./3.));
424  REAL8 that = 8./5./sqrtepsm * (1. - x5_3);
425  REAL8 argcossin = 3./8.*that*that;
426  REAL8 argfresnel = 0.5*sqrt(3./LAL_PI)*that;
427  /* Resonant term, first two terms in the bracket - use perturbative expansion near resonance */
428  REAL8 resonantterm;
429  if(fabs(x-1.)>1e-2) {
430  resonantterm = f_keffresonant(x, x5_3);
431  }
432  else {
433  resonantterm = f_keffresonant_pert(x);
434  }
435  /* Fresnel term, third term featuring Qlm */
436  REAL8 fres[2];
437  fresnel_sc(argfresnel, fres);
438  REAL8 fresnelS = fres[0];
439  REAL8 fresnelC = fres[1];
440  REAL8 fresnelterm = sqrt(LAL_PI/3.)/sqrtepsm * x2*((1. + 2.*fresnelS)*cos(argcossin) - (1. + 2.*fresnelC)*sin(argcossin));
441  REAL8 klTidaleff = al + bl*(resonantterm + fresnelterm);
442  return klTidaleff;
443 }
444 
445 /**
446  * Function to compute the enhancement of kltidal and its u-derivative due to the presence of f-mode resonance
447  * Implements (11) of https://arxiv.org/pdf/1702.02053.pdf (note typo: mOmega^2->(mOmega)^2)
448  * f(x) with x=omega0l/(m*Omega) (with m=l here) is the sum of first two terms of the bracket there
449  * Near resonance (x-1<1e-2) f(x) and f'(x) are replaced by a perturbative expansion
450  * Expected numerical precision: |Deltaf/f| normal: 1e-10 | perturbative: 1e-10
451  * Expected numerical precision: |Deltaf'/f'| normal: 1e-8 | perturbative: 1e-10
452  */
454  INT4 l, /**<< Mode number l - the function is valid only for l=2 or l=3 and for m=l */
455  REAL8 u, /**<< Inverse of radial separation in units of M */
456  REAL8 eta, /**<< Symmetric mass ratio */
457  TidalEOBParams * tidal, /**<< Tidal parameters */
458  REAL8 output[2] /**<< Output array */
459 )
460 {
461  /* Function only valid for l=2 or l=3 and for m=l */
462  REAL8 al, bl, w0l;
463  switch(l) {
464  case 2:
465  al = 1./4.;
466  bl = 3./4.;
467  w0l = tidal->omega02Tidal;
468  break;
469  case 3:
470  al = 3./8.;
471  bl = 5./8.;
472  w0l = tidal->omega03Tidal;
473  break;
474  default:
475  XLALPrintError("XLAL Error - %s: mode number l must be 2 or 3!\n", __func__);
477  break;
478  }
479  /* NOTE: the function is valid only for m=l */
480  INT4 m = l;
481  REAL8 Omega = pow(u, 1.5);
482  REAL8 x = w0l/(m*Omega);
483  REAL8 x_u = -3./2./u*x;
484  REAL8 x2 = x*x;
485  REAL8 x5_3 = pow(x, 5./3.);
486  REAL8 sqrtepsm = sqrt(256./5.*eta*pow(w0l/m, 5./3.));
487  REAL8 that = 8./5./sqrtepsm * (1. - x5_3);
488  REAL8 that_u = -8./3./sqrtepsm * x5_3/x * x_u;
489  REAL8 argcossin = 3./8.*that*that;
490  REAL8 argcossin_u = 3./4.*that*that_u;
491  REAL8 argfresnel = 0.5*sqrt(3./LAL_PI)*that;
492  /* Resonant term, first two terms in the bracket - use perturbative expansion near resonance */
493  REAL8 resonantterm, resonantterm_u;
494  if(fabs(x-1.)>1e-2) {
495  resonantterm = f_keffresonant(x, x5_3);
496  resonantterm_u = x_u * df_keffresonant(x, x5_3);
497  }
498  else {
499  resonantterm = f_keffresonant_pert(x);
500  resonantterm_u = x_u * df_keffresonant_pert(x);
501  }
502  /* Fresnel term, third term featuring Qlm */
503  REAL8 fres[2];
504  fresnel_sc(argfresnel, fres);
505  REAL8 fresnelS = fres[0];
506  REAL8 fresnelC = fres[1];
507  REAL8 fresnelterm = sqrt(LAL_PI/3.)/sqrtepsm * x2*((1. + 2.*fresnelS)*cos(argcossin) - (1. + 2.*fresnelC)*sin(argcossin));
508  REAL8 fresnelterm_u = sqrt(LAL_PI/3.)/sqrtepsm * (2.*x*x_u*((1. + 2.*fresnelS)*cos(argcossin) - (1. + 2.*fresnelC)*sin(argcossin)) - x2*argcossin_u*((1. + 2.*fresnelS)*sin(argcossin) + (1. + 2.*fresnelC)*cos(argcossin)));
509  REAL8 klTidaleff = al + bl*(resonantterm + fresnelterm);
510  REAL8 klTidaleff_u = bl*(resonantterm_u + fresnelterm_u);
511  output[0] = klTidaleff;
512  output[1] = klTidaleff_u;
513 
514  return XLAL_SUCCESS;
515 }
516 
517 /**
518  * Function to compute the quadrupolar tidal contribution to the EOB Delta_u potential for just one NS.
519  * This implements the model of Phys.Rev.Lett. 116 (2016) no.18, 181101
520  */
522  REAL8 u, /**<< Inverse of radial separation in units of M */
523  REAL8 u2, /**<< Inverse of radial separation^2 in units of M */
524  REAL8 u6, /**<< Inverse of radial separation^6 in units of M */
525  REAL8 XNS, /**<< NS mass by M */
526  REAL8 XCompanion, /**<< Companion mass by M */
527  REAL8 lambda2TidalNS, /**<< NS dimensionless quadrupolar tidal deformability */
528  REAL8 k2TidalNSeff /**<< Dynamical enhancement of k2TidalNS */
529 )
530 {
531  return - 3.*XCompanion/XNS*lambda2TidalNS*k2TidalNSeff*u6* ( 1. + 5./2.*u*XNS + u2*(3. + XNS/8. + 337./28.*XNS*XNS) );
532 }
533 
534 /**
535  * Function to compute the u-derivative of the quadrupolar tidal contribution to the EOB Delta_u potential for just one NS.
536  * This implements the model of Phys.Rev.Lett. 116 (2016) no.18, 181101
537  */
539  REAL8 u, /**<< Inverse of radial separation in units of M */
540  REAL8 u2, /**<< Inverse of radial separation^2 in units of M */
541  REAL8 u6, /**<< Inverse of radial separation^6 in units of M */
542  REAL8 XNS, /**<< NS mass by M */
543  REAL8 XCompanion, /**<< Companion mass by M */
544  REAL8 lambda2TidalNS, /**<< NS dimensionless quadrupolar tidal deformability */
545  REAL8 k2TidalNSeff, /**<< Dynamical enhancement of k2TidalNS */
546  REAL8 k2TidalNSeff_u /**<< u-derivative of the dynamical enhancement of k2TidalNS */
547 )
548 {
549  REAL8 deltaUQSingle = XLALSimIMRTEOBdeltaUTidalQuadSingleNS(u, u2, u6, XNS, XCompanion, lambda2TidalNS, k2TidalNSeff);
550  return (6./u + ( 5./2.*XNS + 2.*u*(3. + XNS/8. + 337./28.*XNS*XNS) )/( 1. + 5./2.*u*XNS + u2*(3. + XNS/8. + 337./28.*XNS*XNS) ) + k2TidalNSeff_u/k2TidalNSeff)*deltaUQSingle;
551 }
552 
553 
554 /**
555  * Function to compute the quadrupolar tidal contribution to the EOB Delta_u potential.
556  * This implements the model of Phys.Rev.Lett. 116 (2016) no.18, 181101
557  */
559  REAL8 u, /**<< Inverse of radial separation in units of M */
560  REAL8 u2, /**<< Inverse of radial separation^2 in units of M */
561  REAL8 u6, /**<< Inverse of radial separation^6 in units of M */
562  REAL8 eta, /**<< Symmetric mass ratio */
563  TidalEOBParams *tidal1, /**<< Tidal parameters of body 1 */
564  TidalEOBParams *tidal2 /**<< Tidal parameters of body 2 */
565 )
566 {
567  REAL8 k2Tidal1eff = 0.;
568  REAL8 k2Tidal2eff = 0.;
569  REAL8 deltaUQ = 0.;
570  if ( tidal1->lambda2Tidal != 0.) {
571  k2Tidal1eff = XLALSimIMRTEOBkleff(2, u, eta, tidal1);
572  deltaUQ += XLALSimIMRTEOBdeltaUTidalQuadSingleNS(u, u2, u6, tidal1->mByM, tidal2->mByM, tidal1->lambda2Tidal, k2Tidal1eff);
573  }
574  if ( tidal2->lambda2Tidal != 0.) {
575  k2Tidal2eff = XLALSimIMRTEOBkleff(2, u, eta, tidal2);
576  deltaUQ += XLALSimIMRTEOBdeltaUTidalQuadSingleNS(u, u2, u6, tidal2->mByM, tidal1->mByM, tidal2->lambda2Tidal, k2Tidal2eff);
577  }
578  return deltaUQ;
579 }
580 
581 /**
582  * Function to compute the u-derivative of the quadrupolar tidal contribution to the EOB Delta_u potential.
583  * This implements the model of Phys.Rev.Lett. 116 (2016) no.18, 181101
584  */
586  REAL8 u, /**<< Inverse of radial separation in units of M */
587  REAL8 u2, /**<< Inverse of radial separation^2 in units of M */
588  REAL8 u6, /**<< Inverse of radial separation^6 in units of M */
589  REAL8 eta, /**<< Symmetric mass ratio */
590  TidalEOBParams *tidal1, /**<< Tidal parameters of body 1 */
591  TidalEOBParams *tidal2 /**<< Tidal parameters of body 2 */
592 )
593 {
594  REAL8 k2Tidal1eff = 0.;
595  REAL8 k2Tidal2eff = 0.;
596  REAL8 k2Tidal1eff_u = 0.;
597  REAL8 k2Tidal2eff_u = 0.;
598  REAL8 deltaUQ_u = 0.;
599  if ( tidal1->lambda2Tidal != 0.) {
600  REAL8 k2Tidal1eff_and_k2Tidal1eff[2];
601  XLALSimIMRTEOBkleff_and_kleff_u(2, u, eta, tidal1, k2Tidal1eff_and_k2Tidal1eff);
602  k2Tidal1eff = k2Tidal1eff_and_k2Tidal1eff[0];
603  k2Tidal1eff_u = k2Tidal1eff_and_k2Tidal1eff[1];
604  deltaUQ_u += XLALSimIMRTEOBdeltaUTidalQuadSingleNS_u(u, u2, u6, tidal1->mByM, tidal2->mByM, tidal1->lambda2Tidal, k2Tidal1eff, k2Tidal1eff_u);
605  }
606  if ( tidal2->lambda2Tidal != 0.) {
607  REAL8 k2Tidal2eff_and_k2Tidal2eff[2];
608  XLALSimIMRTEOBkleff_and_kleff_u(2, u, eta, tidal2, k2Tidal2eff_and_k2Tidal2eff);
609  k2Tidal2eff = k2Tidal2eff_and_k2Tidal2eff[0];
610  k2Tidal2eff_u = k2Tidal2eff_and_k2Tidal2eff[1];
611  deltaUQ_u += XLALSimIMRTEOBdeltaUTidalQuadSingleNS_u(u, u2, u6, tidal2->mByM, tidal1->mByM, tidal2->lambda2Tidal, k2Tidal2eff, k2Tidal2eff_u);
612  }
613  return deltaUQ_u;
614 }
615 
616 
617 /**
618  * Function to compute the octupolar tidal contribution to the EOB Delta_u potential for just one NS.
619  * This implements the model of Phys.Rev.Lett. 116 (2016) no.18, 181101
620  */
622  REAL8 u, /**<< Inverse of radial separation in units of M */
623  REAL8 u2, /**<< Inverse of radial separation^2 in units of M */
624  REAL8 u8, /**<< Inverse of radial separation^8 in units of M */
625  REAL8 XNS, /**<< NS mass by M */
626  REAL8 XCompanion, /**<< Companion mass by M */
627  REAL8 lambda3TidalNS, /**<< NS dimensionless octupolar tidal deformability */
628  REAL8 k3TidalNSeff /**<< Dynamical enhancement of k3TidalNS */
629 )
630 {
631  return - 15.*XCompanion/XNS*lambda3TidalNS*k3TidalNSeff*u8* (1. + u*(15./2.*XNS - 2.) + u2*(8./3. - 311./24.*XNS + 110./3.*XNS*XNS) );
632 }
633 
634 /**
635  * Function to compute the u-derivative of the octupolar tidal contribution to the EOB Delta_u potential for just one NS.
636  * This implements the model of Phys.Rev.Lett. 116 (2016) no.18, 181101
637  */
639  REAL8 u, /**<< Inverse of radial separation in units of M */
640  REAL8 u2, /**<< Inverse of radial separation^2 in units of M */
641  REAL8 u8, /**<< Inverse of radial separation^8 in units of M */
642  REAL8 XNS, /**<< NS mass by M */
643  REAL8 XCompanion, /**<< Companion mass by M */
644  REAL8 lambda3TidalNS, /**<< NS dimensionless octupolar tidal deformability */
645  REAL8 k3TidalNSeff, /**<< Dynamical enhancement of k3TidalNS */
646  REAL8 k3TidalNSeff_u /**<< u-derivative of dynamical enhancement of k3TidalNS */
647 )
648 {
649  REAL8 deltaUOSingle = XLALSimIMRTEOBdeltaUTidalOctuSingleNS(u, u2, u8, XNS, XCompanion, lambda3TidalNS, k3TidalNSeff);
650  return (8./u + ((15./2.*XNS - 2.) + 2.*u*(8./3. - 311./24.*XNS + 110./3.*XNS*XNS) )/(1. + u*(15./2.*XNS - 2.) + u2*(8./3. - 311./24.*XNS + 110./3.*XNS*XNS) ) + k3TidalNSeff_u/k3TidalNSeff)*deltaUOSingle;
651 }
652 
653 /**
654  * Function to compute the octupolar tidal contribution to the EOB Delta_u potential.
655  * This implements the model of Phys.Rev.Lett. 116 (2016) no.18, 181101
656  */
658  REAL8 u, /**<< Inverse of radial separation in units of M */
659  REAL8 u2, /**<< Inverse of radial separation^2 in units of M */
660  REAL8 u8, /**<< Inverse of radial separation^8 in units of M */
661  REAL8 eta, /**<< Symmetric mass ratio */
662  TidalEOBParams *tidal1, /**<< Tidal parameters of body 1 */
663  TidalEOBParams *tidal2 /**<< Tidal parameters of body 2 */
664 )
665 {
666  REAL8 k3Tidal1eff = 0.;
667  REAL8 k3Tidal2eff = 0.;
668  REAL8 deltaUO = 0.;
669  if ( tidal1->lambda3Tidal != 0.) {
670  k3Tidal1eff = XLALSimIMRTEOBkleff(3, u, eta, tidal1);
671  deltaUO += XLALSimIMRTEOBdeltaUTidalOctuSingleNS(u, u2, u8, tidal1->mByM, tidal2->mByM, tidal1->lambda3Tidal, k3Tidal1eff);
672  }
673  if ( tidal2->lambda3Tidal != 0.) {
674  k3Tidal2eff = XLALSimIMRTEOBkleff(3, u, eta, tidal2);
675  deltaUO += XLALSimIMRTEOBdeltaUTidalOctuSingleNS(u, u2, u8, tidal2->mByM, tidal1->mByM, tidal2->lambda3Tidal, k3Tidal2eff);
676  }
677  return deltaUO;
678 }
679 
680 /**
681  * Function to compute the u-derivative of the octupolar tidal contribution to the EOB Delta_u potential.
682  * This implements the model of Phys.Rev.Lett. 116 (2016) no.18, 181101
683  */
685  REAL8 u, /**<< Inverse of radial separation in units of M */
686  REAL8 u2, /**<< Inverse of radial separation^2 in units of M */
687  REAL8 u8, /**<< Inverse of radial separation^8 in units of M */
688  REAL8 eta, /**<< Symmetric mass ratio */
689  TidalEOBParams *tidal1, /**<< Tidal parameters of body 1 */
690  TidalEOBParams *tidal2 /**<< Tidal parameters of body 2 */
691 )
692 {
693  REAL8 k3Tidal1eff = 0.;
694  REAL8 k3Tidal2eff = 0.;
695  REAL8 k3Tidal1eff_u = 0.;
696  REAL8 k3Tidal2eff_u = 0.;
697  REAL8 deltaUO_u = 0.;
698  if ( tidal1->lambda3Tidal != 0.) {
699  REAL8 output[2];
700  XLALSimIMRTEOBkleff_and_kleff_u(3, u, eta, tidal1, output);
701  k3Tidal1eff = output[0];
702  k3Tidal1eff_u = output[1];
703 
704  deltaUO_u += XLALSimIMRTEOBdeltaUTidalOctuSingleNS_u(u, u2, u8, tidal1->mByM, tidal2->mByM, tidal1->lambda3Tidal, k3Tidal1eff, k3Tidal1eff_u);
705  }
706  if ( tidal2->lambda3Tidal != 0.) {
707  REAL8 output[2];
708  XLALSimIMRTEOBkleff_and_kleff_u(3, u, eta, tidal2, output);
709  k3Tidal2eff = output[0];
710  k3Tidal2eff_u = output[1];
711 
712  deltaUO_u += XLALSimIMRTEOBdeltaUTidalOctuSingleNS_u(u, u2, u8, tidal2->mByM, tidal1->mByM, tidal2->lambda3Tidal, k3Tidal2eff, k3Tidal2eff_u);
713  }
714  return deltaUO_u;
715 }
716 
717 /**
718  * Function to compute the tidal contribution to the EOB Delta_u potential.
719  * This implements the model of Phys.Rev.Lett. 116 (2016) no.18, 181101
720  */
722  REAL8 u, /**<< Inverse of radial separation in units of M */
723  REAL8 eta, /**<< Symmetric mass ratio */
724  TidalEOBParams *tidal1, /**<< Tidal parameters of body 1 */
725  TidalEOBParams *tidal2 /**<< Tidal parameters of body 2 */
726 )
727 {
728  REAL8 u2 = u*u;
729  REAL8 u6 = u2*u2*u2;
730  REAL8 deltaUQ = XLALSimIMRTEOBdeltaUTidalQuad(u, u2, u6, eta, tidal1, tidal2);
731  REAL8 deltaUO = 0.;
732  if ( (tidal1->lambda3Tidal != 0. && tidal1->omega03Tidal != 0.) || (tidal2->lambda3Tidal != 0. && tidal2->omega03Tidal != 0.) ) {
733  REAL8 u8 = u2*u6;
734  deltaUO = XLALSimIMRTEOBdeltaUTidalOctu(u, u2, u8, eta, tidal1, tidal2);
735  }
736  return deltaUQ + deltaUO;
737 }
738 
739 /**
740  * Function to compute the u-derivative of the tidal contribution to the EOB Delta_u potential.
741  * This implements the model of Phys.Rev.Lett. 116 (2016) no.18, 181101
742  */
744  REAL8 u, /**<< Inverse of radial separation in units of M */
745  REAL8 eta, /**<< Symmetric mass ratio */
746  TidalEOBParams *tidal1, /**<< Tidal parameters of body 1 */
747  TidalEOBParams *tidal2 /**<< Tidal parameters of body 2 */
748  )
749 {
750  REAL8 u2 = u*u;
751  REAL8 u6 = u2*u2*u2;
752  REAL8 deltaUQ_u = XLALSimIMRTEOBdeltaUTidalQuad_u(u, u2, u6, eta, tidal1, tidal2);
753  REAL8 deltaUO_u = 0.;
754  if ( (tidal1->lambda3Tidal != 0. && tidal1->omega03Tidal != 0.) || (tidal2->lambda3Tidal != 0. && tidal2->omega03Tidal != 0.) ) {
755  REAL8 u8 = u2*u6;
756  deltaUO_u = XLALSimIMRTEOBdeltaUTidalOctu_u(u, u2, u8, eta, tidal1, tidal2);
757  }
758  return deltaUQ_u + deltaUO_u;
759 }
760 
761 /**
762  * Function to compute the leading-order 2PN spin-induced quadrupole contribution to Heff/mu
763  * consistently with code in the function XLALSimIMRSpinEOBHamiltonian, written for generic Cartesian spin components, although used so far only for spin aligned
764  */
766  const REAL8 eta, /**<< Symmetric mass ratio */
767  REAL8 u, /**<< Inverse of radial separation in units of M */
768  REAL8Vector * restrict s1Vec, /**<< Spin vector 1 */
769  REAL8Vector * restrict s2Vec, /**<< Spin vector 2 */
770  REAL8 nx, /**<< Cartesian component of unit separation vector n */
771  REAL8 ny, /**<< Cartesian component of unit separation vector n */
772  REAL8 nz, /**<< Cartesian component of unit separation vector n */
773  TidalEOBParams *tidal1, /**<< Tidal parameters of body 1 */
774  TidalEOBParams *tidal2 /**<< Tidal parameters of body 2 */
775 )
776 {
777  REAL8 deltaHss = 0.;
778  REAL8 u3 = u*u*u;
779  REAL8 m1ByM = tidal1->mByM;
780  REAL8 m2ByM = tidal2->mByM;
781  REAL8 s1_x = s1Vec->data[0];
782  REAL8 s1_y = s1Vec->data[1];
783  REAL8 s1_z = s1Vec->data[2];
784  REAL8 s2_x = s2Vec->data[0];
785  REAL8 s2_y = s2Vec->data[1];
786  REAL8 s2_z = s2Vec->data[2];
787  REAL8 quadparam1 = tidal1->quadparam;
788  REAL8 quadparam2 = tidal2->quadparam;
789  REAL8 s1s1 = s1_x * s1_x + s1_y * s1_y + s1_z * s1_z;
790  REAL8 s2s2 = s2_x * s2_x + s2_y * s2_y + s2_z * s2_z;
791  REAL8 s1n = s1_x * nx + s1_y * ny + s1_z * nz;
792  REAL8 s2n = s2_x * nx + s2_y * ny + s2_z * nz;
793  deltaHss = 0.5 * u3 / eta * ((quadparam1 - 1.) * m2ByM/m1ByM * (3. * s1n*s1n - s1s1) + (quadparam2 - 1.) * m1ByM/m2ByM * (3. * s2n*s2n - s2s2));
794  return deltaHss;
795 }
796 
797 /**
798  *
799  * Function to calculate the value of the spinning Hamiltonian for given values
800  * of the dynamical variables (in a Cartesian co-ordinate system). The inputs are
801  * as follows:
802  *
803  * x - the separation vector r expressed in Cartesian co-ordinates
804  * p - the momentum vector (with the radial component tortoise pr*)
805  * sigmaKerr - spin of the effective Kerr background (a combination of the individual spin vectors)
806  * sigmaStar - spin of the effective particle (a different combination of the individual spins).
807  * coeffs - coefficients which crop up in the Hamiltonian. These can be calculated using the
808  * XLALCalculateSpinEOBParams() function.
809  *
810  * The function returns a REAL8, which will be the value of the Hamiltonian if all goes well;
811  * otherwise, it will return the XLAL REAL8 failure NaN.
812  */
813 static REAL8
814 XLALSimIMRSpinEOBHamiltonian (const REAL8 eta, /**<< Symmetric mass ratio */
815  REAL8Vector * restrict x,
816  /**<< Position vector */
817  REAL8Vector * restrict p,
818  /**<< Momentum vector (tortoise radial component pr*) */
819  REAL8Vector * restrict s1Vec,
820  /**<< Spin vector 1 */
821  REAL8Vector * restrict s2Vec,
822  /**<< Spin vector 2 */
823  REAL8Vector * restrict sigmaKerr,
824  /**<< Spin vector sigma_kerr */
825  REAL8Vector * restrict sigmaStar,
826  /**<< Spin vector sigma_star */
827  INT4 tortoise, /**<< flag to state whether the momentum is the tortoise co-ord */
828  SpinEOBHCoeffs * coeffs
829  /**<< Structure containing various coefficients */
830  )
831 {
832  REAL8 r, r2, nx, ny, nz;
833  REAL8 sKerr_x, sKerr_y, sKerr_z, a, a2;
834  REAL8 sStar_x, sStar_y, sStar_z;
835  REAL8 e3_x, e3_y, e3_z;
836  REAL8 costheta; /* Cosine of angle between Skerr and r */
837  REAL8 xi2, xi_x, xi_y, xi_z; /* Cross product of unit vectors in direction of Skerr and r */
838  REAL8 vx, vy, vz, pxir, pvr, pn, prT, pr, pf, ptheta2; /*prT is the tortoise pr */
839  REAL8 w2, rho2;
840  REAL8 u, u2, u3, u4, u5;
842  REAL8 D, qq, ww, B, w, MU, nu, BR, wr, nur, mur;
843  REAL8 wcos, nucos, mucos, ww_r, Lambda_r;
844  REAL8 logTerms, deltaU, deltaU_u, Q, deltaT_r, pn2, pp;
845  REAL8 deltaSigmaStar_x, deltaSigmaStar_y, deltaSigmaStar_z;
846  REAL8 sx, sy, sz, sxi, sv, sn, s3;
847  REAL8 H, Hns, Hs, Hss, Hreal, Hwcos, Hwr, HSOL, HSONL;
849 
850  /* Terms which come into the 3.5PN mapping of the spins */
851  //REAL8 aaa, bbb, a13P5, a23P5, a33P5, b13P5, b23P5, b33P5;
853 
854  /*Temporary p vector which we will make non-tortoise */
855  REAL8 tmpP[3];
856 
857  REAL8 csi;
858 
859  /* Spin gauge parameters. (YP) simplified, since both are zero. */
860  // static const double aa=0., bb=0.;
861 
862  //printf( "In Hamiltonian:\n" );
863  //printf( "x = %.16e\t%.16e\t%.16e\n", x->data[0], x->data[1], x->data[2] );
864  //printf( "p = %.16e\t%.16e\t%.16e\n", p->data[0], p->data[1], p->data[2] );
865 
866  r2 =
867  x->data[0] * x->data[0] + x->data[1] * x->data[1] +
868  x->data[2] * x->data[2];
869  r = sqrt (r2);
870  nx = x->data[0] / r;
871  ny = x->data[1] / r;
872  nz = x->data[2] / r;
873 
874  sKerr_x = sigmaKerr->data[0];
875  sKerr_y = sigmaKerr->data[1];
876  sKerr_z = sigmaKerr->data[2];
877 
878  sStar_x = sigmaStar->data[0];
879  sStar_y = sigmaStar->data[1];
880  sStar_z = sigmaStar->data[2];
881 
882  a2 = sKerr_x * sKerr_x + sKerr_y * sKerr_y + sKerr_z * sKerr_z;
883  a = sqrt (a2);
884 
885  if (a != 0.)
886  {
887  e3_x = sKerr_x / a;
888  e3_y = sKerr_y / a;
889  e3_z = sKerr_z / a;
890  }
891  else
892  {
893  e3_x = 0.;
894  e3_y = 0.;
895  e3_z = 1.;
896  }
897 
898  costheta = e3_x * nx + e3_y * ny + e3_z * nz;
899 
900  xi2 = 1. - costheta * costheta;
901 
902  xi_x = -e3_z * ny + e3_y * nz;
903  xi_y = e3_z * nx - e3_x * nz;
904  xi_z = -e3_y * nx + e3_x * ny;
905 
906  vx = -nz * xi_y + ny * xi_z;
907  vy = nz * xi_x - nx * xi_z;
908  vz = -ny * xi_x + nx * xi_y;
909 
910  w2 = r2 + a2;
911  rho2 = r2 + a2 * costheta * costheta;
912 
913  u = 1. / r;
914  u2 = u * u;
915  u3 = u2 * u;
916  u4 = u2 * u2;
917  u5 = u4 * u;
918 
919  //printf( "KK = %.16e\n", coeffs->KK );
920  m1PlusetaKK = -1. + eta * coeffs->KK;
921  /* Eq. 5.75 of BB1 */
922  bulk = 1. / (m1PlusetaKK * m1PlusetaKK) + (2. * u) / m1PlusetaKK + a2 * u2;
923  /* Eq. 5.73 of BB1 */
924  logTerms =
925  1. + eta * coeffs->k0 + eta * log (1. + coeffs->k1 * u + coeffs->k2 * u2 +
926  coeffs->k3 * u3 + coeffs->k4 * u4 +
927  coeffs->k5 * u5 +
928  coeffs->k5l * u5 * log (u));
929  //printf( "bulk = %.16e, logTerms = %.16e\n", bulk, logTerms );
930  /* Eq. 5.73 of BB1 */
931  deltaU = bulk * logTerms;
932  if ( (coeffs->tidal1->lambda2Tidal != 0. && coeffs->tidal1->omega02Tidal != 0.) || (coeffs->tidal2->lambda2Tidal != 0. && coeffs->tidal2->omega02Tidal != 0.) ) {
933  deltaU += XLALSimIMRTEOBdeltaUTidal(u, eta, coeffs->tidal1, coeffs->tidal2);
934  }
935 
936  /* Eq. 5.71 of BB1 */
937  deltaT = r2 * deltaU;
938  /* ddeltaU/du */
939  deltaU_u = 2. * (1. / m1PlusetaKK + a2 * u) * logTerms +
940  bulk * (eta *
941  (coeffs->k1 +
942  u * (2. * coeffs->k2 +
943  u * (3. * coeffs->k3 +
944  u * (4. * coeffs->k4 +
945  5. * (coeffs->k5 +
946  coeffs->k5l * log (u)) * u))))) / (1. +
947  coeffs->
948  k1 * u +
949  coeffs->
950  k2 * u2 +
951  coeffs->
952  k3 * u3 +
953  coeffs->
954  k4 * u4 +
955  (coeffs->
956  k5 +
957  coeffs->
958  k5l *
959  log (u))
960  * u5);
961  if ( (coeffs->tidal1->lambda2Tidal != 0. && coeffs->tidal1->omega02Tidal != 0.) || (coeffs->tidal2->lambda2Tidal != 0. && coeffs->tidal2->omega02Tidal != 0.) ) {
962  deltaU_u += XLALSimIMRTEOBdeltaUTidal_u(u, eta, coeffs->tidal1, coeffs->tidal2);
963 // FILE *out = fopen("outDImpor.dat","a");
964 // fprintf(out, "%.16e %.16e %.16e\n", u, XLALSimIMRTEOBdeltaUTidal(u, eta, coeffs->tidal1, coeffs->tidal2), XLALSimIMRTEOBdeltaUTidal_u(u, eta, coeffs->tidal1, coeffs->tidal2));
965 // fclose(out);
966  }
967  /* ddeltaT/dr */
968  deltaT_r = 2. * r * deltaU - deltaU_u;
969  /* Eq. 5.39 of BB1 */
970  Lambda = w2 * w2 - a2 * deltaT * xi2;
971  /* Eq. 5.83 of BB1, inverse */
972  D = 1. + log (1. + 6. * eta * u2 + 2. * (26. - 3. * eta) * eta * u3);
973  /* Eq. 5.38 of BB1 */
974  deltaR = deltaT * D;
975  /* See Hns below, Eq. 4.34 of Damour et al. PRD 62, 084011 (2000) */
976  qq = 2. * eta * (4. - 3. * eta);
977  /* See Hns below. In Sec. II D of BB2 b3 and bb3 coeffs are chosen to be zero. */
978  ww = 2. * a * r + coeffs->b3 * eta * a2 * a * u + coeffs->bb3 * eta * a * u;
979 
980  /* We need to transform the momentum to get the tortoise co-ord */
981  if (tortoise)
982  {
983  csi = sqrt (deltaT * deltaR) / w2; /* Eq. 28 of Pan et al. PRD 81, 084041 (2010) */
984  }
985  else
986  {
987  csi = 1.0;
988  }
989  //printf( "csi(miami) = %.16e\n", csi );
990 
991  prT = p->data[0] * nx + p->data[1] * ny + p->data[2] * nz;
992  /* p->data is BL momentum vector; tmpP is tortoise momentum vector */
993  tmpP[0] = p->data[0] - nx * prT * (csi - 1.) / csi;
994  tmpP[1] = p->data[1] - ny * prT * (csi - 1.) / csi;
995  tmpP[2] = p->data[2] - nz * prT * (csi - 1.) / csi;
996 
997  pxir = (tmpP[0] * xi_x + tmpP[1] * xi_y + tmpP[2] * xi_z) * r;
998  pvr = (tmpP[0] * vx + tmpP[1] * vy + tmpP[2] * vz) * r;
999  pn = tmpP[0] * nx + tmpP[1] * ny + tmpP[2] * nz;
1000 
1001  pr = pn;
1002  pf = pxir;
1003  ptheta2 = pvr * pvr / xi2;
1004 
1005  //printf( "pr = %.16e, prT = %.16e\n", pr, prT );
1006 
1007  //printf( " a = %.16e, r = %.16e\n", a, r );
1008  //printf( "D = %.16e, ww = %.16e, rho = %.16e, Lambda = %.16e, xi = %.16e\npr = %.16e, pf = %.16e, deltaR = %.16e, deltaT = %.16e\n",
1009  //D, ww, sqrt(rho2), Lambda, sqrt(xi2), pr, pf, deltaR, deltaT );
1010  /* Eqs. 5.36 - 5.46 of BB1 */
1011  /* Note that the tortoise prT appears only in the quartic term, explained in Eqs. 14 and 15 of Tarrachini et al. */
1012  Hns =
1013  sqrt (1. + prT * prT * prT * prT * qq * u2 + ptheta2 / rho2 +
1014  pf * pf * rho2 / (Lambda * xi2) +
1015  pr * pr * deltaR / rho2) / sqrt (Lambda / (rho2 * deltaT)) +
1016  pf * ww / Lambda;
1017 
1018  //printf( "term 1 in Hns: %.16e\n", prT*prT*prT*prT*qq*u2 );
1019  //printf( "term 2 in Hns: %.16e\n", ptheta2/rho2 );
1020  //printf( "term 3 in Hns = %.16e\n", pf*pf*rho2/(Lambda*xi2) );
1021  //printf( "term 4 in Hns = %.16e\n", pr*pr*deltaR/rho2 );
1022  //printf( "term 5 in Hns = %.16e\n", Lambda/(rho2*deltaT) );
1023  //printf( "term 6 in Hns = %.16e\n", pf*ww/Lambda );
1024  /* Eqs. 5.30 - 5.33 of BB1 */
1025  B = sqrt (deltaT);
1026  w = ww / Lambda;
1027  nu = 0.5 * log (deltaT * rho2 / Lambda);
1028  MU = 0.5 * log (rho2);
1029  /* dLambda/dr */
1030  Lambda_r = 4. * r * w2 - a2 * deltaT_r * xi2;
1031 
1032  ww_r =
1033  2. * a - (a2 * a * coeffs->b3 * eta) * u2 - coeffs->bb3 * eta * a * u2;
1034  /* Eqs. 5.47a - 5.47d of BB1 */
1035  BR =
1036  (-2. * deltaT + sqrt (deltaR) * deltaT_r) / (2. * sqrt (deltaR * deltaT));
1037  wr = (-Lambda_r * ww + Lambda * ww_r) / (Lambda * Lambda);
1038  nur =
1039  (r / rho2 +
1040  (w2 * (-4. * r * deltaT + w2 * deltaT_r)) / (2. * deltaT * Lambda));
1041  mur = (r / rho2 - 1. / sqrt (deltaR));
1042  /* Eqs. 5.47f - 5.47h of BB1 */
1043  wcos = -2. * a2 * costheta * deltaT * ww / (Lambda * Lambda);
1044  nucos = a2 * costheta * w2 * (w2 - deltaT) / (rho2 * Lambda);
1045  mucos = a2 * costheta / rho2;
1046  /* Eq. 5.52 of BB1, (YP) simplified */
1047  //Q = 1. + pvr*pvr/(exp(2.*MU)*xi2) + exp(2.*nu)*pxir*pxir/(B*B*xi2) + pn*pn*deltaR/exp(2.*MU);
1048  Q =
1049  1. + pvr * pvr / (rho2 * xi2) +
1050  deltaT * rho2 / Lambda * pxir * pxir / (B * B * xi2) +
1051  pn * pn * deltaR / rho2;
1052 
1053  pn2 = pr * pr * deltaR / rho2;
1054  pp = Q - 1.;
1055 
1056  //printf( "pn2 = %.16e, pp = %.16e\n", pn2, pp );
1057  //printf( "sigmaKerr = %.16e, sigmaStar = %.16e\n", sKerr_z, sStar_z );
1058  /* Eq. 5.68 of BB1, (YP) simplified for aa=bb=0. */
1059  /*
1060  deltaSigmaStar_x=(- 8.*aa*(1. + 3.*pn2*r - pp*r)*sKerr_x - 8.*bb*(1. + 3.*pn2*r - pp*r)*sStar_x +
1061  eta*(-8.*sKerr_x - 36.*pn2*r*sKerr_x + 3.*pp*r*sKerr_x + 14.*sStar_x - 30.*pn2*r*sStar_x + 4.*pp*r*sStar_x))/(12.*r);
1062 
1063  deltaSigmaStar_y=(-8.*aa*(1. + 3.*pn2*r - pp*r)*sKerr_y - 8.*bb*(1. + 3.*pn2*r - pp*r)*sStar_y +
1064  eta*(-8.*sKerr_y - 36.*pn2*r*sKerr_y + 3.*pp*r*sKerr_y + 14.*sStar_y - 30.*pn2*r*sStar_y + 4.*pp*r*sStar_y))/(12.*r);
1065 
1066  deltaSigmaStar_z=(-8.*aa*(1. + 3.*pn2*r - pp*r)*sKerr_z - 8.*bb*(1. + 3.*pn2*r - pp*r)*sStar_z +
1067  eta*(-8.*sKerr_z - 36.*pn2*r*sKerr_z + 3.*pp*r*sKerr_z + 14.*sStar_z - 30.*pn2*r*sStar_z + 4.*pp*r*sStar_z))/(12.*r);
1068  */
1069  deltaSigmaStar_x =
1070  eta * (-8. * sKerr_x - 36. * pn2 * r * sKerr_x + 3. * pp * r * sKerr_x +
1071  14. * sStar_x - 30. * pn2 * r * sStar_x +
1072  4. * pp * r * sStar_x) / (12. * r);
1073 
1074  deltaSigmaStar_y =
1075  eta * (-8. * sKerr_y - 36. * pn2 * r * sKerr_y + 3. * pp * r * sKerr_y +
1076  14. * sStar_y - 30. * pn2 * r * sStar_y +
1077  4. * pp * r * sStar_y) / (12. * r);
1078 
1079  deltaSigmaStar_z =
1080  eta * (-8. * sKerr_z - 36. * pn2 * r * sKerr_z + 3. * pp * r * sKerr_z +
1081  14. * sStar_z - 30. * pn2 * r * sStar_z +
1082  4. * pp * r * sStar_z) / (12. * r);
1083 
1084 
1085  /* Now compute the additional 3.5PN terms. */
1086  /* The following gauge parameters correspond to those given by
1087  * Eqs. (69) and (70) of BB2 (aaa -> a0, bbb -> b0).
1088  * In SEOBNRv1 model, we chose to set all of them to zero,
1089  * described between Eqs. (3) and (4).
1090  */
1091  /*
1092  aaa = -3./2.*eta;
1093  bbb = -5./4.*eta;
1094  a1 = eta*eta/2.;
1095  a2 = -(1./8.)*eta*(-7. + 8.*eta);
1096  a3 = -((9.*eta*eta)/16.);
1097  b1 = 1./16.*eta*(9. + 5.*eta);
1098  b2 = -(1./8.)*eta*(-17. + 5.*eta);
1099  b3 = -3./8.*eta*eta;
1100  */
1101  /*aaa = 0.;
1102  bbb = 0.;
1103  a13P5 = 0.;
1104  a23P5 = 0.;
1105  a33P5 = 0.;
1106  b13P5 = 0.;
1107  b23P5 = 0.;
1108  b33P5 = 0.;
1109  */
1110  /* Eq. 52 of BB2, (YP) simplified for zero gauge parameters */
1111  /*
1112  sMultiplier1 =-(2.*(24.*b23P5 + eta*(-353. + 27.*eta) + bbb*(56. + 60.*eta)) +
1113  2.*(24.*b13P5 - 24.*b23P5 + bbb*(14. - 66.*eta) + 103.*eta - 60.*eta*eta)*pp*
1114  r + 120.*(2.*b33P5 - 3.*eta*(bbb + eta))*pn2*pn2*r*r +
1115  (-48.*b13P5 + 4.*bbb*(1. + 3.*eta) + eta*(23. + 3.*eta))*pp*pp*
1116  r*r + 6.*pn2*r*(16.*b13P5 + 32.*b23P5 + 24.*b33P5 - 47.*eta +
1117  54.*eta*eta + 24.*bbb*(1. + eta) +
1118  (24.*b13P5 - 24.*b33P5 - 16.*eta + 21.*eta*eta + bbb*(-2. + 30.*eta))*pp*
1119  r))/(72.*r*r);
1120  */
1121  sMultiplier1 =
1122  -(2. * eta * (-353. + 27. * eta) +
1123  2. * (103. * eta - 60. * eta * eta) * pp * r +
1124  120. * (-3. * eta * eta) * pn2 * pn2 * r * r +
1125  (eta * (23. + 3. * eta)) * pp * pp * r * r +
1126  6. * pn2 * r * (-47. * eta + 54. * eta * eta +
1127  (-16. * eta +
1128  21. * eta * eta) * pp * r)) / (72. * r * r);
1129  /* Eq. 52 of BB2, (YP) simplified for zero gauge parameters */
1130  /*
1131  sMultiplier2 = (-16.*(6.*a23P5 + 7.*eta*(8. + 3.*eta) + aaa*(14. + 15.*eta)) +
1132  4.*(-24.*a13P5 + 24.*a23P5 - 109.*eta + 51.*eta*eta + 2.*aaa*(-7. + 33.*eta))*
1133  pp*r + 30.*(-16.*a33P5 + 3.*eta*(8.*aaa + 9.*eta))*pn2*pn2*r*r +
1134  (96.*a13P5 - 45.*eta - 8.*aaa*(1. + 3.*eta))*pp*pp*r*r -
1135  6.*pn2*r*(32.*a13P5 + 64.*a23P5 + 48.*a33P5 + 16.*eta + 147.*eta*eta +
1136  48.*aaa*(1. + eta) + (48.*a13P5 - 48.*a33P5 - 6.*eta + 39.*eta*eta +
1137  aaa*(-4. + 60.*eta))*pp*r))/(144.*r*r);
1138  */
1139  sMultiplier2 =
1140  (-16. * (7. * eta * (8. + 3. * eta)) +
1141  4. * (-109. * eta + 51. * eta * eta) * pp * r +
1142  810. * eta * eta * pn2 * pn2 * r * r - 45. * eta * pp * pp * r * r -
1143  6. * pn2 * r * (16. * eta + 147. * eta * eta +
1144  (-6. * eta +
1145  39. * eta * eta) * pp * r)) / (144. * r * r);
1146  /* Eq. 52 of BB2 */
1147  deltaSigmaStar_x +=
1148  sMultiplier1 * sigmaStar->data[0] + sMultiplier2 * sigmaKerr->data[0];
1149  deltaSigmaStar_y +=
1150  sMultiplier1 * sigmaStar->data[1] + sMultiplier2 * sigmaKerr->data[1];
1151  deltaSigmaStar_z +=
1152  sMultiplier1 * sigmaStar->data[2] + sMultiplier2 * sigmaKerr->data[2];
1153 
1154  /* And now the (calibrated) 4.5PN term */
1155  deltaSigmaStar_x += coeffs->d1 * eta * sigmaStar->data[0] / (r * r * r);
1156  deltaSigmaStar_y += coeffs->d1 * eta * sigmaStar->data[1] / (r * r * r);
1157  deltaSigmaStar_z += coeffs->d1 * eta * sigmaStar->data[2] / (r * r * r);
1158  deltaSigmaStar_x += coeffs->d1v2 * eta * sigmaKerr->data[0] / (r * r * r);
1159  deltaSigmaStar_y += coeffs->d1v2 * eta * sigmaKerr->data[1] / (r * r * r);
1160  deltaSigmaStar_z += coeffs->d1v2 * eta * sigmaKerr->data[2] / (r * r * r);
1161 
1162 
1163  //printf( "deltaSigmaStar_x = %.16e, deltaSigmaStar_y = %.16e, deltaSigmaStar_z = %.16e\n",
1164  // deltaSigmaStar_x, deltaSigmaStar_y, deltaSigmaStar_z );
1165 
1166  sx = sStar_x + deltaSigmaStar_x;
1167  sy = sStar_y + deltaSigmaStar_y;
1168  sz = sStar_z + deltaSigmaStar_z;
1169 
1170 
1171  sxi = sx * xi_x + sy * xi_y + sz * xi_z;
1172  sv = sx * vx + sy * vy + sz * vz;
1173  sn = sx * nx + sy * ny + sz * nz;
1174 
1175  s3 = sx * e3_x + sy * e3_y + sz * e3_z;
1176  /* Eq. 3.45 of BB1, second term */
1177  Hwr =
1178  (exp (-3. * MU - nu) * sqrt (deltaR) *
1179  (exp (2. * (MU + nu)) * pxir * pxir * sv -
1180  B * exp (MU + nu) * pvr * pxir * sxi +
1181  B * B * xi2 * (exp (2. * MU) * (sqrt (Q) + Q) * sv +
1182  pn * pvr * sn * sqrt (deltaR) -
1183  pn * pn * sv * deltaR))) / (2. * B * (1. +
1184  sqrt (Q)) *
1185  sqrt (Q) * xi2);
1186  /* Eq. 3.45 of BB1, third term */
1187  Hwcos =
1188  (exp (-3. * MU - nu) *
1189  (sn *
1190  (-(exp (2. * (MU + nu)) * pxir * pxir) +
1191  B * B * (pvr * pvr - exp (2. * MU) * (sqrt (Q) + Q) * xi2)) -
1192  B * pn * (B * pvr * sv -
1193  exp (MU +
1194  nu) * pxir * sxi) * sqrt (deltaR))) / (2. * B * (1. +
1195  sqrt
1196  (Q)) *
1197  sqrt (Q));
1198  /* Eq. 3.44 of BB1, leading term */
1199  HSOL =
1200  (exp (-MU + 2. * nu) * (-B + exp (MU + nu)) * pxir * s3) / (B * B *
1201  sqrt (Q) *
1202  xi2);
1203  /* Eq. 3.44 of BB1, next-to-leading term */
1204  HSONL =
1205  (exp (-2. * MU + nu) *
1206  (-(B * exp (MU + nu) * nucos * pxir * (1. + 2. * sqrt (Q)) * sn * xi2) +
1207  (-(BR * exp (MU + nu) * pxir * (1. + sqrt (Q)) * sv) +
1208  B * (exp (MU + nu) * nur * pxir * (1. + 2. * sqrt (Q)) * sv +
1209  B * mur * pvr * sxi + B * sxi * (-(mucos * pn * xi2) +
1210  sqrt (Q) * (mur * pvr -
1211  nur * pvr + (-mucos +
1212  nucos) *
1213  pn * xi2)))) *
1214  sqrt (deltaR))) / (B * B * (sqrt (Q) + Q) * xi2);
1215  /* Eq. 3.43 and 3.45 of BB1 */
1216  Hs = w * s3 + Hwr * wr + Hwcos * wcos + HSOL + HSONL;
1217  /* Eq. 5.70 of BB1, last term */
1218  Hss = -0.5 * u3 * (sx * sx + sy * sy + sz * sz - 3. * sn * sn);
1219  /* Add correction for leading-order spin-induced quadrupole, relevant for BNS - this is zero when kappa_1,2=1 */
1220  if((coeffs->tidal1->quadparam - 1.) != 0. || (coeffs->tidal2->quadparam - 1.) != 0.) {
1221  Hss += XLALSimIMRTEOBdeltaHssQuadMonLO(eta, u, s1Vec, s2Vec, nx, ny, nz, coeffs->tidal1, coeffs->tidal2);
1222  }
1223  /* Eq. 5.70 of BB1 */
1224  H = Hns + Hs + Hss;
1225 
1226  /* Add the additional calibrated term */
1227  H +=
1228  coeffs->dheffSS * eta * (sKerr_x * sStar_x + sKerr_y * sStar_y +
1229  sKerr_z * sStar_z) / (r * r * r * r);
1230  /* One more calibrated term proportional to S1^2+S2^2. Note that we use symmetric expressions of m1,m2 and S1,S2 */
1231  /*H += coeffs->dheffSSv2 * eta / (r*r*r*r) / (1.-4.*eta)
1232  * ( (sKerr_x*sKerr_x + sKerr_y*sKerr_y + sKerr_z*sKerr_z)*(1.-4.*eta+2.*eta*eta)
1233  +(sKerr_x*sStar_x + sKerr_y*sStar_y + sKerr_z*sStar_z)*(-2.*eta+4.*eta*eta)
1234  +(sStar_x*sStar_x + sStar_y*sStar_y + sStar_z*sStar_z)*(2.*eta*eta) );*/
1235  H += coeffs->dheffSSv2 * eta / (r * r * r * r)
1236  * (s1Vec->data[0] * s1Vec->data[0] + s1Vec->data[1] * s1Vec->data[1] +
1237  s1Vec->data[2] * s1Vec->data[2] + s2Vec->data[0] * s2Vec->data[0] +
1238  s2Vec->data[1] * s2Vec->data[1] + s2Vec->data[2] * s2Vec->data[2]);
1239  //printf( "Hns = %.16e, Hs = %.16e, Hss = %.16e\n", Hns, Hs, Hss );
1240  //printf( "H = %.16e\n", H );
1241  /* Real Hamiltonian given by Eq. 2, ignoring the constant -1. */
1242  Hreal = sqrt (1. + 2. * eta * (H - 1.));
1243 
1244  return Hreal;
1245 }
1246 
1247 
1248 /**
1249  *
1250  * This function is used to calculate some coefficients which will be used in the
1251  * spinning EOB Hamiltonian. It takes the following inputs:
1252  *
1253  * coeffs - a (non-null) pointer to a SpinEOBParams structure. This will be populated
1254  * with the output.
1255  * eta - the symmetric mass ratio.
1256  * sigmaKerr - the spin of the effective Kerr background (a combination of the individual spins).
1257  *
1258  * If all goes well, the function will return XLAL_SUCCESS. Otherwise, XLAL_FAILURE is returned.
1259  */
1261  /**<< OUTPUT, EOB parameters including pre-computed coefficients */
1262  const REAL8 eta,
1263  /**<< symmetric mass ratio */
1264  const REAL8 a,
1265  /**<< Normalized deformed Kerr spin */
1266  const UINT4 SpinAlignedEOBversion
1267  /**<< 1 for SEOBNRv1; 2 for SEOBNRv2 */
1268  )
1269 {
1270 
1271  REAL8 KK, k0, k1, k2, k3, k4, k5, k5l, k1p2, k1p3;
1272  REAL8 m1PlusEtaKK;
1273 
1274  coeffs->SpinAlignedEOBversion = SpinAlignedEOBversion;
1275 
1276  /* Constants are fits taken from Eq. 37 */
1277  static const REAL8 c0 = 1.4467; /* needed to get the correct self-force results */
1278  static const REAL8 c1 = -1.7152360250654402;
1279  static const REAL8 c2 = -3.246255899738242;
1280 
1281  static const REAL8 c20 = 1.712;
1282  static const REAL8 c21 = -1.803949138004582;
1283  static const REAL8 c22 = -39.77229225266885;
1284  static const REAL8 c23 = 103.16588921239249;
1285 
1286  if (!coeffs)
1287  {
1289  }
1290 
1291 
1292  coeffs->b3 = 0.;
1293  coeffs->bb3 = 0.;
1294  coeffs->KK = KK = c0 + c1 * eta + c2 * eta * eta;
1295  if (SpinAlignedEOBversion == 2)
1296  {
1297  coeffs->KK = KK =
1298  c20 + c21 * eta + c22 * eta * eta + c23 * eta * eta * eta;
1299  }
1300 
1301  REAL8 chi = a / (1. - 2. * eta);
1302  REAL8 eta2 = eta * eta, eta3 = eta2 * eta;
1303  REAL8 chi2 = chi * chi, chi3 = chi2 * chi;
1304 
1305  if (SpinAlignedEOBversion == 4)
1306  {
1307  coeffs->KK = KK =
1308  coeff00K + coeff01K * chi + coeff02K * chi2 + coeff03K * chi3 +
1309  coeff10K * eta + coeff11K * eta * chi + coeff12K * eta * chi2 +
1310  coeff13K * eta * chi3 + coeff20K * eta2 + coeff21K * eta2 * chi +
1311  coeff22K * eta2 * chi2 + coeff23K * eta2 * chi3 + coeff30K * eta3 +
1312  coeff31K * eta3 * chi + coeff32K * eta3 * chi2 + coeff33K * eta3 * chi3;
1313 // printf("KK %.16e\n", KK);
1314  }
1315 
1316  m1PlusEtaKK = -1. + eta * KK;
1317  /* Eqs. 5.77 - 5.81 of BB1 */
1318  coeffs->k0 = k0 = KK * (m1PlusEtaKK - 1.);
1319  coeffs->k1 = k1 = -2. * (k0 + KK) * m1PlusEtaKK;
1320  k1p2 = k1 * k1;
1321  k1p3 = k1 * k1p2;
1322  coeffs->k2 = k2 =
1323  (k1 * (k1 - 4. * m1PlusEtaKK)) / 2. -
1324  a * a * k0 * m1PlusEtaKK * m1PlusEtaKK;
1325  coeffs->k3 = k3 =
1326  -k1 * k1 * k1 / 3. + k1 * k2 + k1 * k1 * m1PlusEtaKK - 2. * (k2 -
1327  m1PlusEtaKK)
1328  * m1PlusEtaKK - a * a * k1 * m1PlusEtaKK * m1PlusEtaKK;
1329  coeffs->k4 = k4 =
1330  (24. * k1 * k1 * k1 * k1 - 96. * k1 * k1 * k2 + 48. * k2 * k2 -
1331  64. * k1 * k1 * k1 * m1PlusEtaKK + 48. * a * a * (k1 * k1 -
1332  2. * k2) *
1333  m1PlusEtaKK * m1PlusEtaKK + 96. * k1 * (k3 + 2. * k2 * m1PlusEtaKK) -
1334  m1PlusEtaKK * (192. * k3 +
1335  m1PlusEtaKK * (-3008. + 123. * LAL_PI * LAL_PI))) / 96.;
1336  coeffs->k5 = k5 = 0.0;
1337  coeffs->k5l = k5l = 0.0;
1338  if (SpinAlignedEOBversion == 2)
1339  {
1340  coeffs->k5 = k5 = m1PlusEtaKK * m1PlusEtaKK
1341  * (-4237. / 60. + 128. / 5. * LAL_GAMMA +
1342  2275. * LAL_PI * LAL_PI / 512. - 1. / 3. * a * a * (k1p3 -
1343  3. * k1 * k2 +
1344  3. * k3) -
1345  (k1p3 * k1p2 - 5. * k1p3 * k2 + 5. * k1 * k2 * k2 +
1346  5. * k1p2 * k3 - 5. * k2 * k3 -
1347  5. * k1 * k4) / 5. / m1PlusEtaKK / m1PlusEtaKK + (k1p2 * k1p2 -
1348  4. * k1p2 * k2 +
1349  2. * k2 * k2 +
1350  4. * k1 * k3 -
1351  4. * k4) / 2. /
1352  m1PlusEtaKK + 256. / 5. * log (2.));
1353  coeffs->k5l = k5l = m1PlusEtaKK * m1PlusEtaKK * 64. / 5.;
1354  }
1355  if (SpinAlignedEOBversion == 4)
1356  {
1357  /* Include eta^2 terms at 4PN from arXiv:1305.4884 */
1358  coeffs->k5 = k5 = m1PlusEtaKK * m1PlusEtaKK
1359  * (-4237. / 60. + 128. / 5. * LAL_GAMMA +
1360  2275. * LAL_PI * LAL_PI / 512. - 1. / 3. * a * a * (k1p3 -
1361  3. * k1 * k2 +
1362  3. * k3) -
1363  (k1p3 * k1p2 - 5. * k1p3 * k2 + 5. * k1 * k2 * k2 +
1364  5. * k1p2 * k3 - 5. * k2 * k3 -
1365  5. * k1 * k4) / 5. / m1PlusEtaKK / m1PlusEtaKK + (k1p2 * k1p2 -
1366  4. * k1p2 * k2 +
1367  2. * k2 * k2 +
1368  4. * k1 * k3 -
1369  4. * k4) / 2. /
1370  m1PlusEtaKK + 256. / 5. * log (2.) + (41. * LAL_PI * LAL_PI / 32. -
1371  221. / 6.) * eta);
1372  coeffs->k5l = k5l = m1PlusEtaKK * m1PlusEtaKK * 64. / 5.;
1373  }
1374  /*printf( "a = %.16e, k0 = %.16e, k1 = %.16e, k2 = %.16e, k3 = %.16e, k4 = %.16e, b3 = %.16e, bb3 = %.16e, KK = %.16e\n",
1375  a, coeffs->k0, coeffs->k1, coeffs->k2, coeffs->k3, coeffs->k4, coeffs->b3, coeffs->bb3, coeffs->KK );
1376  */
1377 
1378  /* Now calibrated parameters for spin models */
1379  coeffs->d1 = coeffs->d1v2 = 0.0;
1380  coeffs->dheffSS = coeffs->dheffSSv2 = 0.0;
1381  switch (SpinAlignedEOBversion)
1382  {
1383  case 1:
1384  coeffs->d1 = -69.5;
1385  coeffs->dheffSS = 2.75;
1386  break;
1387  case 2:
1388  coeffs->d1v2 = -74.71 - 156. * eta + 627.5 * eta * eta;
1389  coeffs->dheffSSv2 = 8.127 - 154.2 * eta + 830.8 * eta * eta;
1390  break;
1391  case 4:
1392  // dSO
1393  coeffs->d1v2 =
1394  coeff00dSO + coeff01dSO * chi + coeff02dSO * chi2 + coeff03dSO * chi3 +
1395  coeff10dSO * eta + coeff11dSO * eta * chi + coeff12dSO * eta * chi2 +
1396  coeff13dSO * eta * chi3 + coeff20dSO * eta2 + coeff21dSO * eta2 * chi +
1397  coeff22dSO * eta2 * chi2 + coeff23dSO * eta2 * chi3 + coeff30dSO * eta3 +
1398  coeff31dSO * eta3 * chi + coeff32dSO * eta3 * chi2 + coeff33dSO * eta3 * chi3;
1399 
1400  // dSS
1401  coeffs->dheffSSv2 =
1402  coeff00dSS + coeff01dSS * chi + coeff02dSS * chi2 + coeff03dSS * chi3 +
1403  coeff10dSS * eta + coeff11dSS * eta * chi + coeff12dSS * eta * chi2 +
1404  coeff13dSS * eta * chi3 + coeff20dSS * eta2 + coeff21dSS * eta2 * chi +
1405  coeff22dSS * eta2 * chi2 + coeff23dSS * eta2 * chi3 + coeff30dSS * eta3 +
1406  coeff31dSS * eta3 * chi + coeff32dSS * eta3 * chi2 + coeff33dSS * eta3 * chi3;
1407 // printf("dSO %.16e, dSS %.16e\n", coeffs->d1v2,coeffs->dheffSSv2);
1408  break;
1409  default:
1411  ("XLAL Error - %s: wrong SpinAlignedEOBversion value, must be 1 or 2!\n",
1412  __func__);
1414  break;
1415  }
1416 
1417  return XLAL_SUCCESS;
1418 }
1419 
1420 
1421 /**
1422  * This function calculates the function \f$\Delta_t(r)\f$ which appears in the spinning EOB
1423  * potential function. Eqs. 7a and 8.
1424  */
1425 static REAL8
1427  /**<< Pre-computed coefficients which appear in the function */
1428  const REAL8 r,
1429  /**<< Current orbital radius (in units of total mass) */
1430  const REAL8 eta,
1431  /**<< Symmetric mass ratio */
1432  const REAL8 a
1433  /**<< Normalized deformed Kerr spin */
1434  )
1435 {
1436 
1437  REAL8 a2;
1438  REAL8 u, u2, u3, u4, u5;
1440 
1441  REAL8 bulk;
1442  REAL8 logTerms;
1443  REAL8 deltaU;
1444  REAL8 deltaT;
1445 
1446  u = 1. / r;
1447  u2 = u * u;
1448  u3 = u2 * u;
1449  u4 = u2 * u2;
1450  u5 = u4 * u;
1451 
1452  a2 = a * a;
1453 
1454  m1PlusetaKK = -1. + eta * coeffs->KK;
1455 
1456  bulk = 1. / (m1PlusetaKK * m1PlusetaKK) + (2. * u) / m1PlusetaKK + a2 * u2;
1457 
1458  logTerms =
1459  1. + eta * coeffs->k0 + eta * log (1. + coeffs->k1 * u + coeffs->k2 * u2 +
1460  coeffs->k3 * u3 + coeffs->k4 * u4 +
1461  coeffs->k5 * u5 +
1462  coeffs->k5l * u5 * log (u));
1463  /*printf(" a = %.16e, u = %.16e\n",a,u);
1464  printf( "k0 = %.16e, k1 = %.16e, k2 = %.16e, k3 = %.16e , k4 = %.16e, k5 = %.16e, k5l = %.16e\n",coeffs->k0,
1465  coeffs->k1,coeffs->k2,coeffs->k3,coeffs->k4,coeffs->k5,coeffs->k5l);
1466  printf( "bulk = %.16e, logTerms = %.16e\n", bulk, logTerms ); */
1467  deltaU = bulk * logTerms;
1468 
1469  if ( (coeffs->tidal1->lambda2Tidal != 0. && coeffs->tidal1->omega02Tidal != 0.) || (coeffs->tidal2->lambda2Tidal != 0. && coeffs->tidal2->omega02Tidal != 0.) ) {
1470  deltaU += XLALSimIMRTEOBdeltaUTidal(u, eta, coeffs->tidal1, coeffs->tidal2);
1471  }
1472 
1473  deltaT = r * r * deltaU;
1474 
1475 
1476  return deltaT;
1477 }
1478 
1479 
1480 /**
1481  * This function calculates the function \f$\Delta_r(r)\f$ which appears in the spinning EOB
1482  * potential function. Eqs. 10a and 10b
1483  */
1484 UNUSED static REAL8
1486  /**<< Pre-computed coefficients which appear in the function */
1487  const REAL8 r,
1488  /**<< Current orbital radius (in units of total mass) */
1489  const REAL8 eta,
1490  /**<< Symmetric mass ratio */
1491  const REAL8 a
1492  /**<< Normalized deformed Kerr spin */
1493  )
1494 {
1495 
1496 
1497  REAL8 u2, u3;
1498  REAL8 D;
1499  REAL8 deltaT; /* The potential function, not a time interval... */
1500  REAL8 deltaR;
1501 
1502  u2 = 1. / (r * r);
1503  u3 = u2 / r;
1504 
1505  D = 1. + log (1. + 6. * eta * u2 + 2. * (26. - 3. * eta) * eta * u3);
1506 
1507  deltaT = XLALSimIMRSpinEOBHamiltonianDeltaT (coeffs, r, eta, a);
1508 
1509  deltaR = deltaT * D;
1510  return deltaR;
1511 }
1512 
1513 /**
1514  * Function to calculate the value of omega for the spin-aligned EOB waveform.
1515  * Can NOT be used in precessing cases. This omega is defined as \f$\dot{y}/r\f$ by setting \f$y=0\f$.
1516  * The function calculates omega = v/r, by first converting (r,phi,pr,pphi) to Cartesian coordinates
1517  * in which rVec={r,0,0} and pVec={0,pphi/r,0}, i.e. the effective-test-particle is positioned at x=r,
1518  * and its velocity along y-axis. Then it computes omega, which is now given by dydt/r = (dH/dp_y)/r.
1519  */
1520 static REAL8
1521 XLALSimIMRSpinAlignedEOBCalcOmega (const REAL8 values[],/**<< Dynamical variables */
1522  SpinEOBParams * funcParams,
1523  /**<< EOB parameters */
1524  REAL8 STEP_SIZE /**<< Step size for numerical derivation of H */
1525  )
1526 {
1527 
1529 
1530  /* Cartesian values for calculating the Hamiltonian */
1531  REAL8 cartValues[6];
1532 
1533  gsl_function F;
1534  INT4 gslStatus;
1535 
1536  REAL8 omega;
1537  REAL8 r;
1538 
1539  /* The error in a derivative as measured by GSL */
1540  REAL8 absErr;
1541 
1542  /* Set up pointers for GSL */
1543  params.values = cartValues;
1544  params.params = funcParams;
1545 
1546  F.function = &GSLSpinAlignedHamiltonianWrapper;
1547  F.params = &params;
1548 
1549  /* Populate the Cartesian values vector */
1550  /* We can assume phi is zero wlog */
1551  memset (cartValues, 0, sizeof (cartValues));
1552  cartValues[0] = r = values[0];
1553  cartValues[3] = values[2];
1554  cartValues[4] = values[3] / values[0];
1555 
1556  /* Now calculate omega. In the chosen co-ordinate system, */
1557  /* we need dH/dpy to calculate this, i.e. varyParam = 4 */
1558  params.varyParam = 4;
1559  XLAL_CALLGSL (gslStatus = gsl_deriv_central (&F, cartValues[4],
1560  STEP_SIZE, &omega, &absErr));
1561 
1562  if (gslStatus != GSL_SUCCESS)
1563  {
1564  XLALPrintError ("XLAL Error - %s: Failure in GSL function\n", __func__);
1566  }
1567 
1568  omega = omega / r;
1569 
1570  return omega;
1571 }
1572 
1573 /**
1574  * Function to calculate the non-Keplerian coefficient for the spin-aligned EOB model.
1575  * radius \f$r\f$ times the cuberoot of the returned number is \f$r_\Omega\f$ defined in Eq. A2.
1576  * i.e. the function returns \f$(r_{\Omega} / r)^3\f$.
1577  */
1578 UNUSED static REAL8
1580  /**<< Dynamical variables */
1581  SpinEOBParams * funcParams
1582  /**<< EOB parameters */
1583  )
1584 {
1585  REAL8 STEP_SIZE = STEP_SIZE_CALCOMEGA;
1586 
1587  REAL8 omegaCirc;
1588 
1589  REAL8 tmpValues[4];
1590 
1591  REAL8 r3;
1592 
1593  /* We need to find the values of omega assuming pr = 0 */
1594  memcpy (tmpValues, values, sizeof (tmpValues));
1595  tmpValues[2] = 0.0;
1596 
1597  omegaCirc = XLALSimIMRSpinAlignedEOBCalcOmega (tmpValues, funcParams, STEP_SIZE);
1598  if (XLAL_IS_REAL8_FAIL_NAN (omegaCirc))
1599  {
1601  }
1602 
1603  r3 = values[0] * values[0] * values[0];
1604 
1605  return 1.0 / (omegaCirc * omegaCirc * r3);
1606 }
1607 
1608 
1609 
1610 /**
1611  * Function to calculate the non-Keplerian coefficient for the spin-aligned EOB model.
1612  * radius \f$r\f$ times the cuberoot of the returned number is \f$r_\Omega\f$ defined in Eq. A2.
1613  * i.e. the function returns \f$(r_{\Omega} / r)^3\f$.
1614  * This is the generic precessing version
1615  */
1616 static REAL8 UNUSED
1617 XLALSimIMRSpinEOBNonKeplerCoeff (const REAL8 values[], /**<< Dynamical variables */
1618  SpinEOBParams * funcParams
1619  /**<< EOB parameters */
1620  )
1621 {
1622 
1623  REAL8 STEP_SIZE = STEP_SIZE_CALCOMEGA;
1624 
1625  REAL8 omegaCirc;
1626 
1627  REAL8 tmpValues[4];
1628 
1629  REAL8 r3;
1630 
1631  /* We need to find the values of omega assuming pr = 0 */
1632  memcpy (tmpValues, values, sizeof (tmpValues));
1633  tmpValues[0] =
1634  sqrt (values[0] * values[0] + values[1] * values[1] +
1635  values[2] * values[2]);
1636  tmpValues[1] = 0.0;
1637  tmpValues[2] = 0.0;
1638  tmpValues[3] = sqrt ((values[0] * values[4] - values[1] * values[3])
1639  * (values[0] * values[4] - values[1] * values[3])
1640  + (values[2] * values[3] - values[0] * values[5])
1641  * (values[2] * values[3] - values[0] * values[5])
1642  + (values[1] * values[5] - values[2] * values[4])
1643  * (values[1] * values[5] - values[2] * values[4]));
1644 
1645  omegaCirc = XLALSimIMRSpinAlignedEOBCalcOmega (tmpValues, funcParams, STEP_SIZE);
1646  if (XLAL_IS_REAL8_FAIL_NAN (omegaCirc))
1647  {
1649  }
1650 
1651  r3 = tmpValues[0] * tmpValues[0] * tmpValues[0];
1652 
1653  return 1.0 / (omegaCirc * omegaCirc * r3);
1654 }
1655 
1656 
1657 
1658 /* Wrapper for GSL to call the Hamiltonian function */
1659 static double
1661 {
1662  HcapDerivParams *dParams = (HcapDerivParams *) params;
1663 
1664  EOBParams *eobParams = dParams->params->eobParams;
1665 
1666  REAL8 tmpVec[6];
1667 
1668  /* These are the vectors which will be used in the call to the Hamiltonian */
1669  REAL8Vector r, p;
1670  REAL8Vector *s1Vec = dParams->params->s1Vec;
1671  REAL8Vector *s2Vec = dParams->params->s2Vec;
1672  REAL8Vector *sigmaKerr = dParams->params->sigmaKerr;
1673  REAL8Vector *sigmaStar = dParams->params->sigmaStar;
1674 
1675  /* Use a temporary vector to avoid corrupting the main function */
1676  memcpy (tmpVec, dParams->values, sizeof (tmpVec));
1677 
1678  /* Set the relevant entry in the vector to the correct value */
1679  tmpVec[dParams->varyParam] = x;
1680 
1681  /* Set the LAL-style vectors to point to the appropriate things */
1682  r.length = p.length = 3;
1683  r.data = tmpVec;
1684  p.data = tmpVec + 3;
1685 
1686  return XLALSimIMRSpinEOBHamiltonian (eobParams->eta, &r, &p, s1Vec, s2Vec,
1687  sigmaKerr, sigmaStar,
1688  dParams->params->tortoise,
1689  dParams->params->seobCoeffs) /
1690  eobParams->eta;
1691 }
1692 
1693 #endif /*_LALSIMIMRSPINEOBHAMILTONIAN_C*/
const double c1
const double c2
const double c0
static double df_keffresonant_pert(REAL8 x)
static REAL8 XLALSimIMRTEOBdeltaUTidalOctuSingleNS_u(REAL8 u, REAL8 u2, REAL8 u8, REAL8 XNS, REAL8 XCompanion, REAL8 lambda3TidalNS, REAL8 k3TidalNSeff, REAL8 k3TidalNSeff_u)
Function to compute the u-derivative of the octupolar tidal contribution to the EOB Delta_u potential...
static const double f_data_b2[18]
static REAL8 XLALSimIMRTEOBdeltaUTidal_u(REAL8 u, REAL8 eta, TidalEOBParams *tidal1, TidalEOBParams *tidal2)
Function to compute the u-derivative of the tidal contribution to the EOB Delta_u potential.
static int XLALSimIMRCalculateSpinEOBHCoeffs(SpinEOBHCoeffs *coeffs, const REAL8 eta, const REAL8 a, const UINT4 SpinAlignedEOBversion)
This function is used to calculate some coefficients which will be used in the spinning EOB Hamiltoni...
static REAL8 XLALSimIMRTEOBdeltaUTidalOctuSingleNS(REAL8 u, REAL8 u2, REAL8 u8, REAL8 XNS, REAL8 XCompanion, REAL8 lambda3TidalNS, REAL8 k3TidalNSeff)
Function to compute the octupolar tidal contribution to the EOB Delta_u potential for just one NS.
static REAL8 XLALSimIMRSpinAlignedEOBCalcOmega(const REAL8 values[], SpinEOBParams *funcParams, REAL8 STEP_SIZE)
Function to calculate the value of omega for the spin-aligned EOB waveform.
static REAL8 UNUSED XLALSimIMRSpinEOBNonKeplerCoeff(const REAL8 values[], SpinEOBParams *funcParams)
Function to calculate the non-Keplerian coefficient for the spin-aligned EOB model.
static void fresnel_sincos_0_8(double x, double output[2])
static int XLALSimIMRTEOBkleff_and_kleff_u(INT4 l, REAL8 u, REAL8 eta, TidalEOBParams *tidal, REAL8 output[2])
Function to compute the enhancement of kltidal and its u-derivative due to the presence of f-mode res...
static const double pi_2
static REAL8 XLALSimIMRSpinEOBHamiltonianDeltaR(SpinEOBHCoeffs *coeffs, const REAL8 r, const REAL8 eta, const REAL8 a)
This function calculates the DeltaR potential function in the spin EOB Hamiltonian.
static REAL8 XLALSimIMRTEOBdeltaUTidalOctu(REAL8 u, REAL8 u2, REAL8 u8, REAL8 eta, TidalEOBParams *tidal1, TidalEOBParams *tidal2)
Function to compute the octupolar tidal contribution to the EOB Delta_u potential.
static const double df_keffresonant_pertdata[5]
static double df_keffresonant(double x, double x5_3)
static REAL8 XLALSimIMRSpinEOBHamiltonian(const REAL8 eta, REAL8Vector *restrict x, REAL8Vector *restrict p, REAL8Vector *restrict s1Vec, REAL8Vector *restrict s2Vec, REAL8Vector *restrict sigmaKerr, REAL8Vector *restrict sigmaStar, int tortoise, SpinEOBHCoeffs *coeffs)
static const double sqrt_2_pi
static REAL8 XLALSimIMRTEOBdeltaUTidal(REAL8 u, REAL8 eta, TidalEOBParams *tidal1, TidalEOBParams *tidal2)
Function to compute the tidal contribution to the EOB Delta_u potential.
static const double _1_sqrt_2pi
static double f_keffresonant_pert(REAL8 x)
static const double f_data_a[18]
static REAL8 XLALSimIMRTEOBdeltaUTidalQuad(REAL8 u, REAL8 u2, REAL8 u6, REAL8 eta, TidalEOBParams *tidal1, TidalEOBParams *tidal2)
Function to compute the quadrupolar tidal contribution to the EOB Delta_u potential.
static double f_keffresonant(double x, double x5_3)
Function to compute k2tidal, k3tidal: resonant terms f(x) with x=omega0l/(m*Omega) (with m=l here) is...
static void fresnel_sincos_8_inf(double x, double output[2])
static REAL8 XLALSimIMRTEOBkleff(INT4 l, REAL8 u, REAL8 eta, TidalEOBParams *tidal)
Function to compute the enhancement of kltidal due to the presence of f-mode resonance Implements (11...
static REAL8 XLALSimIMRTEOBdeltaUTidalQuad_u(REAL8 u, REAL8 u2, REAL8 u6, REAL8 eta, TidalEOBParams *tidal1, TidalEOBParams *tidal2)
Function to compute the u-derivative of the quadrupolar tidal contribution to the EOB Delta_u potenti...
static const double sqrt_pi_2
static REAL8 XLALSimIMRTEOBdeltaUTidalOctu_u(REAL8 u, REAL8 u2, REAL8 u8, REAL8 eta, TidalEOBParams *tidal1, TidalEOBParams *tidal2)
Function to compute the u-derivative of the octupolar tidal contribution to the EOB Delta_u potential...
static double GSLSpinAlignedHamiltonianWrapper(double x, void *params)
static void fresnel_sc(double x, double output[2])
static const REAL8 STEP_SIZE_CALCOMEGA
static const double f_keffresonant_pertdata[5]
static double f_data_e[41]
static REAL8 XLALSimIMRTEOBdeltaUTidalQuadSingleNS(REAL8 u, REAL8 u2, REAL8 u6, REAL8 XNS, REAL8 XCompanion, REAL8 lambda2TidalNS, REAL8 k2TidalNSeff)
Function to compute the quadrupolar tidal contribution to the EOB Delta_u potential for just one NS.
static REAL8 XLALSimIMRTEOBdeltaUTidalQuadSingleNS_u(REAL8 u, REAL8 u2, REAL8 u6, REAL8 XNS, REAL8 XCompanion, REAL8 lambda2TidalNS, REAL8 k2TidalNSeff, REAL8 k2TidalNSeff_u)
Function to compute the u-derivative of the quadrupolar tidal contribution to the EOB Delta_u potenti...
static double f_data_f[35]
static REAL8 XLALSimIMRTEOBdeltaHssQuadMonLO(const REAL8 eta, REAL8 u, REAL8Vector *restrict s1Vec, REAL8Vector *restrict s2Vec, REAL8 nx, REAL8 ny, REAL8 nz, TidalEOBParams *tidal1, TidalEOBParams *tidal2)
Function to compute the leading-order 2PN spin-induced quadrupole contribution to Heff/mu consistentl...
static REAL8 XLALSimIMRSpinEOBHamiltonianDeltaT(SpinEOBHCoeffs *coeffs, const REAL8 r, const REAL8 eta, const REAL8 a)
This function calculates the function which appears in the spinning EOB potential function.
static REAL8 XLALSimIMRSpinAlignedEOBNonKeplerCoeff(const REAL8 values[], SpinEOBParams *funcParams)
Function to calculate the non-Keplerian coefficient for the spin-aligned EOB model.
static const REAL8 coeff12dSO
static const REAL8 coeff00dSO
static const REAL8 coeff02K
static const REAL8 coeff21dSO
static const REAL8 coeff12dSS
static const REAL8 coeff31dSS
static const REAL8 coeff20K
static const REAL8 coeff31dSO
static const REAL8 coeff32dSS
static const REAL8 coeff23K
static const REAL8 coeff33K
static const REAL8 coeff32K
static const REAL8 coeff11dSS
static const REAL8 coeff11dSO
static const REAL8 coeff21K
static const REAL8 coeff10dSO
static const REAL8 coeff31K
static const REAL8 coeff23dSO
static const REAL8 coeff10dSS
static const REAL8 coeff01K
static const REAL8 coeff02dSS
static const REAL8 coeff13dSS
static const REAL8 coeff10K
static const REAL8 coeff20dSS
static const REAL8 coeff30dSS
static const REAL8 coeff11K
static const REAL8 coeff03K
static const REAL8 coeff22K
static const REAL8 coeff23dSS
static const REAL8 coeff20dSO
static const REAL8 coeff03dSS
static const REAL8 coeff22dSO
static const REAL8 coeff32dSO
static const REAL8 coeff33dSS
static const REAL8 coeff33dSO
static const REAL8 coeff01dSS
static const REAL8 coeff02dSO
static const REAL8 coeff03dSO
static const REAL8 coeff21dSS
static const REAL8 coeff13K
static const REAL8 coeff22dSS
static const REAL8 coeff00K
static const REAL8 coeff00dSS
static const REAL8 coeff01dSO
static const REAL8 coeff12K
static const REAL8 coeff30K
static const REAL8 coeff30dSO
static const REAL8 coeff13dSO
REAL8 Hreal
#define XLAL_CALLGSL(statement)
int l
Definition: bh_qnmode.c:135
double i
Definition: bh_ringdown.c:118
double e
Definition: bh_ringdown.c:117
const double pn2
const double sx
const double pp
const double Hns
const double pvr
const double sMultiplier1
const double sxi
const double prT
const double Hss
const double sz
const double Hs
const double Q
const double HSONL
const double pn
const double sy
const double Hwr
const double sv
const double pxir
const double HSOL
const double H
const double pr
const double pf
const double s3
const double sMultiplier2
const double sn
const double Hwcos
const double ptheta2
const double ww
const double deltaU
const double nur
const double mucos
const double deltaR
const double u
const double w2
const double u3
const double bulk
const double wr
const double r2
const double ny
const double nucos
const double vy
const double wcos
const double BR
const double u5
const double qq
const double a2
const double xi2
const double w
const double m1PlusetaKK
const double rho2
const double u2
const double vz
const double u4
const double mur
const double csi
const double Lambda
const double costheta
const double nz
const double B
const double vx
const double nx
const double logTerms
#define LAL_PI
#define LAL_GAMMA
double REAL8
uint32_t UINT4
int32_t INT4
static const INT4 r
static const INT4 m
static const INT4 a
#define XLAL_ERROR_REAL8(...)
#define XLAL_ERROR(...)
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
#define XLAL_IS_REAL8_FAIL_NAN(val)
XLAL_SUCCESS
XLAL_EFUNC
XLAL_EINVAL
list x
list p
Structure containing all the parameters needed for the EOB waveform.
const REAL8 * values
SpinEOBParams * params
Parameters for the spinning EOB model, used in calculating the Hamiltonian.
UINT4 SpinAlignedEOBversion
TidalEOBParams * tidal1
TidalEOBParams * tidal2
Parameters for the spinning EOB model.
SpinEOBHCoeffs * seobCoeffs
REAL8Vector * sigmaStar
REAL8Vector * s1Vec
EOBParams * eobParams
REAL8Vector * sigmaKerr
REAL8Vector * s2Vec
Tidal parameters for EOB model of NS: mByM - dimensionless ratio m_{NS}/M lambda2Tidal - dimensionles...
Definition: burst.c:245
LALDict * params
Definition: inspiral.c:248
char output[FILENAME_MAX]
Definition: unicorn.c:26
double deltaT
Definition: unicorn.c:24