1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693
|
/*
* Methods of class Etoile
*
* (see file etoile.h for documentation)
*/
/*
* Copyright (c) 2000-2001 Eric Gourgoulhon
* Copyright (c) 2000-2001 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 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 etoile_C[] = "$Header: /cvsroot/Lorene/C++/Source/Etoile/etoile.C,v 1.10 2014/10/13 08:52:58 j_novak Exp $" ;
/*
* $Id: etoile.C,v 1.10 2014/10/13 08:52:58 j_novak Exp $
* $Log: etoile.C,v $
* Revision 1.10 2014/10/13 08:52:58 j_novak
* Lorene classes and functions now belong to the namespace Lorene.
*
* Revision 1.9 2012/08/12 17:48:35 p_cerda
* Magnetstar: New classes for magnetstar. Allowing for non-equatorial symmetry in Etoile et al. Adding B_phi in Et_rot_mag.
*
* Revision 1.8 2005/01/18 22:36:50 k_taniguchi
* Delete a pointer for ray_eq(int kk).
*
* Revision 1.7 2005/01/18 20:35:05 k_taniguchi
* Addition of ray_eq(int kk).
*
* Revision 1.6 2005/01/17 20:40:25 k_taniguchi
* Addition of ray_eq_3pis2().
*
* Revision 1.5 2004/03/25 10:29:06 j_novak
* All LORENE's units are now defined in the namespace Unites (in file unites.h).
*
* Revision 1.4 2003/10/13 15:23:56 f_limousin
* *** empty log message ***
*
* Revision 1.3 2002/04/09 14:32:15 e_gourgoulhon
* 1/ Added extra parameters in EOS computational functions (argument par)
* 2/ New class MEos for multi-domain EOS
*
* Revision 1.2 2001/12/04 21:27:53 e_gourgoulhon
*
* All writing/reading to a binary file are now performed according to
* the big endian convention, whatever the system is big endian or
* small endian, thanks to the functions fwrite_be and fread_be
*
* Revision 1.1.1.1 2001/11/20 15:19:28 e_gourgoulhon
* LORENE
*
* Revision 2.14 2000/11/24 13:27:44 eric
* Dans eqution_of_state(): changement leger de ent dans le cas ou l'on a
* deux domaine avant d'appeler l'EOS.
*
* Revision 2.13 2000/09/25 12:22:02 keisuke
* *** empty log message ***
*
* Revision 2.12 2000/09/22 15:50:58 keisuke
* Ajout du membre d_logn_auto_div.
*
* Revision 2.11 2000/09/07 14:34:09 keisuke
* Ajout du membre logn_auto_regu.
*
* Revision 2.10 2000/08/31 15:36:54 eric
* Bases spectrales standards pour nnn, a_car et gam_euler dans le
* constructeur (initialisation a la metrique plate).
*
* Revision 2.9 2000/08/29 11:37:49 eric
* Ajout des membres k_div et logn_auto_div.
*
* Revision 2.8 2000/07/21 12:01:11 eric
* Modif dans Etoile::del_deriv() :
* appel de Etoile::set_der_0x0() et non de la fonction virtuelle set_der_0x0().
*
* Revision 2.7 2000/03/21 12:39:34 eric
* Le constructeur standard teste la compatibilite de l'EOS avec le
* caractere relativiste de l'etoile.
*
* Revision 2.6 2000/02/21 14:32:40 eric
* gam_euler est initialise a 1 dans le constructeur standard.
* Suppression de l'appel a del_hydro_euler dans equation_of_state().
*
* Revision 2.5 2000/02/09 19:30:47 eric
* La triade de decomposition doit desormais figurer en argument des
* constructeurs de Tenseur.
*
* Revision 2.4 2000/02/02 09:23:34 eric
* Affichage de la masse.
*
* Revision 2.3 2000/01/28 17:18:10 eric
* Modifs noms des quantites globales.
* Affichage.
*
* Revision 2.2 2000/01/24 17:13:36 eric
* Le mapping mp n'est plus constant.
*
* Revision 2.1 2000/01/24 13:37:22 eric
* *** empty log message ***
*
* Revision 2.0 2000/01/20 17:04:45 eric
* *** empty log message ***
*
*
* $Header: /cvsroot/Lorene/C++/Source/Etoile/etoile.C,v 1.10 2014/10/13 08:52:58 j_novak Exp $
*
*/
// Headers C
#include "math.h"
// Headers Lorene
#include "etoile.h"
#include "eos.h"
#include "utilitaires.h"
#include "param.h"
#include "unites.h"
//--------------//
// Constructors //
//--------------//
// Standard constructor
// --------------------
namespace Lorene {
Etoile::Etoile(Map& mpi, int nzet_i, bool relat, const Eos& eos_i)
: mp(mpi),
nzet(nzet_i),
relativistic(relat),
k_div(0),
eos(eos_i),
ent(mpi),
nbar(mpi),
ener(mpi),
press(mpi),
ener_euler(mpi),
s_euler(mpi),
gam_euler(mpi),
u_euler(mpi, 1, CON, mp.get_bvect_cart()),
logn_auto(mpi),
logn_auto_regu(mpi),
logn_auto_div(mpi),
d_logn_auto_div(mpi, 1, COV, mp.get_bvect_spher()),
beta_auto(mpi),
nnn(mpi),
shift(mpi, 1, CON, mp.get_bvect_cart()),
a_car(mpi) {
// Check of the EOS
const Eos_poly* p_eos_poly = dynamic_cast<const Eos_poly*>( &eos ) ;
const Eos_poly_newt* p_eos_poly_newt =
dynamic_cast<const Eos_poly_newt*>( &eos ) ;
const Eos_incomp* p_eos_incomp = dynamic_cast<const Eos_incomp*>( &eos ) ;
const Eos_incomp_newt* p_eos_incomp_newt =
dynamic_cast<const Eos_incomp_newt*>( &eos ) ;
if (relativistic) {
if (p_eos_poly_newt != 0x0) {
cout <<
"Etoile::Etoile : the EOS Eos_poly_newt must not be employed"
<< " for a relativistic star ! " << endl ;
cout << "(Use Eos_poly instead)" << endl ;
abort() ;
}
if (p_eos_incomp_newt != 0x0) {
cout <<
"Etoile::Etoile : the EOS Eos_incomp_newt must not be employed"
<< " for a relativistic star ! " << endl ;
cout << "(Use Eos_incomp instead)" << endl ;
abort() ;
}
}
else{
if ( (p_eos_poly != 0x0) && (p_eos_poly_newt == 0x0) ) {
cout <<
"Etoile::Etoile : the EOS Eos_poly must not be employed"
<< " for a Newtonian star ! " << endl ;
cout << "(Use Eos_poly_newt instead)" << endl ;
abort() ;
}
if ( (p_eos_incomp != 0x0) && (p_eos_incomp_newt == 0x0) ) {
cout <<
"Etoile::Etoile : the EOS Eos_incomp must not be employed"
<< " for a relativistic star ! " << endl ;
cout << "(Use Eos_incomp_newt instead)" << endl ;
abort() ;
}
}
// Parameter 1/c^2
unsurc2 = relativistic ? double(1) : double(0) ;
// Pointers of derived quantities initialized to zero :
set_der_0x0() ;
// All the matter quantities are initialized to zero :
nbar = 0 ;
ener = 0 ;
press = 0 ;
ent = 0 ;
ener_euler = 0 ;
s_euler = 0 ;
gam_euler = 1 ;
gam_euler.set_std_base() ;
u_euler = 0 ;
// The metric is initialized to the flat one :
logn_auto = 0 ;
logn_auto_regu = 0 ;
logn_auto_div = 0 ;
d_logn_auto_div = 0 ;
beta_auto = 0 ;
nnn = 1 ;
nnn.set_std_base() ;
shift = 0 ;
a_car = 1 ;
a_car.set_std_base() ;
}
// Copy constructor
// ----------------
Etoile::Etoile(const Etoile& et)
: mp(et.mp),
nzet(et.nzet),
relativistic(et.relativistic),
unsurc2(et.unsurc2),
k_div(et.k_div),
eos(et.eos),
ent(et.ent),
nbar(et.nbar),
ener(et.ener),
press(et.press),
ener_euler(et.ener_euler),
s_euler(et.s_euler),
gam_euler(et.gam_euler),
u_euler(et.u_euler),
logn_auto(et.logn_auto),
logn_auto_regu(et.logn_auto_regu),
logn_auto_div(et.logn_auto_div),
d_logn_auto_div(et.d_logn_auto_div),
beta_auto(et.beta_auto),
nnn(et.nnn),
shift(et.shift),
a_car(et.a_car) {
set_der_0x0() ;
}
// Constructor from a file
// -----------------------
Etoile::Etoile(Map& mpi, const Eos& eos_i, FILE* fich)
: mp(mpi),
eos(eos_i),
ent(mpi),
nbar(mpi),
ener(mpi),
press(mpi),
ener_euler(mpi),
s_euler(mpi),
gam_euler(mpi),
u_euler(mpi, 1, CON, mp.get_bvect_cart()),
logn_auto(mpi),
logn_auto_regu(mpi),
logn_auto_div(mpi),
d_logn_auto_div(mpi, 1, COV, mp.get_bvect_spher()),
beta_auto(mpi),
nnn(mpi),
shift(mpi, 1, CON, mp.get_bvect_cart()),
a_car(mpi) {
// Etoile parameters
// -----------------
// nzet and relativistic are read in the file:
int xx ;
fread_be(&xx, sizeof(int), 1, fich) ;
k_div = xx / 1000 ; // integer part
nzet = xx - k_div * 1000 ;
fread(&relativistic, sizeof(bool), 1, fich) ;
// Parameter 1/c^2 is deduced from relativistic:
unsurc2 = relativistic ? double(1) : double(0) ;
// Equation of state
// -----------------
// Read of the saved EOS
Eos* p_eos_file = Eos::eos_from_file(fich) ;
// Comparison with the assigned EOS:
if (eos != *p_eos_file) {
cout <<
"Etoile::Etoile(const Map&, const Eos&, FILE*) : the EOS given in "
<< endl <<
" argument and that read in the file are different !" << endl ;
abort() ;
}
// p_eos_file is no longer required (it was used only for checking the
// EOS compatibility)
delete p_eos_file ;
// Read of the saved fields:
// ------------------------
Tenseur ent_file(mp, fich) ;
ent = ent_file ;
Tenseur logn_auto_file(mp, fich) ;
logn_auto = logn_auto_file ;
Tenseur beta_auto_file(mp, fich) ;
beta_auto = beta_auto_file ;
if (k_div == 0) {
logn_auto_div = 0 ;
d_logn_auto_div = 0 ;
}
else {
Tenseur logn_auto_div_file(mp, fich) ;
logn_auto_div = logn_auto_div_file ;
Tenseur d_logn_auto_div_file(mp, mp.get_bvect_spher(), fich) ;
d_logn_auto_div = d_logn_auto_div_file ;
}
logn_auto_regu = logn_auto - logn_auto_div ;
shift = 0 ;
// Pointers of derived quantities initialized to zero
// --------------------------------------------------
set_der_0x0() ;
}
//------------//
// Destructor //
//------------//
Etoile::~Etoile(){
del_deriv() ;
}
//----------------------------------//
// Management of derived quantities //
//----------------------------------//
void Etoile::del_deriv() const {
if (p_mass_b != 0x0) delete p_mass_b ;
if (p_mass_g != 0x0) delete p_mass_g ;
if (p_ray_eq != 0x0) delete p_ray_eq ;
if (p_ray_eq_pis2 != 0x0) delete p_ray_eq_pis2 ;
if (p_ray_eq_pi != 0x0) delete p_ray_eq_pi ;
if (p_ray_eq_3pis2 != 0x0) delete p_ray_eq_3pis2 ;
if (p_ray_pole != 0x0) delete p_ray_pole ;
if (p_l_surf != 0x0) delete p_l_surf ;
if (p_xi_surf != 0x0) delete p_xi_surf ;
Etoile::set_der_0x0() ;
}
void Etoile::set_der_0x0() const {
p_mass_b = 0x0 ;
p_mass_g = 0x0 ;
p_ray_eq = 0x0 ;
p_ray_eq_pis2 = 0x0 ;
p_ray_eq_pi = 0x0 ;
p_ray_eq_3pis2 = 0x0 ;
p_ray_pole = 0x0 ;
p_l_surf = 0x0 ;
p_xi_surf = 0x0 ;
}
void Etoile::del_hydro_euler() {
ener_euler.set_etat_nondef() ;
s_euler.set_etat_nondef() ;
gam_euler.set_etat_nondef() ;
u_euler.set_etat_nondef() ;
del_deriv() ;
}
//--------------//
// Assignment //
//--------------//
// Assignment to another Etoile
// ----------------------------
void Etoile::operator=(const Etoile& et) {
assert( &(et.mp) == &mp ) ; // Same mapping
assert( &(et.eos) == &eos ) ; // Same EOS
nzet = et.nzet ;
relativistic = et.relativistic ;
k_div = et.k_div ;
unsurc2 = et.unsurc2 ;
ent = et.ent ;
nbar = et.nbar ;
ener = et.ener ;
press = et.press ;
ener_euler = et.ener_euler ;
s_euler = et.s_euler ;
gam_euler = et.gam_euler ;
u_euler = et.u_euler ;
logn_auto = et.logn_auto ;
logn_auto_regu = et.logn_auto_regu ;
logn_auto_div = et.logn_auto_div ;
d_logn_auto_div = et.d_logn_auto_div ;
beta_auto = et.beta_auto ;
nnn = et.nnn ;
shift = et.shift ;
a_car = et.a_car ;
del_deriv() ; // Deletes all derived quantities
}
// Assignment of the enthalpy field
// --------------------------------
void Etoile::set_enthalpy(const Cmp& ent_i) {
ent = ent_i ;
// Update of (nbar, ener, press) :
equation_of_state() ;
// The derived quantities are obsolete:
del_deriv() ;
}
//--------------//
// Outputs //
//--------------//
// Save in a file
// --------------
void Etoile::sauve(FILE* fich) const {
int xx = nzet + k_div * 1000 ;
fwrite_be(&xx, sizeof(int), 1, fich) ;
fwrite(&relativistic, sizeof(bool), 1, fich) ;
eos.sauve(fich) ;
ent.sauve(fich) ;
logn_auto.sauve(fich) ;
beta_auto.sauve(fich) ;
if (k_div != 0) {
logn_auto_div.sauve(fich) ;
d_logn_auto_div.sauve(fich) ;
}
}
// Printing
// --------
ostream& operator<<(ostream& ost, const Etoile& et) {
et >> ost ;
return ost ;
}
ostream& Etoile::operator>>(ostream& ost) const {
using namespace Unites ;
ost << endl ;
if (relativistic) {
ost << "Relativistic star" << endl ;
ost << "-----------------" << endl ;
}
else {
ost << "Newtonian star" << endl ;
ost << "--------------" << endl ;
}
ost << "Number of domains occupied by the star : " << nzet << endl ;
ost << "Equation of state : " << endl ;
ost << eos << endl ;
ost << endl << "Central enthalpy : " << ent()(0,0,0,0) << " c^2" << endl ;
ost << "Central proper baryon density : " << nbar()(0,0,0,0)
<< " x 0.1 fm^-3" << endl ;
ost << "Central proper energy density : " << ener()(0,0,0,0)
<< " rho_nuc c^2" << endl ;
ost << "Central pressure : " << press()(0,0,0,0)
<< " rho_nuc c^2" << endl ;
ost << endl
<< "Regularization index of the gravitational potential : k_div = "
<< k_div << endl ;
ost << "Central lapse N : " << nnn()(0,0,0,0) << endl ;
ost << "Central value of A^2 : " << a_car()(0,0,0,0) << endl ;
ost << endl
<< "Coordinate equatorial radius (phi=0) a1 = "
<< ray_eq()/km << " km" << endl ;
ost << "Coordinate equatorial radius (phi=pi/2) a2 = "
<< ray_eq_pis2()/km << " km" << endl ;
ost << "Coordinate equatorial radius (phi=pi): "
<< ray_eq_pi()/km << " km" << endl ;
ost << "Coordinate polar radius a3 = "
<< ray_pole()/km << " km" << endl ;
ost << "Axis ratio a2/a1 = " << ray_eq_pis2() / ray_eq()
<< " a3/a1 = " << ray_pole() / ray_eq() << endl ;
ost << endl << "Baryon mass : " << mass_b() / msol << " M_sol" << endl ;
ost << "Gravitational mass : " << mass_g() / msol << " M_sol" << endl ;
return ost ;
}
//-----------------------------------------//
// Computation of hydro quantities //
//-----------------------------------------//
void Etoile::equation_of_state() {
Cmp ent_eos = ent() ;
// Slight rescale of the enthalpy field in case of 2 domains inside the
// star
double epsilon = 1.e-12 ;
const Mg3d* mg = mp.get_mg() ;
int nz = mg->get_nzone() ;
Mtbl xi(mg) ;
xi.set_etat_qcq() ;
for (int l=0; l<nz; l++) {
xi.t[l]->set_etat_qcq() ;
for (int k=0; k<mg->get_np(l); k++) {
for (int j=0; j<mg->get_nt(l); j++) {
for (int i=0; i<mg->get_nr(l); i++) {
xi.set(l,k,j,i) =
mg->get_grille3d(l)->x[i] ;
}
}
}
}
Cmp fact_ent(mp) ;
fact_ent.allocate_all() ;
fact_ent.set(0) = 1 + epsilon * xi(0) * xi(0) ;
fact_ent.set(1) = 1 - 0.25 * epsilon * (xi(1) - 1) * (xi(1) - 1) ;
for (int l=nzet; l<nz; l++) {
fact_ent.set(l) = 1 ;
}
if (nzet > 1) {
if(nzet == 3) {
fact_ent.set(1) = 1 - 0.5 * epsilon * (xi(1) - 0.5) * (xi(1) - 0.5) ;
fact_ent.set(2) = 1 - 0.25 * epsilon * (xi(2) - 1) * (xi(2) - 1) ;
}
if (nzet > 3) {
cout << "Etoile::equation_of_state: not ready yet for nzet > 3 !"
<< endl ;
}
ent_eos = fact_ent * ent_eos ;
ent_eos.std_base_scal() ;
}
// Call to the EOS (the EOS is called domain by domain in order to
// allow for the use of MEos)
Cmp tempo(mp) ;
nbar.set_etat_qcq() ;
nbar.set() = 0 ;
for (int l=0; l<nzet; l++) {
Param par ; // Paramater for multi-domain equation of state
par.add_int(l) ;
tempo = eos.nbar_ent(ent_eos, 1, l, &par) ;
nbar = nbar() + tempo ;
}
ener.set_etat_qcq() ;
ener.set() = 0 ;
for (int l=0; l<nzet; l++) {
Param par ; // Paramater for multi-domain equation of state
par.add_int(l) ;
tempo = eos.ener_ent(ent_eos, 1, l, &par) ;
ener = ener() + tempo ;
}
press.set_etat_qcq() ;
press.set() = 0 ;
for (int l=0; l<nzet; l++) {
Param par ; // Paramater for multi-domain equation of state
par.add_int(l) ;
tempo = eos.press_ent(ent_eos, 1, l, &par) ;
press = press() + tempo ;
}
// Set the bases for spectral expansion
nbar.set_std_base() ;
ener.set_std_base() ;
press.set_std_base() ;
// The Eulerian quantities are obsolete
//## del_hydro_euler() ;
// The derived quantities are obsolete
del_deriv() ;
}
void Etoile::hydro_euler() {
cout <<
"Etoile::hydro_euler : hydro_euler must be called via a derived class"
<< endl << " of Etoile !" << endl ;
abort() ;
}
}
|