LALApps 10.1.0.1-eeff03c
inspiralDistance.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 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/* This programme expects six inputs at the command line:
21 *
22 * m1: mass of the first object in the binary source,
23 * m2: mass of the second object in the binary source,
24 * rhorms: rms SNR required from the source,
25 * flow: lower frequency cutoff,
26 * LO: Last orbit in units of M (either 6, for LSO, or 2.8, for light ring)
27 * ispec: an integer indicating the nature of input data: power (0) or amplitude (1) spectrum is input
28 *
29 * reads a data from a file contianing two columns of frequency
30 * and power/amplitude spectral density. It outputs the distance in Kpc
31 * for a source with the given rms SNR.
32 */
33
34#include <stdlib.h>
35#include <math.h>
36#include <stdio.h>
37
38int main (int argc, char **argv)
39{
40 double m1, m2, totalMass, eta, flso, lso, fOld, sevenBy3 = 7.L/3.L;
41 double x, pwrSpec;
42 double freq, flow;
43 double rhorms, rmsD, Crms, integral;
44 double MTSUN_SI=4.925e-6, pi=3.14159, PC_SI=3.e19, C_SI=3.e8;
45 double SNRat1Mpc;
46 int ispec;
47
48 if (argc !=7 )
49 {
50 fprintf(stderr, "-----------------------------\n");
51 fprintf(stderr, "Usage:%s mass1/solarMass mass2/solarMass rhoRMS fLow LO ispec < PSD_File\n",argv[0]);
52 fprintf(stderr, "-----------------------------\n");
53 exit(1);
54 }
55
56 m1 = atof(argv[1]);
57 m2 = atof(argv[2]);
58 rhorms = atof(argv[3]);
59 flow = atof(argv[4]);
60 lso = atof(argv[5]);
61 ispec = atoi(argv[6]);
62
63 totalMass = (m1+m2);
64 eta = m1*m2/(totalMass*totalMass);
65 totalMass *= MTSUN_SI;
66 Crms = pow(totalMass,5./6.) * pow(2.*eta/15.,0.5) / (rhorms * pow(pi,2./3.));
67
68 flso = 1.L/ ( pow(lso, 1.5) * pi * totalMass);
69
70 /*
71 printf("%e %e %e %e \n",totalMass, eta, Crms, flso );
72 */
73
74 integral = 0.;
75 if (scanf("%le %le\n", &freq, &x) == EOF)
76 {
77 fprintf(stderr, "No data in file\n");
78 return 1;
79 }
80 fOld = freq;
81
82 while ( scanf("%le %le\n", &freq, &x) != EOF)
83 {
84
85 if (freq > flso) break;
86 if (x && freq > flow)
87 {
88 if (ispec)
89 pwrSpec = x*x;
90 else
91 pwrSpec = x;
92 integral += (freq - fOld) * pow(freq, -sevenBy3)/pwrSpec;
93 }
94 fOld = freq;
95 }
96
97 rmsD = Crms * sqrt(integral) / PC_SI * C_SI;
98 SNRat1Mpc = 1.e-3 * 2.5 * rmsD*rhorms;
99 fprintf(stdout, "%e %e %e %e %e %e %e\n", totalMass/MTSUN_SI, SNRat1Mpc, flow, rmsD, m1, m2, flso);
100 return 0;
101}
#define pi
#define fprintf
double flow
int main(int argc, char **argv)
eta
m2
m1
float freq