26#include <lal/LALConstants.h>
27#include <lal/LALDatatypes.h>
29#include <lal/FrequencySeries.h>
30#include <lal/LALSimInspiral.h>
31#include <lal/LALSimIMR.h>
32#include <lal/XLALError.h>
33#include <lal/LALAdaptiveRungeKuttaIntegrator.h>
34#include <lal/LALSimInspiralWaveformParams.h>
74"Generate a simulation using the lalsimulation library\n\n"
75"The following options can be given (will assume a default value if omitted):\n"
76"--domain DOM 'TD' for time domain (default) or 'FD' for frequency\n"
77" domain; not all approximants support all domains\n"
78"--amp-phase If given, will output:\n"
79" |h+ - i hx|, Arg(h+ - i hx) (TD) or\n"
80" |h+(f)|, Arg(h+(f)), |hx(f)|, Arg(hx(f)) (FD)\n"
81" If not given, will output h+ and hx (TD and FD)\n"
82"--approximant APPROX Supported TD approximants:\n"
83" TaylorT1 (default)\n"
116" Supported FD approximants:\n"
127" SEOBNRv1_ROM_EffectiveSpin\n"
128" SEOBNRv1_ROM_DoubleSpin\n"
129" SEOBNRv2_ROM_EffectiveSpin\n"
130" SEOBNRv2_ROM_DoubleSpin\n"
139" SpinTaylorT4Fourier\n"
140" SpinTaylorT5Fourier\n"
142" TaylorF2RedSpinTidal\n"
143" NOTE: Other approximants may be available if the\n"
144" developer forgot to edit this help message\n"
145"--phase-order ORD Twice PN order of phase (default ORD=7 <==> 3.5PN)\n"
146"--amp-order ORD Twice PN order of amplitude (default 0 <==> Newt.)\n"
147"--phiRef PHIREF Phase at the reference frequency (default 0)\n"
148"--fRef FREF Reference frequency in Hz\n"
150"--sample-rate SRATE Sampling rate of TD approximants in Hz (default 4096)\n"
151"--deltaF DF Frequency bin size for FD approximants in Hz (default 1/8)\n"
152"--m1 M1 Mass of the 1st object in solar masses (default 10)\n"
153"--m2 M2 Mass of the 2nd object in solar masses (default 1.4)\n"
154"--inclination IOTA Angle in radians between line of sight (N) and \n"
155" orbital angular momentum (L) at the reference\n"
156" (default 0, face on)\n"
157"--spin1x S1X Vector components for spin of mass1 (default all 0)\n"
158"--spin1y S1Y z-axis=line of sight, L in x-z plane at reference\n"
159"--spin1z S1Z Kerr limit: s1x^2 + s1y^2 + s1z^2 <= 1\n"
160"--spin2x S2X Vector components for spin of mass2 (default all 0)\n"
161"--spin2y S2Y z-axis=line of sight, L in x-z plane at reference\n"
162"--spin2z S2Z Kerr limit: s2x^2 + s2y^2 + s2z^2 <= 1\n"
163"--tidal-lambda1 L1 (tidal deformability of mass 1) / (mass of body 1)^5\n"
164" (~128-2560 for NS, 0 for BH) (default 0)\n"
165"--tidal-lambda2 L2 (tidal deformability of mass 2) / (mass of body 2)^5\n"
166" (~128-2560 for NS, 0 for BH) (default 0)\n"
167"--ecc_order eccO PN order for eccentric correction term\n"
168" (-1 for maximum order) (default -1)\n"
169"--f_ecc f reference frequency for initial eccentricity\n"
170" (10Hz) (default 10)\n"
171"--tidal-lambda-octu1 L31 (octupolar tidal deformability of mass 1) / (mass of body 1)^7\n"
172" (0 for BH) (default 0)\n"
173"--tidal-lambda-octu2 L32 (octupolar tidal deformability of mass 2) / (mass of body 2)^7\n"
174" (0 for BH) (default 0)\n"
175"--tidal-quadfmode1 W21 dimensionless quadrupolar f-mode angular frequency of mass 1, normalized to mass 1\n"
176"--tidal-quadfmode2 W22 dimensionless quadrupolar f-mode angular frequency of mass 2, normalized to mass 2\n"
177"--tidal-octufmode1 W31 dimensionless octupolar f-mode angular frequency of mass 1, normalized to mass 1\n"
178"--tidal-octufmode2 W32 dimensionless octupolar f-mode angular frequency of mass 2, normalized to mass 2\n"
179"--quad-mon1 kappa1 dimensionless quadrupole-monopole parameter of mass 1, value 1 for a black hole\n"
180"--quad-mon2 kappa2 dimensionless quadrupole-monopole parameter of mass 2, value 1 for a black hole\n"
181"--spin-order ORD Twice PN order of spin effects\n"
182" (default ORD=-1 <==> All spin effects)\n"
183"--tidal-order ORD Twice PN order of tidal effects\n"
184" (default ORD=-1 <==> All tidal effects)\n"
185"--f-min FMIN Lower frequency to start waveform in Hz (default 40)\n"
186"--f-max FMAX Frequency at which to stop waveform in Hz\n"
187" (default: generate as much as possible)\n"
188"--distance D Distance in Mpc (default 100)\n"
189"--long-asc-nodes omega Longitude of ascending nodes in radians (default 0)\n"
190"--eccentricity ecc Eccentricity (default 0)\n"
191"--mean-per-ano psi Mean periastron anomaly in radians (default 0)\n"
192"--axis AXIS for PhenSpin: 'View' (default), 'TotalJ', 'OrbitalL'\n"
193"--nr-file for NR_hdf5\n"
194"--nonGRpar NAME VALUE add the nonGRparam with name 'NAME' and value 'VALUE'\n"
210"--higher-modes VALUE specify l modes with value 'VALUE' (L2 or RESTRICTED is default)\n"
211"--outname FNAME Output to file FNAME (default 'simulation.dat')\n"
212"--verbose If included, add verbose output\n"
213"--phenomXHMMband float Threshold parameter for the Multibanding of IMRPhenomXHM. By default set to 10^-3. If set to 0 then do not use multibanding.\n"
214"--modesList string List of modes to be used by the model, e.g. --modesList '2,2, 2,-2, 2,1, 2,-1'. \n"
215" To use all the modes available in the mode do not add --modesList. Do not use if you do not know which modes the model returns!\n"
216"--phenomXPHMMband float Threshold parameter for the Multibanding of the Euler angles in IMRPhenomXPHM. \n"
217" Options and default values can be found in https://lscsoft.docs.ligo.org/lalsuite/lalsimulation/group___l_a_l_sim_i_m_r_phenom_x__c.html.\n"
218"--phenomXPHMUseModes int Switch between the two polarization functions IMRPhenomXPHM and IMRPhenomXPHMFromModes.\n"
219" Options and default values can be found in https://lscsoft.docs.ligo.org/lalsuite/lalsimulation/group___l_a_l_sim_i_m_r_phenom_x__c.html.\n"
220"--phenomXPrecVersion int Choose precessing version for the Euler angles.\n"
221" Options and default values can be found in https://lscsoft.docs.ligo.org/lalsuite/lalsimulation/group___l_a_l_sim_i_m_r_phenom_x__c.html.\n"
222"--phenomXPFinalSpinMod int Choose final spin prescription.\n"
223" Options and default values can be found in https://lscsoft.docs.ligo.org/lalsuite/lalsimulation/group___l_a_l_sim_i_m_r_phenom_x__c.html.\n"
224"--newinterface If included, it will use XLALSimInspiralGenerateT(F)DWaveform instead of XLALSimInspiralChooseT(F)DWaveform\n"
225" Can use flexible parameters: --total_mass --chirp_mass --mass_ratio ... --spin1_norm --spin1_tilt --spin1_phi ...\n"
226"--python-module char Name of the External python module\n"
227"--python-object char Name of the python class defined in python-module which includes the methods generate_fd/td_waveform\n"
244 params->deltaT = 1./4096.;
262 params->m1_newinterface = 0;
263 params->m2_newinterface = 0;
264 strcpy(
params->module,
"");
265 strcpy(
params->object,
"");
279 snprintf(
params->outname,
sizeof(
params->outname),
"simulation.dat");
282 for (
i = 1;
i < argc; ++
i) {
283 if ((strcmp(argv[
i],
"-h") == 0) || (strcmp(argv[
i],
"--help") == 0)) {
287 }
else if (strcmp(argv[
i],
"--verbose") == 0) {
289 }
else if (strcmp(argv[
i],
"--newinterface") == 0) {
291 }
else if (strcmp(argv[
i],
"--amp-phase") == 0) {
293 }
else if ( (
i == argc ) || ( !argv[
i+1] ) ) {
295 }
else if (strcmp(argv[
i],
"--approximant") == 0) {
298 XLALPrintError(
"Error: invalid value %s for --interaction-flag\n", argv[
i]);
301 }
else if (strcmp(argv[
i],
"--domain") == 0) {
303 if (strcmp(argv[
i],
"TD") == 0)
305 else if (strcmp(argv[
i],
"FD") == 0)
311 }
else if (strcmp(argv[
i],
"--phase-order") == 0) {
313 }
else if (strcmp(argv[
i],
"--amp-order") == 0) {
315 }
else if (strcmp(argv[
i],
"--phiRef") == 0) {
317 }
else if (strcmp(argv[
i],
"--fRef") == 0) {
319 }
else if (strcmp(argv[
i],
"--sample-rate") == 0) {
320 params->deltaT = 1./atof(argv[++
i]);
321 }
else if (strcmp(argv[
i],
"--deltaF") == 0) {
322 params->deltaF = atof(argv[++
i]);
323 }
else if (strcmp(argv[
i],
"--m1") == 0) {
325 params->m1_newinterface = 1;
326 }
else if (strcmp(argv[
i],
"--m2") == 0) {
328 params->m2_newinterface = 1;
329 }
else if (strcmp(argv[
i],
"--spin1x") == 0) {
331 }
else if (strcmp(argv[
i],
"--spin1y") == 0) {
333 }
else if (strcmp(argv[
i],
"--spin1z") == 0) {
335 }
else if (strcmp(argv[
i],
"--spin2x") == 0) {
337 }
else if (strcmp(argv[
i],
"--spin2y") == 0) {
339 }
else if (strcmp(argv[
i],
"--spin2z") == 0) {
341 }
else if (strcmp(argv[
i],
"--tidal-lambda1") == 0) {
343 }
else if (strcmp(argv[
i],
"--tidal-lambda2") == 0) {
345 }
else if (strcmp(argv[
i],
"--ecc_order") == 0) {
347 }
else if (strcmp(argv[
i],
"--f_ecc") == 0) {
349 }
else if (strcmp(argv[
i],
"--tidal-lambda-octu1") == 0) {
351 }
else if (strcmp(argv[
i],
"--tidal-lambda-octu2") == 0) {
353 }
else if (strcmp(argv[
i],
"--tidal-quadfmode1") == 0) {
355 }
else if (strcmp(argv[
i],
"--tidal-quadfmode2") == 0) {
357 }
else if (strcmp(argv[
i],
"--tidal-octufmode1") == 0) {
359 }
else if (strcmp(argv[
i],
"--tidal-octufmode2") == 0) {
361 }
else if (strcmp(argv[
i],
"--quad-mon1") == 0) {
363 }
else if (strcmp(argv[
i],
"--quad-mon2") == 0) {
365 }
else if (strcmp(argv[
i],
"--spin-order") == 0) {
367 }
else if (strcmp(argv[
i],
"--tidal-order") == 0) {
369 }
else if (strcmp(argv[
i],
"--f-min") == 0) {
371 }
else if (strcmp(argv[
i],
"--f-max") == 0) {
372 params->f_max = atof(argv[++
i]);
373 }
else if (strcmp(argv[
i],
"--distance") == 0) {
375 }
else if (strcmp(argv[
i],
"--inclination") == 0) {
377 }
else if (strcmp(argv[
i],
"--long-asc-nodes") == 0) {
379 }
else if (strcmp(argv[
i],
"--eccentricity") == 0) {
381 }
else if (strcmp(argv[
i],
"--mean-per-ano") == 0) {
383 }
else if (strcmp(argv[
i],
"--axis") == 0) {
390 }
else if (strcmp(argv[
i],
"--modes") == 0) {
396 }
else if (strcmp(argv[
i],
"--nonGRpar") == 0) {
398 strcpy(
name,argv[++
i]);
399 if ( (
i == argc ) || ( !argv[
i+1] ) ) {
400 XLALPrintError(
"Error: 'name value' pair required for option %s\n", argv[
i-1]);
401 }
else if(strcmp(
name,
"Phi1")==0) {
404 }
else if (strcmp(argv[
i],
"--outname") == 0) {
405 snprintf(
params->outname,
sizeof(
params->outname),
"%s", argv[++
i]);
406 }
else if (strcmp(argv[
i],
"--nr-file") == 0) {
408 }
else if (strcmp(argv[
i],
"--modesList") == 0) {
410 int modes[50], iii = 0;
411 while ((current_mode = strtok(iii ? NULL : argv[++
i],
",")) != NULL){
412 modes[iii++] = atoi(current_mode);
415 for (
int ii=0; ii<iii; ii+=2){
421 }
else if(strcmp(argv[
i],
"--phenomXHMMband") == 0){
423 }
else if(strcmp(argv[
i],
"--phenomXPHMMband") == 0){
425 }
else if(strcmp(argv[
i],
"--phenomXPHMUseModes") == 0){
427 }
else if(strcmp(argv[
i],
"--phenomXPrecVersion") == 0){
429 }
else if(strcmp(argv[
i],
"--phenomXPFinalSpinMod") == 0){
431 }
else if(strcmp(argv[
i],
"--phenomXHMRelease") == 0){
434 }
else if (strcmp(argv[
i],
"--total_mass") == 0) {
436 }
else if (strcmp(argv[
i],
"--chirp_mass") == 0) {
438 }
else if (strcmp(argv[
i],
"--mass_difference") == 0) {
440 }
else if (strcmp(argv[
i],
"--reduced_mass") == 0) {
442 }
else if (strcmp(argv[
i],
"--spin1_norm") == 0) {
444 }
else if (strcmp(argv[
i],
"--spin1_tilt") == 0) {
446 }
else if (strcmp(argv[
i],
"--spin1_phi") == 0) {
448 }
else if (strcmp(argv[
i],
"--spin2_norm") == 0) {
450 }
else if (strcmp(argv[
i],
"--spin2_tilt") == 0) {
452 }
else if (strcmp(argv[
i],
"--spin2_phi") == 0) {
454 }
else if (strcmp(argv[
i],
"--condition") == 0) {
456 }
else if (strcmp(argv[
i],
"--python-module") == 0) {
457 snprintf(
params->module,
sizeof(
params->module),
"%s", argv[++
i]);
458 }
else if (strcmp(argv[
i],
"--python-object") == 0) {
459 snprintf(
params->object,
sizeof(
params->object),
"%s", argv[++
i]);
476 size_t len,
REAL8 thresh) {
480 for(
i=1;
i<len;
i++) {
481 if(phi[
i-1] - phi[
i] > thresh)
483 else if(phi[
i] - phi[
i-1] > thresh)
496 XLALPrintError(
"Error: hptilde and hctilde are not the same length\n");
499 XLALPrintError(
"Error: hptilde and hctilde do not have the same freq. bin size\n");
503 fprintf(f,
"# f hptilde.re hptilde.im hctilde.re hctilde.im\n");
505 fprintf(f,
"%.16e %.16e %.16e %.16e %.16e\n",
507 creal(dataPtr1[
i]), cimag(dataPtr1[
i]), creal(dataPtr2[
i]), cimag(dataPtr2[
i]));
518 XLALPrintError(
"Error: hptilde and hctilde are not the same length\n");
521 XLALPrintError(
"Error: hptilde and hctilde do not have the same freq. bin size\n");
529 amp1[
i] = sqrt(creal(dataPtr1[
i])*creal(dataPtr1[
i])
530 + cimag(dataPtr1[
i])*cimag(dataPtr1[
i]));
531 phase1[
i] = atan2(cimag(dataPtr1[
i]), creal(dataPtr1[
i]));
532 amp2[
i] = sqrt(creal(dataPtr2[
i])*creal(dataPtr2[
i])
533 + cimag(dataPtr2[
i])*cimag(dataPtr2[
i]));
534 phase2[
i] = atan2(cimag(dataPtr2[
i]), creal(dataPtr2[
i]));
539 fprintf(f,
"# f amp_+ phase_+ amp_x phase_x\n");
541 fprintf(f,
"%25.16e %25.16e %25.16e %25.16e %25.16e\n",
543 amp1[
i], phaseUW1[
i], amp2[
i], phaseUW2[
i]);
551 XLALPrintError(
"Error: hplus and hcross are not the same length\n");
554 XLALPrintError(
"Error: hplus and hcross do not have the same sample rate\n");
558 fprintf(f,
"# t hplus hcross\n");
572 XLALPrintError(
"Error: hplus and hcross are not the same length\n");
575 XLALPrintError(
"Error: hplus and hcross do not have the same sample rate\n");
583 amp[
i] = sqrt( dataPtr1[
i]*dataPtr1[
i] + dataPtr2[
i]*dataPtr2[
i]);
584 phase[
i] = atan2(-dataPtr2[
i], dataPtr1[
i]);
598int main (
int argc ,
char **argv) {
614 start_time = time(NULL);
615 if (
params->newinterface == 0)
648 if (strcmp(
params->module,
"") != 0){
651 if (strcmp(
params->object,
"") != 0){
660 const char *mass_keys[6] = {
"total_mass",
"chirp_mass",
"mass_difference",
"reduced_mass",
"mass_ratio",
"sym_mass_ratio"};
661 UINT2 key_exists = 0;
662 for (
size_t j = 0; j <
sizeof(mass_keys)/
sizeof(*mass_keys); ++j){
668 if (key_exists == 0){
717 difftime(time(NULL), start_time));
725 if ( strlen(
params->outname) > 0 ) {
726 f = fopen(
params->outname,
"w");
728 printf(
"**ERROR** Impossible to write file %s\n",
params->outname);
733 if (
params->ampPhase == 1)
738 if (
params->ampPhase == 1)
static int dump_TD2(FILE *f, REAL8TimeSeries *hplus, REAL8TimeSeries *hcross)
static int dump_FD2(FILE *f, COMPLEX16FrequencySeries *hptilde, COMPLEX16FrequencySeries *hctilde)
int main(int argc, char **argv)
static int dump_FD(FILE *f, COMPLEX16FrequencySeries *hptilde, COMPLEX16FrequencySeries *hctilde)
static int dump_TD(FILE *f, REAL8TimeSeries *hplus, REAL8TimeSeries *hcross)
static GSParams * parse_args(ssize_t argc, char **argv)
static int unwind_phase(REAL8 phiUW[], REAL8 phi[], size_t len, REAL8 thresh)
int XLALDictContains(const LALDict *dict, const char *key)
void XLALDestroyDict(LALDict *dict)
LALDict * XLALCreateDict(void)
int XLALDictInsertStringValue(LALDict *dict, const char *key, const char *string)
int XLALDictInsertINT4Value(LALDict *dict, const char *key, INT4 value)
int XLALSimInspiralGetHigherModesFromString(const char *string)
Parses a string to determine the LALSimInspiralModesChoice enum value.
int XLALGetFrameAxisFromString(const char *waveform)
int XLALSimInspiralGetApproximantFromString(const char *waveform)
Parses a waveform string to determine approximant.
void XLALDestroyValue(LALValue *value)
void XLALDestroyCOMPLEX16FrequencySeries(COMPLEX16FrequencySeries *series)
void * XLALMalloc(size_t n)
int XLALSimInspiralGenerateTDWaveform(REAL8TimeSeries **hplus, REAL8TimeSeries **hcross, LALDict *params, LALSimInspiralGenerator *generator)
Returns time-domain polarizations for a specific approximant.
int XLALSimInspiralGenerateFDWaveform(COMPLEX16FrequencySeries **hplus, COMPLEX16FrequencySeries **hcross, LALDict *params, LALSimInspiralGenerator *generator)
Returns frequency-domain polarizations for a specific approximant.
int XLALSimInspiralChooseFDWaveform(COMPLEX16FrequencySeries **hptilde, COMPLEX16FrequencySeries **hctilde, const REAL8 m1, const REAL8 m2, const REAL8 S1x, const REAL8 S1y, const REAL8 S1z, const REAL8 S2x, const REAL8 S2y, const REAL8 S2z, const REAL8 distance, const REAL8 inclination, const REAL8 phiRef, const REAL8 longAscNodes, const REAL8 eccentricity, const REAL8 UNUSED meanPerAno, const REAL8 deltaF, const REAL8 f_min, const REAL8 f_max, REAL8 f_ref, LALDict *params, const Approximant approximant)
Chooses between different approximants when requesting a waveform to be generated For spinning wavefo...
LALSimInspiralGenerator * XLALSimInspiralChooseGenerator(Approximant approx, LALDict *params)
Returns LALSimInspiralGenerator object from approximant.
int XLALSimInspiralChooseTDWaveform(REAL8TimeSeries **hplus, REAL8TimeSeries **hcross, const REAL8 m1, const REAL8 m2, const REAL8 S1x, const REAL8 S1y, const REAL8 S1z, const REAL8 S2x, const REAL8 S2y, const REAL8 S2z, const REAL8 distance, const REAL8 inclination, const REAL8 phiRef, const REAL8 longAscNodes, const REAL8 eccentricity, const REAL8 UNUSED meanPerAno, const REAL8 deltaT, const REAL8 f_min, REAL8 f_ref, LALDict *params, const Approximant approximant)
Chooses between different approximants when requesting a waveform to be generated For spinning wavefo...
void XLALDestroySimInspiralGenerator(LALSimInspiralGenerator *generator)
Destroy LALSimInspiralGenerator object.
LALSimulationDomain
Enumeration to specify time or frequency domain.
Approximant
Enum that specifies the PN approximant to be used in computing the waveform.
@ LAL_SIM_DOMAIN_FREQUENCY
@ IMRPhenomXPHM
Frequency domain, precessing with subdominant modes phenomenological IMR waveform model.
@ TaylorT1
Time domain Taylor approximant in which the energy and flux are both kept as Taylor expansions and a ...
void XLALDestroyREAL8TimeSeries(REAL8TimeSeries *series)
void XLALAbortErrorHandler(const char *func, const char *file, int line, int errnum)
int int int XLALPrintInfo(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
XLALErrorHandlerType * XLALSetErrorHandler(XLALErrorHandlerType *newHandler)
#define XLAL_CHECK(assertion,...)
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
REAL8 XLALGPSGetREAL8(const LIGOTimeGPS *epoch)
char module[256]
Name of the External python module.
REAL8 phiRef
phase at fRef
int condition
Conditioning waveform for (Inverse)Fourier Transform.
REAL8 s2y
z-axis along line of sight, L in x-z plane
REAL8 f_min
start frequency
REAL8 inclination
inclination of L relative to line of sight
REAL8 s1x
(x,y,z) components of spin of m1 body
REAL8 fRef
reference frequency
REAL8 s1y
z-axis along line of sight, L in x-z plane
REAL8 deltaF
frequency resolution
REAL8 deltaT
sampling interval
Approximant approximant
waveform family or "approximant"
REAL8 meanPerAno
mean periastron anomaly 0<= psi < 2 Pi
REAL8 s2x
(x,y,z) component ofs spin of m2 body
int m2_newinterface
Check if mass2 is an input argument.
int newinterface
0 or 1: Old or New interface respectively
REAL8 s2z
dimensionless spin, Kerr bound: |s2| <= 1
LALSimulationDomain domain
flag for time or frequency domain waveform
LALDict * params
Container for all accessory parameters.
REAL8 m2
mass of companion 2
REAL8 m1
mass of companion 1
int m1_newinterface
Check if mass1 is an input argument.
REAL8 distance
distance of source
REAL8 s1z
dimensionless spin, Kerr bound: |s1| <= 1
char outname[256]
file to which output should be written
REAL8 longAscNodes
longitude of ascending nodes 0<= omega < 2 pi
REAL8 ecc
eccentricity 0<= ecc < 1