Debian Codegraph @

Codes/Bin_star_ncp/lit_bin_ncp.C

raw
1 /*
2 * Reads a file containing a binary configuration (class Bin_ns_ncp) and
3 * performs various plots.
4 *
5 */
6
7 /*
8 * Copyright (c) 2003 Francois Limousin
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 as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
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
28 char lit_bin_ncp_C[] = "$Header: /cvsroot/Lorene/Codes/Bin_star_ncp/lit_bin_ncp.C,v 1.3 2014/10/13 08:53:54 j_novak Exp $" ;
29
30 /*
31 * $Header: /cvsroot/Lorene/Codes/Bin_star_ncp/lit_bin_ncp.C,v 1.3 2014/10/13 08:53:54 j_novak Exp $
32 *
33 */
34 // headers C
35 #include <cstdlib>
36 #include <cmath>
37 #include <cstring>
38
39 // headers Lorene
40 #include "bin_ns_ncp.h"
41 #include "eos.h"
42 #include "utilitaires.h"
43 #include "graphique.h"
44
45 // Local prototype
46 Cmp raccord_c1(const Cmp& uu, int l1) ;
47
48 //******************************************************************************
49
50 using namespace Lorene ;
51
52 int main(int argc, char** argv){
53
54 // Identification of all the subroutines called by the code :
55
56 // system("ident lit_bin") ;
57
58 if (argc < 2) {
59 cout <<
60 "lit_bin_ncp : the name of a file containing a binary configuration"
61 << endl << " must be given in argument !" << endl ;
62 abort() ;
63 }
64
65 char* nomresu = argv[1] ;
66 cout << "Name of the file to be read : " << nomresu << endl ;
67
68 cout << endl <<
69 "Do you want to draw the boundaries of the various domains (y/n) ? [y]"
70 << endl ;
71 char rep ;
72 cin.get(rep) ;
73 bool draw_bound = !(rep == 'n') ;
74
75 #include "unites.h"
76 // To avoid some compilation warnings
77 if (nomresu == 0x0) {
78 cout << qpig << f_unit << mevpfm3 << endl ;
79 }
80
81
82 FILE* fich = fopen(nomresu, "r") ;
83
84 int mer ;
85 fread(&mer, sizeof(int), 1, fich) ; // mer
86
87 Mg3d mg1(fich) ;
88 Map_et mp1(mg1, fich) ;
89 Eos* peos1 = Eos::eos_from_file(fich) ;
90
91 Mg3d mg2(fich) ;
92 Map_et mp2(mg2, fich) ;
93 Eos* peos2 = Eos::eos_from_file(fich) ;
94
95 Tenseur_sym plat1(mp1, 2, COV, mp1.get_bvect_cart() ) ;
96 plat1.set_etat_qcq() ;
97 for (int i=0; i<3; i++) {
98 for (int j=0; j<i; j++) {
99 plat1.set(i,j) = 0 ;
100 }
101 plat1.set(i,i) = 1 ;
102 }
103 plat1.set_std_base() ;
104
105 Metrique flat1(plat1, true) ;
106
107 Tenseur_sym plat2(mp2, 2, COV, mp2.get_bvect_cart() ) ;
108 plat2.set_etat_qcq() ;
109 for (int i=0; i<3; i++) {
110 for (int j=0; j<i; j++) {
111 plat2.set(i,j) = 0 ;
112 }
113 plat2.set(i,i) = 1 ;
114 }
115 plat2.set_std_base() ;
116
117 Metrique flat2(plat2, true) ;
118
119 Bin_ns_ncp star(mp1, *peos1, mp2, *peos2, flat1, flat2, fich) ;
120
121 fclose(fich) ;
122
123 bool relativistic = star(1).is_relativistic() ;
124 bool irrotational = star(1).is_irrotational() ;
125
126 cout << endl << "Grid on which star 1 is defined : " << endl ;
127 cout << "=============================== " << endl ;
128 cout << *((star(1).get_mp()).get_mg()) << endl ;
129
130 cout << endl << "Grid on which star 2 is defined : " << endl ;
131 cout << "=============================== " << endl ;
132 cout << *((star(2).get_mp()).get_mg()) << endl ;
133
134 cout << endl << "Mapping on which star 1 is defined : " << endl ;
135 cout << "================================== " << endl ;
136 cout << star(1).get_mp() << endl ;
137
138 des_map_et(mp1, 0) ;
139 des_map_et(mp1, 1) ;
140
141 cout << endl << "Mapping on which star 2 is defined : " << endl ;
142 cout << "================================== " << endl ;
143 cout << star(2).get_mp() << endl ;
144
145 for (int i=1; i<=2; i++) {
146 (star.set(i)).update_metric(star(3-i)) ;
147 }
148
149 for (int i=1; i<=2; i++) {
150 (star.set(i)).update_metric_der_comp(star(3-i)) ;
151 }
152
153 for (int i=1; i<=2; i++) {
154 (star.set(i)).equation_of_state() ;
155 (star.set(i)).kinematics(star.get_omega(), star.get_x_axe()) ;
156 (star.set(i)).fait_d_psi() ;
157 (star.set(i)).hydro_euler() ;
158 }
159
160 cout << "Binary system read in file : " << endl ;
161 cout << star << endl ;
162
163 /*
164 cout << "ADM mass [M_sol] : " << star.mass_adm() / msol << endl ;
165 cout << "Total energy [M_sol c^2] : "
166 << star.total_ener() / msol << endl ;
167 cout << "Total angular momentum [M_sol c km] : "
168 << (star.angu_mom())(2) / msol / km << endl ;
169 if (!relativistic) {
170 cout << "Relative error on the virial theorem : "
171 << star.virial() << endl ;
172 }
173
174 cout << "Relative error in the Hamiltonian constraint : " << endl ;
175 cout << star.ham_constr() << endl ;
176
177 cout << "Relative error in the momentum constraint : " << endl ;
178 cout << " X component : " << star.mom_constr()(0) << endl ;
179 cout << " Y component : " << star.mom_constr()(1) << endl ;
180 cout << " Z component : " << star.mom_constr()(2) << endl ;
181 */
182
183 //==============================================================
184 // Reduced quantities for polytropic EOS
185 //==============================================================
186
187 star.display_poly(cout) ;
188
189 //==============================================================
190 // Drawings
191 //==============================================================
192
193 des_explorer_symz(star, "latbin") ;
194
195 int nzdes1 = star(1).get_nzet() ;
196
197 double ori_x1 = star(1).get_mp().get_ori_x() ;
198 double ori_x2 = star(2).get_mp().get_ori_x() ;
199
200 double xdes_min = - 1.5 * star(1).ray_eq_pi() + ori_x1 ;
201 xdes_min += 0.2 * xdes_min ;
202 double xdes_max = 1.5 * star(2).ray_eq_pi() + ori_x2 ;
203 xdes_max += 0.2 * fabs(xdes_min) ;
204
205 double ydes_min1 = - 4. * star(1).ray_eq_pis2() ;
206 double ydes_min2 = - 4. * star(2).ray_eq_pis2() ;
207 double ydes_min = (ydes_min1 < ydes_min2) ? ydes_min1 : ydes_min2 ;
208
209 double ydes_max1 = 4. * star(1).ray_eq_pis2() ;
210 double ydes_max2 = 4. * star(2).ray_eq_pis2() ;
211 double ydes_max = (ydes_max1 > ydes_max2) ? ydes_max1 : ydes_max2 ;
212
213 double zdes_min1 = - 4. * star(1).ray_pole() ;
214 double zdes_min2 = - 4. * star(2).ray_pole() ;
215 double zdes_min = (zdes_min1 < zdes_min2) ? zdes_min1 : zdes_min2 ;
216
217 double zdes_max1 = 4. * star(1).ray_pole() ;
218 double zdes_max2 = 4. * star(2).ray_pole() ;
219 double zdes_max = (zdes_max1 > zdes_max2) ? zdes_max1 : zdes_max2 ;
220
221 Cmp surf1 = star(1).get_ent()() ;
222 Cmp surf1_ext(mp1) ;
223 surf1_ext = - 0.2 * surf1(0, 0, 0, 0) ;
224 surf1_ext.annule(0, star(1).get_nzet()-1) ;
225 surf1.annule(star(1).get_nzet(), mg1.get_nzone()-1) ;
226 surf1 = surf1 + surf1_ext ;
227 surf1 = raccord_c1(surf1, star(1).get_nzet()) ;
228
229 Cmp surf2 = star(2).get_ent()() ;
230 Cmp surf2_ext(mp2) ;
231 surf2_ext = - 0.2 * surf2(0, 0, 0, 0) ;
232 surf2_ext.annule(0, star(2).get_nzet()-1) ;
233 surf2.annule(star(2).get_nzet(), mg2.get_nzone()-1) ;
234 surf2 = surf2 + surf2_ext ;
235
236 surf2 = raccord_c1(surf2, star(2).get_nzet()) ;
237
238 char title[80] ;
239 char bslash[2] = {92, '\0'} ; // 92 is the ASCII code for backslash
240
241 ofstream fent("enthalpy.d") ;
242
243 fent << "Enthalpy field at the boundary of last inner domain of star 1 : "
244 << endl ;
245 int lzet = star(1).get_nzet() - 1 ;
246 for (int k=0; k<mg1.get_np(lzet); k++) {
247 fent << "k = " << k << " : " ;
248 for (int j=0; j<mg1.get_nt(lzet); j++) {
249 fent
250 << " " << star(1).get_ent()()(lzet, k, j, mg1.get_nr(lzet)-1) ;
251 }
252 fent << endl ;
253 }
254
255 fent << endl << "enthalpy field of star 1 : " << endl ;
256 fent << star(1).get_ent() << endl ;
257 fent.close() ;
258
259 des_coupe_z(star(1).get_ent()(), 0., 1,
260 "Enthalpy (z=0)", &surf1, 1.2, draw_bound ) ;
261
262 des_coupe_y(star(1).get_ent()(), 0., 1,
263 "Enthalpy (y=0)", &surf1, 1.2, draw_bound ) ;
264
265
266 des_profile (star(1).get_ent()(), 0., 2* star(1).ray_eq(), 0., 0.,
267 "H", "H (theta=0)" ) ;
268
269 des_profile (star(1).get_ent()(), 0., 2* star(1).ray_eq(), M_PI/2., M_PI/2.,
270 "H", "H (theta=pi/2, phi=pi/2)" ) ;
271
272
273
274 //==========================================
275 // Metric quantities
276 //==========================================
277
278 //----------------------------
279 // ln(N)
280 //----------------------------
281
282 Tenseur logn1 = - star(1).get_logn_auto() ;
283 Tenseur logn2 = - star(2).get_logn_auto() ;
284
285 des_coupe_bin_y(logn1(), logn2(), 0,
286 xdes_min, xdes_max, zdes_min, zdes_max,
287 "ln(N) (y=0)", &surf1, &surf2, draw_bound ) ;
288
289 des_coupe_bin_z(logn1(), logn2(), 0,
290 xdes_min, xdes_max, ydes_min, ydes_max,
291 "ln(N) (z=0)", &surf1, &surf2, draw_bound ) ;
292
293 des_coupe_bin_x(logn1(), logn2(),
294 ori_x1, ydes_min, ydes_max, zdes_min, zdes_max,
295 "ln(N) (x=x1)", &surf1, 0x0, draw_bound ) ;
296
297
298 if (relativistic) {
299
300 //--------------
301 // Shift vector
302 //--------------
303
304 Tenseur shift2_auto = star(2).get_shift_auto() ;
305 shift2_auto.change_triad(mp1.get_bvect_cart()) ;
306
307 des_vect_bin_z(star(1).get_shift_auto(), shift2_auto, 0.,
308 -2., 0.5, xdes_min, xdes_max, ydes_min, ydes_max,
309 "Shift vector (z=0)",
310 &surf1, &surf2, draw_bound ) ;
311
312 //----------------------------
313 // Extrinsic curvature tensor
314 //----------------------------
315
316 Tenseur tkij1 = star(1).get_tkij_auto() ;
317 Tenseur tkij2 = star(2).get_tkij_auto() ;
318
319 // Division by r^2 in the external compactified domain in order to get
320 // K^{ij} :
321 tkij1.dec2_dzpuis() ;
322 tkij2.dec2_dzpuis() ;
323
324 char debtit[] = {'K', 92, 'u', '\0'} ;
325
326 strcpy(title, debtit) ;
327 strcat(title, "xx") ;
328 strcat(title, bslash) ;
329 strcat(title, "d (z=0)") ;
330
331 des_coupe_bin_z(tkij1(0, 0), tkij2(0, 0), 0,
332 xdes_min, xdes_max, ydes_min, ydes_max,
333 title, &surf1, &surf2, draw_bound ) ;
334
335 strcpy(title, debtit) ;
336 strcat(title, "xy") ;
337 strcat(title, bslash) ;
338 strcat(title, "d (z=0)") ;
339
340 des_coupe_bin_z(tkij1(0, 1), tkij2(0, 1), 0,
341 xdes_min, xdes_max, ydes_min, ydes_max,
342 title, &surf1, &surf2, draw_bound ) ;
343
344 strcpy(title, debtit) ;
345 strcat(title, "xz") ;
346 strcat(title, bslash) ;
347 strcat(title, "d (y=0)") ;
348
349 des_coupe_bin_y(tkij1(0, 2), tkij2(0, 2), 0,
350 xdes_min, xdes_max, ydes_min, ydes_max,
351 title, &surf1, &surf2, draw_bound ) ;
352
353 strcpy(title, debtit) ;
354 strcat(title, "yy") ;
355 strcat(title, bslash) ;
356 strcat(title, "d (z=0)") ;
357
358 des_coupe_bin_z(tkij1(1, 1), tkij2(1, 1), 0,
359 xdes_min, xdes_max, ydes_min, ydes_max,
360 title, &surf1, &surf2, draw_bound ) ;
361
362 strcpy(title, debtit) ;
363 strcat(title, "yz") ;
364 strcat(title, bslash) ;
365 strcat(title, "d (y=0)") ;
366
367 des_coupe_bin_y(tkij1(1, 2), tkij2(1, 2), 0,
368 xdes_min, xdes_max, ydes_min, ydes_max,
369 title, &surf1, &surf2, draw_bound ) ;
370
371 strcpy(title, debtit) ;
372 strcat(title, "zz") ;
373 strcat(title, bslash) ;
374 strcat(title, "d (z=0)") ;
375
376 des_coupe_bin_z(tkij1(2, 2), tkij2(2, 2), 0,
377 xdes_min, xdes_max, ydes_min, ydes_max,
378 title, &surf1, &surf2, draw_bound ) ;
379
380
381 //----------------------------
382 // Term K_ij K^ij
383 //----------------------------
384
385 Tenseur kcar1 = star(1).get_kcar_auto() ;
386 Tenseur kcar2 = star(2).get_kcar_auto() ;
387
388 // Division by r^4 in the external compactified domain in order to get
389 // A^2 K_ij K^{ij} :
390 kcar1.dec2_dzpuis() ;
391 kcar1.dec2_dzpuis() ;
392 kcar2.dec2_dzpuis() ;
393 kcar2.dec2_dzpuis() ;
394
395 char title1[80] ;
396 strcpy(title1, debtit) ;
397 strcat(title1, "ij") ;
398 strcat(title1, bslash) ;
399 strcat(title1, "d K") ;
400 strcat(title1, bslash) ;
401 strcat(title1, "dij") ;
402 strcat(title1, bslash) ;
403
404 strcpy(title, title1) ;
405 strcat(title, "u (x=x1)") ;
406
407 des_coupe_bin_x(kcar1(), kcar2(), ori_x1,
408 ydes_min, ydes_max, zdes_min, zdes_max,
409 title, &surf1, 0x0, draw_bound ) ;
410
411 strcpy(title, title1) ;
412 strcat(title, "u (y=0)") ;
413
414 des_coupe_bin_y(kcar1(), kcar2(), 0,
415 xdes_min, xdes_max, zdes_min, zdes_max,
416 title, &surf1, &surf2, draw_bound ) ;
417
418 strcpy(title, title1) ;
419 strcat(title, "u (z=0)") ;
420
421 des_coupe_bin_z(kcar1(), kcar2(), 0,
422 xdes_min, xdes_max, ydes_min, ydes_max,
423 title, &surf1, &surf2, draw_bound ) ;
424
425 //----------------------------
426 // determinant gamma
427 //----------------------------
428
429 Tenseur gamma1 = - star(1).get_loggamma_auto() ;
430 Tenseur gamma2 = - star(2).get_loggamma_auto() ;
431
432 des_coupe_bin_x(gamma1(), gamma2(),
433 ori_x1, ydes_min, ydes_max, zdes_min, zdes_max,
434 "loggamma (x=x1)", &surf1, 0x0, draw_bound ) ;
435
436 des_coupe_bin_y(gamma1(), gamma2(), 0,
437 xdes_min, xdes_max, zdes_min, zdes_max,
438 "loggamma (y=0)", &surf1, &surf2, draw_bound ) ;
439
440 des_coupe_bin_z(gamma1(), gamma2(), 0,
441 xdes_min, xdes_max, ydes_min, ydes_max,
442 "loggamma (z=0)", &surf1, &surf2, draw_bound ) ;
443
444 }
445
446 //==========================================
447 // Hydro quantities
448 //==========================================
449
450
451 des_coupe_bin_z(star(1).get_nbar()(), star(2).get_nbar()(), 0,
452 xdes_min, xdes_max, ydes_min, ydes_max,
453 "Baryon density (z=0)",
454 &surf1, &surf2, draw_bound ) ;
455
456 des_coupe_bin_y(star(1).get_nbar()(), star(2).get_nbar()(), 0,
457 xdes_min, xdes_max, zdes_min, zdes_max,
458 "Baryon density (y=0)",
459 &surf1, &surf2, draw_bound ) ;
460
461 des_coupe_z(star(1).get_nbar()(), 0., 1,
462 "Baryon density (z=0)", &surf1, 1.2, draw_bound ) ;
463
464 des_coupe_y(star(1).get_nbar()(), 0., 1,
465 "Baryon density (y=0)", &surf1, 1.2, draw_bound ) ;
466
467 if (irrotational) {
468 Tenseur tmp_draw1 = star(1).get_wit_w() ;
469 tmp_draw1.annule(star(1).get_nzet(), mg1.get_nzone()-1) ;
470 Tenseur tmp_draw2 = star(2).get_wit_w() ;
471 tmp_draw2.annule(star(2).get_nzet(), mg2.get_nzone()-1) ;
472
473 des_vect_bin_z(tmp_draw1, tmp_draw2, 0.,
474 -3., 0.5, xdes_min, xdes_max, ydes_min, ydes_max,
475 "Velocity w.r.t corotating frame (z=0)",
476 &surf1, &surf2, draw_bound, 40, 40) ;
477 }
478
479 Tenseur tmp_draw1 = star(1).get_u_euler() ;
480 tmp_draw1.annule(star(1).get_nzet(), mg1.get_nzone()-1) ;
481
482 Tenseur tmp_draw2 = star(2).get_u_euler() ;
483 tmp_draw2.annule(star(2).get_nzet(), mg2.get_nzone()-1) ;
484 tmp_draw2.change_triad(mp1.get_bvect_cart()) ;
485
486 des_coupe_vect_x(tmp_draw1, mp1.get_ori_x(), -1., 0.5, nzdes1,
487 "U (x=x1)", &surf1, 1.2, draw_bound ) ;
488
489 des_vect_bin_z(tmp_draw1, tmp_draw2, 0.,
490 -2., 0.5, xdes_min, xdes_max, ydes_min, ydes_max,
491 "U (z=0)", &surf1, &surf2, draw_bound, 40, 40) ;
492
493 if (irrotational) {
494 tmp_draw1 = star(1).get_d_psi() ;
495 tmp_draw1.annule(star(1).get_nzet(), mg1.get_nzone()-1) ;
496 des_coupe_vect_z(tmp_draw1, 0, -1., 0.5, nzdes1,
497 "Grad(psi) (z=0)", &surf1, 1.2, draw_bound ) ;
498
499 des_coupe_z(star(1).get_psi0()(), 0., 1,
500 "psi0 (z=0)", &surf1, 1.2, draw_bound ) ;
501
502 Tenseur d_psi0 = star(1).get_psi0().gradient() ;
503 //## d_psi0.change_triad(star.get_ref_triad()) ;
504
505 des_coupe_vect_z(d_psi0, 0, -3., 0.5, nzdes1, "Grad(psi0) (z=0)",
506 &surf1, 1.2, draw_bound ) ;
507
508 tmp_draw1 = star(1).get_wit_w() ;
509 tmp_draw1.annule(star(1).get_nzet(), mg1.get_nzone()-1) ;
510 des_coupe_vect_z(tmp_draw1, 0, -3., 0.5, nzdes1, "W (z=0)",
511 &surf1, 1.2, draw_bound ) ;
512
513 }
514
515 // Cleaning
516 // --------
517
518 delete peos1 ;
519 delete peos2 ;
520
521 return EXIT_SUCCESS ;
522
523 }