/* * Main code for computing stationary axisymmetric rotating stars. * */ /* * Copyright (c) 2010 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 nrotstar_C[] = "$Header: /cvsroot/Lorene/Codes/Nrotstar/nrotstar.C,v 1.13 2014/10/13 08:53:58 j_novak Exp $" ; /* * $Id: nrotstar.C,v 1.13 2014/10/13 08:53:58 j_novak Exp $ * $Log: nrotstar.C,v $ * Revision 1.13 2014/10/13 08:53:58 j_novak * Lorene classes and functions now belong to the namespace Lorene. * * Revision 1.12 2013/12/15 17:48:15 e_gourgoulhon * Added output file for GYOTO * * Revision 1.11 2012/01/02 13:57:58 j_novak * Reverting to version 1.9 * * Revision 1.7 2010/03/29 14:36:13 e_gourgoulhon * Change of name of the output file calcul.d --> result.txt * * Revision 1.6 2010/03/29 14:07:27 e_gourgoulhon * Added file outputs prof_*.d for various radial profile plots. * * Revision 1.5 2010/01/31 18:27:38 e_gourgoulhon * Better reading of parameter files. * * Revision 1.4 2010/01/26 16:52:37 e_gourgoulhon * Added the graphical outputs at the end. * * Revision 1.3 2010/01/26 10:54:07 e_gourgoulhon * First complete version. * * Revision 1.2 2010/01/25 22:34:15 e_gourgoulhon * On avance... * * Revision 1.1 2010/01/25 18:16:39 e_gourgoulhon * First version. * * * $Header: /cvsroot/Lorene/Codes/Nrotstar/nrotstar.C,v 1.13 2014/10/13 08:53:58 j_novak Exp $ * */ // C headers #include #include #include // Lorene headers #include "star_rot.h" #include "eos.h" #include "utilitaires.h" #include "graphique.h" #include "nbr_spx.h" #include "unites.h" namespace Lorene{ // Local prototype (for drawings only) Scalar raccord_c1(const Scalar& uu, int l1) ; } //****************************************************************************** using namespace Lorene ; int main(){ using namespace Unites ; // Identification of all the subroutines called by the code : system("ident nrotstar > identif.d") ; // For the display : char display_bold[]="x[1m" ; display_bold[0] = 27 ; //------------------------------------------------------------------ // Parameters of the computation //------------------------------------------------------------------ int relat_i, mer_max, mer_rot, mer_change_omega, mer_fix_omega, delta_mer_kep, mer_mass, mermax_poisson, graph, nz, nzet, nzadapt, nt, np, mer_triax ; double ent_c, freq_si, fact_omega, mbar_wanted, precis, freq_ini_si, thres_adapt, aexp_mass, relax, relax_poisson, ampli_triax, precis_adapt ; ifstream fpar("par_rot.d") ; if ( !fpar.good() ) { cerr << "Problem in opening the file par_rot.d ! " << endl ; abort() ; } fpar.ignore(1000,'\n') ; // skip title fpar >> relat_i ; fpar.ignore(1000,'\n') ; bool relat = (relat_i == 1) ; fpar >> ent_c ; fpar.ignore(1000,'\n') ; fpar >> freq_si ; fpar.ignore(1000,'\n') ; fpar >> fact_omega ; fpar.ignore(1000,'\n') ; fpar >> mbar_wanted ; fpar.ignore(1000,'\n') ; mbar_wanted *= msol ; fpar.ignore(1000,'\n') ; // skip title fpar >> mer_max ; fpar.ignore(1000,'\n') ; fpar >> precis ; fpar.ignore(1000,'\n') ; fpar >> mer_rot ; fpar.ignore(1000,'\n') ; fpar >> freq_ini_si ; fpar.ignore(1000,'\n') ; fpar >> mer_change_omega ; fpar.ignore(1000,'\n') ; fpar >> mer_fix_omega ; fpar.ignore(1000,'\n') ; fpar >> delta_mer_kep ; fpar.ignore(1000,'\n') ; fpar >> thres_adapt ; fpar.ignore(1000,'\n') ; fpar >> mer_triax ; fpar.ignore(1000,'\n') ; fpar >> ampli_triax ; fpar.ignore(1000,'\n') ; fpar >> mer_mass ; fpar.ignore(1000,'\n') ; fpar >> aexp_mass ; fpar.ignore(1000,'\n') ; fpar >> relax ; fpar.ignore(1000,'\n') ; fpar >> mermax_poisson ; fpar.ignore(1000,'\n') ; fpar >> relax_poisson ; fpar.ignore(1000,'\n') ; fpar >> precis_adapt ; fpar.ignore(1000,'\n') ; fpar >> graph ; fpar.ignore(1000,'\n') ; fpar.ignore(1000,'\n') ; // skip title fpar >> nz ; fpar.ignore(1000,'\n') ; fpar >> nzet; fpar.ignore(1000,'\n') ; fpar >> nzadapt; fpar.ignore(1000,'\n') ; fpar >> nt; fpar.ignore(1000,'\n') ; fpar >> np; fpar.ignore(1000,'\n') ; int* nr = new int[nz]; int* nt_tab = new int[nz]; int* np_tab = new int[nz]; double* bornes = new double[nz+1]; fpar.ignore(1000,'\n'); // skip title for (int l=0; l> nr[l]; fpar >> bornes[l]; fpar.ignore(1000,'\n') ; np_tab[l] = np ; nt_tab[l] = nt ; } bornes[nz] = __infinity ; Tbl ent_limit(nzet) ; ent_limit.set_etat_qcq() ; ent_limit.set(nzet-1) = 0 ; // enthalpy at the stellar surface for (int l=0; l> ent_limit.set(l) ; fpar.ignore(1000,'\n') ; } fpar.close(); // Particular cases // ---------------- // Initial frequency = final frequency if ( freq_ini_si < 0 ) { freq_ini_si = freq_si ; mer_change_omega = mer_rot ; mer_fix_omega = mer_rot + 1 ; } //----------------------------------------------------------------------- // Equation of state //----------------------------------------------------------------------- fpar.open("par_eos.d") ; if ( !fpar.good() ) { cerr << "Problem in opening the file par_eos.d ! " << endl ; abort() ; } Eos* peos = Eos::eos_from_file(fpar) ; Eos& eos = *peos ; fpar.close() ; // Special treatment of crust - liquid core boundary in the case // of Eos_strange if (eos.identify() == 6) { assert( nzet == 2 ) ; const Eos_strange_cr* peos_cr = dynamic_cast(peos) ; if (peos_cr == 0x0) { cout << "nrotstar: problem : peos is not of type Eos_strange_cr !" << endl ; abort() ; } ent_limit.set(0) = peos_cr->get_ent_nd() ; // enthalpy at core/crust transition } //----------------------------------------------------------------------- // Construction of the multi-grid and the mapping //----------------------------------------------------------------------- // Rescale of bornes in the case where there more than 1 domain inside // the star for (int l=0; l> result.txt") ; fichfinal.open("result.txt", ios::app) ; fichfinal << endl << "================================================================" << endl ; fichfinal << " EOS PARAMETERS (file par_eos.d) : " << endl ; fichfinal << "================================================================" << endl ; fichfinal.close() ; system("cat par_eos.d >> result.txt") ; // Identification du code et de ses sous-routines (no. de version RCS) : fichfinal.open("result.txt", ios::app) ; fichfinal << endl << "================================================================" << endl ; fichfinal << " IDENTIFICATION OF THE CODE : " << endl ; fichfinal << "================================================================" << endl ; fichfinal.close() ; system("ident nrotstar >> result.txt") ; // Saveguard of the whole configuration // ------------------------------------ FILE* fresu = fopen("resu.d", "w") ; star.get_mp().get_mg()->sauve(fresu) ; // writing of the grid star.get_mp().sauve(fresu) ; // writing of the mapping star.get_eos().sauve(fresu) ; // writing of the EOS star.sauve(fresu) ; // writing of the star fclose(fresu) ; // Drawings // -------- ofstream fichdes("prof_n.d") ; fichdes.precision(10) ; fichdes << "# r [km] N(theta=0) N(theta=pi/2)" << endl ; int npd = 300 ; double r_max = 3 ; double h = r_max/double(npd-1) ; for (int i=0; i beta Scalar beta_phi = - star.get_nphi() ; // beta^phi = - N^phi Vector beta(star.get_mp(), CON, star.get_mp().get_bvect_spher()) ; beta.set(1) = 0 ; beta.set(2) = 0 ; Scalar tmp = beta_phi ; tmp.mult_rsint() ; beta.set(3) = tmp ; // Extrinsic curvature --> kk Scalar nn = star.get_nn() ; Scalar bb2 = star.get_b_car() ; Sym_tensor kk(star.get_mp(), COV, star.get_mp().get_bvect_spher()) ; kk.set(1,1) = 0 ; kk.set(1,2) = 0 ; tmp = 0.5 * bb2 * beta_phi.dsdr() / nn ; tmp.mult_rsint() ; kk.set(1,3) = tmp ; kk.set(2,2) = 0 ; tmp = 0.5 * bb2 * beta_phi.dsdt() / nn ; tmp.mult_sint() ; kk.set(2,3) = tmp ; kk.set(3,3) = 0 ; // File for GYOTO FILE* file_out = fopen("resu_gyoto.d", "w") ; double total_time = 0. ; // for compatibility fwrite_be(&total_time, sizeof(double), 1, file_out) ; star.get_mp().get_mg()->sauve(file_out) ; star.get_mp().sauve(file_out) ; star.get_nn().sauve(file_out) ; beta.sauve(file_out) ; star.get_gamma().cov().sauve(file_out) ; star.get_gamma().con().sauve(file_out) ; kk.sauve(file_out) ; // aa = c J / (G M^2) double aa = star.angu_mom()/( qpig / (4* M_PI) * pow(star.mass_g(), 2.) ) ; fwrite_be(&aa, sizeof(double), 1, file_out) ; fclose(file_out) ; // Cleaning // -------- delete peos ; exit(EXIT_SUCCESS) ; return EXIT_SUCCESS ; }