| 1 |
/* |
| 2 |
* Main code for computing a sequence of stationary axisymmetric differentially |
| 3 |
* rotating stars |
| 4 |
*/ |
| 5 |
|
| 6 |
/* |
| 7 |
* Copyright (c) 2001-2003 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 rotseq_C[] = "$Header: /cvsroot/Lorene/Codes/Rot_star/rotseq.C,v 1.10 2014/10/13 08:53:58 j_novak Exp $" ; |
| 28 |
|
| 29 |
/* |
| 30 |
* $Id: rotseq.C,v 1.10 2014/10/13 08:53:58 j_novak Exp $ |
| 31 |
* $Log: rotseq.C,v $ |
| 32 |
* Revision 1.10 2014/10/13 08:53:58 j_novak |
| 33 |
* Lorene classes and functions now belong to the namespace Lorene. |
| 34 |
* |
| 35 |
* Revision 1.9 2014/10/06 15:09:45 j_novak |
| 36 |
* Modified #include directives to use c++ syntax. |
| 37 |
* |
| 38 |
* Revision 1.8 2004/03/25 12:35:44 j_novak |
| 39 |
* now using namespace Unites |
| 40 |
* |
| 41 |
* Revision 1.7 2003/09/16 13:06:24 e_gourgoulhon |
| 42 |
* Replaced the fich.getline(blabla, 120) by fich.ignore(1000, '\n') |
| 43 |
* |
| 44 |
* Revision 1.6 2003/08/26 08:58:50 e_gourgoulhon |
| 45 |
* |
| 46 |
* Added M/R and quantities in polytropic units in the |
| 47 |
* output file res.d |
| 48 |
* |
| 49 |
* Revision 1.5 2003/05/25 19:56:49 e_gourgoulhon |
| 50 |
* |
| 51 |
* Added the possibility to choose the factor a = R_eq / R0, instead of R0 |
| 52 |
* in the differential rotation law. |
| 53 |
* |
| 54 |
* Revision 1.4 2003/05/14 20:06:09 e_gourgoulhon |
| 55 |
* Suppressed the qualifier ios::nocreate in call to fstream::open |
| 56 |
* (not supported by gcc 3.2). |
| 57 |
* |
| 58 |
* Revision 1.3 2003/01/09 11:07:50 j_novak |
| 59 |
* headcpp.h is now compliant with C++ norm. |
| 60 |
* The include files have been ordered, as well as the local_settings_linux |
| 61 |
* |
| 62 |
* Revision 1.2 2002/03/27 22:00:23 e_gourgoulhon |
| 63 |
* Now can computes sequences of rigidly rotating stars (class Etoile_rot) |
| 64 |
* as well as differentially rotating stars (class Et_rot_diff) |
| 65 |
* |
| 66 |
* Revision 1.1.1.1 2001/11/20 15:19:31 e_gourgoulhon |
| 67 |
* LORENE |
| 68 |
* |
| 69 |
* Revision 1.1 2001/10/26 17:02:18 eric |
| 70 |
* Initial revision |
| 71 |
* |
| 72 |
* |
| 73 |
* $Header: /cvsroot/Lorene/Codes/Rot_star/rotseq.C,v 1.10 2014/10/13 08:53:58 j_novak Exp $ |
| 74 |
* |
| 75 |
*/ |
| 76 |
|
| 77 |
|
| 78 |
// headers C |
| 79 |
#include <cstdlib> |
| 80 |
#include <cmath> |
| 81 |
#include <cstring> |
| 82 |
|
| 83 |
// headers Lorene |
| 84 |
#include "et_rot_diff.h" |
| 85 |
#include "eos.h" |
| 86 |
#include "utilitaires.h" |
| 87 |
#include "graphique.h" |
| 88 |
#include "nbr_spx.h" |
| 89 |
#include "unites.h" |
| 90 |
|
| 91 |
// Function defining the rotation profile |
| 92 |
double frotlin(double omega, const Lorene::Tbl& par) ; |
| 93 |
double primfrotlin(double omega, const Lorene::Tbl& par) ; |
| 94 |
|
| 95 |
namespace Lorene { |
| 96 |
// Local prototype (for drawings only) |
| 97 |
Cmp raccord_c1(const Cmp& uu, int l1) ; |
| 98 |
} |
| 99 |
//****************************************************************************** |
| 100 |
|
| 101 |
|
| 102 |
using namespace Lorene ; |
| 103 |
|
| 104 |
int main(){ |
| 105 |
|
| 106 |
using namespace Unites ; |
| 107 |
|
| 108 |
// For the display : |
| 109 |
char display_bold[]="x[1m" ; display_bold[0] = 27 ; |
| 110 |
|
| 111 |
//------------------------------------------------------------------ |
| 112 |
// Parameters of the computation |
| 113 |
//------------------------------------------------------------------ |
| 114 |
|
| 115 |
int relat_i, mer_max, mer_rot, mer_change_omega, mer_fix_omega, |
| 116 |
delta_mer_kep, mer_mass, mermax_poisson, graph, nz, nzet, nzadapt, |
| 117 |
nt, np, mer_triax, n_conf, diffrot_i ; |
| 118 |
double entc_min, entc_max, fact_omega, mbar_wanted, precis, freq_min_si, |
| 119 |
freq_max_si, thres_adapt, aexp_mass, relax, relax_poisson, |
| 120 |
ampli_triax, precis_adapt, rrot_km, arot ; |
| 121 |
|
| 122 |
ifstream fich("parrotseq.d") ; |
| 123 |
if ( !fich.good() ) { |
| 124 |
cout << "Problem with opening the file parrotseq.d ! " << endl ; |
| 125 |
abort() ; |
| 126 |
} |
| 127 |
|
| 128 |
fich.ignore(1000,'\n') ; |
| 129 |
fich >> relat_i ; fich.ignore(1000,'\n') ; |
| 130 |
bool relat = (relat_i == 1) ; |
| 131 |
fich >> entc_min ; fich.ignore(1000,'\n') ; |
| 132 |
fich >> entc_max ; fich.ignore(1000,'\n') ; |
| 133 |
fich >> freq_min_si ; fich.ignore(1000,'\n') ; |
| 134 |
fich >> freq_max_si ; fich.ignore(1000,'\n') ; |
| 135 |
fich >> n_conf ; fich.ignore(1000,'\n') ; |
| 136 |
if (n_conf > 1000) { |
| 137 |
cout << "rotseq: n_conf must be smaller than 1000" << endl ; |
| 138 |
abort() ; |
| 139 |
} |
| 140 |
|
| 141 |
fich >> diffrot_i ; fich.ignore(1000,'\n'); |
| 142 |
if (diffrot_i <= 1) { |
| 143 |
fich >> rrot_km ; fich.ignore(1000,'\n'); |
| 144 |
arot = 0 ; |
| 145 |
} |
| 146 |
else { |
| 147 |
assert (diffrot_i == 2) ; |
| 148 |
fich >> arot ; fich.ignore(1000,'\n'); |
| 149 |
rrot_km = 0 ; |
| 150 |
} |
| 151 |
|
| 152 |
fact_omega = 1 ; |
| 153 |
fich >> mbar_wanted ; fich.ignore(1000,'\n'); |
| 154 |
mbar_wanted *= msol ; |
| 155 |
fich.ignore(1000,'\n'); |
| 156 |
fich >> mer_max ; fich.ignore(1000,'\n'); |
| 157 |
fich >> precis ; fich.ignore(1000,'\n'); |
| 158 |
mer_rot = 0 ; |
| 159 |
mer_change_omega = 0 ; |
| 160 |
mer_fix_omega = 1 ; |
| 161 |
delta_mer_kep = 0 ; |
| 162 |
fich >> thres_adapt ; fich.ignore(1000,'\n'); |
| 163 |
mer_triax = 100000 ; |
| 164 |
ampli_triax = 0 ; |
| 165 |
fich >> mer_mass ; fich.ignore(1000,'\n'); |
| 166 |
fich >> aexp_mass ; fich.ignore(1000,'\n'); |
| 167 |
fich >> relax ; fich.ignore(1000,'\n'); |
| 168 |
fich >> mermax_poisson ; fich.ignore(1000,'\n'); |
| 169 |
fich >> relax_poisson ; fich.ignore(1000,'\n'); |
| 170 |
fich >> precis_adapt ; fich.ignore(1000,'\n'); |
| 171 |
fich >> graph ; fich.ignore(1000,'\n'); |
| 172 |
fich.ignore(1000,'\n'); |
| 173 |
fich >> nz ; fich.ignore(1000,'\n') ; |
| 174 |
fich >> nzet; fich.ignore(1000,'\n') ; |
| 175 |
fich >> nzadapt; fich.ignore(1000,'\n') ; |
| 176 |
fich >> nt; fich.ignore(1000,'\n') ; |
| 177 |
fich >> np; fich.ignore(1000,'\n') ; |
| 178 |
|
| 179 |
int* nr = new int[nz]; |
| 180 |
int* nt_tab = new int[nz]; |
| 181 |
int* np_tab = new int[nz]; |
| 182 |
double* bornes = new double[nz+1]; |
| 183 |
|
| 184 |
fich.ignore(1000,'\n') ; |
| 185 |
for (int l=0; l<nz; l++) { |
| 186 |
fich >> nr[l]; |
| 187 |
fich >> bornes[l]; fich.ignore(1000,'\n'); |
| 188 |
np_tab[l] = np ; |
| 189 |
nt_tab[l] = nt ; |
| 190 |
} |
| 191 |
bornes[nz] = __infinity ; |
| 192 |
|
| 193 |
Tbl ent_limit(nzet) ; |
| 194 |
ent_limit.set_etat_qcq() ; |
| 195 |
ent_limit.set(nzet-1) = 0 ; // enthalpy at the stellar surface |
| 196 |
for (int l=0; l<nzet-1; l++) { |
| 197 |
fich >> ent_limit.set(l) ; fich.ignore(1000,'\n'); |
| 198 |
} |
| 199 |
|
| 200 |
|
| 201 |
fich.close(); |
| 202 |
|
| 203 |
|
| 204 |
//----------------------------------------------------------------------- |
| 205 |
// Equation of state |
| 206 |
//----------------------------------------------------------------------- |
| 207 |
|
| 208 |
fich.open("par_eos.d") ; |
| 209 |
|
| 210 |
Eos* peos = Eos::eos_from_file(fich) ; |
| 211 |
Eos& eos = *peos ; |
| 212 |
|
| 213 |
fich.close() ; |
| 214 |
|
| 215 |
|
| 216 |
// Special treatment of crust - liquid core boundary in the case |
| 217 |
// of Eos_strange |
| 218 |
if (eos.identify() == 6) { |
| 219 |
assert( nzet == 2 ) ; |
| 220 |
const Eos_strange_cr* peos_cr = dynamic_cast<const Eos_strange_cr*>(peos) ; |
| 221 |
if (peos_cr == 0x0) { |
| 222 |
cout << "rotseq: problem : peos is not of type Eos_strange_cr !" << endl ; |
| 223 |
abort() ; |
| 224 |
} |
| 225 |
|
| 226 |
ent_limit.set(0) = peos_cr->get_ent_nd() ; // enthalpy at core/crust transition |
| 227 |
|
| 228 |
} |
| 229 |
|
| 230 |
//----------------------------------------------------------------------- |
| 231 |
// Construction of the multi-grid and the mapping |
| 232 |
//----------------------------------------------------------------------- |
| 233 |
|
| 234 |
// Rescale of bornes in the case where there more than 1 domain inside |
| 235 |
// the star |
| 236 |
|
| 237 |
for (int l=0; l<nzet-1; l++) { |
| 238 |
|
| 239 |
bornes[l+1] = bornes[nzet] * sqrt(1 - ent_limit(l) / entc_min) ; |
| 240 |
|
| 241 |
} |
| 242 |
|
| 243 |
// Type of r sampling : |
| 244 |
int* type_r = new int[nz]; |
| 245 |
type_r[0] = RARE ; |
| 246 |
for (int l=1; l<nz-1; l++) { |
| 247 |
type_r[l] = FIN ; |
| 248 |
} |
| 249 |
type_r[nz-1] = UNSURR ; |
| 250 |
|
| 251 |
// Type of sampling in theta and phi : |
| 252 |
int type_t = SYM ; |
| 253 |
int type_p = SYM ; |
| 254 |
|
| 255 |
Mg3d mg(nz, nr, type_r, nt_tab, type_t, np_tab, type_p) ; |
| 256 |
|
| 257 |
Map_et mp(mg, bornes) ; |
| 258 |
|
| 259 |
// Cleaning |
| 260 |
// -------- |
| 261 |
|
| 262 |
delete [] nr ; |
| 263 |
delete [] nt_tab ; |
| 264 |
delete [] np_tab ; |
| 265 |
delete [] type_r ; |
| 266 |
delete [] bornes ; |
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
cout << endl |
| 271 |
<< "==========================================================" << endl |
| 272 |
<< " Physical parameters " << endl |
| 273 |
<< "==========================================================" |
| 274 |
<< endl ; |
| 275 |
cout << endl ; |
| 276 |
|
| 277 |
cout << endl << "Equation of state : " |
| 278 |
<< endl << "================= " << endl ; |
| 279 |
cout << eos << endl ; |
| 280 |
|
| 281 |
cout << "Central enthalpy range: " << entc_min << " - " << entc_max << " c^2" << endl ; |
| 282 |
cout << "Rotation frequency range : " << freq_min_si |
| 283 |
<< " - " << freq_max_si << " Hz" << endl ; |
| 284 |
if ( abs(mer_mass) < mer_max ) { |
| 285 |
cout << "Required Baryon mass [M_sol] : " |
| 286 |
<< mbar_wanted / msol << endl ; |
| 287 |
} |
| 288 |
|
| 289 |
|
| 290 |
cout << endl |
| 291 |
<< "==========================================================" << endl |
| 292 |
<< " Computational parameters " << endl |
| 293 |
<< "==========================================================" |
| 294 |
<< endl << endl ; |
| 295 |
|
| 296 |
cout << "Maximum number of steps in the main iteration : " |
| 297 |
<< mer_max << endl ; |
| 298 |
cout << "Relaxation factor in the main iteration : " |
| 299 |
<< relax << endl ; |
| 300 |
cout << "Threshold on the enthalpy relative change for ending the computation : " |
| 301 |
<< precis << endl ; |
| 302 |
cout << "Maximum number of steps in Map_et::poisson : " |
| 303 |
<< mermax_poisson << endl ; |
| 304 |
cout << "Relaxation factor in Map_et::poisson : " |
| 305 |
<< relax_poisson << endl ; |
| 306 |
cout << "Step from which the baryon mass is forced to converge : " |
| 307 |
<< mer_mass << endl ; |
| 308 |
cout << "Exponent for the increase factor of the central enthalpy or frequency : " |
| 309 |
<< aexp_mass << endl ; |
| 310 |
cout << |
| 311 |
"Threshold on |dH/dr|_eq / |dH/dr|_pole for the adaptation of the mapping" |
| 312 |
<< endl << thres_adapt << endl ; |
| 313 |
|
| 314 |
|
| 315 |
cout << endl << "Multi-grid : " |
| 316 |
<< endl << "==========" << endl << mg << endl ; |
| 317 |
cout << "Mapping : " |
| 318 |
<< endl << "=======" << endl << mp << endl ; |
| 319 |
|
| 320 |
|
| 321 |
//----------------------------------------------------------------------- |
| 322 |
// Parameters for the function defining the differential rotation |
| 323 |
//----------------------------------------------------------------------- |
| 324 |
|
| 325 |
double omega_c_min = 2 * M_PI * freq_min_si / f_unit ; |
| 326 |
double omega_c_max = 2 * M_PI * freq_max_si / f_unit ; |
| 327 |
|
| 328 |
double rrot = rrot_km * km ; |
| 329 |
|
| 330 |
Tbl parfrot(3) ; |
| 331 |
parfrot.set_etat_qcq() ; |
| 332 |
parfrot.set(0) = 0 ; |
| 333 |
parfrot.set(1) = rrot ; |
| 334 |
parfrot.set(2) = arot ; |
| 335 |
|
| 336 |
//----------------------------------------------------------------------- |
| 337 |
// Construction of the star |
| 338 |
//----------------------------------------------------------------------- |
| 339 |
|
| 340 |
bool diffrot = (diffrot_i >= 1) ; |
| 341 |
Etoile_rot* p_star ; |
| 342 |
Et_rot_diff* p_star_diff = 0x0 ; |
| 343 |
|
| 344 |
if ( diffrot ) { |
| 345 |
p_star_diff = new Et_rot_diff(mp, nzet, relat, eos, frotlin, primfrotlin, parfrot) ; |
| 346 |
p_star = p_star_diff ; |
| 347 |
} |
| 348 |
else { |
| 349 |
p_star = new Etoile_rot(mp, nzet, relat, eos) ; |
| 350 |
} |
| 351 |
Etoile_rot& star = *p_star ; |
| 352 |
|
| 353 |
if ( star.is_relativistic() ) { |
| 354 |
cout << "========================" << endl ; |
| 355 |
cout << "Relativistic computation" << endl ; |
| 356 |
cout << "========================" << endl ; |
| 357 |
} |
| 358 |
else { |
| 359 |
cout << "=====================" << endl ; |
| 360 |
cout << "Newtonian computation" << endl ; |
| 361 |
cout << "=====================" << endl ; |
| 362 |
} |
| 363 |
|
| 364 |
//----------------------------------------------------------------------- |
| 365 |
// Initialization of the enthalpy field |
| 366 |
//----------------------------------------------------------------------- |
| 367 |
|
| 368 |
|
| 369 |
const Coord& r = mp.r ; |
| 370 |
double ray0 = mp.val_r(nzet-1, 1., 0., 0.) ; |
| 371 |
Cmp ent0(mp) ; |
| 372 |
ent0 = entc_min * ( 1 - r*r / (ray0*ray0) ) ; |
| 373 |
ent0.annule(nz-1) ; |
| 374 |
ent0.std_base_scal() ; |
| 375 |
star.set_enthalpy(ent0) ; |
| 376 |
|
| 377 |
// Initialization of (n,e,p) from H |
| 378 |
star.equation_of_state() ; |
| 379 |
|
| 380 |
// Initialization of (E,S,U,etc...) (quantities relative to the Eulerian obs) |
| 381 |
star.hydro_euler() ; |
| 382 |
|
| 383 |
cout << endl << "Initial star : " |
| 384 |
<< endl << "============ " << endl ; |
| 385 |
|
| 386 |
cout << star << endl ; |
| 387 |
|
| 388 |
//--------------------------------------------------- |
| 389 |
// Sequence parameters saved in file "calcul_seq.d" |
| 390 |
//--------------------------------------------------- |
| 391 |
ofstream fichseq("calcul_seq.d") ; |
| 392 |
fichseq << endl << |
| 393 |
"================================================================" << endl ; |
| 394 |
fichseq << |
| 395 |
" PARAMETERS USED FOR THE COMPUTATION (file parrotseq.d) : " << endl ; |
| 396 |
fichseq << |
| 397 |
"================================================================" << endl ; |
| 398 |
fichseq.close() ; |
| 399 |
system("cat parrotseq.d >> calcul_seq.d") ; |
| 400 |
|
| 401 |
fichseq.open("calcul_seq.d", ios::app) ; |
| 402 |
fichseq << endl << |
| 403 |
"================================================================" << endl ; |
| 404 |
fichseq << |
| 405 |
" EOS PARAMETERS (file par_eos.d) : " << endl ; |
| 406 |
fichseq << |
| 407 |
"================================================================" << endl ; |
| 408 |
fichseq.close() ; |
| 409 |
system("cat par_eos.d >> calcul_seq.d") ; |
| 410 |
|
| 411 |
// Identification du code et de ses sous-routines (no. de version RCS) : |
| 412 |
fichseq.open("calcul_seq.d", ios::app) ; |
| 413 |
fichseq << endl << |
| 414 |
"================================================================" << endl ; |
| 415 |
fichseq << " IDENTIFICATION OF THE CODE : " << endl ; |
| 416 |
fichseq << |
| 417 |
"================================================================" << endl ; |
| 418 |
fichseq.close() ; |
| 419 |
system("ident rotseq >> calcul_seq.d") ; |
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
//----------------------------------------------------------------------- |
| 424 |
// Computation of the equilibrium sequence |
| 425 |
//----------------------------------------------------------------------- |
| 426 |
|
| 427 |
|
| 428 |
Itbl icontrol(8) ; |
| 429 |
icontrol.set_etat_qcq() ; |
| 430 |
icontrol.set(0) = mer_max ; |
| 431 |
icontrol.set(1) = mer_rot ; |
| 432 |
icontrol.set(2) = mer_change_omega ; |
| 433 |
icontrol.set(3) = mer_fix_omega ; |
| 434 |
// icontrol.set(4) set later |
| 435 |
icontrol.set(5) = mermax_poisson ; |
| 436 |
icontrol.set(6) = mer_triax ; |
| 437 |
icontrol.set(7) = delta_mer_kep ; |
| 438 |
|
| 439 |
Tbl control(7) ; |
| 440 |
control.set_etat_qcq() ; |
| 441 |
control.set(0) = precis ; |
| 442 |
control.set(2) = relax ; |
| 443 |
control.set(3) = relax_poisson ; |
| 444 |
control.set(4) = thres_adapt ; |
| 445 |
control.set(5) = ampli_triax ; |
| 446 |
control.set(6) = precis_adapt ; |
| 447 |
|
| 448 |
Tbl diff(8) ; |
| 449 |
|
| 450 |
ofstream fichresu("seq.d") ; |
| 451 |
fichresu << "# M/R M [poly] M_B [poly] J [G M_sol^2/c] M [M_sol] f_c [Hz] H_c r_p/r_e" |
| 452 |
<< " T/W M_B [M_sol] GRV2 GRV3 " << endl ; |
| 453 |
|
| 454 |
// Loop on the configurations |
| 455 |
// -------------------------- |
| 456 |
|
| 457 |
bool seq_freq = ( entc_min == entc_max ) ; |
| 458 |
if ( !seq_freq ) { |
| 459 |
if ( omega_c_min != omega_c_max ) { |
| 460 |
cout << "rotseq : one must have freq_min == freq_max " |
| 461 |
<< "when entc_min != entc_max !" << endl ; |
| 462 |
abort() ; |
| 463 |
} |
| 464 |
} |
| 465 |
|
| 466 |
double domega = (n_conf > 1) ? |
| 467 |
(omega_c_max - omega_c_min) / double(n_conf-1) : 0 ; |
| 468 |
double dent = (n_conf > 1) ? (entc_max - entc_min) / double(n_conf-1) : 0 ; |
| 469 |
|
| 470 |
for (int jj = 0; jj < n_conf; jj++) { |
| 471 |
|
| 472 |
double omega_c, ent_c ; |
| 473 |
|
| 474 |
if ( seq_freq ) { |
| 475 |
|
| 476 |
icontrol.set(4) = mer_mass ; |
| 477 |
|
| 478 |
ent_c = star.get_ent()()(0, 0, 0, 0) ; |
| 479 |
omega_c = omega_c_min + jj * domega ; |
| 480 |
} |
| 481 |
else { |
| 482 |
|
| 483 |
icontrol.set(4) = - mer_mass ; |
| 484 |
|
| 485 |
ent_c = entc_min + jj * dent ; |
| 486 |
omega_c = star.get_omega_c() ; |
| 487 |
if (omega_c == double(0)) { |
| 488 |
omega_c = omega_c_min ; |
| 489 |
icontrol.set(1) = 10 ; // mer_rot = 10 |
| 490 |
icontrol.set(2) = 10 ; |
| 491 |
icontrol.set(3) = 11 ; |
| 492 |
} |
| 493 |
else { |
| 494 |
icontrol.set(1) = 0 ; // mer_rot = 0 |
| 495 |
icontrol.set(2) = 0 ; |
| 496 |
icontrol.set(3) = 1 ; |
| 497 |
} |
| 498 |
} |
| 499 |
|
| 500 |
control.set(1) = omega_c ; |
| 501 |
|
| 502 |
star.equilibrium(ent_c, omega_c, fact_omega, nzadapt, ent_limit, |
| 503 |
icontrol, control, mbar_wanted, aexp_mass, diff) ; |
| 504 |
|
| 505 |
|
| 506 |
const Eos_poly* p_eos_poly = dynamic_cast<const Eos_poly*>( |
| 507 |
&(star.get_eos()) ) ; |
| 508 |
|
| 509 |
double mass_g_poly, mass_b_poly ; |
| 510 |
if (p_eos_poly != 0x0) { |
| 511 |
|
| 512 |
double kappa = p_eos_poly->get_kap() ; |
| 513 |
double gamma = p_eos_poly->get_gam() ; ; |
| 514 |
|
| 515 |
// kappa^{n/2} |
| 516 |
double kap_ns2 = pow( kappa, 0.5 /(gamma-1) ) ; |
| 517 |
|
| 518 |
// Polytropic unit of length in terms of r_unit : |
| 519 |
double r_poly = kap_ns2 / sqrt(ggrav) ; |
| 520 |
|
| 521 |
// Polytropic unit of mass in terms of m_unit : |
| 522 |
double m_poly = r_poly / ggrav ; |
| 523 |
|
| 524 |
mass_g_poly = star.mass_g() / m_poly ; |
| 525 |
mass_b_poly = star.mass_b() / m_poly ; |
| 526 |
|
| 527 |
} |
| 528 |
else{ |
| 529 |
mass_g_poly = 0 ; |
| 530 |
mass_b_poly = 0 ; |
| 531 |
} |
| 532 |
|
| 533 |
|
| 534 |
int precisaff = 8 ; |
| 535 |
int tailleaff = precisaff + 3 ; |
| 536 |
fichresu.precision(precisaff) ; |
| 537 |
fichresu << setw(tailleaff) |
| 538 |
<< ggrav * star.mass_g() / star.r_circ() << " " |
| 539 |
<< setw(tailleaff) |
| 540 |
<< mass_g_poly << " " |
| 541 |
<< setw(tailleaff) |
| 542 |
<< mass_b_poly << " " |
| 543 |
<< setw(tailleaff) |
| 544 |
<< star.angu_mom()/( qpig / (4* M_PI) * msol*msol) << " " |
| 545 |
<< setw(tailleaff) |
| 546 |
<< star.mass_g() / msol << " " |
| 547 |
<< setw(tailleaff) |
| 548 |
<< star.get_omega_c() / (2.*M_PI) * f_unit << " " |
| 549 |
<< setw(tailleaff) |
| 550 |
<< star.get_ent()()(0, 0, 0, 0) << " " |
| 551 |
<< setw(tailleaff) |
| 552 |
<< star.aplat() << " " |
| 553 |
<< setw(tailleaff) |
| 554 |
<< star.tsw() << " " |
| 555 |
<< setw(tailleaff) |
| 556 |
<< star.mass_b() / msol << " " |
| 557 |
<< setw(tailleaff) |
| 558 |
<< star.grv2() << " " |
| 559 |
<< setw(tailleaff) |
| 560 |
<< star.grv3() << endl ; |
| 561 |
|
| 562 |
cout << endl << "Configuration " << jj << " : " |
| 563 |
<< endl << "===========================" << endl ; |
| 564 |
|
| 565 |
cout.precision(10) ; |
| 566 |
cout << star << endl ; |
| 567 |
|
| 568 |
//----------------------------------------------- |
| 569 |
// General features of the final configuration |
| 570 |
// saved in a file |
| 571 |
//----------------------------------------------- |
| 572 |
|
| 573 |
char nomfich[20] ; |
| 574 |
strcpy(nomfich, "calcul") ; |
| 575 |
|
| 576 |
char numero[3] ; |
| 577 |
sprintf(numero, "%3.3d", jj) ; |
| 578 |
strcat(nomfich, numero) ; |
| 579 |
strcat(nomfich, ".d") ; |
| 580 |
cout << endl << "File name : " << nomfich << endl ; |
| 581 |
|
| 582 |
ofstream fichfinal(nomfich) ; |
| 583 |
fichfinal.precision(10) ; |
| 584 |
|
| 585 |
if ( star.is_relativistic() ) { |
| 586 |
fichfinal << "Relativistic computation" << endl ; |
| 587 |
} |
| 588 |
else { |
| 589 |
fichfinal << "Newtonian computation" << endl ; |
| 590 |
} |
| 591 |
|
| 592 |
fichfinal << star.get_eos() << endl ; |
| 593 |
|
| 594 |
fichfinal << endl << "Total CPU time : " << endl ; |
| 595 |
fichfinal << "Memory size : " << endl << endl ; |
| 596 |
|
| 597 |
fichfinal << endl << endl ; |
| 598 |
fichfinal << "Grid : " << endl ; |
| 599 |
fichfinal << "------ " << endl ; |
| 600 |
fichfinal << *(star.get_mp().get_mg()) << endl ; |
| 601 |
fichfinal << endl << "Physical characteristics : " << endl ; |
| 602 |
fichfinal << "-------------------------" << endl ; |
| 603 |
fichfinal << star << endl ; |
| 604 |
fichfinal << "Growing rate of triaxial perturbation: 0 " << endl ; |
| 605 |
|
| 606 |
fichfinal << endl << |
| 607 |
"===================================================================" |
| 608 |
<< endl ; |
| 609 |
fichfinal << "Diff_ent : " << diff(0) << endl ; |
| 610 |
fichfinal << "Relative error on the virial theorem GRV2 : " |
| 611 |
<< star.grv2() << endl ; |
| 612 |
fichfinal << "Relative error on the virial theorem GRV3 : " |
| 613 |
<< star.grv3() << endl ; |
| 614 |
|
| 615 |
fichfinal.close() ; |
| 616 |
|
| 617 |
|
| 618 |
|
| 619 |
|
| 620 |
// Drawings |
| 621 |
// -------- |
| 622 |
|
| 623 |
if (graph == 1) { |
| 624 |
|
| 625 |
des_map_et(mp, 0) ; |
| 626 |
|
| 627 |
// Cmp defining the surface of the star (via the enthalpy field) |
| 628 |
Cmp surf = star.get_ent()() ; |
| 629 |
Cmp surf_ext(mp) ; |
| 630 |
surf_ext = - 0.2 * surf(0, 0, 0, 0) ; |
| 631 |
surf_ext.annule(0, star.get_nzet()-1) ; |
| 632 |
surf.annule(star.get_nzet(), mg.get_nzone()-1) ; |
| 633 |
surf = surf + surf_ext ; |
| 634 |
surf = raccord_c1(surf, star.get_nzet()) ; |
| 635 |
|
| 636 |
int nzdes = star.get_nzet() ; |
| 637 |
|
| 638 |
des_coupe_y(star.get_ent()(), 0., nzdes, "Enthalpy", &surf) ; |
| 639 |
|
| 640 |
if (mer_triax < mer_max) { |
| 641 |
des_coupe_z(star.get_ent()(), 0., nzdes, "Enthalpy (equatorial plane)", |
| 642 |
&surf) ; |
| 643 |
} |
| 644 |
|
| 645 |
if (diffrot) { |
| 646 |
Cmp tmpdes = p_star_diff->get_omega_field()() / (2*M_PI) * f_unit ; |
| 647 |
des_profile(tmpdes, 0., star.ray_eq(), |
| 648 |
M_PI/2., 0., "\\gW/2\\gp [Hz]", |
| 649 |
"Angular velocity in equatorial plane") ; |
| 650 |
|
| 651 |
des_coupe_y(p_star_diff->get_omega_field()(), 0., nzdes, |
| 652 |
"\\gW", &surf) ; |
| 653 |
} |
| 654 |
|
| 655 |
des_coupe_y(star.get_logn()(), 0., nzdes, |
| 656 |
"Gravitational potential \\gn", &surf) ; |
| 657 |
|
| 658 |
if (star.is_relativistic()) { |
| 659 |
|
| 660 |
des_coupe_y(star.get_nphi()(), 0., nzdes, |
| 661 |
"Azimuthal shift N\\u\\gf", &surf) ; |
| 662 |
|
| 663 |
des_coupe_y(star.get_dzeta()(), 0., nzdes, |
| 664 |
"Metric potential \\gz", &surf) ; |
| 665 |
|
| 666 |
des_coupe_y(star.get_tggg()(), 0., nzdes, |
| 667 |
"Metric potential (NB-1) r sin\\gh", &surf) ; |
| 668 |
|
| 669 |
des_coupe_y(star.get_ak_car()(), 0., nzdes, |
| 670 |
"A\\u2\\d K\\dij\\u K\\uij\\d", &surf) ; |
| 671 |
} |
| 672 |
|
| 673 |
} |
| 674 |
|
| 675 |
|
| 676 |
} // End of the loop on the configurations |
| 677 |
|
| 678 |
fichresu.close() ; |
| 679 |
|
| 680 |
// Cleaning |
| 681 |
// -------- |
| 682 |
|
| 683 |
delete p_star ; |
| 684 |
|
| 685 |
delete peos ; |
| 686 |
|
| 687 |
exit(EXIT_SUCCESS) ; |
| 688 |
|
| 689 |
return EXIT_SUCCESS ; |
| 690 |
|
| 691 |
} |
| 692 |
|
| 693 |
//------------------------------// |
| 694 |
// Function F(Omega) // |
| 695 |
//------------------------------// |
| 696 |
|
| 697 |
double frotlin(double omega, const Tbl& par){ |
| 698 |
|
| 699 |
double omega_c = par(0) ; |
| 700 |
double rrot = par(1) ; |
| 701 |
|
| 702 |
return rrot*rrot* (omega_c - omega) ; |
| 703 |
|
| 704 |
} |
| 705 |
|
| 706 |
//------------------------------// |
| 707 |
// Primitive of F(Omega) // |
| 708 |
//------------------------------// |
| 709 |
|
| 710 |
double primfrotlin(double omega, const Tbl& par){ |
| 711 |
|
| 712 |
double omega_c = par(0) ; |
| 713 |
double rrot = par(1) ; |
| 714 |
|
| 715 |
return - 0.5 * rrot*rrot* (omega_c - omega)*(omega_c - omega) ; |
| 716 |
|
| 717 |
} |