Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
gw_signal.cc
Go to the documentation of this file.
1 #include "egw_model.hh"
2 #include "geodesics.hh"
3 #include "merger.hh"
4 #include "numpy.hh"
5 
6 #include "stdio.h"
7 #include "stdlib.h"
8 #include "math.h"
9 
10 inline double min(double x, double y)
11 { return x<y? x: y;}
12 
13 
14 int main(int argc, char** argv)
15 {
16  if(argc<3){
17  printf("Usage: %s <rmin> <eccentricity> [<mass ratio>] [PLOT] [<TMAX>]\n",
18  argv[0]);
19  return -1;
20  }
21 
22  double rmin0 = atof(argv[1]);
23  if(rmin0<0){
24  printf("Error! rmin must be >=0\n");
25  return -2;
26  }
27  double e0 = atof(argv[2]);
28  if(e0>1){
29  printf("Error! Orbit must be initially parabolic or bound.\n");
30  return -3;
31  }
32  double q = 0.25;
33 
34  double t_end = 10000000.0;
35  bool PLOT = false;
36  if(argc>3){
37  q = atof(argv[3]);
38  if(q<0 || q>1){
39  printf("Error! mass ratio must be between 0 and 1\n");
40  return -4;
41  }
42  if(argc>4){
43  PLOT = true;
44  if(argc>5)t_end = atof(argv[5]);
45  }
46  }
47 
48  double rmin = rmin0;
49  double e = e0;
50  double Mbh = 1/(1+q);
51  double Mns = 1 - Mbh;
52  printf("Mbh = %.1lf\nMns = %.1lf\n", Mbh, Mns);
53  double mu = Mns*Mbh;
54 
55  double abh = 0.0;
56  double dt = 1;
57  double a_final = 0;
58  double t_post_merger = 400;
59 
60  double Jspin = abh*Mbh*Mbh;
61  double L0 = ang_mom_eff_geo(rmin0, e0, Jspin, mu);
62  double a0 = Jspin+mu*L0;
63  double E0 = energy_geo(rmin0, e0, a0);
64  double r0 = 1000;
65  if (e0<1 && r0 > rmin0*(1+e0)/(1-e0)) r0 = rmin0*(1+e0)/(1-e0);
66 
67  int dir = -1; //inward
68  int N_plot = t_end/dt; //printf("%d\n", N_plot);
69  double phi0 = 0; //printf("%.6le %.6le %.6le %.6le %d %.6le %.6le\n", r0, phi0, E0, L0, dir, Jspin, mu);
70  geodesic geo(r0, phi0, E0, L0, dir, Jspin, mu);
71 
72  bool success = geo.integrate(t_end, N_plot, 0, true);
73  printf("%d\n", N_plot);
74 
75  FILE* f = fopen("path_cc.dat", "w");
76  for(int i=0; i<N_plot; ++i)
77  fprintf(f, "%1.6e %1.6e %1.6e %1.6e %1.6e %1.6e %1.6e %1.6e %1.6e\n",
78  geo.t[i], geo.r[i], geo.pr[i], geo.phi[i], geo.tau[i], geo.Et[i], geo.Lt[i],
79  geo.hplus[i], geo.hcross[i]);
80  fclose(f);
81 
82  double tmerge;
83  if (success){
84  tmerge = -1;
85  t_post_merger=0;
86  }
87  else{
88  double* r_LR = new double[N_plot];
89  for(int i=0; i<N_plot; ++i)
90  r_LR[i] = 2*(1+cos(2*(acos(-min(mu*geo.Lt[i] + Jspin, 1.))/3))) - geo.r[i]; //Light ring
91  tmerge = interp(0, r_LR, geo.t, N_plot, 1., 1.);
92  delete [] r_LR;
93  }
94 
95  int Ntsig = (geo.t[N_plot-1]+t_post_merger)/dt;
96  double* tsig = new double[Ntsig];
97  for(int i=0; i<Ntsig; ++i) tsig[i] = dt*i;
98 
99  double* hr = interp(tsig, Ntsig, geo.t, geo.hplus, N_plot, 0, 0);
100  double* hi = interp(tsig, Ntsig, geo.t, geo.hcross, N_plot, 0, 0);
101 
102  Complex* hsig = new Complex[Ntsig];
103  for(int i=0; i<Ntsig; ++i)hsig[i] = Complex(hr[i], hi[i]);
104 
105  a_final = mu*geo.Lt[N_plot-1] + abh*Mbh*Mbh; // Spin of final BH
106 
107  double tstart_merger = tmerge;
108  if (tmerge>0) irs_merger(dt, tmerge, tsig, hsig, Ntsig, a_final, tstart_merger);
109 
110  f=fopen("wave_cc.dat", "w");
111  for(int i=0; i<Ntsig; ++i)
112  fprintf(f, "%1.8e %1.8e %1.8e\n", tsig[i], hsig[i].Re(), hsig[i].Im());
113  fclose(f);
114  //hsigr = real(hsig)
115  //hsigi = imag(hsig)
116 
117  //N.savetxt('t.dat', tsig, fmt='%1.8e', delimiter='\n')
118  //N.savetxt('hp.dat', hsigr, fmt='%1.8e', delimiter='\n')
119  //N.savetxt('hc.dat', hsigi, fmt='%1.8e', delimiter='\n')
120 }
double * Et
Definition: geodesics.hh:18
tuple f
Definition: cwb_online.py:91
printf("total live time: non-zero lags = %10.1f \n", liveTot)
fprintf(stdout,"start=%f duration=%f rate=%f\n", x.start(), x.size()/x.rate(), x.rate())
int main(int argc, char **argv)
Definition: gw_signal.cc:14
cout<< endl;cout<< "ts size = "<< ts.size()<< " ts rate = "<< ts.rate()<< endl;tf.Forward(ts, wdm);int levels=tf.getLevel();cout<< "tf size = "<< tf.size()<< endl;double dF=tf.resolution();double dT=1./(2 *dF);cout<< "rate(hz) : "<< RATE<< "\t layers : "<< nLAYERS<< "\t dF(hz) : "<< dF<< "\t dT(ms) : "<< dT *1000.<< endl;int itime=TIME_PIXEL_INDEX;int ifreq=FREQ_PIXEL_INDEX;int index=(levels+1)*itime+ifreq;double time=itime *dT;double freq=(ifreq >0)?ifreq *dF:dF/4;cout<< endl;cout<< "PIXEL TIME = "<< time<< " sec "<< endl;cout<< "PIXEL FREQ = "<< freq<< " Hz "<< endl;cout<< endl;wavearray< double > x
double * hcross
Definition: geodesics.hh:18
i drho i
bool integrate(double D_t, int &N, double rmin=0, bool stop_alr=false)
Definition: geodesics.cc:242
double * t
Definition: geodesics.hh:18
double * hplus
Definition: geodesics.hh:18
double * r
Definition: geodesics.hh:18
double e
double dt
double * phi
Definition: geodesics.hh:18
double * Lt
Definition: geodesics.hh:18
double e0
Definition: RescaleEBBH.C:17
double interp(double v, double *x, double *y, int n)
Definition: numpy.cc:3
double energy_geo(double rp, double e, double a)
Definition: egw_model.cc:209
double min(double x, double y)
Definition: gw_signal.cc:10
double * tau
Definition: geodesics.hh:18
fclose(ftrig)
double ang_mom_eff_geo(double rp, double e, double Jspin, double mu)
Definition: egw_model.cc:242
wavearray< double > y
Definition: Test10.C:31
void irs_merger(double dt, double tmerge, double *tsig, Complex *hsig, int lentsig, double a, double tstart=-1)
Definition: merger.cc:14
Definition: numpy.hh:11
double * pr
Definition: geodesics.hh:18