/* * Constructor of class Bin_NS (binary neutron star exportation) * which depends explicitely on Lorene objects. * * (see file bin_ns.h for documentation). */ /* * Copyright (c) 2002 Eric Gourgoulhon * Copyright (c) 2002 Keisuke Taniguchi * * This file is part of LORENE. * * LORENE is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 * as published by the Free Software Foundation. * * LORENE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with LORENE; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ 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 $" ; /* * $Id: bin_ns_aux.C,v 1.8 2014/10/13 08:54:05 j_novak Exp $ * $Log: bin_ns_aux.C,v $ * Revision 1.8 2014/10/13 08:54:05 j_novak * Lorene classes and functions now belong to the namespace Lorene. * * Revision 1.7 2014/10/06 15:13:25 j_novak * Modified #include directives to use c++ syntax. * * Revision 1.6 2014/02/24 16:08:11 e_gourgoulhon * Eulerian velocities set to zero outside the stars * * Revision 1.5 2006/09/12 08:04:07 j_novak * Removal of the include path Export/C++/Include, updating of the relevant * source files in Export/C++/Source. * * Revision 1.4 2004/04/29 20:29:18 e_gourgoulhon * Corrected a bug in the computation of ener_spec. * * Revision 1.3 2004/03/25 10:29:27 j_novak * All LORENE's units are now defined in the namespace Unites (in file unites.h). * * Revision 1.2 2002/01/15 09:11:04 e_gourgoulhon * Display of Lorene object (class binaire) read in file * * Revision 1.1 2002/01/11 17:03:02 e_gourgoulhon * Exportation of binary neutron stars configuration to a Cartesian grid * * * $Header: /cvsroot/Lorene/Export/C++/Source/bin_ns_aux.C,v 1.8 2014/10/13 08:54:05 j_novak Exp $ * */ #include "../Include/bin_ns.h" // C headers #include #include // Lorene headers #include "tenseur.h" #include "binaire.h" #include "eos.h" #include "unites.h" //----------------------------------------// // Constructor from LORENE data // //----------------------------------------// namespace Lorene { Bin_NS::Bin_NS(int nbpoints, const double* xi, const double* yi, const double* zi, const char* filename) : np(nbpoints) { using namespace Unites ; // Reading of data // --------------- FILE* fich = fopen(filename, "r") ; int mer ; fread(&mer, sizeof(int), 1, fich) ; // mer Mg3d mg1(fich) ; Map_et mp1(mg1, fich) ; Eos* peos1 = Eos::eos_from_file(fich) ; Mg3d mg2(fich) ; Map_et mp2(mg2, fich) ; Eos* peos2 = Eos::eos_from_file(fich) ; Binaire star(mp1, *peos1, mp2, *peos2, fich) ; fclose(fich) ; if ( (star(1).is_relativistic() == false) || (star(2).is_relativistic() == false) ) { cout << "Bin_NS::Bin_NS can import only relativistic stars !" << endl ; abort() ; } // Construction of the binary system // --------------------------------- for (int i=1; i<=2; i++) { (star.set(i)).update_metric(star(3-i)) ; } for (int i=1; i<=2; i++) { (star.set(i)).update_metric_der_comp(star(3-i)) ; } for (int i=1; i<=2; i++) { (star.set(i)).equation_of_state() ; (star.set(i)).kinematics(star.get_omega(), star.get_x_axe()) ; (star.set(i)).fait_d_psi() ; (star.set(i)).hydro_euler() ; } // Initialisation of member data // ----------------------------- const Eos_poly* p_eos_poly1 = dynamic_cast( peos1 ) ; const Eos_poly* p_eos_poly2 = dynamic_cast( peos2 ) ; if ( p_eos_poly1 != 0x0 ) { strcpy(eos_name1, "Polytropic EOS") ; gamma_poly1 = p_eos_poly1->get_gam() ; kappa_poly1 = p_eos_poly1->get_kap() ; } else { strncpy(eos_name1, (star(1).get_eos()).get_name(), 100) ; gamma_poly1 = 0 ; kappa_poly1 = 0 ; } if ( p_eos_poly2 != 0x0 ) { strcpy(eos_name2, "Polytropic EOS") ; gamma_poly2 = p_eos_poly2->get_gam() ; kappa_poly2 = p_eos_poly2->get_kap() ; } else { strncpy(eos_name2, (star(2).get_eos()).get_name(), 100) ; gamma_poly2 = 0 ; kappa_poly2 = 0 ; } omega = star.get_omega() * f_unit ; dist = star.separation() / km ; dist_mass = ( star(2).xa_barycenter() - star(1).xa_barycenter() ) / km ; mass1_b = star(1).mass_b() / msol ; mass2_b = star(2).mass_b() / msol ; mass_adm = star.mass_adm() / msol ; angu_mom = star.angu_mom()(2) / ( ggrav * msol*msol) ; rad1_x_comp = star(1).ray_eq() / km ; rad1_y = star(1).ray_eq_pis2() / km ; rad1_z = star(1).ray_pole() / km ; rad1_x_opp = star(1).ray_eq_pi() / km ; rad2_x_comp = star(2).ray_eq() / km ; rad2_y = star(2).ray_eq_pis2() / km ; rad2_z = star(2).ray_pole() / km ; rad2_x_opp = star(2).ray_eq_pi() / km ; cout.precision(13) ; cout << endl << "Binary system read in file : " << endl ; cout << "---------------------------- " << endl ; cout << star << endl ; cout << endl << "Summary : " << endl ; cout << "-------" << endl ; cout << " Separation d : " << dist << " km" << endl ; cout << " Separation d_G : " << dist_mass << " km" << endl ; cout << " Omega : " << omega << " rad/s" << endl ; cout << " Baryon mass of star 1 : " << mass1_b << " M_sol" << endl ; cout << " Baryon mass of star 2 : " << mass2_b << " M_sol" << endl ; cout << " ADM mass of the system : " << mass_adm << " M_sol" << endl ; cout << " Total angular momentum : " << angu_mom << " G M_sol^2 / c" << endl ; cout << " Radius of star 1 (x_comp) : " << rad1_x_comp << " km" << endl ; cout << " Radius of star 1 (y) : " << rad1_y << " km" << endl ; cout << " Radius of star 1 (z) : " << rad1_z << " km" << endl ; cout << " Radius of star 1 (x_opp) : " << rad1_x_opp << " km" << endl ; cout << " Radius of star 2 (x_comp) : " << rad2_x_comp << " km" << endl ; cout << " Radius of star 2 (y) : " << rad2_y << " km" << endl ; cout << " Radius of star 2 (z) : " << rad2_z << " km" << endl ; cout << " Radius of star 2 (x_opp) : " << rad2_x_opp << " km" << endl ; // Creation of the various arrays on the Cartesian grid // ---------------------------------------------------- alloc_memory() ; // Initialisation of the Cartesian grid // ------------------------------------ for (int i=0; ival_point_symy(l1, xi1, theta1, phi1) * vnn2.c_cf->val_point_symy(l2, xi2, theta2, phi2) ; // Shift vector // ------------ beta_x[i] = vshiftx1.c_cf->val_point_asymy(l1, xi1, theta1, phi1) + vshiftx2.c_cf->val_point_asymy(l2, xi2, theta2, phi2) ; beta_y[i] = vshifty1.c_cf->val_point_symy(l1, xi1, theta1, phi1) + vshifty2.c_cf->val_point_symy(l2, xi2, theta2, phi2) ; // + omega * xx[i] ; beta_z[i] = vshiftz1.c_cf->val_point_asymy(l1, xi1, theta1, phi1) + vshiftz2.c_cf->val_point_asymy(l2, xi2, theta2, phi2) ; // Conformal factor // ---------------- double psi4 = vacar1.c_cf->val_point_symy(l1, xi1, theta1, phi1) * vacar2.c_cf->val_point_symy(l2, xi2, theta2, phi2) ; g_xx[i] = psi4 ; g_yy[i] = psi4 ; g_zz[i] = psi4 ; g_xy[i] = 0 ; g_xz[i] = 0 ; g_yz[i] = 0 ; // Extrinsic curvature // ------------------- double pre = km * psi4 ; k_xx[i] = pre*( vkxx1.c_cf->val_point_asymy(l1, xi1, theta1, phi1) +vkxx2.c_cf->val_point_asymy(l2, xi2, theta2, phi2) ) ; k_xy[i] = pre*( vkxy1.c_cf->val_point_symy(l1, xi1, theta1, phi1) +vkxy2.c_cf->val_point_symy(l2, xi2, theta2, phi2) ) ; k_xz[i] = pre*( vkxz1.c_cf->val_point_asymy(l1, xi1, theta1, phi1) +vkxz2.c_cf->val_point_asymy(l2, xi2, theta2, phi2) ) ; k_yy[i] = pre*( vkyy1.c_cf->val_point_asymy(l1, xi1, theta1, phi1) +vkyy2.c_cf->val_point_asymy(l2, xi2, theta2, phi2) ) ; k_yz[i] = pre*( vkyz1.c_cf->val_point_symy(l1, xi1, theta1, phi1) +vkyz2.c_cf->val_point_symy(l2, xi2, theta2, phi2) ) ; k_zz[i] = pre*( vkzz1.c_cf->val_point_asymy(l1, xi1, theta1, phi1) +vkzz2.c_cf->val_point_asymy(l2, xi2, theta2, phi2) ) ; // Baryon density [kg/m^3] // -------------- nbar[i] = rho_unit*( vnbar1.c_cf->val_point_symy(l1, xi1, theta1, phi1) + vnbar2.c_cf->val_point_symy(l2, xi2, theta2, phi2) ) ; // Energy density // -------------- double ener = vener1.c_cf->val_point_symy(l1, xi1, theta1, phi1) + vener2.c_cf->val_point_symy(l2, xi2, theta2, phi2) ; if ( nbar[i] == double(0) ) { ener_spec[i] = 0 ; } else { ener_spec[i] = ener / (nbar[i]/rho_unit) - double(1) ; } // 3-velocity with respect to the Eulerian observer // ------------------------------------------------ u_euler_x[i] = vueulerx1.c_cf->val_point(l1, xi1, theta1, phi1) + vueulerx2.c_cf->val_point(l2, xi2, theta2, phi2) ; u_euler_y[i] = vueulery1.c_cf->val_point(l1, xi1, theta1, phi1) + vueulery2.c_cf->val_point(l2, xi2, theta2, phi2) ; // + omega * xx[i] ; u_euler_z[i] = vueulerz1.c_cf->val_point(l1, xi1, theta1, phi1) + vueulerz2.c_cf->val_point(l2, xi2, theta2, phi2) ; } // End of loop on the points delete peos1 ; delete peos2 ; } }