Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALSimulation 6.2.0.1-8a6b96f
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
InitialSpinRotationTest.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2016 Riccardo Sturani
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 <stdlib.h>
21#include <math.h>
22#include <lal/LALSimInspiral.h>
23#include <lal/LALConstants.h>
24#include <lal/LALSimInspiralWaveformFlags.h>
25#include <lal/Units.h>
26#include <lal/XLALError.h>
27
28#define EPSILON 1.e-11
29
30static int compare(
31 REAL8 val1,
32 REAL8 val2)
33{
34 if (fabs(val1 - val2) > EPSILON)
35 return 1;
36 else
37 return 0;
38}
39
40int main (int argc, char **argv)
41{
42 /* Ignore unused parameters. */
43 (void)argc;
44 (void)argv;
45
46 const UINT4 Ntest=8;
47 REAL8 idxr;
48 int ret = 0;
49 int errCode=0;
50 REAL8 incl, spin1x, spin1y, spin1z, spin2x, spin2y, spin2z;
51 REAL8 thetaJN, phiJL, theta1, theta2, phi12, chi1, chi2, phiRef;
52 REAL8 inclIn,s1xIn, s1yIn, s1zIn, s2xIn, s2yIn, s2zIn;
53 REAL8 m1, m2, fRef;
54 const REAL8 m1min=1.4;
55 const REAL8 m1max=100.;
56 const REAL8 m2min=1.4;
57 const REAL8 m2max=50.;
58
59 LALSimInspiralWaveformFlags *waveFlag=XLALSimInspiralCreateWaveformFlags();
60
61 for (UINT4 idx=0;idx<=Ntest;idx++) {
62 idxr=((REAL8)idx)/((REAL8) Ntest);
63 thetaJN = idxr*LAL_PI;
64 phiJL = idxr*2.*LAL_PI;
65 theta1 = idxr*LAL_PI;
66 theta2 = (1.-idxr)*LAL_PI;
67 phi12 = idxr*2.*LAL_PI;
68 chi1 = idxr;
69 chi2 = (1.-idxr);
70 m1=m1min+idxr*(m1max-m1min);
71 m2=m2min+idxr*(m2max-m2min);
72 fRef=0.5/(sqrt(6.)*LAL_PI*(m1+m2)*LAL_MTSUN_SI);
73 phiRef=idxr*LAL_PI;
74
75 s1xIn=chi1*sin(theta1);
76 s1yIn=0.;
77 s1zIn=chi1*cos(theta1);
78 s2xIn=chi2*sin(theta2)*cos(phi12);
79 s2yIn=chi2*sin(theta2)*sin(phi12);
80 s2zIn=chi2*cos(theta2);
81 inclIn=thetaJN;
82
83 errCode=XLALSimInspiralTransformPrecessingNewInitialConditions(&incl, &spin1x, &spin1y, &spin1z, &spin2x, &spin2y, &spin2z, thetaJN, phiJL, theta1, theta2, phi12, chi1, chi2, m1*LAL_MSUN_SI, m2*LAL_MSUN_SI, fRef, phiRef);
84 ret += compare(chi1*chi1, spin1x*spin1x+spin1y*spin1y+spin1z*spin1z);
85 ret += compare(chi2*chi2, spin2x*spin2x+spin2y*spin2y+spin2z*spin2z);
86 ret += compare(s1zIn, spin1z);
87 ret += compare(s2zIn, spin2z);
88 ret += compare(s1xIn*s2xIn+s1yIn*s2yIn+s1zIn*s2zIn, spin1x*spin2x+spin1y*spin2y+spin1z*spin2z);
89 ret += compare(s1xIn*s2xIn+s1yIn*s2yIn, spin1x*spin2x+spin1y*spin2y );
90
92 errCode+=XLALSimInspiralInitialConditionsPrecessingApproxs(&incl, &spin1x, &spin1y, &spin1z, &spin2x, &spin2y, &spin2z, inclIn, s1xIn, s1yIn, s1zIn, s2xIn, s2yIn, s2zIn, m1*LAL_MSUN_SI, m2*LAL_MSUN_SI, fRef, phiRef, XLALSimInspiralGetFrameAxis(waveFlag));
93 ret += compare(s1xIn*s2xIn+s1yIn*s2yIn+s1zIn*s2zIn,spin1x*spin2x+spin1y*spin2y+spin1z*spin2z);
94 ret += compare(chi1*chi1, spin1x*spin1x+spin1y*spin1y+spin1z*spin1z);
95 ret += compare(chi2*chi2, spin2x*spin2x+spin2y*spin2y+spin2z*spin2z);
96 ret += compare(s1zIn,spin1x*sin(incl)+spin1z*cos(incl));
97 ret += compare(s2zIn,spin2x*sin(incl)+spin2z*cos(incl));
98 ret += compare(inclIn,incl);
99
101 errCode+=XLALSimInspiralInitialConditionsPrecessingApproxs(&incl, &spin1x, &spin1y, &spin1z, &spin2x, &spin2y, &spin2z, inclIn, s1xIn, s1yIn, s1zIn, s2xIn, s2yIn, s2zIn, m1*LAL_MSUN_SI, m2*LAL_MSUN_SI, fRef, phiRef, XLALSimInspiralGetFrameAxis(waveFlag));
102 ret += compare(chi1*chi1, spin1x*spin1x+spin1y*spin1y+spin1z*spin1z);
103 ret += compare(chi2*chi2, spin2x*spin2x+spin2y*spin2y+spin2z*spin2z);
104 ret += compare(s1xIn*s2xIn+s1yIn*s2yIn+s1zIn*s2zIn,spin1x*spin2x+spin1y*spin2y+spin1z*spin2z);
105 ret += compare(s1xIn*sin(incl)+s1zIn*cos(incl),spin1x*sin(inclIn)+spin1z*cos(inclIn));
106 ret += compare(s2xIn*sin(incl)+s2zIn*cos(incl),spin2x*sin(inclIn)+spin2z*cos(inclIn));
107 ret += compare(inclIn,incl);
108
110errCode+=XLALSimInspiralInitialConditionsPrecessingApproxs(&incl, &spin1x, &spin1y, &spin1z, &spin2x, &spin2y, &spin2z, inclIn, s1xIn, s1yIn, s1zIn, s2xIn, s2yIn, s2zIn, m1*LAL_MSUN_SI, m2*LAL_MSUN_SI, fRef, phiRef, XLALSimInspiralGetFrameAxis(waveFlag));
111 ret += compare(chi1*chi1, spin1x*spin1x+spin1y*spin1y+spin1z*spin1z);
112 ret += compare(chi2*chi2, spin2x*spin2x+spin2y*spin2y+spin2z*spin2z);
113 ret += compare(s1xIn*s2xIn+s1yIn*s2yIn+s1zIn*s2zIn,spin1x*spin2x+spin1y*spin2y+spin1z*spin2z);
114 }
115
116 if ( (ret == 0) && (errCode == 0) )
117 {
118 fprintf(stdout, "\nInitial condition rotation test passed.\n");
119 }
120 else
121 {
122 fprintf(stderr, "\nFAILURE: %u Initial condition rotation test failed.\n", ret);
123 }
124
125 return ret;
126}
#define EPSILON
int main(int argc, char **argv)
static int compare(REAL8 val1, REAL8 val2)
#define fprintf
#define LAL_MSUN_SI
#define LAL_PI
#define LAL_MTSUN_SI
double REAL8
uint32_t UINT4
#define LAL_SIM_INSPIRAL_FRAME_AXIS_DEFAULT
@ LAL_SIM_INSPIRAL_FRAME_AXIS_VIEW
Set z-axis along direction of GW propagation (line of sight)
@ LAL_SIM_INSPIRAL_FRAME_AXIS_TOTAL_J
Set z-axis along the initial total angular momentum.
int XLALSimInspiralInitialConditionsPrecessingApproxs(REAL8 *inc, REAL8 *S1x, REAL8 *S1y, REAL8 *S1z, REAL8 *S2x, REAL8 *S2y, REAL8 *S2z, const REAL8 inclIn, const REAL8 S1xIn, const REAL8 S1yIn, const REAL8 S1zIn, const REAL8 S2xIn, const REAL8 S2yIn, const REAL8 S2zIn, const REAL8 m1, const REAL8 m2, const REAL8 fRef, const REAL8 phiRef, LALSimInspiralFrameAxis axisChoice)
Function to specify the desired orientation of the spin components of a precessing binary.
void XLALSimInspiralSetFrameAxis(LALSimInspiralWaveformFlags *waveFlags, LALSimInspiralFrameAxis axisChoice)
Set the LALSimInspiralFrameAxis within a LALSimInspiralWaveformFlags struct.
LALSimInspiralWaveformFlags * XLALSimInspiralCreateWaveformFlags(void)
Create a new LALSimInspiralWaveformFlags struct with all flags set to their default values.
LALSimInspiralFrameAxis XLALSimInspiralGetFrameAxis(LALSimInspiralWaveformFlags *waveFlags)
Get the LALSimInspiralFrameAxis within a LALSimInspiralWaveformFlags struct, or LAL_SIM_INSPIRAL_FRAM...
int XLALSimInspiralTransformPrecessingNewInitialConditions(REAL8 *incl, REAL8 *S1x, REAL8 *S1y, REAL8 *S1z, REAL8 *S2x, REAL8 *S2y, REAL8 *S2z, const REAL8 thetaJN, const REAL8 phiJL, const REAL8 theta1, const REAL8 theta2, const REAL8 phi12, const REAL8 chi1, const REAL8 chi2, const REAL8 m1_SI, const REAL8 m2_SI, const REAL8 fRef, const REAL8 phiRef)
Transform Precessing Parameters.