Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALInspiral 5.0.3.1-ea7c608
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
PNTemplates.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 Jolien Creighton, B.S. Sathyaprakash, Thomas Cokelaer
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 B.S. Sathyaprakash
22 * \file
23 *
24 * \brief Creates a template mesh for BCV (or, alternatively, for SPA but
25 * assuing a constant metric) using the mismatch metric.
26 *
27 * ### Usage ###
28 *
29 *
30 * ### Description ###
31 *
32 *
33 * ### Algorithm ###
34 *
35 *
36 * ### Uses ###
37 *
38 * \code
39 * lalDebugLevel
40 * \endcode
41 *
42 * ### Notes ###
43 *
44 */
45
46#include <math.h>
47#include <stdlib.h>
48#include <lal/LALInspiralBank.h>
49#include <lal/AVFactories.h>
50#include <lal/SeqFactories.h>
51
52/* Default parameter settings. */
53
54/*static void PSItoMasses (LALStatus *status, InspiralTemplate *params, UINT4 *valid, REAL4 psi0, REAL4 psi3);*/
56static void
59 InspiralMomentsEtc *moments,
62
63int
64main(void)
65{
66 static LALStatus status; /* top-level status structure */
68 UINT4 numPSDpts=262144;
69 INT4 nlist;
71 REAL8 samplingRate, dx0, dx1;
72 void (*noisemodel)(LALStatus*,REAL8*,REAL8) = LALLIGOIPsd;
73 static InspiralCoarseBankIn coarseIn;
74 REAL4VectorSequence *list=NULL;
75 static InspiralMetric metric;
76 static InspiralMomentsEtc moments;
77 static InspiralBankParams bankParams;
78 static CreateVectorSequenceIn in;
79 INT4 valid;
80 FILE *fpr;
81
82
83 fpr = fopen("PNTemplates.out", "w");
84
85/* Number of templates is nlist */
86
87 nlist = 0;
88
89 params.OmegaS = 0.;
90 params.Theta = 0.;
91 params.ieta=1;
92 params.mass1=10.;
93 params.mass2=10.;
94 params.startTime=0.0;
95 params.startPhase=0.0;
96 params.fLower=40.0;
97 params.fCutoff=2000.00;
98 params.tSampling=4096.0;
99 params.order=4;
100 params.approximant=TaylorT3;
101 params.signalAmplitude=1.0;
102 params.nStartPad=0;
103 params.nEndPad=1000;
104 params.massChoice=m1Andm2;
107
108 coarseIn.fLower = params.fLower;
109 coarseIn.fUpper = params.fCutoff;
110 coarseIn.tSampling = params.tSampling;
111 coarseIn.order = params.order;
112 coarseIn.space = Tau0Tau3;
113 coarseIn.approximant = params.approximant;
114 coarseIn.mmCoarse = 0.70;
115 coarseIn.mmFine = 0.97;
116 coarseIn.iflso = 0.0L;
117 coarseIn.mMin = 1.0;
118 coarseIn.mMax = 20.0;
119 coarseIn.MMax = coarseIn.mMax * 2.;
121 /* coarseIn.massRange = MinComponentMassMaxTotalMass;*/
122 /* minimum value of eta */
123 coarseIn.etamin = coarseIn.mMin * ( coarseIn.MMax - coarseIn.mMin) / pow(coarseIn.MMax,2.);
124
125 metric.space = Tau0Tau3;
126
127 samplingRate = params.tSampling;
128 memset( &(shf), 0, sizeof(REAL8FrequencySeries) );
129 shf.f0 = 0;
130 LALDCreateVector( &status, &(shf.data), numPSDpts );
131 shf.deltaF = samplingRate / (2.*(REAL8) shf.data->length + 1.L);
132 LALNoiseSpectralDensity (&status, shf.data, noisemodel, shf.deltaF );
133
134 /* compute the metric */
135
136 GetInspiralMoments (&status, &moments, &shf, &params);
137 LALInspiralComputeMetric(&status, &metric, &params, &moments);
138 dx0 = sqrt(2.L * (1.L-coarseIn.mmCoarse)/metric.g00);
139 dx1 = sqrt(2.L * (1.L-coarseIn.mmCoarse)/metric.g11);
140
141 fprintf(fpr, "%e %e %e\n", metric.G00, metric.G01, metric.G11);
142 fprintf(fpr, "%e %e %e\n", metric.g00, metric.g11, metric.theta);
143 fprintf(fpr, "dp0=%e dp1=%e\n", dx0, dx1);
144
145 bankParams.metric = &metric;
146 bankParams.minimalMatch = coarseIn.mmCoarse;
147 bankParams.x0Min = 3.0;
148 bankParams.x0Max = 10.00;
149 bankParams.x1Min = 0.15;
150 bankParams.x1Max = 1.25;
151
152 in.length = 1;
153 in.vectorLength = 2;
154 LALSCreateVectorSequence(&status, &list, &in);
155
156 list->vectorLength = 2;
157 LALInspiralCreateFlatBank(&status, list, &bankParams);
158 nlist = list->length;
159
160 fprintf(fpr, "Number of templates=%d dx0=%e dx1=%e\n", nlist, bankParams.dx0, bankParams.dx1);
161
162
163 /* Prepare to print result. */
164 {
165 INT4 j;
166 /* Print out the template parameters */
167 for (j=0; j<nlist; j++)
168 {
169 /*
170 Retain only those templates that have meaningful masses:
171 */
172 bankParams.x0 = (REAL8) list->data[2*j];
173 bankParams.x1 = (REAL8) list->data[2*j+1];
174 LALInspiralValidParams(&status, &valid, bankParams, coarseIn);
175 if (valid) fprintf(fpr, "%10.4f %10.4f\n",
176 bankParams.x0, bankParams.x1);
177 }
178 }
179 {
180 INT4 j;
181 INT4 local_valid;
182
183 static RectangleIn RectIn;
184 static RectangleOut RectOut;
185
186
187 RectIn.dx = sqrt(2.0 * (1. - coarseIn.mmCoarse)/metric.g00 );
188 RectIn.dy = sqrt(2.0 * (1. - coarseIn.mmCoarse)/metric.g11 );
189 RectIn.theta = metric.theta;
190
191 params.massChoice=t03;
192 /* Print out the template parameters */
193 for (j=0; j<nlist; j++)
194 {
195 /*
196 Retain only those templates that have meaningful masses:
197 */
198 RectIn.x0 = bankParams.x0 = (REAL8) list->data[2*j];
199 RectIn.y0 = bankParams.x1 = (REAL8) list->data[2*j+1];
200 LALInspiralValidParams(&status, &valid, bankParams, coarseIn);
201 local_valid = 1;
202 if (local_valid)
203 {
204 LALRectangleVertices(&status, &RectOut, &RectIn);
205 fprintf(fpr, "%e %e\n%e %e\n%e %e\n%e %e\n%e %e\n",
206 RectOut.x1, RectOut.y1,
207 RectOut.x2, RectOut.y2,
208 RectOut.x3, RectOut.y3,
209 RectOut.x4, RectOut.y4,
210 RectOut.x5, RectOut.y5);
211 fprintf(fpr, "&\n");
212 }
213 }
214 }
215 fclose(fpr);
216 /* Free the list, and exit. */
218 LALDDestroyVector(&status, &(shf.data) );
220 return 0;
221}
222
223
224static void
227 InspiralMomentsEtc *moments,
230{
231
232 UINT4 k;
234
237
238 ASSERT (params, status, LALINSPIRALBANKH_ENULL, LALINSPIRALBANKH_MSGENULL);
239 ASSERT (params->fLower>0, status, LALINSPIRALBANKH_ENULL, LALINSPIRALBANKH_MSGENULL);
240 ASSERT (moments, status, LALINSPIRALBANKH_ENULL, LALINSPIRALBANKH_MSGENULL);
241 ASSERT (psd, status, LALINSPIRALBANKH_ENULL, LALINSPIRALBANKH_MSGENULL);
242
243 moments->a01 = 3.L/5.L;
244 moments->a21 = 11.L * LAL_PI/12.L;
245 moments->a22 = 743.L/2016.L * pow(25.L/(2.L*LAL_PI*LAL_PI), 1.L/3.L);
246 moments->a31 = -3.L/2.L;
247 moments->a41 = 617.L * LAL_PI * LAL_PI / 384.L;
248 moments->a42 = 5429.L/5376.L * pow ( 25.L * LAL_PI/2.L, 1.L/3.L);
249 moments->a43 = 1.5293365L/1.0838016L * pow(5.L/(4.L*pow(LAL_PI,4.L)), 1.L/3.L);
250
251 /* setup the input structure needed in the computation of the moments */
252
253 in.shf = psd;
254 in.shf->f0 /= params->fLower;
255 in.shf->deltaF /= params->fLower;
256 in.xmin = params->fLower/params->fLower;
257 in.xmax = params->fCutoff/params->fLower;
258
259 /* First compute the norm */
260
261 in.norm = 1.L;
262 in.ndx = 7.L/3.L;
263 LALInspiralMoments(status->statusPtr, &moments->j[7], in);
265 in.norm = moments->j[7];
266
268 {
269 fprintf (stderr, "a01=%e a21=%e a22=%e a31=%e a41=%e a42=%e a43=%e \n",
270 moments->a01, moments->a21, moments->a22, moments->a31,
271 moments->a41, moments->a42, moments->a43);
272
273 fprintf(stderr, "j7=%e\n", moments->j[7]);
274 }
275
276 /* Normalised moments of the noise PSD from 1/3 to 17/3. */
277
278 for (k=1; k<=17; k++)
279 {
280 in.ndx = (REAL8) k /3.L;
281 LALInspiralMoments(status->statusPtr,&moments->j[k],in);
283 }
284 in.shf->deltaF *= params->fLower;
285 in.shf->f0 *= params->fLower;
286
288 RETURN (status);
289}
void LALInspiralParameterCalc(LALStatus *status, InspiralTemplate *params)
void LALCheckMemoryLeaks(void)
#define CHECKSTATUSPTR(statusptr)
#define ATTATCHSTATUSPTR(statusptr)
#define ASSERT(assertion, statusptr, code, mesg)
#define DETATCHSTATUSPTR(statusptr)
#define INITSTATUS(statusptr)
#define RETURN(statusptr)
static void GetInspiralMoments(LALStatus *status, InspiralMomentsEtc *moments, REAL8FrequencySeries *psd, InspiralTemplate *params)
Definition: PNTemplates.c:225
int main(void)
Definition: PNTemplates.c:64
#define fprintf
void XLALDestroyREAL4VectorSequence(REAL4VectorSequence *vecseq)
void LALSCreateVectorSequence(LALStatus *status, REAL4VectorSequence **vectorSequence, CreateVectorSequenceIn *vSeqParams)
#define LAL_C_SI
#define LAL_PI
#define LAL_PC_SI
double REAL8
uint32_t UINT4
int32_t INT4
#define lalDebugLevel
LALINFO
@ t03
chirptimes and , and
Definition: LALInspiral.h:185
@ m1Andm2
component masses
Definition: LALInspiral.h:179
void LALInspiralCreateFlatBank(LALStatus *status, REAL4VectorSequence *list, InspiralBankParams *bankParams)
The code expects list->vectorLength=2 and allocates just the requisite amount of memory to list and r...
void LALInspiralValidParams(LALStatus *status, INT4 *valid, InspiralBankParams bankParams, InspiralCoarseBankIn coarseIn)
Function which checks whether or not a pair of parameter values are consistent with the search space.
#define LALINSPIRALBANKH_ENULL
Null pointer.
void LALRectangleVertices(LALStatus *status, RectangleOut *out, RectangleIn *in)
Function to find the vertices of a rectangle given its centre, half side-lengths and orientation angl...
void LALInspiralMoments(LALStatus *status, REAL8 *moment, InspiralMomentsIn pars)
void LALInspiralComputeMetric(LALStatus *status, InspiralMetric *metric, InspiralTemplate *params, InspiralMomentsEtc *moments)
@ MinMaxComponentMass
@ Tau0Tau3
space of chirptimes
void LALNoiseSpectralDensity(LALStatus *status, REAL8Vector *psd, void(*NoisePsd)(LALStatus *status, REAL8 *shf, REAL8 f), REAL8 df)
void LALLIGOIPsd(LALStatus UNUSED *status, REAL8 *psd, REAL8 f)
TaylorT3
void LALDCreateVector(LALStatus *, REAL8Vector **, UINT4)
void LALDDestroyVector(LALStatus *, REAL8Vector **)
This is a structure needed in the inner workings of the LALInspiralCreateCoarseBank code.
REAL8 x1Max
maximum value of the second coordinate as defined by the search region
REAL8 x1Min
minimum value of the second coordinate as defined by the search region
REAL8 x1
the second coordinate, chosen to be either or
REAL8 x0Min
minimum value of the first coordinate as defined by the search region
REAL8 dx0
increment in the x0-direction
InspiralMetric * metric
pointer to the metric at the current location
REAL8 dx1
increment in the x1-direction
REAL8 x0Max
maximum value of the first coordinate as defined by the search region
REAL8 x0
the first coordinate, chosen to be always
REAL8 minimalMatch
UNDOCUMENTED.
Input for choosing a template bank.
REAL8 mmFine
Fine grid minimal match.
REAL8 mMin
minimum mass of components to search for
REAL8 mMax
maximum mass of components to search for
InspiralBankMassRange massRange
enum that determines whether templates should be chosen using fixed ranges for component masses or to...
REAL8 tSampling
Sampling rate.
LALPNOrder order
Post-Newtonian order of the waveform.
INT4 iflso
iflso is an integer that tells whether to compute the moments using an upper limit defined by flso; t...
REAL8 MMax
alternatively, maximum total mass of binary to search for
REAL8 etamin
minimum value of eta in our search
REAL8 fUpper
Upper frequency cutoff.
REAL8 fLower
Lower frequency cutoff.
Approximant approximant
Approximant of the waveform.
REAL8 mmCoarse
Coarse grid minimal match.
CoordinateSpace space
enum that decides whether to use or in constructing the template bank
Structure to store metric at various points the signal manifold.
REAL8 g11
11-component of the diagonalised metric
CoordinateSpace space
The enum describing the coordinate space in which the metric is computed.
REAL8 G01
01-component of the metric in coordinates
REAL8 g00
00-component of the diagonalised metric
REAL8 theta
Angle from tau0 to semi-major axis of the ellipse.
REAL8 G00
00-component of the metric in coordinates
REAL8 G11
11-component of the metric in coordinates
Parameter structure that holds the moments of the PSD and other useful constants required in the comp...
REAL8 j[18]
The required moments are all computed once and stored in this array; The required moments are from J(...
Inputs to the function that computes the moments of the PSD.
REAL8FrequencySeries * shf
the frequency series containing the noise psd
REAL8 norm
norm to be used in computing the moment, the returned value is the above integral divided by the norm
REAL8 ndx
index (without the negative sign) in the moment integral as above
REAL8 xmax
upper limit of the integral
REAL8 xmin
lower limit of the integral
The inspiral waveform parameter structure containing information about the waveform to be generated.
Definition: LALInspiral.h:205
REAL8Sequence * data
Input structure to function LALRectangleVertices()
Output structure to function LALRectangleVertices().
double distance