LALInspiral 5.0.3.1-eeff03c
LALSTPNWaveformTest.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 Duncan Brown, Jolien Creighton, Thomas Cokelaer, Michele Vallisneri
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/**
21 * \author Cokelaer, T. and Vallisneri, M.
22 *
23 * \brief Create a waveform based on SpinTaylor model (LALSTPNWaveform),
24 * switching to LALSTPNWaveform2 if anything is given as argument.
25 *
26 * Outputs a file with three columns corresponding to time (in seconds),
27 * \f$h_+\f$, and \f$h_\times\f$. The outputfile is <tt>wave1.dat</tt> in the
28 * current directory. [This is an obsolete test program that should
29 * be refactored with access to the new frameless LALSTPNWaveform.]
30 *
31 * ### Usage ###
32 *
33 * <tt>LALSTPNWaveformTest [switch]</tt>
34 *
35 */
36
37#include <math.h>
38#include <lal/LALStdlib.h>
39#include <lal/LALInspiral.h>
40#include <lal/GeneratePPNInspiral.h>
41#include <lal/GenerateInspiral.h>
42
43#include <lal/LALSTPNWaveform2.h>
44
45#ifdef __GNUC__
46#define UNUSED __attribute__ ((unused))
47#else
48#define UNUSED
49#endif
50
51extern int newswitch;
52
53int main(int argc,char UNUSED **argv) {
54 static LALStatus mystatus;
55
56 CoherentGW thewaveform;
57 SimInspiralTable injParams;
58 PPNParamStruc ppnParams;
59
60 const char *filename = "wave1.dat";
61 FILE *outputfile;
62 INT4 i,length;
63 REAL8 dt;
64 REAL8 a1, a2, phi, shift, phi0;
65
66 memset( &mystatus, 0, sizeof(LALStatus) );
67 memset( &thewaveform, 0, sizeof(CoherentGW) );
68 memset( &injParams, 0, sizeof(SimInspiralTable) );
69 memset( &ppnParams, 0, sizeof(PPNParamStruc) );
70
71 /* --- first we fill the SimInspiral structure --- */
72
73 injParams.mass1 = 10.;
74 injParams.mass2 = 10.;
75
76 /* MV-20060224: I believe this is not used in the SpinTaylor code! */
77 injParams.f_final = 500.0;
78 injParams.f_lower = 40.;
79
80 snprintf(injParams.waveform,LIGOMETA_WAVEFORM_MAX*sizeof(CHAR),"SpinTaylortwoPN");
81
82 /* this is given in Mpc */
83 injParams.distance = 100.;
84 /* this should not be zero*/
85 injParams.theta0 = 0.01;
86 injParams.phi0 = 0.5;
87
88 injParams.inclination = 0.8;
89 injParams.polarization = 0.9;
90
91 injParams.spin1x = 0.1;
92 injParams.spin1y = 0.2;
93 injParams.spin1z = 0.3;
94
95 injParams.spin2x = 0.4;
96 injParams.spin2y = 0.5;
97 injParams.spin2z = 0.6;
98
99 ppnParams.deltaT = 1.0 / 4096.0;
100
101 fprintf(stderr, "Lower cut-off frequency used will be %fHz\n", injParams.f_lower);
102
103 if(argc > 1) newswitch=1;
104 /* --- now we can call the injection function --- */
105 LALGenerateInspiral( &mystatus, &thewaveform, &injParams, &ppnParams );
106 if ( mystatus.statusCode )
107 {
108 fprintf( stderr, "LALSTPNWaveformTest: error generating waveform %d\n", mystatus.statusCode );
109 exit( 1 );
110 }
111
112 /* --- and finally save in a file --- */
113
114 outputfile = fopen(filename,"w");
115
116 length = thewaveform.phi->data->length;
117 dt = thewaveform.phi->deltaT;
118
119 phi0 = thewaveform.phi->data->data[0];
120
121 for(i = 0; i < length; i++) {
122 a1 = thewaveform.a->data->data[2*i];
123 a2 = thewaveform.a->data->data[2*i+1];
124 phi = thewaveform.phi->data->data[i] - phi0;
125 shift = thewaveform.shift->data->data[i];
126
127 fprintf(outputfile,"%e\t%e\t%e\n",
128 i*dt,
129 a1*cos(shift)*cos(phi) - a2*sin(shift)*sin(phi),
130 a1*sin(shift)*cos(phi) + a2*cos(shift)*sin(phi));
131 }
132
133 fclose(outputfile);
134 fprintf(stderr,"waveform saved in wave1.dat\n" );
135 return 0;
136}
int newswitch
int main(int argc, char UNUSED **argv)
#define LIGOMETA_WAVEFORM_MAX
#define fprintf
double i
const double a2
void LALGenerateInspiral(LALStatus *status, CoherentGW *waveform, SimInspiralTable *thisEvent, PPNParamStruc *ppnParams)
double REAL8
char CHAR
int32_t INT4
REAL4TimeSeries * shift
REAL4TimeVectorSeries * a
REAL8TimeSeries * phi
INT4 statusCode
This structure stores the parameters for constructing a restricted post-Newtonian waveform.
REAL8 deltaT
The requested sampling interval of the waveform, in s.
REAL4Sequence * data
REAL4VectorSequence * data
REAL4 * data
REAL8Sequence * data
REAL8 * data
CHAR waveform[LIGOMETA_WAVEFORM_MAX]