LALSimulation 6.2.1.1-bf6a62b
SEOBNRv4_ROM_NRTidalv2_NSBH_Test.c
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2019 Andrew Matas
3 * Test code for LALSimIMRSEOBNRv4ROM_NSBHAmplitudeCorrection
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with with program; see the file COPYING. If not, write to the
17 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18 * MA 02110-1301 USA
19 */
20
21#include <stdio.h>
22#include <stdlib.h>
23#include <math.h>
24#include <float.h>
25
26#include <lal/Units.h>
27#include <lal/LALAdaptiveRungeKuttaIntegrator.h>
28#include <lal/LALConstants.h>
29#include <lal/FindRoot.h>
30#include <lal/SeqFactories.h>
31#include <lal/LALSimInspiral.h>
32#include <lal/LALSimIMR.h>
33#include <lal/Sequence.h>
34#include <lal/FrequencySeries.h>
35
36
37#include <lal/LALSimNoise.h>
38#include <lal/ComplexFFT.h>
39
40#include <lal/ComplexFFT.h>
41#include <gsl/gsl_errno.h>
42#include <gsl/gsl_spline.h>
43#include <gsl/gsl_math.h>
44
45#include "../lib/LALSimIMRSEOBNRv4ROM_NSBHAmplitudeCorrection.c"
46
47#define MYUNUSED(expr) do { (void)(expr); } while (0)
48
49
50bool approximatelyEqual(REAL8 a, REAL8 b, REAL8 epsilon);
52 if (a == 0)
53 return fabs(b) < epsilon;
54 else if (b == 0)
55 return fabs(a) < epsilon;
56 else
57 return !gsl_fcmp(a, b, epsilon);
58}
61 if (a->length != b->length)
62 return false;
63 for (UINT4 i=0; i<a->length; i++){
64 if (!approximatelyEqual(a->data[i],b->data[i],epsilon))
65 return false;
66 }
67 return true;
68}
69
70
71void print_difference(const char *name, REAL8 u, REAL8 u_expected);
72void print_difference(const char *name, REAL8 u, REAL8 u_expected) {
73 printf("%s: %-20.17g\t%-20.17g\t%-20.17g\n", name, u, u_expected, u - u_expected);
74}
75
78 for (UINT4 i=0; i<freqs->length; i++){
79 printf("%s [%2.5f Hz]: %-20.17g\t%-20.17g\t%-20.17g\n", name, freqs->data[i], u->data[i], u_expected->data[i], u->data[i] - u_expected->data[i]);
80 }
81}
84 REAL8 m1_SI=1.4*LAL_MSUN_SI;
85 REAL8 m2_SI=1.4*LAL_MSUN_SI;
86 REAL8 chi1=0;
87 REAL8 lambda2=1000;
88
89 REAL8 deltaF=100;
90 REAL8 Fmax=1000;
91 int nfreqs = (int)(Fmax/deltaF);
92
93 REAL8Sequence *freqs=NULL;
94 freqs = XLALCreateREAL8Sequence(nfreqs);
95 for (int i=0; i<nfreqs; i++){
96 freqs->data[i]=i*deltaF;
97 }
98
99 REAL8Sequence *amp_tidal = NULL;
100 amp_tidal = XLALCreateREAL8Sequence(freqs->length);
102 amp_tidal, freqs,
103 m1_SI, m2_SI, chi1, lambda2);
104 MYUNUSED(ret);
105
106 REAL8Sequence *expected_amp_tidal=NULL;
107 expected_amp_tidal=XLALCreateREAL8Sequence(freqs->length);
108 expected_amp_tidal->data[0]=0.98956307697285817;
109 expected_amp_tidal->data[1]=0.98623701074185499;
110 expected_amp_tidal->data[2]=0.98187040424514516;
111 expected_amp_tidal->data[3]=0.97615189747808495;
112 expected_amp_tidal->data[4]=0.96868716084731876;
113 expected_amp_tidal->data[5]=0.95898405100871376;
114 expected_amp_tidal->data[6]=0.94644042313762244;
115 expected_amp_tidal->data[7]=0.93033932007923714;
116 expected_amp_tidal->data[8]=0.90985889942914522;
117 expected_amp_tidal->data[9]=0.8841072573277694;
118
119 print_difference_FrequencySequence("Amplitude Correction",amp_tidal,expected_amp_tidal,freqs);
120 XLAL_CHECK_EXIT(approximatelyEqualREAL8Sequence(amp_tidal,expected_amp_tidal,1e-8));
121}
122
123int main(int argc, char *argv[]) {
124 MYUNUSED(argc);
125 MYUNUSED(argv);
126
128
129 return 0;
130}
const char * name
bool approximatelyEqual(REAL8 a, REAL8 b, REAL8 epsilon)
int main(int argc, char *argv[])
static void Test_amplitude_correction_disruptive(void)
#define MYUNUSED(expr)
void print_difference_FrequencySequence(const char *name, REAL8Sequence *u, REAL8Sequence *u_expected, REAL8Sequence *freqs)
void print_difference(const char *name, REAL8 u, REAL8 u_expected)
bool approximatelyEqualREAL8Sequence(REAL8Sequence *a, REAL8Sequence *b, REAL8 epsilon)
double i
Definition: bh_ringdown.c:118
double e
Definition: bh_ringdown.c:117
const double u
#define LAL_MSUN_SI
double REAL8
uint32_t UINT4
int XLALSEOBNRv4ROMNSBHAmplitudeCorrectionFrequencySeries(const REAL8Sequence *amp_tidal, const REAL8Sequence *fHz, REAL8 m1_SI, REAL8 m2_SI, REAL8 chi1, REAL8 lambda2)
Compute amplitude correction to SEOBNRv4_ROM_NRTidalv2 in LAL format at specified frequencies for the...
static const INT4 a
REAL8Sequence * XLALCreateREAL8Sequence(size_t length)
#define XLAL_CHECK_EXIT(assertion)
REAL8 * data