Debian Codegraph @

Codes/Alternatives/altbh.C

raw
1 /*
2 * Code for reading alternative BH spacetime from a file
3 */
4
5 /*
6 * Copyright (c) 2013 Odele Straub, Eric Gourgoulhon
7 *
8 * This file is part of LORENE.
9 *
10 * LORENE is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2
12 * as published by the Free Software Foundation.
13 *
14 * LORENE is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with LORENE; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 */
24
25 char altBH_C[] = "$Header: /cvsroot/Lorene/Codes/Alternatives/altbh.C,v 1.6 2014/10/13 08:53:52 j_novak Exp $" ;
26
27 /*
28 * $Id: altbh.C,v 1.6 2014/10/13 08:53:52 j_novak Exp $
29 * $Log: altbh.C,v $
30 * Revision 1.6 2014/10/13 08:53:52 j_novak
31 * Lorene classes and functions now belong to the namespace Lorene.
32 *
33 * Revision 1.5 2014/04/11 17:22:07 o_straub
34 * Risco and Rms output for GYOTO
35 *
36 * Revision 1.4 2014/02/12 16:44:54 o_straub
37 * New output : calculates radii for a range of spin and stores them in file
38 *
39 * Revision 1.3 2014/01/14 20:54:47 e_gourgoulhon
40 * Comparison with Kerr_QI; better outputs
41 *
42 * Revision 1.2 2013/04/17 13:03:29 e_gourgoulhon
43 * New member krphi
44 *
45 * Revision 1.1 2013/04/16 15:29:33 e_gourgoulhon
46 * New code for reading Enrico's data
47 *
48 *
49 * $Header: /cvsroot/Lorene/Codes/Alternatives/altbh.C,v 1.6 2014/10/13 08:53:52 j_novak Exp $
50 *
51 */
52
53 // C++ headers
54 #include "headcpp.h"
55
56 // C headers
57 #include <cstdlib>
58 #include <cmath>
59 #include <cstdio>
60 #include <iostream>
61 using namespace std ;
62
63 // Lorene headers
64 #include "compobj.h"
65 #include "nbr_spx.h"
66 #include "utilitaires.h"
67 #include "proto.h"
68 #include "graphique.h"
69
70
71 using namespace Lorene ;
72
73 int main() {
74
75 // Parameters of the computation
76 // -----------------------------
77
78 ifstream fpar("par_altbh.d") ;
79 if ( !fpar.good() ) {
80 cerr << "Problem in opening the file par_altbh.d ! " << endl ;
81 abort() ;
82 }
83
84 char file_name[256] ;
85 fpar.getline(file_name, 256) ;
86 cout << "File to be read: " << file_name << endl ;
87
88 double mass ; // M
89 fpar >> mass ; fpar.ignore(1000,'\n') ;
90
91 double a_ov_m ;
92 fpar >> a_ov_m ; fpar.ignore(1000,'\n') ;
93
94 int graphic_out ; // flag for graphical outputs
95 fpar >> graphic_out ; fpar.ignore(1000,'\n') ;
96
97 int nr ; // Number of collocation points in r in each domain
98 fpar >> nr; fpar.ignore(1000,'\n') ;
99
100 int nt ; // Number of collocation points in theta in each domain
101 fpar >> nt; fpar.ignore(1000,'\n') ;
102
103 int np ; // Number of collocation points in phi in each domain
104 fpar >> np; fpar.ignore(1000,'\n') ;
105
106 int nz ; // Number of domains
107 fpar >> nz ; fpar.ignore(1000,'\n') ;
108 int nzm1 = nz - 1 ; // Index of outermost domain
109
110 fpar.ignore(1000,'\n') ; // skip title
111 double* r_limits = new double[nz+1]; // inner boundaries of each domain in units of M
112 for (int l=0; l<nz; l++)
113 {
114 fpar >> r_limits[l];
115 }
116 r_limits[nz] = __infinity ;
117
118 fpar.close();
119
120 // cout << "M = " << mass << ", a/M = " << a_ov_m << endl ;
121 double r_hor = double(0.5)*mass*sqrt(double(1)-a_ov_m*a_ov_m) ;
122
123 // cout << "Value of coordinate r at the event horizon : " << r_hor << endl ;
124 // cout << "r_limits : " ;
125 // for (int l=0; l<nz+1; l++) {
126 // cout << r_limits[l] << " " ;
127 // }
128 // cout << endl ;
129
130 // arrete() ;
131
132
133 // Setup of a multi-domain grid (Lorene class Mg3d)
134 // ------------------------------------------------
135
136 int symmetry_theta = SYM ; // symmetry with respect to the equatorial plane
137 int symmetry_phi = SYM ; // symmetry with respect to phi --> phi + pi
138 bool compact = true ; // external domain is compactified
139
140 Mg3d mgrid(nz, nr, nt, np, symmetry_theta, symmetry_phi, compact) ;
141
142 //cout << mgrid << endl ;
143
144
145 // Setup of an affine mapping : grid --> physical space (Lorene class Map_af)
146 // --------------------------------------------------------------------------
147
148 Map_af map(mgrid, r_limits) ;
149
150 // Construction of the AltBH_QI object:
151 // ----------------------------------
152
153 AltBH_QI bh(map, file_name, a_ov_m) ;
154 Kerr_QI bh2(map, 1., a_ov_m) ;
155
156 bh.update_metric() ;
157 bh2.update_metric() ;
158
159
160 cout.precision(15) ;
161 cout << endl << "******* bh ******** " << endl ;
162 cout << bh << endl ;
163 cout << endl << "******* bh2 ******** " << endl ;
164 cout << bh2 << endl ;
165
166
167 // SOME TESTS
168 // Scalar diffn = bh.get_nn() - bh2.get_nn();
169 // cout << "max(N - N(2)) : " << max(diffn) << endl ;
170 // Scalar tmp = bh.get_nn().dsdr() ;
171 // tmp.annule_domain(nzm1) ;
172 // tmp = tmp.dsdr() ;
173 // Scalar tmp2 = bh2.get_nn().dsdr() ;
174 // tmp2.annule_domain(nzm1) ;
175 // tmp2 = tmp2.dsdr() ;
176 // Scalar diffddn = tmp - tmp2;
177 // cout << "max(d2N - d2N(2)) : " << max(diffddn) << endl ;
178 // Scalar diffa2 = bh.get_a_car() - bh2.get_a_car();
179 // cout << "max(A^2 - A^2(2)) : " << max(diffa2) << endl ;
180 // Scalar diffb2 = bh.get_b_car() - bh2.get_b_car();
181 // cout << "max(B^2 - B^2(2)) : " << max(diffb2) << endl ;
182 // Scalar diffnp = bh.get_nphi() - bh2.get_nphi();
183 // cout << "max(Nphi - Nphi(2)) : " << max(diffnp) << endl ;
184 // arrete() ;
185
186
187
188
189 // ISCO from Eq. (21) of Bardeen, Press & Teukolsky, ApJ 178, 347 (1972):
190 double third = double(1)/double(3) ;
191 double z1 = 1 + pow(1-a_ov_m*a_ov_m, third)*( pow(1+a_ov_m, third) +
192 pow(1-a_ov_m, third) ) ;
193 double z2 = sqrt(3*a_ov_m*a_ov_m + z1*z1) ;
194
195 double R_isco = 3 + z2 - sqrt((3-z1)*(3+z1+2*z2)) ;
196 double R_isco_QI = bh2.r_isco(0)/mass + mass*(1-a_ov_m*a_ov_m)/(4*bh2.r_isco(0)) + 1 ;
197 double R_isco_alt = bh.r_isco(0)/mass + mass*(1-a_ov_m*a_ov_m)/(4*bh.r_isco(0)) + 1 ;
198
199
200 cout.precision(15) ;
201 cout << "Analytic value of R_ISCO (Kerr): " << R_isco << " M " << endl ;
202 cout << "Numerical value of R_ISCO (Kerr_QI): " << R_isco_QI << " M - at " << bh2.r_isco(0) << endl ;
203 cout << "Numerical value of R_ISCO (alternative): " << R_isco_alt << " M - at " << bh.r_isco(0) << endl ;
204
205
206
207 // R_mb analogue to Eq. (19) of Bardeen, Press & Teukolsky, ApJ 178, 347 (1972):
208 double R_mb = 2 - a_ov_m + 2 * sqrt(1 - a_ov_m) ;
209 double R_mb_QI = bh2.r_mb(0)/mass + mass*(1 - a_ov_m*a_ov_m)/(4*bh2.r_mb(0)) + 1 ;
210 double R_mb_alt = bh.r_mb(0)/mass + mass*(1 - a_ov_m*a_ov_m)/(4*bh.r_mb(0)) + 1 ;
211
212 cout.precision(15) ;
213 cout << "Analytical value of R_mb (Kerr): " << R_mb << " M " << endl ;
214 cout << "Numerical value of R_mb (Kerr_QI): " << R_mb_QI << " M - at " << bh2.r_mb(0) << endl ;
215 cout << "Numerical value of R_mb (alternative): " << R_mb_alt << " M - at " << bh.r_mb(0) << endl ;
216
217
218
219
220 // Drawings
221 if (graphic_out == 1)
222 {
223 double r_max = 1.5*map.val_r(nzm1,-1.,0.,0.) ;
224 des_meridian(bh.get_nn(), 0, r_max, "N", 1) ;
225 //des_meridian(diffn , 0, r_max, "N - N(2)", 2) ;
226 //des_meridian(diffddn , 0, r_max, "diff d2N", 3) ;
227
228 des_meridian(bh.get_nphi(), 0, r_max, "Nphi", 4) ;
229 des_meridian(bh.get_nphi().dsdr(), 0, r_max, "dNphi/dr", 5) ;
230
231 des_meridian(bh.get_gamma().cov()(1,1), 0, r_max, "gamma_11", 6) ;
232 des_meridian(bh.get_gamma().cov()(3,3), 0, r_max, "gamma_33", 7) ;
233
234 des_meridian(bh.get_kk()(1,3), 0.4, 0.6, "K_(r)(ph)", 8) ;
235 des_meridian(bh.get_krphi(), 0.4, 0.6, "K_(r)(ph)/sin(theta) from file", 9) ;
236 des_meridian(bh.get_kk()(2,3), 0, r_max, "K_(th)(ph)", 10) ;
237 //arrete() ;
238 }
239
240
241
242 //----------------------
243 // Output file for GYOTO
244 //----------------------
245 bh.gyoto_data("gyoto_altBH_QI.d") ;
246
247
248
249 // a small loop to get Risco and Rmb for a range of spins
250 // and store the results in a file
251 for (a_ov_m=0.0001; a_ov_m<0.3; a_ov_m+=0.01)
252 {
253
254 AltBH_QI bh(map, file_name, a_ov_m) ;
255
256 bh.update_metric() ;
257
258 // ISCO from Eq. (21) of Bardeen, Press & Teukolsky, ApJ 178, 347 (1972):
259 double third = double(1)/double(3) ;
260 double z1 = 1 + pow(1-a_ov_m*a_ov_m, third)*( pow(1+a_ov_m, third) +
261 pow(1-a_ov_m, third) ) ;
262 double z2 = sqrt(3*a_ov_m*a_ov_m + z1*z1) ;
263
264 double R_isco = 3 + z2 - sqrt((3-z1)*(3+z1+2*z2)) ;
265 double R_isco_alt = bh.r_isco(0)/mass + mass*(1-a_ov_m*a_ov_m)/(4*bh.r_isco(0)) + 1 ;
266
267 // R_mb analogue to Eq. (19) of Bardeen, Press & Teukolsky, ApJ 178, 347 (1972):
268 double R_mb = 2 - a_ov_m + 2 * sqrt(1 - a_ov_m) ;
269 double R_mb_alt = bh.r_mb(0)/mass + mass*(1 - a_ov_m*a_ov_m)/(4*bh.r_mb(0)) + 1 ;
270
271
272 //-------------------------------
273 // Output files for Risco and Rmb
274 //-------------------------------
275 freopen("radbound.txt", "a", stdout) ; // "a" for append (during loop)
276 cout.precision(15) ;
277 cout << a_ov_m << " " << R_mb << " " << R_mb_alt << " " << endl ;
278
279 freopen("radisco.txt", "a", stdout) ;
280 cout.precision(15) ;
281 cout << a_ov_m << " " << R_isco << " " << R_isco_alt << " " << endl ;
282
283 freopen("dummy.txt", "w", stdout) ; // empty log file (needed for clean stdout - not sure why)
284 cout << " " << endl ;
285
286 }
287
288 fclose (stdout) ;
289
290 return EXIT_SUCCESS ;
291
292 }
293
294
295
296
297
298
299
300
301
302
303
304
305