22 #define UNUSED __attribute__ ((unused))
37 #include <gsl/gsl_errno.h>
38 #include <gsl/gsl_bspline.h>
39 #include <gsl/gsl_blas.h>
40 #include <gsl/gsl_min.h>
41 #include <gsl/gsl_spline.h>
42 #include <gsl/gsl_poly.h>
43 #include <lal/Units.h>
44 #include <lal/SeqFactories.h>
45 #include <lal/LALConstants.h>
46 #include <lal/XLALError.h>
47 #include <lal/FrequencySeries.h>
49 #include <lal/StringInput.h>
50 #include <lal/Sequence.h>
51 #include <lal/LALStdio.h>
52 #include <lal/FileIO.h>
54 #ifdef LAL_HDF5_ENABLED
55 #include <lal/H5FileIO.h>
56 static const char ROMDataHDF5[] =
"SEOBNRv2ROM_DS_HI_v1.0.hdf5";
57 static const INT4 ROMDataHDF5_VERSION_MAJOR = 1;
58 static const INT4 ROMDataHDF5_VERSION_MINOR = 0;
59 static const INT4 ROMDataHDF5_VERSION_MICRO = 0;
62 #include <lal/LALSimInspiral.h>
63 #include <lal/LALSimIMR.h>
66 UNUSED
static int read_vector_test(
const char dir[],
const char fname[], gsl_vector *v) {
67 size_t size = strlen(dir) + strlen(fname) + 2;
69 snprintf(
path, size,
"%s/%s", dir, fname);
71 FILE *f = fopen(
path,
"rb");
74 int ret = gsl_vector_fread(f, v);
86 #include <lal/LALConfig.h>
87 #ifdef LAL_PTHREAD_LOCK
118 #define nk_amp_sub1 200
119 #define nk_phi_sub1 250
124 static const double gA_sub1[] = {0.0000985, 0.000102213, 0.000106067, 0.000110066, 0.000114215, \
125 0.000118521, 0.000122989, 0.000127626, 0.000132437, 0.00013743, \
126 0.000142611, 0.000147988, 0.000153567, 0.000159357, 0.000165364, \
127 0.000171598, 0.000178068, 0.000184781, 0.000191747, 0.000198976, \
128 0.000206477, 0.000214262, 0.000222339, 0.000230721, 0.00023942, \
129 0.000248446, 0.000257812, 0.000267532, 0.000277618, 0.000288084, \
130 0.000298945, 0.000310215, 0.00032191, 0.000334046, 0.000346639, \
131 0.000359708, 0.000373269, 0.000387341, 0.000401944, 0.000417097, \
132 0.000432822, 0.000449139, 0.000466071, 0.000483642, 0.000501876, \
133 0.000520796, 0.00054043, 0.000560805, 0.000581947, 0.000603886, \
134 0.000626653, 0.000650278, 0.000674793, 0.000700233, 0.000726632, \
135 0.000754026, 0.000782452, 0.000811951, 0.000842561, 0.000874326, \
136 0.000907288, 0.000941493, 0.000976987, 0.00101382, 0.00105204, \
137 0.0010917, 0.00113286, 0.00117557, 0.00121989, 0.00126588, 0.0013136, \
138 0.00136312, 0.00141451, 0.00146784, 0.00152318, 0.0015806, \
139 0.00164019, 0.00170203, 0.00176619, 0.00183278, 0.00190187, \
140 0.00197357, 0.00204798, 0.00212519, 0.00220531, 0.00228845, \
141 0.00237472, 0.00246425, 0.00255715, 0.00265355, 0.00275359, \
142 0.0028574, 0.00296513, 0.00307691, 0.00319291, 0.00331329, 0.0034382, \
143 0.00356782, 0.00370232, 0.0038419, 0.00398674, 0.00413704, \
144 0.00429301, 0.00445485, 0.0046228, 0.00479708, 0.00497793, 0.0051656, \
145 0.00536034, 0.00556243, 0.00577213, 0.00598974, 0.00621555, \
146 0.00644988, 0.00669304, 0.00694537, 0.00720721, 0.00747892, \
147 0.00776087, 0.00805346, 0.00835707, 0.00867214, 0.00899908, \
148 0.00933834, 0.0096904, 0.0100557, 0.0104348, 0.0108282, 0.0112364, \
149 0.0116601, 0.0120996, 0.0125558, 0.0130291, 0.0135203, 0.0140301, \
150 0.014559, 0.0151079, 0.0156774, 0.0162685, 0.0168818, 0.0175182, \
151 0.0181787, 0.018864, 0.0195752, 0.0203132, 0.021079, 0.0218737, \
152 0.0226983, 0.023554, 0.024442, 0.0253635, 0.0263197, 0.0273119, \
153 0.0283416, 0.0294101, 0.0305188, 0.0316694, 0.0328633, 0.0341023, \
154 0.0353879, 0.036722, 0.0381065, 0.0395431, 0.0410339, 0.0425808, \
155 0.0441861, 0.0458519, 0.0475806, 0.0493744, 0.0512358, 0.0531674, \
156 0.0551718, 0.0572517, 0.0594101, 0.0616499, 0.0639741, 0.0663859, \
157 0.0688887, 0.0714858, 0.0741808, 0.0769774, 0.0798794, 0.0828909, \
158 0.0860159, 0.0892587, 0.0926237, 0.0961157, 0.0997392, 0.103499, \
159 0.107401, 0.11145, 0.115652, 0.120012, 0.124537, 0.129232, 0.134104, \
160 0.139159, 0.144406, 0.14985, 0.15};
162 static const double gPhi_sub1[] = {0.0000985, 0.0000996191, 0.000100755, 0.000101908, 0.000103079, \
163 0.000104268, 0.000105476, 0.000106702, 0.000107947, 0.000109211, \
164 0.000110495, 0.000111799, 0.000113124, 0.00011447, 0.000115838, \
165 0.000117227, 0.000118638, 0.000120072, 0.000121529, 0.00012301, \
166 0.000124515, 0.000126045, 0.000127599, 0.00012918, 0.000130786, \
167 0.000132419, 0.000134079, 0.000135768, 0.000137484, 0.00013923, \
168 0.000141005, 0.00014281, 0.000144647, 0.000146515, 0.000148415, \
169 0.000150348, 0.000152314, 0.000154315, 0.000156352, 0.000158424, \
170 0.000160532, 0.000162679, 0.000164863, 0.000167087, 0.000169351, \
171 0.000171656, 0.000174003, 0.000176393, 0.000178826, 0.000181305, \
172 0.000183829, 0.0001864, 0.00018902, 0.000191688, 0.000194407, \
173 0.000197177, 0.000200001, 0.000202878, 0.00020581, 0.0002088, \
174 0.000211847, 0.000214954, 0.000218121, 0.000221351, 0.000224645, \
175 0.000228005, 0.000231431, 0.000234927, 0.000238492, 0.000242131, \
176 0.000245843, 0.000249632, 0.000253499, 0.000257445, 0.000261474, \
177 0.000265587, 0.000269787, 0.000274075, 0.000278455, 0.000282928, \
178 0.000287497, 0.000292165, 0.000296934, 0.000301807, 0.000306787, \
179 0.000311877, 0.00031708, 0.000322399, 0.000327838, 0.000333398, \
180 0.000339086, 0.000344902, 0.000350852, 0.00035694, 0.000363169, \
181 0.000369543, 0.000376066, 0.000382744, 0.00038958, 0.000396579, \
182 0.000403747, 0.000411088, 0.000418607, 0.000426311, 0.000434203, \
183 0.000442292, 0.000450582, 0.000459079, 0.000467791, 0.000476725, \
184 0.000485886, 0.000495283, 0.000504923, 0.000514813, 0.000524964, \
185 0.000535381, 0.000546076, 0.000557056, 0.000568331, 0.000579912, \
186 0.000591808, 0.000604031, 0.000616592, 0.000629502, 0.000642774, \
187 0.00065642, 0.000670454, 0.000684889, 0.000699741, 0.000715023, \
188 0.000730752, 0.000746943, 0.000763615, 0.000780785, 0.000798472, \
189 0.000816695, 0.000835474, 0.000854831, 0.000874789, 0.00089537, \
190 0.0009166, 0.000938503, 0.000961107, 0.000984439, 0.00100853, \
191 0.00103341, 0.00105911, 0.00108567, 0.00111312, 0.0011415, \
192 0.00117085, 0.0012012, 0.00123261, 0.00126513, 0.00129879, \
193 0.00133365, 0.00136976, 0.00140718, 0.00144597, 0.00148619, \
194 0.00152792, 0.00157121, 0.00161614, 0.0016628, 0.00171126, \
195 0.00176161, 0.00181395, 0.00186837, 0.00192498, 0.00198389, \
196 0.00204521, 0.00210908, 0.00217561, 0.00224496, 0.00231727, \
197 0.00239271, 0.00247143, 0.00255363, 0.0026395, 0.00272923, \
198 0.00282306, 0.00292121, 0.00302394, 0.00313151, 0.00324421, \
199 0.00336236, 0.00348627, 0.00361632, 0.00375287, 0.00389633, \
200 0.00404716, 0.00420582, 0.00437283, 0.00454874, 0.00473414, \
201 0.00492969, 0.00513608, 0.00535408, 0.00558449, 0.00582823, \
202 0.00608624, 0.0063596, 0.00664946, 0.00695705, 0.00728377, 0.0076311, \
203 0.00800069, 0.00839433, 0.00881401, 0.0092619, 0.00974038, 0.0102521, \
204 0.0108, 0.0113872, 0.0120175, 0.0126946, 0.0134231, 0.0142079, \
205 0.0150544, 0.0159688, 0.0169581, 0.0180299, 0.0191929, 0.020457, \
206 0.0218334, 0.0233345, 0.0249749, 0.0267707, 0.0287408, 0.0309065, \
207 0.0332925, 0.0359272, 0.0388435, 0.0420796, 0.0456801, 0.0496972, \
208 0.054192, 0.0592368, 0.0649174, 0.0713356, 0.0786136, 0.086898, \
209 0.0963666, 0.107235, 0.115, 0.119768, 0.13, 0.134291, 0.145, 0.15};
211 #define nk_amp_sub2 113
212 #define nk_phi_sub2 113
215 static const double g_sub2[] = {0.00739041, 0.00753436, 0.00768207, 0.00783364, 0.00798922, \
216 0.00814894, 0.00831292, 0.00848132, 0.00865428, 0.00883196, \
217 0.00901452, 0.00920213, 0.00939497, 0.00959321, 0.00979705, \
218 0.0100067, 0.0102223, 0.0104442, 0.0106725, 0.0109074, 0.0111493, \
219 0.0113984, 0.0116549, 0.0119192, 0.0121915, 0.012472, 0.0127613, \
220 0.0130595, 0.013367, 0.0136843, 0.0140116, 0.0143494, 0.0146981, \
221 0.0150581, 0.0154299, 0.0158141, 0.016211, 0.0166213, 0.0170455, \
222 0.0174842, 0.017938, 0.0184075, 0.0188935, 0.0193968, 0.0199179, \
223 0.0204578, 0.0210174, 0.0215974, 0.0221988, 0.0228227, 0.0234701, \
224 0.0241421, 0.0248398, 0.0255646, 0.0263177, 0.0271005, 0.0279145, \
225 0.0287613, 0.0296425, 0.0305599, 0.0315153, 0.0325108, 0.0335484, \
226 0.0346304, 0.0357592, 0.0369373, 0.0381675, 0.0394525, 0.0407956, \
227 0.0422, 0.0436692, 0.045207, 0.0468174, 0.0485048, 0.0502737, \
228 0.0521292, 0.0540765, 0.0561214, 0.0582701, 0.0605292, 0.0629058, \
229 0.0654076, 0.0680429, 0.0708208, 0.0737509, 0.0768437, 0.0801107, \
230 0.0835641, 0.0872175, 0.0910854, 0.0951836, 0.0995295, 0.104142, \
231 0.109042, 0.114251, 0.119795, 0.1257, 0.131997, 0.138718, 0.145899, \
232 0.15358, 0.161804, 0.170621, 0.180084, 0.190254, 0.201196, 0.212986, \
233 0.225705, 0.239447, 0.254316, 0.270429, 0.287917, 0.3};
235 #define gA_sub2 g_sub2
236 #define gPhi_sub2 g_sub2
239 #define nk_amp_sub3 nk_amp_sub2
240 #define nk_phi_sub3 nk_phi_sub2
241 #define gA_sub3 g_sub2
242 #define gPhi_sub3 g_sub2
249 static const double etavec_sub1[] = {0.01, 0.011, 0.012, 0.013, 0.015, 0.017, 0.018, 0.02, 0.021, 0.022, \
250 0.023, 0.024, 0.025, 0.027, 0.03, 0.035, 0.037, 0.04, 0.042, 0.045, \
251 0.048, 0.05, 0.055, 0.06, 0.065, 0.07, 0.075, 0.08, 0.085, 0.09, \
252 0.095, 0.1, 0.105, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.18, 0.2, \
253 0.22, 0.23, 0.235, 0.24, 0.241, 0.242, 0.243, 0.244, 0.245, 0.246, \
254 0.247, 0.248, 0.2485, 0.2488, 0.249, 0.2491, 0.2492, 0.2493, 0.2494, \
255 0.2495, 0.2496, 0.2497, 0.2498, 0.2499, 0.24995, 0.25};
256 static const double chi1vec_sub1[] = {-0.9999, -0.8, -0.6, -0.4, -0.2, 0., 0.2, 0.4, 0.6, 0.8, 0.9, \
258 static const double chi2vec_sub1[] = {-0.9999, -0.8, -0.6, -0.4, -0.2, 0., 0.2, 0.4, 0.6, 0.8, 0.9, \
266 static const double etavec_sub2[] = {0.01, 0.0105, 0.011, 0.0115, 0.0125, 0.015, 0.0175, 0.02, 0.025, \
267 0.03, 0.035, 0.04, 0.045, 0.05, 0.055, 0.06, 0.065, 0.07, 0.075, \
268 0.08, 0.085, 0.09, 0.095, 0.1, 0.105, 0.11, 0.115, 0.12, 0.125, 0.13, \
269 0.135, 0.14, 0.145, 0.15, 0.155, 0.16, 0.165, 0.17, 0.175, 0.18, \
270 0.185, 0.19, 0.195, 0.2, 0.205, 0.21, 0.215, 0.22, 0.225, 0.23, \
271 0.235, 0.24, 0.2425, 0.2435, 0.245, 0.24625, 0.2475, 0.2485, 0.249, \
272 0.2495, 0.2498, 0.2499, 0.25};
273 static const double chi1vec_sub2[] = {-0.9999, -0.96, -0.92, -0.88, -0.84, -0.8, -0.76, -0.72, -0.68, \
274 -0.64, -0.6, -0.56, -0.52, -0.48, -0.44, -0.4, -0.36, -0.32, -0.28, \
275 -0.24, -0.2, -0.16, -0.12, -0.08, -0.04, 0., 0.04, 0.08, 0.12, 0.16, \
276 0.2, 0.24, 0.28, 0.32, 0.36, 0.4, 0.44};
277 static const double chi2vec_sub2[] = {-0.9999, -0.96, -0.92, -0.88, -0.84, -0.8, -0.76, -0.72, -0.68, \
278 -0.64, -0.6, -0.56, -0.52, -0.48, -0.44, -0.4, -0.36, -0.32, -0.28, \
279 -0.24, -0.2, -0.16, -0.12, -0.08, -0.04, 0., 0.04, 0.08, 0.12, 0.16, \
280 0.2, 0.24, 0.28, 0.32, 0.36, 0.4, 0.44, 0.48, 0.52, 0.56, 0.6, 0.64, \
281 0.68, 0.72, 0.76, 0.8, 0.84, 0.88, 0.92, 0.96, 0.98999};
288 static const double etavec_sub3[] = {0.01, 0.0105, 0.011, 0.0115, 0.0125, 0.015, 0.0175, 0.02, 0.0225, \
289 0.025, 0.0275, 0.03, 0.0325, 0.035, 0.0375, 0.04, 0.0425, 0.045, \
290 0.0475, 0.05, 0.0525, 0.055, 0.0575, 0.06, 0.0625, 0.065, 0.0675, \
291 0.07, 0.0725, 0.075, 0.0775, 0.08, 0.0825, 0.085, 0.0875, 0.09, \
292 0.0925, 0.095, 0.0975, 0.1, 0.1025, 0.105, 0.1075, 0.11, 0.1125, \
293 0.115, 0.1175, 0.12, 0.1225, 0.125, 0.1275, 0.13, 0.1325, 0.135, \
294 0.1375, 0.14, 0.1425, 0.145, 0.1475, 0.15, 0.1525, 0.155, 0.1575, \
295 0.16, 0.1625, 0.165, 0.1675, 0.17, 0.1725, 0.175, 0.1775, 0.18, \
296 0.1825, 0.185, 0.1875, 0.19, 0.1925, 0.195, 0.1975, 0.2, 0.2025, \
297 0.205, 0.2075, 0.21, 0.2125, 0.215, 0.2175, 0.22, 0.2225, 0.225, \
298 0.2275, 0.23, 0.2325, 0.235, 0.2375, 0.24, 0.2425, 0.245, 0.24625, \
299 0.2475, 0.2485, 0.249, 0.2495, 0.2498, 0.2499, 0.25};
300 static const double chi1vec_sub3[] = {0.4, 0.405, 0.41, 0.415, 0.42, 0.425, 0.43, 0.435, 0.44, 0.445, \
301 0.45, 0.455, 0.46, 0.465, 0.47, 0.475, 0.48, 0.485, 0.49, 0.495, 0.5, \
302 0.505, 0.51, 0.515, 0.52, 0.525, 0.53, 0.535, 0.54, 0.545, 0.55, \
303 0.555, 0.56, 0.565, 0.57, 0.575, 0.58, 0.585, 0.59, 0.595, 0.6, \
304 0.605, 0.61, 0.615, 0.62, 0.625, 0.63, 0.635, 0.64, 0.645, 0.65, \
305 0.655, 0.66, 0.665, 0.67, 0.675, 0.68, 0.685, 0.69, 0.695, 0.7, \
306 0.705, 0.71, 0.715, 0.72, 0.725, 0.73, 0.735, 0.74, 0.745, 0.75, \
307 0.755, 0.76, 0.765, 0.77, 0.775, 0.78, 0.785, 0.79, 0.795, 0.8, \
308 0.805, 0.81, 0.815, 0.82, 0.825, 0.83, 0.835, 0.84, 0.845, 0.85, \
309 0.855, 0.86, 0.865, 0.87, 0.875, 0.88, 0.885, 0.89, 0.895, 0.9, \
310 0.905, 0.91, 0.915, 0.92, 0.925, 0.93, 0.935, 0.94, 0.945, 0.95, \
311 0.955, 0.96, 0.965, 0.97, 0.975, 0.98, 0.985, 0.98999};
312 static const double chi2vec_sub3[] = {-0.9999, -0.96, -0.92, -0.88, -0.84, -0.8, -0.76, -0.72, -0.68, \
313 -0.64, -0.6, -0.56, -0.52, -0.48, -0.44, -0.4, -0.36, -0.32, -0.28, \
314 -0.24, -0.2, -0.16, -0.12, -0.08, -0.04, 0., 0.04, 0.08, 0.12, 0.16, \
315 0.2, 0.24, 0.28, 0.32, 0.36, 0.4, 0.44, 0.48, 0.52, 0.56, 0.6, 0.64, \
316 0.68, 0.72, 0.76, 0.8, 0.84, 0.88, 0.92, 0.96, 0.98999};
322 #ifdef LAL_PTHREAD_LOCK
323 static pthread_once_t SEOBNRv2ROMDoubleSpin_is_initialized = PTHREAD_ONCE_INIT;
328 typedef struct tagSEOBNRROMdataDS_coeff
355 SEOBNRROMdataDS_submodel*
sub1;
356 SEOBNRROMdataDS_submodel*
sub2;
357 SEOBNRROMdataDS_submodel*
sub3;
363 typedef int (*
load_dataPtr)(
const char*, gsl_vector *, gsl_vector *, gsl_matrix *, gsl_matrix *, gsl_vector *);
365 typedef struct tagSplineData
367 gsl_bspline_workspace *bwx;
368 gsl_bspline_workspace *bwy;
369 gsl_bspline_workspace *bwz;
385 gsl_vector *cvec_amp,
386 gsl_vector *cvec_phi,
387 gsl_vector *cvec_amp_pre,
394 const double *etavec,
395 const double *chi1vec,
396 const double *chi2vec,
403 SEOBNRROMdataDS_submodel **submodel,
408 const double *etavec,
409 const double *chi1vec,
410 const double *chi2vec,
448 static size_t NextPow2(
const size_t n);
455 const double *etavec,
456 const double *chi1vec,
457 const double *chi2vec
460 static int load_data_sub1(
const char dir[], gsl_vector *cvec_amp, gsl_vector *cvec_phi, gsl_matrix *Bamp, gsl_matrix *Bphi, gsl_vector *cvec_amp_pre);
461 static int load_data_sub2(
const char dir[], gsl_vector *cvec_amp, gsl_vector *cvec_phi, gsl_matrix *Bamp, gsl_matrix *Bphi, gsl_vector *cvec_amp_pre);
462 static int load_data_sub3(
const char dir[], gsl_vector *cvec_amp, gsl_vector *cvec_phi, gsl_matrix *Bamp, gsl_matrix *Bphi, gsl_vector *cvec_amp_pre);
465 gsl_spline **spline_phi,
466 gsl_interp_accel **acc_phi,
481 gsl_bspline_workspace *bwx,
482 gsl_bspline_workspace *bwy
487 SEOBNRROMdataDS_submodel *submodel_lo,
488 SEOBNRROMdataDS_submodel *submodel_hi,
489 gsl_vector* phi_f_lo,
490 gsl_vector* phi_f_hi,
493 gsl_interp_accel **acc_phi_out,
494 gsl_spline **spline_phi_out
528 static int load_data_sub1(
const char dir[], gsl_vector *cvec_amp, gsl_vector *cvec_phi, gsl_matrix *Bamp, gsl_matrix *Bphi, gsl_vector *cvec_amp_pre) {
536 #ifdef LAL_HDF5_ENABLED
537 size_t size = strlen(dir) + strlen(ROMDataHDF5) + 2;
539 snprintf(
path, size,
"%s/%s", dir, ROMDataHDF5);
545 ReadHDF5RealVectorDataset(sub1,
"Amp_ciall", &cvec_amp);
546 ReadHDF5RealVectorDataset(sub1,
"Phase_ciall", &cvec_phi);
547 ReadHDF5RealVectorDataset(sub1,
"AmpPrefac_ci", &cvec_amp_pre);
549 ReadHDF5RealMatrixDataset(sub1,
"Bamp", &Bamp);
550 ReadHDF5RealMatrixDataset(sub1,
"Bphase", &Bphi);
564 ret |=
read_vector(dir,
"SEOBNRv2ROM_DS_HI_sub1_Amp_ciall.dat", cvec_amp);
565 ret |=
read_vector(dir,
"SEOBNRv2ROM_DS_HI_sub1_Phase_ciall.dat", cvec_phi);
566 ret |=
read_matrix(dir,
"SEOBNRv2ROM_DS_HI_sub1_Bamp_bin.dat", Bamp);
567 ret |=
read_matrix(dir,
"SEOBNRv2ROM_DS_HI_sub1_Bphase_bin.dat", Bphi);
568 ret |=
read_vector(dir,
"SEOBNRv2ROM_DS_HI_sub1_AmpPrefac_ci.dat", cvec_amp_pre);
574 static int load_data_sub2(
const char dir[], gsl_vector *cvec_amp, gsl_vector *cvec_phi, gsl_matrix *Bamp, gsl_matrix *Bphi, gsl_vector *cvec_amp_pre) {
582 #ifdef LAL_HDF5_ENABLED
583 size_t size = strlen(dir) + strlen(ROMDataHDF5) + 2;
585 snprintf(
path, size,
"%s/%s", dir, ROMDataHDF5);
591 ReadHDF5RealVectorDataset(sub2,
"Amp_ciall", &cvec_amp);
592 ReadHDF5RealVectorDataset(sub2,
"Phase_ciall", &cvec_phi);
593 ReadHDF5RealVectorDataset(sub2,
"AmpPrefac_ci", &cvec_amp_pre);
595 ReadHDF5RealMatrixDataset(sub2,
"Bamp", &Bamp);
596 ReadHDF5RealMatrixDataset(sub2,
"Bphase", &Bphi);
610 ret |=
read_vector(dir,
"SEOBNRv2ROM_DS_HI_sub2_Amp_ciall.dat", cvec_amp);
611 ret |=
read_vector(dir,
"SEOBNRv2ROM_DS_HI_sub2_Phase_ciall.dat", cvec_phi);
612 ret |=
read_matrix(dir,
"SEOBNRv2ROM_DS_HI_sub2_Bamp_bin.dat", Bamp);
613 ret |=
read_matrix(dir,
"SEOBNRv2ROM_DS_HI_sub2_Bphase_bin.dat", Bphi);
614 ret |=
read_vector(dir,
"SEOBNRv2ROM_DS_HI_sub2_AmpPrefac_ci.dat", cvec_amp_pre);
620 static int load_data_sub3(
const char dir[], gsl_vector *cvec_amp, gsl_vector *cvec_phi, gsl_matrix *Bamp, gsl_matrix *Bphi, gsl_vector *cvec_amp_pre) {
628 #ifdef LAL_HDF5_ENABLED
629 size_t size = strlen(dir) + strlen(ROMDataHDF5) + 2;
631 snprintf(
path, size,
"%s/%s", dir, ROMDataHDF5);
637 ReadHDF5RealVectorDataset(sub3,
"Amp_ciall", &cvec_amp);
638 ReadHDF5RealVectorDataset(sub3,
"Phase_ciall", &cvec_phi);
639 ReadHDF5RealVectorDataset(sub3,
"AmpPrefac_ci", &cvec_amp_pre);
641 ReadHDF5RealMatrixDataset(sub3,
"Bamp", &Bamp);
642 ReadHDF5RealMatrixDataset(sub3,
"Bphase", &Bphi);
656 ret |=
read_vector(dir,
"SEOBNRv2ROM_DS_HI_sub3_Amp_ciall.dat", cvec_amp);
657 ret |=
read_vector(dir,
"SEOBNRv2ROM_DS_HI_sub3_Phase_ciall.dat", cvec_phi);
658 ret |=
read_matrix(dir,
"SEOBNRv2ROM_DS_HI_sub3_Bamp_bin.dat", Bamp);
659 ret |=
read_matrix(dir,
"SEOBNRv2ROM_DS_HI_sub3_Bphase_bin.dat", Bphi);
660 ret |=
read_vector(dir,
"SEOBNRv2ROM_DS_HI_sub3_AmpPrefac_ci.dat", cvec_amp_pre);
671 const double *etavec,
672 const double *chi1vec,
673 const double *chi2vec
676 if(!splinedata) exit(1);
682 const size_t nbreak_x = ncx-2;
683 const size_t nbreak_y = ncy-2;
684 const size_t nbreak_z = ncz-2;
687 gsl_bspline_workspace *bwx = gsl_bspline_alloc(4, nbreak_x);
688 gsl_bspline_workspace *bwy = gsl_bspline_alloc(4, nbreak_y);
689 gsl_bspline_workspace *bwz = gsl_bspline_alloc(4, nbreak_z);
692 gsl_vector *breakpts_x = gsl_vector_alloc(nbreak_x);
693 gsl_vector *breakpts_y = gsl_vector_alloc(nbreak_y);
694 gsl_vector *breakpts_z = gsl_vector_alloc(nbreak_z);
696 gsl_vector_set(breakpts_x,
i, etavec[
i]);
697 for (
UINT4 j=0; j<nbreak_y; j++)
698 gsl_vector_set(breakpts_y, j, chi1vec[j]);
699 for (
UINT4 k=0; k<nbreak_z; k++)
700 gsl_vector_set(breakpts_z, k, chi2vec[k]);
702 gsl_bspline_knots(breakpts_x, bwx);
703 gsl_bspline_knots(breakpts_y, bwy);
704 gsl_bspline_knots(breakpts_z, bwz);
706 gsl_vector_free(breakpts_x);
707 gsl_vector_free(breakpts_y);
708 gsl_vector_free(breakpts_z);
710 (*splinedata)->bwx=bwx;
711 (*splinedata)->bwy=bwy;
712 (*splinedata)->bwz=bwz;
717 if(!splinedata)
return;
718 if(splinedata->
bwx) gsl_bspline_free(splinedata->
bwx);
719 if(splinedata->
bwy) gsl_bspline_free(splinedata->
bwy);
720 if(splinedata->
bwz) gsl_bspline_free(splinedata->
bwz);
730 gsl_vector *cvec_amp,
731 gsl_vector *cvec_phi,
732 gsl_vector *cvec_amp_pre,
739 const double *etavec,
740 const double *chi1vec,
741 const double *chi2vec,
758 gsl_bspline_workspace *bwx=splinedata->
bwx;
759 gsl_bspline_workspace *bwy=splinedata->
bwy;
760 gsl_bspline_workspace *bwz=splinedata->
bwz;
764 for (
int k=0; k<
nk_amp; k++) {
765 gsl_vector v = gsl_vector_subvector(cvec_amp, k*
N,
N).vector;
767 gsl_vector_set(c_amp, k, csum);
771 for (
int k=0; k<
nk_phi; k++) {
772 gsl_vector v = gsl_vector_subvector(cvec_phi, k*
N,
N).vector;
774 gsl_vector_set(c_phi, k, csum);
787 SEOBNRROMdataDS_submodel **submodel,
792 const double *etavec,
793 const double *chi1vec,
794 const double *chi2vec,
803 if(!submodel) exit(1);
806 *submodel =
XLALCalloc(1,
sizeof(SEOBNRROMdataDS_submodel));
814 (*submodel)->cvec_amp = gsl_vector_alloc(
N*
nk_amp);
815 (*submodel)->cvec_phi = gsl_vector_alloc(
N*
nk_phi);
818 (*submodel)->cvec_amp_pre = gsl_vector_alloc(
N);
821 ret=
load_data(dir, (*submodel)->cvec_amp, (*submodel)->cvec_phi, (*submodel)->Bamp, (*submodel)->Bphi, (*submodel)->cvec_amp_pre);
824 (*submodel)->nk_amp =
nk_amp;
825 (*submodel)->nk_phi =
nk_phi;
826 (*submodel)->gA =
gA;
827 (*submodel)->gPhi =
gPhi;
828 (*submodel)->etavec = etavec;
829 (*submodel)->chi1vec = chi1vec;
830 (*submodel)->chi2vec = chi2vec;
831 (*submodel)->ncx = ncx;
832 (*submodel)->ncy = ncy;
833 (*submodel)->ncz = ncz;
840 if(submodel->cvec_amp) gsl_vector_free(submodel->cvec_amp);
841 if(submodel->cvec_phi) gsl_vector_free(submodel->cvec_phi);
842 if(submodel->Bamp) gsl_matrix_free(submodel->Bamp);
843 if(submodel->Bphi) gsl_matrix_free(submodel->Bphi);
844 if(submodel->cvec_amp_pre) gsl_vector_free(submodel->cvec_amp_pre);
853 XLALPrintError(
"WARNING: You tried to setup the SEOBNRv2ROMDoubleSpin model that was already initialised. Ignoring\n");
857 #ifdef LAL_HDF5_ENABLED
859 size_t size = strlen(dir) + strlen(ROMDataHDF5) + 2;
861 snprintf(
path, size,
"%s/%s", dir, ROMDataHDF5);
864 ret = ROM_check_version_number(
file, ROMDataHDF5_VERSION_MAJOR, ROMDataHDF5_VERSION_MINOR, ROMDataHDF5_VERSION_MICRO);
865 PrintInfoStringAttribute(
file,
"Email");
866 PrintInfoStringAttribute(
file,
"Description");
899 (romdata)->sub1 = NULL;
905 if(!romdatacoeff) exit(1);
912 (*romdatacoeff)->c_amp = gsl_vector_alloc(
nk_amp);
913 (*romdatacoeff)->c_phi = gsl_vector_alloc(
nk_phi);
918 if(romdatacoeff->
c_amp) gsl_vector_free(romdatacoeff->
c_amp);
919 if(romdatacoeff->
c_phi) gsl_vector_free(romdatacoeff->
c_phi);
926 return 1 << (size_t) ceil(log2(n));
931 SEOBNRROMdataDS_submodel *submodel_lo,
932 SEOBNRROMdataDS_submodel *submodel_hi,
933 gsl_vector* amp_f_lo,
934 gsl_vector* amp_f_hi,
939 gsl_interp_accel **acc_amp,
940 gsl_spline **spline_amp
945 SEOBNRROMdataDS_submodel *submodel_lo,
946 SEOBNRROMdataDS_submodel *submodel_hi,
947 gsl_vector* amp_f_lo,
948 gsl_vector* amp_f_hi,
953 gsl_interp_accel **acc_amp,
954 gsl_spline **spline_amp
959 for (jA_lo=0; jA_lo < submodel_lo->nk_amp; jA_lo++) {
960 if (submodel_lo->gA[jA_lo] > Mfm) {
968 for (jA_hi=0; jA_hi < submodel_hi->nk_amp; jA_hi++)
969 if (submodel_hi->gA[jA_hi] > Mfm)
972 int nA = 1 + jA_lo + (submodel_hi->nk_amp - jA_hi);
974 gsl_vector *gAU = gsl_vector_alloc(nA);
975 gsl_vector *amp_f = gsl_vector_alloc(nA);
978 for (
int i=0;
i<=jA_lo;
i++) {
979 gsl_vector_set(gAU,
i, submodel_lo->gA[
i]);
980 double A = amp_pre_lo * gsl_vector_get(amp_f_lo,
i);
981 gsl_vector_set(amp_f,
i, A);
984 for (
int i=jA_lo+1;
i<nA;
i++) {
985 int k = jA_hi - (jA_lo+1) +
i;
986 gsl_vector_set(gAU,
i, submodel_hi->gA[k]);
987 double A = amp_pre_hi * gsl_vector_get(amp_f_hi, k);
988 gsl_vector_set(amp_f,
i, A);
992 *acc_amp = gsl_interp_accel_alloc();
993 *spline_amp = gsl_spline_alloc(gsl_interp_cspline, nA);
995 gsl_spline_init(*spline_amp, gsl_vector_const_ptr(gAU,0), gsl_vector_const_ptr(amp_f,0), nA);
997 gsl_vector_free(gAU);
998 gsl_vector_free(amp_f);
999 gsl_vector_free(amp_f_lo);
1000 gsl_vector_free(amp_f_hi);
1006 SEOBNRROMdataDS_submodel *submodel_lo,
1007 SEOBNRROMdataDS_submodel *submodel_hi,
1008 gsl_vector* phi_f_lo,
1009 gsl_vector* phi_f_hi,
1012 gsl_interp_accel **acc_phi,
1013 gsl_spline **spline_phi
1018 for (jP_lo=0; jP_lo < submodel_lo->nk_phi; jP_lo++) {
1019 if (submodel_lo->gPhi[jP_lo] > Mfm) {
1027 for (jP_hi=0; jP_hi < submodel_hi->nk_phi; jP_hi++)
1028 if (submodel_hi->gPhi[jP_hi] > Mfm)
1031 int nP = 1 + jP_lo + (submodel_hi->nk_phi - jP_hi);
1032 gsl_vector *gPU = gsl_vector_alloc(nP);
1033 gsl_vector *phi_f = gsl_vector_alloc(nP);
1035 for (
int i=0;
i<=jP_lo;
i++) {
1036 gsl_vector_set(gPU,
i, submodel_lo->gPhi[
i]);
1037 double P = gsl_vector_get(phi_f_lo,
i);
1038 gsl_vector_set(phi_f,
i, P);
1041 for (
int i=jP_lo+1;
i<nP;
i++) {
1042 int k = jP_hi - (jP_lo+1) +
i;
1043 gsl_vector_set(gPU,
i, submodel_hi->gPhi[k]);
1044 double P = gsl_vector_get(phi_f_hi, k);
1045 gsl_vector_set(phi_f,
i, P);
1053 gsl_interp_accel *acc_phi_lo = gsl_interp_accel_alloc();
1054 gsl_spline *spline_phi_lo = gsl_spline_alloc(gsl_interp_cspline, submodel_lo->nk_phi);
1055 gsl_spline_init(spline_phi_lo, submodel_lo->gPhi, gsl_vector_const_ptr(phi_f_lo,0), submodel_lo->nk_phi);
1058 gsl_vector_const_view gP_hi_data = gsl_vector_const_view_array(submodel_hi->gPhi + jP_hi - nn, 2*nn+1);
1059 gsl_vector_const_view P_hi_data = gsl_vector_const_subvector(phi_f_hi, jP_hi - nn, 2*nn+1);
1060 gsl_vector *P_lo_data = gsl_vector_alloc(2*nn+1);
1061 for (
int i=0;
i<2*nn+1;
i++) {
1062 double P = gsl_spline_eval(spline_phi_lo, gsl_vector_get(&gP_hi_data.vector,
i), acc_phi_lo);
1063 gsl_vector_set(P_lo_data,
i, P);
1067 gsl_vector *cP_lo =
Fit_cubic(&gP_hi_data.vector, P_lo_data);
1068 gsl_vector *cP_hi =
Fit_cubic(&gP_hi_data.vector, &P_hi_data.vector);
1070 double P_lo_derivs[2];
1071 double P_hi_derivs[2];
1072 gsl_poly_eval_derivs(cP_lo->data, 4, Mfm, P_lo_derivs, 2);
1073 gsl_poly_eval_derivs(cP_hi->data, 4, Mfm, P_hi_derivs, 2);
1075 double delta_omega = P_hi_derivs[1] - P_lo_derivs[1];
1076 double delta_phi = P_hi_derivs[0] - P_lo_derivs[0] - delta_omega * Mfm;
1078 for (
int i=jP_lo+1;
i<nP;
i++) {
1079 int k = jP_hi - (jP_lo+1) +
i;
1080 double f = submodel_hi->gPhi[k];
1081 gsl_vector_set(gPU,
i, f);
1082 double P = gsl_vector_get(phi_f_hi, k) - delta_omega * f - delta_phi;
1083 gsl_vector_set(phi_f,
i, P);
1087 gsl_vector_free(P_lo_data);
1088 gsl_vector_free(cP_lo);
1089 gsl_vector_free(cP_hi);
1090 gsl_vector_free(phi_f_lo);
1091 gsl_vector_free(phi_f_hi);
1094 *acc_phi = gsl_interp_accel_alloc();
1095 *spline_phi = gsl_spline_alloc(gsl_interp_cspline, nP);
1097 gsl_spline_init(*spline_phi, gsl_vector_const_ptr(gPU,0), gsl_vector_const_ptr(phi_f,0), nP);
1101 gsl_vector_free(phi_f);
1102 gsl_vector_free(gPU);
1103 gsl_spline_free(spline_phi_lo);
1104 gsl_interp_accel_free(acc_phi_lo);
1136 if(!hptilde || !hctilde)
1142 "Error setting up SEOBNRv2ROMDoubleSpinHI data - check your $LAL_DATA_PATH\n");
1145 if(*hptilde || *hctilde)
1147 XLALPrintError(
"(*hptilde) and (*hctilde) are supposed to be NULL, but got %p and %p",(*hptilde),(*hctilde));
1153 if (eta > 0.25)
nudge(&eta, 0.25, 1
e-6);
1154 if (eta < 0.01)
nudge(&eta, 0.01, 1
e-6);
1155 if (chi1 < -0.9999)
nudge(&chi1, -0.9999, 1
e-4);
1156 if (chi1 > 0.98999)
nudge(&chi1, 0.98999, 1
e-4);
1157 if (chi2 < -0.9999)
nudge(&chi2, -0.9999, 1
e-4);
1158 if (chi2 > 0.98999)
nudge(&chi2, 0.98999, 1
e-4);
1160 if ( chi1 < -1.0 || chi2 < -1.0 || chi1 > 0.99 || chi2 > 0.99) {
1161 XLALPrintError(
"XLAL Error - %s: chi1 or chi2 smaller than -1.0 or larger than 0.99!\nSEOBNRv2ROMDoubleSpinHI is only available for spins in the range -1 <= a/M <= 0.99.\n", __func__);
1165 if (eta<0.01 || eta > 0.25) {
1166 XLALPrintError(
"XLAL Error - %s: eta (%f) smaller than 0.01 or unphysical!\nSEOBNRv2ROMDoubleSpin is only available for eta in the range 0.01 <= eta <= 0.25.\n", __func__,eta);
1171 SEOBNRROMdataDS_submodel *submodel_hi;
1172 SEOBNRROMdataDS_submodel *submodel_lo;
1173 submodel_lo = romdata->sub1;
1176 submodel_hi = romdata->sub2;
1178 submodel_hi = romdata->sub3;
1183 double fLow = freqs_in->
data[0];
1184 double fHigh = freqs_in->
data[freqs_in->
length - 1];
1190 double Mf_ROM_min = fmax(submodel_lo->gA[0], submodel_lo->gPhi[0]);
1191 double Mf_ROM_max = fmin(submodel_hi->gA[submodel_hi->nk_amp-1], submodel_hi->gPhi[submodel_hi->nk_phi-1]);
1192 double fLow_geom = fLow * Mtot_sec;
1193 double fHigh_geom = fHigh * Mtot_sec;
1194 double fRef_geom = fRef * Mtot_sec;
1195 double deltaF_geom = deltaF * Mtot_sec;
1200 if (fHigh_geom == 0 || fHigh_geom >
Mf_ROM_max)
1203 XLAL_ERROR(
XLAL_EDOM,
"End frequency %g is smaller than starting frequency %g!\n", fHigh_geom, fLow_geom);
1205 XLALPrintWarning(
"Reference frequency Mf_ref=%g is greater than maximal frequency in ROM Mf=%g. Starting at maximal frequency in ROM.\n", fRef_geom,
Mf_ROM_max);
1209 XLALPrintWarning(
"Reference frequency Mf_ref=%g is smaller than lowest frequency in ROM Mf=%g. Starting at lowest frequency in ROM.\n", fLow_geom,
Mf_ROM_min);
1214 XLALPrintWarning(
"Total mass=%gMsun > 500Msun. SEOBNRv2_ROM_DoubleSpin_HI disagrees with SEOBNRv2 for high total masses.\n", Mtot_sec/
LAL_MTSUN_SI);
1221 REAL8 amp_pre_lo, amp_pre_hi;
1228 submodel_lo->cvec_amp,
1229 submodel_lo->cvec_phi,
1230 submodel_lo->cvec_amp_pre,
1231 submodel_lo->nk_amp,
1232 submodel_lo->nk_phi,
1237 submodel_lo->etavec,
1238 submodel_lo->chi1vec,
1239 submodel_lo->chi2vec,
1240 romdata_coeff_lo->
c_amp,
1241 romdata_coeff_lo->
c_phi,
1255 submodel_hi->cvec_amp,
1256 submodel_hi->cvec_phi,
1257 submodel_hi->cvec_amp_pre,
1258 submodel_hi->nk_amp,
1259 submodel_hi->nk_phi,
1264 submodel_hi->etavec,
1265 submodel_hi->chi1vec,
1266 submodel_hi->chi2vec,
1267 romdata_coeff_hi->
c_amp,
1268 romdata_coeff_hi->
c_phi,
1281 gsl_vector* amp_f_lo = gsl_vector_alloc(submodel_lo->nk_amp);
1282 gsl_vector* phi_f_lo = gsl_vector_alloc(submodel_lo->nk_phi);
1283 gsl_blas_dgemv(CblasTrans, 1.0, submodel_lo->Bamp, romdata_coeff_lo->
c_amp, 0.0, amp_f_lo);
1284 gsl_blas_dgemv(CblasTrans, 1.0, submodel_lo->Bphi, romdata_coeff_lo->
c_phi, 0.0, phi_f_lo);
1286 gsl_vector* amp_f_hi = gsl_vector_alloc(submodel_hi->nk_amp);
1287 gsl_vector* phi_f_hi = gsl_vector_alloc(submodel_hi->nk_phi);
1288 gsl_blas_dgemv(CblasTrans, 1.0, submodel_hi->Bamp, romdata_coeff_hi->
c_amp, 0.0, amp_f_hi);
1289 gsl_blas_dgemv(CblasTrans, 1.0, submodel_hi->Bphi, romdata_coeff_hi->
c_phi, 0.0, phi_f_hi);
1291 const double Mfm = 0.01;
1294 gsl_interp_accel *acc_amp;
1295 gsl_spline *spline_amp;
1296 GlueAmplitude(submodel_lo, submodel_hi, amp_f_lo, amp_f_hi, amp_pre_lo, amp_pre_hi, Mfm,
1297 &acc_amp, &spline_amp
1301 gsl_interp_accel *acc_phi;
1302 gsl_spline *spline_phi;
1303 GluePhasing(submodel_lo, submodel_hi, phi_f_lo, phi_f_hi, Mfm,
1304 &acc_phi, &spline_phi
1313 npts =
NextPow2(fHigh_geom / deltaF_geom) + 1;
1314 if (fHigh_geom < fHigh * Mtot_sec)
1315 npts =
NextPow2(fHigh * Mtot_sec / deltaF_geom) + 1;
1323 double fHigh_temp = fHigh_geom / Mtot_sec;
1325 UINT4 iStop = (
UINT4) ceil(fHigh_temp / deltaF);
1331 freqs->
data[
i-iStart] =
i*deltaF_geom;
1345 freqs->
data[
i] = freqs_in->
data[
i] * Mtot_sec;
1348 if (!(*hptilde) || !(*hctilde)) {
1350 gsl_spline_free(spline_amp);
1351 gsl_spline_free(spline_phi);
1352 gsl_interp_accel_free(acc_amp);
1353 gsl_interp_accel_free(acc_phi);
1358 memset((*hptilde)->data->data, 0, npts *
sizeof(
COMPLEX16));
1359 memset((*hctilde)->data->data, 0, npts *
sizeof(
COMPLEX16));
1364 COMPLEX16 *pdata=(*hptilde)->data->data;
1365 COMPLEX16 *cdata=(*hctilde)->data->data;
1367 REAL8 cosi = cos(inclination);
1368 REAL8 pcoef = 0.5*(1.0 + cosi*cosi);
1373 double amp0 = Mtot * Mtot_sec *
LAL_MRSUN_SI / (distance);
1376 double phase_change = gsl_spline_eval(spline_phi, fRef_geom, acc_phi) - 2*phiRef;
1380 double f = freqs->
data[
i];
1383 double A = gsl_spline_eval(spline_amp, f, acc_amp);
1384 double phase = gsl_spline_eval(spline_phi, f, acc_phi) - phase_change;
1386 pdata[j] = pcoef * htilde;
1387 cdata[j] = -I * ccoef * htilde;
1400 if (Mf_final > freqs->
data[L-1])
1401 Mf_final = freqs->
data[L-1];
1402 if (Mf_final < freqs->
data[0]) {
1404 gsl_spline_free(spline_amp);
1405 gsl_spline_free(spline_phi);
1406 gsl_interp_accel_free(acc_amp);
1407 gsl_interp_accel_free(acc_phi);
1415 REAL8 t_corr = gsl_spline_eval_deriv(spline_phi, Mf_final, acc_phi) / (2*
LAL_PI);
1419 double f = freqs->
data[
i] - fRef_geom;
1421 pdata[j] *= cexp(-2*
LAL_PI * I * f * t_corr);
1422 cdata[j] *= cexp(-2*
LAL_PI * I * f * t_corr);
1427 gsl_spline_free(spline_amp);
1428 gsl_spline_free(spline_phi);
1429 gsl_interp_accel_free(acc_amp);
1430 gsl_interp_accel_free(acc_phi);
1487 struct tagCOMPLEX16FrequencySeries **hptilde,
1488 struct tagCOMPLEX16FrequencySeries **hctilde,
1503 double m1temp = m1SI;
1504 double chi1temp = chi1;
1514 double Mtot = mass1+mass2;
1515 double eta = mass1 * mass2 / (Mtot*Mtot);
1521 #ifdef LAL_PTHREAD_LOCK
1529 "Error setting up SEOBNRv2ROMDoubleSpinHI data - check your $LAL_DATA_PATH\n");
1535 phiRef, fRef, distance, inclination, Mtot_sec, eta, chi1, chi2, freqs, 0, nk_max);
1548 struct tagCOMPLEX16FrequencySeries **hptilde,
1549 struct tagCOMPLEX16FrequencySeries **hctilde,
1566 double m1temp = m1SI;
1567 double chi1temp = chi1;
1577 double Mtot = mass1+mass2;
1578 double eta = mass1 * mass2 / (Mtot*Mtot);
1585 #ifdef LAL_PTHREAD_LOCK
1595 freqs->
data[0] = fLow;
1596 freqs->
data[1] = fHigh;
1599 phiRef, fRef, distance, inclination, Mtot_sec, eta, chi1, chi2, freqs, deltaF, nk_max);
1610 gsl_spline **spline_phi,
1611 gsl_interp_accel **acc_phi,
1623 double Mtot = mass1 + mass2;
1624 double eta = mass1 * mass2 / (Mtot*Mtot);
1628 if (eta > 0.25)
nudge(&eta, 0.25, 1
e-6);
1629 if (eta < 0.01)
nudge(&eta, 0.01, 1
e-6);
1630 if (chi1 < -0.9999)
nudge(&chi1, -0.9999, 1
e-4);
1631 if (chi1 > 0.98999)
nudge(&chi1, 0.98999, 1
e-4);
1632 if (chi2 < -0.9999)
nudge(&chi2, -0.9999, 1
e-4);
1633 if (chi2 > 0.98999)
nudge(&chi2, 0.98999, 1
e-4);
1635 if ( chi1 < -1.0 || chi2 < -1.0 || chi1 > 0.99 || chi2 > 0.99) {
1636 XLALPrintError(
"XLAL Error - %s: chi1 or chi2 smaller than -1.0 or larger than 0.99!\nSEOBNRv2ROMDoubleSpinHI is only available for spins in the range -1 <= a/M <= 0.99.\n", __func__);
1640 if (eta < 0.01 || eta > 0.25) {
1641 XLALPrintError(
"XLAL Error - %s: eta (%f) smaller than 0.01 or unphysical!\nSEOBNRv2ROMDoubleSpin is only available for spins in the range 0.01 <= eta <= 0.25.\n", __func__,eta);
1646 #ifdef LAL_PTHREAD_LOCK
1655 "Error setting up SEOBNRv2ROMDoubleSpinHI data - check your $LAL_DATA_PATH\n");
1659 SEOBNRROMdataDS_submodel *submodel_hi;
1660 SEOBNRROMdataDS_submodel *submodel_lo;
1661 submodel_lo = romdata->sub1;
1664 submodel_hi = romdata->sub2;
1666 submodel_hi = romdata->sub3;
1673 REAL8 amp_pre_lo, amp_pre_hi;
1681 submodel_lo->cvec_amp,
1682 submodel_lo->cvec_phi,
1683 submodel_lo->cvec_amp_pre,
1684 submodel_lo->nk_amp,
1685 submodel_lo->nk_phi,
1690 submodel_lo->etavec,
1691 submodel_lo->chi1vec,
1692 submodel_lo->chi2vec,
1693 romdata_coeff_lo->
c_amp,
1694 romdata_coeff_lo->
c_phi,
1708 submodel_hi->cvec_amp,
1709 submodel_hi->cvec_phi,
1710 submodel_hi->cvec_amp_pre,
1711 submodel_hi->nk_amp,
1712 submodel_hi->nk_phi,
1717 submodel_hi->etavec,
1718 submodel_hi->chi1vec,
1719 submodel_hi->chi2vec,
1720 romdata_coeff_hi->
c_amp,
1721 romdata_coeff_hi->
c_phi,
1732 gsl_vector* phi_f_lo = gsl_vector_alloc(submodel_lo->nk_phi);
1733 gsl_blas_dgemv(CblasTrans, 1.0, submodel_lo->Bphi, romdata_coeff_lo->
c_phi, 0.0, phi_f_lo);
1735 gsl_vector* phi_f_hi = gsl_vector_alloc(submodel_hi->nk_phi);
1736 gsl_blas_dgemv(CblasTrans, 1.0, submodel_hi->Bphi, romdata_coeff_hi->
c_phi, 0.0, phi_f_hi);
1738 const double Mfm = 0.01;
1741 GluePhasing(submodel_lo, submodel_hi, phi_f_lo, phi_f_hi, Mfm,
1779 double m1temp = m1SI;
1780 double chi1temp = chi1;
1788 gsl_spline *spline_phi;
1789 gsl_interp_accel *acc_phi;
1790 double Mf_final, Mtot_sec;
1800 double t_corr = gsl_spline_eval_deriv(spline_phi, Mf_final, acc_phi) / (2*
LAL_PI);
1803 double Mf = frequency * Mtot_sec;
1804 if (Mf < Mf_ROM_min || Mf >
Mf_ROM_max || Mf > Mf_final) {
1805 gsl_spline_free(spline_phi);
1806 gsl_interp_accel_free(acc_phi);
1811 double time_M = gsl_spline_eval_deriv(spline_phi, frequency * Mtot_sec, acc_phi) / (2*
LAL_PI) - t_corr;
1812 *t = time_M * Mtot_sec;
1814 gsl_spline_free(spline_phi);
1815 gsl_interp_accel_free(acc_phi);
1848 double m1temp = m1SI;
1849 double chi1temp = chi1;
1857 gsl_spline *spline_phi;
1858 gsl_interp_accel *acc_phi;
1859 double Mf_final, Mtot_sec;
1868 double t_corr = gsl_spline_eval_deriv(spline_phi, Mf_final, acc_phi) / (2*
LAL_PI);
1874 double log_f_pts[
N];
1875 double log_t_pts[
N];
1877 double log_f_rng_2 = log(Mf_final/2.0);
1878 double dlog_f = (log_f_rng_2 - log_f_min) / (
N-1);
1881 for (
int i=0;
i<
N;
i++) {
1882 log_f_pts[
i] = log_f_rng_2 -
i*dlog_f;
1884 double time_M = gsl_spline_eval_deriv(spline_phi, exp(log_f_pts[
i]), acc_phi) / (2*
LAL_PI) - t_corr;
1885 log_t_pts[
i] = log(time_M * Mtot_sec);
1889 double t_rng_2 = exp(log_t_pts[0]);
1890 double t_min = exp(log_t_pts[
N-1]);
1891 if (t < t_rng_2 || t > t_min) {
1892 gsl_spline_free(spline_phi);
1893 gsl_interp_accel_free(acc_phi);
1894 XLAL_ERROR(
XLAL_EDOM,
"The frequency of time %g is outside allowed frequency range.\n", t);
1898 gsl_interp_accel *acc = gsl_interp_accel_alloc();
1899 gsl_spline *spline = gsl_spline_alloc(gsl_interp_cspline,
N);
1900 gsl_spline_init(spline, log_t_pts, log_f_pts,
N);
1902 *frequency = exp(gsl_spline_eval(spline, log(t), acc)) / Mtot_sec;
1904 gsl_spline_free(spline);
1905 gsl_interp_accel_free(acc);
1906 gsl_spline_free(spline_phi);
1907 gsl_interp_accel_free(acc_phi);
1922 #ifdef LAL_HDF5_ENABLED
1923 #define datafile ROMDataHDF5
1925 const char datafile[] =
"SEOBNRv2ROM_DS_HI_sub1_Phase_ciall.dat";
1931 char *dir = dirname(
path);
struct tagLALH5File LALH5File
static const REAL8 Mf_ROM_max
static const REAL8 Mf_ROM_min
static void nudge(REAL8 *x, REAL8 X, REAL8 epsilon)
Auxiliary functions for SEOBNRv1/v2 reduced order modeling codes in LALSimIMRSEOBNRv2ROMDoubleSpin....
static UNUSED gsl_vector * Fit_cubic(const gsl_vector *xi, const gsl_vector *yi)
static UNUSED REAL8 Interpolate_Coefficent_Tensor(gsl_vector *v, REAL8 eta, REAL8 chi1, REAL8 chi2, int ncy, int ncz, gsl_bspline_workspace *bwx, gsl_bspline_workspace *bwy, gsl_bspline_workspace *bwz)
static UNUSED int read_vector(const char dir[], const char fname[], gsl_vector *v)
static UNUSED double SEOBNRROM_Ringdown_Mf_From_Mtot_Eta(const double Mtot_sec, const double eta, const double chi1, const double chi2, Approximant apx)
static UNUSED int read_matrix(const char dir[], const char fname[], gsl_matrix *m)
static const double gPhi[]
static int load_data(const char dir[], gsl_vector *cvec_amp, gsl_vector *cvec_phi, gsl_matrix *Bamp, gsl_matrix *Bphi, gsl_vector *cvec_amp_pre)
static const double chi1vec_sub1[]
static const double etavec_sub1[]
static const int ncx_sub2
static int SEOBNRv2ROMDoubleSpinCore(COMPLEX16FrequencySeries **hptilde, COMPLEX16FrequencySeries **hctilde, double phiRef, double fRef, double distance, double inclination, double Mtot_sec, double eta, double chi1, double chi2, const REAL8Sequence *freqs, double deltaF, int nk_max)
Core function for computing the ROM waveform.
static int SEOBNRROMdataDS_Init_submodel(SEOBNRROMdataDS_submodel **submodel, const int nk_amp, const int nk_phi, const double *gA, const double *gPhi, const double *etavec, const double *chi1vec, const double *chi2vec, const int ncx, const int ncy, const int ncz, const char dir[], load_dataPtr load_data)
static bool SEOBNRv2ROMDoubleSpin_IsSetup(void)
Helper function to check if the SEOBNRv2ROMDoubleSpin model has been initialised.
static void GluePhasing(SEOBNRROMdataDS_submodel *submodel_lo, SEOBNRROMdataDS_submodel *submodel_hi, gsl_vector *phi_f_lo, gsl_vector *phi_f_hi, const double Mfm, gsl_interp_accel **acc_phi_out, gsl_spline **spline_phi_out)
static const double chi1vec_sub2[]
int(* load_dataPtr)(const char *, gsl_vector *, gsl_vector *, gsl_matrix *, gsl_matrix *, gsl_vector *)
static const double gPhi_sub1[]
static const int ncy_sub1
static const int ncx_sub1
static void SEOBNRv2ROMDoubleSpin_Init_LALDATA(void)
Setup SEOBNRv2ROMDoubleSpin model using data files installed in $LAL_DATA_PATH.
static const double g_sub2[]
static const int ncz_sub1
static int SEOBNRv2ROMDoubleSpin_Init(const char dir[])
Setup SEOBNRv2ROMDoubleSpin model using data files installed in dir.
static const double etavec_sub3[]
static const int ncz_sub3
static void SplineData_Destroy(SplineData *splinedata)
int XLALSimIMRSEOBNRv2ROMDoubleSpinHITimeOfFrequency(REAL8 *t, REAL8 frequency, REAL8 m1SI, REAL8 m2SI, REAL8 chi1, REAL8 chi2)
Compute the 'time' elapsed in the ROM waveform from a given starting frequency until the ringdown.
static const int ncx_sub3
static const double chi2vec_sub1[]
static const int ncy_sub2
static UNUSED REAL8 Interpolate_Coefficent_Matrix(gsl_vector *v, REAL8 eta, REAL8 chi, int ncx, int ncy, gsl_bspline_workspace *bwx, gsl_bspline_workspace *bwy)
static const int ncz_sub2
static SEOBNRROMdataDS __lalsim_SEOBNRv2ROMDS_data
static void SplineData_Init(SplineData **splinedata, int ncx, int ncy, int ncz, const double *etavec, const double *chi1vec, const double *chi2vec)
static int load_data_sub1(const char dir[], gsl_vector *cvec_amp, gsl_vector *cvec_phi, gsl_matrix *Bamp, gsl_matrix *Bphi, gsl_vector *cvec_amp_pre)
int XLALSimIMRSEOBNRv2ROMDoubleSpinHIFrequencyOfTime(REAL8 *frequency, REAL8 t, REAL8 m1SI, REAL8 m2SI, REAL8 chi1, REAL8 chi2)
Compute the starting frequency so that the given amount of 'time' elapses in the ROM waveform from th...
static int load_data_sub3(const char dir[], gsl_vector *cvec_amp, gsl_vector *cvec_phi, gsl_matrix *Bamp, gsl_matrix *Bphi, gsl_vector *cvec_amp_pre)
static const double gA_sub1[]
static UNUSED int read_vector_test(const char dir[], const char fname[], gsl_vector *v)
static int load_data_sub2(const char dir[], gsl_vector *cvec_amp, gsl_vector *cvec_phi, gsl_matrix *Bamp, gsl_matrix *Bphi, gsl_vector *cvec_amp_pre)
static const double chi2vec_sub3[]
static const double etavec_sub2[]
static const double chi2vec_sub2[]
static void SEOBNRROMdataDS_coeff_Init(SEOBNRROMdataDS_coeff **romdatacoeff, int nk_amp, int nk_phi)
static void SEOBNRROMdataDS_Cleanup_submodel(SEOBNRROMdataDS_submodel *submodel)
static void SEOBNRROMdataDS_coeff_Cleanup(SEOBNRROMdataDS_coeff *romdatacoeff)
static int SEOBNRv2ROMDoubleSpinTimeFrequencySetup(gsl_spline **spline_phi, gsl_interp_accel **acc_phi, REAL8 *Mf_final, REAL8 *Mtot_sec, REAL8 m1SI, REAL8 m2SI, REAL8 chi1, REAL8 chi2)
static int TP_Spline_interpolation_3d(REAL8 eta, REAL8 chi1, REAL8 chi2, gsl_vector *cvec_amp, gsl_vector *cvec_phi, gsl_vector *cvec_amp_pre, int nk_amp, int nk_phi, int nk_max, int ncx, int ncy, int ncz, const double *etavec, const double *chi1vec, const double *chi2vec, gsl_vector *c_amp, gsl_vector *c_phi, REAL8 *amp_pre)
static void SEOBNRROMdataDS_Cleanup(SEOBNRROMdataDS *romdata)
static void GlueAmplitude(SEOBNRROMdataDS_submodel *submodel_lo, SEOBNRROMdataDS_submodel *submodel_hi, gsl_vector *amp_f_lo, gsl_vector *amp_f_hi, double amp_pre_lo, double amp_pre_hi, const double Mfm, gsl_interp_accel **acc_amp, gsl_spline **spline_amp)
static size_t NextPow2(const size_t n)
static const double chi1vec_sub3[]
static const int ncy_sub3
static int SEOBNRROMdataDS_Init(SEOBNRROMdataDS *romdata, const char dir[])
#define XLAL_FILE_RESOLVE_PATH(fname)
COMPLEX16FrequencySeries * XLALCreateCOMPLEX16FrequencySeries(const CHAR *name, const LIGOTimeGPS *epoch, REAL8 f0, REAL8 deltaF, const LALUnit *sampleUnits, size_t length)
void XLALH5FileClose(LALH5File UNUSED *file)
LALH5File * XLALH5GroupOpen(LALH5File UNUSED *file, const char UNUSED *name)
LALH5File * XLALH5FileOpen(const char UNUSED *path, const char UNUSED *mode)
void * XLALCalloc(size_t m, size_t n)
void * XLALMalloc(size_t n)
int XLALSimIMRSEOBNRv2ROMDoubleSpinHI(struct tagCOMPLEX16FrequencySeries **hptilde, struct tagCOMPLEX16FrequencySeries **hctilde, REAL8 phiRef, REAL8 deltaF, REAL8 fLow, REAL8 fHigh, REAL8 fRef, REAL8 distance, REAL8 inclination, REAL8 m1SI, REAL8 m2SI, REAL8 chi1, REAL8 chi2, INT4 nk_max)
Compute waveform in LAL format for the SEOBNRv2_ROM_DoubleSpin_HI model.
int XLALSimIMRSEOBNRv2ROMDoubleSpinHIFrequencySequence(struct tagCOMPLEX16FrequencySeries **hptilde, struct tagCOMPLEX16FrequencySeries **hctilde, const REAL8Sequence *freqs, REAL8 phiRef, REAL8 fRef, REAL8 distance, REAL8 inclination, REAL8 m1SI, REAL8 m2SI, REAL8 chi1, REAL8 chi2, INT4 nk_max)
Compute waveform in LAL format at specified frequencies for the SEOBNRv2_ROM_DoubleSpin_HI model.
@ SEOBNRv2
Spin-aligned EOBNR model v2.
void XLALDestroyREAL8Sequence(REAL8Sequence *sequence)
REAL8Sequence * XLALCreateREAL8Sequence(size_t length)
const LALUnit lalStrainUnit
const LALUnit lalSecondUnit
LALUnit * XLALUnitMultiply(LALUnit *output, const LALUnit *unit1, const LALUnit *unit2)
#define XLAL_ERROR_VOID(...)
#define XLAL_PRINT_INFO(...)
int int int XLALPrintInfo(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
int int XLALPrintWarning(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
LIGOTimeGPS * XLALGPSAdd(LIGOTimeGPS *epoch, REAL8 dt)
int pthread_once(pthread_once_t *once_control, void(*init_routine)(void))
gsl_bspline_workspace * bwx
gsl_bspline_workspace * bwz
gsl_bspline_workspace * bwy
gsl_vector * cvec_amp_pre
SEOBNRROMdataDS_submodel * sub2
SEOBNRROMdataDS_submodel * sub1
SEOBNRROMdataDS_submodel * sub3