/* * Reads a file containing a binary configuration (class Binary) and * performs various plots. * */ /* * Copyright (c) 1999-2003 Eric Gourgoulhon * * 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 as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * 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 lit_bin_C[] = "$Header: /cvsroot/Lorene/Codes/Binary_star/lit_bin.C,v 1.5 2014/10/13 08:53:55 j_novak Exp $" ; /* * $Id: lit_bin.C,v 1.5 2014/10/13 08:53:55 j_novak Exp $ * $Log: lit_bin.C,v $ * Revision 1.5 2014/10/13 08:53:55 j_novak * Lorene classes and functions now belong to the namespace Lorene. * * Revision 1.4 2014/10/06 15:09:41 j_novak * Modified #include directives to use c++ syntax. * * Revision 1.3 2005/09/14 17:13:28 f_limousin * Plot of fields along X, Y and Z_axis * * Revision 1.2 2005/09/13 19:47:28 f_limousin * Reintroduction of the resolution of the equations in cartesian coordinates. * * Revision 1.1 2004/09/16 12:14:47 f_limousin * *** empty log message *** * * * $Header: /cvsroot/Lorene/Codes/Binary_star/lit_bin.C,v 1.5 2014/10/13 08:53:55 j_novak Exp $ * */ // headers C #include #include #include // headers Lorene #include "unites.h" #include "binary.h" #include "eos.h" #include "utilitaires.h" #include "graphique.h" #include "cmp.h" #include "tenseur.h" #include "nbr_spx.h" namespace Lorene { // Local prototype Cmp raccord_c1(const Cmp& uu, int l1) ; } //****************************************************************************** using namespace Lorene ; int main(int argc, char** argv){ // Identification of all the subroutines called by the code : // system("ident lit_bin") ; if (argc < 2) { cout << "lit_bin : the name of a file containing a binary configuration" << endl << " must be given in argument !" << endl ; abort() ; } char* nomresu = argv[1] ; //char* nomresu = "resu.d" ; cout << "Name of the file to be read : " << nomresu << endl ; cout << endl << "Do you want to draw the boundaries of the various domains (y/n) ? [y]" << endl ; char rep ; cin.get(rep) ; bool draw_bound = !(rep == 'n') ; using namespace Unites ; FILE* fich = fopen(nomresu, "r") ; if (fich == 0x0) { cout << "Problem in opening the file " << nomresu << " ! " << endl ; perror(" reason") ; abort() ; } 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) ; Binary star(mp1, *peos1, mp2, *peos2, fich) ; fclose(fich) ; bool irrotational = star(1).is_irrotational() ; cout << endl << "Grid on which star 1 is defined : " << endl ; cout << "=============================== " << endl ; cout << *((star(1).get_mp()).get_mg()) << endl ; cout << endl << "Grid on which star 2 is defined : " << endl ; cout << "=============================== " << endl ; cout << *((star(2).get_mp()).get_mg()) << endl ; cout << endl << "Mapping on which star 1 is defined : " << endl ; cout << "================================== " << endl ; cout << star(1).get_mp() << endl ; cout << endl << "Mapping on which star 2 is defined : " << endl ; cout << "================================== " << endl ; cout << star(2).get_mp() << endl ; star.fait_decouple() ; for (int i=1; i<=2; i++) { (star.set(i)).update_metric(star(3-i), star.get_omega()) ; } for (int i=1; i<=2; i++) { (star.set(i)).update_metric_der_comp(star(3-i), star.get_omega()) ; } 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() ; } // Writing of resformat.d ofstream seqfich("resformat.d") ; if ( !seqfich.good() ) { cout << "coal : problem with opening the file resformat.d !" << endl ; abort() ; } star.write_global(seqfich) ; seqfich.close() ; // Some printings cout.precision(6) ; cout << "mass_bar = " << star(1).mass_b()/msol << endl ; cout << "mass_vol = " << star.mass_adm_vol()/msol << endl ; cout << "mass_adm = " << star.mass_adm()/msol << endl ; cout << "d = " << star.separation() << endl ; cout << "ray_eq = " << star(1).ray_eq() << endl ; cout << "ray_eq_pi = " << star(1).ray_eq_pi() << endl ; cout << "R = " << (star(1).ray_eq() + star(1).ray_eq_pi())/2. << endl ; cout << "d_milieu = " << star.separation()/2. + (star(1).ray_eq_pi() - star(1).ray_eq())/2. << endl ; cout << "d/R = " << (star.separation() + (star(1).ray_eq_pi() - star(1).ray_eq()))/(star(1).ray_eq() + star(1).ray_eq_pi()) << endl ; // abort() ; cout << "Binary system read in file : " << endl ; cout << star << endl ; star.display_poly(cout) ; // Reduced quantities for polytropic EOS cout << "ADM mass [M_sol] : " << star.mass_adm() / msol << endl ; ////////////////////////////////////////////////////////// // Plot of different fields along X, Y and Z axis // ////////////////////////////////////////////////////////// Vector beta (star(1).get_beta()) ; beta.change_triad(star(1).get_mp().get_bvect_cart()) ; Scalar beta_y_aux (beta(2)) ; Scalar logn_aux (star(1).get_logn()) ; Scalar psi_aux (pow(star(1).get_psi4(), 0.25)) ; psi_aux.std_spectral_base() ; Sym_tensor gtilde (star(1).get_gtilde().cov()) ; Sym_tensor flat (star(1).get_flat().cov()) ; Sym_tensor hij_aux (gtilde-flat) ; hij_aux.change_triad(star(1).get_mp().get_bvect_cart()) ; Sym_tensor hij1(hij_aux) ; Sym_tensor gtilde2 (star(2).get_gtilde().cov()) ; Sym_tensor flat2 (star(2).get_flat().cov()) ; Sym_tensor hij2 (gtilde2-flat2) ; hij2.change_triad(star(2).get_mp().get_bvect_cart()) ; Cmp hxx (hij_aux(1,1)) ; Cmp hxy (hij_aux(2,1)) ; Cmp hxz (hij_aux(3,1)) ; Cmp hyy (hij_aux(2,2)) ; Cmp hyz (hij_aux(3,2)) ; Cmp hzz (hij_aux(3,3)) ; Cmp hxx1 (hij1(1,1)) ; Cmp hxy1 (hij1(2,1)) ; Cmp hxz1 (hij1(3,1)) ; Cmp hyy1 (hij1(2,2)) ; Cmp hyz1 (hij1(3,2)) ; Cmp hzz1 (hij1(3,3)) ; Cmp hxx2 (hij2(1,1)) ; Cmp hxy2 (hij2(2,1)) ; Cmp hxz2 (hij2(3,1)) ; Cmp hyy2 (hij2(2,2)) ; Cmp hyz2 (hij2(3,2)) ; Cmp hzz2 (hij2(3,3)) ; ofstream fich_xaxis("metric_xaxis.d") ; fich_xaxis.precision(6) ; ofstream fich_yaxis("metric_yaxis.d") ; fich_yaxis.precision(6) ; ofstream fich_zaxis("metric_zaxis.d") ; fich_zaxis.precision(6) ; ofstream fich_xaxis_all("metric_xaxis_all.d") ; fich_xaxis_all.precision(6) ; ofstream fich_yaxis_all("metric_yaxis_all.d") ; fich_yaxis_all.precision(6) ; ofstream fich_zaxis_all("metric_zaxis_all.d") ; fich_zaxis_all.precision(6) ; // Construction of an auxiliar grid and mapping int nz = star(1).get_mp().get_mg()->get_nzone() ; assert (nz >= 4); double* bornes = new double [nz+1] ; double r_in = 0.95 * (-star(1).get_mp().get_ori_x()-star(1).ray_eq()) ; double r_ext = 1.05 * (-star(1).get_mp().get_ori_x()+star(1).ray_eq_pi()) ; bornes[0] = 0 ; bornes[1] = r_in ; bornes[2] = r_ext ; for (int l=3; l ydes_max2) ? ydes_max1 : ydes_max2 ; double zdes_min1 = - 4. * star(1).ray_pole() ; double zdes_min2 = - 4. * star(2).ray_pole() ; double zdes_min = (zdes_min1 < zdes_min2) ? zdes_min1 : zdes_min2 ; double zdes_max1 = 4. * star(1).ray_pole() ; double zdes_max2 = 4. * star(2).ray_pole() ; double zdes_max = (zdes_max1 > zdes_max2) ? zdes_max1 : zdes_max2 ; Cmp surf1 (star(1).get_ent()) ; Cmp surf1_ext(mp1) ; surf1_ext = - 0.2 * surf1(0, 0, 0, 0) ; surf1_ext.annule(0, star(1).get_nzet()-1) ; surf1.annule(star(1).get_nzet(), mg1.get_nzone()-1) ; surf1 = surf1 + surf1_ext ; surf1 = raccord_c1(surf1, star(1).get_nzet()) ; Cmp surf2 (star(2).get_ent()) ; Cmp surf2_ext(mp2) ; surf2_ext = - 0.2 * surf2(0, 0, 0, 0) ; surf2_ext.annule(0, star(2).get_nzet()-1) ; surf2.annule(star(2).get_nzet(), mg2.get_nzone()-1) ; surf2 = surf2 + surf2_ext ; surf2 = raccord_c1(surf2, star(2).get_nzet()) ; char title[80] ; char bslash[2] = {92, '\0'} ; // 92 is the ASCII code for backslash ofstream fent("enthalpy.d") ; if ( !fent.good() ) { cout << "lit_bin : problem with opening the file enthalpy.d !" << endl ; abort() ; } fent << "Enthalpy field at the boundary of last inner domain of star 1 : " << endl ; int lzet = star(1).get_nzet() - 1 ; for (int k=0; k