Logo coherent WaveBurst  
Library Reference Guide
Logo
gw_signal.cc
Go to the documentation of this file.
1 /*
2 # Copyright (C) 2019 Sergey Klimenko, Valentin Necula
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 3 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 this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17 
18 
19 #include "egw_model.hh"
20 #include "geodesics.hh"
21 #include "merger.hh"
22 #include "numpy.hh"
23 
24 #include "stdio.h"
25 #include "stdlib.h"
26 #include "math.h"
27 
28 inline double min(double x, double y)
29 { return x<y? x: y;}
30 
31 
32 int main(int argc, char** argv)
33 {
34  if(argc<3){
35  printf("Usage: %s <rmin> <eccentricity> [<mass ratio>] [PLOT] [<TMAX>]\n",
36  argv[0]);
37  return -1;
38  }
39 
40  double rmin0 = atof(argv[1]);
41  if(rmin0<0){
42  printf("Error! rmin must be >=0\n");
43  return -2;
44  }
45  double e0 = atof(argv[2]);
46  if(e0>1){
47  printf("Error! Orbit must be initially parabolic or bound.\n");
48  return -3;
49  }
50  double q = 0.25;
51 
52  double t_end = 10000000.0;
53  bool PLOT = false;
54  if(argc>3){
55  q = atof(argv[3]);
56  if(q<0 || q>1){
57  printf("Error! mass ratio must be between 0 and 1\n");
58  return -4;
59  }
60  if(argc>4){
61  PLOT = true;
62  if(argc>5)t_end = atof(argv[5]);
63  }
64  }
65 
66  double rmin = rmin0;
67  double e = e0;
68  double Mbh = 1/(1+q);
69  double Mns = 1 - Mbh;
70  printf("Mbh = %.1lf\nMns = %.1lf\n", Mbh, Mns);
71  double mu = Mns*Mbh;
72 
73  double abh = 0.0;
74  double dt = 1;
75  double a_final = 0;
76  double t_post_merger = 400;
77 
78  double Jspin = abh*Mbh*Mbh;
79  double L0 = ang_mom_eff_geo(rmin0, e0, Jspin, mu);
80  double a0 = Jspin+mu*L0;
81  double E0 = energy_geo(rmin0, e0, a0);
82  double r0 = 1000;
83  if (e0<1 && r0 > rmin0*(1+e0)/(1-e0)) r0 = rmin0*(1+e0)/(1-e0);
84 
85  int dir = -1; //inward
86  int N_plot = t_end/dt; //printf("%d\n", N_plot);
87  double phi0 = 0; //printf("%.6le %.6le %.6le %.6le %d %.6le %.6le\n", r0, phi0, E0, L0, dir, Jspin, mu);
88  geodesic geo(r0, phi0, E0, L0, dir, Jspin, mu);
89 
90  bool success = geo.integrate(t_end, N_plot, 0, true);
91  printf("%d\n", N_plot);
92 
93  FILE* f = fopen("path_cc.dat", "w");
94  for(int i=0; i<N_plot; ++i)
95  fprintf(f, "%1.6e %1.6e %1.6e %1.6e %1.6e %1.6e %1.6e %1.6e %1.6e\n",
96  geo.t[i], geo.r[i], geo.pr[i], geo.phi[i], geo.tau[i], geo.Et[i], geo.Lt[i],
97  geo.hplus[i], geo.hcross[i]);
98  fclose(f);
99 
100  double tmerge;
101  if (success){
102  tmerge = -1;
103  t_post_merger=0;
104  }
105  else{
106  double* r_LR = new double[N_plot];
107  for(int i=0; i<N_plot; ++i)
108  r_LR[i] = 2*(1+cos(2*(acos(-min(mu*geo.Lt[i] + Jspin, 1.))/3))) - geo.r[i]; //Light ring
109  tmerge = interp(0, r_LR, geo.t, N_plot, 1., 1.);
110  delete [] r_LR;
111  }
112 
113  int Ntsig = (geo.t[N_plot-1]+t_post_merger)/dt;
114  double* tsig = new double[Ntsig];
115  for(int i=0; i<Ntsig; ++i) tsig[i] = dt*i;
116 
117  double* hr = interp(tsig, Ntsig, geo.t, geo.hplus, N_plot, 0, 0);
118  double* hi = interp(tsig, Ntsig, geo.t, geo.hcross, N_plot, 0, 0);
119 
120  Complex* hsig = new Complex[Ntsig];
121  for(int i=0; i<Ntsig; ++i)hsig[i] = Complex(hr[i], hi[i]);
122 
123  a_final = mu*geo.Lt[N_plot-1] + abh*Mbh*Mbh; // Spin of final BH
124 
125  double tstart_merger = tmerge;
126  if (tmerge>0) irs_merger(dt, tmerge, tsig, hsig, Ntsig, a_final, tstart_merger);
127 
128  f=fopen("wave_cc.dat", "w");
129  for(int i=0; i<Ntsig; ++i)
130  fprintf(f, "%1.8e %1.8e %1.8e\n", tsig[i], hsig[i].Re(), hsig[i].Im());
131  fclose(f);
132  //hsigr = real(hsig)
133  //hsigi = imag(hsig)
134 
135  //N.savetxt('t.dat', tsig, fmt='%1.8e', delimiter='\n')
136  //N.savetxt('hp.dat', hsigr, fmt='%1.8e', delimiter='\n')
137  //N.savetxt('hc.dat', hsigi, fmt='%1.8e', delimiter='\n')
138 }
double * Et
Definition: geodesics.hh:36
int main(int argc, char **argv)
Definition: gw_signal.cc:32
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<< "\ layers : "<< nLAYERS<< "\ dF(hz) : "<< dF<< "\ 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:36
i drho i
bool integrate(double D_t, int &N, double rmin=0, bool stop_alr=false)
Definition: geodesics.cc:270
cout<< "SNR "<< xsnr<< endl;wavearray< double > f
Definition: ComputeSNR.C:75
double * t
Definition: geodesics.hh:36
fprintf(stdout,"start=%f duration=%f rate=%f\, x.start(), x.size()/x.rate(), x.rate())
double * hplus
Definition: geodesics.hh:36
printf("total live time: non-zero lags = %10.1f \, liveTot)
double * r
Definition: geodesics.hh:36
double e
double dt
double * phi
Definition: geodesics.hh:36
double * Lt
Definition: geodesics.hh:36
double e0
Definition: RescaleEBBH.C:17
double interp(double v, double *x, double *y, int n)
Definition: numpy.cc:21
double energy_geo(double rp, double e, double a)
Definition: egw_model.cc:227
double min(double x, double y)
Definition: gw_signal.cc:28
double * tau
Definition: geodesics.hh:36
fclose(ftrig)
double ang_mom_eff_geo(double rp, double e, double Jspin, double mu)
Definition: egw_model.cc:260
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:32
Definition: numpy.hh:29
double * pr
Definition: geodesics.hh:36