Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALSimulation 6.2.0.1-b246709
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
SpinTaylorHlmsTest.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2018 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 <math.h>
21#include <stdlib.h>
22#include <time.h>
23#include <sys/types.h>
24
25#include <lal/Units.h>
26#include <lal/SphericalHarmonics.h>
27#include <lal/LALConstants.h>
28#include <lal/LALDatatypes.h>
29#include <lal/LALSimInspiral.h>
30#include <lal/LALSimInspiralWaveformParams.h>
31#include <lal/LALSimSphHarmMode.h>
32
33int main(void){
34
35 /* This codes checks that the SpinTaylor approximant constructed on
36 *
37 */
38
39 REAL8TimeSeries *V=NULL;
40 REAL8TimeSeries *Phi=NULL;
41 REAL8TimeSeries *S1x=NULL;
42 REAL8TimeSeries *S1y=NULL;
43 REAL8TimeSeries *S1z=NULL;
44 REAL8TimeSeries *S2x=NULL;
45 REAL8TimeSeries *S2y=NULL;
46 REAL8TimeSeries *S2z=NULL;
47 REAL8TimeSeries *LNhx=NULL;
48 REAL8TimeSeries *LNhy=NULL;
49 REAL8TimeSeries *LNhz=NULL;
50 REAL8TimeSeries *E1x=NULL;
51 REAL8TimeSeries *E1y=NULL;
52 REAL8TimeSeries *E1z=NULL;
53
54 REAL8 f_low = 50.;
55 REAL8 f_ref=50.;
56 REAL8 sample_rate = 8192.;
57 REAL8 dT=1./sample_rate;
58 REAL8 m1=21.;
59 REAL8 m2=11.;
60 REAL8 m1_SI=m1*LAL_MSUN_SI;
61 REAL8 m2_SI=m2*LAL_MSUN_SI;
62 REAL8 dist_SI=1.e6*LAL_PC_SI;
63 REAL8 phi_ref=0.4;
64 REAL8 s1x=0.3;
65 REAL8 s1y=0.2;
66 REAL8 s1z=0.5;
67 REAL8 s2x=0.;
68 REAL8 s2y=-0.4;
69 REAL8 s2z=0.;
70 REAL8 incl=0.1;
71 REAL8 lam1=1.e3;
72 REAL8 lam2=5.e2;
73 const UINT4 LMAX=4;
74 const INT4 ampO=(INT4) LMAX-2;
75 /*Test will fail if ampO>LMAX-2,
76 * as polarizations will involve terms belonging to l higher than LMAX.
77 * The highest possible LMAX is 4, as only l=2,3,4 hlm modes have been coded.
78 */
79
80 LALDict *params=XLALCreateDict();
84
85 REAL8TimeSeries *hp_std=NULL,*hc_std=NULL;
86 Approximant apprx=XLALGetApproximantFromString("SpinTaylorT4");
87 errCode +=XLALSimInspiralChooseTDWaveform(&hp_std,&hc_std,m1_SI,m2_SI,s1x,s1y,s1z,s2x,s2y,s2z,dist_SI,incl,phi_ref,0.,0.,0.,dT,f_low,f_ref,params,apprx);
88
89 REAL8 inclination,spin1x,spin1y,spin1z,spin2x,spin2y,spin2z;
90 errCode +=XLALSimInspiralInitialConditionsPrecessingApproxs(&inclination,&spin1x,&spin1y,&spin1z,&spin2x,&spin2y,&spin2z,incl,s1x,s1y,s1z,s2x,s2y,s2z,m1,m2,f_ref,phi_ref,XLALSimInspiralWaveformParamsLookupFrameAxis(params));
91
92 REAL8 lnhx=sin(inclination);
93 REAL8 lnhy=0.;
94 REAL8 lnhz=cos(inclination);
95 REAL8 e1x=0.;
96 REAL8 e1y=1.;
97 REAL8 e1z=0.;
98 UINT4 idx=0;
99
100 REAL8TimeSeries *hp_drv=NULL,*hc_drv=NULL;
101 errCode+=XLALSimInspiralSpinTaylorDriver(&hp_drv,&hc_drv,&V,&Phi,&S1x,&S1y,&S1z,&S2x,&S2y,&S2z,&LNhx,&LNhy,&LNhz,&E1x,&E1y,&E1z, phi_ref, dT, m1_SI, m2_SI, f_low, f_ref, dist_SI, spin1x, spin1y, spin1z, spin2x, spin2y, spin2z, lnhx, lnhy, lnhz, e1x, e1y, e1z, params, apprx);
102 // Additional rotation by polarization angle Pi/2 as done in ChooseWf
103 for (idx=0;idx<hp_drv->data->length;idx++) {
104 hp_drv->data->data[idx]*=-1.;
105 hc_drv->data->data[idx]*=-1.;
106 }
107
108 UINT4 l;
109 INT4 m;
110 LALValue *modearray=XLALSimInspiralCreateModeArray();
111 for (l=2; l<=LMAX; l++)
113
114 SphHarmTimeSeries *Hlms_orb=NULL;
115 errCode+=XLALSimInspiralSpinTaylorHlmModesFromOrbit(&Hlms_orb,V,Phi,LNhx,LNhy,LNhz,E1x,E1y,E1z,S1x,S1y,S1z,S2x,S2y,S2z,m1_SI,m2_SI,dist_SI,ampO,modearray);
130
131 SphHarmTimeSeries *Hlms_modes=XLALSimInspiralChooseTDModes(0.,dT, m1_SI, m2_SI, s1x, s1y, s1z, s2x, s2y, s2z, f_low, f_ref, dist_SI, params, LMAX, apprx);
132
133 UINT4 lmax=XLALSphHarmTimeSeriesGetMaxL(Hlms_orb);
135 REAL8TimeSeries *hp_orb=XLALCreateREAL8TimeSeries("H+ from orbit", &hlm_tmp->epoch, 0., dT, &lalStrainUnit, hlm_tmp->data->length);
136 REAL8TimeSeries *hc_orb=XLALCreateREAL8TimeSeries("Hx from orbit", &hlm_tmp->epoch, 0., dT, &lalStrainUnit, hlm_tmp->data->length);
137 hlm_tmp=XLALSphHarmTimeSeriesGetMode(Hlms_modes,2,2);
138 REAL8TimeSeries *hp_modes=XLALCreateREAL8TimeSeries("H+ from mods", &hlm_tmp->epoch, 0., dT, &lalStrainUnit, hlm_tmp->data->length);
139 REAL8TimeSeries *hc_modes=XLALCreateREAL8TimeSeries("Hx from modes ",&hlm_tmp->epoch, 0., dT, &lalStrainUnit, hlm_tmp->data->length);
140 memset(hp_orb->data->data, 0, sizeof(REAL8)*hc_orb->data->length);
141 memset(hc_orb->data->data, 0, sizeof(REAL8)*hc_orb->data->length);
142 memset(hp_modes->data->data, 0, sizeof(REAL8)*hp_modes->data->length);
143 memset(hc_modes->data->data, 0, sizeof(REAL8)*hc_modes->data->length);
144
145 for (l=2; l<=lmax; l++) {
146 for (m=-l; m<=(INT4)l; m++) {
147 errCode += XLALSimAddMode(hp_orb, hc_orb, XLALSphHarmTimeSeriesGetMode(Hlms_orb,l,m), 0., 0., l, m, 0);
148 errCode += XLALSimAddMode(hp_modes, hc_modes, XLALSphHarmTimeSeriesGetMode(Hlms_modes,l,m), incl, LAL_PI/2.-phi_ref, l, m, 0);
149 }
150 }
151
152 REAL8 tmp;
153 INT4 ret=0;
154 // We take out of the comparison the last samples
155 UINT4 minlen=hp_orb->data->length;
156 if (minlen>hp_modes->data->length)
157 minlen=hp_modes->data->length;
158 for (idx=1; idx<minlen; idx++) {
159 tmp=sqrt((hp_std->data->data[idx]*hp_std->data->data[idx])+(hc_std->data->data[idx]*hc_std->data->data[idx]));
160 if (fabs(hp_std->data->data[idx]-hp_drv->data->data[idx])>0.01*tmp)
161 ret+=1;
162 if (fabs(hp_std->data->data[idx]-hp_orb->data->data[idx])>0.01*tmp)
163 ret+=1;
164 if ( fabs(hp_std->data->data[idx]-hp_modes->data->data[idx])>0.01*tmp)
165 ret+=1;
166 if (fabs(hc_std->data->data[idx]-hc_drv->data->data[idx])>0.01*tmp)
167 ret+=1;
168 if (fabs(hc_std->data->data[idx]-hc_orb->data->data[idx])>0.01*tmp)
169 ret+=1;
170 if (fabs(hc_std->data->data[idx]-hc_modes->data->data[idx])>0.01*tmp)
171 ret+=1;
172 }
173
174 if ( (ret == 0) && (errCode == 0) ) {
175 fprintf(stdout, "\n Mode vs. polarization test passed.\n");
176 }
177 else {
178 fprintf(stderr, "\nFAILURE: %u %u Mode vs. polarization test failed.\n", ret,errCode);
179 }
180
181 return ret;
182
183}
LALDict * XLALCreateDict(void)
int XLALGetApproximantFromString(const char *waveform)
int XLALSimInspiralSpinTaylorDriver(REAL8TimeSeries **hplus, REAL8TimeSeries **hcross, REAL8TimeSeries **Vout, REAL8TimeSeries **Phiout, REAL8TimeSeries **S1xout, REAL8TimeSeries **S1yout, REAL8TimeSeries **S1zout, REAL8TimeSeries **S2xout, REAL8TimeSeries **S2yout, REAL8TimeSeries **S2zout, REAL8TimeSeries **LNhxout, REAL8TimeSeries **LNhyout, REAL8TimeSeries **LNhzout, REAL8TimeSeries **E1xout, REAL8TimeSeries **E1yout, REAL8TimeSeries **E1zout, REAL8 phiRef, REAL8 deltaT, REAL8 m1_SI, REAL8 m2_SI, REAL8 fStart, REAL8 fRef, REAL8 r, REAL8 s1x, REAL8 s1y, REAL8 s1z, REAL8 s2x, REAL8 s2y, REAL8 s2z, REAL8 lnhatx, REAL8 lnhaty, REAL8 lnhatz, REAL8 e1x, REAL8 e1y, REAL8 e1z, LALDict *LALparams, Approximant approx)
Driver function to generate any of SpinTaylorT1/T5/T4 If the output entries are not null the relative...
INT4 XLALSimInspiralSpinTaylorHlmModesFromOrbit(SphHarmTimeSeries **hlm, REAL8TimeSeries *V, REAL8TimeSeries *Phi, REAL8TimeSeries *LNhx, REAL8TimeSeries *LNhy, REAL8TimeSeries *LNhz, REAL8TimeSeries *e1x, REAL8TimeSeries *e1y, REAL8TimeSeries *e1z, REAL8TimeSeries *S1x, REAL8TimeSeries *S1y, REAL8TimeSeries *S1z, REAL8TimeSeries *S2x, REAL8TimeSeries *S2y, REAL8TimeSeries *S2z, REAL8 m1_SI, REAL8 m2_SI, REAL8 distance, int ampO, LALValue *modearray)
int XLALSimInspiralWaveformParamsInsertTidalLambda1(LALDict *params, REAL8 value)
INT4 XLALSimInspiralWaveformParamsLookupFrameAxis(LALDict *params)
int XLALSimInspiralWaveformParamsInsertTidalLambda2(LALDict *params, REAL8 value)
int XLALSimInspiralWaveformParamsInsertPNAmplitudeOrder(LALDict *params, INT4 value)
int main(void)
#define fprintf
int l
Definition: bh_qnmode.c:135
#define LAL_MSUN_SI
#define LAL_PI
#define LAL_PC_SI
double REAL8
uint32_t UINT4
int32_t INT4
int XLALSimInspiralChooseTDWaveform(REAL8TimeSeries **hplus, REAL8TimeSeries **hcross, const REAL8 m1, const REAL8 m2, const REAL8 S1x, const REAL8 S1y, const REAL8 S1z, const REAL8 S2x, const REAL8 S2y, const REAL8 S2z, const REAL8 distance, const REAL8 inclination, const REAL8 phiRef, const REAL8 longAscNodes, const REAL8 eccentricity, const REAL8 UNUSED meanPerAno, const REAL8 deltaT, const REAL8 f_min, REAL8 f_ref, LALDict *params, const Approximant approximant)
Chooses between different approximants when requesting a waveform to be generated For spinning wavefo...
SphHarmTimeSeries * XLALSimInspiralChooseTDModes(UNUSED REAL8 phiRef, REAL8 deltaT, REAL8 m1, REAL8 m2, REAL8 S1x, REAL8 S1y, REAL8 S1z, REAL8 S2x, REAL8 S2y, REAL8 S2z, REAL8 f_min, REAL8 f_ref, REAL8 distance, LALDict *params, int lmax, Approximant approximant)
Interface to compute a set of -2 spin-weighted spherical harmonic modes for a binary inspiral for a g...
Approximant
Enum that specifies the PN approximant to be used in computing the waveform.
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.
LALValue * XLALSimInspiralCreateModeArray(void)
Create a LALValue pointer to store the mode array.
LALValue * XLALSimInspiralModeArrayActivateAllModesAtL(LALValue *modes, unsigned l)
int XLALSimAddMode(REAL8TimeSeries *hplus, REAL8TimeSeries *hcross, COMPLEX16TimeSeries *hmode, REAL8 theta, REAL8 phi, int l, int m, int sym)
Multiplies a mode h(l,m) by a spin-2 weighted spherical harmonic to obtain hplus - i hcross,...
COMPLEX16TimeSeries * XLALSphHarmTimeSeriesGetMode(SphHarmTimeSeries *ts, UINT4 l, INT4 m)
Get the time series of a waveform's (l,m) spherical harmonic mode from a SphHarmTimeSeries linked lis...
UINT4 XLALSphHarmTimeSeriesGetMaxL(SphHarmTimeSeries *ts)
Get the largest l index of any mode in the SphHarmTimeSeries linked list.
static const INT4 m
void XLALDestroyREAL8TimeSeries(REAL8TimeSeries *series)
REAL8TimeSeries * XLALCreateREAL8TimeSeries(const CHAR *name, const LIGOTimeGPS *epoch, REAL8 f0, REAL8 deltaT, const LALUnit *sampleUnits, size_t length)
const LALUnit lalStrainUnit
COMPLEX16Sequence * data
REAL8Sequence * data
REAL8 * data
Structure to carry a collection of spherical harmonic modes in COMPLEX16 time series.
Definition: burst.c:245
double V
Definition: unicorn.c:25