| 1 |
/* |
| 2 |
* Copyright (c) 1999-2001 Eric Gourgoulhon |
| 3 |
* 2012 Jerome Novak |
| 4 |
* |
| 5 |
* This file is part of LORENE. |
| 6 |
* |
| 7 |
* LORENE is free software; you can redistribute it and/or modify |
| 8 |
* it under the terms of the GNU General Public License as published by |
| 9 |
* the Free Software Foundation; either version 2 of the License, or |
| 10 |
* (at your option) any later version. |
| 11 |
* |
| 12 |
* LORENE is distributed in the hope that it will be useful, |
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
* GNU General Public License for more details. |
| 16 |
* |
| 17 |
* You should have received a copy of the GNU General Public License |
| 18 |
* along with LORENE; if not, write to the Free Software |
| 19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 20 |
* |
| 21 |
*/ |
| 22 |
|
| 23 |
char examrot_dirac_C[] = "$Header: /cvsroot/Lorene/Codes/Rot_star/examrot_dirac.C,v 1.2 2014/10/13 08:53:58 j_novak Exp $" ; |
| 24 |
|
| 25 |
/* |
| 26 |
* $Id: examrot_dirac.C,v 1.2 2014/10/13 08:53:58 j_novak Exp $ |
| 27 |
* $Log: examrot_dirac.C,v $ |
| 28 |
* Revision 1.2 2014/10/13 08:53:58 j_novak |
| 29 |
* Lorene classes and functions now belong to the namespace Lorene. |
| 30 |
* |
| 31 |
* Revision 1.1 2012/05/10 09:05:30 j_novak |
| 32 |
* New code examrot_dirac for reading the results of |
| 33 |
* rotstar_dirac. Simplification of the parrot.d parameter file for |
| 34 |
* rotstar_dirac. |
| 35 |
* |
| 36 |
* |
| 37 |
* $Header: /cvsroot/Lorene/Codes/Rot_star/examrot_dirac.C,v 1.2 2014/10/13 08:53:58 j_novak Exp $ |
| 38 |
* |
| 39 |
*/ |
| 40 |
|
| 41 |
// headers C |
| 42 |
#include <cmath> |
| 43 |
|
| 44 |
// headers Lorene |
| 45 |
#include "star_rot_dirac.h" |
| 46 |
#include "cmp.h" |
| 47 |
#include "eos.h" |
| 48 |
#include "utilitaires.h" |
| 49 |
#include "graphique.h" |
| 50 |
#include "unites.h" |
| 51 |
|
| 52 |
namespace Lorene { |
| 53 |
// Local prototype (for drawings only) |
| 54 |
Cmp raccord_c1(const Cmp& uu, int l1) ; |
| 55 |
} |
| 56 |
|
| 57 |
//****************************************************************************** |
| 58 |
|
| 59 |
using namespace Lorene ; |
| 60 |
|
| 61 |
int main(int argc, char** argv){ |
| 62 |
|
| 63 |
using namespace Unites ; |
| 64 |
|
| 65 |
if (argc < 2) { |
| 66 |
cout << |
| 67 |
"examrot_dirac : the name of a file containing a stellar configuration" |
| 68 |
<< endl << " must be given in argument !" << endl ; |
| 69 |
abort() ; |
| 70 |
} |
| 71 |
|
| 72 |
char* nomresu = argv[1] ; |
| 73 |
cout << "Name of the file to be read : " << nomresu << endl ; |
| 74 |
|
| 75 |
cout << endl << |
| 76 |
"Do you want to draw the boundaries of the various domains (y/n) ? [y]" |
| 77 |
<< endl ; |
| 78 |
char rep ; |
| 79 |
cin.get(rep) ; |
| 80 |
bool draw_bound = !(rep == 'n') ; |
| 81 |
|
| 82 |
|
| 83 |
FILE* fich = fopen(nomresu, "r") ; // open binary file in readonly |
| 84 |
|
| 85 |
Mg3d mg(fich) ; |
| 86 |
Map_af mp(mg, fich) ; |
| 87 |
|
| 88 |
Eos* peos = Eos::eos_from_file(fich) ; |
| 89 |
|
| 90 |
Star_rot_Dirac star(mp, *peos, fich) ; |
| 91 |
|
| 92 |
fclose(fich) ; |
| 93 |
|
| 94 |
star.update_metric() ; |
| 95 |
star.equation_of_state() ; |
| 96 |
star.hydro_euler() ; |
| 97 |
|
| 98 |
|
| 99 |
cout.precision(10) ; |
| 100 |
cout << star << endl ; |
| 101 |
|
| 102 |
|
| 103 |
// Formula (150) of Shapiro & Zane (1998) --> tsw1 |
| 104 |
double tcin = 0.5 * star.get_omega() * star.angu_mom() ; |
| 105 |
double tsw1 = tcin / ( tcin + star.mass_b() - star.mass_g() ) ; |
| 106 |
|
| 107 |
cout << "tsw, tsw1 : " << star.tsw() << " " << tsw1 << endl ; |
| 108 |
|
| 109 |
|
| 110 |
// Print of the enthalpy field |
| 111 |
cout << "Enthalpy : " << endl ; |
| 112 |
cout << star.get_ent() << endl ; |
| 113 |
arrete() ; |
| 114 |
|
| 115 |
// Print of the energy density field |
| 116 |
cout << "Proper energy density : " << endl ; |
| 117 |
cout << star.get_ener() << endl ; |
| 118 |
arrete() ; |
| 119 |
|
| 120 |
|
| 121 |
int nzet = star.get_nzet() ; |
| 122 |
|
| 123 |
// 2-D drawings |
| 124 |
// ------------ |
| 125 |
|
| 126 |
// Cmp defining the surface of the star (via the enthalpy field) |
| 127 |
Cmp surf = star.get_ent() ; |
| 128 |
Cmp surf_ext(mp) ; |
| 129 |
surf_ext = - 0.2 * surf(0, 0, 0, 0) ; |
| 130 |
surf_ext.annule(0, star.get_nzet()-1) ; |
| 131 |
surf.annule(star.get_nzet(), mg.get_nzone()-1) ; |
| 132 |
surf = surf + surf_ext ; |
| 133 |
surf = raccord_c1(surf, star.get_nzet()) ; |
| 134 |
|
| 135 |
double zoom = 1.2 ; |
| 136 |
|
| 137 |
// Various fields |
| 138 |
des_coupe_y(star.get_ent(), 0., nzet, "Enthalpy", &surf, zoom, |
| 139 |
draw_bound) ; |
| 140 |
|
| 141 |
if (mg.get_np(0) > 1) { |
| 142 |
des_coupe_z(star.get_ent(), 0., nzet, "Enthalpy (equatorial plane)", |
| 143 |
&surf, zoom, draw_bound) ; |
| 144 |
} |
| 145 |
|
| 146 |
des_coupe_y(star.get_logn(), 0., nzet, "Gravitational potential \\gn", &surf, zoom, |
| 147 |
draw_bound) ; |
| 148 |
|
| 149 |
|
| 150 |
des_coupe_y(star.get_beta()(3), 0., nzet, "Azimuthal shift \\gb\\u\\gf", &surf, zoom, |
| 151 |
draw_bound) ; |
| 152 |
|
| 153 |
des_coupe_y(star.get_lnq(), 0., nzet, "Metric potential ln(Q)", &surf, zoom, |
| 154 |
draw_bound) ; |
| 155 |
|
| 156 |
|
| 157 |
des_coupe_y(star.get_aa_quad(), 0., nzet, "A\\uij\\d A\\dij", &surf, zoom, |
| 158 |
draw_bound) ; |
| 159 |
|
| 160 |
des_coupe_y(star.get_hh()(1,1), 0., nzet, "Metric potential h\\urr", &surf) ; |
| 161 |
des_coupe_y(star.get_hh()(1,2), 0., nzet, "Metric potential h\\ur\\gh", &surf) ; |
| 162 |
des_coupe_y(star.get_hh()(2,2), 0., nzet, "Metric potential h\\u\\gh\\gh", &surf) ; |
| 163 |
des_coupe_y(star.get_hh()(3,3), 0., nzet, "Metric potential h\\u\\gf\\gf", &surf) ; |
| 164 |
|
| 165 |
|
| 166 |
// 1-D plots |
| 167 |
// --------- |
| 168 |
|
| 169 |
// Energy density |
| 170 |
double r_min = 0 ; // plot starts at center |
| 171 |
double r_max = star.ray_eq() ; |
| 172 |
double theta = M_PI / 2 ; |
| 173 |
double phi = 0 ; |
| 174 |
des_profile(star.get_ener(), r_min, r_max, theta, phi, |
| 175 |
"Proper energy density [rho_nuc]") ; |
| 176 |
|
| 177 |
// Outputs in file for Xmgr, Gnuplot, ... |
| 178 |
|
| 179 |
ofstream fdata("profiles.d") ; |
| 180 |
fdata << "# r [km] e(theta=pi/2) e(theta=0)" << endl ; |
| 181 |
|
| 182 |
r_min = 0 ; |
| 183 |
r_max = star.ray_eq() ; |
| 184 |
int npt = 200 ; |
| 185 |
|
| 186 |
for (int i=0; i<npt; i++) { |
| 187 |
|
| 188 |
double r = r_min + double(i) * (r_max -r_min) / double(npt-1) ; |
| 189 |
|
| 190 |
theta = M_PI / 2. ; |
| 191 |
double uu1 = star.get_ener().val_point(r,theta,phi) ; |
| 192 |
|
| 193 |
theta = 0 ; |
| 194 |
double uu2 = star.get_ener().val_point(r,theta,phi) ; |
| 195 |
|
| 196 |
fdata << r / km << " " << uu1 << " " << uu2 ; |
| 197 |
|
| 198 |
|
| 199 |
fdata << endl ; |
| 200 |
} |
| 201 |
|
| 202 |
fdata.close() ; |
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
// Cleaning |
| 207 |
// -------- |
| 208 |
|
| 209 |
delete peos ; |
| 210 |
|
| 211 |
exit(EXIT_SUCCESS) ; |
| 212 |
|
| 213 |
return EXIT_SUCCESS ; |
| 214 |
|
| 215 |
} |