1 #include <lal/LALSimIMR.h>
2 #include <lal/LALSimInspiral.h>
4 #include <lal/TimeSeries.h>
6 #include <lal/LALAdaptiveRungeKuttaIntegrator.h>
7 #include <lal/SphericalHarmonics.h>
8 #include <lal/LALSimSphHarmMode.h>
10 #include <lal/LALDict.h>
12 #include <gsl/gsl_sf_gamma.h>
13 #include <gsl/gsl_matrix.h>
14 #include <gsl/gsl_poly.h>
15 #include <gsl/gsl_spline.h>
16 #include <gsl/gsl_roots.h>
17 #include <gsl/gsl_deriv.h>
34 #define ROOT_SOLVER_ABS_TOL 1.0e-10
35 #define ROOT_SOLVER_REL_TOL 1.0e-8
62 for (
i = 0;
i < rSize;
i++)
64 rVec->
data[
i] = rInitial -
i*dr;
103 return partialHBypartialr;
126 REAL8 dprstarBydpr = prstarParams->
csi;
145 if (analyticFlag == 0)
229 REAL8 dprstarBydpr = pphiParams->
csi;
245 if (analyticFlag == 0)
328 + (dHBydx - dHBydpy *
pphi / (
r *
r))
344 double (*Func)(
REAL8,
void *),
360 INT4 maxIters = 1000;
373 const gsl_root_fsolver_type *solver_type;
374 solver_type = gsl_root_fsolver_falsepos;
376 gsl_root_fsolver *solver;
377 solver = gsl_root_fsolver_alloc(solver_type);
384 if (F_lower*F_upper >= 0.0)
390 F_lower = Func(x_lower,
params);
391 F_upper = Func(x_upper,
params);
393 if (F_lower*F_upper >= 0.0)
400 while (F_lower*F_upper >= 0.0)
405 F_lower = Func(x_lower,
params);
406 F_upper = Func(x_upper,
params);
410 gsl_root_fsolver_set(solver, &F, x_lower, x_upper);
418 status = gsl_root_fsolver_iterate(solver);
420 if (
status != GSL_SUCCESS)
423 x = gsl_root_fsolver_root(solver);
424 x_lower = gsl_root_fsolver_x_lower(solver);
425 x_upper = gsl_root_fsolver_x_upper(solver);
427 status = gsl_root_test_interval(
432 while (iters <= maxIters &&
status == GSL_CONTINUE);
436 result->
nIter = iters;
438 if (
status != GSL_SUCCESS)
444 gsl_root_fsolver_free (solver);
465 for (
i = 0;
i < vecLength;
i++)
467 reverseVec->
data[
i] = Vec->
data[vecLength-
i-1];
491 for (
i = 0;
i < vecLength;
i++)
517 for (
i = 0;
i < vecLength;
i++)
569 for (
i = 0;
i < rSize;
i++)
580 / (rVec->
data[
i] * rVec->
data[
i] + sigmaKerr * sigmaKerr)
588 j0Params.
r = rVec->
data[
i];
596 pphi0_lower = 0.1 * Newtonianj0;
597 pphi0_upper = 1.9 * Newtonianj0;
618 REAL8 polarDynamics[4];
620 polarDynamics[0] = rVec->
data[
i];
621 polarDynamics[1] = phiVec->
data[
i];
622 polarDynamics[2] = prstarVec->
data[
i];
623 polarDynamics[3] = pphiVec->
data[
i];
635 rReverseVec->
data, 0,
641 pphiReverseVec->
data, 0,
647 dpphiBydrReverseVec->
data, 0,
654 rReverseVec, pphiReverseVec, dpphiBydrReverseVec
721 LALParams,
"analyticFlag"
732 rReverseVec->
data, 0,
740 pphiReverseVec->
data, 0,
746 dpphiBydrReverseVec->
data, 0,
752 prstarReverseVec->
data, 0,
758 dprstarBydrReverseVec->
data, 0,
770 if (analyticFlag == 0)
772 for (
i = 0;
i < rSize;
i++)
774 dprstarVec->
data[
i] = 1.e-4;
778 REAL8 polarDynamics[4];
783 for (n = 1; n <= PAOrder; n++)
787 if ((n > 1) && (analyticFlag == 0))
794 for (
i = 0;
i < rSize;
i++)
797 prstarParams.
r = rVec->
data[
i];
799 prstarParams.
phi = 0.;
809 x_upper = 0.8 * prstarVec->
data[
i];
810 x_lower = 1.2 * prstarVec->
data[
i];
830 polarDynamics[0] = rVec->
data[
i];
831 polarDynamics[1] = phiVec->
data[
i];
832 polarDynamics[2] = prstarVec->
data[
i];
833 polarDynamics[3] = pphiVec->
data[
i];
845 dprstarBydrReverseVec->
data, 0,
850 rReverseVec, prstarReverseVec, dprstarBydrReverseVec
854 dprstarBydrReverseVec, dprstarBydrVec
859 for (
i = 0;
i < rSize;
i++)
864 pphiParams.
r = rVec->
data[
i];
892 polarDynamics[0] = rVec->
data[
i];
893 polarDynamics[1] = phiVec->
data[
i];
894 polarDynamics[2] = prstarVec->
data[
i];
895 polarDynamics[3] = pphiVec->
data[
i];
907 dpphiBydrReverseVec->
data, 0,
912 rReverseVec, pphiReverseVec, dpphiBydrReverseVec
918 if ((parity) && (analyticFlag == 0))
925 for(
i = 0;
i < rSize;
i++)
935 dtBydrVec->
data[
i] = (
936 1. / (dHBydprstar * csiVec->
data[
i])
977 REAL8 partialHByPartialr = 0.;
979 if (analyticFlag == 0)
982 1./280., -4./105., 1./5., -4./5., 0, 4./5., -1./5., 4./105., -1./280.
987 for (
i = -4;
i <= 4;
i++)
991 partialHByPartialr += (
1003 partialHByPartialr /= h;
1021 partialHByPartialr = dHBydx - dHBydpy*
pphi/(
r*
r);
1024 return partialHByPartialr;
1048 1./280., -4./105., 1./5., -4./5., 0, 4./5., -1./5., 4./105., -1./280.
1055 REAL8 partialHByPartialprstar = 0.;
1057 if (analyticFlag == 0)
1061 for (
i = -4;
i <= 4;
i++)
1065 partialHByPartialprstar += (
1077 partialHByPartialprstar /= h;
1089 partialHByPartialprstar = dHBydpx;
1092 return partialHByPartialprstar;
1111 for (
i = 0;
i < vecLength;
i++)
1115 for (j = 0; j < 8; j++)
1117 meanVec->
data[
i] += fabs(
1118 inputVec->
data[j+1] - inputVec->
data[j]
1124 for (j = 0; j < 8; j++)
1126 meanVec->
data[
i] += fabs(
1127 inputVec->
data[j+1] - inputVec->
data[j]
1133 for (j = 0; j < 8; j++)
1135 meanVec->
data[
i] += fabs(
1136 inputVec->
data[j+1] - inputVec->
data[j]
1142 for (j = 0; j < 8; j++)
1144 meanVec->
data[
i] += fabs(
1145 inputVec->
data[j+1] - inputVec->
data[j]
1149 else if (
i == vecLength-4)
1151 for (j = 0; j < 8; j++)
1153 meanVec->
data[
i] += fabs(
1154 inputVec->
data[
i+j-5] - inputVec->
data[
i+j-4]
1158 else if (
i == vecLength-3)
1160 for (j = 0; j < 8; j++)
1162 meanVec->
data[
i] += fabs(
1163 inputVec->
data[
i+j-6] - inputVec->
data[
i+j-5]
1167 else if (
i == vecLength-2)
1169 for (j = 0; j < 8; j++)
1171 meanVec->
data[
i] += fabs(
1172 inputVec->
data[
i+j-7] - inputVec->
data[
i+j-6]
1176 else if (
i == vecLength-1)
1178 for (j = 0; j < 8; j++)
1180 meanVec->
data[
i] += fabs(
1181 inputVec->
data[
i+j-8] - inputVec->
data[
i+j-7]
1187 for (j = 0; j < 8; j++)
1189 meanVec->
data[
i] += fabs(
1190 inputVec->
data[
i+j-4] - inputVec->
data[
i+j-3]
1195 meanVec->
data[
i] /= 8.0;
1232 REAL8 xCart[3] = {
r, 0., 0.};
1234 xCartVec.
data = xCart;
1235 pCartVec.
data = pCart;
1237 REAL8Vector a1CartVec, a2CartVec, aKCartVec, SstarCartVec;
1240 REAL8 spin1[3] = {0., 0., a1};
1241 REAL8 spin2[3] = {0., 0.,
a2};
1242 REAL8 aKV[3] = {0., 0., aK};
1243 REAL8 SstarV[3] = {0., 0., Sstar};
1244 a1CartVec.
data = spin1;
1245 a2CartVec.
data = spin2;
1246 aKCartVec.
data = aKV;
1247 SstarCartVec.
data = SstarV;
1255 if (analyticFlag == 0)
1329 polarDynamics.
length = 4;
1331 polarDynamics.
data = pol;
1333 const UINT4 lMax = 8;
1335 const UINT4 SpinAlignedEOBversion = 4;
1339 if (analyticFlag == 0)
1348 SpinAlignedEOBversion
1360 SpinAlignedEOBversion
1400 UINT4 SpinAlignedEOBversion,
1412 if (SpinAlignedEOBversion != 4)
1416 "XLALSimInspiralEOBPostAdiabatic can only be used with SpinAlignedEOBversion = 4.\n"
1419 REAL8 mass_swap = 0.0;
1420 REAL8 spin_swap = 0.0;
1432 REAL8 chi1 = spin1z;
1433 REAL8 chi2 = spin2z;
1454 REAL8 rFinalPrefactor = 1.6;
1458 REAL8 rFinal = rFinalPrefactor * rf;
1460 if (rInitial <= rFinal)
1465 REAL8 rSwitchPrefactor = 1.6;
1466 REAL8 rSwitch = rSwitchPrefactor * rf;
1468 if (rInitial <= rSwitch)
1475 UINT4 rSize = (int) ceil((rInitial-rFinal)/
dr);
1481 else if (rSize < 10)
1521 rReverseVec->
data, 0,
1533 tReverseVec->
data, 0,
1545 dtBydrReverseVec->
data, 0,
1557 phiReverseVec->
data, 0,
1563 dphiBydrVec->
data, 0,
1569 dphiBydrReverseVec->
data, 0,
1587 omegaReverseVec->
data, 0,
1611 pphiReverseVec->
data, 0,
1623 dprstarBydrVec->
data, 0,
1629 dpphiBydrVec->
data, 0,
1635 dpphiBydrReverseVec->
data, 0,
1641 prstarReverseVec->
data, 0,
1647 dprstarBydrReverseVec->
data, 0,
1653 domegadrVec->
data, 0,
1659 domegadrReverseVec->
data, 0,
1665 adiabatic_param_Vec->
data, 0,
1689 "XLALSimInspiralEOBPACalculateAdiabaticDynamics failed."
1715 "XLALSimInspiralEOBPACalculatePostAdiabaticDynamics failed."
1727 rReverseVec, omegaReverseVec, domegadrReverseVec
1732 UNUSED
REAL8 adiabatic_param = 0.0;
1737 for (j=0; j<rSize; j++)
1741 if (idx_stop == 0 && rSwitch >=
r)
1750 idx_stop = rSize - 1;
1753 UINT4 outSize = idx_stop;
1757 for (
i = 0;
i < outSize;
i++)
1759 (*dynamics)->data[
i] = tVec->
data[
i];
1760 (*dynamics)->data[outSize +
i] = rVec->
data[
i];
1761 (*dynamics)->data[2*outSize +
i] = phiVec->
data[
i];
1762 (*dynamics)->data[3*outSize +
i] = prstarVec->
data[
i];
1763 (*dynamics)->data[4*outSize +
i] = pphiVec->
data[
i];
1799 "PA inspiral doesn't have enough points for interpolation."
void XLALDestroyDict(LALDict *dict)
LALDict * XLALCreateDict(void)
int XLALDictInsertUINT4Value(LALDict *dict, const char *key, UINT4 value)
int XLALDictInsertUINT2Value(LALDict *dict, const char *key, UINT2 value)
REAL8 XLALDictLookupREAL8Value(LALDict *dict, const char *key)
UINT2 XLALDictLookupUINT2Value(LALDict *dict, const char *key)
int XLALDictInsertREAL8Value(LALDict *dict, const char *key, REAL8 value)
UINT4 XLALDictLookupUINT4Value(LALDict *dict, const char *key)
static REAL8 XLALInspiralSpinFactorizedFlux_PA(REAL8Vector *values, EOBNonQCCoeffs *nqcCoeffs, const REAL8 omega, SpinEOBParams *ak, const REAL8 H, const UINT4 lMax, const UINT4 SpinAlignedEOBversion)
static REAL8 XLALInspiralSpinFactorizedFluxOptimized(REAL8Vector *values, EOBNonQCCoeffs *nqcCoeffs, const REAL8 omega, SpinEOBParams *ak, const REAL8 H, const INT4 lMax, const UINT4 SpinAlignedEOBversion)
This function calculates the spin factorized-resummed GW energy flux for given dynamical variables.
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 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 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.
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 XLALSpinHcapExactDerivWRTParam(const INT4 paramIdx, const REAL8 values[], SpinEOBParams *params)
Calculate the derivative of the Hamiltonian w.r.t.
REAL8 XLALSimInspiralEOBPACalculateMassRatio(const REAL8 m1, const REAL8 m2)
Function which calculates the mass ratio q from the masses m1 and m2.
REAL8 XLALSimInspiralEOBPACalculatea(REAL8 X, REAL8 chi)
Function which calculates the spin parameter a.
REAL8 XLALSimIMRSpinAlignedEOBPACalculateOmega(REAL8 polarDynamics[], REAL8 dr, SpinEOBParams *seobParams, LALDict *LALParams)
Function which calculates the frequency Omega.
REAL8 XLALSimInspiralEOBPACalculatedr(REAL8 rStart, REAL8 rFinal, UINT4 rSize)
Function which calculates the spacing of the radial grid.
REAL8 XLALSimInspiralEOBPACalculateSymmetricMassRatio(const REAL8 q)
Function which calculates the symmetric mass ratio nu from the mass ratio q.
REAL8 XLALSimInspiralEOBPACalculateSstar(REAL8 X1, REAL8 X2, REAL8 chi1, REAL8 chi2)
Function which calculates the spin parameter Sstar (S*)
REAL8 XLALSimInspiralEOBPostAdiabaticFinalRadiusAlternative(REAL8 a)
Function which calculates the final radius at which the post-adiabatic routine stops.
REAL8 XLALSimInspiralEOBPACalculateNewtonianj0(REAL8 r)
Function which calculates the circular angular momentum j0.
REAL8 XLALSimInspiralEOBPACalculateX2(const REAL8 nu)
Function which calculates the parameter X2 from the symmetric mass ratio nu.
REAL8 XLALSimInspiralEOBPACalculateX1(REAL8 nu)
Function which calculates the parameter X1 from the symmetric mass ratio nu.
int XLALCumulativeIntegral3(REAL8Vector *XVec, REAL8Vector *YVec, REAL8Vector *integralVec)
Function which calculates the 3-order cumulative derivative of a numerical function.
int XLALFDDerivative1Order8(REAL8Vector *XVec, REAL8Vector *YVec, REAL8Vector *derivativeVec)
Function which calculates the 8-order first finite difference derivative of a numerical function.
int XLALSimInspiralEOBPAMeanValueOrder8(REAL8Vector *inputVec, REAL8Vector *meanVec)
Function which performs an 8-order mean smoothing of a vector.
int XLALRescaleREAL8Vector(REAL8Vector *Vec, REAL8 factor, REAL8Vector *rescaledVec)
This function rescales each element of an array by a given factor.
REAL8 XLALSimInspiralEOBPAPartialHByPartialr(REAL8 h, REAL8 r, REAL8 prstar, REAL8 pphi, SpinEOBParams *seobParams, LALDict *LALParams)
Function which calculates the partial derivative dH/dr.
REAL8 XLALSimInspiralEOBPAFluxWrapper(REAL8 r, REAL8 prstar, REAL8 pphi, REAL8 omega, SpinEOBParams *seobParams, EOBNonQCCoeffs *nqcCoeffs, LALDict *LALParams)
A wrapper for the factorized flux, depending on the user choices.
double XLALSimInspiralEOBPostAdiabaticdpphiFunc(REAL8 pphi_sol, void *params)
Function which implements eq.
double XLALSimInspiralEOBPostAdiabaticdprstarFunc(REAL8 prstar_sol, void *params)
Function which implements eq.
int XLALSimInspiralEOBPACalculateRadialGrid(REAL8Vector *rVec, LALDict *LALParams)
Function which comstructs the radial grid on which the post-adiabatic approximation will be computed.
REAL8 XLALSimInspiralEOBPAHamiltonianWrapper(REAL8 r, REAL8 prstar, REAL8 pphi, SpinEOBHCoeffs *seobCoeffs, LALDict *LALParams)
A wrapper for the SEOB Hamiltonian, depending on the user choices.
REAL8 XLALSimInspiralEOBPAPartialHByPartialprstar(REAL8 h, REAL8 r, REAL8 prstar, REAL8 pphi, SpinEOBParams *seobParams, LALDict *LALParams)
Function which calculates the partial derivative dH/dprstar.
int XLALSimInspiralEOBPACalculatePostAdiabaticDynamics(REAL8Vector *rVec, REAL8Vector *phiVec, REAL8Vector *dphiBydrVec, REAL8Vector *prstarVec, REAL8Vector *dprstarBydrVec, REAL8Vector *pphiVec, REAL8Vector *dpphiBydrVec, REAL8Vector *dtBydrVec, REAL8Vector *csiVec, REAL8Vector *omegaVec, SpinEOBParams *seobParams, EOBNonQCCoeffs *nqcCoeffs, LALDict *LALParams)
This function calculates the (n-th order) post-adiabatic approximation of the inspiral dynamics.
int XLALSimInspiralEOBPostAdiabatic(REAL8Array **dynamics, REAL8 m1, REAL8 m2, REAL8 spin1z, REAL8 spin2z, const REAL8Vector initVals, UINT4 SpinAlignedEOBversion, SpinEOBParams *seobParams, EOBNonQCCoeffs *nqcCoeffs, LALDict *PAParams)
This function generates post-adiabatic inspiral for spin-aligned binary in the SEOB formalism.
#define ROOT_SOLVER_REL_TOL
int XLALOffsetREAL8Vector(REAL8Vector *Vec, REAL8 offset, REAL8Vector *offsetVec)
Function which add a constant to each element of an array.
int XLALSimInspiralEOBPACalculateAdiabaticDynamics(REAL8Vector *rVec, REAL8Vector *phiVec, REAL8Vector *prstarVec, REAL8Vector *pphiVec, REAL8Vector *pphi0Vec, REAL8Vector *dpphiBydrVec, REAL8Vector *csiVec, REAL8Vector *omegaVec, SpinEOBParams *seobParams, LALDict *LALParams)
This function calculates the adiabatic (0th order PA) approximation of the inspiral dynamics.
int XLALReverseREAL8Vector(REAL8Vector *Vec, REAL8Vector *reverseVec)
Function which reverses a 1D array.
int XLALSimInspiralEOBPostAdiabaticRootFinder(struct PostAdiabaticRoot *result, double(*Func)(REAL8, void *), struct PostAdiabaticRootSolveParams *params, REAL8 x_lower, REAL8 x_upper, REAL8 absTol, REAL8 relTol, INT2 parity)
Root finder function which is used for computing the adiabatic and post-adiabatic approximations.
double XLALSimInspiralEOBPostAdiabaticj0Func(REAL8 j0_sol, void *params)
Function which implements eq.
#define ROOT_SOLVER_ABS_TOL
REAL8Array * XLALCreateREAL8ArrayL(UINT4,...)
REAL8Vector * XLALCreateREAL8Vector(UINT4 length)
void XLALDestroyREAL8Vector(REAL8Vector *vector)
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
The coefficients which are used in calculating the non-quasicircular correction to the EOBNRv2 model.
SpinEOBParams * seobParams
EOBNonQCCoeffs * nqcCoeffs
Parameters for the spinning EOB model, used in calculating the Hamiltonian.
Parameters for the spinning EOB model.
SpinEOBHCoeffs * seobCoeffs