| 1 |
/* |
| 2 |
* Main code for computing stationary axisymmetric rotating stars. |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
/* |
| 7 |
* Copyright (c) 2010 Eric Gourgoulhon |
| 8 |
* |
| 9 |
* This file is part of LORENE. |
| 10 |
* |
| 11 |
* LORENE is free software; you can redistribute it and/or modify |
| 12 |
* it under the terms of the GNU General Public License as published by |
| 13 |
* the Free Software Foundation; either version 2 of the License, or |
| 14 |
* (at your option) any later version. |
| 15 |
* |
| 16 |
* LORENE is distributed in the hope that it will be useful, |
| 17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 |
* GNU General Public License for more details. |
| 20 |
* |
| 21 |
* You should have received a copy of the GNU General Public License |
| 22 |
* along with LORENE; if not, write to the Free Software |
| 23 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 24 |
* |
| 25 |
*/ |
| 26 |
|
| 27 |
char nrotstar_C[] = "$Header: /cvsroot/Lorene/Codes/Nrotstar/nrotstar.C,v 1.13 2014/10/13 08:53:58 j_novak Exp $" ; |
| 28 |
|
| 29 |
/* |
| 30 |
* $Id: nrotstar.C,v 1.13 2014/10/13 08:53:58 j_novak Exp $ |
| 31 |
* $Log: nrotstar.C,v $ |
| 32 |
* Revision 1.13 2014/10/13 08:53:58 j_novak |
| 33 |
* Lorene classes and functions now belong to the namespace Lorene. |
| 34 |
* |
| 35 |
* Revision 1.12 2013/12/15 17:48:15 e_gourgoulhon |
| 36 |
* Added output file for GYOTO |
| 37 |
* |
| 38 |
* Revision 1.11 2012/01/02 13:57:58 j_novak |
| 39 |
* Reverting to version 1.9 |
| 40 |
* |
| 41 |
* Revision 1.7 2010/03/29 14:36:13 e_gourgoulhon |
| 42 |
* Change of name of the output file calcul.d --> result.txt |
| 43 |
* |
| 44 |
* Revision 1.6 2010/03/29 14:07:27 e_gourgoulhon |
| 45 |
* Added file outputs prof_*.d for various radial profile plots. |
| 46 |
* |
| 47 |
* Revision 1.5 2010/01/31 18:27:38 e_gourgoulhon |
| 48 |
* Better reading of parameter files. |
| 49 |
* |
| 50 |
* Revision 1.4 2010/01/26 16:52:37 e_gourgoulhon |
| 51 |
* Added the graphical outputs at the end. |
| 52 |
* |
| 53 |
* Revision 1.3 2010/01/26 10:54:07 e_gourgoulhon |
| 54 |
* First complete version. |
| 55 |
* |
| 56 |
* Revision 1.2 2010/01/25 22:34:15 e_gourgoulhon |
| 57 |
* On avance... |
| 58 |
* |
| 59 |
* Revision 1.1 2010/01/25 18:16:39 e_gourgoulhon |
| 60 |
* First version. |
| 61 |
* |
| 62 |
* |
| 63 |
* $Header: /cvsroot/Lorene/Codes/Nrotstar/nrotstar.C,v 1.13 2014/10/13 08:53:58 j_novak Exp $ |
| 64 |
* |
| 65 |
*/ |
| 66 |
|
| 67 |
// C headers |
| 68 |
#include <cstdlib> |
| 69 |
#include <cmath> |
| 70 |
#include <cstring> |
| 71 |
|
| 72 |
// Lorene headers |
| 73 |
#include "star_rot.h" |
| 74 |
#include "eos.h" |
| 75 |
#include "utilitaires.h" |
| 76 |
#include "graphique.h" |
| 77 |
#include "nbr_spx.h" |
| 78 |
#include "unites.h" |
| 79 |
|
| 80 |
namespace Lorene{ |
| 81 |
// Local prototype (for drawings only) |
| 82 |
Scalar raccord_c1(const Scalar& uu, int l1) ; |
| 83 |
} |
| 84 |
//****************************************************************************** |
| 85 |
|
| 86 |
using namespace Lorene ; |
| 87 |
|
| 88 |
int main(){ |
| 89 |
|
| 90 |
using namespace Unites ; |
| 91 |
|
| 92 |
// Identification of all the subroutines called by the code : |
| 93 |
|
| 94 |
system("ident nrotstar > identif.d") ; |
| 95 |
|
| 96 |
// For the display : |
| 97 |
char display_bold[]="x[1m" ; display_bold[0] = 27 ; |
| 98 |
|
| 99 |
//------------------------------------------------------------------ |
| 100 |
// Parameters of the computation |
| 101 |
//------------------------------------------------------------------ |
| 102 |
|
| 103 |
int relat_i, mer_max, mer_rot, mer_change_omega, mer_fix_omega, |
| 104 |
delta_mer_kep, mer_mass, mermax_poisson, graph, nz, nzet, nzadapt, |
| 105 |
nt, np, mer_triax ; |
| 106 |
double ent_c, freq_si, fact_omega, mbar_wanted, precis, freq_ini_si, |
| 107 |
thres_adapt, aexp_mass, relax, relax_poisson, ampli_triax, |
| 108 |
precis_adapt ; |
| 109 |
|
| 110 |
ifstream fpar("par_rot.d") ; |
| 111 |
if ( !fpar.good() ) { |
| 112 |
cerr << "Problem in opening the file par_rot.d ! " << endl ; |
| 113 |
abort() ; |
| 114 |
} |
| 115 |
|
| 116 |
|
| 117 |
fpar.ignore(1000,'\n') ; // skip title |
| 118 |
fpar >> relat_i ; fpar.ignore(1000,'\n') ; |
| 119 |
bool relat = (relat_i == 1) ; |
| 120 |
fpar >> ent_c ; fpar.ignore(1000,'\n') ; |
| 121 |
fpar >> freq_si ; fpar.ignore(1000,'\n') ; |
| 122 |
fpar >> fact_omega ; fpar.ignore(1000,'\n') ; |
| 123 |
fpar >> mbar_wanted ; fpar.ignore(1000,'\n') ; |
| 124 |
mbar_wanted *= msol ; |
| 125 |
fpar.ignore(1000,'\n') ; // skip title |
| 126 |
fpar >> mer_max ; fpar.ignore(1000,'\n') ; |
| 127 |
fpar >> precis ; fpar.ignore(1000,'\n') ; |
| 128 |
fpar >> mer_rot ; fpar.ignore(1000,'\n') ; |
| 129 |
fpar >> freq_ini_si ; fpar.ignore(1000,'\n') ; |
| 130 |
fpar >> mer_change_omega ; fpar.ignore(1000,'\n') ; |
| 131 |
fpar >> mer_fix_omega ; fpar.ignore(1000,'\n') ; |
| 132 |
fpar >> delta_mer_kep ; fpar.ignore(1000,'\n') ; |
| 133 |
fpar >> thres_adapt ; fpar.ignore(1000,'\n') ; |
| 134 |
fpar >> mer_triax ; fpar.ignore(1000,'\n') ; |
| 135 |
fpar >> ampli_triax ; fpar.ignore(1000,'\n') ; |
| 136 |
fpar >> mer_mass ; fpar.ignore(1000,'\n') ; |
| 137 |
fpar >> aexp_mass ; fpar.ignore(1000,'\n') ; |
| 138 |
fpar >> relax ; fpar.ignore(1000,'\n') ; |
| 139 |
fpar >> mermax_poisson ; fpar.ignore(1000,'\n') ; |
| 140 |
fpar >> relax_poisson ; fpar.ignore(1000,'\n') ; |
| 141 |
fpar >> precis_adapt ; fpar.ignore(1000,'\n') ; |
| 142 |
fpar >> graph ; fpar.ignore(1000,'\n') ; |
| 143 |
fpar.ignore(1000,'\n') ; // skip title |
| 144 |
fpar >> nz ; fpar.ignore(1000,'\n') ; |
| 145 |
fpar >> nzet; fpar.ignore(1000,'\n') ; |
| 146 |
fpar >> nzadapt; fpar.ignore(1000,'\n') ; |
| 147 |
fpar >> nt; fpar.ignore(1000,'\n') ; |
| 148 |
fpar >> np; fpar.ignore(1000,'\n') ; |
| 149 |
|
| 150 |
int* nr = new int[nz]; |
| 151 |
int* nt_tab = new int[nz]; |
| 152 |
int* np_tab = new int[nz]; |
| 153 |
double* bornes = new double[nz+1]; |
| 154 |
|
| 155 |
fpar.ignore(1000,'\n'); // skip title |
| 156 |
for (int l=0; l<nz; l++) { |
| 157 |
fpar >> nr[l]; |
| 158 |
fpar >> bornes[l]; fpar.ignore(1000,'\n') ; |
| 159 |
np_tab[l] = np ; |
| 160 |
nt_tab[l] = nt ; |
| 161 |
} |
| 162 |
bornes[nz] = __infinity ; |
| 163 |
|
| 164 |
Tbl ent_limit(nzet) ; |
| 165 |
ent_limit.set_etat_qcq() ; |
| 166 |
ent_limit.set(nzet-1) = 0 ; // enthalpy at the stellar surface |
| 167 |
for (int l=0; l<nzet-1; l++) { |
| 168 |
fpar >> ent_limit.set(l) ; fpar.ignore(1000,'\n') ; |
| 169 |
} |
| 170 |
|
| 171 |
fpar.close(); |
| 172 |
|
| 173 |
// Particular cases |
| 174 |
// ---------------- |
| 175 |
|
| 176 |
// Initial frequency = final frequency |
| 177 |
if ( freq_ini_si < 0 ) { |
| 178 |
freq_ini_si = freq_si ; |
| 179 |
mer_change_omega = mer_rot ; |
| 180 |
mer_fix_omega = mer_rot + 1 ; |
| 181 |
} |
| 182 |
|
| 183 |
|
| 184 |
//----------------------------------------------------------------------- |
| 185 |
// Equation of state |
| 186 |
//----------------------------------------------------------------------- |
| 187 |
|
| 188 |
fpar.open("par_eos.d") ; |
| 189 |
if ( !fpar.good() ) { |
| 190 |
cerr << "Problem in opening the file par_eos.d ! " << endl ; |
| 191 |
abort() ; |
| 192 |
} |
| 193 |
|
| 194 |
Eos* peos = Eos::eos_from_file(fpar) ; |
| 195 |
Eos& eos = *peos ; |
| 196 |
|
| 197 |
fpar.close() ; |
| 198 |
|
| 199 |
|
| 200 |
// Special treatment of crust - liquid core boundary in the case |
| 201 |
// of Eos_strange |
| 202 |
if (eos.identify() == 6) { |
| 203 |
assert( nzet == 2 ) ; |
| 204 |
const Eos_strange_cr* peos_cr = dynamic_cast<const Eos_strange_cr*>(peos) ; |
| 205 |
if (peos_cr == 0x0) { |
| 206 |
cout << "nrotstar: problem : peos is not of type Eos_strange_cr !" << endl ; |
| 207 |
abort() ; |
| 208 |
} |
| 209 |
|
| 210 |
ent_limit.set(0) = peos_cr->get_ent_nd() ; // enthalpy at core/crust transition |
| 211 |
|
| 212 |
} |
| 213 |
|
| 214 |
//----------------------------------------------------------------------- |
| 215 |
// Construction of the multi-grid and the mapping |
| 216 |
//----------------------------------------------------------------------- |
| 217 |
|
| 218 |
// Rescale of bornes in the case where there more than 1 domain inside |
| 219 |
// the star |
| 220 |
|
| 221 |
for (int l=0; l<nzet-1; l++) { |
| 222 |
|
| 223 |
bornes[l+1] = bornes[nzet] * sqrt(1 - ent_limit(l) / ent_c) ; |
| 224 |
|
| 225 |
} |
| 226 |
|
| 227 |
// Type of r sampling : |
| 228 |
int* type_r = new int[nz]; |
| 229 |
type_r[0] = RARE ; |
| 230 |
for (int l=1; l<nz-1; l++) { |
| 231 |
type_r[l] = FIN ; |
| 232 |
} |
| 233 |
type_r[nz-1] = UNSURR ; |
| 234 |
|
| 235 |
// Type of sampling in theta and phi : |
| 236 |
int type_t = SYM ; |
| 237 |
int type_p = SYM ; |
| 238 |
|
| 239 |
Mg3d mg(nz, nr, type_r, nt_tab, type_t, np_tab, type_p) ; |
| 240 |
|
| 241 |
Map_et mp(mg, bornes) ; |
| 242 |
|
| 243 |
// Cleaning |
| 244 |
// -------- |
| 245 |
|
| 246 |
delete [] nr ; |
| 247 |
delete [] nt_tab ; |
| 248 |
delete [] np_tab ; |
| 249 |
delete [] type_r ; |
| 250 |
delete [] bornes ; |
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
cout << endl |
| 255 |
<< "==========================================================" << endl |
| 256 |
<< " Physical parameters " << endl |
| 257 |
<< "==========================================================" |
| 258 |
<< endl ; |
| 259 |
cout << endl ; |
| 260 |
|
| 261 |
cout << endl << "Equation of state : " |
| 262 |
<< endl << "================= " << endl ; |
| 263 |
cout << eos << endl ; |
| 264 |
|
| 265 |
cout << "Central enthalpy : " << ent_c << " c^2" << endl ; |
| 266 |
cout << "Rotation frequency : " << freq_si << " Hz" << endl ; |
| 267 |
if ( abs(mer_mass) < mer_max ) { |
| 268 |
cout << "Required Baryon mass [M_sol] : " |
| 269 |
<< mbar_wanted / msol << endl ; |
| 270 |
} |
| 271 |
|
| 272 |
cout << endl |
| 273 |
<< "==========================================================" << endl |
| 274 |
<< " Computational parameters " << endl |
| 275 |
<< "==========================================================" |
| 276 |
<< endl << endl ; |
| 277 |
|
| 278 |
cout << "Maximum number of steps in the main iteration : " |
| 279 |
<< mer_max << endl ; |
| 280 |
cout << "Relaxation factor in the main iteration : " |
| 281 |
<< relax << endl ; |
| 282 |
cout << "Threshold on the enthalpy relative change for ending the computation : " |
| 283 |
<< precis << endl ; |
| 284 |
cout << "Maximum number of steps in Map_et::poisson : " |
| 285 |
<< mermax_poisson << endl ; |
| 286 |
cout << "Relaxation factor in Map_et::poisson : " |
| 287 |
<< relax_poisson << endl ; |
| 288 |
cout << "Step from which the baryon mass is forced to converge : " |
| 289 |
<< mer_mass << endl ; |
| 290 |
cout << "Exponent for the increase factor of the central enthalpy : " |
| 291 |
<< aexp_mass << endl ; |
| 292 |
cout << |
| 293 |
"Threshold on |dH/dr|_eq / |dH/dr|_pole for the adaptation of the mapping" |
| 294 |
<< endl << thres_adapt << endl ; |
| 295 |
|
| 296 |
|
| 297 |
cout << endl << "Multi-grid : " |
| 298 |
<< endl << "==========" << endl << mg << endl ; |
| 299 |
cout << "Mapping : " |
| 300 |
<< endl << "=======" << endl << mp << endl ; |
| 301 |
|
| 302 |
|
| 303 |
//----------------------------------------------------------------------- |
| 304 |
// Construction of the star |
| 305 |
//----------------------------------------------------------------------- |
| 306 |
|
| 307 |
Star_rot star(mp, nzet, relat, eos) ; |
| 308 |
|
| 309 |
if ( star.is_relativistic() ) { |
| 310 |
cout << "========================" << endl ; |
| 311 |
cout << "Relativistic computation" << endl ; |
| 312 |
cout << "========================" << endl ; |
| 313 |
} |
| 314 |
else { |
| 315 |
cout << "=====================" << endl ; |
| 316 |
cout << "Newtonian computation" << endl ; |
| 317 |
cout << "=====================" << endl ; |
| 318 |
} |
| 319 |
|
| 320 |
//----------------------------------------------------------------------- |
| 321 |
// Initialization of the enthalpy field |
| 322 |
//----------------------------------------------------------------------- |
| 323 |
|
| 324 |
|
| 325 |
const Coord& r = mp.r ; |
| 326 |
double ray0 = mp.val_r(nzet-1, 1., 0., 0.) ; |
| 327 |
Scalar ent0(mp) ; |
| 328 |
ent0 = ent_c * ( 1 - r*r / (ray0*ray0) ) ; |
| 329 |
ent0.annule_domain(nz-1) ; |
| 330 |
ent0.std_spectral_base() ; |
| 331 |
star.set_enthalpy(ent0) ; |
| 332 |
|
| 333 |
// Initialization of (n,e,p) from H |
| 334 |
star.equation_of_state() ; |
| 335 |
|
| 336 |
// Initialization of (E,S,U,etc...) (quantities relative to the Eulerian obs) |
| 337 |
star.hydro_euler() ; |
| 338 |
|
| 339 |
cout << endl << "Initial star : " |
| 340 |
<< endl << "============ " << endl ; |
| 341 |
|
| 342 |
cout << star << endl ; |
| 343 |
|
| 344 |
//----------------------------------------------------------------------- |
| 345 |
// Computation of the rotating equilibrium |
| 346 |
//----------------------------------------------------------------------- |
| 347 |
|
| 348 |
double omega = 2 * M_PI * freq_si / f_unit ; |
| 349 |
double omega_ini = 2 * M_PI * freq_ini_si / f_unit ; |
| 350 |
|
| 351 |
Itbl icontrol(8) ; |
| 352 |
icontrol.set_etat_qcq() ; |
| 353 |
icontrol.set(0) = mer_max ; |
| 354 |
icontrol.set(1) = mer_rot ; |
| 355 |
icontrol.set(2) = mer_change_omega ; |
| 356 |
icontrol.set(3) = mer_fix_omega ; |
| 357 |
icontrol.set(4) = mer_mass ; |
| 358 |
icontrol.set(5) = mermax_poisson ; |
| 359 |
icontrol.set(6) = mer_triax ; |
| 360 |
icontrol.set(7) = delta_mer_kep ; |
| 361 |
|
| 362 |
Tbl control(7) ; |
| 363 |
control.set_etat_qcq() ; |
| 364 |
control.set(0) = precis ; |
| 365 |
control.set(1) = omega_ini ; |
| 366 |
control.set(2) = relax ; |
| 367 |
control.set(3) = relax_poisson ; |
| 368 |
control.set(4) = thres_adapt ; |
| 369 |
control.set(5) = ampli_triax ; |
| 370 |
control.set(6) = precis_adapt ; |
| 371 |
|
| 372 |
Tbl diff(8) ; |
| 373 |
|
| 374 |
star.equilibrium(ent_c, omega, fact_omega, nzadapt, ent_limit, icontrol, control, |
| 375 |
mbar_wanted, aexp_mass, diff) ; |
| 376 |
|
| 377 |
cout << endl << "Final star : " |
| 378 |
<< endl << "========== " << endl ; |
| 379 |
|
| 380 |
cout.precision(10) ; |
| 381 |
cout << star << endl ; |
| 382 |
|
| 383 |
double rho_c = star.get_ener().val_grid_point(0,0,0,0) ; |
| 384 |
|
| 385 |
cout << "r_p/r_eq :" << star.aplat() << endl ; |
| 386 |
cout << "Omega rho0^{-1/2} : " << star.get_omega_c() / |
| 387 |
sqrt( ggrav * rho_c ) << endl ; |
| 388 |
|
| 389 |
cout << "M rho0^{1/2} : " << star.mass_g() * pow(ggrav,1.5) * |
| 390 |
sqrt( rho_c ) << endl ; |
| 391 |
|
| 392 |
cout << "M_B rho0^{1/2} : " << star.mass_b() * pow(ggrav,1.5) * |
| 393 |
sqrt( rho_c ) << endl ; |
| 394 |
|
| 395 |
cout << "R_circ rho0^{1/2} : " << star.r_circ() * |
| 396 |
sqrt( ggrav * rho_c ) << endl ; |
| 397 |
|
| 398 |
cout << "J rho0 : " << star.angu_mom() * ggrav * ggrav * rho_c << endl ; |
| 399 |
|
| 400 |
cout << "Z_p : " << star.z_pole() << endl ; |
| 401 |
cout << "Z_eq^f : " << star.z_eqf() << endl ; |
| 402 |
cout << "Z_eq^b : " << star.z_eqb() << endl ; |
| 403 |
|
| 404 |
cout << "GRV2: " << star.grv2() << endl ; |
| 405 |
cout << "GRV3: " << star.grv3() << endl ; |
| 406 |
|
| 407 |
double vit_triax = diff(7) ; |
| 408 |
|
| 409 |
//----------------------------------------------- |
| 410 |
// General features of the final configuration |
| 411 |
// saved in a file |
| 412 |
//----------------------------------------------- |
| 413 |
|
| 414 |
ofstream fichfinal("result.txt") ; |
| 415 |
fichfinal.precision(10) ; |
| 416 |
|
| 417 |
if ( star.is_relativistic() ) { |
| 418 |
fichfinal << "Relativistic computation" << endl ; |
| 419 |
} |
| 420 |
else { |
| 421 |
fichfinal << "Newtonian computation" << endl ; |
| 422 |
} |
| 423 |
|
| 424 |
fichfinal << star.get_eos() << endl ; |
| 425 |
|
| 426 |
fichfinal << endl << "Total CPU time : " << endl ; |
| 427 |
fichfinal << "Memory size : " << endl << endl ; |
| 428 |
|
| 429 |
fichfinal << endl << endl ; |
| 430 |
fichfinal << "Grid : " << endl ; |
| 431 |
fichfinal << "------ " << endl ; |
| 432 |
fichfinal << *(star.get_mp().get_mg()) << endl ; |
| 433 |
fichfinal << endl << "Physical characteristics : " << endl ; |
| 434 |
fichfinal << "-------------------------" << endl ; |
| 435 |
fichfinal << star << endl ; |
| 436 |
fichfinal << "Growing rate of triaxial perturbation: " << vit_triax |
| 437 |
<< endl ; |
| 438 |
|
| 439 |
fichfinal << endl << |
| 440 |
"===================================================================" |
| 441 |
<< endl ; |
| 442 |
fichfinal << "Diff_ent : " << diff(0) << endl ; |
| 443 |
fichfinal << "Relative error on the virial theorem GRV2 : " |
| 444 |
<< star.grv2() << endl ; |
| 445 |
fichfinal << "Relative error on the virial theorem GRV3 : " |
| 446 |
<< star.grv3() << endl ; |
| 447 |
|
| 448 |
fichfinal << endl << |
| 449 |
"================================================================" << endl ; |
| 450 |
fichfinal << |
| 451 |
" PARAMETERS USED FOR THE COMPUTATION (file parrot.d) : " << endl ; |
| 452 |
fichfinal << |
| 453 |
"================================================================" << endl ; |
| 454 |
fichfinal.close() ; |
| 455 |
system("cat par_rot.d >> result.txt") ; |
| 456 |
|
| 457 |
fichfinal.open("result.txt", ios::app) ; |
| 458 |
fichfinal << endl << |
| 459 |
"================================================================" << endl ; |
| 460 |
fichfinal << |
| 461 |
" EOS PARAMETERS (file par_eos.d) : " << endl ; |
| 462 |
fichfinal << |
| 463 |
"================================================================" << endl ; |
| 464 |
fichfinal.close() ; |
| 465 |
system("cat par_eos.d >> result.txt") ; |
| 466 |
|
| 467 |
// Identification du code et de ses sous-routines (no. de version RCS) : |
| 468 |
fichfinal.open("result.txt", ios::app) ; |
| 469 |
fichfinal << endl << |
| 470 |
"================================================================" << endl ; |
| 471 |
fichfinal << " IDENTIFICATION OF THE CODE : " << endl ; |
| 472 |
fichfinal << |
| 473 |
"================================================================" << endl ; |
| 474 |
fichfinal.close() ; |
| 475 |
system("ident nrotstar >> result.txt") ; |
| 476 |
|
| 477 |
|
| 478 |
// Saveguard of the whole configuration |
| 479 |
// ------------------------------------ |
| 480 |
|
| 481 |
FILE* fresu = fopen("resu.d", "w") ; |
| 482 |
|
| 483 |
star.get_mp().get_mg()->sauve(fresu) ; // writing of the grid |
| 484 |
star.get_mp().sauve(fresu) ; // writing of the mapping |
| 485 |
star.get_eos().sauve(fresu) ; // writing of the EOS |
| 486 |
star.sauve(fresu) ; // writing of the star |
| 487 |
|
| 488 |
fclose(fresu) ; |
| 489 |
|
| 490 |
// Drawings |
| 491 |
// -------- |
| 492 |
|
| 493 |
ofstream fichdes("prof_n.d") ; |
| 494 |
fichdes.precision(10) ; |
| 495 |
fichdes << "# r [km] N(theta=0) N(theta=pi/2)" << endl ; |
| 496 |
int npd = 300 ; |
| 497 |
double r_max = 3 ; |
| 498 |
double h = r_max/double(npd-1) ; |
| 499 |
for (int i=0; i<npd; i++) { |
| 500 |
double rr = h * i ; |
| 501 |
fichdes << rr*10 << " " |
| 502 |
<< star.get_nn().val_point(rr,0.,0.) << " " |
| 503 |
<< star.get_nn().val_point(rr, M_PI/2.,0.) << endl ; |
| 504 |
} |
| 505 |
fichdes.close() ; |
| 506 |
|
| 507 |
fichdes.open("prof_omega.d") ; |
| 508 |
fichdes.precision(10) ; |
| 509 |
fichdes << "# r [km] omega(theta=0) omega(theta=pi/2)" << endl ; |
| 510 |
for (int i=0; i<npd; i++) { |
| 511 |
double rr = h * i ; |
| 512 |
fichdes << rr*10 << " " |
| 513 |
<< star.get_nphi().val_point(rr,0.,0.) << " " |
| 514 |
<< star.get_nphi().val_point(rr, M_PI/2.,0.) << endl ; |
| 515 |
} |
| 516 |
fichdes.close() ; |
| 517 |
|
| 518 |
fichdes.open("prof_omega.d") ; |
| 519 |
fichdes.precision(10) ; |
| 520 |
fichdes << "# r [km] omega(theta=0)/Omega omega(theta=pi/2)/Omega" << endl ; |
| 521 |
double omega_rot = star.get_omega_c() ; |
| 522 |
if (omega_rot == double(0)) omega_rot = 1 ; |
| 523 |
for (int i=0; i<npd; i++) { |
| 524 |
double rr = h * i ; |
| 525 |
fichdes << rr*10 << " " |
| 526 |
<< star.get_nphi().val_point(rr,0.,0.) / omega_rot << " " |
| 527 |
<< star.get_nphi().val_point(rr, M_PI/2.,0.) / omega_rot << endl ; |
| 528 |
} |
| 529 |
fichdes.close() ; |
| 530 |
|
| 531 |
fichdes.open("prof_a.d") ; |
| 532 |
fichdes.precision(10) ; |
| 533 |
fichdes << "# r [km] A(theta=0) A(theta=pi/2)" << endl ; |
| 534 |
for (int i=0; i<npd; i++) { |
| 535 |
double rr = h * i ; |
| 536 |
fichdes << rr*10 << " " |
| 537 |
<< sqrt( star.get_a_car().val_point(rr,0.,0.) ) << " " |
| 538 |
<< sqrt( star.get_a_car().val_point(rr, M_PI/2.,0.) ) << endl ; |
| 539 |
} |
| 540 |
fichdes.close() ; |
| 541 |
|
| 542 |
fichdes.open("prof_bma.d") ; |
| 543 |
fichdes.precision(10) ; |
| 544 |
fichdes << "# r [km] B-A(theta=0) B-A(theta=pi/2)" << endl ; |
| 545 |
for (int i=0; i<npd; i++) { |
| 546 |
double rr = h * i ; |
| 547 |
fichdes << rr*10 << " " |
| 548 |
<< sqrt( star.get_b_car().val_point(rr,0.,0.) ) |
| 549 |
- sqrt( star.get_a_car().val_point(rr,0.,0.) ) << " " |
| 550 |
<< sqrt( star.get_b_car().val_point(rr, M_PI/2.,0.) ) |
| 551 |
- sqrt( star.get_a_car().val_point(rr, M_PI/2.,0.) ) << endl ; |
| 552 |
} |
| 553 |
fichdes.close() ; |
| 554 |
|
| 555 |
fichdes.open("prof_ener.d") ; |
| 556 |
fichdes.precision(10) ; |
| 557 |
fichdes << "# r [km] ener(theta=0) ener(theta=pi/2)" << endl ; |
| 558 |
for (int i=0; i<npd; i++) { |
| 559 |
double rr = h * i ; |
| 560 |
fichdes << rr*10 << " " |
| 561 |
<< star.get_ener().val_point(rr,0.,0.) << " " |
| 562 |
<< star.get_ener().val_point(rr, M_PI/2.,0.) << endl ; |
| 563 |
} |
| 564 |
fichdes.close() ; |
| 565 |
|
| 566 |
fichdes.open("prof_h.d") ; |
| 567 |
fichdes.precision(10) ; |
| 568 |
fichdes << "# r [km] H(theta=0) H(theta=pi/2)" << endl ; |
| 569 |
for (int i=0; i<npd; i++) { |
| 570 |
double rr = h * i ; |
| 571 |
fichdes << rr*10 << " " |
| 572 |
<< star.get_ent().val_point(rr,0.,0.) << " " |
| 573 |
<< star.get_ent().val_point(rr, M_PI/2.,0.) << endl ; |
| 574 |
} |
| 575 |
fichdes.close() ; |
| 576 |
|
| 577 |
fichdes.open("prof_u.d") ; |
| 578 |
fichdes.precision(10) ; |
| 579 |
fichdes << "# r [km] U(theta=0)/c U(theta=pi/2)/c" << endl ; |
| 580 |
for (int i=0; i<npd; i++) { |
| 581 |
double rr = h * i ; |
| 582 |
fichdes << rr*10 << " " |
| 583 |
<< star.get_uuu().val_point(rr,0.,0.) << " " |
| 584 |
<< star.get_uuu().val_point(rr, M_PI/2.,0.) << endl ; |
| 585 |
} |
| 586 |
fichdes.close() ; |
| 587 |
|
| 588 |
|
| 589 |
if (graph == 1) { |
| 590 |
|
| 591 |
char title[80] ; |
| 592 |
char bslash[2] = {92, '\0'} ; // 92 is the ASCII code for backslash |
| 593 |
|
| 594 |
// Scalar defining the surface of the star (via the enthalpy field) |
| 595 |
Scalar surf( star.get_ent() ); |
| 596 |
Scalar surf_ext(mp) ; |
| 597 |
surf_ext = - 0.2 * surf.val_grid_point(0, 0, 0, 0) ; |
| 598 |
surf_ext.annule(0, star.get_nzet()-1) ; |
| 599 |
surf.annule(star.get_nzet(), mg.get_nzone()-1) ; |
| 600 |
surf = surf + surf_ext ; |
| 601 |
surf = raccord_c1(surf, star.get_nzet()) ; |
| 602 |
|
| 603 |
int nzdes = star.get_nzet() ; |
| 604 |
|
| 605 |
des_coupe_y(star.get_ent(), 0., nzdes, "Log-enthalpy", &surf) ; |
| 606 |
|
| 607 |
cout << endl << "Plot of the coefficients of the cos(j theta) expansion of the function G(theta) defining the stellar surface:" << endl ; |
| 608 |
des_map_et(mp, star.get_nzet()-1) ; |
| 609 |
|
| 610 |
des_coupe_y(star.get_ener(), 0., nzdes, "Fluid Proper energy density", &surf) ; |
| 611 |
|
| 612 |
if (mer_triax < mer_max) { |
| 613 |
des_coupe_z(star.get_ent(), 0., nzdes, "Log-enthalpy (equatorial plane)", |
| 614 |
&surf) ; |
| 615 |
} |
| 616 |
|
| 617 |
char partit[] = {92, 'g', 'n', '\0'} ; |
| 618 |
strcpy(title, "Gravitational potential ") ; |
| 619 |
strcat(title, partit) ; |
| 620 |
|
| 621 |
des_coupe_y(star.get_logn(), 0., nzdes, title, &surf) ; |
| 622 |
|
| 623 |
|
| 624 |
strcpy(title, "Azimuthal shift N") ; |
| 625 |
strcat(title, bslash) ; |
| 626 |
strcat(title, "u") ; |
| 627 |
strcat(title, bslash) ; |
| 628 |
strcat(title, "gf") ; |
| 629 |
des_coupe_y(star.get_nphi(), 0., nzdes, title, &surf) ; |
| 630 |
|
| 631 |
strcpy(title, "Metric potential ") ; |
| 632 |
strcat(title, bslash) ; |
| 633 |
strcat(title, "gz") ; |
| 634 |
des_coupe_y(star.get_dzeta(), 0., nzdes, title, &surf) ; |
| 635 |
|
| 636 |
strcpy(title, "Metric potential (NB-1) r sin") ; |
| 637 |
strcat(title, bslash) ; |
| 638 |
strcat(title, "gh") ; |
| 639 |
des_coupe_y(star.get_tggg(), 0., nzdes, title, &surf) ; |
| 640 |
|
| 641 |
char debtit[] = {'A', 92, 'u', '2', 92, 'd', ' ', 'K', 92, 'u', '\0'} ; |
| 642 |
strcpy(title, debtit) ; |
| 643 |
strcat(title, "ij") ; |
| 644 |
strcat(title, bslash) ; |
| 645 |
strcat(title, "d K") ; |
| 646 |
strcat(title, bslash) ; |
| 647 |
strcat(title, "dij") ; |
| 648 |
strcat(title, bslash) ; |
| 649 |
strcat(title, "u") ; |
| 650 |
|
| 651 |
des_coupe_y(star.get_ak_car(), 0., nzdes, title, &surf) ; |
| 652 |
|
| 653 |
} |
| 654 |
|
| 655 |
ofstream seq("seq.d", ios::app) ; |
| 656 |
seq << star.get_ent().val_grid_point(0,0,0,0) << " " << star.mass_g() / msol |
| 657 |
<< " " << qpig/(4.*M_PI) * star.mass_g() / star.r_circ() << endl ; |
| 658 |
|
| 659 |
seq.close() ; |
| 660 |
|
| 661 |
|
| 662 |
// Output file for GYOTO |
| 663 |
//---------------------- |
| 664 |
|
| 665 |
// Shift vector on spherical triad --> beta |
| 666 |
Scalar beta_phi = - star.get_nphi() ; // beta^phi = - N^phi |
| 667 |
Vector beta(star.get_mp(), CON, star.get_mp().get_bvect_spher()) ; |
| 668 |
beta.set(1) = 0 ; |
| 669 |
beta.set(2) = 0 ; |
| 670 |
Scalar tmp = beta_phi ; |
| 671 |
tmp.mult_rsint() ; |
| 672 |
beta.set(3) = tmp ; |
| 673 |
|
| 674 |
// Extrinsic curvature --> kk |
| 675 |
Scalar nn = star.get_nn() ; |
| 676 |
Scalar bb2 = star.get_b_car() ; |
| 677 |
Sym_tensor kk(star.get_mp(), COV, star.get_mp().get_bvect_spher()) ; |
| 678 |
kk.set(1,1) = 0 ; |
| 679 |
kk.set(1,2) = 0 ; |
| 680 |
tmp = 0.5 * bb2 * beta_phi.dsdr() / nn ; |
| 681 |
tmp.mult_rsint() ; |
| 682 |
kk.set(1,3) = tmp ; |
| 683 |
kk.set(2,2) = 0 ; |
| 684 |
tmp = 0.5 * bb2 * beta_phi.dsdt() / nn ; |
| 685 |
tmp.mult_sint() ; |
| 686 |
kk.set(2,3) = tmp ; |
| 687 |
kk.set(3,3) = 0 ; |
| 688 |
|
| 689 |
// File for GYOTO |
| 690 |
FILE* file_out = fopen("resu_gyoto.d", "w") ; |
| 691 |
double total_time = 0. ; // for compatibility |
| 692 |
fwrite_be(&total_time, sizeof(double), 1, file_out) ; |
| 693 |
star.get_mp().get_mg()->sauve(file_out) ; |
| 694 |
star.get_mp().sauve(file_out) ; |
| 695 |
star.get_nn().sauve(file_out) ; |
| 696 |
beta.sauve(file_out) ; |
| 697 |
star.get_gamma().cov().sauve(file_out) ; |
| 698 |
star.get_gamma().con().sauve(file_out) ; |
| 699 |
kk.sauve(file_out) ; |
| 700 |
// aa = c J / (G M^2) |
| 701 |
double aa = star.angu_mom()/( qpig / (4* M_PI) * pow(star.mass_g(), 2.) ) ; |
| 702 |
fwrite_be(&aa, sizeof(double), 1, file_out) ; |
| 703 |
fclose(file_out) ; |
| 704 |
|
| 705 |
// Cleaning |
| 706 |
// -------- |
| 707 |
|
| 708 |
delete peos ; |
| 709 |
|
| 710 |
exit(EXIT_SUCCESS) ; |
| 711 |
|
| 712 |
return EXIT_SUCCESS ; |
| 713 |
|
| 714 |
} |