LALSimulation  5.4.0.1-fe68b98
LALSimSGWBORF.c
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2011 Jolien Creighton
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 
22 #include <lal/LALConstants.h>
23 #include <lal/LALDetectors.h>
24 #include <lal/Units.h>
25 #include <lal/LALSimSGWB.h>
26 
27 /**
28  * @addtogroup LALSimSGWBORF_c
29  * @brief Routines to compute the Overlap Reduction Function for stochastic
30  * background gravitational waves between two detectors.
31  * @{
32  */
33 
34 /**
35  * Computes the overlap reduction function between two detectors at a specified
36  * frequency.
37  *
38  * Implements the formulae given in Allen & Romano (1999).
39  */
41  double f, /**< [in] frequency (Hz) */
42  const LALDetector *detector1, /**< [in] 1st detector */
43  const LALDetector *detector2 /**< [in] 2nd detector */
44 )
45 {
46  double d;
47  double s[3];
48  double alpha, alphasq, sinalpha, cosalpha;
49  double j_0, j_1, j_2;
50  double rho1, rho2, rho3;
51  double dd, sdds, sds1, sds2;
52  double gam;
53  size_t i, j;
54 
55  /* compute vector between detectors */
56  s[0] = detector2->location[0] - detector1->location[0];
57  s[1] = detector2->location[1] - detector1->location[1];
58  s[2] = detector2->location[2] - detector1->location[2];
59  d = sqrt(s[0]*s[0] + s[1]*s[1] + s[2]*s[2]);
60 
61  /* if d is zero (less than 1 meter), detectors are at the same site */
62  if (d < 1.0) {
63  dd = 0.0;
64  for (i = 0; i < 3; ++i)
65  for (j = 0; j < 3; ++j)
66  dd += detector1->response[i][j] * detector2->response[i][j];
67  gam = 2.0*dd;
68  return gam;
69  }
70 
71  /* change s[] into a unit vector */
72  s[0] /= d;
73  s[1] /= d;
74  s[2] /= d;
75 
76  /* Eq. (3.32) of Allen and Romano (1999) */
77  alpha = 2.0*LAL_PI*f*d/LAL_C_SI;
78 
79  alphasq = alpha*alpha;
80  sinalpha = sin(alpha);
81  cosalpha = cos(alpha);
82 
83  /* Eq. (3.40) of Allen and Romano (1999) */
84  j_0 = sinalpha/alpha;
85  j_1 = sinalpha/alphasq - cos(alpha)/alpha;
86  j_2 = 3.0*sinalpha/(alpha*alphasq) - 3.0*cosalpha/alphasq - sinalpha/alpha;
87 
88  /* Eq. (3.44) of Allen and Romano (1999) */
89  rho1 = 0.5*( 10.0*alphasq*j_0 - 20.0*alpha*j_1 + 10.0*j_2)/alphasq;
90  rho2 = 0.5*(-20.0*alphasq*j_0 + 80.0*alpha*j_1 - 100.0*j_2)/alphasq;
91  rho3 = 0.5*( 5.0*alphasq*j_0 - 50.0*alpha*j_1 + 175.0*j_2)/alphasq;
92 
93  /* Compute d1:d2, (s.d1).(d2.s), and (s.d1.s)(s.d2.s) */
94  dd = sdds = sds1 = sds2 = 0.0;
95  for (i = 0; i < 3; ++i) {
96  double sd1 = 0.0;
97  double sd2 = 0.0;
98  for (j = 0; j < 3; ++j) {
99  dd += detector1->response[i][j] * detector2->response[i][j];
100  sd1 += detector1->response[i][j] * s[j];
101  sd2 += detector2->response[i][j] * s[j];
102  }
103  sds1 += sd1 * s[i];
104  sds2 += sd2 * s[i];
105  sdds += sd1 * sd2;
106  }
107 
108  /* Eq (3.43) of Allen and Romano (1999) */
109  gam = rho1*dd + rho2*sdds + rho3*sds1*sds2;
110 
111  return gam;
112 }
113 
114 /** @} */
115 
116 /*
117  *
118  * TEST CODE
119  *
120  */
121 
122 #if 0
123 #include <stdio.h>
124 
125 /*
126  * Computes the overlap reduction function between the Hanford and Livingston,
127  * Virgo, and TAMA for comparison with Allen & Romano.
128  */
129 int test_orf(void)
130 {
135  double f;
136  FILE *fp;
137 
138  fp = fopen("orf.dat", "w");
139  for (f = 1.0; f < 10000.0; f *= 1.01)
140  fprintf(fp, "%f %f %f %f\n", f,
144  );
145  fclose(fp);
146 
147  return 0;
148 }
149 
150 int main(void)
151 {
153  test_orf();
155  return 0;
156 }
157 #endif
void LALCheckMemoryLeaks(void)
static vector d(const double L_norm, const double J_norm, const vector roots)
Internal function that returns the coefficients "d_0", "d_2" and "d_4" from 1703.03967 corresponding ...
#define fprintf
int main(int argc, char *argv[])
Definition: bh_qnmode.c:226
int s
Definition: bh_qnmode.c:137
double i
Definition: bh_ringdown.c:118
const double H
const double rho2
const LALDetector lalCachedDetectors[LAL_NUM_DETECTORS]
#define LAL_C_SI
#define LAL_PI
LAL_TAMA_300_DETECTOR
LAL_LLO_4K_DETECTOR
LAL_VIRGO_DETECTOR
LAL_LHO_4K_DETECTOR
double XLALSimSGWBOverlapReductionFunction(double f, const LALDetector *detector1, const LALDetector *detector2)
Computes the overlap reduction function between two detectors at a specified frequency.
Definition: LALSimSGWBORF.c:40
void XLALAbortErrorHandler(const char *func, const char *file, int line, int errnum)
XLALErrorHandlerType * XLALSetErrorHandler(XLALErrorHandlerType *newHandler)
double alpha
Definition: sgwb.c:106
REAL4 response[3][3]
REAL8 location[3]
FILE * fp
double V
Definition: unicorn.c:25