LALSimulation  5.4.0.1-fe68b98
LALSimInspiralFDPrecAngles_internals.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Katerina Chatziioannou, Sebastian Khan
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with with program; see the file COPYING. If not, write to the
16  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17  * MA 02110-1301 USA
18  */
19 
20 #include "LALSimIMRPhenomInternalUtils.h" //for UNUSED attribute
22 
23 
24 /**
25  * InitializeSystem computes all the prefactors needed to generate precession angles
26  * from Chatziioannou et al., arXiv 1703.03967 [gr-qc]
27  */
28 UNUSED static int InitializeSystem(sysq* system, /**< [out] Pointer to sysq struct */
29  const double m1, /**< Primary mass in SI (kg) */
30  const double m2, /**< Secondary mass in SI (kg) */
31  const double mul, /**< Cosine of Polar angle of orbital angular momentum */
32  const double phl, /**< Azimuthal angle of orbital angular momentum */
33  const double mu1, /**< Cosine of Polar angle of primary spin w.r.t. orbital angular momentum */
34  const double ph1, /**< Azimuthal angle of primary spin */
35  const double ch1, /**< Dimensionless spin magnitude of primary spin */
36  const double mu2, /**< Cosine of Polar angle of secondary spin w.r.t. orbital angular momentum */
37  const double ph2, /**< Azimuthal angle of secondary spin */
38  const double ch2, /**< Dimensionless spin magnitude of secondary spin */
39  const double f_0, /**< Reference Gravitational Wave frequency (Hz) */
40  const int ExpansionOrder /**< Keep terms upto ExpansionOrder in precession angles phi_z and zeta (1,2,3,4,5 or -1 for all orders) */
41  )
42 {
43  memset(system, 0, sizeof(sysq));
44 
45  system->onethird = 1./3.;
46 
47  const double domegadt_csts_nonspin[17] = {96./5.,-1486./35.,-264./5.,384.*LAL_PI/5.,34103./945.,13661./105.,944./15.,LAL_PI*(-4159./35.),LAL_PI*(-2268./5.),(16447322263./7276500. + LAL_PI*LAL_PI*512./5. - LAL_LN2*109568./175. -LAL_GAMMA*54784./175.),(-56198689./11340. + LAL_PI*LAL_PI*902./5.),1623./140.,-1121./27.,-54784./525.,-LAL_PI*883./42.,LAL_PI*71735./63.,LAL_PI*73196./63.};
48  const double domegadt_csts_spinorbit[18] = {-904./5.,-120.,-62638./105.,4636./5.,-6472./35.,3372./5.,-LAL_PI*720.,-LAL_PI*2416./5.,-208520./63.,796069./105.,-100019./45.,-1195759./945.,514046./105.,-8709./5.,-LAL_PI*307708./105.,LAL_PI*44011./7.,-LAL_PI*7992./7.,LAL_PI*151449./35.};
49  const double domegadt_csts_spinspin[4] = {-494./5.,-1442./5.,-233./5.,-719./5.};
50  const double L_csts_nonspin[9] = {3./2.,1./6.,27./8.,-19./8.,1./24.,135./16.,-6889/144.+ 41./24.*LAL_PI*LAL_PI,31./24.,7./1296.};
51  const double L_csts_spinorbit[6] = {-14./6.,-3./2.,-11./2.,133./72.,-33./8.,7./4.};
52 
53  const double G_over_c = LAL_G_SI/LAL_C_SI;
54  const double M = m1 + m2;
55  system->q = m2/m1;
56  const double q = system->q;
57  system->nu = q/(1+q)/(1+q);
58  const double nu = system->nu;
59  system->nu_2 = nu*nu;
60  const double nu_2 = system->nu_2;
61  const double piGM_over_cthree = LAL_PI*G_over_c/LAL_C_SI/LAL_C_SI*(m1+m2);
62  system->deltam_over_M = (1-q)/(1+q);
63  const double deltam_over_M = system->deltam_over_M;
64 
65  const double S1_norm = fabs(ch1)*nu/q;//in geometric units and with M=1
66  const double S2_norm = fabs(ch2)*nu*q;
67 
68  const double xi_0 = pow(piGM_over_cthree*f_0, system->onethird);
69  const double xi0_2 = xi_0*xi_0;
70  const vector Lhat_0 = CreateSphere(1.,acos(mul),phl);
71  const vector S1_0 = CreateSphere(S1_norm,acos(mu1),ph1);//in geometric units and with M=1
72  const vector S2_0 = CreateSphere(S2_norm,acos(mu2),ph2);
73  const vector L_0 = ScalarProd(nu/xi_0,Lhat_0);
74 
75  system->dot1 = DotProd(S1_0,Lhat_0);
76  system->dot2 = DotProd(S2_0,Lhat_0);
77  system->dot1n = DotProd(S1_0,Lhat_0)/S1_norm;
78  system->dot2n = DotProd(S2_0,Lhat_0)/S2_norm;
79  system->dot12 = DotProd(S1_0,S2_0);
80 
81  //eq.7 (1703.03967)
82  system->Seff = ((system->dot1)/m1 +(system->dot2)/m2)*M;
83 
84  const vector S_0 = Sum(S1_0,S2_0);
85  const vector J_0 = Sum(L_0,S_0);
86 
87  const double S_0_norm = Norm(S_0);
88  const double J_0_norm = Norm(J_0);
89  const double L_0_norm = Norm(L_0);
90  system->S1_norm_2 = S1_norm*S1_norm;
91  system->S2_norm_2 = S2_norm*S2_norm;
92  system->S0_norm = S_0_norm;
93 
94  const vector roots = Roots(L_0_norm,J_0_norm,system);
95 
96  const double q_2 = q*q;
97  const double one_m_q_sq = (1.-q)*(1.-q);
98  const double one_m_q_4 = one_m_q_sq*one_m_q_sq;
99  const double one_p_q_sq = (1.+q)*(1.+q);
100 
101  const double Save_square = 0.5*(roots.z+roots.y);
102  const double S1_norm_2 = system->S1_norm_2;
103  const double S2_norm_2 = system->S2_norm_2;
104  const double Seff = system->Seff;
105  const double Seff_2 = Seff*Seff;
106 
107  //computed with initial spin couplings, they're not exactly accurate for generic precession, but the correction should be 4PN
108  //these constants are used in TaylorT1 where domega/dt is expressed as a polynomial
109  const double a0 = nu*domegadt_csts_nonspin[0];
110  const double a2 = nu*(domegadt_csts_nonspin[1] + nu*(domegadt_csts_nonspin[2]));
111  const double a3 = nu*(domegadt_csts_nonspin[3] + beta(domegadt_csts_spinorbit[0], domegadt_csts_spinorbit[1], system));
112  const double a4 = nu*(domegadt_csts_nonspin[4] + nu*(domegadt_csts_nonspin[5] + nu*(domegadt_csts_nonspin[6])) + sigma(domegadt_csts_spinspin[0], domegadt_csts_spinspin[1], system) + tau(domegadt_csts_spinspin[2], domegadt_csts_spinspin[3], system));
113  const double a5 = nu*(domegadt_csts_nonspin[7] + nu*(domegadt_csts_nonspin[8]) + beta((domegadt_csts_spinorbit[2] + nu*(domegadt_csts_spinorbit[3])), (domegadt_csts_spinorbit[4] + nu*(domegadt_csts_spinorbit[5])), system));
114 
115  const double a0_2 = a0*a0;
116  const double a0_3 = a0_2*a0;
117  const double a2_2 = a2*a2;
118 
119  //these constants are used in TaylorT2 where domega/dt is expressed as an inverse polynomial
120  //eq.A1 (1703.03967)
121  const double c0 = 1./a0;
122  //eq.A2 (1703.03967)
123  const double c2 = -a2/a0_2;
124  //eq.A3 (1703.03967)
125  const double c3 = -a3/a0_2;
126  //eq.A4 (1703.03967)
127  const double c4 = (a2_2 - a0*a4)/a0_3;
128  //eq.A5 (1703.03967)
129  const double c5 = (2.*a2*a3 - a0*a5)/a0_3;
130 
131  system->nu_4 = nu_2*nu_2;
132  const double nu_4 = system->nu_4;
133 
134  //eq.41 (1703.03967)
135  system->c_1 =0.5*(J_0_norm*J_0_norm - L_0_norm*L_0_norm - Save_square)/L_0_norm*nu;
136  double c_1 = system->c_1;
137  system->c_1_over_nu = system->c_1/nu;
138  double c_1_over_nu = system->c_1_over_nu;
139  system->c1_2 = c_1*c_1;
140  double c1_2 = system->c1_2;
141  double c1_over_nu_2 = c_1_over_nu*c_1_over_nu;
142 
143  const double one_m_q2_2 = (1. - q_2) * (1. - q_2);
144 
145  //eq.C3 (1703.03967) - note this is actually 2*\Delta
146  const double Del1 = 4. * c1_over_nu_2 * one_p_q_sq;
147  const double Del2 = 8. * c_1_over_nu * q * (1. + q) * Seff;
148  const double Del3 = 4. * (one_m_q2_2 * S1_norm_2 - q_2 * Seff_2);
149  const double Del4 = 4. * c1_over_nu_2 * q_2 * one_p_q_sq;
150  const double Del5 = 8. * c_1_over_nu * q_2 * (1. + q) * Seff;
151  const double Del6 = 4. * (one_m_q2_2 * S2_norm_2 - q_2 * Seff_2);
152  const double Delta = sqrt((Del1 - Del2 - Del3) * (Del4 - Del5 - Del6));
153 
154  //this is g_0 in eq.51 (1703.03967)
155  system->constants_u[0] = -c0;
156  //eq.C1 (1703.03967)
157  system->constants_u[1] = (6.*Seff*nu - 3.*c_1_over_nu)/deltam_over_M/deltam_over_M;
158 
159 
160  const double u1 = 3. * c2 / c0;
161  const double u2 = 0.75 * one_p_q_sq / one_m_q_4;
162  const double u3 = -20. * c1_over_nu_2 * q_2 * one_p_q_sq;
163  const double u4 = 2. * one_m_q2_2 * (q * (2. + q) * S1_norm_2 + (1. + 2. * q) * S2_norm_2 - 2. * q * Save_square);
164  const double u5 = 2. * q_2 * (7. + 6. * q + 7. * q_2) * 2. * c_1_over_nu * Seff;
165  const double u6 = 2. * q_2 * (3. + 4. * q + 3. * q_2) * Seff_2;
166  const double u7 = q * Delta;
167  //eq.C2 (1703.03967)
168  system->constants_u[2] = u1 + u2*(u3 + u4 + u5 - u6 + u7);
169 
170  //eq.45 (1703.03967)
171  system->Ssqave = 0.5*(roots.z+roots.y);
172  system->sqrtSsqave = sqrt(system->Ssqave);
173 
174  //eq.D1 (1703.03967)
175  const double Rm = roots.z - roots.y;
176  const double Rm_2 = Rm*Rm;
177  //eq.D2 (1703.03967)
178  const double cp = roots.z*nu_2 - c1_2;
179  //eq.D3 (1703.03967)
180  const double cm = cp-Rm*nu_2;
181  //difference of spin norm squared used in eq.D6 (1703.03967)
182  const double S0m = S1_norm_2 - S2_norm_2;
183  const double cpcm = fabs(cp*cm);
184  const double sqrt_cpcm = sqrt(cpcm);
185 
186  //eq.D4 (1703.03967)
187  const double A1t = 0.5+0.75/nu;//xi^6
188  //eq.D5 (1703.03967)
189  const double A2t = -0.75*Seff/nu;//xi^7
190  //eq.E3, called $D_2$ in paper (1703.03967)
191  const double A1ave = (cp-sqrt_cpcm)/nu_2 ;
192  //eq.E4, called $D_4$ in paper (1703.03967)
193  const double Bave = -0.5*Rm*sqrt_cpcm/nu_2 - cp/nu_4*(sqrt_cpcm-cp);
194 
195  const double aw = (-3.*(1. + q)/q*(2.*(1. + q)*nu_2*Seff*c_1 - (1. + q)*c1_2 + (1. - q)*nu_2*S0m));
196  const double cw = 3./32./nu*Rm_2;
197  const double dw = 4.*cp - 4.*A1ave*nu_2;
198  const double hw = -2*(2*A1ave - Rm)*c_1;
199  const double fw = Rm*A1ave-Bave-0.25*Rm_2;
200 
201  //eq.D6 (1703.03967)
202  const double ad = aw/dw;
203  //eq.XX (1703.03967)
204  const double hd = hw/dw;
205  //eq.D7 (1703.03967)
206  const double cd = cw/dw;
207  //eq.XX (1703.03967)
208  const double fd = fw/dw;
209 
210  const double hd_2 = hd*hd;
211  const double hd_4 = hd_2*hd_2;
212  const double adfd = ad*fd;
213  const double adfdhd = adfd*hd;
214  const double adfdhd_2 = adfd*hd_2;
215  const double adhd = ad*hd;
216  const double adhd_2 = ad*hd_2;
217  const double adhd_3 = ad*hd_2*hd;
218  const double adhd_4 = ad*hd_4;
219  const double cdfd = cd*fd;
220  const double cdhd = cd*hd;
221  const double cdhd_2 = cd*hd_2;
222 
223  //eq.D10 (1703.03967)
224  double Omegaz0 = A1t + ad;
225  //eq.D11 (1703.03967)
226  double Omegaz1 = A2t - ad*Seff - adhd;
227  //eq.D12 (1703.03967)
228  double Omegaz2 = cd - adfd + adhd_2 + adhd*Seff;
229  //eq.D13 (1703.03967)
230  double Omegaz3 = (adfd - cd - adhd_2)*Seff + 2*adfdhd - adhd_3 - cdhd;
231  //eq.D14 (1703.03967)
232  double Omegaz4 = -(2*adfdhd - adhd_3 - cdhd)*Seff + adfd*fd - cdfd + cdhd_2 - 3*adfdhd_2 + adhd_4;
233  //eq.D15 (1703.03967)
234  double Omegaz5 = -(adfd*fd - cdfd + cdhd_2 - 3*adfdhd_2 + adhd_4)*Seff + hd*(2*cdfd - 3*adfd*fd - cdhd_2 + 4*adfdhd_2 - adhd_4);
235 
236 
237  /* We check the size of the Omegaz5 coefficient to try and catch
238  cases where we think the precession model is breaking down */
239  XLAL_CHECK(
240  Omegaz5 < 1000.0, XLAL_EDOM,
241  "Omegaz5 = %.16f which is larger than expected. Not generating a waveform here.\n",
242  Omegaz5);
243 
244  //eq.D16 (1703.03967), note that "c0" in the code is "$g_0$" in the paper and likewise for the other "c's" and "g's"
245  system->constants_phiz[0] = 3.*Omegaz0*c0;
246  //eq.D17 (1703.03967)
247  system->constants_phiz[1] = 3.*Omegaz1*c0;
248  //eq.D18 (1703.03967)
249  system->constants_phiz[2] = 3.*(Omegaz2*c0 + Omegaz0*c2);
250  //eq.D19 (1703.03967)
251  system->constants_phiz[3] = 3.*(Omegaz0*c3 + Omegaz1*c2 + Omegaz3*c0);
252  //eq.D20 (1703.03967)
253  system->constants_phiz[4] = 3.*(Omegaz0*c4 + Omegaz1*c3 + Omegaz2*c2 + Omegaz4*c0);
254  //eq.D21 (1703.03967)
255  system->constants_phiz[5] = 3.*(c5*Omegaz0 + c4*Omegaz1 + c3*Omegaz2 + c2*Omegaz3 + c0*Omegaz5);
256 
257  const double gw = 3./16./nu_2/nu*Rm_2*(c_1 - nu_2*Seff);
258  //eq.F18 (1703.03967)
259  const double gd = gw/dw;
260 
261  //eq.F17 (1703.03967)
262  Omegaz5 += Omegaz4*c_1/nu_2 - fd*gd + gd*hd_2 + gd*hd*Seff;
263  //eq.F16 (1703.03967)
264  Omegaz4 += Omegaz3*c_1/nu_2 - gd*hd - gd*Seff;
265  //eq.F15 (1703.03967)
266  Omegaz3 += Omegaz2*c_1/nu_2 + gd;
267  //eq.F14 (1703.03967)
268  Omegaz2 += Omegaz1*c_1/nu_2;
269  //eq.F13 (1703.03967)
270  Omegaz1 += Omegaz0*c_1/nu_2;
271 
272  //eq.F12 (1703.03967)
273  system->constants_zeta[0] = 3.*Omegaz0*c0;
274  //eq.F13 (1703.03967)
275  system->constants_zeta[1] = 3.*Omegaz1*c0;
276  //eq.F14 (1703.03967)
277  system->constants_zeta[2] = 3.*(Omegaz2*c0 + Omegaz0*c2);
278  //eq.F15 (1703.03967)
279  system->constants_zeta[3] = 3.*(Omegaz0*c3 + Omegaz1*c2 + Omegaz3*c0);
280  //eq.F16 (1703.03967)
281  system->constants_zeta[4] = 3.*(Omegaz0*c4 + Omegaz1*c3 + Omegaz2*c2 + Omegaz4*c0);
282  //eq.F17 (1703.03967)
283  system->constants_zeta[5] = 3.*(Omegaz0*c5 + Omegaz1*c4 + Omegaz2*c3 + Omegaz3*c2 + Omegaz5*c0);
284 
285  switch (ExpansionOrder)
286  {
287  case -1:
288  /* default case, generate all orders.s */
289  break;
290  case 1:
291  /* Only keep 1st order term, i.e. only keep system->constants_phiz[0] and system->constants_zeta[0] */
292  system->constants_phiz[1] *= 0.;
293  system->constants_zeta[1] *= 0.;
294 #if __GNUC__ >= 7 && !defined __INTEL_COMPILER
295  __attribute__ ((fallthrough));
296 #endif
297  case 2:
298  system->constants_phiz[2] *= 0.;
299  system->constants_zeta[2] *= 0.;
300 #if __GNUC__ >= 7 && !defined __INTEL_COMPILER
301  __attribute__ ((fallthrough));
302 #endif
303  case 3:
304  system->constants_phiz[3] *= 0.;
305  system->constants_zeta[3] *= 0.;
306 #if __GNUC__ >= 7 && !defined __INTEL_COMPILER
307  __attribute__ ((fallthrough));
308 #endif
309  case 4:
310  system->constants_phiz[4] *= 0.;
311  system->constants_zeta[4] *= 0.;
312 #if __GNUC__ >= 7 && !defined __INTEL_COMPILER
313  __attribute__ ((fallthrough));
314 #endif
315  case 5:
316  system->constants_phiz[5] *= 0.;
317  system->constants_zeta[5] *= 0.;
318  break;
319  default:
320  XLAL_ERROR(XLAL_EDOM, "ExpansionOrder = %i not recognised. \
321 Defaulting to keeping all orders in expansion. \
322 In future please choose from [1,2,3,4,5,-1]. \n", ExpansionOrder);
323  }
324 
325  double m, B, volumeellement;
326  int sign_num;
327 
328  // I think 'constant_of_S' is the "$\psi_0$" term in equation 51 (1703.03967)
329  if(fabs(roots.y-roots.z)<1.e-5) system->constant_of_S = 0;
330  else{
331  m = sqrt((roots.y - roots.z)/(roots.x - roots.z));
332  B = (S_0_norm*S_0_norm-roots.z)/(roots.y-roots.z);
333  volumeellement = DotProd(CrossProd(L_0,S1_0),S2_0);
334  sign_num = (volumeellement > 0) - (volumeellement < 0);
335 
336  if(B < 0. || B > 1.) {
337  if(B > 1 && B-1. < 0.00001) system->constant_of_S = gsl_sf_ellint_F(asin(sign_num*sqrt(1.)), m, GSL_PREC_DOUBLE) - u_of_xi(xi_0,xi0_2,system);
338  if(B < 0 && B > -0.00001) system->constant_of_S = gsl_sf_ellint_F(asin(sign_num*sqrt(0.)), m, GSL_PREC_DOUBLE) - u_of_xi(xi_0,xi0_2,system);
339  }
340  else system->constant_of_S = gsl_sf_ellint_F(asin(sign_num*sqrt(B)), m, GSL_PREC_DOUBLE) - u_of_xi(xi_0,xi0_2,system);
341  }
342 
343  system->constants_L[0] = (L_csts_nonspin[0] + nu*L_csts_nonspin[1]);
344  system->constants_L[1] = beta(L_csts_spinorbit[0], L_csts_spinorbit[1], system);
345  system->constants_L[2] = (L_csts_nonspin[2] + nu*L_csts_nonspin[3] + nu*nu*L_csts_nonspin[4]);
346  system->constants_L[3] = beta((L_csts_spinorbit[2]+L_csts_spinorbit[3]*nu), (L_csts_spinorbit[4]+L_csts_spinorbit[5]*nu), system);
347  system->constants_L[4] = (L_csts_nonspin[5]+L_csts_nonspin[6]*nu +L_csts_nonspin[7]*nu*nu+L_csts_nonspin[8]*nu*nu*nu);
348 
349  vector MScorrections = {0.,0.,0.};
350  if(fabs(roots.y-roots.z)>1.e-5){
351  MScorrections = computeMScorrections(xi_0,xi0_2,L_0_norm,J_0_norm,roots,system);
352  }
353 
354  system->phiz_0 = 0.;
355  system->phiz_0 = - phiz_of_xi(xi_0,xi0_2,J_0_norm,system) - MScorrections.x;
356  system->zeta_0 = 0.;
357  system->zeta_0 = - zeta_of_xi(xi_0,xi0_2,system) - MScorrections.y;
358 
359  return XLAL_SUCCESS;
360 }
361 
362 /**
363  * Internal function that computes phiz, zeta, and costhetaL at 3PN
364  */
365 UNUSED static vector compute_phiz_zeta_costhetaL3PN(const double xi, const sysq *system)
366 {
367  vector angles;
368  const double xi_2 = xi*xi;
369  const double L_norm = ((*system).nu)/xi;
370  const double L_norm3PN = L_norm_3PN_of_xi(xi,xi_2,L_norm,system);
371  const double J_norm3PN = J_norm_of_xi(L_norm3PN,system);
372  const double J_norm = J_norm_of_xi(L_norm,system);
373  const vector roots = Roots(L_norm,J_norm,system);
374  const double S_norm = S_norm_of_xi(xi,xi_2,roots,system);
375 
376  vector MScorrections = {0.,0.,0.};
377  if(fabs(roots.y-roots.z)>1.e-5){
378  MScorrections = computeMScorrections(xi,xi_2,L_norm,J_norm,roots,system);
379  }
380 
381  angles.x = phiz_of_xi(xi,xi_2,J_norm,system) + MScorrections.x;
382  angles.y = zeta_of_xi(xi,xi_2,system) + MScorrections.y;
383  angles.z = costhetaL(J_norm3PN,L_norm3PN,S_norm);//costhetaL 3PN
384 
385  return angles;
386 }
387 
388 /**
389  * Internal function that computes phiz, zeta, and costhetaL at 2PN NonSpinning
390  */
391 UNUSED static vector compute_phiz_zeta_costhetaL2PNNonSpinning(const double xi, const sysq *system)
392 {
393  vector angles;
394  const double xi_2 = xi * xi;
395  const double L_norm = ((*system).nu) / xi;
396  const double L_norm2PN = L_norm_2PN_NonSpinning_of_xi(xi_2, L_norm, system);
397  const double J_norm2PN = J_norm_of_xi(L_norm2PN, system);
398  const double J_norm = J_norm_of_xi(L_norm, system);
399  const vector roots = Roots(L_norm, J_norm, system);
400  const double S_norm = S_norm_of_xi(xi, xi_2, roots, system);
401 
402  vector MScorrections = {0., 0., 0.};
403  if (fabs(roots.y - roots.z) > 1.e-5)
404  {
405  MScorrections = computeMScorrections(xi, xi_2, L_norm, J_norm, roots, system);
406  }
407 
408  angles.x = phiz_of_xi(xi, xi_2, J_norm, system) + MScorrections.x;
409  angles.y = zeta_of_xi(xi, xi_2, system) + MScorrections.y;
410  angles.z = costhetaL(J_norm2PN, L_norm2PN, S_norm); //costhetaL 3PN
411 
412  return angles;
413 }
414 
415 /**
416  * Internal function that computes phiz, zeta, and costhetaL at Newtonian order
417  */
418 UNUSED static vector compute_phiz_zeta_costhetaL(const double xi, const sysq *system)
419 {
420  vector angles;
421  const double xi_2 = xi*xi;
422  const double L_norm = ((*system).nu)/xi;
423  const double J_norm = J_norm_of_xi(L_norm,system);
424  const vector roots = Roots(L_norm,J_norm,system);
425  const double S_norm = S_norm_of_xi(xi,xi_2,roots,system);
426 
427  vector MScorrections = {0.,0.,0.};
428  if(fabs(roots.y-roots.z)>1.e-5){
429  MScorrections = computeMScorrections(xi,xi_2,L_norm,J_norm,roots,system);
430  }
431 
432  angles.x = phiz_of_xi(xi,xi_2,J_norm,system) + MScorrections.x;
433  angles.y = zeta_of_xi(xi,xi_2,system) + MScorrections.y;
434  angles.z = costhetaL(J_norm,L_norm,S_norm);//costhetaL Newtonian
435 
436  return angles;
437 }
438 
439 /**
440  * Internal function that computes the roots of Eq. 22 in arxiv:1703.03967
441  * out.x = A1 = S_{3}^2
442  * out.y = A2 = S_{-}^2
443  * out.z = A3 = S_{+}^2
444  */
445 static vector Roots(const double L_norm, const double J_norm, const sysq *system)
446 {
447  vector out;
448  vector coeffs = BCDcoeff(L_norm, J_norm, system);
449  double A1, A2, A3;
450  const double B_2 = coeffs.x*coeffs.x;
451  const double B_3 = B_2*coeffs.x;
452  const double B_C = coeffs.x*coeffs.y;
453 
454  const double p = coeffs.y - ((*system).onethird)*B_2;
455  const double qc = 2./27.*B_3 - ((*system).onethird)*B_C + coeffs.z;
456  const double sqrtarg = sqrt(-p/3.);
457  double acosarg = 1.5*qc/p/sqrtarg;
458  if(acosarg < -1) acosarg = -1;
459  if(acosarg > 1) acosarg = 1;
460  const double theta = ((*system).onethird)*acos(acosarg);
461 
462 
463  /* Case when the total spin is constant */
464  /* when spin1 or spin2 is zero then the norm and the total spin is constant. But there is still precession. */
465  if(theta!=theta || sqrtarg!=sqrtarg || (*system).dot1n == 1 || (*system).dot2n == 1 || (*system).dot1n == -1 || (*system).dot2n == -1|| (*system).S1_norm_2 == 0 || (*system).S2_norm_2 == 0) {
466  out.x = 0;
467  out.y = ((*system).S0_norm)*((*system).S0_norm);
468  out.z = out.y + 1e-9;
469  /* The 1e-9 is a nudge because sometimes the azimuthal
470  * precession angle has a term that makes it -inf.
471  * This small perturbation was to remedy these cases. */
472  }
473  else{
474  out.z = 2.*sqrtarg*cos(theta) - ((*system).onethird)*coeffs.x;
475  out.y = 2.*sqrtarg*cos(theta - LAL_TWOPI*((*system).onethird)) - ((*system).onethird)*coeffs.x;
476  out.x = 2.*sqrtarg*cos(theta - 2.*LAL_TWOPI*((*system).onethird)) - ((*system).onethird)*coeffs.x;
477 
478  A3 = fmax(fmax(out.x,out.y),out.z);
479  A1 = fmin(fmin(out.x,out.y),out.z);
480 
481  if ((A3 - out.z) > 0 && (A1 - out.z) < 0)
482  A2 = out.z;
483  else if ((A3 - out.x) > 0 && (A1 - out.x) < 0)
484  A2 = out.x;
485  else
486  A2 = out.y;
487 
488  out.x = A1;
489  out.y = A2;
490  out.z = A3;
491 
492  }
493  return out;
494 }
495 
496 /**
497  * Internal function that computes the B,C,D coefficients of Eq. 21 in arxiv:1703.03967
498  * The expressions are given in Appendix B.
499  * B coefficient = eq. B2
500  * C coefficient = eq. B3
501  * D coefficient = eq. B4
502  */
503 static vector BCDcoeff(const double L_norm, const double J_norm, const sysq *system)
504 {
505  vector out;
506  const double J_norm_2 = J_norm*J_norm;
507  const double L_norm_2 = L_norm*L_norm;
508 
509  out.x = (L_norm_2+((*system).S1_norm_2))*((*system).q) + (L_norm_2+((*system).S2_norm_2))/((*system).q) + 2.*L_norm*((*system).Seff) - 2.*J_norm_2 - ((*system).S1_norm_2) - ((*system).S2_norm_2);
510 
511  out.y = (L_norm_2 - J_norm_2)*(L_norm_2 - J_norm_2) + 2.*((*system).Seff)*L_norm*(L_norm_2 - J_norm_2) - 2.*L_norm_2*(((*system).S1_norm_2) - ((*system).S2_norm_2)*((*system).q))*(1./((*system).q)-1) + 4.*((*system).nu)*((*system).Seff)*((*system).Seff)*L_norm_2 - 2.*((*system).Seff)*L_norm*(((*system).S1_norm_2)-((*system).S2_norm_2))*((*system).deltam_over_M) + 2.*J_norm_2*(((*system).S1_norm_2)*((*system).q) - ((*system).S2_norm_2))*(1./((*system).q)-1);
512 
513  out.z = -(L_norm_2 - J_norm_2)*(L_norm_2 - J_norm_2)*(((*system).S1_norm_2)*((*system).q) - ((*system).S2_norm_2))*(1./((*system).q)-1) - 2.*((*system).Seff)*((*system).deltam_over_M)*(((*system).S1_norm_2) - ((*system).S2_norm_2))*L_norm*(L_norm_2 - J_norm_2) + (((*system).S1_norm_2) - ((*system).S2_norm_2))*(((*system).S1_norm_2) - ((*system).S2_norm_2))*L_norm_2*((*system).deltam_over_M)*((*system).deltam_over_M)/((*system).nu);
514 
515  return out;
516 }
517 
518 /**
519  * Internal function that returns the magnitude of J to Newtonian order
520  * Equation 41 (1703.03967)
521  */
522 static double J_norm_of_xi(const double L_norm, const sysq *system)
523 {
524  return sqrt(L_norm*L_norm + 2.*L_norm*((*system).c_1_over_nu) + (*system).Ssqave);
525 }
526 
527 /**
528  * Internal function that returns the magnitude of S divided by GMsquare_over_c
529  * Equation 23 (1703.03967)
530  */
531 static double S_norm_of_xi(const double xi, const double xi_2, const vector roots, const sysq *system)
532 {
533  double sn, cn, dn, m, u;
534 
535  if(fabs(roots.y-roots.z)<1.e-5) sn = 0.;
536  else {
537  m = (roots.y - roots.z)/(roots.x - roots.z);
538  u = u_of_xi(xi,xi_2,system)+(*system).constant_of_S;
539  gsl_sf_elljac_e(u, m, &sn, &cn, &dn);
540  }
541  const double S_norm_square_bar = roots.z + (roots.y - roots.z)*sn*sn;
542  return sqrt(S_norm_square_bar);
543 }
544 
545 /**
546  * Internal function that returns the magnitude of L divided by GMsquare_over_c to
547  * 2PN order, non-spinning terms
548  * from 0605140 and Blanchet LRR and 1212.5520 Eq. 4.7
549  */
550 static double L_norm_2PN_NonSpinning_of_xi(const double xi_2, const double L_norm, const sysq *system)
551 {
552  return L_norm * \
553  (1. + xi_2 * \
554  ((*system).constants_L[0] \
555  + xi_2 * ((*system).constants_L[2])) \
556  );
557 }
558 
559 /**
560  * Internal function that returns the magnitude of L divided by GMsquare_over_c to
561  * 3PN order
562  * from 0605140 and Blanchet LRR and 1212.5520 Eq. 4.7
563  */
564 static double L_norm_3PN_of_xi(const double xi, const double xi_2, const double L_norm, const sysq *system)
565 {
566  return L_norm*(1. + xi_2*((*system).constants_L[0] + xi*(*system).constants_L[1] + xi_2*((*system).constants_L[2] + xi*(*system).constants_L[3] + xi_2*((*system).constants_L[4]))));
567 }
568 
569 /**
570  * Internal function that returns the coefficients
571  * "c_0", "c_2" and "c_4" from 1703.03967
572  * corresponding to equations
573  * B6, B7 and B8 in 1703.03967 respectively
574  * out.x = c_0
575  * out.y = c_2
576  * out.z = c_4
577  */
578 static vector c(const double xi, const double xi_2, const double J_norm, const vector roots, const sysq *system)
579 {
580  const double xi_3 = xi_2*xi;
581  const double xi_4 = xi_3*xi;
582  const double xi_6 = xi_3*xi_3;
583 
584  const double J_norm_2 = J_norm*J_norm;
585 
586  vector out;
587 
588  out.x = -0.75*((J_norm_2-roots.z)*(J_norm_2-roots.z)*xi_4/((*system).nu) - 4.*((*system).nu)*((*system).Seff)*(J_norm_2-roots.z)*xi_3-2.*(J_norm_2-roots.z+2*(((*system).S1_norm_2)-((*system).S2_norm_2))*((*system).deltam_over_M))*((*system).nu)*xi_2+(4.*((*system).Seff)*xi+1)*((*system).nu)*((*system).nu_2))*J_norm*xi_2*(((*system).Seff)*xi-1.);
589  out.y = 1.5*(roots.y-roots.z)*J_norm*((J_norm_2-roots.z)/((*system).nu)*xi_2-2.*((*system).nu)*((*system).Seff)*xi-((*system).nu))*(((*system).Seff)*xi-1.)*xi_4;
590  out.z = -0.75*J_norm*(((*system).Seff)*xi-1.)*(roots.z-roots.y)*(roots.z-roots.y)*xi_6/((*system).nu);
591 
592  return out;
593 }
594 
595 /**
596  * Internal function that returns the coefficients
597  * "d_0", "d_2" and "d_4" from 1703.03967
598  * corresponding to equations
599  * B9, B10 and B11 in 1703.03967 respectively
600  * out.x = d_0
601  * out.y = d_2
602  * out.z = d_4
603  */
604 static vector d(const double L_norm, const double J_norm, const vector roots)
605 {
606  vector out;
607 
608  out.x = -((L_norm+J_norm)*(L_norm+J_norm)-roots.z)*((L_norm-J_norm)*(L_norm-J_norm)-roots.z);
609  out.y = 2.*(roots.y-roots.z)*(J_norm*J_norm+L_norm*L_norm-roots.z);
610  out.z = -(roots.z-roots.y)*(roots.z-roots.y);
611 
612  return out;
613 }
614 
615 /**
616  * Internal function that returns the cosine of the angle between L and J
617  * equation 8 1703.03967
618  */
619 static double costhetaL(const double J_norm, const double L_norm, const double S_norm)
620 {
621  double out = 0.5*(J_norm*J_norm + L_norm*L_norm - S_norm*S_norm)/L_norm/J_norm;
622 
623  if (out>1) out = 1;
624  if (out<-1) out = -1;
625 
626  return out;
627 }
628 
629 /**
630  * Internal function that returns the phase of the magnitude of S
631  * given by equation 51 in arxiv:1703.03967
632  */
633 static double u_of_xi(const double xi, const double xi_2, const sysq *system)
634 {
635 
636  /*
637  dictionary from code variables to paper symbols arxiv:1703.03967
638  (*system).deltam_over_M = (m1-m2)/(m1+m2)
639  (*system).constants_u[0] = $-g_0$ in eq. 51. Where g_0 is given in eq. A1.
640  xi corresponds to v so
641  1./xi_2/xi corresponds to the $v^{-3}$ factor
642  (*system).constants_u[1] = $\psi_1$ in eq. 51, given in eq. C1
643  (*system).constants_u[2] = $\psi_2$ in eq. 51, given in eq. C2
644  */
645 
646  return 0.75*((*system).deltam_over_M)*(*system).constants_u[0]/xi_2/xi*(1. + xi*((*system).constants_u[1] + xi*((*system).constants_u[2])));
647 }
648 
649 /**
650  * Internal function that returns the derivative of the phase of the magnitude of S
651  * given by equation 24 in arxiv:1703.03967
652  */
653 static double psidot(const double xi, const double xi_2, const vector roots, const sysq *system)
654 {
655  const double xi_3 = xi_2*xi;
656  const double xi_6 = xi_3*xi_3;
657 
658  /*
659  dictionary from code variables to paper symbols arxiv:1703.03967
660  roots.z = S_+^2 as computed in the 'Roots' function
661  roots.x = S_3^2 as computed in the 'Roots' function
662  (*system).nu = symmetric mass-ratio
663  (*system).Seff = "$\xi$" (eq. 7) i.e. the effective spin,
664  which is NOT the same as the first argument to this function which is
665  confusingly also called 'xi'
666  xi and xi_6 are the v and v^6 variables in eq. B1 (in appendix B)
667 
668  the numerical factor is 0.75 which comes from a factor of 3/2 in eq.B1
669  and a factor of 1/2 in eq. 24
670  */
671 
672  return -0.75/sqrt((*system).nu)*(1.-(*system).Seff*xi)*xi_6*sqrt(roots.z-roots.x);
673 }
674 
675 /**
676  * Internal function that returns phiz
677  * equation 66 in 1703.03967
678  */
679 static double phiz_of_xi(const double xi, const double xi_2, const double J_norm, const sysq *system)
680 {
681  const double inside_log1 = ((*system).c_1) + J_norm*((*system).nu)+((*system).nu_2)/xi;
682  // eq. D28 in 1703.03967
683  const double log1 = log(fabs(inside_log1));
684  const double inside_log2 = ((*system).c_1) + J_norm*((*system).sqrtSsqave)*xi + ((*system).Ssqave)*xi;
685  // eq. D29 in 1703.03967
686  const double log2 = log(fabs(inside_log2));
687 
688  // eq. D22 in 1703.03967
689  const double phiz0 = J_norm*(0.5*((*system).c1_2)/((*system).nu_4) - 0.5*((*system).onethird)*((*system).c_1)/xi/((*system).nu_2) - ((*system).onethird)*((*system).Ssqave)/((*system).nu_2) - ((*system).onethird)/xi_2) - 0.5*((*system).c_1)*(((*system).c1_2)/((*system).nu_4) - ((*system).Ssqave)/((*system).nu_2))/((*system).nu)*log1;
690  // eq. D23 in 1703.03967
691  const double phiz1 = -J_norm*0.5*(((*system).c_1)/((*system).nu_2) + 1./xi) + 0.5*(((*system).c1_2)/((*system).nu_2) - ((*system).Ssqave))/((*system).nu)*log1 ;
692  // eq. D24 in 1703.03967
693  const double phiz2 = -J_norm + ((*system).sqrtSsqave)*log2 - ((*system).c_1)/((*system).nu)*log1;
694  // eq. D25 in 1703.03967
695  const double phiz3 = J_norm*xi -((*system).nu)*log1 + ((*system).c_1)/((*system).sqrtSsqave)*log2;
696  // eq. D26 in 1703.03967
697  const double phiz4 = J_norm*0.5*xi*(((*system).c_1)/((*system).Ssqave) + xi) - 0.5*(((*system).c1_2)/((*system).Ssqave) - ((*system).nu_2))/((*system).sqrtSsqave)*log2;
698  // eq. D27 in 1703.03967
699  const double phiz5 = J_norm*xi*(-0.5*((*system).c1_2)/((*system).Ssqave)/((*system).Ssqave) + 0.5*((*system).onethird)*((*system).c_1)*xi/((*system).Ssqave) + ((*system).onethird)*(xi_2 + ((*system).nu_2)/((*system).Ssqave))) + 0.5*((*system).c_1)*(((*system).c1_2)/((*system).Ssqave) - ((*system).nu_2))/((*system).Ssqave)/((*system).sqrtSsqave)*log2;
700 
701  // perform the summation in eq. 66 in 1703.03967
702  double phizout = phiz0*(*system).constants_phiz[0] + phiz1*(*system).constants_phiz[1] + phiz2*(*system).constants_phiz[2] + phiz3*(*system).constants_phiz[3] + phiz4*(*system).constants_phiz[4] + phiz5*(*system).constants_phiz[5] + (*system).phiz_0;
703  if (phizout!=phizout) phizout = 0;
704 
705  return phizout;
706 }
707 
708 /**
709  * Internal function that returns zeta
710  * eq. F5 in 1703.03967
711  */
712 static double zeta_of_xi(const double xi, const double xi_2, const sysq *system)
713 {
714  const double logxi = log(xi);
715  const double xi_3 = xi_2*xi;
716 
717  // summation in eq. F5 in 1703.03967
718  double zetaout = ((*system).nu)*(-(*system).onethird*(*system).constants_zeta[0]/xi_3 - 0.5*(*system).constants_zeta[1]/xi_2 - (*system).constants_zeta[2]/xi + (*system).constants_zeta[3]*logxi + (*system).constants_zeta[4]*xi + 0.5*(*system).constants_zeta[5]*xi_2) + (*system).zeta_0;
719  if (zetaout!=zetaout) zetaout = 0;
720 
721  return zetaout;
722 }
723 
724 /**
725  * Internal function that computes the MS corrections for phiz and zeta
726  * eq. 67 (for phiz) and F19 (for zeta)
727  */
728 static vector computeMScorrections (const double xi, const double xi_2, const double L_norm, const double J_norm, const vector roots, const sysq *system)
729 {
730  vector out;
731  const vector c_return = c(xi,xi_2,J_norm,roots,system);
732  const vector d_return = d(L_norm,J_norm,roots);
733  const double c0 = c_return.x; //eq. B6 in 1703.03967
734  const double c2 = c_return.y; //eq. B7 in 1703.03967
735  const double c4 = c_return.z; //eq. B8 in 1703.03967
736  const double d0 = d_return.x; //eq. B9 in 1703.03967
737  const double d2 = d_return.y; //eq. B10 in 1703.03967
738  const double d4 = d_return.z; //eq. B11 in 1703.03967
739 
740  //"s_d" in the paper: eq. B20 in 1703.03967
741  const double sqt = sqrt(fabs(d2 * d2 - 4. * d0 * d4));
742 
743  //related to eq. F20 in 1703.03967
744  const double Aa = 0.5*(J_norm/L_norm + L_norm/J_norm - roots.z/J_norm/L_norm);
745  //eq. F21 in 1703.03967
746  const double Bb = 0.5*(roots.z - roots.y)/L_norm/J_norm;
747 
748  const double twod0_d2 = 2*d0+d2;
749  const double twod0d4 = 2*d0*d4;
750  const double d2_twod4 = d2+2.*d4;
751  const double d2_d4 =d2+d4;
752  const double d0_d2_d4 = d0+d2+d4;
753 
754  // "n3" in the code is "n_c" in the paper eq. B16 in 1703.03967
755  const double n3 = (2.*d0_d2_d4/(twod0_d2+sqt));
756  // "n4" in the code is "n_d" in the paper eq. B17 in 1703.03967
757  const double n4 = ((twod0_d2+sqt)/(2.*d0));
758  const double sqtn3 = sqrt(fabs(n3));
759  const double sqtn4 = sqrt(fabs(n4));
760  const double den = 2.*d0*d0_d2_d4*sqt;
761 
762  const double u = u_of_xi(xi,xi_2,system)+(*system).constant_of_S;
763  const double tanu = tan(u);
764  const double atanu = atan(tan(u));
765  const double psdot = psidot(xi,xi_2,roots,system);
766 
767  double L3, L4;
768  //L3 is XX (1703.03967)
769  if (n3 == 1){
770  L3 = 0;
771  } else {
772  L3 = fabs((c4 * d0 * (twod0_d2 + sqt) - c2 * d0 * (d2_twod4 - sqt) - c0 * (twod0d4 - d2_d4 * (d2 - sqt))) / (den)) * (sqtn3 / (n3 - 1.) * (atanu - atan(sqtn3 * tanu))) / psdot;
773  }
774 
775  //L4 is XX (1703.03967)
776  if (n4 == 1){
777  L4 = 0;
778  } else {
779  L4 = fabs((-c4 * d0 * (twod0_d2 - sqt) + c2 * d0 * (d2_twod4 + sqt) - c0 * (-twod0d4 + d2_d4 * (d2 + sqt)))) / (den) * (sqtn4 / (n4 - 1.) * (atanu - atan(sqtn4 * tanu))) / psdot;
780  }
781 
782  out.x = L3+L4;
783  if (out.x != out.x) out.x=0;
784 
785  // eq. F19 in 1703.03967
786  out.y = Aa*out.x + 2.*Bb*d0*(L3/(sqt-d2)-L4/(sqt+d2));
787  if (out.y != out.y) out.y=0;
788 
789  out.z = 0;
790 
791  return out;
792 }
793 
794 
795 /**
796  * Internal function that computes the spin-orbit couplings
797  */
798 static double beta(const double a, const double b, const sysq *system)
799 {
800  return ((((*system).dot1)*(a + b*((*system).q))) + (((*system).dot2)*(a + b/((*system).q))));
801 }
802 
803 /**
804  * Internal function that computes the spin-spin couplings
805  */
806 static double sigma(const double a, const double b, const sysq *system)
807 {
808  return (a*((*system).dot12) - b*((*system).dot1)*((*system).dot2))/((*system).nu);
809 }
810 
811 /**
812  * Internal function that computes the spin-spin couplings
813  */
814 static double tau(const double a, const double b, const sysq *system)
815 {
816  return (((*system).q)*((*system).S1_norm_2*a - b*((*system).dot1)*((*system).dot1)) + ((*system).S2_norm_2*a - b*((*system).dot2)*((*system).dot2))/((*system).q))/((*system).nu);
817 }
818 
819 /**
820  * Internal function that returns the dot product of two vectors
821  */
822 static double DotProd(const vector vec1, const vector vec2)
823 {
824  return vec1.x*vec2.x + vec1.y*vec2.y + vec1.z*vec2.z;
825 }
826 
827 
828 /**
829  * Internal function that returns the norm of a vector
830  */
831 static double Norm(const vector vec)
832 {
833  return sqrt(vec.x*vec.x + vec.y*vec.y + vec.z*vec.z);
834 }
835 
836 
837 /**
838  * Internal function that calculates a vector fro its spherical components
839  */
840 static vector CreateSphere(const double r, const double th, const double ph)
841 {
842  vector out;
843  const double fact = r*sin(th);
844  out.x = fact*cos(ph);
845  out.y = fact*sin(ph);
846  out.z = r*cos(th);
847 
848  return out;
849 }
850 
851 /**
852  * Internal function that returns the scalar product of a vector with a scalar
853  */
854 static vector ScalarProd(double c, vector vec)
855 {
856  vector out;
857  out.x = c*vec.x;
858  out.y = c*vec.y;
859  out.z = c*vec.z;
860 
861  return out;
862 }
863 
864 /**
865  * Internal function that returns the sum of two vectors
866  */
867 static vector Sum(vector vec1, vector vec2)
868 {
869  vector out;
870  out.x = vec1.x+vec2.x;
871  out.y = vec1.y+vec2.y;
872  out.z = vec1.z+vec2.z;
873 
874  return out;
875 }
876 
877 /**
878  * Internal function that returns the cross product of two vectors
879  */
880 static vector CrossProd(vector vec1, vector vec2)
881 {
882  vector out;
883  out.x = vec1.y*vec2.z-vec1.z*vec2.y;
884  out.y = vec1.z*vec2.x-vec1.x*vec2.z;
885  out.z = vec1.x*vec2.y-vec1.y*vec2.x;
886 
887  return out;
888 }
const double c2
const double c0
static vector CreateSphere(const double r, const double th, const double ph)
Internal function that calculates a vector fro its spherical components.
static vector Sum(vector vec1, vector vec2)
Internal function that returns the sum of two vectors.
static UNUSED vector compute_phiz_zeta_costhetaL(const double xi, const sysq *system)
Internal function that computes phiz, zeta, and costhetaL at Newtonian order.
static double psidot(const double xi, const double xi_2, const vector roots, const sysq *system)
Internal function that returns the derivative of the phase of the magnitude of S given by equation 24...
static vector CrossProd(vector vec1, vector vec2)
Internal function that returns the cross product of two vectors.
static double L_norm_3PN_of_xi(const double xi, const double xi_2, const double L_norm, const sysq *system)
Internal function that returns the magnitude of L divided by GMsquare_over_c to 3PN order from 060514...
static double J_norm_of_xi(const double L_norm, const sysq *system)
Internal function that returns the magnitude of J to Newtonian order Equation 41 (1703....
static UNUSED int InitializeSystem(sysq *system, const double m1, const double m2, const double mul, const double phl, const double mu1, const double ph1, const double ch1, const double mu2, const double ph2, const double ch2, const double f_0, const int ExpansionOrder)
InitializeSystem computes all the prefactors needed to generate precession angles from Chatziioannou ...
static double S_norm_of_xi(const double xi, const double xi_2, const vector roots, const sysq *system)
Internal function that returns the magnitude of S divided by GMsquare_over_c Equation 23 (1703....
static double tau(const double a, const double b, const sysq *system)
Internal function that computes the spin-spin couplings.
static double sigma(const double a, const double b, const sysq *system)
Internal function that computes the spin-spin couplings.
static vector d(const double L_norm, const double J_norm, const vector roots)
Internal function that returns the coefficients "d_0", "d_2" and "d_4" from 1703.03967 corresponding ...
static vector ScalarProd(double c, vector vec)
Internal function that returns the scalar product of a vector with a scalar.
static double u_of_xi(const double xi, const double xi_2, const sysq *system)
Internal function that returns the phase of the magnitude of S given by equation 51 in arxiv:1703....
static UNUSED vector compute_phiz_zeta_costhetaL2PNNonSpinning(const double xi, const sysq *system)
Internal function that computes phiz, zeta, and costhetaL at 2PN NonSpinning.
static double costhetaL(const double J_norm, const double L_norm, const double S_norm)
Internal function that returns the cosine of the angle between L and J equation 8 1703....
static double L_norm_2PN_NonSpinning_of_xi(const double xi_2, const double L_norm, const sysq *system)
Internal function that returns the magnitude of L divided by GMsquare_over_c to 2PN order,...
static double DotProd(const vector vec1, const vector vec2)
Internal function that returns the dot product of two vectors.
static UNUSED vector compute_phiz_zeta_costhetaL3PN(const double xi, const sysq *system)
Internal function that computes phiz, zeta, and costhetaL at 3PN.
static double beta(const double a, const double b, const sysq *system)
Internal function that computes the spin-orbit couplings.
static double Norm(const vector vec)
Internal function that returns the norm of a vector.
static double zeta_of_xi(const double xi, const double xi_2, const sysq *system)
Internal function that returns zeta eq.
static vector computeMScorrections(const double xi, const double xi_2, const double L_norm, const double J_norm, const vector roots, const sysq *system)
Internal function that computes the MS corrections for phiz and zeta eq.
static vector c(const double xi, const double xi_2, const double J_norm, const vector roots, const sysq *system)
Internal function that returns the coefficients "c_0", "c_2" and "c_4" from 1703.03967 corresponding ...
static double phiz_of_xi(const double xi, const double xi_2, const double J_norm, const sysq *system)
Internal function that returns phiz equation 66 in 1703.03967.
static vector Roots(const double L_norm, const double J_norm, const sysq *system)
Internal function that computes the roots of Eq.
static vector BCDcoeff(const double L_norm, const double J_norm, const sysq *system)
Internal function that computes the B,C,D coefficients of Eq.
REAL8 M
Definition: bh_qnmode.c:133
double e
Definition: bh_ringdown.c:117
double theta
Definition: bh_sphwf.c:118
const double sn
const double u
const double a4
const double u3
const double u5
const double a2
const double u2
const double u4
const double B
#define __attribute__(x)
#define LAL_LN2
#define LAL_C_SI
#define LAL_PI
#define LAL_TWOPI
#define LAL_GAMMA
#define LAL_G_SI
static const INT4 r
static const INT4 m
static const INT4 q
static const INT4 a
#define XLAL_ERROR(...)
#define XLAL_CHECK(assertion,...)
XLAL_SUCCESS
XLAL_EDOM
list p
double constants_L[6]
double constants_phiz[6]
double constants_zeta[6]
double constants_u[6]