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
WaveformFromCacheTest.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2013 Evan Ochsner
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 Evan Ochsner
22 *
23 * \file
24 *
25 * \brief Check ChooseTD/FDWaveformFromCache is consistent with ChooseWaveoform
26 */
27
28#include <math.h>
29#include <lal/LALSimInspiralWaveformCache.h>
30#include <lal/FrequencySeries.h>
31#include <time.h>
32#include <lal/LALConstants.h>
33
34int main(void) {
35 clock_t s1, e1, s2, e2;
36 double diff1, diff2;
37 unsigned int i;
38 REAL8 plusdiff, crossdiff, temp;
39 REAL8TimeSeries *hplus = NULL;
40 REAL8TimeSeries *hcross = NULL;
41 REAL8TimeSeries *hplusC = NULL;
42 REAL8TimeSeries *hcrossC = NULL;
43 COMPLEX16FrequencySeries *hptilde = NULL;
44 COMPLEX16FrequencySeries *hctilde = NULL;
45 COMPLEX16FrequencySeries *hptildeC = NULL;
46 COMPLEX16FrequencySeries *hctildeC = NULL;
47 REAL8 m1 = 10. * LAL_MSUN_SI, m2 = 10 * LAL_MSUN_SI;
48 REAL8 s1x = 0., s1y = 0., s1z = 0., s2x = 0., s2y = 0., s2z = 0.;
49 REAL8 f_min = 40., f_ref = 0., lambda1 = 0., lambda2 = 0.i, f_max = 0.;
50 REAL8 dt = 1./16384., df = 1./16.;
51 int ret, phaseO = 7, ampO = 0;
52 Approximant approx = SEOBNRv1;
53 Approximant approxFD = TaylorF2;
54 REAL8 phiref1 = 0., phiref2 = 0.3;
55 REAL8 inc1 = 0.2, inc2 = 1.3;
56 REAL8 dist1 = 1.e6 * LAL_PC_SI, dist2 = 2.e6 * LAL_PC_SI;
58 LALDict *LALpars=XLALCreateDict();
63
64 //
65 // Test TD path with SEOBNRv1
66 //
67
68 // Generate waveform via usual ChooseTDWaveform path
69 s1 = clock();
70 ret = XLALSimInspiralChooseTDWaveform(&hplus, &hcross,
71 m1, m2, s1x, s1y, s1z, s2x, s2y, s2z,
72 dist1, inc1,
73 phiref1, 0., 0., 0., dt, f_min, f_ref,
74 LALpars, approx);
75 e1 = clock();
76 diff1 = (double) (e1 - s1) / CLOCKS_PER_SEC;
77 if( ret == XLAL_FAILURE )
79
80 // Generate waveform via FromCache - will call ChooseWaveform this 1st time
81 s2 = clock();
82 ret = XLALSimInspiralChooseTDWaveformFromCache(&hplusC, &hcrossC, phiref1,
83 dt, m1, m2, s1x, s1y, s1z, s2x, s2y, s2z, f_min, f_ref, dist1, inc1,
84 LALpars, approx, cache);
85 e2 = clock();
86 diff2 = (double) (e2 - s2) / CLOCKS_PER_SEC;
87 if( ret == XLAL_FAILURE )
89
90 // Find level of agreement
91 plusdiff = crossdiff = 0.;
92 for(i=0; i < hplus->data->length; i++)
93 {
94 temp = fabs(hplus->data->data[i] - hplusC->data->data[i]);
95 if(temp > plusdiff) plusdiff = temp;
96 temp = fabs(hcross->data->data[i] - hcrossC->data->data[i]);
97 if(temp > crossdiff) crossdiff = temp;
98 }
99 printf("Comparing waveforms from ChooseTDWaveform and ChooseTDWaveformFromCache\n");
100 printf("when both must be generated from scratch...\n");
101 printf("ChooseTDWaveform took %f seconds\n", diff1);
102 printf("ChooseTDWaveformFromCache took %f seconds\n", diff2);
103 printf("Largest difference in plus polarization is: %.16g\n", plusdiff);
104 printf("Largest difference in cross polarization is: %.16g\n\n", crossdiff);
105
110 hplus = hcross = hplusC = hcrossC = NULL;
111
112
113 // Generate another waveform via ChooseTDWaveform path
114 s1 = clock();
115 ret = XLALSimInspiralChooseTDWaveform(&hplus, &hcross, m1, m2,
116 s1x, s1y, s1z, s2x, s2y, s2z,
117 dist2, inc2, phiref2, 0., 0., 0.,
118 dt, f_min, f_ref,
119 LALpars, approx);
120 e1 = clock();
121 diff1 = (double) (e1 - s1) / CLOCKS_PER_SEC;
122 if( ret == XLAL_FAILURE )
124
125 // Generate waveform via FromCache - will transform previous waveform
126 s2 = clock();
127 ret = XLALSimInspiralChooseTDWaveformFromCache(&hplusC, &hcrossC, phiref2,
128 dt, m1, m2, s1x, s1y, s1z, s2x, s2y, s2z, f_min, f_ref, dist2, inc2,
129 LALpars, approx, cache);
130 e2 = clock();
131 diff2 = (double) (e2 - s2) / CLOCKS_PER_SEC;
132 if( ret == XLAL_FAILURE )
134
135 // Find level of agreement
136 plusdiff = crossdiff = 0.;
137 for(i=0; i < hplus->data->length; i++)
138 {
139 temp = fabs(hplus->data->data[i] - hplusC->data->data[i]);
140 if(temp > plusdiff) plusdiff = temp;
141 temp = fabs(hcross->data->data[i] - hcrossC->data->data[i]);
142 if(temp > crossdiff) crossdiff = temp;
143 }
144 printf("Comparing waveforms from ChooseTDWaveform and ChooseTDWaveformFromCache\n");
145 printf("when the latter is cached and transformed...\n");
146 printf("ChooseTDWaveform took %f seconds\n", diff1);
147 printf("ChooseTDWaveformFromCache took %f seconds\n", diff2);
148 printf("Largest difference in plus polarization is: %.16g\n", plusdiff);
149 printf("Largest difference in cross polarization is: %.16g\n\n", crossdiff);
150
155 hplus = hcross = hplusC = hcrossC = NULL;
156
157
158 //
159 // Test FD path with TaylorF2
160 //
161
162 // Generate waveform via usual ChooseFDWaveform path
163 s1 = clock();
164 ret = XLALSimInspiralChooseFDWaveform(&hptilde, &hctilde,
165 m1, m2, s1x, s1y, s1z, s2x, s2y, s2z,
166 dist1, inc1, phiref1, 0., 0., 0.,
167 df,f_min, f_max, f_ref,
168 LALpars, approxFD);
169 e1 = clock();
170 diff1 = (double) (e1 - s1) / CLOCKS_PER_SEC;
171 if( ret == XLAL_FAILURE )
173
174 // Generate waveform via FromCache - will call ChooseWaveform this 1st time
175 s2 = clock();
176 ret = XLALSimInspiralChooseFDWaveformFromCache(&hptildeC, &hctildeC,
177 phiref1, df, m1, m2, s1x, s1y, s1z, s2x, s2y, s2z, f_min, f_max,
178 f_ref, dist1, inc1, LALpars, approxFD, cache, NULL);
179 e2 = clock();
180 diff2 = (double) (e2 - s2) / CLOCKS_PER_SEC;
181 if( ret == XLAL_FAILURE )
183
184 // Find level of agreement
185 plusdiff = crossdiff = 0.;
186 for(i=0; i < hptilde->data->length; i++)
187 {
188 temp = cabs(hptilde->data->data[i] - hptildeC->data->data[i]);
189 if(temp > plusdiff) plusdiff = temp;
190 temp = cabs(hctilde->data->data[i] - hctildeC->data->data[i]);
191 if(temp > crossdiff) crossdiff = temp;
192 }
193 printf("Comparing waveforms from ChooseFDWaveform and ChooseFDWaveformFromCache\n");
194 printf("when both must be generated from scratch...\n");
195 printf("ChooseFDWaveform took %f seconds\n", diff1);
196 printf("ChooseFDWaveformFromCache took %f seconds\n", diff2);
197 printf("Largest difference in plus polarization is: %.16g\n", plusdiff);
198 printf("Largest difference in cross polarization is: %.16g\n\n", crossdiff);
199
204 hptilde = hctilde = hptildeC = hctildeC = NULL;
205
206 // Generate another waveform via ChooseFDWaveform path
207 s1 = clock();
208 ret = XLALSimInspiralChooseFDWaveform(&hptilde, &hctilde,
209 m1, m2, s1x, s1y, s1z, s2x, s2y, s2z,
210 dist2, inc2,
211 phiref2, 0., 0., 0.,
212 df, f_min, f_max, f_ref,
213 LALpars, approxFD);
214 e1 = clock();
215 diff1 = (double) (e1 - s1) / CLOCKS_PER_SEC;
216 if( ret == XLAL_FAILURE )
218
219 // Generate waveform via FromCache - will transform previous waveform
220 s2 = clock();
221 ret = XLALSimInspiralChooseFDWaveformFromCache(&hptildeC, &hctildeC,
222 phiref2, df, m1, m2, s1x, s1y, s1z, s2x, s2y, s2z, f_min, f_max,
223 f_ref, dist2, inc2, LALpars, approxFD, cache, NULL);
224 XLALDestroyDict(LALpars);
225 e2 = clock();
226 diff2 = (double) (e2 - s2) / CLOCKS_PER_SEC;
227 if( ret == XLAL_FAILURE )
229
230 // Find level of agreement
231 plusdiff = crossdiff = 0.;
232 for(i=0; i < hptilde->data->length; i++)
233 {
234 temp = cabs(hptilde->data->data[i] - hptildeC->data->data[i]);
235 if(temp > plusdiff) plusdiff = temp;
236 temp = cabs(hctilde->data->data[i] - hctildeC->data->data[i]);
237 if(temp > crossdiff) crossdiff = temp;
238 }
239 printf("Comparing waveforms from ChooseFDWaveform and ChooseFDWaveformFromCache\n");
240 printf("when the latter is cached and transformed...\n");
241 printf("ChooseFDWaveform took %f seconds\n", diff1);
242 printf("ChooseFDWaveformFromCache took %f seconds\n", diff2);
243 printf("Largest difference in plus polarization is: %.16g\n", plusdiff);
244 printf("Largest difference in cross polarization is: %.16g\n\n", crossdiff);
245
250 hptilde = hctilde = hptildeC = hctildeC = NULL;
251
254
255 return 0;
256}
void XLALDestroyDict(LALDict *dict)
LALDict * XLALCreateDict(void)
void LALCheckMemoryLeaks(void)
int XLALSimInspiralWaveformParamsInsertPNPhaseOrder(LALDict *params, INT4 value)
int XLALSimInspiralWaveformParamsInsertTidalLambda1(LALDict *params, REAL8 value)
int XLALSimInspiralWaveformParamsInsertPNAmplitudeOrder(LALDict *params, INT4 value)
int main(void)
double dt
Definition: bh_ringdown.c:113
double i
Definition: bh_ringdown.c:118
void XLALDestroyCOMPLEX16FrequencySeries(COMPLEX16FrequencySeries *series)
#define LAL_MSUN_SI
#define LAL_PC_SI
double REAL8
int XLALSimInspiralChooseFDWaveform(COMPLEX16FrequencySeries **hptilde, COMPLEX16FrequencySeries **hctilde, 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 deltaF, const REAL8 f_min, const REAL8 f_max, REAL8 f_ref, LALDict *params, const Approximant approximant)
Chooses between different approximants when requesting a waveform to be generated For spinning wavefo...
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...
Approximant
Enum that specifies the PN approximant to be used in computing the waveform.
@ SEOBNRv1
Spin-aligned EOBNR model.
@ TaylorF2
The standard stationary phase approximation; Outputs a frequency-domain wave.
LALSimInspiralWaveformCache * XLALCreateSimInspiralWaveformCache(void)
Construct and initialize a waveform cache.
int XLALSimInspiralChooseTDWaveformFromCache(REAL8TimeSeries **hplus, REAL8TimeSeries **hcross, 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 r, REAL8 i, LALDict *LALpars, Approximant approximant, LALSimInspiralWaveformCache *cache)
Chooses between different approximants when requesting a waveform to be generated Returns the wavefor...
void XLALDestroySimInspiralWaveformCache(LALSimInspiralWaveformCache *cache)
Destroy a waveform cache.
int XLALSimInspiralChooseFDWaveformFromCache(COMPLEX16FrequencySeries **hptilde, COMPLEX16FrequencySeries **hctilde, REAL8 phiRef, REAL8 deltaF, REAL8 m1, REAL8 m2, REAL8 S1x, REAL8 S1y, REAL8 S1z, REAL8 S2x, REAL8 S2y, REAL8 S2z, REAL8 f_min, REAL8 f_max, REAL8 f_ref, REAL8 r, REAL8 i, LALDict *LALpars, Approximant approximant, LALSimInspiralWaveformCache *cache, REAL8Sequence *frequencies)
Chooses between different approximants when requesting a waveform to be generated Returns the wavefor...
void XLALDestroyREAL8TimeSeries(REAL8TimeSeries *series)
#define XLAL_ERROR(...)
XLAL_EFUNC
XLAL_FAILURE
COMPLEX16Sequence * data
COMPLEX16 * data
REAL8Sequence * data
REAL8 * data
double f_min
Definition: unicorn.c:22
double f_max
Definition: unicorn.c:23