Debian Codegraph @

Codes/Bin_star/analyse.C

raw
1 /*
2 * Code for reading a binary black hole or binary neutron star configuration
3 * and performing some analysis of the asymptotic
4 * behavior of the metric coefficients
5 *
6 */
7
8 /*
9 * Copyright (c) 2002 Francois Limousin
10 *
11 * This file is part of LORENE.
12 *
13 * LORENE is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2
15 * as published by the Free Software Foundation.
16 *
17 * LORENE is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with LORENE; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 */
27 char analyse_C[] = "$Header: /cvsroot/Lorene/Codes/Bin_star/analyse.C,v 1.5 2014/10/13 08:53:53 j_novak Exp $" ;
28
29 /*
30 * $Id: analyse.C,v 1.5 2014/10/13 08:53:53 j_novak Exp $
31 * $Log: analyse.C,v $
32 * Revision 1.5 2014/10/13 08:53:53 j_novak
33 * Lorene classes and functions now belong to the namespace Lorene.
34 *
35 * Revision 1.4 2014/10/06 15:09:42 j_novak
36 * Modified #include directives to use c++ syntax.
37 *
38 * Revision 1.3 2004/03/25 12:35:36 j_novak
39 * now using namespace Unites
40 *
41 * Revision 1.2 2003/01/09 11:07:48 j_novak
42 * headcpp.h is now compliant with C++ norm.
43 * The include files have been ordered, as well as the local_settings_linux
44 *
45 * Revision 1.1 2002/06/18 14:07:26 f_limousin
46 * Analysis of asymptotic behavior of binary NS and BH
47 *
48 *
49 *
50 * $Header: /cvsroot/Lorene/Codes/Bin_star/analyse.C,v 1.5 2014/10/13 08:53:53 j_novak Exp $
51 *
52 */
53
54 // Headers standard du C
55 // (par exemple definit la macro EXIT_SUCCESS)
56 #include <cstdlib>
57 #include <cstdio>
58
59
60 // Headers Lorene
61 #include "tenseur.h"
62 #include "bhole.h"
63 #include "binaire.h"
64 #include "eos.h"
65 #include "utilitaires.h"
66 #include "graphique.h"
67 #include "nbr_spx.h"
68 #include "unites.h"
69
70 namespace Lorene {
71 // Local prototype
72 Cmp raccord_c1(const Cmp& uu, int l1) ;
73
74 void asymptot(const Cmp&, const char*, bool, ostream& );
75 }
76 using namespace Lorene ;
77
78 int main() {
79
80 using namespace Unites ;
81
82 // Reads the parameters of the computation
83 // ---------------------------------------
84
85 char nom_config[100], blabla[100] ;
86 int type_objet, nr_a, nt_a, np_a, graphics_i ;
87 double rayon_a ;
88
89 ifstream fichparam("par_ana.d") ;
90 fichparam >> graphics_i ; fichparam.getline(blabla,100) ;
91 fichparam >> type_objet ; fichparam.getline(blabla,100) ;
92 fichparam.getline(nom_config,100) ;
93 fichparam >> nr_a ; fichparam.getline(blabla,100) ;
94 fichparam >> nt_a ; fichparam.getline(blabla,100) ;
95 fichparam >> np_a ; fichparam.getline(blabla,100) ;
96 fichparam >> rayon_a ; fichparam.getline(blabla,100) ;
97 fichparam.close() ;
98
99 bool black_hole = (type_objet == 1) ;
100 bool graphics = (graphics_i == 1) ;
101
102 cout << "Name of the file containing the binary system :"
103 << endl << nom_config << endl ;
104
105 // Pointers on global objects (independent of BH or NS)
106 Mg3d* grille_un ;
107 Mg3d* grille_deux ;
108 Map* map_un ;
109 Map* map_deux ;
110 Cmp* p_nn1 ;
111 Cmp* p_nn2 ;
112 Tenseur* p_shift1 ;
113 Tenseur* p_shift2 ;
114
115 FILE* fich = fopen(nom_config, "r") ;
116 if (fich == 0x0) {
117 cout << "Problem in opening the file " << nom_config << " !" << endl ;
118 abort() ;
119 }
120
121 //*******************************************************************
122 // Reading of binary black hole data
123 //*******************************************************************
124 if (black_hole) {
125
126 grille_un = new Mg3d(fich) ;
127 grille_deux = grille_un ;
128 Map_af* map_un_af = new Map_af(*grille_un, fich) ;
129 Map_af* map_deux_af = new Map_af(*grille_deux, fich) ;
130 map_un = map_un_af ;
131 map_deux = map_deux_af ;
132 Bhole hole_un (*map_un_af, fich) ;
133 Bhole hole_deux (*map_deux_af, fich) ;
134 fclose(fich) ;
135
136 assert (hole_un.get_omega() == hole_deux.get_omega()) ;
137
138 cout << "Multi-grid read in file : " << endl << *grille_un << endl ;
139 // arrete() ;
140 cout << "Mapping 1 read in file : " << endl << *map_un << endl ;
141 cout << "Mapping 2 read in file : " << endl << *map_deux << endl ;
142 // arrete() ;
143
144 // Construction of the binary system
145 // ---------------------------------
146 Bhole_binaire systeme (*map_un_af, *map_deux_af) ;
147 systeme.set(1) = hole_un ;
148 systeme.set(2) = hole_deux ;
149 systeme.set_omega(hole_un.get_omega()) ;
150
151 // On initialise les grandeurs derivees :
152 systeme.set(1).fait_n_comp (systeme(2)) ;
153 systeme.set(1).fait_psi_comp (systeme(2)) ;
154 systeme.set(2).fait_n_comp (systeme(1)) ;
155 systeme.set(2).fait_psi_comp (systeme(1)) ;
156 systeme.fait_decouple() ;
157 systeme.fait_tkij() ;
158
159 // Initialisation of member data
160 // -----------------------------
161
162 // Unit of length:
163 double aa = systeme(1).get_rayon() ;
164 double aa2 = systeme(2).get_rayon() ;
165
166 double omega = systeme.get_omega() * aa ;
167 double dist = ( map_un->get_ori_x() - map_deux->get_ori_x() ) / aa ;
168
169 cout << endl << "Binary system read in file : " << endl ;
170 cout << "---------------------------- " << endl ;
171 cout << " Separation d/a : " << dist << endl ;
172 cout << " Omega : " << omega << " / a" << endl ;
173 cout << " Size of black hole 2 : " << aa2 / aa << " a" << endl ;
174 cout << " ADM mass : " << systeme.adm_systeme() / aa
175 << " a" << endl ;
176 cout << " Komar-lile mass : " << systeme.komar_systeme() / aa
177 << " a" << endl ;
178 cout << " Angular momentum : " << systeme.moment_systeme_inf()
179 / (aa*aa) << " a^2" << endl ;
180 cout << " Proper distance between the two throats : "
181 << systeme.distance_propre() / aa << " a" << endl ;
182 cout << " Area of black hole 1 apparent horizon : " <<
183 systeme(1).area() / (aa*aa) << " a^2" << endl ;
184 cout << " Area of black hole 2 apparent horizon : " <<
185 systeme(2).area() / (aa*aa) << " a^2" << endl ;
186
187 //------------------------------------------------------
188 // Lapse function
189 //------------------------------------------------------
190
191 // nn1 defined as a Tenseur copy of systeme(1).n_auto
192 // (constructed by the copy constructor of class Tenseur)
193 // Tenseur nn1 = systeme(1).get_n_auto() ;
194
195
196
197 // *nn1 is a copy of the Cmp systeme(1).n_auto.c[0]
198 p_nn1 = new Cmp( systeme(1).get_n_auto()() ) ;
199
200 // cout << "N_1 : " << endl << *nn1 << endl ;
201
202 // nn2 defined as a reference to the Cmp systeme(2).n_auto.c[0]
203 p_nn2 = new Cmp( systeme(2).get_n_auto()() ) ;
204
205 // Shift vector
206 p_shift1 = new Tenseur( systeme(1).get_shift_auto() ) ;
207 p_shift2 = new Tenseur( systeme(2).get_shift_auto() ) ;
208
209
210 } // End of the black hole case
211
212 //*******************************************************************
213 // Reading of binary neutron star data
214 //*******************************************************************
215 else{
216
217 int mer ;
218 fread_be(&mer, sizeof(int), 1, fich) ; // step
219
220 grille_un = new Mg3d(fich) ;
221 map_un = new Map_et(*grille_un, fich) ;
222 Eos* peos_un = Eos::eos_from_file(fich) ;
223
224 grille_deux = new Mg3d(fich) ;
225 map_deux = new Map_et(*grille_deux, fich) ;
226 Eos* peos_deux = Eos::eos_from_file(fich) ;
227
228 Binaire star(*map_un, *peos_un, *map_deux, *peos_deux, fich) ;
229
230 fclose(fich) ;
231
232 bool relativistic = star(1).is_relativistic() ;
233
234 cout << endl << "Grid on which star 1 is defined : " << endl ;
235 cout << "=============================== " << endl ;
236 cout << *((star(1).get_mp()).get_mg()) << endl ;
237
238 cout << endl << "Grid on which star 2 is defined : " << endl ;
239 cout << "=============================== " << endl ;
240 cout << *((star(2).get_mp()).get_mg()) << endl ;
241
242 cout << endl << "Mapping on which star 1 is defined : " << endl ;
243 cout << "================================== " << endl ;
244 cout << star(1).get_mp() << endl ;
245
246
247 cout << endl << "Mapping on which star 2 is defined : " << endl ;
248 cout << "================================== " << endl ;
249 cout << star(2).get_mp() << endl ;
250
251 for (int i=1; i<=2; i++) {
252 (star.set(i)).update_metric(star(3-i)) ;
253 }
254
255 for (int i=1; i<=2; i++) {
256 (star.set(i)).update_metric_der_comp(star(3-i)) ;
257 }
258
259 for (int i=1; i<=2; i++) {
260 (star.set(i)).equation_of_state() ;
261 (star.set(i)).kinematics(star.get_omega(), star.get_x_axe()) ;
262 (star.set(i)).fait_d_psi() ;
263 (star.set(i)).hydro_euler() ;
264 }
265
266 cout << "Binary system read in file : " << endl ;
267 cout << star << endl ;
268
269 cout << "ADM mass [M_sol] : " << star.mass_adm() / msol << endl ;
270 cout << "Total energy [M_sol c^2] : "
271 << star.total_ener() / msol << endl ;
272 cout << "Total angular momentum [M_sol c km] : "
273 << (star.angu_mom())(2) / msol / km << endl ;
274 if (!relativistic) {
275 cout << "Relative error on the virial theorem : "
276 << star.virial() << endl ;
277 }
278 cout << "Relative error in the Hamiltonian constraint : " << endl ;
279 cout << star.ham_constr() << endl ;
280
281 cout << "Relative error in the momentum constraint : " << endl ;
282 cout << " X component : " << star.mom_constr()(0) << endl ;
283 cout << " Y component : " << star.mom_constr()(1) << endl ;
284 cout << " Z component : " << star.mom_constr()(2) << endl ;
285
286 star.display_poly(cout) ; // Reduced quantities for polytropic EOS
287
288 //==============================================================
289 // Drawings
290 //==============================================================
291
292 // int nzdes1 = star(1).get_nzet() ;
293
294 double ori_x1 = star(1).get_mp().get_ori_x() ;
295 double ori_x2 = star(2).get_mp().get_ori_x() ;
296
297 double xdes_min = - 1.5 * star(1).ray_eq_pi() + ori_x1 ;
298 xdes_min += 0.2 * xdes_min ;
299 double xdes_max = 1.5 * star(2).ray_eq_pi() + ori_x2 ;
300 xdes_max += 0.2 * fabs(xdes_min) ;
301
302 double ydes_min1 = - 4. * star(1).ray_eq_pis2() ;
303 double ydes_min2 = - 4. * star(2).ray_eq_pis2() ;
304 double ydes_min = (ydes_min1 < ydes_min2) ? ydes_min1 : ydes_min2 ;
305
306 double ydes_max1 = 4. * star(1).ray_eq_pis2() ;
307 double ydes_max2 = 4. * star(2).ray_eq_pis2() ;
308 double ydes_max = (ydes_max1 > ydes_max2) ? ydes_max1 : ydes_max2 ;
309
310 double zdes_min1 = - 4. * star(1).ray_pole() ;
311 double zdes_min2 = - 4. * star(2).ray_pole() ;
312 double zdes_min = (zdes_min1 < zdes_min2) ? zdes_min1 : zdes_min2 ;
313
314 double zdes_max1 = 4. * star(1).ray_pole() ;
315 double zdes_max2 = 4. * star(2).ray_pole() ;
316 double zdes_max = (zdes_max1 > zdes_max2) ? zdes_max1 : zdes_max2 ;
317
318
319 Cmp surf1 = star(1).get_ent()() ;
320 Cmp surf1_ext(*map_un) ;
321 surf1_ext = - 0.2 * surf1(0, 0, 0, 0) ;
322 surf1_ext.annule(0, star(1).get_nzet()-1) ;
323 surf1.annule(star(1).get_nzet(), grille_un->get_nzone()-1) ;
324 surf1 = surf1 + surf1_ext ;
325 surf1 = raccord_c1(surf1, star(1).get_nzet()) ;
326
327 Cmp surf2 = star(2).get_ent()() ;
328 Cmp surf2_ext(*map_deux) ;
329 surf2_ext = - 0.2 * surf2(0, 0, 0, 0) ;
330 surf2_ext.annule(0, star(2).get_nzet()-1) ;
331 surf2.annule(star(2).get_nzet(), grille_deux->get_nzone()-1) ;
332 surf2 = surf2 + surf2_ext ;
333
334 surf2 = raccord_c1(surf2, star(2).get_nzet()) ;
335
336 Tenseur logn1 = - star(1).get_logn_auto() ;
337 Tenseur logn2 = - star(2).get_logn_auto() ;
338
339 if (graphics) {
340 des_coupe_bin_y(logn1(), logn2(), 0,
341 xdes_min, xdes_max, zdes_min, zdes_max,
342 "ln(N) (y=0)", &surf1, &surf2) ;
343
344 des_coupe_bin_z(logn1(), logn2(), 0,
345 xdes_min, xdes_max, ydes_min, ydes_max,
346 "ln(N) (z=0)", &surf1, &surf2) ;
347
348
349 des_coupe_z(star(1).get_ent()(), 0., 1,
350 "Enthalpy (z=0)", &surf1, 1.2) ;
351
352 des_coupe_y(star(1).get_ent()(), 0., 1,
353 "Enthalpy (y=0)", &surf1, 1.2) ;
354 }
355
356 // *nn1 is a copy of the Cmp systeme(1).n_auto.c[0]
357 p_nn1 = new Cmp( exp( star(1). get_logn_auto()() ) ) ;
358 p_nn1->std_base_scal() ;
359
360
361
362 // cout << "N_1 : " << endl << *nn1 << endl ;
363
364 // nn2 defined as a reference to the Cmp systeme(2).n_auto.c[0]
365 p_nn2 = new Cmp( exp( star(2). get_logn_auto()() ) ) ;
366 p_nn2->std_base_scal() ;
367
368 // Shift vector
369 p_shift1 = new Tenseur( star(1).get_shift_auto() ) ;
370 p_shift2 = new Tenseur( star(2).get_shift_auto() ) ;
371
372 delete peos_un ;
373 delete peos_deux ;
374
375 } // End of neutron star case
376
377 //***************************************************************************
378 // Begin of the asymptotic study
379 //***************************************************************************
380
381
382 /*
383
384 double z0 = 0 ; // cut by the plane z=z0
385 double x_min = - 100 ;
386 double x_max = + 100 ;
387 double y_min = - 50 ;
388 double y_max = + 50 ;
389
390 des_coupe_bin_z(nn1, nn2, z0, x_min, x_max, y_min, y_max,
391 "Lapse function N") ;
392
393 // Asymptotic behavior of N_1 :
394 Valeur** nn1_asymp = nn2.asymptot(3,1) ;
395
396 // Value (on the angular grid) containing the coef of 1/r^0
397 Valeur& nn1_0 = *(nn1_asymp[0]) ;
398
399 // Value (on the angular grid) containing the coef of 1/r
400 Valeur& nn1_1 = *(nn1_asymp[1]) ;
401
402 // Value (on the angular grid) containing the coef of 1/r^2
403 Valeur& nn1_2 = *(nn1_asymp[2]) ;
404
405 // Value (on the angular grid) containing the coef of 1/r^3
406 Valeur& nn1_3 = *(nn1_asymp[3]) ;
407
408
409 // Computation of spectral expansions
410 nn1_0.coef() ;
411 cout << "Spectral coefficients of nn1_0 : " << endl ;
412 nn1_0.affiche_seuil(cout,0,4,1e-3) ;
413
414 nn1_1.coef() ;
415 cout << "Spectral coefficients of nn1_1 : " << endl ;
416 nn1_1.affiche_seuil(cout,0,4,1e-3) ;
417
418 nn1_2.coef() ;
419 cout << "Spectral coefficients of nn1_2 : " << endl ;
420 nn1_2.affiche_seuil(cout,0,4,1e-3) ;
421
422 nn1_3.coef() ;
423 cout << "Spectral coefficients of nn1_3 : " << endl ;
424 nn1_3.affiche_seuil(cout,0,4,1e-5) ;
425
426
427 */
428
429 //----------------------------------------------
430 // Grid centered on the system "center of mass"
431 //----------------------------------------------
432
433 int nz_a = 2 ; // number of domains
434 Mg3d mg(nz_a, nr_a, nt_a, np_a, grille_un->get_type_t(),
435 grille_un->get_type_p(), true) ;
436
437 double bornes_a[3] ;
438 bornes_a[0] = 0 ;
439 bornes_a[1] = rayon_a ;
440 // bornes_a[2] = 2*rayon_a ;
441 // bornes_a[3] = 4*rayon_a ;
442 // bornes_a[4] = 8*rayon_a ;
443 bornes_a[2] = __infinity ;
444 Map_af mp(mg, bornes_a) ;
445 cout << "Mapping on the \"centered\" grid : " << endl
446 << mp << endl ;
447
448 // Evaluation of the lapse on the mapping mp
449 Cmp nn1(mp) ;
450 Cmp nn2(mp) ;
451
452 nn1.import( *(p_nn1) ) ;
453 nn2.import( *(p_nn2) ) ;
454
455 nn1.std_base_scal() ;
456 nn2.std_base_scal() ;
457
458 Cmp nn(mp) ;
459 if (black_hole) { // N = N_1 + N_2 for black holes
460 nn = nn1 + nn2 ;
461 }
462 else{ // ln(N) = ln(N_1) + ln(N_2) for neutron stars
463 nn = nn1*nn2 ;
464 }
465
466 // The lapse is set to 1 in the inner domain
467 nn.annule(0) ;
468 Cmp tmp(mp) ;
469 tmp = 1 ;
470 tmp.annule(1) ;
471 nn = nn + tmp ;
472
473 // Logarithm of the lapse
474 Cmp logn = log( nn ) ;
475 logn.std_base_scal() ;
476
477
478 // Evaluation of the shift vector on the mapping mp
479
480 // Ensures that the components of shift1 and shift2 are
481 // defined with respect to the same triad (this was
482 // true for binary NS but not for BH)
483 p_shift1->change_triad( mp.get_bvect_cart() ) ;
484 p_shift2->change_triad( mp.get_bvect_cart() ) ;
485
486 Tenseur shift1(mp, 1, CON, mp.get_bvect_cart()) ;
487 Tenseur shift2(mp, 1, CON, mp.get_bvect_cart()) ;
488
489 shift1.set_etat_qcq() ;
490 shift2.set_etat_qcq() ;
491 for (int i=0; i<3; i++) {
492 (shift1.set(i)).import( (*p_shift1)(i) ) ;
493 (shift2.set(i)).import( (*p_shift2)(i) ) ;
494 }
495
496 // Spectral bases for the x-component and y-component
497 for (int i=0; i<2; i++) {
498 shift1.set(i).va.set_base_r(0,R_CHEBPIM_P) ;
499 shift1.set(i).va.set_base_r(1,R_CHEBU) ;
500 shift1.set(i).va.set_base_t(T_COSSIN_CP) ;
501 shift1.set(i).va.set_base_p(P_COSSIN) ;
502
503 shift2.set(i).va.set_base_r(0,R_CHEBPIM_P) ;
504 shift2.set(i).va.set_base_r(1,R_CHEBU) ;
505 shift2.set(i).va.set_base_t(T_COSSIN_CP) ;
506 shift2.set(i).va.set_base_p(P_COSSIN) ;
507 }
508 // Spectral bases for the z-component
509 shift1.set(2).va.set_base_r(0,R_CHEBPIM_I) ;
510 shift1.set(2).va.set_base_r(1,R_CHEBU) ;
511 shift1.set(2).va.set_base_t(T_COSSIN_CI) ;
512 shift1.set(2).va.set_base_p(P_COSSIN) ;
513
514 shift2.set(2).va.set_base_r(0,R_CHEBPIM_I) ;
515 shift2.set(2).va.set_base_r(1,R_CHEBU) ;
516 shift2.set(2).va.set_base_t(T_COSSIN_CI) ;
517 shift2.set(2).va.set_base_p(P_COSSIN) ;
518
519
520 Tenseur shift = shift1 + shift2 ;
521
522 //--------------------------------------------
523 // Graphical outputs
524 //-------------------------------------------
525
526 if (graphics) {
527 des_coupe_z(nn1, 0., 1, "nn1") ;
528
529 des_coupe_vect_z(shift, 0., -3., 1., 1,"shift vector") ;
530
531 }
532
533 Cmp shift_x = shift.set(0) ;
534 Cmp shift_y = shift.set(1) ;
535 Cmp shift_z = shift.set(2) ;
536
537 if (graphics) {
538 des_coupe_z(shift_y, 0., 1, "shift_y") ;
539 des_coupe_z(shift_x, 0., 1, "shift_x") ;
540 des_coupe_z(shift_z, 0., 1, "shift_z") ;
541 }
542
543 cout << "msol" << 4.62/msol << endl ;
544
545 ofstream fichresu("resu_asymptot.d") ;
546 fichresu << "nom de fichier :" << nom_config << endl
547 << "nr_a : number of points in r for the centered grid = "
548 << nr_a << endl
549 <<"nt_a : number of points in theta for the center grid = "
550 << nt_a << endl
551 << "np_a : number of points in phi for the centered grid = "
552 << np_a << endl
553 <<"rayon_a (10 km) : inner radius of the last domain = "
554 << rayon_a << endl <<endl << endl ;
555
556
557 asymptot(nn, "N", graphics, fichresu) ;
558 asymptot(logn, "logn", graphics, fichresu) ;
559 asymptot(shift_x, "shift_x", graphics, fichresu) ;
560 asymptot(shift_y, "shift_y", graphics, fichresu) ;
561 asymptot(shift_z, "shift_z", graphics, fichresu) ;
562
563 fichresu.close() ;
564
565
566
567 // Freeing memory
568
569 // delete [] nn1_asymp ;
570 // delete [] nn_asymp ;
571
572 delete p_shift1 ;
573 delete p_shift2 ;
574 delete p_nn1 ;
575 delete p_nn2 ;
576 delete map_un ;
577 delete map_deux ;
578 delete grille_un ;
579 if (!black_hole) delete grille_deux ;
580
581
582 //home/francois/EUNetwork/Meudon/Data/BinNS/GR/irrotation/G18vs18_g2_ir_M.d
583 return EXIT_SUCCESS ;
584
585 }
586
587
588