1 #ifndef _LALSIMIMRSPINPRECEOBEULERANGLES_C
2 #define _LALSIMIMRSPINPRECEOBEULERANGLES_C
27 R->
data[3*0 + 0] = e1p[0];
28 R->
data[3*1 + 0] = e1p[1];
29 R->
data[3*2 + 0] = e1p[2];
30 R->
data[3*0 + 1] = e2p[0];
31 R->
data[3*1 + 1] = e2p[1];
32 R->
data[3*2 + 1] = e2p[2];
33 R->
data[3*0 + 2] = e3p[0];
34 R->
data[3*1 + 2] = e3p[1];
35 R->
data[3*2 + 2] = e3p[2];
49 return -1. * alphadot * cos(
beta);
66 const UINT4 retLenLow,
67 const REAL8 InitialAlpha,
68 const REAL8 InitialGamma,
70 const UINT4 use_optimized ) {
72 REAL8Vector *LN_x = NULL, *LN_y = NULL, *LN_z = NULL;
73 REAL8 tmpR[3], tmpRdot[3], magLN;
75 REAL8 inGamma = InitialGamma;
81 gsl_spline *x_spline = gsl_spline_alloc( gsl_interp_cspline, retLenLow );
82 gsl_spline *y_spline = gsl_spline_alloc( gsl_interp_cspline, retLenLow );
83 gsl_spline *z_spline = gsl_spline_alloc( gsl_interp_cspline, retLenLow );
85 gsl_interp_accel *x_acc = gsl_interp_accel_alloc();
86 gsl_interp_accel *y_acc = gsl_interp_accel_alloc();
87 gsl_interp_accel *z_acc = gsl_interp_accel_alloc();
89 gsl_spline_init( x_spline, tVec.
data, posVecx.
data, retLenLow );
90 gsl_spline_init( y_spline, tVec.
data, posVecy.
data, retLenLow );
91 gsl_spline_init( z_spline, tVec.
data, posVecz.
data, retLenLow );
93 for(
i=0;
i < retLenLow;
i++ )
95 tmpR[0] = posVecx.
data[
i]; tmpR[1] = posVecy.
data[
i]; tmpR[2] = posVecz.
data[
i];
96 tmpRdot[0] = gsl_spline_eval_deriv( x_spline, tVec.
data[
i], x_acc );
97 tmpRdot[1] = gsl_spline_eval_deriv( y_spline, tVec.
data[
i], y_acc );
98 tmpRdot[2] = gsl_spline_eval_deriv( z_spline, tVec.
data[
i], z_acc );
100 LN_x->
data[
i] = tmpR[1] * tmpRdot[2] - tmpR[2] * tmpRdot[1];
101 LN_y->data[
i] = tmpR[2] * tmpRdot[0] - tmpR[0] * tmpRdot[2];
102 LN_z->data[
i] = tmpR[0] * tmpRdot[1] - tmpR[1] * tmpRdot[0];
104 magLN = sqrt(LN_x->
data[
i] * LN_x->
data[
i] + LN_y->data[
i] * LN_y->data[
i]
105 + LN_z->data[
i] * LN_z->data[
i]);
106 LN_x->
data[
i] /= magLN; LN_y->data[
i] /= magLN; LN_z->data[
i] /= magLN;
110 if (fabs(LN_x->
data[
i]) <= 1.e-10 && fabs(LN_y->data[
i]) <=1.e-10){
111 Alpha->
data[
i] = 0.0;
114 Alpha->
data[
i] = atan2( LN_y->data[
i], LN_x->
data[
i] )
116 if (
i==0 && flag_highSR != 1){
117 inGamma = -Alpha->
data[
i];
121 while(
i>0 && Alpha->
data[
i] - Alpha->
data[
i-1] > 5. ) {
122 *phaseCounterA = *phaseCounterA - 1;
125 while(
i && Alpha->
data[
i] - Alpha->
data[
i-1] < -5. ) {
126 *phaseCounterA = *phaseCounterA + 1;
129 if (LN_z->data[
i] >1.) {
132 if (LN_z->data[
i] <-1.) {
135 if ( flag_highSR == 1) {
136 Alpha->
data[
i] -= (Alpha->
data[0] - InitialAlpha);
139 if (fabs(1.0 - LN_z->data[
i]) < 1.e-12){
142 LN_y->data[
i]*LN_y->data[
i]);
144 Beta->
data[
i] = atan2(LN_xy, LN_z->data[
i]);
147 Beta->
data[
i] = acos( LN_z->data[
i] );
150 *phaseCounterB = *phaseCounterB - 1;
155 gsl_spline_init( x_spline, tVec.
data, Alpha->
data, retLenLow );
156 gsl_spline_init( y_spline, tVec.
data, Beta->
data, retLenLow );
163 Gamma->
data[0] = inGamma;
165 for(
i = 1;
i < retLenLow;
i++ ){
166 double t1 = tVec.
data[
i-1];
167 double t2 = tVec.
data[
i];
175 gsl_integration_workspace * precEulerw = gsl_integration_workspace_alloc (1000);
176 gsl_function precEulerF;
177 REAL8 precEulerresult = 0, precEulererror = 0;
179 precEulerF.params = &precEulerparams;
180 for(
i = 1;
i < retLenLow;
i++ ) {
181 gsl_integration_qags (&precEulerF, tVec.
data[
i-1], tVec.
data[
i], 1
e-9, 1
e-9, 1000, precEulerw, &precEulerresult, &precEulererror);
182 Gamma->
data[
i] = Gamma->
data[
i-1] + precEulerresult;
184 gsl_integration_workspace_free( precEulerw );
187 gsl_spline_free( x_spline );
188 gsl_spline_free( y_spline );
189 gsl_spline_free( z_spline );
190 gsl_interp_accel_free( x_acc );
191 gsl_interp_accel_free( y_acc );
192 gsl_interp_accel_free( z_acc );
215 const REAL8 JframeEx[],
216 const REAL8 JframeEy[],
217 const REAL8 JframeEz[]
219 REAL8 LframeEx[3] = {0,0,0}, LframeEy[3] = {0,0,0}, LframeEz[3] = {0,0,0};
220 LframeEx[0] = cos(aI2P)*cos(bI2P)*cos(gI2P) - sin(aI2P)*sin(gI2P);
221 LframeEx[1] = sin(aI2P)*cos(bI2P)*cos(gI2P) + cos(aI2P)*sin(gI2P);
222 LframeEx[2] = -sin(bI2P)*cos(gI2P);
223 LframeEy[0] = -cos(aI2P)*cos(bI2P)*sin(gI2P) - sin(aI2P)*cos(gI2P);
224 LframeEy[1] = -sin(aI2P)*cos(bI2P)*sin(gI2P) + cos(aI2P)*cos(gI2P);
225 LframeEy[2] = sin(bI2P)*sin(gI2P);
230 normJ = JframeEz[0]*JframeEz[0]+JframeEz[1]*JframeEz[1]+JframeEz[2]*JframeEz[2];
231 normLz = LframeEz[0]*LframeEz[0]+LframeEz[1]*LframeEz[1]+LframeEz[2]*LframeEz[2];
232 *aP2J = atan2(JframeEz[0]*LframeEy[0]+JframeEz[1]*LframeEy[1]+JframeEz[2]*LframeEy[2],
233 JframeEz[0]*LframeEx[0]+JframeEz[1]*LframeEx[1]+JframeEz[2]*LframeEx[2]);
234 REAL8 cosarg = JframeEz[0]*LframeEz[0]+JframeEz[1]*LframeEz[1]+JframeEz[2]*LframeEz[2];
235 if ( cosarg >= 1. && cosarg < 1. + 1.e-10 ) {
238 if ( cosarg <= -1. && cosarg > -1. - 1.e-10 ) {
241 *bP2J = acos( cosarg );
243 cosarg = (JframeEz[0]*LframeEz[0]+JframeEz[1]*LframeEz[1]+JframeEz[2]*LframeEz[2])/sqrt(normJ*normLz);
244 if ( cosarg >= 1. && cosarg < 1. + 1.e-10 ) {
247 if ( cosarg <= -1. && cosarg > -1. - 1.e-10 ) {
250 *bP2J = acos( cosarg );
252 *gP2J = atan2( JframeEy[0]*LframeEz[0]+JframeEy[1]*LframeEz[1]+JframeEy[2]*LframeEz[2],
253 -(JframeEx[0]*LframeEz[0]+JframeEx[1]*LframeEz[1]+JframeEx[2]*LframeEz[2]));
256 if ( fabs(*bP2J-
LAL_PI) < 1.e-10){
258 *aP2J = atan2( JframeEx[1], JframeEx[0]);
261 if ( fabs(*bP2J) < 1.e-10){
263 *aP2J = atan2( JframeEx[1], JframeEx[0]);
static double f_alphadotcosi(double x, void *inparams)
Computes RHS of ODE for gamma.
static UNUSED void EulerAnglesP2J(REAL8 *aP2J, REAL8 *bP2J, REAL8 *gP2J, const REAL8 aI2P, const REAL8 bI2P, const REAL8 gI2P, const REAL8 LNhx, const REAL8 LNhy, const REAL8 LNhz, const REAL8 JframeEx[], const REAL8 JframeEy[], const REAL8 JframeEz[])
Given Euler angles to go from initial inertial frame to precessing frama and the LNhat vector,...
static UNUSED int RotationMatrixActiveFromBasisVectors(REAL8Array *R, const REAL8 e1p[], const REAL8 e2p[], const REAL8 e3p[])
Active rotation matrix from orthonormal basis (e1, e2, e3) to (e1', e2', e3') Input are e1',...
static UNUSED int EulerAnglesI2P(REAL8Vector *Alpha, REAL8Vector *Beta, REAL8Vector *Gamma, INT4 *phaseCounterA, INT4 *phaseCounterB, const REAL8Vector tVec, const REAL8Vector posVecx, const REAL8Vector posVecy, const REAL8Vector posVecz, const UINT4 retLenLow, const REAL8 InitialAlpha, const REAL8 InitialGamma, UINT4 flag_highSR, const UINT4 use_optimized)
Given the trajectory in an inertial frame, this computes Euler angles of the roation from the inertia...
static UNUSED int EulerAnglesZYZFromRotationMatrixActive(REAL8 *alpha, REAL8 *beta, REAL8 *gamma, REAL8Array *R)
Computes the Euler angles in the (z,y,z) convention corresponding to a given 3*3 active rotation matr...
static double beta(const double a, const double b, const sysq *system)
Internal function that computes the spin-orbit couplings.
REAL8Vector * XLALCreateREAL8Vector(UINT4 length)
void XLALDestroyREAL8Vector(REAL8Vector *vector)
gsl_spline * alpha_spline
gsl_interp_accel * alpha_acc
gsl_interp_accel * beta_acc