Debian Codegraph @

Export/C++/Source/bin_ns_aux.C

raw
1 /*
2 * Constructor of class Bin_NS (binary neutron star exportation)
3 * which depends explicitely on Lorene objects.
4 *
5 * (see file bin_ns.h for documentation).
6 */
7
8 /*
9 * Copyright (c) 2002 Eric Gourgoulhon
10 * Copyright (c) 2002 Keisuke Taniguchi
11 *
12 * This file is part of LORENE.
13 *
14 * LORENE is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License version 2
16 * as published by the Free Software Foundation.
17 *
18 * LORENE is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with LORENE; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 *
27 */
28
29 char bin_ns_aux_C[] = "$Header: /cvsroot/Lorene/Export/C++/Source/bin_ns_aux.C,v 1.8 2014/10/13 08:54:05 j_novak Exp $" ;
30
31 /*
32 * $Id: bin_ns_aux.C,v 1.8 2014/10/13 08:54:05 j_novak Exp $
33 * $Log: bin_ns_aux.C,v $
34 * Revision 1.8 2014/10/13 08:54:05 j_novak
35 * Lorene classes and functions now belong to the namespace Lorene.
36 *
37 * Revision 1.7 2014/10/06 15:13:25 j_novak
38 * Modified #include directives to use c++ syntax.
39 *
40 * Revision 1.6 2014/02/24 16:08:11 e_gourgoulhon
41 * Eulerian velocities set to zero outside the stars
42 *
43 * Revision 1.5 2006/09/12 08:04:07 j_novak
44 * Removal of the include path Export/C++/Include, updating of the relevant
45 * source files in Export/C++/Source.
46 *
47 * Revision 1.4 2004/04/29 20:29:18 e_gourgoulhon
48 * Corrected a bug in the computation of ener_spec.
49 *
50 * Revision 1.3 2004/03/25 10:29:27 j_novak
51 * All LORENE's units are now defined in the namespace Unites (in file unites.h).
52 *
53 * Revision 1.2 2002/01/15 09:11:04 e_gourgoulhon
54 * Display of Lorene object (class binaire) read in file
55 *
56 * Revision 1.1 2002/01/11 17:03:02 e_gourgoulhon
57 * Exportation of binary neutron stars configuration to a Cartesian grid
58 *
59 *
60 * $Header: /cvsroot/Lorene/Export/C++/Source/bin_ns_aux.C,v 1.8 2014/10/13 08:54:05 j_novak Exp $
61 *
62 */
63
64 #include "../Include/bin_ns.h"
65
66 // C headers
67 #include <cstring>
68 #include <cmath>
69
70 // Lorene headers
71 #include "tenseur.h"
72 #include "binaire.h"
73 #include "eos.h"
74 #include "unites.h"
75
76 //----------------------------------------//
77 // Constructor from LORENE data //
78 //----------------------------------------//
79
80 namespace Lorene {
81 Bin_NS::Bin_NS(int nbpoints, const double* xi, const double* yi,
82 const double* zi, const char* filename)
83 : np(nbpoints) {
84
85 using namespace Unites ;
86
87 // Reading of data
88 // ---------------
89 FILE* fich = fopen(filename, "r") ;
90
91 int mer ;
92 fread(&mer, sizeof(int), 1, fich) ; // mer
93
94 Mg3d mg1(fich) ;
95 Map_et mp1(mg1, fich) ;
96 Eos* peos1 = Eos::eos_from_file(fich) ;
97
98 Mg3d mg2(fich) ;
99 Map_et mp2(mg2, fich) ;
100 Eos* peos2 = Eos::eos_from_file(fich) ;
101
102 Binaire star(mp1, *peos1, mp2, *peos2, fich) ;
103
104 fclose(fich) ;
105
106 if ( (star(1).is_relativistic() == false) ||
107 (star(2).is_relativistic() == false) ) {
108 cout << "Bin_NS::Bin_NS can import only relativistic stars !" << endl ;
109 abort() ;
110 }
111
112 // Construction of the binary system
113 // ---------------------------------
114 for (int i=1; i<=2; i++) {
115 (star.set(i)).update_metric(star(3-i)) ;
116 }
117
118 for (int i=1; i<=2; i++) {
119 (star.set(i)).update_metric_der_comp(star(3-i)) ;
120 }
121
122 for (int i=1; i<=2; i++) {
123 (star.set(i)).equation_of_state() ;
124 (star.set(i)).kinematics(star.get_omega(), star.get_x_axe()) ;
125 (star.set(i)).fait_d_psi() ;
126 (star.set(i)).hydro_euler() ;
127 }
128
129 // Initialisation of member data
130 // -----------------------------
131
132 const Eos_poly* p_eos_poly1 = dynamic_cast<const Eos_poly*>( peos1 ) ;
133 const Eos_poly* p_eos_poly2 = dynamic_cast<const Eos_poly*>( peos2 ) ;
134
135 if ( p_eos_poly1 != 0x0 ) {
136 strcpy(eos_name1, "Polytropic EOS") ;
137 gamma_poly1 = p_eos_poly1->get_gam() ;
138 kappa_poly1 = p_eos_poly1->get_kap() ;
139 }
140 else {
141 strncpy(eos_name1, (star(1).get_eos()).get_name(), 100) ;
142 gamma_poly1 = 0 ;
143 kappa_poly1 = 0 ;
144 }
145
146 if ( p_eos_poly2 != 0x0 ) {
147 strcpy(eos_name2, "Polytropic EOS") ;
148 gamma_poly2 = p_eos_poly2->get_gam() ;
149 kappa_poly2 = p_eos_poly2->get_kap() ;
150 }
151 else {
152 strncpy(eos_name2, (star(2).get_eos()).get_name(), 100) ;
153 gamma_poly2 = 0 ;
154 kappa_poly2 = 0 ;
155 }
156
157 omega = star.get_omega() * f_unit ;
158 dist = star.separation() / km ;
159 dist_mass = ( star(2).xa_barycenter()
160 - star(1).xa_barycenter() ) / km ;
161 mass1_b = star(1).mass_b() / msol ;
162 mass2_b = star(2).mass_b() / msol ;
163 mass_adm = star.mass_adm() / msol ;
164 angu_mom = star.angu_mom()(2) / ( ggrav * msol*msol) ;
165 rad1_x_comp = star(1).ray_eq() / km ;
166 rad1_y = star(1).ray_eq_pis2() / km ;
167 rad1_z = star(1).ray_pole() / km ;
168 rad1_x_opp = star(1).ray_eq_pi() / km ;
169 rad2_x_comp = star(2).ray_eq() / km ;
170 rad2_y = star(2).ray_eq_pis2() / km ;
171 rad2_z = star(2).ray_pole() / km ;
172 rad2_x_opp = star(2).ray_eq_pi() / km ;
173
174 cout.precision(13) ;
175 cout << endl << "Binary system read in file : " << endl ;
176 cout << "---------------------------- " << endl ;
177 cout << star << endl ;
178 cout << endl << "Summary : " << endl ;
179 cout << "-------" << endl ;
180 cout << " Separation d : " << dist << " km" << endl ;
181 cout << " Separation d_G : " << dist_mass << " km" << endl ;
182 cout << " Omega : " << omega << " rad/s" << endl ;
183 cout << " Baryon mass of star 1 : " << mass1_b
184 << " M_sol" << endl ;
185 cout << " Baryon mass of star 2 : " << mass2_b
186 << " M_sol" << endl ;
187 cout << " ADM mass of the system : " << mass_adm
188 << " M_sol" << endl ;
189 cout << " Total angular momentum : " << angu_mom
190 << " G M_sol^2 / c" << endl ;
191 cout << " Radius of star 1 (x_comp) : " << rad1_x_comp
192 << " km" << endl ;
193 cout << " Radius of star 1 (y) : " << rad1_y
194 << " km" << endl ;
195 cout << " Radius of star 1 (z) : " << rad1_z
196 << " km" << endl ;
197 cout << " Radius of star 1 (x_opp) : " << rad1_x_opp
198 << " km" << endl ;
199 cout << " Radius of star 2 (x_comp) : " << rad2_x_comp
200 << " km" << endl ;
201 cout << " Radius of star 2 (y) : " << rad2_y
202 << " km" << endl ;
203 cout << " Radius of star 2 (z) : " << rad2_z
204 << " km" << endl ;
205 cout << " Radius of star 2 (x_opp) : " << rad2_x_opp
206 << " km" << endl ;
207
208 // Creation of the various arrays on the Cartesian grid
209 // ----------------------------------------------------
210
211 alloc_memory() ;
212
213 // Initialisation of the Cartesian grid
214 // ------------------------------------
215
216 for (int i=0; i<np; i++) {
217 xx[i] = xi[i] ;
218 }
219 for (int i=0; i<np; i++) {
220 yy[i] = yi[i] ;
221 }
222 for (int i=0; i<np; i++) {
223 zz[i] = zi[i] ;
224 }
225
226 // Computation of the values at the points of the Cartesian grid
227 // -------------------------------------------------------------
228
229 // Parameter 1/c^2
230 double unsurc2 = star(1).is_relativistic() ? double(1) : double(0) ;
231
232 Tenseur lapse1 = exp( unsurc2 * star(1).get_logn_auto() ) ;
233 lapse1.set_std_base() ;
234 Tenseur lapse2 = exp( unsurc2 * star(2).get_logn_auto() ) ;
235 lapse2.set_std_base() ;
236
237 Valeur vnn1 = lapse1().va ;
238 Valeur vnn2 = lapse2().va ;
239 vnn1.coef() ;
240 vnn2.coef() ;
241
242 const Valeur& vshiftx1 = (star(1).get_shift_auto()(0)).va ;
243 const Valeur& vshiftx2 = (star(2).get_shift_auto()(0)).va ;
244 const Valeur& vshifty1 = (star(1).get_shift_auto()(1)).va ;
245 const Valeur& vshifty2 = (star(2).get_shift_auto()(1)).va ;
246 const Valeur& vshiftz1 = (star(1).get_shift_auto()(2)).va ;
247 const Valeur& vshiftz2 = (star(2).get_shift_auto()(2)).va ;
248 vshiftx1.coef() ;
249 vshiftx2.coef() ;
250 vshifty1.coef() ;
251 vshifty2.coef() ;
252 vshiftz1.coef() ;
253 vshiftz2.coef() ;
254
255 Tenseur a_car1 = exp( 2.*unsurc2*( star(1).get_beta_auto()
256 - star(1).get_logn_auto() ) ) ;
257 a_car1.set_std_base() ;
258 Tenseur a_car2 = exp( 2.*unsurc2*( star(2).get_beta_auto()
259 - star(2).get_logn_auto() ) ) ;
260 a_car2.set_std_base() ;
261
262 Valeur vacar1 = a_car1().va ;
263 Valeur vacar2 = a_car2().va ;
264 vacar1.coef() ;
265 vacar2.coef() ;
266
267 Tenseur_sym k_one(star(1).get_tkij_auto()) ;
268 k_one.set_std_base() ;
269 k_one.dec2_dzpuis() ;
270 Tenseur_sym k_two(star(2).get_tkij_auto()) ;
271 k_two.set_std_base() ;
272 k_two.dec2_dzpuis() ;
273
274 Valeur vkxx1 = (k_one(0, 0)).va ;
275 Valeur vkxx2 = (k_two(0, 0)).va ;
276 Valeur vkxy1 = (k_one(0, 1)).va ;
277 Valeur vkxy2 = (k_two(0, 1)).va ;
278 Valeur vkxz1 = (k_one(0, 2)).va ;
279 Valeur vkxz2 = (k_two(0, 2)).va ;
280 Valeur vkyy1 = (k_one(1, 1)).va ;
281 Valeur vkyy2 = (k_two(1, 1)).va ;
282 Valeur vkyz1 = (k_one(1, 2)).va ;
283 Valeur vkyz2 = (k_two(1, 2)).va ;
284 Valeur vkzz1 = (k_one(2, 2)).va ;
285 Valeur vkzz2 = (k_two(2, 2)).va ;
286
287 vkxx1.set_base( (star(1).get_tkij_auto()(0, 0)).va.base ) ;
288 vkxx2.set_base( (star(2).get_tkij_auto()(0, 0)).va.base ) ;
289 vkxy1.set_base( (star(1).get_tkij_auto()(0, 1)).va.base ) ;
290 vkxy2.set_base( (star(2).get_tkij_auto()(0, 1)).va.base ) ;
291 vkxz1.set_base( (star(1).get_tkij_auto()(0, 2)).va.base ) ;
292 vkxz2.set_base( (star(2).get_tkij_auto()(0, 2)).va.base ) ;
293 vkyy1.set_base( (star(1).get_tkij_auto()(1, 1)).va.base ) ;
294 vkyy2.set_base( (star(2).get_tkij_auto()(1, 1)).va.base ) ;
295 vkyz1.set_base( (star(1).get_tkij_auto()(1, 2)).va.base ) ;
296 vkyz2.set_base( (star(2).get_tkij_auto()(1, 2)).va.base ) ;
297 vkzz1.set_base( (star(1).get_tkij_auto()(2, 2)).va.base ) ;
298 vkzz2.set_base( (star(2).get_tkij_auto()(2, 2)).va.base ) ;
299 vkxx1.coef() ;
300 vkxx2.coef() ;
301 vkxy1.coef() ;
302 vkxy2.coef() ;
303 vkxz1.coef() ;
304 vkxz2.coef() ;
305 vkyy1.coef() ;
306 vkyy2.coef() ;
307 vkyz1.coef() ;
308 vkyz2.coef() ;
309 vkzz1.coef() ;
310 vkzz2.coef() ;
311
312 const Valeur& vnbar1 = (star(1).get_nbar()()).va ;
313 const Valeur& vnbar2 = (star(2).get_nbar()()).va ;
314 vnbar1.coef() ;
315 vnbar2.coef() ;
316
317 const Valeur& vener1 = (star(1).get_ener()()).va ;
318 const Valeur& vener2 = (star(2).get_ener()()).va ;
319 vener1.coef() ;
320 vener2.coef() ;
321
322 Valeur vueulerx1 = (star(1).get_u_euler()(0)).va ;
323 Valeur vueulerx2 = (star(2).get_u_euler()(0)).va ;
324 Valeur vueulery1 = (star(1).get_u_euler()(1)).va ;
325 Valeur vueulery2 = (star(2).get_u_euler()(1)).va ;
326 Valeur vueulerz1 = (star(1).get_u_euler()(2)).va ;
327 Valeur vueulerz2 = (star(2).get_u_euler()(2)).va ;
328
329 // Velocities set to zero outside the stars:
330 int nzet1 = star(1).get_nzet() ;
331 int nz1m1 = mg1.get_nzone() - 1 ;
332 int nzet2 = star(2).get_nzet() ;
333 int nz2m1 = mg2.get_nzone() - 1 ;
334 vueulerx1.annule(nzet1, nz1m1) ;
335 vueulery1.annule(nzet1, nz1m1) ;
336 vueulerz1.annule(nzet1, nz1m1) ;
337 vueulerx2.annule(nzet2, nz2m1) ;
338 vueulery2.annule(nzet2, nz2m1) ;
339 vueulerz2.annule(nzet2, nz2m1) ;
340
341 vueulerx1.coef() ;
342 vueulerx2.coef() ;
343 vueulery1.coef() ;
344 vueulery2.coef() ;
345 vueulerz1.coef() ;
346 vueulerz2.coef() ;
347
348 for (int i=0; i<np; i++) {
349
350 double x0 = xx[i] * km ; // x in Lorene's unit
351 double y0 = yy[i] * km ;
352 double z0 = zz[i] * km ;
353
354 // Values of (l1, xi1, theta1, phi1) (grid 1)
355 // corresponding to (x,y,z):
356 // ------------------------------------------
357 double r1, theta1, phi1 ; // polar coordinates centered on NS 1
358 mp1.convert_absolute(x0, y0, z0, r1, theta1, phi1) ;
359
360 int l1 ; // domain index
361 double xi1 ; // radial coordinate xi in [0,1] or [-1,1]
362 mp1.val_lx(r1, theta1, phi1, l1, xi1) ;
363
364 // Values of (l2, xi2, theta2, phi2) (grid 2)
365 // corresponding to (x,y,z):
366 // ------------------------------------------
367 double r2, theta2, phi2 ; // polar coordinates centered on b.h. 2
368 mp2.convert_absolute(x0, y0, z0, r2, theta2, phi2) ;
369
370 int l2 ; // domain index
371 double xi2 ; // radial coordinate xi in [0,1] or [-1,1]
372 mp2.val_lx(r2, theta2, phi2, l2, xi2) ;
373
374 // Lapse function
375 // --------------
376
377 nnn[i] = vnn1.c_cf->val_point_symy(l1, xi1, theta1, phi1)
378 * vnn2.c_cf->val_point_symy(l2, xi2, theta2, phi2) ;
379
380 // Shift vector
381 // ------------
382
383 beta_x[i] = vshiftx1.c_cf->val_point_asymy(l1, xi1, theta1, phi1)
384 + vshiftx2.c_cf->val_point_asymy(l2, xi2, theta2, phi2) ;
385
386 beta_y[i] = vshifty1.c_cf->val_point_symy(l1, xi1, theta1, phi1)
387 + vshifty2.c_cf->val_point_symy(l2, xi2, theta2, phi2) ;
388 // + omega * xx[i] ;
389
390 beta_z[i] = vshiftz1.c_cf->val_point_asymy(l1, xi1, theta1, phi1)
391 + vshiftz2.c_cf->val_point_asymy(l2, xi2, theta2, phi2) ;
392
393 // Conformal factor
394 // ----------------
395
396 double psi4 = vacar1.c_cf->val_point_symy(l1, xi1, theta1, phi1)
397 * vacar2.c_cf->val_point_symy(l2, xi2, theta2, phi2) ;
398
399 g_xx[i] = psi4 ;
400 g_yy[i] = psi4 ;
401 g_zz[i] = psi4 ;
402 g_xy[i] = 0 ;
403 g_xz[i] = 0 ;
404 g_yz[i] = 0 ;
405
406 // Extrinsic curvature
407 // -------------------
408
409 double pre = km * psi4 ;
410
411 k_xx[i] = pre*( vkxx1.c_cf->val_point_asymy(l1, xi1, theta1, phi1)
412 +vkxx2.c_cf->val_point_asymy(l2, xi2, theta2, phi2) ) ;
413
414 k_xy[i] = pre*( vkxy1.c_cf->val_point_symy(l1, xi1, theta1, phi1)
415 +vkxy2.c_cf->val_point_symy(l2, xi2, theta2, phi2) ) ;
416
417 k_xz[i] = pre*( vkxz1.c_cf->val_point_asymy(l1, xi1, theta1, phi1)
418 +vkxz2.c_cf->val_point_asymy(l2, xi2, theta2, phi2) ) ;
419
420 k_yy[i] = pre*( vkyy1.c_cf->val_point_asymy(l1, xi1, theta1, phi1)
421 +vkyy2.c_cf->val_point_asymy(l2, xi2, theta2, phi2) ) ;
422
423 k_yz[i] = pre*( vkyz1.c_cf->val_point_symy(l1, xi1, theta1, phi1)
424 +vkyz2.c_cf->val_point_symy(l2, xi2, theta2, phi2) ) ;
425
426 k_zz[i] = pre*( vkzz1.c_cf->val_point_asymy(l1, xi1, theta1, phi1)
427 +vkzz2.c_cf->val_point_asymy(l2, xi2, theta2, phi2) ) ;
428
429 // Baryon density [kg/m^3]
430 // --------------
431
432 nbar[i] = rho_unit*(
433 vnbar1.c_cf->val_point_symy(l1, xi1, theta1, phi1)
434 + vnbar2.c_cf->val_point_symy(l2, xi2, theta2, phi2)
435 ) ;
436
437 // Energy density
438 // --------------
439
440 double ener = vener1.c_cf->val_point_symy(l1, xi1, theta1, phi1)
441 + vener2.c_cf->val_point_symy(l2, xi2, theta2, phi2) ;
442
443 if ( nbar[i] == double(0) ) {
444 ener_spec[i] = 0 ;
445 }
446 else {
447 ener_spec[i] = ener / (nbar[i]/rho_unit) - double(1) ;
448 }
449
450
451 // 3-velocity with respect to the Eulerian observer
452 // ------------------------------------------------
453 u_euler_x[i] = vueulerx1.c_cf->val_point(l1, xi1, theta1, phi1)
454 + vueulerx2.c_cf->val_point(l2, xi2, theta2, phi2) ;
455
456 u_euler_y[i] = vueulery1.c_cf->val_point(l1, xi1, theta1, phi1)
457 + vueulery2.c_cf->val_point(l2, xi2, theta2, phi2) ;
458 // + omega * xx[i] ;
459
460 u_euler_z[i] = vueulerz1.c_cf->val_point(l1, xi1, theta1, phi1)
461 + vueulerz2.c_cf->val_point(l2, xi2, theta2, phi2) ;
462
463
464
465 } // End of loop on the points
466
467
468 delete peos1 ;
469 delete peos2 ;
470 }
471
472 }