Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALInspiral 5.0.3.1-b246709
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
GenerateInspiral.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 Stas Babak, Drew Keppel, Duncan Brown, Eirini Messaritaki, Gareth Jones, Thomas Cokelaer, Laszlo Vereb
3*
4* This program is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License as published by
6* the Free Software Foundation; either version 2 of the License, or
7* (at your option) any later version.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with with program; see the file COPYING. If not, write to the
16* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17* MA 02110-1301 USA
18*/
19
20#include <math.h>
21#include <lal/LALInspiral.h>
22#include <lal/LALStdlib.h>
23#include <lal/LALStdio.h>
24#include <lal/GenerateInspiral.h>
25#include <lal/GeneratePPNInspiral.h>
26#include <lal/SeqFactories.h>
27#include <lal/Units.h>
28
29/**
30 * XLAL function to determine adaptive integration flag from a string. Returns
31 * 1 if string contains 'fixedStep', otherwise returns 0 to signal
32 * adaptive integration should be used.
33 */
35{
36 if (strstr(inString, "fixedStep"))
37 return 1;
38 else
39 return 0;
40}
41
42/**
43 * XLAL function to determine inspiral-only flag from a string. Returns
44 * 1 if string contains 'inspiralOnly', otherwise returns 0 to signal
45 * full inspiral-merger-ringdown waveform should be generated.
46 */
48{
49 if (strstr(inString, "inspiralOnly"))
50 return 1;
51 else
52 return 0;
53}
54
55/**
56 * XLAL function to determine LALInspiralInteraction from a string.
57 * DEPRECATED: USE LALSimInspiralSpinOrder, LALSimInspiralTidalOrder INSTEAD
58*/
60{
61 if (strstr(inString, "NO")) {
63 } else if (strstr(inString, "SO15")) {
65 } else if (strstr(inString,"SS")) {
67 } else if (strstr(inString,"SELF")) {
69 } else if (strstr(inString, "QM")) {
71 } else if (strstr(inString, "SO25")) {
73 } else if (strstr(inString, "SO")) {
75 } else if (strstr(inString, "ALL_SPIN")) {
77 } else if (strstr(inString, "TIDAL5PN")) {
79 } else if (strstr(inString, "TIDAL")) {
81 } else if (strstr(inString, "ALL")){
83 } else {
84 XLALPrintError( "Cannot parse LALInspiralInteraction from string: %s\n Please add 'ALL' to the above string for including all spin interactions\n", inString );
86 }
87}
88
89/** \see See \ref GenerateInspiral_h for documentation */
90void
92 LALStatus *status, /**< UNDOCUMENTED */
93 CoherentGW *waveform, /**< UNDOCUMENTED */
94 SimInspiralTable *thisEvent, /**< UNDOCUMENTED */
95 PPNParamStruc *ppnParams /**< UNDOCUMENTED */
96 )
97
98{
99 LALPNOrder order; /* Order of the model */
100 Approximant approximant; /* And its approximant value */
101 InspiralTemplate inspiralParams; /* structure for inspiral package */
102 CHAR warnMsg[1024];
103 int oldxlalErrno; /* store old xlal error number */
104
107
108 ASSERT(thisEvent, status,
109 GENERATEINSPIRALH_ENULL, GENERATEINSPIRALH_MSGENULL);
110
111 /* read the event waveform approximant and order */
112 oldxlalErrno = xlalErrno;
113 xlalErrno = 0;
115 if ( (int) approximant == XLAL_FAILURE)
117
118 order = XLALGetOrderFromString(thisEvent->waveform);
119 if ( (int) order == XLAL_FAILURE)
121 xlalErrno = oldxlalErrno;
122
123 /* when entering here, approximant is in principle well defined. */
124 /* We dont need any else if or ABORT in the if statement. */
125 /* Depending on the apporixmant we use inject or inspiral package */
126 if ( approximant == GeneratePPN )
127 {
128 /* fill structure with input parameters */
129 oldxlalErrno = xlalErrno;
130 xlalErrno = 0;
131 if (XLALGenerateInspiralPopulatePPN(ppnParams, thisEvent) == XLAL_FAILURE)
133 xlalErrno = oldxlalErrno;
134
135 /* generate PPN waveform */
136 LALGeneratePPNInspiral(status->statusPtr, waveform, ppnParams);
138 }
139 else if ( approximant == AmpCorPPN )
140 {
141 int i;
142
143 /* fill structure with input parameters */
144 oldxlalErrno = xlalErrno;
145 xlalErrno = 0;
146 if (XLALGenerateInspiralPopulatePPN(ppnParams, thisEvent) == XLAL_FAILURE)
148 xlalErrno = oldxlalErrno;
149
150 /* PPN parameter. */
151 ppnParams->ppn = NULL;
152 LALSCreateVector( status->statusPtr, &(ppnParams->ppn), order + 1 );
153 ppnParams->ppn->length = order + 1;
154
155 ppnParams->ppn->data[0] = 1.0;
156 if ( order > 0 )
157 {
158 ppnParams->ppn->data[1] = 0.0;
159 for ( i = 2; i <= (INT4)( order ); i++ )
160 {
161 ppnParams->ppn->data[i] = 1.0;
162 }
163 }
164
165 /* generate PPN waveform */
166 LALGeneratePPNAmpCorInspiral(status->statusPtr, waveform, ppnParams);
168
169 LALSDestroyVector(status->statusPtr, &(ppnParams->ppn) );
171 }
172 else
173 {
174 inspiralParams.approximant = approximant;
175 inspiralParams.order = order;
177 xlalErrno = 0;
179 thisEvent->waveform);
180 if ( (int) inspiralParams.interaction == XLAL_FAILURE)
182 }
183
185 xlalErrno = 0;
186 /* These next three functions cannot fail - they return a default value
187 if no target string is present - so we don't check for failure. */
188 inspiralParams.axisChoice = XLALGetFrameAxisFromString(
189 thisEvent->waveform);
191 thisEvent->waveform);
193 thisEvent->waveform);
194 }
195
196 /* We fill ppnParams */
197 oldxlalErrno = xlalErrno;
198 xlalErrno = 0;
199 if (XLALGenerateInspiralPopulatePPN(ppnParams, thisEvent) == XLAL_FAILURE)
201 xlalErrno = oldxlalErrno;
202
203 /* we fill inspiralParams structure as well.*/
204 oldxlalErrno = xlalErrno;
205 xlalErrno = 0;
206 if (XLALGenerateInspiralPopulateInspiral(&inspiralParams, thisEvent, ppnParams) == XLAL_FAILURE)
208 xlalErrno = oldxlalErrno;
209
210 /* the waveform generation itself */
211 LALInspiralWaveForInjection(status->statusPtr, waveform, &inspiralParams,
212 ppnParams);
213 /* we populate the simInspiral table with the fFinal needed for
214 template normalisation. */
215 thisEvent->f_final = inspiralParams.fFinal;
217 }
218
219 /* If no waveform has been generated.*/
220 if ( waveform->a == NULL && waveform->h == NULL)
221 {
222 snprintf( warnMsg, XLAL_NUM_ELEM(warnMsg),
223 "No waveform generated (check lower frequency)\n");
224 LALInfo( status, warnMsg );
225 ABORT( status, LALINSPIRALH_ENOWAVEFORM, LALINSPIRALH_MSGENOWAVEFORM );
226 }
227
228
229 /* If sampling problem. (AmpCorPPN may not be compatible) */
230 if ( ppnParams->dfdt > 2.0 && approximant != AmpCorPPN )
231 {
232 snprintf( warnMsg, XLAL_NUM_ELEM(warnMsg),
233 "Waveform sampling interval is too large:\n"
234 "\tmaximum df*dt = %f", ppnParams->dfdt );
235 LALInfo( status, warnMsg );
236 ABORT( status, GENERATEINSPIRALH_EDFDT, GENERATEINSPIRALH_MSGEDFDT );
237 }
238
239 /* Some info should add everything (spin and so on) */
240 snprintf( warnMsg, XLAL_NUM_ELEM(warnMsg),
241 "Injected waveform parameters:\n"
242 "ppnParams->mTot\t= %"LAL_REAL4_FORMAT"\n"
243 "ppnParams->eta\t= %"LAL_REAL4_FORMAT"\n"
244 "ppnParams->d\t= %"LAL_REAL4_FORMAT"\n"
245 "ppnParams->inc\t= %"LAL_REAL4_FORMAT"\n"
246 "ppnParams->phi\t= %"LAL_REAL4_FORMAT"\n"
247 "ppnParams->psi\t= %"LAL_REAL4_FORMAT"\n"
248 "ppnParams->fStartIn\t= %"LAL_REAL4_FORMAT"\n"
249 "ppnParams->fStopIn\t= %"LAL_REAL4_FORMAT"\n"
250 "ppnParams->position.longitude\t= %"LAL_REAL8_FORMAT"\n"
251 "ppnParams->position.latitude\t= %"LAL_REAL8_FORMAT"\n"
252 "ppnParams->position.system\t= %d\n"
253 "ppnParams->epoch.gpsSeconds\t= %"LAL_INT4_FORMAT"\n"
254 "ppnParams->epoch.gpsNanoSeconds\t= %"LAL_INT4_FORMAT"\n"
255 "ppnParams->tC\t= %"LAL_REAL8_FORMAT"\n"
256 "ppnParams->dfdt\t =%"LAL_REAL4_FORMAT"\n",
257 ppnParams->mTot,
258 ppnParams->eta,
259 ppnParams->d,
260 ppnParams->inc,
261 ppnParams->phi,
262 ppnParams->psi,
263 ppnParams->fStartIn,
264 ppnParams->fStopIn,
265 ppnParams->position.longitude,
266 ppnParams->position.latitude,
267 ppnParams->position.system,
268 ppnParams->epoch.gpsSeconds,
269 ppnParams->epoch.gpsNanoSeconds,
270 ppnParams->tc,
271 ppnParams->dfdt );
272 LALInfo( status, warnMsg );
273
275 RETURN( status );
276}
277
278/** \see See \ref GenerateInspiral_h for documentation */
279int
281 PPNParamStruc * restrict ppnParams,
282 SimInspiralTable * restrict thisEvent
283 )
284{
285 if ( !ppnParams || !thisEvent )
287
288 /* input fields */
289 ppnParams->mTot = thisEvent->mass1 + thisEvent->mass2;
290 ppnParams->eta = thisEvent->eta;
291 ppnParams->d = thisEvent->distance* 1.0e6 * LAL_PC_SI; /*in Mpc*/
292 ppnParams->inc = thisEvent->inclination;
293 ppnParams->phi = thisEvent->coa_phase;
294 ppnParams->ampOrder = thisEvent->amp_order;
295
296 /* frequency cutoffs */
297 if ( thisEvent->f_lower > 0 )
298 {
299 ppnParams->fStartIn = thisEvent->f_lower;
300 }
301 else
302 {
304 "f_lower must be specified in the injection file generation.\n" );
306 }
307 ppnParams->fStopIn = -1.0 /
308 ( sqrt(216.0) * LAL_PI * ppnParams->mTot * LAL_MTSUN_SI);
309
310 /* passed fields */
311 ppnParams->position.longitude = thisEvent->longitude;
312 ppnParams->position.latitude = thisEvent->latitude;
313 ppnParams->position.system = COORDINATESYSTEM_EQUATORIAL;
314 ppnParams->psi = thisEvent->polarization;
315 ppnParams->epoch.gpsSeconds = 0;
316 ppnParams->epoch.gpsNanoSeconds = 0;
317
318 return XLAL_SUCCESS;
319}
320
321
322/** \see See \ref GenerateInspiral_h for documentation */
323int
325 InspiralTemplate * restrict inspiralParams,
326 SimInspiralTable * restrict thisEvent,
327 PPNParamStruc * restrict ppnParams
328 )
329{
330
331 if ( !inspiralParams || !thisEvent || !ppnParams )
333
334 /* --- Let's fill the inspiral structure now --- */
335 inspiralParams->mass1 = thisEvent->mass1; /* masses 1 */
336 inspiralParams->mass2 = thisEvent->mass2; /* masses 2 */
337 inspiralParams->fLower = ppnParams->fStartIn; /* lower cutoff frequency */
338 inspiralParams->fFinal = thisEvent->f_final;
339 inspiralParams->fCutoff = 1./ (ppnParams->deltaT)/2.-1;
340 inspiralParams->ampOrder = ppnParams->ampOrder;
341
342 /* -1 to be in agreement with the inspiral assert. */
343 inspiralParams->tSampling = 1./ (ppnParams->deltaT); /* sampling*/
344 inspiralParams->signalAmplitude = 1.;
345 inspiralParams->distance = thisEvent->distance * LAL_PC_SI * 1e6;
346
347 /* distance in Mpc */
348 inspiralParams->startTime = 0.0;
349 inspiralParams->startPhase = thisEvent->coa_phase;
350
351 inspiralParams->OmegaS = GENERATEINSPIRAL_OMEGAS;/* EOB 3PN contribution */
352 inspiralParams->Theta = GENERATEINSPIRAL_THETA; /* EOB 3PN contribution */
353 inspiralParams->Zeta2 = GENERATEINSPIRAL_ZETA2; /* EOB 3PN contribution */
354
355 inspiralParams->alpha = -1.; /* bcv useless for the time being */
356 inspiralParams->psi0 = -1.; /* bcv useless for the time being */
357 inspiralParams->psi3 = -1.; /* bcv useless for the time being */
358 inspiralParams->alpha1 = -1.; /* bcv useless for the time being */
359 inspiralParams->alpha2 = -1.; /* bcv useless for the time being */
360 inspiralParams->beta = -1.; /* bcv useless for the time being */
361
362 /* inclination of the binary */
363 /* inclination cannot be equal to zero for SpinTaylor injections */
364 if ( inspiralParams->approximant == SpinTaylor && thisEvent->inclination == 0 )
365 {
366 XLALPrintError( "Inclination cannot be exactly zero for SpinTaylor approximant.\n");
368 }
369 inspiralParams->inclination = thisEvent->inclination;
370
371 inspiralParams->ieta = 1;
372 inspiralParams->nStartPad = 0;
373 /* increased end padding from zero so that longer waveforms do not
374 have errors due to underestimation of number of bins requred */
375 inspiralParams->nEndPad = 16384;
376
377 inspiralParams->massChoice = m1Andm2;
378
379 /* spin parameters */
380 inspiralParams->sourceTheta = GENERATEINSPIRAL_SOURCETHETA;
381 inspiralParams->sourcePhi = GENERATEINSPIRAL_SOURCEPHI;
382 inspiralParams->spin1[0] = thisEvent->spin1x;
383 inspiralParams->spin2[0] = thisEvent->spin2x;
384 inspiralParams->spin1[1] = thisEvent->spin1y;
385 inspiralParams->spin2[1] = thisEvent->spin2y;
386 inspiralParams->spin1[2] = thisEvent->spin1z;
387 inspiralParams->spin2[2] = thisEvent->spin2z;
388
389 inspiralParams->orbitTheta0 = thisEvent->theta0;
390 inspiralParams->orbitPhi0 = thisEvent->phi0;
391 inspiralParams->qmParameter[0] = thisEvent->qmParameter1;
392 inspiralParams->qmParameter[1] = thisEvent->qmParameter2;
393
394 return XLAL_SUCCESS;
395}
int XLALGetAdaptiveIntFromString(const CHAR *inString)
XLAL function to determine adaptive integration flag from a string.
int XLALGetInspiralOnlyFromString(const CHAR *inString)
XLAL function to determine inspiral-only flag from a string.
int XLALGenerateInspiralPopulateInspiral(InspiralTemplate *restrict inspiralParams, SimInspiralTable *restrict thisEvent, PPNParamStruc *restrict ppnParams)
int XLALGenerateInspiralPopulatePPN(PPNParamStruc *restrict ppnParams, SimInspiralTable *restrict thisEvent)
void LALInspiralWaveForInjection(LALStatus *status, CoherentGW *waveform, InspiralTemplate *params, PPNParamStruc *ppnParams)
int XLALGetOrderFromString(const char *waveform)
int XLALGetApproximantFromString(const char *waveform)
int XLALGetFrameAxisFromString(const char *waveform)
#define ABORT(statusptr, code, mesg)
#define CHECKSTATUSPTR(statusptr)
#define ATTATCHSTATUSPTR(statusptr)
#define ASSERT(assertion, statusptr, code, mesg)
#define DETATCHSTATUSPTR(statusptr)
#define INITSTATUS(statusptr)
#define RETURN(statusptr)
#define ABORTXLAL(sp)
double i
#define GENERATEINSPIRAL_SOURCEPHI
#define GENERATEINSPIRAL_THETA
#define GENERATEINSPIRALH_EDFDT
Waveform sampling interval is too large.
void LALGenerateInspiral(LALStatus *status, CoherentGW *waveform, SimInspiralTable *thisEvent, PPNParamStruc *ppnParams)
#define GENERATEINSPIRAL_OMEGAS
#define GENERATEINSPIRAL_ZETA2
#define GENERATEINSPIRAL_SOURCETHETA
#define GENERATEINSPIRALH_ENULL
Null pointer.
void LALGeneratePPNInspiral(LALStatus *stat, CoherentGW *output, PPNParamStruc *params)
Computes a parametrized post-Newtonian inspiral waveform.
void LALGeneratePPNAmpCorInspiral(LALStatus *stat, CoherentGW *output, PPNParamStruc *params)
Computes a parametrized post-Newtonian inspiral waveform with ampltidude corrections.
#define LAL_PI
#define LAL_MTSUN_SI
#define LAL_PC_SI
#define XLAL_NUM_ELEM(x)
char CHAR
int32_t INT4
int LALInfo(LALStatus *status, const char *info)
int XLALGetInteractionFromString(const CHAR *inString)
XLAL function to determine LALInspiralInteraction from a string.
#define LALINSPIRALH_ENOWAVEFORM
No Waveform generated.
Definition: LALInspiral.h:67
@ m1Andm2
component masses
Definition: LALInspiral.h:179
@ LAL_INSPIRAL_INTERACTION_TIDAL_5PN
Leading-order tidal interaction.
Definition: LALInspiral.h:124
@ LAL_INSPIRAL_INTERACTION_ALL
all spin and tidal interactions
Definition: LALInspiral.h:127
@ LAL_INSPIRAL_INTERACTION_TIDAL_6PN
Next-to-leading-order tidal interaction.
Definition: LALInspiral.h:125
@ LAL_INSPIRAL_INTERACTION_SPIN_ORBIT_25PN
Next-to-leading-order spin-orbit interaction.
Definition: LALInspiral.h:122
@ LAL_INSPIRAL_INTERACTION_QUAD_MONO_2PN
Quadrupole-monopole interaction.
Definition: LALInspiral.h:121
@ LAL_INSPIRAL_INTERACTION_SPIN_ORBIT_3PN
Spin-spin interaction.
Definition: LALInspiral.h:123
@ LAL_INSPIRAL_INTERACTION_NONE
No spin, tidal or other interactions.
Definition: LALInspiral.h:117
@ LAL_INSPIRAL_INTERACTION_SPIN_SPIN_2PN
Spin-spin interaction.
Definition: LALInspiral.h:119
@ LAL_INSPIRAL_INTERACTION_SPIN_ORBIT_15PN
Leading order spin-orbit interaction.
Definition: LALInspiral.h:118
@ LAL_INSPIRAL_INTERACTION_ALL_SPIN
all spin interactions, no tidal interactions
Definition: LALInspiral.h:126
@ LAL_INSPIRAL_INTERACTION_SPIN_SPIN_SELF_2PN
Spin-spin-self interaction.
Definition: LALInspiral.h:120
Approximant
LALPNOrder
GeneratePPN
SpinQuadTaylor
AmpCorPPN
PhenSpinTaylorRD
SpinTaylor
#define LAL_REAL8_FORMAT
#define LAL_INT4_FORMAT
#define LAL_REAL4_FORMAT
COORDINATESYSTEM_EQUATORIAL
void LALSDestroyVector(LALStatus *, REAL4Vector **)
void LALSCreateVector(LALStatus *, REAL4Vector **, UINT4)
#define xlalErrno
#define XLAL_ERROR(...)
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
XLAL_SUCCESS
XLAL_EFAULT
XLAL_EINVAL
XLAL_FAILURE
REAL4TimeVectorSeries * a
REAL4TimeVectorSeries * h
The inspiral waveform parameter structure containing information about the waveform to be generated.
Definition: LALInspiral.h:205
Approximant approximant
Post-Newtonain approximant to be used in generating the wave (input)
Definition: LALInspiral.h:208
UINT4 inspiralOnly
UNDOCUMENTED.
Definition: LALInspiral.h:344
REAL8 fFinal
final frequency reached, in units of Hz (output)
Definition: LALInspiral.h:293
UINT4 fixedStep
UNDOCUMENTED.
Definition: LALInspiral.h:343
LALPNOrder order
Post-Newtonain order to be used in generating the wave (input)
Definition: LALInspiral.h:209
LALInspiralInteraction interaction
UNDOCUMENTED.
Definition: LALInspiral.h:341
LALSimInspiralFrameAxis axisChoice
UNDOCUMENTED.
Definition: LALInspiral.h:283
INT4 gpsNanoSeconds
This structure stores the parameters for constructing a restricted post-Newtonian waveform.
REAL4 fStopIn
The requested termination frequency of the waveform, in Hz; If set to 0, the waveform will be generat...
REAL4Vector * ppn
The parameters selecting the type of post-Newtonian expansion; If ppn=NULL, a "normal" (physical) ex...
REAL4 dfdt
The maximum value of encountered over any timestep used in generating the waveform.
LIGOTimeGPS epoch
start time of output time series
REAL4 phi
The phase at coalescence (or arbitrary reference phase for a post -Newtonian approximation),...
REAL4 psi
polarization angle (radians)
SkyPosition position
location of source on sky
REAL4 eta
The mass ratio of the binary system; Physically this parameter must lie in the range ; values outsid...
REAL8 tc
The time from the start of the waveform to coalescence (in the point-mass approximation),...
REAL4 mTot
The total mass of the binary system, in solar masses.
REAL4 fStartIn
The requested starting frequency of the waveform, in Hz.
REAL4 d
The distance to the system, in metres.
REAL4 inc
The inclination of the system to the line of sight, in radians.
REAL4 * data
CHAR waveform[LIGOMETA_WAVEFORM_MAX]
REAL8 longitude
REAL8 latitude
CoordinateSystem system