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
BHNSRemnantFitsTest.c
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2019 Edward Jacob Fauchon-Jones, Jonathan E. Thompson, Sebastian Khan
3 * Test code for LALSimIMRPhenomNSBH
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#include <complex.h>
26#include <lal/LALStdlib.h>
27#include <lal/LALConstants.h>
28#include <lal/Date.h>
29#include <lal/Units.h>
30#include <lal/LALSimIMR.h>
31#include <gsl/gsl_math.h>
32
33#include "../lib/LALSimBHNSRemnantFits.c"
34
35#define MYUNUSED(expr) do { (void)(expr); } while (0)
36
37bool approximatelyEqual(REAL8 a, REAL8 b, REAL8 epsilon);
39 if (a == 0)
40 return fabs(b) < epsilon;
41 else if (b == 0)
42 return fabs(a) < epsilon;
43 else
44 return !gsl_fcmp(a, b, epsilon);
45}
46
47void print_difference(const char *name, REAL8 u, REAL8 u_expected);
48void print_difference(const char *name, REAL8 u, REAL8 u_expected) {
49 printf("%s: %-20.17g\t%-20.17g\t%-20.17g\n", name, u, u_expected, u - u_expected);
50}
51
52#define COUNT_BHNS_SPIN_ALIGNED 48
53#define TOLERANCE_BHNS_SPIN_ALIGNED 1e-7
55 {0.66666667, 0.33333333, -0.90, 100.00}, {0.66666667, 0.33333333, -0.90, 800.00},
56 {0.66666667, 0.33333333, -0.90, 1500.00}, {0.66666667, 0.33333333, -0.90, 2200.00},
57 {0.66666667, 0.33333333, 0.00, 100.00}, {0.66666667, 0.33333333, 0.00, 800.00},
58 {0.66666667, 0.33333333, 0.00, 1500.00}, {0.66666667, 0.33333333, 0.00, 2200.00},
59 {0.66666667, 0.33333333, 0.90, 100.00}, {0.66666667, 0.33333333, 0.90, 800.00},
60 {0.66666667, 0.33333333, 0.90, 1500.00}, {0.66666667, 0.33333333, 0.90, 2200.00},
61 {0.75, 0.25, -0.90, 100.00}, {0.75, 0.25, -0.90, 800.00}, {0.75, 0.25, -0.90, 1500.00},
62 {0.75, 0.25, -0.90, 2200.00}, {0.75, 0.25, 0.00, 100.00}, {0.75, 0.25, 0.00, 800.00},
63 {0.75, 0.25, 0.00, 1500.00}, {0.75, 0.25, 0.00, 2200.00}, {0.75, 0.25, 0.90, 100.00},
64 {0.75, 0.25, 0.90, 800.00}, {0.75, 0.25, 0.90, 1500.00}, {0.75, 0.25, 0.90, 2200.00},
65 {0.8, 0.2, -0.90, 100.00}, {0.8, 0.2, -0.90, 800.00}, {0.8, 0.2, -0.90, 1500.00},
66 {0.8, 0.2, -0.90, 2200.00}, {0.8, 0.2, 0.00, 100.00}, {0.8, 0.2, 0.00, 800.00},
67 {0.8, 0.2, 0.00, 1500.00}, {0.8, 0.2, 0.00, 2200.00}, {0.8, 0.2, 0.90, 100.00},
68 {0.8, 0.2, 0.90, 800.00}, {0.8, 0.2, 0.90, 1500.00}, {0.8, 0.2, 0.90, 2200.00},
69 {0.83333333, 0.16666667, -0.90, 100.00}, {0.83333333, 0.16666667, -0.90, 800.00},
70 {0.83333333, 0.16666667, -0.90, 1500.00}, {0.83333333, 0.16666667, -0.90, 2200.00},
71 {0.83333333, 0.16666667, 0.00, 100.00}, {0.83333333, 0.16666667, 0.00, 800.00},
72 {0.83333333, 0.16666667, 0.00, 1500.00}, {0.83333333, 0.16666667, 0.00, 2200.00},
73 {0.83333333, 0.16666667, 0.90, 100.00}, {0.83333333, 0.16666667, 0.90, 800.00},
74 {0.83333333, 0.16666667, 0.90, 1500.00}, {0.83333333, 0.16666667, 0.90, 2200.00}};
76 0.32531986806109, 0.32531986806109, 0.32531986806109, 0.32531986806109,
77 0.6233940746778823, 0.6233940746778823, 0.6233940746778823,
78 0.6233940746778823, 0.8933593070287664, 0.8933593070287664,
79 0.8933593070287664, 0.8933593070287664, 0.1322915526236391,
80 0.1322915526236391, 0.1322915526236391, 0.1322915526236391,
81 0.5405636817226854, 0.5405636817226854, 0.5351118873433093,
82 0.523184424888309, 0.9144046655280058, 0.9144046655280058,
83 0.9144046655280058, 0.9140801081503465, -0.0152898311874099,
84 -0.0152898311874099, -0.0152898311874099, -0.0152898311874099,
85 0.4716225198815366, 0.4716225198815366, 0.4592291695111008,
86 0.448324709134483, 0.9207205436502875, 0.9155233478254116,
87 0.9122614149305155, 0.9101116289882841, -0.1282904163538133,
88 -0.1282904163538133, -0.1282904163538133, -0.1282904163538133,
89 0.416618630787216, 0.416618630787216, 0.40851912434322, 0.3989747180991385,
90 0.9208154871629006, 0.9098290393520181, 0.9068297787096088, 0.90596110497524};
91static void Test_BHNS_spin_aligned(void);
92static void Test_BHNS_spin_aligned(void) {
93 printf("\n## Test_BHNS_spin_aligned\n\n");
94 for (int i=0; i<COUNT_BHNS_SPIN_ALIGNED; i++) {
100 print_difference("XLALBHNS_spin_aligned", output, expected_BHNS_spin_aligned[i]);
102 }
103}
104
105#define COUNT_BHNS_MASS_ALIGNED 27
106#define TOLERANCE_BHNS_MASS_ALIGNED 1e-7
108 {0.66666667, 0.33333333, -0.90, 100.00}, {0.66666667, 0.33333333, -0.90, 1150.00},
109 {0.66666667, 0.33333333, -0.90, 2200.00}, {0.66666667, 0.33333333, 0.00, 100.00},
110 {0.66666667, 0.33333333, 0.00, 1150.00}, {0.66666667, 0.33333333, 0.00, 2200.00},
111 {0.66666667, 0.33333333, 0.90, 100.00}, {0.66666667, 0.33333333, 0.90, 1150.00},
112 {0.66666667, 0.33333333, 0.90, 2200.00}, {0.77777778, 0.22222222, -0.90, 100.00},
113 {0.77777778, 0.22222222, -0.90, 1150.00}, {0.77777778, 0.22222222, -0.90, 2200.00},
114 {0.77777778, 0.22222222, 0.00, 100.00}, {0.77777778, 0.22222222, 0.00, 1150.00},
115 {0.77777778, 0.22222222, 0.00, 2200.00}, {0.77777778, 0.22222222, 0.90, 100.00},
116 {0.77777778, 0.22222222, 0.90, 1150.00}, {0.77777778, 0.22222222, 0.90, 2200.00},
117 {0.83333333, 0.16666667, -0.90, 100.00}, {0.83333333, 0.16666667, -0.90, 1150.00},
118 {0.83333333, 0.16666667, -0.90, 2200.00}, {0.83333333, 0.16666667, 0.00, 100.00},
119 {0.83333333, 0.16666667, 0.00, 1150.00}, {0.83333333, 0.16666667, 0.00, 2200.00},
120 {0.83333333, 0.16666667, 0.90, 100.00}, {0.83333333, 0.16666667, 0.90, 1150.00},
121 {0.83333333, 0.16666667, 0.90, 2200.00}};
123 0.9721892463752283, 0.9721892463752283, 0.9721892463752283,
124 0.9612091161354085, 0.9552067472181308, 0.9388638553490046,
125 0.9271901050008575, 0.8997642986449343, 0.8897816607983570,
126 0.9829386159400940, 0.9829386159400940, 0.9829386159400940,
127 0.9749212476580998, 0.9721096119194406, 0.9569331789707566,
128 0.9402726792593378, 0.9149725534498141, 0.9099426996879995,
129 0.9881860533109941, 0.9881860533109941, 0.9881860533109941,
130 0.9823333002460519, 0.9823333002460519, 0.9790220473994081,
131 0.9529747726329996, 0.9305878984670090, 0.9215091426291755};
132static void Test_BHNS_mass_aligned(void);
133static void Test_BHNS_mass_aligned(void) {
134 printf("\n## Test_BHNS_mass_aligned\n\n");
135 for (int i=0; i<COUNT_BHNS_MASS_ALIGNED; i++) {
141 print_difference("XLALBHNS_mass_aligned", output, expected_BHNS_mass_aligned[i]);
143 }
144}
145
146#define COUNT_BBH_FINAL_SPIN_NON_PRECESSING_UIB2016 49
147#define TOLERANCE_BBH_FINAL_SPIN_NON_PRECESSING_UIB2016 1e-6
149 {0.66666667, 0.33333333, -0.90, 0.0}, {0.66666667, 0.33333333, -0.60, 0.0},
150 {0.66666667, 0.33333333, -0.30, 0.0}, {0.66666667, 0.33333333, -0.00, 0.0},
151 {0.66666667, 0.33333333, 0.30, 0.0}, {0.66666667, 0.33333333, 0.60, 0.0},
152 {0.66666667, 0.33333333, 0.90, 0.0}, {0.71428571, 0.28571429, -0.90, 0.0},
153 {0.71428571, 0.28571429, -0.60, 0.0}, {0.71428571, 0.28571429, -0.30, 0.0},
154 {0.71428571, 0.28571429, -0.00, 0.0}, {0.71428571, 0.28571429, 0.30, 0.0},
155 {0.71428571, 0.28571429, 0.60, 0.0}, {0.71428571, 0.28571429, 0.90, 0.0}, {0.75, 0.25, -0.90, 0.0},
156 {0.75, 0.25, -0.60, 0.0}, {0.75, 0.25, -0.30, 0.0}, {0.75, 0.25, -0.00, 0.0},
157 {0.75, 0.25, 0.30, 0.0}, {0.75, 0.25, 0.60, 0.0}, {0.75, 0.25, 0.90, 0.0},
158 {0.77777778, 0.22222222, -0.90, 0.0}, {0.77777778, 0.22222222, -0.60, 0.0},
159 {0.77777778, 0.22222222, -0.30, 0.0}, {0.77777778, 0.22222222, -0.00, 0.0},
160 {0.77777778, 0.22222222, 0.30, 0.0}, {0.77777778, 0.22222222, 0.60, 0.0},
161 {0.77777778, 0.22222222, 0.90, 0.0}, {0.8, 0.2, -0.90, 0.0}, {0.8, 0.2, -0.60, 0.0},
162 {0.8, 0.2, -0.30, 0.0}, {0.8, 0.2, -0.00, 0.0}, {0.8, 0.2, 0.30, 0.0}, {0.8, 0.2, 0.60, 0.0},
163 {0.8, 0.2, 0.90, 0.0}, {0.81818182, 0.18181818, -0.90, 0.0}, {0.81818182, 0.18181818, -0.60, 0.0},
164 {0.81818182, 0.18181818, -0.30, 0.0}, {0.81818182, 0.18181818, -0.00, 0.0},
165 {0.81818182, 0.18181818, 0.30, 0.0}, {0.81818182, 0.18181818, 0.60, 0.0},
166 {0.81818182, 0.18181818, 0.90, 0.0}, {0.83333333, 0.16666667, -0.90, 0.0},
167 {0.83333333, 0.16666667, -0.60, 0.0}, {0.83333333, 0.16666667, -0.30, 0.0},
168 {0.83333333, 0.16666667, -0.00, 0.0}, {0.83333333, 0.16666667, 0.30, 0.0},
169 {0.83333333, 0.16666667, 0.60, 0.0}, {0.83333333, 0.16666667, 0.90, 0.0}};
171 0.32531986806109, 0.426811247693234, 0.5262816282723659, 0.6233940746778823,
172 0.7176256005624781, 0.8081181824732344, 0.8933593070287664,
173 0.2227051046418287, 0.3442933029242015, 0.4637591716373274,
174 0.5806968749960987, 0.6944463986439515, 0.8038576147344049,
175 0.9067316365893437, 0.1322915526236391, 0.2707009129437816,
176 0.406938775219245, 0.5405636817226853, 0.6708305510903845,
177 0.7963754449272744, 0.9144046655280058, 0.05344403493307415,
178 0.206040738641565, 0.3564393270154197, 0.5041853113389944,
179 0.6484874217929743, 0.7878347303236208, 0.918937716485219,
180 -0.0152898311874099, 0.1493748390276979, 0.3118300811059859,
181 0.4716225198815365, 0.6279414800852074, 0.7791806423169132,
182 0.9216445513182814, -0.07541925103388192, 0.09959880790600101,
183 0.2724090972820036, 0.4425677935576291, 0.6092626260836896,
184 0.7708304036252198, 0.9232473877391176, -0.1282904163538133,
185 0.05568406681932991, 0.237463578436505, 0.4166186307872159,
186 0.5923469368641248, 0.7629568168378547, 0.9241622345560985};
189 printf("\n## Test_bbh_final_spin_non_precessing_UIB2016\n\n");
196 print_difference("XLALbbh_final_spin_non_precessing_UIB2016", output, expected_bbh_final_spin_non_precessing_UIB2016[i]);
198 }
199}
200
201#define COUNT_BBH_FINAL_MASS_NON_PRECESSING_UIB2016 49
202#define TOLERANCE_BBH_FINAL_MASS_NON_PRECESSING_UIB2016 1e-8
204 {0.66666667, 0.33333333, -0.90, 0.0}, {0.66666667, 0.33333333, -0.60, 0.0},
205 {0.66666667, 0.33333333, -0.30, 0.0}, {0.66666667, 0.33333333, -0.00, 0.0},
206 {0.66666667, 0.33333333, 0.30, 0.0}, {0.66666667, 0.33333333, 0.60, 0.0},
207 {0.66666667, 0.33333333, 0.90, 0.0}, {0.71428571, 0.28571429, -0.90, 0.0},
208 {0.71428571, 0.28571429, -0.60, 0.0}, {0.71428571, 0.28571429, -0.30, 0.0},
209 {0.71428571, 0.28571429, -0.00, 0.0}, {0.71428571, 0.28571429, 0.30, 0.0},
210 {0.71428571, 0.28571429, 0.60, 0.0}, {0.71428571, 0.28571429, 0.90, 0.0}, {0.75, 0.25, -0.90, 0.0},
211 {0.75, 0.25, -0.60, 0.0}, {0.75, 0.25, -0.30, 0.0}, {0.75, 0.25, -0.00, 0.0},
212 {0.75, 0.25, 0.30, 0.0}, {0.75, 0.25, 0.60, 0.0}, {0.75, 0.25, 0.90, 0.0},
213 {0.77777778, 0.22222222, -0.90, 0.0}, {0.77777778, 0.22222222, -0.60, 0.0},
214 {0.77777778, 0.22222222, -0.30, 0.0}, {0.77777778, 0.22222222, -0.00, 0.0},
215 {0.77777778, 0.22222222, 0.30, 0.0}, {0.77777778, 0.22222222, 0.60, 0.0},
216 {0.77777778, 0.22222222, 0.90, 0.0}, {0.8, 0.2, -0.90, 0.0}, {0.8, 0.2, -0.60, 0.0},
217 {0.8, 0.2, -0.30, 0.0}, {0.8, 0.2, -0.00, 0.0}, {0.8, 0.2, 0.30, 0.0}, {0.8, 0.2, 0.60, 0.0},
218 {0.8, 0.2, 0.90, 0.0}, {0.81818182, 0.18181818, -0.90, 0.0}, {0.81818182, 0.18181818, -0.60, 0.0},
219 {0.81818182, 0.18181818, -0.30, 0.0}, {0.81818182, 0.18181818, -0.00, 0.0},
220 {0.81818182, 0.18181818, 0.30, 0.0}, {0.81818182, 0.18181818, 0.60, 0.0},
221 {0.81818182, 0.18181818, 0.90, 0.0}, {0.83333333, 0.16666667, -0.90, 0.0},
222 {0.83333333, 0.16666667, -0.60, 0.0}, {0.83333333, 0.16666667, -0.30, 0.0},
223 {0.83333333, 0.16666667, -0.00, 0.0}, {0.83333333, 0.16666667, 0.30, 0.0},
224 {0.83333333, 0.16666667, 0.60, 0.0}, {0.83333333, 0.16666667, 0.90, 0.0}};
226 0.9721892463752283, 0.9694119738670753, 0.9658485291704533,
227 0.9612091161354085, 0.9549702082338648, 0.9460793967931898,
228 0.9320618564969965, 0.9767340252207777, 0.9742714526109177,
229 0.9710291544184678, 0.9667043606611544, 0.9607082019142325,
230 0.9517232519172408, 0.9360722402912158, 0.9802316623246833,
231 0.9780879021631663, 0.9751897931357891, 0.971248210181883,
232 0.9656691198459941, 0.9570077253038091, 0.9405959334853373,
233 0.982938615940094, 0.9810789379119643, 0.9784948592488221,
234 0.9749212476580998, 0.969790204327316, 0.9616262072084677,
235 0.9450263278811365, 0.985071427714766, 0.9834523313904443,
236 0.9811397472589851, 0.9778948731043349, 0.9731894238502419,
237 0.9655762410464163, 0.9491543700819247, 0.9867848155509094,
238 0.9853653553170411, 0.983283197420709, 0.980324763824162, 0.9760053561768509,
239 0.9689389496020029, 0.9529229375415428, 0.9881860533109941,
240 0.9869312527994188, 0.9850439105054475, 0.9823333002460519,
241 0.9783576056713429, 0.9718080109472624, 0.9563338892210131};
244 printf("\n## Test_bbh_final_mass_non_precessing_UIB2016\n\n");
251 print_difference("XLALbbh_final_mass_non_precessing_UIB2016", output, expected_bbh_final_mass_non_precessing_UIB2016[i]);
253 }
254}
255
256int main(int argc, char *argv[]) {
257 MYUNUSED(argc);
258 MYUNUSED(argv);
259
264
265 return 0;
266}
bool approximatelyEqual(REAL8 a, REAL8 b, REAL8 epsilon)
int main(int argc, char *argv[])
double expected_BHNS_mass_aligned[COUNT_BHNS_MASS_ALIGNED]
#define COUNT_BBH_FINAL_MASS_NON_PRECESSING_UIB2016
double input_bbh_final_mass_non_precessing_UIB2016[COUNT_BBH_FINAL_MASS_NON_PRECESSING_UIB2016][4]
double expected_bbh_final_spin_non_precessing_UIB2016[COUNT_BBH_FINAL_SPIN_NON_PRECESSING_UIB2016]
double expected_BHNS_spin_aligned[COUNT_BHNS_SPIN_ALIGNED]
static void Test_bbh_final_spin_non_precessing_UIB2016(void)
#define MYUNUSED(expr)
double input_BHNS_spin_aligned[COUNT_BHNS_SPIN_ALIGNED][4]
#define TOLERANCE_BHNS_SPIN_ALIGNED
#define TOLERANCE_BBH_FINAL_MASS_NON_PRECESSING_UIB2016
void print_difference(const char *name, REAL8 u, REAL8 u_expected)
double input_bbh_final_spin_non_precessing_UIB2016[COUNT_BBH_FINAL_SPIN_NON_PRECESSING_UIB2016][4]
#define TOLERANCE_BHNS_MASS_ALIGNED
static void Test_BHNS_spin_aligned(void)
double input_BHNS_mass_aligned[COUNT_BHNS_MASS_ALIGNED][5]
#define COUNT_BHNS_MASS_ALIGNED
#define TOLERANCE_BBH_FINAL_SPIN_NON_PRECESSING_UIB2016
static void Test_BHNS_mass_aligned(void)
#define COUNT_BHNS_SPIN_ALIGNED
#define COUNT_BBH_FINAL_SPIN_NON_PRECESSING_UIB2016
double expected_bbh_final_mass_non_precessing_UIB2016[COUNT_BBH_FINAL_MASS_NON_PRECESSING_UIB2016]
static void Test_bbh_final_mass_non_precessing_UIB2016(void)
const char * name
double i
Definition: bh_ringdown.c:118
const double u
double REAL8
REAL8 XLALBHNS_spin_aligned(const REAL8 m1, const REAL8 m2, const REAL8 chi1, const REAL8 lam)
Compute final black hole spin for aligned black hole spin.
REAL8 XLALbbh_final_mass_non_precessing_UIB2016(const REAL8 m1, const REAL8 m2, const REAL8 chi1, const REAL8 chi2)
Calculate the final mass with the aligned-spin NR fit.
REAL8 XLALbbh_final_spin_non_precessing_UIB2016(const REAL8 m1, const REAL8 m2, const REAL8 chi1, const REAL8 chi2)
Calculate the final spin with the aligned-spin NR fit.
REAL8 XLALBHNS_mass_aligned(const REAL8 m1, const REAL8 m2, const REAL8 chi1, const REAL8 lam)
Compute final black hole mass for aligned black hole spin.
static const INT4 a
#define XLAL_CHECK_EXIT(assertion)
char output[FILENAME_MAX]
Definition: unicorn.c:26