Debian Codegraph @

Codes/Bin_hor/lit_bh.C

raw
1 /*
2 * Reads a binary black hole configuration
3 *
4 */
5
6 /*
7 * Copyright (c) 2005 Francois Limousin
8 * Jose Luis Jaramillo
9 *
10 * This file is part of LORENE.
11 *
12 * LORENE is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2
14 * as published by the Free Software Foundation.
15 *
16 * LORENE is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with LORENE; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *
25 */
26
27 char lit_bh_C[] = "$Header: /cvsroot/Lorene/Codes/Bin_hor/lit_bh.C,v 1.8 2014/10/13 08:53:53 j_novak Exp $" ;
28
29 /*
30 * $Id: lit_bh.C,v 1.8 2014/10/13 08:53:53 j_novak Exp $
31 * $Log: lit_bh.C,v $
32 * Revision 1.8 2014/10/13 08:53:53 j_novak
33 * Lorene classes and functions now belong to the namespace Lorene.
34 *
35 * Revision 1.7 2014/10/06 15:09:42 j_novak
36 * Modified #include directives to use c++ syntax.
37 *
38 * Revision 1.6 2005/11/16 15:33:39 f_limousin
39 * Adaptation of the code for spherical components
40 *
41 * Revision 1.5 2005/11/16 14:27:20 f_limousin
42 * Output of boundary conditions
43 *
44 * Revision 1.4 2005/09/24 08:28:31 f_limousin
45 * Implementation of Smarr formula. Computation of dt_psi/psi.
46 *
47 * Revision 1.3 2005/06/09 16:17:21 f_limousin
48 * Many different changes.
49 *
50 * Revision 1.2 2005/03/04 09:42:25 f_limousin
51 * New construction of the object Bin_hor.
52 *
53 * Revision 1.1 2005/03/03 13:51:56 f_limousin
54 * First version
55 *
56 *
57 * $Header: /cvsroot/Lorene/Codes/Bin_hor/lit_bh.C,v 1.8 2014/10/13 08:53:53 j_novak Exp $
58 *
59 */
60
61 //standard
62 #include <cstdlib>
63 #include <cmath>
64
65 // LORENE
66 #include "type_parite.h"
67 #include "nbr_spx.h"
68 #include "proto.h"
69 #include "param.h"
70 #include "tenseur.h"
71 #include "metric.h"
72 #include "isol_hor.h"
73 #include "graphique.h"
74 #include "utilitaires.h"
75 #include "unites.h"
76
77
78 using namespace Lorene ;
79
80 int main(int argc, char** argv) {
81
82 using namespace Unites ;
83
84 if (argc <2) {
85 cout <<" Passer nom du ficher en arguments SVP !" << endl ;
86 abort() ;
87 }
88
89 char* name_fich = argv[1] ;
90
91 // char* name_fich = "bin.dat" ;
92
93
94 // Construction of the binary
95 // --------------------------
96
97 int depth = 3 ;
98 FILE* fich = fopen(name_fich, "r") ;
99 Mg3d grid (fich) ;
100 Map_af map_un (grid, fich) ;
101 Map_af map_deux (grid, fich) ;
102 Bin_hor bin (map_un, map_deux, fich, true, depth) ;
103 fclose(fich) ;
104
105 // Inititialisation of fields :
106 // ----------------------------
107
108 bin.set(1).n_comp (bin(2)) ;
109 bin.set(1).psi_comp (bin(2)) ;
110 bin.set(2).n_comp (bin(1)) ;
111 bin.set(2).psi_comp (bin(1)) ;
112 bin.decouple() ;
113 bin.extrinsic_curvature() ;
114
115 cout << "axi_break = " << bin(1).axi_break() << endl ;
116 // abort() ;
117
118 // Verification of boundary conditions
119 // -----------------------------------
120
121 Metric_flat fff (bin(1).get_mp().flat_met_spher()) ;
122
123 // lapse
124 cout << "Lapse boundary condition" << endl ;
125 for(int j=0; j<bin(1).get_mp().get_mg()->get_nt(1); j++)
126 for(int k=0; k<bin(1).get_mp().get_mg()->get_np(1); k++){
127 cout << bin(1).nn().val_grid_point(1, k, j, 0) << " "
128 << (0.3 - bin(1).nn()).val_grid_point(1, k, j, 0) << endl ;
129 }
130 arrete() ;
131
132 // Psi
133 cout << "Psi boundary condition" << endl ;
134 Scalar bound_temp1 (contract(bin(1).k_dd(), 0, 1, bin(1).tradial_vect_hor()
135 * bin(1).tradial_vect_hor(), 0, 1) / bin(1).psi()) ;
136 Scalar bound_temp2 ( contract(bin(1).k_dd(), 0, 1, bin(1).tradial_vect_hor() * bin(1).tradial_vect_hor(), 0, 1) / bin(1).psi() + bin(1).psi() * bin(1).tradial_vect_hor().divergence(fff) + 4 * contract(bin(1).tradial_vect_hor() * bin(1).psi().derive_cov(fff), 0, 1) ) ;
137
138 for(int j=0; j<bin(1).get_mp().get_mg()->get_nt(1); j++)
139 for(int k=0; k<bin(1).get_mp().get_mg()->get_np(1); k++){
140 cout << bound_temp1.val_grid_point(1, k, j, 0)
141 << " " << bound_temp2.val_grid_point(1, k, j, 0)
142 << endl ;
143 }
144 arrete() ;
145
146 // Shift
147
148 Scalar bb (bin(1).get_mp()) ;
149 Vector shiftt (bin(1).beta()) ;
150 shiftt.change_triad(bin(1).get_mp().get_bvect_cart()) ;
151
152 Scalar xa (bin(1).get_mp()) ;
153 xa = bin(1).get_mp().xa ;
154 xa.annule_domain(bin(1).get_mp().get_mg()->get_nzone()-1) ;
155 Scalar ya (bin(1).get_mp()) ;
156 ya = bin(1).get_mp().ya ;
157 ya.annule_domain(bin(1).get_mp().get_mg()->get_nzone()-1) ;
158
159 double orientation = bin(1).get_mp().get_rot_phi() ;
160 assert ((orientation == 0) || (orientation == M_PI)) ;
161 int aligne = (orientation == 0) ? 1 : -1 ;
162
163 shiftt.set(1) = shiftt(1) - aligne * bin(1).get_omega() * ya ;
164 shiftt.set(2) = shiftt(2) + aligne * bin(1).get_omega() * xa ;
165
166 Vector normal (bin(1).radial_vect_hor()) ;
167 normal.change_triad(bin(1).get_mp().get_bvect_cart()) ;
168 bb = contract(shiftt, 0, normal.up_down(bin(1).gam()), 0) ;
169
170
171 cout << "Shift boundary condition" << endl ;
172 for(int j=0; j<bin(1).get_mp().get_mg()->get_nt(1); j++)
173 for(int k=0; k<bin(1).get_mp().get_mg()->get_np(1); k++){
174 cout << bb.val_grid_point(1, k, j, 0) << " " << bin(1).nn().val_grid_point(1, k, j, 0) << " " << (bb - bin(1).nn()).val_grid_point(1, k, j, 0) << endl ;
175 }
176 arrete() ;
177
178
179 // Calculation of global quantities
180 // --------------------------------
181
182 double distance = map_un.get_ori_x() - map_deux.get_ori_x() ;
183 double beta = distance/bin(1).get_radius() ;
184 double omega = bin.get_omega() ;
185 double adm = bin.adm_mass() ;
186 double komar = bin.komar_mass() ;
187 double moment_inf = bin.ang_mom_adm() ;
188 double moment_hor = bin.ang_mom_hor() ;
189 double mass_area = sqrt(bin(1).area_hor()/16/M_PI) +
190 sqrt(bin(2).area_hor()/16/M_PI) ;
191
192 cout << "Beta : " << beta << endl ;
193 cout << "Omega : " << omega << endl ;
194 cout << "ADM mass : " << adm << endl ;
195 cout << "Komar mass : " << komar << endl ;
196 cout << "Mass area : " << mass_area << endl ;
197 cout << "ADM ang. mom. : " << moment_inf << endl ;
198 cout << "horizon ang.mom. : " << moment_hor << endl ;
199
200 // Verification of \partial_t \Psi << Omega
201 // -----------------------------------------
202
203 const Metric& flat1 (map_un.flat_met_spher()) ;
204 const Metric& flat2 (map_deux.flat_met_spher()) ;
205
206 Vector omdsdp (map_un, CON, map_un.get_bvect_cart()) ;
207 Scalar yya (map_un) ;
208 yya = map_un.ya ;
209 Scalar xxa (map_un) ;
210 xxa = map_un.xa ;
211
212 double om = bin.get_omega() ;
213
214 if (fabs(map_un.get_rot_phi()) < 1e-10){
215 omdsdp.set(1) = - om * yya ;
216 omdsdp.set(2) = om * xxa ;
217 omdsdp.set(3).annule_hard() ;
218 }
219 else{
220 omdsdp.set(1) = om * yya ;
221 omdsdp.set(2) = - om * xxa ;
222 omdsdp.set(3).annule_hard() ;
223 }
224 omdsdp.annule_domain(map_un.get_mg()->get_nzone()-1) ;
225
226 omdsdp.set(1).set_spectral_va()
227 .set_base(*(map_un.get_mg()->std_base_vect_cart()[0])) ;
228 omdsdp.set(2).set_spectral_va()
229 .set_base(*(map_un.get_mg()->std_base_vect_cart()[1])) ;
230 omdsdp.set(3).set_spectral_va()
231 .set_base(*(map_un.get_mg()->std_base_vect_cart()[2])) ;
232
233 omdsdp.change_triad(map_un.get_bvect_spher()) ;
234 Vector shift (bin(1).beta() + omdsdp) ;
235
236 Scalar dt_psi (contract(shift, 0, bin(1).psi().derive_cov(flat1), 0) +
237 bin(1).psi()*bin(1).beta().divergence(flat1)/6.) ;
238
239 cout << "Max(dt_psi/psi) : " << endl << max(dt_psi/bin(1).psi()) << endl ;
240 cout << "Norme(dt_psi/psi) : " << endl << norme(dt_psi/bin(1).psi())/
241 (map_un.get_mg()->get_nr(1)*map_un.get_mg()->get_nt(1)*
242 map_un.get_mg()->get_np(1)) << endl ;
243 cout << " omega = " << bin(1).get_omega() << endl ;
244
245 // Verification of Smarr :
246 // -----------------------
247
248 Vector integrand_un (map_un, COV, map_un.get_bvect_spher()) ;
249 integrand_un = bin(1).nn().derive_cov(flat1)*pow(bin(1).psi(), 2)
250 - bin(1).nn()*contract(bin(1).k_dd(), 1,
251 bin(1).gam().radial_vect(), 0)*pow(bin(1).psi(), 2) ;
252 integrand_un.std_spectral_base() ;
253 //integrand_un.change_triad(map_un.get_bvect_spher()) ;
254
255 Vector integrand_deux (map_deux, COV, map_deux.get_bvect_spher()) ;
256 integrand_deux = bin(2).nn().derive_cov(flat2)*pow(bin(2).psi(), 2)
257 - bin(2).nn()*contract(bin(2).k_dd(), 1,
258 bin(2).gam().radial_vect(), 0)*pow(bin(2).psi(), 2) ;
259 integrand_deux.std_spectral_base() ;
260 //integrand_deux.change_triad(map_deux.get_bvect_spher()) ;
261
262 double horizon = map_un.integrale_surface(integrand_un(1),
263 bin(1).get_radius())+
264 map_deux.integrale_surface(integrand_deux(1), bin(2).get_radius()) ;
265
266 horizon /= 4*M_PI ;
267
268 double j_test = (komar - horizon) / 2. / bin.get_omega() ;
269
270 cout.precision(10) ;
271 cout << "------------------------------------------" << endl ;
272 cout << "Difference between the two J : " << fabs(moment_inf - moment_hor)
273 / moment_inf << endl ;
274 cout << "Difference between ADM and Smarr : "
275 << fabs(moment_inf - j_test) / moment_inf << endl ;
276 cout << "Difference between horizon and Smarr : "
277 << fabs(moment_hor - j_test) / moment_hor << endl ;
278
279 cout << "------------------------------------------" << endl ;
280 cout << "Difference Komar-ADM : " << fabs(komar-adm)/fabs(adm) << endl ;
281 cout << "Comparison to Kepler : " << 4*moment_inf * pow(omega, 1./3.)
282 / pow(adm, 5./3.)
283 << endl ;
284 cout << "------------------------------------------" << endl ;
285 cout << "ADM mass : " << adm/ggrav/msol << " solar masses"<< endl ;
286 cout << "Frequence : " << omega/2/M_PI*f_unit << " Hz" << endl ;
287
288 cout <<"--------------------------------------------------------" << endl ;
289
290
291 // Definition of the surface
292 // -------------------------
293
294 Cmp surface_un (map_un) ;
295 surface_un = pow(map_un.r, 2.)-pow(bin(1).get_radius(), 2.) ;
296 surface_un.annule(grid.get_nzone()-1) ;
297 surface_un.std_base_scal() ;
298
299 Cmp surface_deux (map_deux) ;
300 surface_deux = pow(map_deux.r, 2.)-pow(bin(2).get_radius(), 2.) ;
301 surface_deux.annule(grid.get_nzone()-1) ;
302 surface_deux.std_base_scal() ;
303
304 // ---------------------
305 // Some drawings
306 // ---------------------
307
308
309 // Filter
310 // -------
311
312 double ta = 18.5 ;
313 Scalar filtre_un (map_un) ;
314 int zex = grid.get_nzone()-1 ;
315 filtre_un = 1. + 1e-15 ;
316 double alpha = map_un.get_alpha()[zex] ;
317 double rext = 1/(-2*alpha) ;
318 int nr = grid.get_nr(zex) ;
319 int np = grid.get_np(zex) ;
320 int nt = grid.get_nt(zex) ;
321
322 double uu, coloc ;
323 for (int i=0 ; i<nr-1 ; i++) {
324 coloc = -cos(M_PI*i/(nr-1)) ;
325 uu = alpha*(coloc-1) ;
326 if (uu <= 1./2/rext)
327 for (int j=0 ; j<nt ; j++)
328 for (int k=0 ; k<np ; k++)
329 filtre_un.set_grid_point(zex, k, j, i) =
330 0.5*(cos(M_PI*2*rext*(uu-1./2/rext))+1) ;
331 }
332 for (int j=0 ; j<nt ; j++)
333 for (int k=0 ; k<np ; k++)
334 filtre_un.set_grid_point(zex, k, j, nr-1) = 0 ;
335 filtre_un.std_spectral_base() ;
336
337 Scalar filtre_deux (map_deux) ;
338 filtre_deux.set_etat_qcq() ;
339 filtre_deux.set_spectral_va() = filtre_un.get_spectral_va() ;
340
341 // Shift
342 // ------
343
344 Vector shift_un (bin(1).beta_auto()) ;
345 shift_un.change_triad(map_un.get_bvect_cart()) ;
346
347 Scalar xa_un (map_un) ;
348 xa_un = omega/2*map_un.xa ;
349 Scalar ya_un (map_un) ;
350 ya_un = omega/2*map_un.ya ;
351 shift_un.set(1) = shift_un(1)-ya_un ;
352 shift_un.set(2) = shift_un(2)+xa_un ;
353 for (int i=1 ; i<=3 ; i++) {
354 shift_un.set(i).annule_domain(0) ;
355 shift_un.set(i)= filtre_un*shift_un(i) ;
356 shift_un.set(i).set_outer_boundary(zex, 0) ;
357 }
358
359 Vector shift_deux (bin(2).beta_auto()) ;
360 shift_deux.change_triad(map_deux.get_bvect_cart()) ;
361 shift_deux.change_triad(map_un.get_bvect_cart()) ;
362 Scalar xa_deux (map_deux) ;
363 xa_deux = omega/2*map_deux.xa ;
364 Scalar ya_deux (map_deux) ;
365 ya_deux = omega/2*map_deux.ya ;
366 shift_deux.set(1) = shift_deux(1)-ya_deux ;
367 shift_deux.set(2) = shift_deux(2)+xa_deux ;
368 for (int i=1 ; i<=3 ; i++) {
369 shift_deux.set(i).annule_domain(0) ;
370 shift_deux.set(i)= filtre_deux*shift_deux(i) ;
371 shift_deux.set(i).set_outer_boundary(zex, 0) ;
372 }
373
374 shift_deux.std_spectral_base() ;
375
376 Tenseur beta_un (map_un, 1, CON, map_un.get_bvect_cart()) ;
377 beta_un.set_etat_qcq() ;
378 Cmp beta1_x (shift_un(1)) ;
379 Cmp beta1_y (shift_un(2)) ;
380 Cmp beta1_z (shift_un(3)) ;
381 beta_un.set(0) = beta1_x ;
382 beta_un.set(1) = beta1_y ;
383 beta_un.set(2) = beta1_z ;
384 beta_un.set_std_base() ;
385
386 Tenseur beta_deux (map_deux, 1, CON, map_un.get_bvect_cart()) ;
387 beta_deux.set_etat_qcq() ;
388 Cmp beta2_x (shift_deux(1)) ;
389 Cmp beta2_y (shift_deux(2)) ;
390 Cmp beta2_z (shift_deux(3)) ;
391 beta_deux.set(0) = beta2_x ;
392 beta_deux.set(1) = beta2_y ;
393 beta_deux.set(2) = beta2_z ;
394 beta_deux.set_std_base() ;
395
396 des_vect_bin_z (beta_un, beta_deux, 0, 200, 1, -ta, ta, -ta, ta,
397 "Shift vector (Z=0)", &surface_un, &surface_deux, false, 12, 12) ;
398
399
400 // Lapse
401 // -------
402
403 ta = 18.5 ;
404 Cmp dessin_un (bin(1).n_auto()) ;
405 dessin_un.annule(0) ;
406
407 Cmp dessin_deux (bin(2).n_auto()) ;
408 dessin_deux.annule(0) ;
409
410 des_coupe_bin_z (dessin_un, dessin_deux, 0,
411 -ta, ta, -ta, ta, "Lapse function (Z=0)", &surface_un, &surface_deux,
412 false, 15, 300, 300) ;
413
414 // Psi
415 // -----
416
417 dessin_un = bin(1).psi_auto() ;
418 dessin_un.annule(0) ;
419
420 dessin_deux = bin(2).psi_auto() ;
421 dessin_deux.annule(0) ;
422
423 des_coupe_bin_z (dessin_un, dessin_deux, 0,
424 -ta, ta, -ta, ta, "Conformal factor (Z=0)", &surface_un, &surface_deux,
425 false, 15, 300, 300) ;
426
427
428 // Extrinsic curvature
429 // --------------------
430
431 Sym_tensor aa_auto_un (bin(1).aa_auto()) ;
432 Sym_tensor aa_auto_deux (bin(2).aa_auto()) ;
433
434 ta = 18.5 ;
435 dessin_un = aa_auto_un(1, 1) ;
436 dessin_un.annule(0) ;
437 dessin_un.dec2_dzpuis() ;
438
439 dessin_deux = aa_auto_deux(1, 1) ;
440 dessin_deux.annule(0) ;
441 dessin_deux.dec2_dzpuis() ;
442
443 des_coupe_bin_z (dessin_un, dessin_deux, 0,
444 -ta, ta, -ta, ta, "A\\urr\\d (Z=0)", &surface_un, &surface_deux, false
445 , 20, 300, 300) ;
446
447 dessin_un = aa_auto_un(1, 3) ;
448 dessin_un.annule(0) ;
449 dessin_un.dec2_dzpuis() ;
450
451 dessin_deux = aa_auto_deux(1, 3) ;
452 dessin_deux.annule(0) ;
453 dessin_deux.dec2_dzpuis() ;
454
455 des_coupe_bin_z (dessin_un, dessin_deux, 0,
456 -ta, ta, -ta, ta, "A\\urp\\d (Z=0)", &surface_un, &surface_deux, false,
457 20, 300, 300) ;
458
459 // In cartesian ccordinates.
460
461 aa_auto_un.change_triad(bin(1).get_mp().get_bvect_cart()) ;
462 aa_auto_deux.change_triad(bin(2).get_mp().get_bvect_cart()) ;
463
464 dessin_un = aa_auto_un(1, 1) ;
465 dessin_un.annule(0) ;
466 dessin_un.dec2_dzpuis() ;
467
468 dessin_deux = aa_auto_deux(1, 1) ;
469 dessin_deux.annule(0) ;
470 dessin_deux.dec2_dzpuis() ;
471
472 des_coupe_bin_z (dessin_un, dessin_deux, 0,
473 -ta, ta, -ta, ta, "A\\uXX\\d (Z=0)", &surface_un, &surface_deux, false
474 , 20, 300, 300) ;
475
476
477 dessin_un = aa_auto_un(2, 1) ;
478 dessin_un.annule(0) ;
479 dessin_un.dec2_dzpuis() ;
480
481 dessin_deux = aa_auto_deux(2, 1) ;
482 dessin_deux.annule(0) ;
483 dessin_deux.dec2_dzpuis() ;
484
485 des_coupe_bin_z (dessin_un, dessin_deux, 0,
486 -ta, ta, -ta, ta, "A\\uXY\\d (Z=0)", &surface_un, &surface_deux, false
487 , 20, 300, 300) ;
488
489
490 dessin_un = aa_auto_un(2, 2) ;
491 dessin_un.annule(0) ;
492 dessin_un.dec2_dzpuis() ;
493
494 dessin_deux = aa_auto_deux(2, 2) ;
495 dessin_deux.annule(0) ;
496 dessin_deux.dec2_dzpuis() ;
497
498 des_coupe_bin_z (dessin_un, dessin_deux, 0,
499 -ta, ta, -ta, ta, "A\\uYY\\d (Z=0)", &surface_un, &surface_deux, false
500 , 20, 300, 300) ;
501
502
503 dessin_un = aa_auto_un(3, 3) ;
504 dessin_un.annule(0) ;
505 dessin_un.dec2_dzpuis() ;
506
507 dessin_deux = aa_auto_deux(3, 3) ;
508 dessin_deux.annule(0) ;
509 dessin_deux.dec2_dzpuis() ;
510
511 des_coupe_bin_z (dessin_un, dessin_deux, 0,
512 -ta, ta, -ta, ta, "A\\uZZ\\d (Z=0)", &surface_un, &surface_deux, false
513 , 20, 300, 300) ;
514
515 return 1;
516 }