Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALSimulation 6.2.0.1-3a66518
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
bh_ringdown.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 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/**
21 * @defgroup lalsim_bh_ringdown lalsim-bh-ringdown
22 * @ingroup lalsimulation_programs
23 *
24 * @brief Simulates a gravitational waveform from black hole ringdown.
25 *
26 * ### Synopsis
27 *
28 * lalsim-bh-ringdown [-h] -M Msolar -a a -r distanceMpc -e fracEnergy -i inclination [-q azimuth] -l l -m m
29 *
30 * ### Description
31 *
32 * The `lalsim-bh-ringdown` utility produces a stream of a simulated
33 * gravitational waveform for ringdown radiation from a quasinormal
34 * mode of a Kerr black hole with mode numbers @p l and @p m. The
35 * dimensionless Kerr spin parameter @p a, black hole mass in solar
36 * masses @p Msolar, fraction of mass lost in ringdown radiation
37 * @p e, distance to the observer in Mpc @p distanceMpc, and inclination of the
38 * observer relative to the black hole's spin axis @p inclination must be
39 * specified. The output is written to standard output in three-column ascii
40 * format. The first column gives the time corresponding to each sample, the
41 * second column gives the value of the plus-polarization of the waveform, and
42 * the third column gives the value of the cross-polarization of the waveform.
43 *
44 * ### Options
45 *
46 * <DL>
47 * <DT>`-h`, `--help`</DT>
48 * <DD>print a help message and exit</DD>
49 * <DT>`-M` Msolar</DT>
50 * <DD>(required) set black hole mass (solar masses)</DD>
51 * <DT>`-a` a</DT>
52 * <DD>(required) set value of dimensionless spin parameter a/M, |a/M|<1 (Leaver: |a/M|<0.5)</DD>
53 * <DT>`-r` distanceMpc</DT>
54 * <DD>(required) set distance (Mpc)</DD>
55 * <DT>`-e` fracEnergy</DT>
56 * <DD>(required) set energy radiated (fraction of mass)</DD>
57 * <DT>`-i` inclination</DT>
58 * <DD>(required) set inclination angle (degrees)</DD>
59 * <DT>`-q` azimuth</DT>
60 * <DD>(optional: default=0) set azimuth angle (degrees)</DD>
61 * <DT>`-l` l</DT>
62 * <DD>(required) set value of mode number l, l>=0</DD>
63 * <DT>`-m` m</DT>
64 * <DD>(required) set value of mode number m, abs(m)<=l</DD>
65 * </DL>
66 *
67 * ### Environment
68 *
69 * The `LAL_DEBUG_LEVEL` can used to control the error and warning reporting of
70 * `lalsim-bh-ringdown`. Common values are: `LAL_DEBUG_LEVEL=0` which
71 * suppresses error messages, `LAL_DEBUG_LEVEL=1` which prints error messages
72 * alone, `LAL_DEBUG_LEVEL=3` which prints both error messages and warning
73 * messages, and `LAL_DEBUG_LEVEL=7` which additionally prints informational
74 * messages.
75 *
76 * ### Exit Status
77 *
78 * The `lalsim-bh-ringdown` utility exits 0 on success, and >0 if an error
79 * occurs.
80 *
81 * ### Example
82 *
83 * The command:
84 *
85 * lalsim-bh-ringdown -M 10 -a 0.97 -r 1.0 -e 0.01 -i 45.0 -l 2 -m 2
86 *
87 * produces a three-column ascii output to standard output; the rows are
88 * samples (at the rate of 16384 Hz), and the three columns are 1. the
89 * time of each sample, 2. the plus-polarization strain, and 3. the
90 * cross-polarization strain. The waveform produced is for a 10 solar
91 * mass black hole spinning with Kerr parameter a/M = 0.97 at a distance
92 * of 1 Mpc and inclination of 45 degrees that radiates 1% of its mass in the l
93 * = 2, m = 2 quasinormal mode.
94 */
95
96#include <complex.h>
97#include <limits.h>
98#include <math.h>
99#include <stdio.h>
100#include <stdlib.h>
101
102#include <lal/LALStdlib.h>
103#include <lal/LALgetopt.h>
104#include <lal/LALConstants.h>
105#include <lal/Units.h>
106#include <lal/TimeSeries.h>
107#include <lal/LALSimBlackHoleRingdown.h>
108
109#define a_invalid -100.0 /* invalid */
110#define i_invalid -361.0 /* invalid */
111#define l_invalid (INT_MIN + 1) /* invalid */
112#define m_invalid (INT_MAX) /* invalid */
113double dt = 1.0/16384.0;
114double a = a_invalid;
115double M = 0.0;
116double r = 0.0;
117double e = 0.0;
118double i = i_invalid;
119double q = 0.0;
122
123int usage(const char *program);
124int parseargs(int argc, char **argv);
125
126int main(int argc, char *argv[])
127{
128 LIGOTimeGPS epoch = {0, 0};
129 REAL8TimeSeries *hplus;
130 REAL8TimeSeries *hcross;
131 size_t j;
132
134
135 parseargs(argc, argv);
136
137 XLALSimBlackHoleRingdown(&hplus, &hcross, &epoch, q, dt, M, a, e, r, i, l, m);
138
139 fprintf(stdout, "# time (s)\th_plus (strain)\th_cross (strain)\n");
140 for (j = 0; j < hplus->data->length; ++j)
141 fprintf(stdout, "%.9f\t%.18e\t%.18e\n", j*dt, hplus->data->data[j], hcross->data->data[j]);
142
146
147 return 0;
148}
149
150int parseargs( int argc, char **argv )
151{
152 struct LALoption long_options[] = {
153 { "help", no_argument, 0, 'h' },
154 { "leaver", no_argument, 0, 'L' },
155 { "mass", required_argument, 0, 'M' },
156 { "spin", required_argument, 0, 'a' },
157 { "inclination", required_argument, 0, 'i' },
158 { "azimuth", required_argument, 0, 'q' },
159 { "energy", required_argument, 0, 'e' },
160 { "distance", required_argument, 0, 'r' },
161 { "l", required_argument, 0, 'l' },
162 { "m", required_argument, 0, 'm' },
163 { 0, 0, 0, 0 }
164 };
165 char args[] = "hM:a:i:q:e:r:l:m:";
166 while (1) {
167 int option_index = 0;
168 int c;
169
170 c = LALgetopt_long_only(argc, argv, args, long_options, &option_index);
171 if (c == -1) /* end of options */
172 break;
173
174 switch (c) {
175 case 0: /* if option set a flag, nothing else to do */
176 if (long_options[option_index].flag)
177 break;
178 else {
179 fprintf(stderr, "error parsing option %s with argument %s\n", long_options[option_index].name, LALoptarg);
180 exit(1);
181 }
182 case 'h': /* help */
183 usage(argv[0]);
184 exit(0);
185 case 'M': /* mass */
186 M = LAL_MSUN_SI * atof(LALoptarg);
187 break;
188 case 'a': /* spin */
189 a = atof(LALoptarg);
190 break;
191 case 'i': /* inclination */
192 i = LAL_PI_180 * atof(LALoptarg);
193 break;
194 case 'q': /* azimuth */
195 q = LAL_PI_180 * atof( LALoptarg );
196 break;
197 case 'e': /* energy */
198 e = atof(LALoptarg);
199 break;
200 case 'r': /* distance */
201 r = 1e6 * LAL_PC_SI * atof(LALoptarg);
202 break;
203 case 'l':
204 l = atoi(LALoptarg);
205 break;
206 case 'm':
207 m = atoi(LALoptarg);
208 break;
209 case '?':
210 default:
211 fprintf(stderr, "unknown error while parsing options\n");
212 exit(1);
213 }
214 }
215
216 if ( LALoptind < argc ) {
217 fprintf(stderr, "extraneous command line arguments:\n");
218 while (LALoptind < argc)
219 fprintf(stderr, "%s\n", argv[LALoptind++]);
220 exit(1);
221 }
222
223 if (a == a_invalid || l == l_invalid || m == m_invalid || M <= 0.0 || e <= 0.0 || e >= 1.0 || r <= 0.0 || i == i_invalid) {
224 fprintf(stderr, "must specify mass, spin, distance, frac. energy loss, l, m\n");
225 usage(argv[0]);
226 exit(1);
227 }
228
229 if (l < 2) {
230 fprintf(stderr, "must specify l >= 2\n");
231 exit(1);
232 }
233
234 if (abs(m) > l) {
235 fprintf(stderr, "must specify m <= l\n");
236 exit(1);
237 }
238
239 return 0;
240}
241
242int usage( const char *program )
243{
244 fprintf(stderr, "usage: %s [options]\n", program);
245 fprintf(stderr, "options:\n" );
246 fprintf(stderr, "\t-h, --help \tprint this message and exit\n");
247 fprintf(stderr, "\t-M Msolar \t(required) set black hole mass (solar masses)\n");
248 fprintf(stderr, "\t-a a \t(required) set value of a, -1<a<1\n");
249 fprintf(stderr, "\t-r distanceMpc \t(required) set distance (Mpc)\n");
250 fprintf(stderr, "\t-e fracEnergy \t(required) set energy radiated (fraction of M)\n");
251 fprintf(stderr, "\t-i inclination \t(required) set inclination angle (degrees)\n");
252 fprintf(stderr, "\t-q azimuth \t(default=0) set azimuth angle (degrees)\n");
253 fprintf(stderr, "\t-l l \t(required) set value of l, l>=2\n");
254 fprintf(stderr, "\t-m m \t(required) set value of m, abs(m)<=l\n");
255 return 0;
256}
void LALCheckMemoryLeaks(void)
#define c
const char * name
int LALgetopt_long_only(int argc, char *const *argv, const char *options, const struct LALoption *long_options, int *opt_index)
int LALoptind
char * LALoptarg
#define no_argument
#define required_argument
#define fprintf
double dt
Definition: bh_ringdown.c:113
int main(int argc, char *argv[])
Definition: bh_ringdown.c:126
double a
Definition: bh_ringdown.c:114
int usage(const char *program)
Definition: bh_ringdown.c:242
#define l_invalid
Definition: bh_ringdown.c:111
int parseargs(int argc, char **argv)
Definition: bh_ringdown.c:150
double i
Definition: bh_ringdown.c:118
double q
Definition: bh_ringdown.c:119
#define i_invalid
Definition: bh_ringdown.c:110
int m
Definition: bh_ringdown.c:121
double r
Definition: bh_ringdown.c:116
int l
Definition: bh_ringdown.c:120
double e
Definition: bh_ringdown.c:117
double M
Definition: bh_ringdown.c:115
#define m_invalid
Definition: bh_ringdown.c:112
#define a_invalid
Definition: bh_ringdown.c:109
#define LAL_MSUN_SI
#define LAL_PI_180
#define LAL_PC_SI
int XLALSimBlackHoleRingdown(REAL8TimeSeries **hplus, REAL8TimeSeries **hcross, const LIGOTimeGPS *t0, double phi0, double deltaT, double mass, double dimensionless_spin, double fractional_mass_loss, double distance, double inclination, int l, int m)
Computes the waveform for the ringdown of a black hole quasinormal mode (l,m).
void XLALDestroyREAL8TimeSeries(REAL8TimeSeries *series)
void XLALBacktraceErrorHandler(const char *func, const char *file, int line, int errnum)
XLALErrorHandlerType * XLALSetErrorHandler(XLALErrorHandlerType *newHandler)
char * program
Definition: inject.c:87
int * flag
REAL8Sequence * data
REAL8 * data
LIGOTimeGPS epoch
Definition: unicorn.c:20