55 #define UNUSED __attribute__ ((unused))
63 #include <gsl/gsl_bspline.h>
64 #include <gsl/gsl_blas.h>
65 #include <gsl/gsl_spline.h>
66 #include <gsl/gsl_complex_math.h>
68 #include <lal/SeqFactories.h>
69 #include <lal/FileIO.h>
70 #include <lal/H5FileIO.h>
71 #include <lal/XLALError.h>
72 #include <lal/LALSimIMR.h>
79 #ifdef LAL_PTHREAD_LOCK
83 #ifdef LAL_PTHREAD_LOCK
84 static pthread_once_t NRSur7dq4Remnant_is_initialized = PTHREAD_ONCE_INIT;
148 gsl_vector* fit_params,
160 UINT4 unlim_extrap = 0;
161 if (LALparams != NULL &&
169 REAL8 chiAmag = sqrt(chiAx*chiAx + chiAy*chiAy + chiAz*chiAz);
170 REAL8 chiBmag = sqrt(chiBx*chiBx + chiBy*chiBy + chiBz*chiBz);
173 REAL8 q_max_soft = 4.01;
174 REAL8 chi_max_soft = 0.81;
177 REAL8 q_max_hard = 6.01;
182 if ((
q > q_max_hard) && (unlim_extrap == 0)) {
184 "Too much extrapolation in mass ratio; q = %0.4f > %0.4f\n",
187 if (
q > q_max_soft) {
189 "Extrapolating outside training range q = %0.4f > %0.4f\n",
195 "Invalid spin magnitude |chiA| = %0.4f > 1\n", chiAmag);
199 "Invalid spin magnitude |chiB| = %0.4f > 1\n", chiBmag);
201 if (chiAmag > chi_max_soft) {
203 "Extrapolating outside training range |chiA| = %0.4f > %0.4f\n",
204 chiAmag, chi_max_soft);
206 if (chiBmag > chi_max_soft) {
208 "Extrapolating outside training range |chiB| = %0.4f > %0.4f\n",
209 chiBmag, chi_max_soft);
214 const REAL8 chi_wtAvg = (
q*chiAz+chiBz)/(1.+
q);
216 = (chi_wtAvg - 38.*eta/113.*(chiAz + chiBz))/(1. - 76.*eta/113.);
217 const REAL8 chi_a = (chiAz - chiBz)/2.;
220 "Size of fit_params should be 7, not %zu.\n", fit_params->size);
222 gsl_vector_set(fit_params, 0, log(
q));
223 gsl_vector_set(fit_params, 1, chiAx);
224 gsl_vector_set(fit_params, 2, chiAy);
225 gsl_vector_set(fit_params, 3, chi_hat);
226 gsl_vector_set(fit_params, 4, chiBx);
227 gsl_vector_set(fit_params, 5, chiBy);
228 gsl_vector_set(fit_params, 6, chi_a);
263 char *remnant_property,
267 #ifdef LAL_PTHREAD_LOCK
276 if (!sur_data->
setup) {
281 gsl_vector *dummy_worker = gsl_vector_alloc(sur_data->
params_dim);
284 gsl_vector *fit_params = gsl_vector_alloc(sur_data->
params_dim);
286 s2x, s2y, s2z, LALparams);
293 if (strcmp(remnant_property,
"mf") == 0) {
297 *result = gsl_vector_alloc(1);
300 gsl_vector_set(*result, 0, tmp);
308 if (strcmp(remnant_property,
"chif") == 0) {
310 }
else if (strcmp(remnant_property,
"vf") == 0) {
314 "of 'mf', 'chif' or 'vf'");
317 *result = gsl_vector_alloc(vec_data->
vec_dim);
320 sur_data->
x_train, dummy_worker);
321 gsl_vector_set(*result,
i, tmp);
struct tagLALH5File LALH5File
int XLALDictContains(const LALDict *dict, const char *key)
UINT4 XLALDictLookupUINT4Value(LALDict *dict, const char *key)
REAL8 NRHybSur_eval_fit(const NRHybSurFitData *fit_data, const gsl_vector *fit_params, const gsl_matrix *x_train, gsl_vector *dummy_worker)
Evaluate a NRHybSur fit.
static bool NRSur7dq4Remnant_IsSetup(void)
Helper function to check if the NRSur7dq4Remnant model has been initialized.
int XLALNRSur7dq4Remnant(gsl_vector **result, REAL8 q, REAL8 s1x, REAL8 s1y, REAL8 s1z, REAL8 s2x, REAL8 s2y, REAL8 s2z, char *remnant_property, LALDict *LALparams)
Returns the remnant BH's mass, spin, or kick according to NRSur7dq4Remnant model.
static int NRSur7dq4Remnant_fitParams(gsl_vector *fit_params, const REAL8 q, const REAL8 chiAx, const REAL8 chiAy, const REAL8 chiAz, const REAL8 chiBx, const REAL8 chiBy, const REAL8 chiBz, LALDict *LALparams)
Map from mass ratio and spins to surrogate fit parameters.
static PrecessingRemnantFitData __lalsim_NRSur7dq4Remnant_data
Global surrogate data.
static void NRSur7dq4Remnant_Init_LALDATA(void)
Surrogate initialization.
NRSur7dq4Remnant model for remnant BH mass, spin and recoil kick for generically precessing BBH.
static const char NRSur7dq4Remnant_DATAFILE[]
void NRSurRemnant_LoadH5File(LALH5File **file, const char *NRSurRemnant_DATAFILE)
Loads H5 file for a NRSurRemnant model.
int PrecessingNRSurRemnant_Init(PrecessingRemnantFitData *sur_data, LALH5File *file)
Initializes fit data for a precessing NRSurRemnant.
Utils for NR surrogates for remnant BH mass, spin and recoil kick.
#define print_warning(...)
void XLALH5FileClose(LALH5File UNUSED *file)
#define XLAL_ERROR_VOID(...)
#define XLAL_CHECK(assertion,...)
int pthread_once(pthread_once_t *once_control, void(*init_routine)(void))
NRSurRemnant GPR fit data for the mass, spin, and recoil kick for generically precessing BBHs.
VectorFitData * vf_data
Fit data for recoil kick.
UINT4 setup
Indicates if NRSurRemnant has been initialized.
ScalarFitData * mf_data
Fit data for final mass.
UINT4 params_dim
Dimensions of the model.
VectorFitData * chif_data
Fit data for final spin.
gsl_matrix * x_train
Training set parameters, needed for GPR fits.
Data used in a single vector fit NOTE: basisFunctionOrders, coefs, componentIndices,...
FitData ** fit_data
Vector of FitData.
int vec_dim
Dimension of the vector.