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 <lal/Units.h>
43 #include <lal/SeqFactories.h>
44 #include <lal/LALConstants.h>
45 #include <lal/XLALError.h>
46 #include <lal/FrequencySeries.h>
48 #include <lal/StringInput.h>
49 #include <lal/Sequence.h>
50 #include <lal/LALStdio.h>
51 #include <lal/FileIO.h>
53 #include <lal/LALSimInspiral.h>
54 #include <lal/LALSimIMR.h>
57 #include <lal/LALConfig.h>
58 #ifdef LAL_PTHREAD_LOCK
68 static const double gA[] = {0.0001,0.00010412,0.000108409744,0.00011287622545279999,0.00011752672594145534, 0.00012236882705024332,
69 0.00012741042272471334,0.00013265973214097152,0.00013812531310517954,0.00014381607600511294,0.0001497412983365236,
70 0.00015591063982798835,0.00016233415818890147,0.0001690223255062842,0.00017598604531714312,0.0001832366703842094,
71 0.00019078602120403885,0.00019864640527764526,0.00020683063717508426,0.00021535205942669773,0.00022422456427507767,
72 0.00023346261632321087,0.00024308127611572715,0.0002530962246916951,0.00026352378914899294,0.00027438096926193147,
73 0.00028568546519552304,0.00029745570636157857,0.0003097108814636756,0.000322470969779979,0.0003357567737349142,
74 0.00034958995281279267,0.00036399305886867974,0.00037898957289406936,0.000394603943297305,0.000410861625761154,
75 0.00042778912474251355,0.0004454140366819051,0.0004637650949931996,0.0004828722169069194,0.0005027665522434845,
76 0.0005234805341959161,0.0005450479322047879,0.0005675039070116251,0.000590885067980504,0.0006152295327813008,
77 0.0006405769895318904,0.0006669687615006042,0.0006944478744744291,0.0007230591269027756,0.00075284916293117,
78 0.0007838665484439342,0.0008161618502398242,0.000849787718469705,0.0008847989724706569,0.0009212526901364479,
79 0.0009592083009700695,0.0009987276829700365,0.001039875263508402,0.0010827181243649481,0.001127326111088784,
80 0.0011737719468656418,0.0012221313510765062,0.0012724831627408582,0.0013249094690457816,0.0013794957391704678,
81 0.001436330963624291,0.0014955077993256119,0.001557122720657827,0.0016212761767489296,0.0016880727552309855,
82 0.0017576213527465022,0.0018300353524796581,0.00190543280900182,0.001983936640732695,0.002065674830330882,
83 0.0021507806333405143,0.0022393927954341437,0.0023316557786060305,0.002427719996684599,0.0025277420605480045,
84 0.002631885033442582,0.0027403186968204163,0.0028532198271294176,0.0029707724840071495,0.003093168310348244,
85 0.0032206068447345917,0.003353295846737657,0.0034914516356232485,0.0036352994430109264,0.0037850737800629764,
86 0.003941018819801571,0.0041033887951773965,0.004272448413538705,0.0044484732881765,0.004631750387649371,0.004822578503620526,
87 0.005021268737969691,0.0052281450099740424,0.005443544584384973,0.005667818621261634,0.005901332748457613,
88 0.0061444676576940666,0.006397619725191062,0.006661201657868934,0.006935643166173134,0.007221391664619468,0.00751891300120179,
89 0.007828692216851304,0.008151234336185578,0.008487065190836423,0.008836732276698884,0.009200805646498878,0.009579878839134632,
90 0.009974569847306979,0.010385522125016027,0.010813405636566686,0.011258917948793233,0.011722785368283514,0.012205764125456795,
91 0.012708641607425615,0.01323223764165155,0.013777405832487594,0.014345034952786082,0.014936050392840869,0.015551415669025912,
92 0.01619213399458978,0.01685924991516688,0.017553851011671756,0.018277069673352634,0.019030084943894764,0.019814124443583228,
93 0.020630466370658858,0.021480441585130003,0.02236543577843736,0.023286891732508978,0.024246311671888347,0.025245259712770148,
94 0.026285364412936277,0.02736832142674925,0.02849589626953132,0.029669927195836013,0.030892328196304455,0.0321650921179922,
95 0.03349029391325348,0.03487009402247952,0.036306741896205676,0.03780257966232935,0.03936004594441732,0.04098167983732731,
96 0.0426701250466252,0.04442813419854616,0.04625857332752626,0.04816442654862034,0.0501488009224235,0.052214931520427346,
97 0.05436618669906895,0.056606073591070595,0.05893824382302271,0.06136649946853124,0.06389479924663473,0.06652726497559608,
98 0.06926818829259064,0.07212203765024537,0.07509346560143548,0.07818731638421463,0.08140863381924426,0.08476266953259713,
99 0.08825489151734013,0.09189099304785454,0.09567690196142616,0.09961879032223692,0.10372308448351308,0.10799647556423382,
100 0.11244593035748025,0.11707870268820844,0.12190234523896262,0.12692472186280787,0.13215402040355556,0.13759876604418206,
101 0.14326783520520237,0.1491704700156567,0.15531629338030176,0.1617153246675702,0.16837799604387407,0.1753151694808817,
102 0.182538154463494,0.19005872642738997,0.19788914595619844,0.20604217876959383,0.2145311165349011,0.223369798536139,
103 0.23257263423582794,0.24215462676634406,0.25213139738911744,0.26251921096154907,0.2733350024531649,0.2845964045542353,
104 0.2963217764218698,0.3};
106 static const double gPhi[] = {0.0001,0.0001011603972084032,0.00010233878267233898,0.00010353550576343408,0.00010475092401703343,0.00010598540335537165,
107 0.00010723931831773738,0.0001085130522978776,0.00010980699778889891,0.00011112155663593303,0.00011245714029684425,
108 0.00011381417011126748,0.00011519307757827774,0.00011659430464300309,0.00011801830399250643,0.00011946553936127435,
109 0.00012093648584666495,0.00012243163023468122,0.0001239514713364512,0.00012549652033581237,0.00012706730114841344,
110 0.00012866435079276461,0.0001302882197736849,0.00013193947247861382,0.0001336186875872749,0.00013532645849519842,
111 0.00013706339375163268,0.00013883011751239573,0.00014062727000824248,0.00014245550802934775,0.00014431550542653068,
112 0.00014620795362987388,0.00014813356218541844,0.00015009305931064617,0.0001520871924694914,0.00015411672896765733,
113 0.00015618245656904637,0.00015828518413414986,0.00016042574228128018,0.00016260498407156794,0.00016482378571868855,
114 0.00016708304732432604,0.00016938369364042784,0.0001717266748593521,0.00017411296743306026,0.00017654357492255984,
115 0.000179019528878859,0.0001815418897567524,0.00018411174786282027,0.0001867302243390864,0.0001893984721838501,
116 0.0001921176773112781,0.00019488905965141826,0.00019771387429237596,0.00020059341266647862,0.00020352900378234071,
117 0.0002065220155048353,0.0002095738558850754,0.0002126859745426121,0.00021585986410216392,0.00021909706168730754,
118 0.0002223991504736801,0.00022576776130437057,0.0002292045743703129,0.00023271132095863427,0.00023628978527206272,
119 0.00023994180632265591,0.00024366927990327993,0.0002474741606404437,0.00025135846413228087,0.00025532426917566865,
120 0.000259373720086681,0.00026350902911879455,0.00026773247898349915,0.0002720464254782114,0.00027645330022665123,
121 0.0002809556135371191,0.0002855559573844033,0.00029025700852135906,0.00029506153172652994,0.00029997238319453087,
122 0.00030499251407628374,0.00031012497417658787,0.0003153729158169264,0.0003207395978718508,0.0003262283899877574,
123 0.00033184277699336776,0.0003375863635117564,0.0003434628787843332,0.000349476181717788,0.0003556302661656416,
124 0.00036192926645672906,0.00036837746318366013,0.0003749792892650752,0.00038173933629633125,0.00038866236120412836,
125 0.0003957532932215169,0.00040301724120071894,0.00041045950128225665,0.0004180855649400099,0.0004259011274230334,
126 0.00043391209661625043,0.0004421246023435188,0.0004505450061380353,0.0004591799115066175,0.00046803617471608764,
127 0.0004771209161317804,0.0004864415321401282,0.0004960057076893408,0.0005058214294844088,0.0005158969998750328,
128 0.0005262410514776242,0.0005368625625752512,0.0005477708733423325,0.0005589757029440297,0.000570487167563663,
129 0.0005823157994151132,0.0005944725668010725,0.0006069688952822128,0.0006198166900268609,0.0006330283594156419,
130 0.0006466168399807966,0.0006605956227655398,0.0006749787811949231,0.0006897810005562521,0.0007050176091942138,
131 0.0007207046115335476,0.0007368587230503925,0.0007534974073224147,0.0007706389152975295,0.0007883023269315418,
132 0.0008065075953564147,0.0008252755937532143,0.0008446281651171619,0.0008645881751167426,0.0008851795682645893,
133 0.0009064274276349821,0.0009283580383814316,0.0009509989553280604,0.0009743790749305488,0.0009985287119264209,
134 0.001023479681020617,0.0010492653839808423,0.0010759209025483307,0.0011034830976036844,0.0011319907150646252,
135 0.001161484499033161,0.0011920073127541697,0.001223604267996143,0.0012563228635182632,0.001290213133346581,
136 0.0013253278056463969,0.0013617224730486212,0.0013994557753655948,0.0014385895957173568,0.0014791892711835141,
137 0.0015213238191996614,0.0015650661810317963,0.0016104934837885981,0.001657687322571147,0.0017067340645141838,
138 0.0017577251766440938,0.0018107575796683735,0.0018659340300216179,0.0019233635327265298,0.0019831617878879122,
139 0.0020454516739262497,0.002110363770978921,0.002178036928255416,0.0022486188795328055,0.0023222669114244575,
140 0.0023991485895546133,0.002479442548330867,0.0025633393506336675,0.0026510424244457313,0.002742769084235,
141 0.0028387516457943815,0.0029392386442435347,0.0030444961660280956,0.003154809307027991,0.0032704837703296783,
142 0.0033918476188513494,0.0035192531998631655,0.00365307926054877,0.0037937332761471616,0.003941654014939118,
143 0.00409731436745065,0.0042612244707968,0.004433935163151941,0.0046160418079890615,0.004808188533075856,0.0050110729353623155,
144 0.005225451309975515,0.0054521444697090025,0.0056920442308420974,0.005946120652068382,0.006215430126014334,
145 0.006501124437600008,0.00680446092070622,0.007126813864712588,0.007469687345993064,0.007834729687044038,0.00822374977835156,
146 0.00863873553631827,0.00908187481570728,0.009555579148505829,0.01006251074455828,0.0106056132648355,0.011188146968337661,
147 0.011813728941498652,0.012486379248439126,0.013210573996293905,0.013991306498080315,0.014834157943620526,0.015745379266211335,
148 0.016731986230784316,0.017801870183039872,0.018963927407269193,0.02022821066724284,0.021606107280277058,0.023110549038761655,
149 0.024756260496891908,0.02656005364907936,0.028541178926603447,0.030721744843400595,0.03312722167935155,0.03578704849750366,
150 0.03873536781388351,0.04201191872880512,0.045663127765211343,0.049743447693639815,0.05431700914731336,0.05945966907716407,
151 0.06526156578101447,0.07183032477168075,0.07929510653451066,0.08781175113621649,0.0975693627088662,0.10879879928126432,0.115,
152 0.12178370533810129,0.13,0.1368749683040054,0.145,0.15450982970874225,0.17523738873197545,0.19975298003522046,
153 0.22894501461505934,0.26395954156353574,0.3};
155 #ifdef LAL_PTHREAD_LOCK
156 static pthread_once_t SEOBNRv2ROMEffectiveSpin_is_initialized = PTHREAD_ONCE_INIT;
161 typedef struct tagSEOBNRROMdata_coeff
180 typedef struct tagSplineData
182 gsl_bspline_workspace *bwx;
183 gsl_bspline_workspace *bwy;
199 static size_t NextPow2(
const size_t n);
203 static int read_vector(
const char dir[],
const char fname[], gsl_vector *v);
204 static int read_matrix(
const char dir[],
const char fname[], gsl_matrix *
m);
206 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);
211 gsl_vector *cvec_amp,
212 gsl_vector *cvec_phi,
213 gsl_vector *cvec_amp_pre,
245 gsl_spline **spline_phi,
246 gsl_interp_accel **acc_phi,
261 gsl_bspline_workspace *bwx,
262 gsl_bspline_workspace *bwy,
263 gsl_bspline_workspace *bwz
293 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) {
296 ret |=
read_vector(dir,
"SEOBNRv2ROM_SS_Amp_ciall.dat", cvec_amp);
297 ret |=
read_vector(dir,
"SEOBNRv2ROM_SS_Phase_ciall.dat", cvec_phi);
298 ret |=
read_matrix(dir,
"SEOBNRv2ROM_SS_Bamp_bin.dat", Bamp);
299 ret |=
read_matrix(dir,
"SEOBNRv2ROM_SS_Bphase_bin.dat", Bphi);
300 ret |=
read_vector(dir,
"SEOBNRv2ROM_SS_AmpPrefac_ci.dat", cvec_amp_pre);
306 if(!splinedata) exit(1);
313 (*splinedata)->ncx = ncx;
314 (*splinedata)->ncy = ncy;
317 double etavec[] = {0.01, 0.011, 0.012, 0.013, 0.014, 0.015, 0.016, 0.017, 0.018, 0.019, \
318 0.02, 0.0225, 0.025, 0.0275, 0.03, 0.035, 0.04, 0.045, 0.05, 0.055, \
319 0.06, 0.065, 0.07, 0.075, 0.08, 0.09, 0.1, 0.11, 0.12, 0.13, 0.14, \
320 0.15, 0.16, 0.17, 0.18, 0.19, 0.2, 0.21, 0.22, 0.23, 0.24, 0.245, \
321 0.247, 0.248, 0.2495, 0.2498, 0.2499, 0.25};
323 double chivec[] = {-1., -0.9, -0.8, -0.67115, -0.5423, -0.430639, -0.318978, -0.234489, \
324 -0.15, -0.075, 0., 0.130167, 0.260333, 0.34325, 0.426167, 0.514612, \
325 0.603056, 0.647278, 0.6915, 0.723561, 0.755622, 0.782156, 0.808689, \
326 0.829695, 0.8507, 0.861756, 0.872811, 0.888289, 0.903767, 0.904873, \
327 0.905978, 0.911506, 0.917033, 0.922561, 0.928089, 0.931406, 0.934722, \
328 0.935828, 0.936933, 0.942461, 0.947989, 0.955728, 0.963467, 0.9701, \
329 0.976733, 0.983367, 0.987, 0.99};
331 const size_t nbreak_x = ncx-2;
332 const size_t nbreak_y = ncy-2;
335 gsl_bspline_workspace *bwx = gsl_bspline_alloc(4, nbreak_x);
336 gsl_bspline_workspace *bwy = gsl_bspline_alloc(4, nbreak_y);
339 gsl_vector *breakpts_x = gsl_vector_alloc(nbreak_x);
340 gsl_vector *breakpts_y = gsl_vector_alloc(nbreak_y);
342 gsl_vector_set(breakpts_x,
i, etavec[
i]);
343 for (
UINT4 j=0; j<nbreak_y; j++)
344 gsl_vector_set(breakpts_y, j, chivec[j]);
346 gsl_bspline_knots(breakpts_x, bwx);
347 gsl_bspline_knots(breakpts_y, bwy);
349 gsl_vector_free(breakpts_x);
350 gsl_vector_free(breakpts_y);
352 (*splinedata)->bwx=bwx;
353 (*splinedata)->bwy=bwy;
358 if(!splinedata)
return;
359 if(splinedata->
bwx) gsl_bspline_free(splinedata->
bwx);
360 if(splinedata->
bwy) gsl_bspline_free(splinedata->
bwy);
369 gsl_vector *cvec_amp,
370 gsl_vector *cvec_phi,
371 gsl_vector *cvec_amp_pre,
379 gsl_bspline_workspace *bwx=splinedata->
bwx;
380 gsl_bspline_workspace *bwy=splinedata->
bwy;
382 int ncx = splinedata->
ncx;
383 int ncy = splinedata->
ncy;
387 for (
int k=0; k<
nk_amp; k++) {
388 gsl_vector v = gsl_vector_subvector(cvec_amp, k*
N,
N).vector;
390 gsl_vector_set(c_amp, k, csum);
394 for (
int k=0; k<
nk_phi; k++) {
395 gsl_vector v = gsl_vector_subvector(cvec_phi, k*
N,
N).vector;
397 gsl_vector_set(c_phi, k, csum);
420 XLAL_PRINT_WARNING(
"WARNING: You tried to setup the SEOBNRv2ROMEffectiveSpin model that was already initialised. Ignoring");
424 (romdata)->cvec_amp = gsl_vector_alloc(
N*
nk_amp);
425 (romdata)->cvec_phi = gsl_vector_alloc(
N*
nk_phi);
428 (romdata)->cvec_amp_pre = gsl_vector_alloc(
N);
429 ret=
load_data(dir, (romdata)->cvec_amp, (romdata)->cvec_phi, (romdata)->Bamp, (romdata)->Bphi, (romdata)->cvec_amp_pre);
440 if(romdata->cvec_amp) gsl_vector_free(romdata->cvec_amp);
441 if(romdata->cvec_phi) gsl_vector_free(romdata->cvec_phi);
442 if(romdata->Bamp) gsl_matrix_free(romdata->Bamp);
443 if(romdata->Bphi) gsl_matrix_free(romdata->Bphi);
444 if(romdata->cvec_amp_pre) gsl_vector_free(romdata->cvec_amp_pre);
451 if(!romdatacoeff) exit(1);
459 (*romdatacoeff)->c_amp = gsl_vector_alloc(
nk_amp);
460 (*romdatacoeff)->c_phi = gsl_vector_alloc(
nk_phi);
465 if(romdatacoeff->
c_amp) gsl_vector_free(romdatacoeff->
c_amp);
466 if(romdatacoeff->
c_phi) gsl_vector_free(romdatacoeff->
c_phi);
472 return 1 << (size_t) ceil(log2(n));
499 if(!hptilde || !hctilde)
502 if(*hptilde || *hctilde)
503 XLAL_ERROR(
XLAL_EFAULT,
"(*hptilde) and (*hctilde) are supposed to be NULL, but got %p and %p",(*hptilde),(*hctilde));
507 if (eta > 0.25)
nudge(&eta, 0.25, 1
e-6);
508 if (eta < 0.01)
nudge(&eta, 0.01, 1
e-6);
509 if (chi < -1.0)
nudge(&chi, -1.0, 1
e-6);
510 if (chi > 0.99)
nudge(&chi, 0.99, 1
e-6);
512 if (chi < -1.0 || chi > 0.99)
513 XLAL_ERROR(
XLAL_EDOM,
"XLAL Error - %s: chi (%f) smaller than -1 or larger than 0.99!\nSEOBNRv2ROMEffectiveSpin is only available for spins in the range -1 <= a/M <= 0.99.\n", __func__,chi);
515 if (eta < 0.01 || eta > 0.25)
516 XLAL_ERROR(
XLAL_EDOM,
"XLAL Error - %s: eta (%f) smaller than 0.01 or unphysical!\nSEOBNRv2ROMEffectiveSpin is only available for eta in the range 0.01 <= eta <= 0.25.\n", __func__,eta);
520 double fLow = freqs_in->
data[0];
521 double fHigh = freqs_in->
data[freqs_in->
length - 1];
529 double fLow_geom = fLow * Mtot_sec;
530 double fHigh_geom = fHigh * Mtot_sec;
531 double fRef_geom = fRef * Mtot_sec;
532 double deltaF_geom = deltaF * Mtot_sec;
540 XLALPrintWarning(
"Maximal frequency Mf_high=%g is greater than highest ROM frequency Mf_ROM_Max=%g. Using Mf_high=Mf_ROM_Max.", fHigh_geom,
Mf_ROM_max);
544 XLAL_ERROR(
XLAL_EDOM,
"End frequency %g is smaller than starting frequency %g!\n", fHigh_geom, fLow_geom);
546 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);
550 XLAL_PRINT_WARNING(
"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);
565 romdata->cvec_amp_pre,
566 romdata_coeff->
c_amp,
567 romdata_coeff->
c_phi,
573 XLAL_ERROR(retcode,
"Parameter-space interpolation failed.");
579 gsl_vector* amp_f = gsl_vector_alloc(
nk_amp);
580 gsl_vector* phi_f = gsl_vector_alloc(
nk_phi);
581 gsl_blas_dgemv(CblasTrans, 1.0, romdata->Bamp, romdata_coeff->
c_amp, 0.0, amp_f);
582 gsl_blas_dgemv(CblasTrans, 1.0, romdata->Bphi, romdata_coeff->
c_phi, 0.0, phi_f);
585 gsl_interp_accel *acc_amp = gsl_interp_accel_alloc();
586 gsl_spline *spline_amp = gsl_spline_alloc(gsl_interp_cspline,
nk_amp);
587 gsl_spline_init(spline_amp,
gA, gsl_vector_const_ptr(amp_f,0),
nk_amp);
589 gsl_interp_accel *acc_phi = gsl_interp_accel_alloc();
590 gsl_spline *spline_phi = gsl_spline_alloc(gsl_interp_cspline,
nk_phi);
591 gsl_spline_init(spline_phi,
gPhi, gsl_vector_const_ptr(phi_f,0),
nk_phi);
599 npts =
NextPow2(fHigh_geom / deltaF_geom) + 1;
600 if (fHigh_geom < fHigh * Mtot_sec)
601 npts =
NextPow2(fHigh * Mtot_sec / deltaF_geom) + 1;
609 double fHigh_temp = fHigh_geom / Mtot_sec;
611 UINT4 iStop = (
UINT4) ceil(fHigh_temp / deltaF);
617 freqs->
data[
i-iStart] =
i*deltaF_geom;
631 freqs->
data[
i] = freqs_in->
data[
i] * Mtot_sec;
634 if (!(*hptilde) || !(*hctilde)) {
636 gsl_spline_free(spline_amp);
637 gsl_spline_free(spline_phi);
638 gsl_interp_accel_free(acc_amp);
639 gsl_interp_accel_free(acc_phi);
640 gsl_vector_free(amp_f);
641 gsl_vector_free(phi_f);
645 memset((*hptilde)->data->data, 0, npts *
sizeof(
COMPLEX16));
646 memset((*hctilde)->data->data, 0, npts *
sizeof(
COMPLEX16));
654 REAL8 cosi = cos(inclination);
655 REAL8 pcoef = 0.5*(1.0 + cosi*cosi);
660 double amp0 = Mtot * amp_pre * Mtot_sec *
LAL_MRSUN_SI / (distance);
663 double phase_change = gsl_spline_eval(spline_phi, fRef_geom, acc_phi) - 2*phiRef;
667 double f = freqs->
data[
i];
670 double A = gsl_spline_eval(spline_amp, f, acc_amp);
671 double phase = gsl_spline_eval(spline_phi, f, acc_phi) - phase_change;
673 pdata[j] = pcoef * htilde;
674 cdata[j] = -I * ccoef * htilde;
684 if (Mf_final > freqs->
data[L-1])
685 Mf_final = freqs->
data[L-1];
686 if (Mf_final < freqs->
data[0])
689 gsl_spline_free(spline_amp);
690 gsl_spline_free(spline_phi);
691 gsl_interp_accel_free(acc_amp);
692 gsl_interp_accel_free(acc_phi);
693 gsl_vector_free(amp_f);
694 gsl_vector_free(phi_f);
701 REAL8 t_corr = gsl_spline_eval_deriv(spline_phi, Mf_final, acc_phi) / (2*
LAL_PI);
705 double f = freqs->
data[
i] - fRef_geom;
707 pdata[j] *= cexp(-2*
LAL_PI * I * f * t_corr);
708 cdata[j] *= cexp(-2*
LAL_PI * I * f * t_corr);
713 gsl_spline_free(spline_amp);
714 gsl_spline_free(spline_phi);
715 gsl_interp_accel_free(acc_amp);
716 gsl_interp_accel_free(acc_phi);
717 gsl_vector_free(amp_f);
718 gsl_vector_free(phi_f);
775 struct tagCOMPLEX16FrequencySeries **hptilde,
776 struct tagCOMPLEX16FrequencySeries **hctilde,
790 double Mtot = mass1+mass2;
791 double eta = mass1 * mass2 / (Mtot*Mtot);
797 #ifdef LAL_PTHREAD_LOCK
808 phiRef, fRef, distance, inclination, Mtot_sec, eta, chi, freqs, 0);
822 struct tagCOMPLEX16FrequencySeries **hptilde,
823 struct tagCOMPLEX16FrequencySeries **hctilde,
839 double Mtot = mass1+mass2;
840 double eta = mass1 * mass2 / (Mtot*Mtot);
847 #ifdef LAL_PTHREAD_LOCK
859 freqs->
data[0] = fLow;
860 freqs->
data[1] = fHigh;
863 phiRef, fRef, distance, inclination, Mtot_sec, eta, chi, freqs, deltaF);
893 gsl_spline *spline_phi;
894 gsl_interp_accel *acc_phi;
895 double Mf_final, Mtot_sec;
905 double t_corr = gsl_spline_eval_deriv(spline_phi, Mf_final, acc_phi) / (2*
LAL_PI);
908 double Mf = frequency * Mtot_sec;
911 gsl_spline_free(spline_phi);
912 gsl_interp_accel_free(acc_phi);
916 double time_M = gsl_spline_eval_deriv(spline_phi, frequency * Mtot_sec, acc_phi) / (2*
LAL_PI) - t_corr;
917 *t = time_M * Mtot_sec;
919 gsl_spline_free(spline_phi);
920 gsl_interp_accel_free(acc_phi);
951 gsl_spline *spline_phi;
952 gsl_interp_accel *acc_phi;
953 double Mf_final, Mtot_sec;
962 double t_corr = gsl_spline_eval_deriv(spline_phi, Mf_final, acc_phi) / (2*
LAL_PI);
971 double log_f_rng_2 = log(Mf_final/2.0);
972 double dlog_f = (log_f_rng_2 - log_f_min) / (
N-1);
975 for (
int i=0;
i<
N;
i++) {
976 log_f_pts[
i] = log_f_rng_2 -
i*dlog_f;
978 double time_M = gsl_spline_eval_deriv(spline_phi, exp(log_f_pts[
i]), acc_phi) / (2*
LAL_PI) - t_corr;
979 log_t_pts[
i] = log(time_M * Mtot_sec);
983 double t_rng_2 = exp(log_t_pts[0]);
984 double t_min = exp(log_t_pts[
N-1]);
985 if (t < t_rng_2 || t > t_min)
987 gsl_spline_free(spline_phi);
988 gsl_interp_accel_free(acc_phi);
989 XLAL_ERROR(
XLAL_EDOM,
"The frequency of time %g is outside allowed frequency range.\n", t);
993 gsl_interp_accel *acc = gsl_interp_accel_alloc();
994 gsl_spline *spline = gsl_spline_alloc(gsl_interp_cspline,
N);
995 gsl_spline_init(spline, log_t_pts, log_f_pts,
N);
997 *frequency = exp(gsl_spline_eval(spline, log(t), acc)) / Mtot_sec;
999 gsl_spline_free(spline);
1000 gsl_interp_accel_free(acc);
1001 gsl_spline_free(spline_phi);
1002 gsl_interp_accel_free(acc_phi);
1012 gsl_spline **spline_phi,
1013 gsl_interp_accel **acc_phi,
1024 double Mtot = mass1 + mass2;
1025 double eta = mass1 * mass2 / (Mtot*Mtot);
1034 if (chi < -1.0 || chi > 0.99)
1035 XLAL_ERROR(
XLAL_EDOM,
"XLAL Error - %s: chi (%f) smaller than -1 or larger than 0.99!\nSEOBNRv2ROMEffectiveSpin is only available for spins in the range -1 <= a/M <= 0.99.\n", __func__,chi);
1037 if (eta < 0.01 || eta > 0.25)
1038 XLAL_ERROR(
XLAL_EDOM,
"XLAL Error - %s: eta (%f) smaller than 0.01 or unphysical!\nSEOBNRv2ROMEffectiveSpin is only available for spins in the range 0.01 <= eta <= 0.25.\n", __func__,eta);
1041 #ifdef LAL_PTHREAD_LOCK
1060 romdata->cvec_amp_pre,
1061 romdata_coeff->
c_amp,
1062 romdata_coeff->
c_phi,
1073 gsl_vector* phi_f = gsl_vector_alloc(
nk_phi);
1074 gsl_blas_dgemv(CblasTrans, 1.0, romdata->Bphi, romdata_coeff->
c_phi, 0.0, phi_f);
1077 *acc_phi = gsl_interp_accel_alloc();
1078 *spline_phi = gsl_spline_alloc(gsl_interp_cspline,
nk_phi);
1079 gsl_spline_init(*spline_phi,
gPhi, gsl_vector_const_ptr(phi_f,0),
nk_phi);
1084 gsl_vector_free(phi_f);
1099 char datafile[] =
"SEOBNRv2ROM_SS_Phase_ciall.dat";
1104 char *dir = dirname(
path);
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 double SEOBNRROM_Ringdown_Mf_From_Mtot_Eta(const double Mtot_sec, const double eta, const double chi1, const double chi2, Approximant apx)
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 bool SEOBNRv2ROMEffectiveSpin_IsSetup(void)
Helper function to check if the SEOBNRv2ROMEffectiveSpin model has been initialised.
static SEOBNRROMdata __lalsim_SEOBNRv2ROMSS_data
static void SEOBNRv2ROMEffectiveSpin_Init_LALDATA(void)
Setup SEOBNRv2ROMEffectiveSpin model using data files installed in $LAL_DATA_PATH.
static int SEOBNRv2ROMEffectiveSpin_Init(const char dir[])
Setup SEOBNRv2ROMEffectiveSpin model using data files installed in dir.
static void SEOBNRROMdata_coeff_Cleanup(SEOBNRROMdata_coeff *romdatacoeff)
static void SplineData_Destroy(SplineData *splinedata)
static const double gPhi[]
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 void SEOBNRROMdata_coeff_Init(SEOBNRROMdata_coeff **romdatacoeff)
static int read_vector(const char dir[], const char fname[], gsl_vector *v)
static void SEOBNRROMdata_Cleanup(SEOBNRROMdata *romdata)
static void SplineData_Init(SplineData **splinedata)
static int TP_Spline_interpolation_2d(REAL8 q, REAL8 chi, gsl_vector *cvec_amp, gsl_vector *cvec_phi, gsl_vector *cvec_amp_pre, gsl_vector *c_amp, gsl_vector *c_phi, REAL8 *amp_pre)
static int SEOBNRv2ROMEffectiveSpinCore(COMPLEX16FrequencySeries **hptilde, COMPLEX16FrequencySeries **hctilde, double phiRef, double fRef, double distance, double inclination, double Mtot_sec, double eta, double chi, const REAL8Sequence *freqs, double deltaF)
Core function for computing the ROM waveform.
static int SEOBNRv2ROMEffectiveSpinTimeFrequencySetup(gsl_spline **spline_phi, gsl_interp_accel **acc_phi, REAL8 *Mf_final, REAL8 *Mtot_sec, REAL8 m1SI, REAL8 m2SI, REAL8 chi)
static size_t NextPow2(const size_t n)
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 int SEOBNRROMdata_Init(SEOBNRROMdata *romdata, const char dir[])
static int read_matrix(const char dir[], const char fname[], gsl_matrix *m)
#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 * XLALCalloc(size_t m, size_t n)
int XLALSimIMRSEOBNRv2ROMEffectiveSpinFrequencyOfTime(REAL8 *frequency, REAL8 t, REAL8 m1SI, REAL8 m2SI, REAL8 chi)
Compute the starting frequency so that the given amount of 'time' elapses in the ROM waveform from th...
int XLALSimIMRSEOBNRv2ROMEffectiveSpinFrequencySequence(struct tagCOMPLEX16FrequencySeries **hptilde, struct tagCOMPLEX16FrequencySeries **hctilde, const REAL8Sequence *freqs, REAL8 phiRef, REAL8 fRef, REAL8 distance, REAL8 inclination, REAL8 m1SI, REAL8 m2SI, REAL8 chi)
Compute waveform in LAL format at specified frequencies for the SEOBNRv2_ROM_EffectiveSpin model.
int XLALSimIMRSEOBNRv2ROMEffectiveSpinTimeOfFrequency(REAL8 *t, REAL8 frequency, REAL8 m1SI, REAL8 m2SI, REAL8 chi)
Compute the 'time' elapsed in the ROM waveform from a given starting frequency until the ringdown.
int XLALSimIMRSEOBNRv2ROMEffectiveSpin(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 chi)
Compute waveform in LAL format for the SEOBNRv2_ROM_EffectiveSpin 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(...)
#define XLAL_PRINT_WARNING(...)
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 * bwy
gsl_vector * cvec_amp_pre