LALSimulation  5.4.0.1-fe68b98
LALSimIMRSpinEOBComputeAmpPhasefromEOMSoln.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
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 _LALSIMIMRSPINEOBCOMPUTEAMPPHASEFROMEOMSOLN_C
34 #define _LALSIMIMRSPINEOBCOMPUTEAMPPHASEFROMEOMSOLN_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 
44 /*------------------------------------------------------------------------------------------
45  *
46  * Prototypes of functions defined in this code.
47  *
48  *------------------------------------------------------------------------------------------
49  */
50 
51 
54  params);
55 static void GenerateAmpPhaseFromEOMSoln (UINT4 retLen, REAL8 * inputdata,
56  SpinEOBParams * seobParams);
57 
58 /*------------------------------------------------------------------------------------------
59  *
60  * Defintions of functions.
61  *
62  *------------------------------------------------------------------------------------------
63  */
64 
65 /* This function simply reads in the four inputs from values[] and outputs the Optimized SEOBNRv2 Hamiltonian */
66 static double
69 {
70  EOBParams *eobParams = params->eobParams;
71  REAL8 tmpVec[6];
72 
73  /* These are the vectors which will be used in the call to the Hamiltonian */
74  REAL8Vector r, p;
75  REAL8Vector *s1Vec = params->s1Vec;
76  REAL8Vector *s2Vec = params->s2Vec;
77  REAL8Vector *sigmaKerr = params->sigmaKerr;
78  REAL8Vector *sigmaStar = params->sigmaStar;
79 
80  /* Use a temporary vector to avoid corrupting the main function */
81  memcpy (tmpVec, values, sizeof (tmpVec));
82 
83  /* Set the LAL-style vectors to point to the appropriate things */
84  r.length = p.length = 3;
85  r.data = tmpVec;
86  p.data = tmpVec + 3;
87 
88  /* Notice that the Hamiltonian is not divided by eta. */
89  REAL8 xlalham =
90  XLALSimIMRSpinEOBHamiltonianOptimized (eobParams->eta, &r, &p, s1Vec,
91  s2Vec, sigmaKerr, sigmaStar,
92  params->tortoise,
93  params->seobCoeffs);
94  return xlalham;
95 }
96 
97 static void
99  SpinEOBParams * seobParams)
100 {
101 
102  for (UINT4 jj = 0; jj < retLen; jj++)
103  {
104  REAL8 yForOmegaCirc[4], cartValues[6], yy[4];
105  for (INT4 kk = 1; kk <= 4; kk++)
106  yy[kk - 1] = inputdata[kk * retLen + jj];
107  yForOmegaCirc[0] = yy[0];
108  yForOmegaCirc[1] = yy[1];
109  yForOmegaCirc[2] = 0.0;
110  yForOmegaCirc[3] = yy[3];
111 
112  cartValues[0] = yy[0];
113  cartValues[1] = 0.0;
114  cartValues[2] = 0.0;
115  cartValues[3] = yy[2];
116  cartValues[4] = yy[3] / yy[0];
117  cartValues[5] = 0.0;
118 
119  REAL8 ham =
121  seobParams);
122  REAL8 omega =
124  REAL8 omegaCirc =
126  seobParams);
127 
128  //CALEBS: Consolidated variable declarations:
129  /* REAL8 rOmegaSq,rOmega,sqrtR,v,v2,vh,vh3,eulerlogxabs,deltalm,rholm,rholmPwrl,hlm0,hlmPhase,hlmMag,nqcMag,nqcPhase; */
130 
131  /* REAL8 legendre; */
132  /* REAL8 vPhi2; */
133 
134 
135  EOBNonQCCoeffs *nqcCoeffs = seobParams->nqcCoeffs;
136  FacWaveformCoeffs *hCoeffs = seobParams->eobParams->hCoeffs;
137  REAL8 eta = seobParams->eobParams->eta;
138  REAL8 r = yy[0];
139  REAL8 phi = yy[1];
140  REAL8 p = yy[2];
141  //REAL8 pp = yy[3];
142 
143  /* OPTIMIZATION COMMENT: BEGIN: STEP 7 */
144 
145  /* Calculate the Tail term, 3rd term in Eq. 17, given by Eq. A6 */
146  // OPTIMIZATION COMMENT: Since l=m=2
147  REAL8 k = 2 * omega; /*Location of this line of code: XLALSimIMRSpinEOBGetSpinFactorizedWaveform */
148  REAL8 hathatk = ham * k; /*Location of this line of code: XLALSimIMRSpinEOBGetSpinFactorizedWaveform */
149 
150  // XLAL_CALLGSL( status = gsl_sf_lngamma_complex_e( l+1.0, -2.0*hathatk, &lnr1, &arg1 ) );
151  // XLAL_CALLGSL( status = gsl_sf_lngamma_complex_e( 3.0, -2.0*hathatk, &lnr1, &arg1 ) );
152  //if(zr <= 0.5) //OPTIMIZATION COMMENT: zr = 3.0 so, proceeding to else...
153  //else
154 
155  gsl_sf_result lnr1, arg1;
156  INT4 UNUSED status; /* UNUSED is needed to avoid compiler warning about a variable being declared but unused. */
157  XLAL_CALLGSL (status = gsl_sf_lngamma_complex_e (3.0, -2.0 * hathatk, &lnr1, &arg1)); /*Location of this line of code: XLALSimIMRSpinEOBGetSpinFactorizedWaveform */
158  // XLAL_CALLGSL( status = gsl_sf_fact_e( l, &z2 ) ); //OPTIMIZATION COMMENT: Since l=2, l! = 2 = z2
159 
160  REAL8 TlmPhase = arg1.val + 2.0 * hathatk * log (4.0 * k / sqrt (LAL_E)); /*Location of this line of code: XLALSimIMRSpinEOBGetSpinFactorizedWaveform */
161  REAL8 TlmMag = exp (lnr1.val + LAL_PI * hathatk) * 0.5; /*Location of this line of code: XLALSimIMRSpinEOBGetSpinFactorizedWaveform */
162 
163  /* Calculate the source term, 2nd term in Eq. 17, given by Eq. A5 */
164  //if ( ( (l+m)%2 ) == 0) //OPTIMIZATION COMMENT: Since l=m=2...
165  REAL8 Slm = (ham * ham - 1.) / (2. * eta) + 1.; /*Location of this line of code: XLALSimIMRSpinEOBGetSpinFactorizedWaveform */
166 
167  REAL8 v = cbrt (omega); /*Location of this line of code: XLALSimIMRSpinEOBGetSpinFactorizedWaveform */
168  //pr = values->data[2];
169  REAL8 v2 = v * v; /*Location of this line of code: XLALSimIMRSpinEOBGetSpinFactorizedWaveform */
170  //omega = v2 * v;
171  REAL8 vh3 = ham * omega; /*Location of this line of code: XLALSimIMRSpinEOBGetSpinFactorizedWaveform */
172  REAL8 vh = cbrt (vh3); /*Location of this line of code: XLALSimIMRSpinEOBGetSpinFactorizedWaveform */
173 
174  //eulerlogxabs = LAL_GAMMA + log( 2.0 * (REAL8)m * v ); //OPTIMIZATION COMMENT: m=2
175  REAL8 eulerlogxabs = LAL_GAMMA + log (4.0 * v); /*Location of this line of code: XLALSimIMRSpinEOBGetSpinFactorizedWaveform */
176 
177  REAL8 vPhi2 = (omega * omega / omegaCirc) * cbrt (1.0 / omegaCirc); /*Location of this line of code:1,2:XLALSimIMRSpinEOBGetSpinFactorizedWaveform,XLALSimIMRSpinAlignedEOBNonKeplerCoeff */
178 
179  REAL8 legendre = 0.75 * sqrt (5.0 / (6 * LAL_PI)); /*Location of this line of code: XLALScalarSphHarmThetaPiBy2,XLALAssociatedLegendreXIsZero */
180 
181  REAL8 hlm0 = vPhi2 * seobParams->eobParams->prefixes->values[2][2]; /*Location of this line of code: XLALSimIMRSpinEOBCalculateNewtonianMultipole */
182 
183 
184  /* Calculate the non-Keplerian velocity */
185  // vPhi = XLALSimIMRSpinAlignedEOBNonKeplerCoeff( values->data, &seobParams ); //OPTIMIZATION COMMENT: Replaced with its output
186 
187  /* Calculate the residue phase and amplitude terms */
188  /* deltalm is the 4th term in Eq. 17, delta 22 given by Eq. A15, others */
189  /* rholm is the 5th term in Eq. 17, given by Eqs. A8 - A14 */
190  /* auxflm is a special part of the 5th term in Eq. 17, given by Eq. A15 */
191  /* Actual values of the coefficients are defined in the next function of this file */
192 
193  //OPTIMIZATION COMMENT: Since l=m=2...
194  REAL8 deltalm = vh3 * (hCoeffs->delta22vh3 + vh3 * (hCoeffs->delta22vh6 /* Location of this line of code: XLALSimIMRSpinEOBGetSpinFactorizedWaveform */
195  +
196  vh * vh *
197  (hCoeffs->
198  delta22vh9 *
199  vh))) +
200  hCoeffs->delta22v5 * v * v2 * v2 + hCoeffs->delta22v6 * v2 * v2 * v2 +
201  hCoeffs->delta22v8 * v2 * v2 * v2 * v2;
202  REAL8 rholm =
203  1. + v2 * (hCoeffs->rho22v2 +
204  v * (hCoeffs->rho22v3 +
205  v * (hCoeffs->rho22v4 +
206  v * (hCoeffs->rho22v5 +
207  v * (hCoeffs->rho22v6 +
208  hCoeffs->rho22v6l * eulerlogxabs +
209  v * (hCoeffs->rho22v7 +
210  v * (hCoeffs->rho22v8 +
211  hCoeffs->rho22v8l *
212  eulerlogxabs +
213  (hCoeffs->rho22v10 +
214  hCoeffs->rho22v10l *
215  eulerlogxabs) * v2)))))));
216  /* Raise rholm to the lth power *///OPTIMIZATION COMMENT: since l = 2...
217  REAL8 rholmPwrl = rholm * rholm; /* Location of this line of code: XLALSimIMRSpinEOBGetSpinFactorizedWaveform */
218 
219  /* In the equal-mass odd m case, there is no contribution from nonspin terms,
220  * and the only contribution comes from the auxflm term that is proportional to chiA (asymmetric spins).
221  * In this case, we must ignore the nonspin terms directly, since the leading term defined by
222  * CalculateThisMultipolePrefix in LALSimIMREOBNewtonianMultipole.c is not zero (see comments there).
223  */
224 
225  //OPTIMIZATION COMMENT: Since m = 2, we can comment out:
226  /*if (eta == 0.25 && m % 2)
227  {
228  rholmPwrl = auxflm;
229  }
230  else
231  { */
232  //rholmPwrl += auxflm; /OPTIMIZATION COMMENT: ignoring because auxflm = 0.0;
233  //} //OPTIMIZATION COMMENT: m=2.
234  /*if (r > 8.5)
235  {
236  printf("YP::dynamics variables in waveform: %i, %i, %e, %e, %e\n",l,m,r,pp,values->data[1]);
237  printf( "rholm^l = %.16e, Tlm = %.16e + i %.16e, |Tlm| = %.16e \nSlm = %.16e, hNewton = %.16e + i %.16e, delta = %.16e\n", rholmPwrl, creal(Tlm), cimag(Tlm), cabs(Tlm), Slm, creal(hNewton), cimag(hNewton), deltalm );
238  printf("delta22 coeffs: vh3C = %.16e, vh6C = %.16e, vh9C = %.16e, v5C = %.16e, v6C = %.16e, v8C = %.16e\n",hCoeffs->delta22vh3,hCoeffs->delta22vh6,hCoeffs->delta22vh9,hCoeffs->delta22v5,hCoeffs->delta22v6,hCoeffs->delta22v8);
239  printf("hNewt amp = %.16e, arg = %.16e\n",cabs(hNewton),carg(hNewton));
240  } */
241 
242  /*
243  if (r > 8.5)
244  {
245  printf("YP::FullWave: Reh = %.16e, Imh = %.16e, hAmp = %.16e, hPhi = %.16e\n",creal(*hLM),cimag(*hLM),cabs(*hLM),carg(*hLM));
246  }
247  */
248 
249  REAL8 sqrtR = sqrt (r); /*Location of this line of code: XLALSimIMREOBNonQCCorrection */
250  REAL8 rOmega = r * omega; /*Location of this line of code: XLALSimIMREOBNonQCCorrection */
251  REAL8 rOmegaSq = rOmega * rOmega; /*Location of this line of code: XLALSimIMREOBNonQCCorrection */
252 
253  /* printf("a1 = %.16e, a2 = %.16e, a3 = %.16e, a3S = %.16e, a4 = %.16e, a5 = %.16e\n",nqcCoeffs->a1,nqcCoeffs->a2,nqcCoeffs->a3,nqcCoeffs->a3S, nqcCoeffs->a4,nqcCoeffs->a5);
254  printf("b1 = %.16e, b2 = %.16e, b3 = %.16e, b4 = %.16e\n",nqcCoeffs->b1,nqcCoeffs->b2,nqcCoeffs->b3,nqcCoeffs->b4); */
255  /* In EOBNRv2, coeffs->a3S, coeffs->a4 and coeffs->a5 are set to zero */
256  /* through XLALSimIMREOBGetCalibratedNQCCoeffs() */
257  /* and XLALSimIMREOBCalculateNQCCoefficients() */
258 
259  REAL8 nqcMag = 1. + (p * p / rOmegaSq) * (nqcCoeffs->a1 /*Location of this line of code: XLALSimIMREOBNonQCCorrection */
260  + nqcCoeffs->a2 / r +
261  (nqcCoeffs->a3 +
262  nqcCoeffs->a3S) / (r *
263  sqrtR) +
264  nqcCoeffs->a4 / (r * r) +
265  nqcCoeffs->a5 / (r * r *
266  sqrtR));
267 
268  REAL8 nqcPhase = nqcCoeffs->b1 * p / rOmega + p * p * p / rOmega * (nqcCoeffs->b2 + nqcCoeffs->b3 / sqrtR + nqcCoeffs->b4 / r); /*Location of this line of code: XLALSimIMREOBNonQCCorrection */
269 
270  REAL8 hlmMag = hlm0 * legendre; /*Location of this line of code: XLALScalarSphHarmThetaPiBy2 */
271  REAL8 hlmPhase = -2.0 * phi; /*Location of this line of code: XLALScalarSphHarmThetaPiBy2 */
272 
273  // *hlm = Tlm * cexp(I * deltalm) * Slm * rholmPwrl; //OPTIMIZATION COMMENT: From XLALSimIMRSpinEOBGetSpinFactorizedWaveform
274  // OPTIMIZATION COMMENT: (the final) hlm = hlm*hNQC, (from XLALSimIMRSpinEOBGetSpinFactorizedWaveform) so, combine to get:
275 
276  /* Amplitude: */
277  inputdata[(4 + 1) * retLen + jj] =
278  TlmMag * hlmMag * (Slm * rholmPwrl) * nqcMag;
279 
280  /* Phase: */
281  inputdata[(4 + 2) * retLen + jj] =
282  (hlmPhase + TlmPhase + nqcPhase + deltalm);
283 
284  }
285 }
286 
287 
288 #endif /* _LALSIMIMRSPINEOBCOMPUTEAMPPHASEFROMEOMSOLN_C */
static double GenericSpinAlignedHamiltonianWrapperOptimized(REAL8 *values, SpinEOBParams *params)
static void GenerateAmpPhaseFromEOMSoln(UINT4 retLen, REAL8 *inputdata, SpinEOBParams *seobParams)
UNUSED REAL8 XLALSimIMRSpinEOBHamiltonianOptimized(const REAL8 eta, REAL8Vector *restrict x, REAL8Vector *restrict p, REAL8Vector *restrict s1Vec, REAL8Vector *restrict s2Vec, REAL8Vector *restrict sigmaKerr, REAL8Vector *restrict sigmaStar, INT4 tortoise, SpinEOBHCoeffs *coeffs)
Function to calculate the value of the spinning Hamiltonian for given values of the dynamical variabl...
static REAL8 XLALSimIMRSpinAlignedEOBCalcOmegaOptimized(const REAL8 values[], SpinEOBParams *funcParams)
Function to calculate the value of omega for the spin-aligned EOB waveform.
#define XLAL_CALLGSL(statement)
#define LAL_E
#define LAL_PI
#define LAL_GAMMA
double REAL8
uint32_t UINT4
int32_t INT4
static const INT4 r
list p
string status
The coefficients which are used in calculating the non-quasicircular correction to the EOBNRv2 model.
Structure containing all the parameters needed for the EOB waveform.
FacWaveformCoeffs * hCoeffs
NewtonMultipolePrefixes * prefixes
Structure containing the coefficients for calculating the factorized waveform.
COMPLEX16 values[LALEOB_MAX_MULTIPOLE+1][LALEOB_MAX_MULTIPOLE+1]
Parameters for the spinning EOB model.
EOBNonQCCoeffs * nqcCoeffs
EOBParams * eobParams
Definition: burst.c:245