LALApps 10.1.0.1-eeff03c
DistanceVsMass.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 B.S. Sathyaprakash
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 * Given the noise amplitude/power spectral density as a two-column
22 * ascii file this code returns the distance in Mpc as a function of the
23 * total mass to binaries with equal masses and an rms orientation
24 * and produce an SNR of 5 when integrated up to the LSO at R=6M
25 * or the light ring at R=2.8 M.
26 *
27 */
28#include <stdlib.h>
29#include <math.h>
30#include <stdio.h>
31int main (int argc, char **argv)
32{
33
34 double totalMass, eta, fOld, x, sevenBy3=7./3.;
35 double pwrSpec, LO;
36 double freq;
37 double rhorms, rmsD, idealD, Crms, integral;
38 int ampSpec;
39 double lso_radius=6., light_ring_radius=2.8, MTSUN_SI=4.925e-6, pi=3.14159, MPC_SI=3.e22, C_SI=3.e8;
40
41
42 if (argc!=3)
43 {
44 fprintf(stderr, "* Given the noise amplitude/power spectral density as a two-column\n");
45 fprintf(stderr, "* ascii file this code returns the distance in Mpc as a function of the\n");
46 fprintf(stderr, "* total mass to binaries with equal masses and an rms orientation \n");
47 fprintf(stderr, "* and produce an SNR of 5 when integrated up to the LSO R=6M or \n");
48 fprintf(stderr, "* the light ring R=2.8 M.\n");
49 fprintf(stderr, "-----------------------------\n");
50 fprintf (stderr, "Usage: %s ampSpec (0/1) LO (0/1)\n", argv[0]);
51 fprintf (stderr, "ampSpec: should be 0 if input spectrum is power and 1 if amplitude\n");
52 fprintf (stderr, "LO: should be 0 if the last orbit is at R=6M (Schwarzschild) and nonzero if at R=2.8M (as in EOB)\n");
53 fprintf(stderr, "-----------------------------\n");
54 exit(1);
55 }
56
57 /* Cast the inputs */
58 ampSpec = atoi(argv[1]);
59
60 if (atoi(argv[2]) == 0)
61 LO = lso_radius;
62 else
63 LO = light_ring_radius;
64
65 /* Equal masses means eta=1/4 */
66 eta = 0.25;
67 /* rms SNR = 5 */
68 rhorms = 5.;
69 /* initiate the SNR integral to zero */
70 integral = 0.;
71
72 /* If the file is empty write a warning message and exit */
73 if ( scanf("%le %le\n", &freq, &x) == EOF)
74 {
75 fprintf(stderr, "Empty input file\n");
76 exit(1);
77 }
78 fOld = freq;
79
80 while (scanf("%le %le\n", &freq, &x) != EOF)
81 {
82 if (ampSpec)
83 /* If the file contains amplitude spectrum convert it to power spectrum */
84 pwrSpec = x*x;
85 else
86 /* If the file contains power spectrum use as is */
87 pwrSpec = x;
88
89 integral += (freq-fOld) * pow(freq, -sevenBy3)/pwrSpec;
90
91 /* Compute the total mass of a binary whose last orbit is the current frequency */
92 totalMass = 1./(pow(LO, 1.5) * pi * freq);
93 /* Normalisation to covert integral above to a distance */
94 Crms = pow(totalMass, 5./6.) * pow(2.*eta/15., 0.5) / (rhorms * pow(pi, 2./3.));
95 /* Distance corresponding to a source with RMS orientation producing an SNR equal to rhorms */
96 rmsD = Crms * sqrt(integral) / MPC_SI * C_SI;
97 /* Distance corresponding to an optimally oriented source with the same SNR */
98 idealD = 2.5 * rmsD;
99 /* Convert the mass in seconds to solar masses */
100 totalMass /= MTSUN_SI;
101 if (totalMass < 5000.) fprintf(stdout, "%e %e %e %e\n", totalMass, rmsD, idealD, freq);
102 fOld = freq;
103 }
104 fprintf(stdout, "&\n");
105 return 0;
106}
int main(int argc, char **argv)
#define pi
#define fprintf
eta
float freq