| 1 |
/* |
| 2 |
* Computes the equilibrium configuration of a binary system. |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
/* |
| 7 |
* Copyright (c) 2000-2003 Eric Gourgoulhon |
| 8 |
* Copyright (c) 2001-2002 Keisuke Taniguchi |
| 9 |
* |
| 10 |
* This file is part of LORENE. |
| 11 |
* |
| 12 |
* LORENE is free software; you can redistribute it and/or modify |
| 13 |
* it under the terms of the GNU General Public License as published by |
| 14 |
* the Free Software Foundation; either version 2 of the License, or |
| 15 |
* (at your option) any later version. |
| 16 |
* |
| 17 |
* LORENE is distributed in the hope that it will be useful, |
| 18 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 |
* GNU General Public License for more details. |
| 21 |
* |
| 22 |
* You should have received a copy of the GNU General Public License |
| 23 |
* along with LORENE; if not, write to the Free Software |
| 24 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 25 |
* |
| 26 |
*/ |
| 27 |
|
| 28 |
char coal_C[] = "$Header: /cvsroot/Lorene/Codes/Bin_star/coal.C,v 1.16 2014/10/13 08:53:54 j_novak Exp $" ; |
| 29 |
|
| 30 |
/* |
| 31 |
* $Id: coal.C,v 1.16 2014/10/13 08:53:54 j_novak Exp $ |
| 32 |
* $Log: coal.C,v $ |
| 33 |
* Revision 1.16 2014/10/13 08:53:54 j_novak |
| 34 |
* Lorene classes and functions now belong to the namespace Lorene. |
| 35 |
* |
| 36 |
* Revision 1.15 2014/10/06 15:09:42 j_novak |
| 37 |
* Modified #include directives to use c++ syntax. |
| 38 |
* |
| 39 |
* Revision 1.14 2008/11/14 13:53:23 e_gourgoulhon |
| 40 |
* Introduced the arrays ent_limit to force the enthalpy values at the |
| 41 |
* boundaries between the domains inside the stars. |
| 42 |
* |
| 43 |
* Revision 1.13 2004/09/28 15:53:25 f_limousin |
| 44 |
* Improve the rescaling of the domains for nzone = 4 and nzone = 5. |
| 45 |
* |
| 46 |
* Revision 1.12 2004/03/25 12:35:36 j_novak |
| 47 |
* now using namespace Unites |
| 48 |
* |
| 49 |
* Revision 1.11 2003/10/24 13:28:51 e_gourgoulhon |
| 50 |
* Suppressed des_explorer. |
| 51 |
* |
| 52 |
* Revision 1.10 2003/10/24 13:26:39 e_gourgoulhon |
| 53 |
* Corrected error on reduce_shift (previously: it was read and not used !). |
| 54 |
* |
| 55 |
* Revision 1.9 2003/09/18 15:06:59 e_gourgoulhon |
| 56 |
* Added printing of date and host name in the header of the file calcul.d. |
| 57 |
* |
| 58 |
* Revision 1.8 2003/09/17 15:40:33 e_gourgoulhon |
| 59 |
* Test of good opening of the initial data file. |
| 60 |
* |
| 61 |
* Revision 1.7 2003/09/16 13:36:50 e_gourgoulhon |
| 62 |
* -- initial analytical shift decreased by a factor reduce_shift which |
| 63 |
* can be specified in the parcoal.d file (default value = 0.6) |
| 64 |
* -- replaced the fpar.getline(blabla, 120) by fpar.ignore(1000,'\n') |
| 65 |
* -- new output file "resformat.d" at the end of the computation for |
| 66 |
* formatted output of global quantities (to be read by external code) |
| 67 |
* |
| 68 |
* Revision 1.6 2003/09/08 12:06:20 e_gourgoulhon |
| 69 |
* Added the printing of the virial errors in the output file "calcul.d". |
| 70 |
* |
| 71 |
* Revision 1.5 2003/02/20 15:08:42 e_gourgoulhon |
| 72 |
* Suppressed the qualifier ios::nocreate in call to fstream::open |
| 73 |
* (not supported by gcc 3.2). |
| 74 |
* |
| 75 |
* Revision 1.4 2003/01/09 11:07:48 j_novak |
| 76 |
* headcpp.h is now compliant with C++ norm. |
| 77 |
* The include files have been ordered, as well as the local_settings_linux |
| 78 |
* |
| 79 |
* Revision 1.3 2002/12/11 13:53:01 k_taniguchi |
| 80 |
* Add "thres_adapt" to star 2, |
| 81 |
* and modify the part of "resize". |
| 82 |
* |
| 83 |
* Revision 1.2 2001/12/06 16:20:14 e_gourgoulhon |
| 84 |
* Return type of main changed from 'void' to 'int' |
| 85 |
* |
| 86 |
* Revision 1.1.1.1 2001/11/20 15:19:31 e_gourgoulhon |
| 87 |
* LORENE |
| 88 |
* |
| 89 |
* Revision 2.18 2001/08/07 09:51:33 keisuke |
| 90 |
* Change of the argument in Etoile_bin::equilibrium. |
| 91 |
* Addition of the procedure to calculate a factor for "resize". |
| 92 |
* |
| 93 |
* Revision 2.17 2001/03/20 16:03:22 keisuke |
| 94 |
* Translation of the origin of the absolute frame. |
| 95 |
* |
| 96 |
* Revision 2.16 2000/07/07 14:18:01 eric |
| 97 |
* Sortie des quantites en unites polytropiques dans calcul.d |
| 98 |
* (appel de la nouvelle fonction Binaire::display_poly). |
| 99 |
* |
| 100 |
* Revision 2.15 2000/07/06 10:06:35 eric |
| 101 |
* Ajout des parametres et de l'identification dans calcul.d |
| 102 |
* Creation du fichier identif.d pour l'identification du code. |
| 103 |
* |
| 104 |
* Revision 2.14 2000/05/25 15:19:55 eric |
| 105 |
* Adaptation du mapping gele (cusp). |
| 106 |
* |
| 107 |
* Revision 2.13 2000/03/29 09:13:35 eric |
| 108 |
* Suppression des appels aux routines de dessin (car probleme sur mesioc). |
| 109 |
* |
| 110 |
* Revision 2.12 2000/03/22 16:42:22 eric |
| 111 |
* Sortie des erreurs sur les equations de Poisson. |
| 112 |
* |
| 113 |
* Revision 2.11 2000/03/22 14:00:44 eric |
| 114 |
* Les sorties pour Explorer ne sont effectuees que si graph = 1. |
| 115 |
* |
| 116 |
* Revision 2.10 2000/03/22 13:56:41 eric |
| 117 |
* Changement de prototypage d'Etoile_bin:equilibrium: on passe desormais |
| 118 |
* le Tbl differ pour avoir en sortie des estimateurs d'erreur. |
| 119 |
* Reorganisation des fichiers log : introduction de resconv1 et resconv2 |
| 120 |
* |
| 121 |
* Revision 2.9 2000/03/22 11:08:00 eric |
| 122 |
* Reintroduction des messages Log RCS des versions 2.4-2.6 qui avaient |
| 123 |
* disparus. |
| 124 |
* / |
| 125 |
* |
| 126 |
* Revision 2.8 2000/03/20 14:25:33 eric |
| 127 |
* resviriel.d rebaptise resconver.d |
| 128 |
* Theoreme du viriel calcule a la fin et sorti dans calcul.d |
| 129 |
* Suppression de l'ecriture du mapping dans calcul.d |
| 130 |
* |
| 131 |
* Revision 2.7 2000/03/17 16:52:50 eric |
| 132 |
* Rajout des headers Id et Log qui avaient disparus. |
| 133 |
* |
| 134 |
* |
| 135 |
* Revision 2.6 |
| 136 |
* Mutliplication du shift analytique par un facteur 0.6 |
| 137 |
* Omega_initial donne par Binaire::analytical_omega(). |
| 138 |
* |
| 139 |
* Revision 2.5 |
| 140 |
* Introduction d'un shift analytique dans le cas ou le shift initial est nul |
| 141 |
* |
| 142 |
* Revision 2.4 |
| 143 |
* Sortie des log(diff_ent) et log(diff_masse). |
| 144 |
* |
| 145 |
* Revision 2.3 2000/02/22 16:58:15 eric |
| 146 |
* Ajout de la convergence vers une masse baryonique donnee. |
| 147 |
* |
| 148 |
* Revision 2.2 2000/02/21 16:47:27 eric |
| 149 |
* Appel de fait_d_psi avant hydro_euler. |
| 150 |
* Suppression dessin surface. |
| 151 |
* |
| 152 |
* Revision 2.1 2000/02/17 19:54:44 eric |
| 153 |
* Premiere version operationnelle ! |
| 154 |
* |
| 155 |
* Revision 2.0 2000/02/12 18:41:28 eric |
| 156 |
* *** empty log message *** |
| 157 |
* |
| 158 |
* |
| 159 |
* $Header: /cvsroot/Lorene/Codes/Bin_star/coal.C,v 1.16 2014/10/13 08:53:54 j_novak Exp $ |
| 160 |
* |
| 161 |
*/ |
| 162 |
|
| 163 |
// headers C |
| 164 |
#include <cstdlib> |
| 165 |
#include <cmath> |
| 166 |
#include <ctime> |
| 167 |
|
| 168 |
// headers Lorene |
| 169 |
#include "binaire.h" |
| 170 |
#include "eos.h" |
| 171 |
#include "utilitaires.h" |
| 172 |
#include "graphique.h" |
| 173 |
#include "unites.h" |
| 174 |
|
| 175 |
namespace Lorene { |
| 176 |
// Local prototype |
| 177 |
Cmp raccord_c1(const Cmp& uu, int l1) ; |
| 178 |
} |
| 179 |
//****************************************************************************** |
| 180 |
|
| 181 |
using namespace Lorene ; |
| 182 |
|
| 183 |
int main(){ |
| 184 |
|
| 185 |
using namespace Unites ; |
| 186 |
|
| 187 |
// Identification of all the subroutines called by the code : |
| 188 |
|
| 189 |
system("ident coal > identif.d") ; |
| 190 |
|
| 191 |
// For the display : |
| 192 |
char display_bold[]="x[1m" ; display_bold[0] = 27 ; |
| 193 |
char display_normal[] = "x[0m" ; display_normal[0] = 27 ; |
| 194 |
|
| 195 |
// To avoid some compilation warnings |
| 196 |
if (display_bold == 0x0) { |
| 197 |
cout << qpig << f_unit << mevpfm3 << endl ; |
| 198 |
} |
| 199 |
|
| 200 |
//------------------------------------------------------------------ |
| 201 |
// Parameters of the computation |
| 202 |
//------------------------------------------------------------------ |
| 203 |
|
| 204 |
char nomini[80] ; |
| 205 |
int mermax, mermax_eqb, prompt, graph, fmer_stop, fmer_save, mermax_poisson ; |
| 206 |
int mermax_potvit, mer_masse, fmer_upd_met, ind_rel_met ; |
| 207 |
double seuil, relax_poisson, relax_potvit, relax, aexp_masse ; |
| 208 |
double mbar_voulue[2], fact_separ, relax_met, relax_omeg ; |
| 209 |
double fact_omeg_min, fact_omeg_max, thres_adapt[2], reduce_shift ; |
| 210 |
|
| 211 |
ifstream fpar("parcoal.d") ; |
| 212 |
if ( !fpar.good() ) { |
| 213 |
cout << "Problem with opening the file parcoal.d ! " << endl ; |
| 214 |
abort() ; |
| 215 |
} |
| 216 |
fpar.ignore(1000, '\n') ; |
| 217 |
fpar.ignore(1000, '\n') ; |
| 218 |
fpar.getline(nomini, 80) ; |
| 219 |
fpar >> fact_separ ; fpar.ignore(1000, '\n'); |
| 220 |
fpar >> mbar_voulue[0] ; fpar.ignore(1000, '\n') ; |
| 221 |
fpar >> mbar_voulue[1] ; fpar.ignore(1000, '\n') ; |
| 222 |
mbar_voulue[0] *= msol ; |
| 223 |
mbar_voulue[1] *= msol ; |
| 224 |
fpar.ignore(1000, '\n') ; |
| 225 |
fpar >> mermax ; fpar.ignore(1000, '\n') ; |
| 226 |
fpar >> relax ; fpar.ignore(1000, '\n') ; |
| 227 |
fpar >> mermax_eqb ; fpar.ignore(1000, '\n') ; |
| 228 |
fpar >> prompt ; fpar.ignore(1000, '\n') ; |
| 229 |
fpar >> graph ; fpar.ignore(1000, '\n') ; |
| 230 |
fpar >> seuil ; fpar.ignore(1000, '\n') ; |
| 231 |
fpar >> fmer_stop ; fpar.ignore(1000, '\n') ; |
| 232 |
fpar >> fmer_save ; fpar.ignore(1000, '\n') ; |
| 233 |
fpar >> mermax_poisson ; fpar.ignore(1000, '\n') ; |
| 234 |
fpar >> relax_poisson ; fpar.ignore(1000, '\n') ; |
| 235 |
fpar >> mermax_potvit ; fpar.ignore(1000, '\n') ; |
| 236 |
fpar >> relax_potvit ; fpar.ignore(1000, '\n') ; |
| 237 |
fpar >> mer_masse ; fpar.ignore(1000, '\n') ; |
| 238 |
fpar >> aexp_masse ; fpar.ignore(1000, '\n') ; |
| 239 |
fpar >> fmer_upd_met ; fpar.ignore(1000, '\n'); |
| 240 |
fpar >> ind_rel_met ; fpar.ignore(1000, '\n'); |
| 241 |
fpar >> relax_met ; fpar.ignore(1000, '\n'); |
| 242 |
if (ind_rel_met == 0) relax_met = 1. ; |
| 243 |
fpar >> relax_omeg ; fpar.ignore(1000, '\n'); |
| 244 |
fpar >> fact_omeg_min ; fpar.ignore(1000, '\n'); |
| 245 |
fpar >> fact_omeg_max ; fpar.ignore(1000, '\n'); |
| 246 |
fpar >> thres_adapt[0] ; fpar.ignore(1000, '\n'); |
| 247 |
fpar >> thres_adapt[1] ; fpar.ignore(1000, '\n'); |
| 248 |
fpar >> reduce_shift ; |
| 249 |
if ( ! fpar.good() ) { // to ensure compatibility with old |
| 250 |
reduce_shift = 0.6 ; // parcoal.d files which did not had |
| 251 |
} // the reduce_shift line |
| 252 |
fpar.close() ; |
| 253 |
|
| 254 |
|
| 255 |
cout << endl |
| 256 |
<< "==========================================================" << endl |
| 257 |
<< " Physical parameters " << endl |
| 258 |
<< "==========================================================" |
| 259 |
<< endl ; |
| 260 |
cout << endl << endl ; |
| 261 |
cout << "File containing the initial conditions : " << nomini << endl ; |
| 262 |
cout << "Factor by which the initial separation will be multiplied : " |
| 263 |
<< fact_separ << endl ; |
| 264 |
if ( abs(mer_masse) < mermax ) { |
| 265 |
cout << "Baryon mass required for star 1 [M_sol] : " |
| 266 |
<< mbar_voulue[0] / msol << endl ; |
| 267 |
cout << "Baryon mass required for star 2 [M_sol] : " |
| 268 |
<< mbar_voulue[1] / msol << endl ; |
| 269 |
} |
| 270 |
cout << endl |
| 271 |
<< "==========================================================" << endl |
| 272 |
<< " Parameters of the computation " << endl |
| 273 |
<< "==========================================================" |
| 274 |
<< endl ; |
| 275 |
cout << "Maximum number of steps in the main iteration : " |
| 276 |
<< mermax << endl ; |
| 277 |
cout << "Relaxation factor in the main iteration : " |
| 278 |
<< relax << endl ; |
| 279 |
cout << "Maximum number of steps in Etoile_bin::equilibrium : " |
| 280 |
<< mermax_eqb << endl ; |
| 281 |
cout << "Threshold on the enthalpy relative change for ending the computation : " |
| 282 |
<< seuil << endl ; |
| 283 |
cout << "Step interval between safeguards of the whole configuration : " |
| 284 |
<< fmer_save << endl ; |
| 285 |
cout << "Maximum number of steps in Map_et::poisson : " |
| 286 |
<< mermax_poisson << endl ; |
| 287 |
cout << "Relaxation factor in Map_et::poisson : " |
| 288 |
<< relax_poisson << endl ; |
| 289 |
cout << "Maximum number of steps in Map_radial::poisson_compact : " |
| 290 |
<< mermax_potvit << endl ; |
| 291 |
cout << "Relaxation factor in Map_radial::poisson_compact : " |
| 292 |
<< relax_potvit << endl ; |
| 293 |
cout << "Step from which the baryon mass is forced to converge : " |
| 294 |
<< mer_masse << endl ; |
| 295 |
cout << "Exponent for the increase factor of the central enthalpy : " |
| 296 |
<< aexp_masse << endl ; |
| 297 |
cout << "Step interval between metric updates : " |
| 298 |
<< fmer_upd_met << endl ; |
| 299 |
if (ind_rel_met == 1) { |
| 300 |
cout << "Relaxation factor of the metric : " |
| 301 |
<< relax_met << endl ; |
| 302 |
} |
| 303 |
else { |
| 304 |
cout << "No relaxation on the metric" << endl ; |
| 305 |
} |
| 306 |
cout << "Relaxation factor on Omega (orbital angular velocity) : " |
| 307 |
<< relax_omeg << endl ; |
| 308 |
cout << "Relative low bound in the omega search : " |
| 309 |
<< fact_omeg_min << endl ; |
| 310 |
cout << "Relative high bound in the omega search : " |
| 311 |
<< fact_omeg_max << endl ; |
| 312 |
cout << |
| 313 |
"Threshold on |dH/dr|_eq / |dH/dr|_pole for the adaptation of the mapping for star 1" |
| 314 |
<< endl << thres_adapt[0] << endl ; |
| 315 |
cout << |
| 316 |
"Threshold on |dH/dr|_eq / |dH/dr|_pole for the adaptation of the mapping for star 2" |
| 317 |
<< endl << thres_adapt[1] << endl ; |
| 318 |
cout << "Factor by which the initial analytical shift is reduced : " |
| 319 |
<< reduce_shift << endl ; |
| 320 |
|
| 321 |
arrete(prompt) ; |
| 322 |
|
| 323 |
//------------------------------------------------------------------ |
| 324 |
// Read of the initial conditions |
| 325 |
//------------------------------------------------------------------ |
| 326 |
|
| 327 |
FILE* fich = fopen(nomini, "r") ; |
| 328 |
if (fich == 0x0) { |
| 329 |
cout << "Problem in opening the file " << nomini << " ! " << endl ; |
| 330 |
perror(" reason") ; |
| 331 |
abort() ; |
| 332 |
} |
| 333 |
|
| 334 |
int mer_ini ; |
| 335 |
fread(&mer_ini, sizeof(int), 1, fich) ; |
| 336 |
|
| 337 |
Mg3d mg1(fich) ; |
| 338 |
Map_et mp1(mg1, fich) ; |
| 339 |
Eos* peos1 = Eos::eos_from_file(fich) ; |
| 340 |
|
| 341 |
Mg3d mg2(fich) ; |
| 342 |
Map_et mp2(mg2, fich) ; |
| 343 |
Eos* peos2 = Eos::eos_from_file(fich) ; |
| 344 |
|
| 345 |
Binaire star(mp1, *peos1, mp2, *peos2, fich) ; |
| 346 |
fclose(fich) ; |
| 347 |
|
| 348 |
//Tables with values of enthalpy at the borders of domains |
| 349 |
|
| 350 |
int nzet1 = star(1).get_nzet() ; |
| 351 |
int nzet2 = star(2).get_nzet() ; |
| 352 |
|
| 353 |
Tbl ent_limit1(nzet1) ; |
| 354 |
Tbl ent_limit2(nzet2) ; |
| 355 |
|
| 356 |
ent_limit1.set_etat_qcq() ; |
| 357 |
ent_limit2.set_etat_qcq() ; |
| 358 |
|
| 359 |
for(int j=0; j<nzet1; j++) |
| 360 |
|
| 361 |
ent_limit1.set(j) = star(1).get_ent()()(j+1,0,0,0) ; |
| 362 |
|
| 363 |
for(int j=0; j<nzet2; j++) |
| 364 |
|
| 365 |
ent_limit2.set(j) = star(2).get_ent()()(j+1,0,0,0) ; |
| 366 |
|
| 367 |
Tbl* pent_limit[2] ; |
| 368 |
pent_limit[0] = &ent_limit1 ; |
| 369 |
pent_limit[1] = &ent_limit2 ; |
| 370 |
|
| 371 |
//------------------------------------------------------------------ |
| 372 |
// Modification of the separation between the two stars |
| 373 |
//------------------------------------------------------------------ |
| 374 |
|
| 375 |
for (int i=1 ; i<=2 ; i++) { |
| 376 |
|
| 377 |
double ori_x = (star(i).get_mp()).get_ori_x() ; |
| 378 |
ori_x *= fact_separ ; |
| 379 |
((star.set(i)).set_mp()).set_ori(ori_x, 0., 0.) ; |
| 380 |
} |
| 381 |
|
| 382 |
//------------------------------------------------------------------ |
| 383 |
// Update of the initial conditions |
| 384 |
//------------------------------------------------------------------ |
| 385 |
|
| 386 |
// Initialisation of A^2, N, etc... |
| 387 |
// --------------------------------- |
| 388 |
for (int i=1; i<=2; i++) { |
| 389 |
(star.set(i)).update_metric(star(3-i)) ; |
| 390 |
} |
| 391 |
|
| 392 |
// Initialisation of gradients of companion potentials |
| 393 |
// --------------------------------------------------- |
| 394 |
|
| 395 |
for (int i=1; i<=2; i++) { |
| 396 |
(star.set(i)).update_metric_der_comp(star(3-i)) ; |
| 397 |
} |
| 398 |
|
| 399 |
// Initialisation of hydro quantities |
| 400 |
// ---------------------------------- |
| 401 |
|
| 402 |
for (int i=1; i<=2; i++) { |
| 403 |
(star.set(i)).equation_of_state() ; |
| 404 |
(star.set(i)).kinematics(star.get_omega(), star.get_x_axe()) ; |
| 405 |
(star.set(i)).fait_d_psi() ; |
| 406 |
(star.set(i)).hydro_euler() ; |
| 407 |
} |
| 408 |
|
| 409 |
// If the shift vector has not been set previously, it is set to |
| 410 |
// some analytical value |
| 411 |
// ------------------------------------------------------------- |
| 412 |
|
| 413 |
if (star(1).get_w_shift()(1).get_etat() == ETATZERO) { |
| 414 |
|
| 415 |
assert( star(1).get_w_shift()(0).get_etat() == ETATZERO ) ; |
| 416 |
assert( star(1).get_w_shift()(2).get_etat() == ETATZERO ) ; |
| 417 |
|
| 418 |
assert( star(2).get_w_shift()(0).get_etat() == ETATZERO ) ; |
| 419 |
assert( star(2).get_w_shift()(1).get_etat() == ETATZERO ) ; |
| 420 |
assert( star(2).get_w_shift()(2).get_etat() == ETATZERO ) ; |
| 421 |
|
| 422 |
|
| 423 |
// New initial of value Omega (taking into account the fact |
| 424 |
// that the separation has changed) |
| 425 |
|
| 426 |
star.analytical_omega() ; |
| 427 |
|
| 428 |
// Sets some value to w_shift and khi_shift corresponding to the |
| 429 |
// new values of Omega and separation |
| 430 |
|
| 431 |
star.analytical_shift() ; |
| 432 |
|
| 433 |
for (int i=1; i<=2; i++) { |
| 434 |
star.set(i).set_w_shift() = reduce_shift * star(i).get_w_shift() ; |
| 435 |
star.set(i).set_khi_shift() = reduce_shift * star(i).get_khi_shift() ; |
| 436 |
} |
| 437 |
|
| 438 |
|
| 439 |
// Computes shift_auto from w_shift and khi_shift |
| 440 |
for (int i=1; i<=2; i++) { |
| 441 |
(star.set(i)).fait_shift_auto() ; |
| 442 |
} |
| 443 |
|
| 444 |
// A second call to update_metric must be performed to update |
| 445 |
// shift_comp, tkij_auto and akcar_auto. |
| 446 |
for (int i=1; i<=2; i++) { |
| 447 |
(star.set(i)).update_metric(star(3-i)) ; |
| 448 |
} |
| 449 |
|
| 450 |
// Second update of gradients of companion potentials |
| 451 |
|
| 452 |
for (int i=1; i<=2; i++) { |
| 453 |
(star.set(i)).update_metric_der_comp(star(3-i)) ; |
| 454 |
} |
| 455 |
|
| 456 |
// Second update of hydro quantities |
| 457 |
|
| 458 |
for (int i=1; i<=2; i++) { |
| 459 |
(star.set(i)).equation_of_state() ; |
| 460 |
(star.set(i)).kinematics(star.get_omega(), star.get_x_axe()) ; |
| 461 |
(star.set(i)).fait_d_psi() ; |
| 462 |
(star.set(i)).hydro_euler() ; |
| 463 |
} |
| 464 |
|
| 465 |
|
| 466 |
} // End of the setting of an analytical shift |
| 467 |
|
| 468 |
|
| 469 |
//## |
| 470 |
FILE* fresu = fopen("resu.d", "w") ; |
| 471 |
|
| 472 |
int mer1 = 0 ; |
| 473 |
fwrite(&mer1, sizeof(int), 1, fresu) ; // mer |
| 474 |
|
| 475 |
star(1).get_mp().get_mg()->sauve(fresu) ; |
| 476 |
star(1).get_mp().sauve(fresu) ; |
| 477 |
star(1).get_eos().sauve(fresu) ; |
| 478 |
|
| 479 |
star(2).get_mp().get_mg()->sauve(fresu) ; |
| 480 |
star(2).get_mp().sauve(fresu) ; |
| 481 |
star(2).get_eos().sauve(fresu) ; |
| 482 |
|
| 483 |
star.sauve(fresu) ; |
| 484 |
|
| 485 |
fclose(fresu) ; |
| 486 |
//## |
| 487 |
|
| 488 |
cout << endl |
| 489 |
<< "==========================================================" << endl |
| 490 |
<< " Initial conditions " << endl |
| 491 |
<< "==========================================================" |
| 492 |
<< endl ; |
| 493 |
cout << star << endl ; |
| 494 |
|
| 495 |
if ( star(1).is_relativistic() ) { |
| 496 |
cout << "========================" << endl ; |
| 497 |
cout << "Relativistic computation" << endl ; |
| 498 |
cout << "========================" << endl ; |
| 499 |
} |
| 500 |
else { |
| 501 |
cout << "=====================" << endl ; |
| 502 |
cout << "Newtonian computation" << endl ; |
| 503 |
cout << "=====================" << endl ; |
| 504 |
} |
| 505 |
|
| 506 |
arrete(prompt) ; |
| 507 |
|
| 508 |
|
| 509 |
//---------------------------------------------------------------- |
| 510 |
// Auxiliary quantities |
| 511 |
//---------------------------------------------------------------- |
| 512 |
|
| 513 |
double ent_c[2] ; // Central enthalpy in each star |
| 514 |
double dentdx[2] ; // Central d/dx(enthalpy) in each star |
| 515 |
|
| 516 |
// Resizing factor of the first shell |
| 517 |
// Computation is shown just befor "equilibrium" |
| 518 |
Tbl fact_resize[] = {Tbl(2), Tbl(2)} ; |
| 519 |
fact_resize[0].set_etat_qcq() ; |
| 520 |
fact_resize[1].set_etat_qcq() ; |
| 521 |
|
| 522 |
// Error indicators in each star |
| 523 |
Tbl differ[] = {Tbl(7), Tbl(7)} ; |
| 524 |
differ[0].set_etat_qcq() ; |
| 525 |
differ[1].set_etat_qcq() ; |
| 526 |
|
| 527 |
for (int i=1 ; i<=2 ; i++) { |
| 528 |
ent_c[i-1] = star(i).get_ent()()(0, 0, 0, 0) ; |
| 529 |
differ[i-1].set(0) = 1 ; // diff_ent = 1 |
| 530 |
differ[i-1].set(1) = 1 ; // err_psi = 1 |
| 531 |
differ[i-1].set(2) = 1 ; // err_logn = 1 |
| 532 |
differ[i-1].set(3) = 1 ; // err_beta = 1 |
| 533 |
differ[i-1].set(4) = 1 ; // err_shift_x = 1 |
| 534 |
differ[i-1].set(5) = 1 ; // err_shift_y = 1 |
| 535 |
differ[i-1].set(6) = 1 ; // err_shift_z = 1 |
| 536 |
} |
| 537 |
|
| 538 |
double relax_jm1 = 1. - relax ; |
| 539 |
double relax_omeg_jm1 = 1. - relax_omeg ; |
| 540 |
|
| 541 |
//---------------------------------------------------------------- |
| 542 |
// Binary system at the previous step (for the relaxation) |
| 543 |
//---------------------------------------------------------------- |
| 544 |
|
| 545 |
Binaire star_jm1 = star ; |
| 546 |
|
| 547 |
double omega_jm1 = star_jm1.get_omega() ; |
| 548 |
|
| 549 |
|
| 550 |
// logn_comp and pot_centri are initialized to 0 on star_jm1 : |
| 551 |
// --------------------------------------------------------- |
| 552 |
for (int i=1 ; i<=2 ; i++) { |
| 553 |
star_jm1.set(i).set_logn_comp() = 0 ; |
| 554 |
star_jm1.set(i).set_pot_centri() = 0 ; |
| 555 |
} |
| 556 |
|
| 557 |
//---------------------------------------------------------------- |
| 558 |
// Openning of log files |
| 559 |
//---------------------------------------------------------------- |
| 560 |
|
| 561 |
ofstream fichresu("resglob.d") ; |
| 562 |
fichresu.precision(16) ; |
| 563 |
|
| 564 |
ofstream fichrota("resrota.d") ; |
| 565 |
fichrota.precision(16) ; |
| 566 |
|
| 567 |
ofstream fichvir("resdiffm.d") ; |
| 568 |
fichvir.precision(16) ; |
| 569 |
|
| 570 |
ofstream fichconv[2] ; |
| 571 |
fichconv[0].open("resconv1.d") ; |
| 572 |
fichconv[0].precision(16) ; |
| 573 |
fichconv[1].open("resconv2.d") ; |
| 574 |
fichconv[1].precision(16) ; |
| 575 |
|
| 576 |
ofstream fichet[2] ; |
| 577 |
fichet[0].open("resstar1.d") ; |
| 578 |
fichet[0].precision(16) ; |
| 579 |
fichet[1].open("resstar2.d") ; |
| 580 |
fichet[1].precision(16) ; |
| 581 |
|
| 582 |
fichrota << |
| 583 |
"# Omega [rad/s] x_axe [km] x_g (et 0) [km] x_g (et 1) [km] M_grav [M_sol] J [ G M_sol^2 / c]" |
| 584 |
<< endl ; |
| 585 |
|
| 586 |
fichvir << |
| 587 |
"# diff_mass" |
| 588 |
<< endl ; |
| 589 |
|
| 590 |
for (int i=1; i<=2; i++) { |
| 591 |
fichconv[i-1] << |
| 592 |
"# diff_ent err_psi err_logn err_beta err_shift_x err_shift_y err_shift_z" |
| 593 |
<< endl ; |
| 594 |
|
| 595 |
fichet[i-1] << |
| 596 |
"# ori_x [km] ent_c M_bar [M_sol] R(theta=0) [km] R(pi/2, 0) [km] R(pi/2, pi/2) [km] R(pi/2, pi) [km]" |
| 597 |
<< endl ; |
| 598 |
} |
| 599 |
|
| 600 |
double omega_kep, diff_mass ; |
| 601 |
int mer ; |
| 602 |
|
| 603 |
|
| 604 |
//============================================================================ |
| 605 |
// Start of iteration |
| 606 |
//============================================================================ |
| 607 |
|
| 608 |
for (mer=0; (differ[0](0) > seuil) && (mer < mermax); mer++) { |
| 609 |
|
| 610 |
cout << |
| 611 |
"==========================================================================" |
| 612 |
<< endl ; |
| 613 |
cout << "step = " << mer << " diff_ent (1) (2) (1)<->(2) : " |
| 614 |
<< differ[0](0) << " " << differ[1](0) << " " |
| 615 |
<< differ[0](0) - differ[1](0) << endl ; |
| 616 |
cout << |
| 617 |
"==========================================================================" |
| 618 |
<< endl ; |
| 619 |
|
| 620 |
fichresu << mer; |
| 621 |
fichresu << " step" << endl ; |
| 622 |
|
| 623 |
fichrota << mer ; |
| 624 |
fichvir << mer ; |
| 625 |
fichconv[0] << mer ; |
| 626 |
fichconv[1] << mer ; |
| 627 |
fichet[0] << mer ; |
| 628 |
fichet[1] << mer ; |
| 629 |
|
| 630 |
|
| 631 |
//------------------------------------------------------------------ |
| 632 |
// Computation of the metric coefficients |
| 633 |
//------------------------------------------------------------------ |
| 634 |
|
| 635 |
if ( (mer % fmer_upd_met) == 0 ) { |
| 636 |
|
| 637 |
for (int i=1; i<=2; i++) { |
| 638 |
(star.set(i)).update_metric(star(3-i), star_jm1(i), relax_met) ; |
| 639 |
} |
| 640 |
|
| 641 |
for (int i=1; i<=2; i++) { |
| 642 |
(star.set(i)).update_metric_der_comp(star(3-i)) ; |
| 643 |
} |
| 644 |
|
| 645 |
} |
| 646 |
|
| 647 |
|
| 648 |
//------------------------------------------------------------------ |
| 649 |
// Computation of the orbital angular velocity Omega |
| 650 |
//------------------------------------------------------------------ |
| 651 |
|
| 652 |
double xgg[2] ; |
| 653 |
|
| 654 |
star.orbit(fact_omeg_min, fact_omeg_max, xgg[0], xgg[1]) ; |
| 655 |
|
| 656 |
// Translation of the stars in order to set the origin |
| 657 |
// of the absolute frame on the rotation axis |
| 658 |
//----------------------------------------------------- |
| 659 |
|
| 660 |
double x_rot = star.get_x_axe() ; |
| 661 |
|
| 662 |
for (int i=1 ; i<=2 ; i++) { |
| 663 |
double ori_x_old = (star(i).get_mp()).get_ori_x() ; |
| 664 |
double ori_x_new = ori_x_old - x_rot ; |
| 665 |
((star.set(i)).set_mp()).set_ori(ori_x_new, 0., 0.) ; |
| 666 |
} |
| 667 |
|
| 668 |
star.set_x_axe() = 0. ; |
| 669 |
|
| 670 |
// Relaxation on the orbital velocity |
| 671 |
// ---------------------------------- |
| 672 |
|
| 673 |
double omega_j = star.get_omega() ; |
| 674 |
omega_j = relax_omeg * omega_j + relax_omeg_jm1 * omega_jm1 ; |
| 675 |
omega_jm1 = omega_j ; |
| 676 |
|
| 677 |
star.set_omega() = omega_j ; |
| 678 |
|
| 679 |
cout << display_bold << "New orbital velocity Omega : " |
| 680 |
<< star.get_omega() * f_unit << " rad/s" << display_normal << endl ; |
| 681 |
|
| 682 |
// Keplerian velocity (for comparison only) |
| 683 |
// ---------------------------------------- |
| 684 |
omega_kep = sqrt( g_si/g_unit * (star(1).mass_g() + star(2).mass_g()) |
| 685 |
/ pow( star.separation(), 3.) ) ; |
| 686 |
|
| 687 |
cout << "``Keplerian'' velocity (for comparison only) : " |
| 688 |
<< omega_kep * f_unit << " rad/s" << endl ; |
| 689 |
cout << "New X coordinate of the rotation axis : " |
| 690 |
<< star.get_x_axe() / km << " km" << endl ; |
| 691 |
|
| 692 |
arrete(prompt) ; |
| 693 |
|
| 694 |
fichresu << star.get_x_axe() / km ; |
| 695 |
fichresu << " abscidia of the rotation axis [km] " << endl ; |
| 696 |
|
| 697 |
fichresu << star.get_omega() * f_unit ; |
| 698 |
fichresu << " Orbital frequency Omega [rad/s] " << endl ; |
| 699 |
|
| 700 |
fichresu << xgg[0] / km ; |
| 701 |
fichresu << " Abscidia ``center of mass'' star 1 [km] " << endl ; |
| 702 |
|
| 703 |
fichresu << xgg[1] / km ; |
| 704 |
fichresu << " Abscidia ``center of mass'' star 2 [km] " << endl ; |
| 705 |
|
| 706 |
fichrota << " " << star.get_omega() * f_unit ; |
| 707 |
fichrota << " " << star.get_x_axe() / km ; |
| 708 |
fichrota << " " << xgg[0] / km ; |
| 709 |
fichrota << " " << xgg[1] / km ; |
| 710 |
|
| 711 |
//------------------------------------------------------------------ |
| 712 |
// Computation of B^i/N (bsn) and pot_centri in each star |
| 713 |
//------------------------------------------------------------------ |
| 714 |
|
| 715 |
for (int i=1; i<=2; i++) { |
| 716 |
|
| 717 |
(star.set(i)).kinematics( star.get_omega(), star.get_x_axe() ) ; |
| 718 |
|
| 719 |
} |
| 720 |
|
| 721 |
//------------------------------------------------------------------ |
| 722 |
// Computation of gam_euler, u_euler, ener_euler, s_euler, |
| 723 |
// wit_w and loggam in each star |
| 724 |
//------------------------------------------------------------------ |
| 725 |
|
| 726 |
for (int i=1; i<=2; i++) { |
| 727 |
|
| 728 |
(star.set(i)).fait_d_psi() ; |
| 729 |
(star.set(i)).hydro_euler() ; |
| 730 |
|
| 731 |
// Check of the Binaire::orbit computation |
| 732 |
//---------------------------------------- |
| 733 |
|
| 734 |
Cmp tmp = star(i).get_logn_auto()() + star(i).get_logn_comp()() |
| 735 |
+ star(i).get_loggam()() ; |
| 736 |
double grad1 = tmp.dsdx()(0, 0, 0, 0) ; |
| 737 |
|
| 738 |
double grad2 = star(i).get_pot_centri()().dsdx()(0, 0, 0, 0) ; |
| 739 |
|
| 740 |
dentdx[i-1] = star(i).get_ent()().dsdx()(0, 0, 0, 0) ; |
| 741 |
|
| 742 |
double grad3 = star(i).get_loggam()().dsdx()(0, 0, 0, 0) ; |
| 743 |
|
| 744 |
cout << "Star " << i << " : " << endl ; |
| 745 |
cout << " central dH/dx : " << dentdx[i-1] << endl ; |
| 746 |
cout << " central d(log(Gam))/dx : " << grad3 << endl ; |
| 747 |
cout << " central d/dx(nu + log(Gam)) : " << grad1 << endl ; |
| 748 |
cout << " central d/dx(pot_centri) : " << grad2 << endl ; |
| 749 |
cout << " central d/dx(nu + log(Gam) + pot_centri) : " |
| 750 |
<< grad1 + grad2 << endl ; |
| 751 |
|
| 752 |
|
| 753 |
} |
| 754 |
|
| 755 |
|
| 756 |
//------------------------------------------------------------------ |
| 757 |
// Computation of the stellar equilibrium configurations |
| 758 |
//------------------------------------------------------------------ |
| 759 |
|
| 760 |
for (int i=1; i<=2; i++) { |
| 761 |
|
| 762 |
// Computation of the resizing factor |
| 763 |
double ray_eq_auto = star(i).ray_eq() ; |
| 764 |
double ray_eq_comp = star(3-i).ray_eq() ; |
| 765 |
double ray_eq_pi_comp = star(3-i).ray_eq_pi() ; |
| 766 |
|
| 767 |
int num_resize ; |
| 768 |
|
| 769 |
if (mg1.get_nzone() > 3) { |
| 770 |
assert( mg2.get_nzone() == mg1.get_nzone() ) ; |
| 771 |
num_resize = mg1.get_nzone() - 3 ; |
| 772 |
} |
| 773 |
else { |
| 774 |
num_resize = star(i).get_nzet() ; |
| 775 |
} |
| 776 |
|
| 777 |
double lambda_resize = 0.95 * |
| 778 |
(star.separation() - ray_eq_comp)/ray_eq_auto ; |
| 779 |
fact_resize[i-1].set(0) = |
| 780 |
(lambda_resize < 2.*num_resize) ? lambda_resize : 2.*num_resize ; |
| 781 |
|
| 782 |
fact_resize[i-1].set(1) = 1.05 * |
| 783 |
(star.separation() + ray_eq_pi_comp)/ray_eq_auto ; |
| 784 |
|
| 785 |
} |
| 786 |
|
| 787 |
for (int i=1; i<=2; i++) { |
| 788 |
|
| 789 |
// Relaxation on logn_comp (only if it has not been done by |
| 790 |
// update_metric) |
| 791 |
// -------------------------------------------------------- |
| 792 |
if ( (ind_rel_met == 0) || ( (mer % fmer_upd_met) != 0 ) ) { |
| 793 |
star.set(i).set_logn_comp() = relax * star(i).get_logn_comp() |
| 794 |
+ relax_jm1 * star_jm1(i).get_logn_comp() ; |
| 795 |
} |
| 796 |
|
| 797 |
// Relaxation on pot_centri |
| 798 |
// ------------------------ |
| 799 |
star.set(i).set_pot_centri() = relax * star(i).get_pot_centri() |
| 800 |
+ relax_jm1 * star_jm1(i).get_pot_centri() ; |
| 801 |
|
| 802 |
|
| 803 |
// Call to Etoile_bin::equilibrium |
| 804 |
// -------------------------------- |
| 805 |
|
| 806 |
//mbtest |
| 807 |
(star.set(i)).equilibrium(ent_c[i-1], mermax_eqb, mermax_poisson, |
| 808 |
relax_poisson, mermax_potvit, relax_potvit, |
| 809 |
thres_adapt[i-1], fact_resize[i-1], differ[i-1], pent_limit[i-1]) ; |
| 810 |
|
| 811 |
} |
| 812 |
|
| 813 |
|
| 814 |
//------------------------------------------------------------------ |
| 815 |
// Relaxations |
| 816 |
//------------------------------------------------------------------ |
| 817 |
|
| 818 |
for (int i=1; i<=2; i++) { |
| 819 |
|
| 820 |
star.set(i).relaxation( star_jm1(i), relax, relax_met, mer, |
| 821 |
fmer_upd_met ) ; |
| 822 |
|
| 823 |
star.set(i).hydro_euler() ; |
| 824 |
} |
| 825 |
|
| 826 |
/* if (mer % 1000 == 0) { |
| 827 |
double r_max = 1.2 * star(1).ray_eq() ; |
| 828 |
des_profile(star(1).get_nbar()(), 0., r_max, M_PI/2, 0., "n", "Baryon density") ; |
| 829 |
des_profile(star(1).get_ener()(), 0., r_max, M_PI/2, 0., "e", "Energy density") ; |
| 830 |
des_profile(star(1).get_press()(), 0., r_max, M_PI/2, 0., "p", "Pressure") ; |
| 831 |
des_profile(star(1).get_ent()(), 0., r_max, M_PI/2, 0., "H", "Enthalpy") ; |
| 832 |
} |
| 833 |
*/ |
| 834 |
//------------------------------------------------------------------ |
| 835 |
// Change in the central enthalpy to get a fixed baryon mass |
| 836 |
//------------------------------------------------------------------ |
| 837 |
|
| 838 |
if (mer >= mer_masse) { |
| 839 |
|
| 840 |
for (int i=1; i<=2; i++) { |
| 841 |
|
| 842 |
double xx = star(i).mass_b() / mbar_voulue[i-1] - 1. ; |
| 843 |
|
| 844 |
cout << "Discrepancy M_b / wanted M_b : " << xx << endl ; |
| 845 |
|
| 846 |
double xprog = ( mer > 2*mer_masse) ? 1. : |
| 847 |
double(mer-mer_masse)/double(mer_masse) ; |
| 848 |
xx *= xprog ; |
| 849 |
double ax = .5 * ( 2. + xx ) / (1. + xx ) ; |
| 850 |
|
| 851 |
double fact_ent = pow(ax, aexp_masse) ; |
| 852 |
|
| 853 |
cout << " xprog, xx, ax, fact : " << xprog << " " << |
| 854 |
xx << " " << ax << " " << fact_ent << endl ; |
| 855 |
|
| 856 |
ent_c[i-1] *= fact_ent ; |
| 857 |
|
| 858 |
} |
| 859 |
} |
| 860 |
|
| 861 |
// Updates for the next step |
| 862 |
// ------------------------- |
| 863 |
|
| 864 |
star_jm1 = star ; |
| 865 |
|
| 866 |
|
| 867 |
cout << star << endl ; |
| 868 |
|
| 869 |
|
| 870 |
// Graphical output |
| 871 |
// ---------------- |
| 872 |
|
| 873 |
if ( (graph==1) && (mer % 5 == 0) ) { |
| 874 |
double xdes_min = - star(1).ray_eq_pi() + star(1).get_mp().get_ori_x() ; |
| 875 |
xdes_min *= 1.5 ; |
| 876 |
double xdes_max = star(2).ray_eq_pi() + star(2).get_mp().get_ori_x() ; |
| 877 |
xdes_max *= 1.5 ; |
| 878 |
double ydes_min = - 2.5 * star(1).ray_eq_pis2() ; |
| 879 |
double ydes_max = 2.5 * star(2).ray_eq_pis2() ; |
| 880 |
|
| 881 |
Cmp surf1 = star(1).get_ent()() ; |
| 882 |
Cmp surf1_ext(mp1) ; |
| 883 |
surf1_ext = - 0.2 * surf1(0, 0, 0, 0) ; |
| 884 |
surf1_ext.annule(0, star(1).get_nzet()-1) ; |
| 885 |
surf1.annule(star(1).get_nzet(), mg1.get_nzone()-1) ; |
| 886 |
surf1 = surf1 + surf1_ext ; |
| 887 |
|
| 888 |
surf1 = raccord_c1(surf1, star(1).get_nzet()) ; |
| 889 |
|
| 890 |
Cmp surf2 = star(2).get_ent()() ; |
| 891 |
Cmp surf2_ext(mp2) ; |
| 892 |
surf2_ext = - 0.2 * surf2(0, 0, 0, 0) ; |
| 893 |
surf2_ext.annule(0, star(2).get_nzet()-1) ; |
| 894 |
surf2.annule(star(2).get_nzet(), mg2.get_nzone()-1) ; |
| 895 |
surf2 = surf2 + surf2_ext ; |
| 896 |
|
| 897 |
surf2 = raccord_c1(surf2, star(2).get_nzet()) ; |
| 898 |
|
| 899 |
des_coupe_bin_z(star(1).get_nbar()(), star(2).get_nbar()(), 0., |
| 900 |
xdes_min, xdes_max, ydes_min, ydes_max, |
| 901 |
"Baryon density (z=0)", &surf1, &surf2 ) ; |
| 902 |
|
| 903 |
des_coupe_bin_y(star(1).get_nbar()(), star(2).get_nbar()(), 0., |
| 904 |
xdes_min, xdes_max, ydes_min, ydes_max, |
| 905 |
"Baryon density (y=0)", &surf1, &surf2 ) ; |
| 906 |
} |
| 907 |
|
| 908 |
|
| 909 |
|
| 910 |
//----------------------------------------------------------------------- |
| 911 |
// The whole configuration is saved in a file |
| 912 |
//----------------------------------------------------------------------- |
| 913 |
|
| 914 |
if ( (mer % fmer_save) == 0 ) { |
| 915 |
|
| 916 |
fresu = fopen("resu.d", "w") ; |
| 917 |
|
| 918 |
fwrite(&mer, sizeof(int), 1, fresu) ; // mer |
| 919 |
|
| 920 |
star(1).get_mp().get_mg()->sauve(fresu) ; |
| 921 |
star(1).get_mp().sauve(fresu) ; |
| 922 |
star(1).get_eos().sauve(fresu) ; |
| 923 |
|
| 924 |
star(2).get_mp().get_mg()->sauve(fresu) ; |
| 925 |
star(2).get_mp().sauve(fresu) ; |
| 926 |
star(2).get_eos().sauve(fresu) ; |
| 927 |
|
| 928 |
star.sauve(fresu) ; |
| 929 |
|
| 930 |
fclose(fresu) ; |
| 931 |
} |
| 932 |
|
| 933 |
//-------------------------------------------- |
| 934 |
// Writing of global quantities in log files |
| 935 |
//-------------------------------------------- |
| 936 |
for (int i=1 ; i<=2 ; i++) { |
| 937 |
fichresu << star(i).mass_b() / msol ; |
| 938 |
fichresu << " Baryon mass of star " << i << " [M_sol] " << endl ; |
| 939 |
fichresu << differ[i-1](0) ; |
| 940 |
fichresu << " relative variation enth. star " << i << endl ; |
| 941 |
|
| 942 |
fichresu << star(i).ray_pole() / km ; |
| 943 |
fichresu << " R(theta=0) [km] " << endl ; |
| 944 |
fichresu << star(i).ray_eq() / km ; |
| 945 |
fichresu << " R(theta=pi/2, phi=0) [km] " << endl ; |
| 946 |
fichresu << star(i).ray_eq_pis2() / km ; |
| 947 |
fichresu << " R(theta=pi/2, phi=pi/2) [km] " << endl ; |
| 948 |
fichresu << star(i).ray_eq_pi() / km ; |
| 949 |
fichresu << " R(theta=pi/2, phi=pi) [km] " << endl ; |
| 950 |
|
| 951 |
fichconv[i-1] << " " << log10( fabs(differ[i-1](0)) + 1.e-16 ) ; |
| 952 |
fichconv[i-1] << " " << log10( fabs(differ[i-1](1)) + 1.e-16 ) ; |
| 953 |
fichconv[i-1] << " " << log10( fabs(differ[i-1](2)) + 1.e-16 ) ; |
| 954 |
fichconv[i-1] << " " << log10( fabs(differ[i-1](3)) + 1.e-16 ) ; |
| 955 |
fichconv[i-1] << " " << log10( fabs(differ[i-1](4)) + 1.e-16 ) ; |
| 956 |
fichconv[i-1] << " " << log10( fabs(differ[i-1](5)) + 1.e-16 ) ; |
| 957 |
fichconv[i-1] << " " << log10( fabs(differ[i-1](6)) + 1.e-16 ) ; |
| 958 |
|
| 959 |
fichet[i-1] << " " << star(i).get_mp().get_ori_x() / km ; |
| 960 |
fichet[i-1] << " " << ent_c[i-1] ; |
| 961 |
fichet[i-1] << " " << star(i).mass_b() / msol ; |
| 962 |
fichet[i-1] << " " << star(i).ray_pole() / km ; |
| 963 |
fichet[i-1] << " " << star(i).ray_eq() / km ; |
| 964 |
fichet[i-1] << " " << star(i).ray_eq_pis2() / km ; |
| 965 |
fichet[i-1] << " " << star(i).ray_eq_pi() / km ; |
| 966 |
|
| 967 |
} // End of loop on the stars |
| 968 |
|
| 969 |
diff_mass = ( star(2).mass_b() - star(1).mass_b() ) |
| 970 |
/ star(1).mass_b() ; |
| 971 |
cout << "Relative difference between the baryon masses: " |
| 972 |
<< diff_mass << endl ; |
| 973 |
fichresu << diff_mass ; |
| 974 |
fichresu << " Relative difference between the baryon masses" << endl ; |
| 975 |
|
| 976 |
fichvir << " " << log10( fabs(diff_mass) + 1.e-16 ) ; |
| 977 |
|
| 978 |
|
| 979 |
fichresu << " " << endl ; |
| 980 |
fichresu.flush() ; |
| 981 |
fichrota << " " << endl ; |
| 982 |
fichrota.flush() ; |
| 983 |
fichvir << " " << endl ; |
| 984 |
fichvir.flush() ; |
| 985 |
fichconv[0] << " " << endl ; |
| 986 |
fichconv[0].flush() ; |
| 987 |
fichconv[1] << " " << endl ; |
| 988 |
fichconv[1].flush() ; |
| 989 |
fichet[0] << " " << endl ; |
| 990 |
fichet[0].flush() ; |
| 991 |
fichet[1] << " " << endl ; |
| 992 |
fichet[1].flush() ; |
| 993 |
|
| 994 |
} // End of the main loop (mer) |
| 995 |
|
| 996 |
//============================================================================ |
| 997 |
// End of iteration |
| 998 |
//============================================================================ |
| 999 |
|
| 1000 |
fichresu.close() ; |
| 1001 |
fichrota.close() ; |
| 1002 |
fichvir.close() ; |
| 1003 |
fichconv[0].close() ; |
| 1004 |
fichconv[1].close() ; |
| 1005 |
fichet[0].close() ; |
| 1006 |
fichet[1].close() ; |
| 1007 |
|
| 1008 |
|
| 1009 |
//----------------------------------------------- |
| 1010 |
// General features of the final configuration |
| 1011 |
// saved in a file |
| 1012 |
//----------------------------------------------- |
| 1013 |
|
| 1014 |
ofstream fichfinal("calcul.d") ; |
| 1015 |
fichfinal.precision(6) ; |
| 1016 |
|
| 1017 |
time_t rawtime = time(0x0) ; |
| 1018 |
fichfinal << "Date: " << asctime( localtime( &rawtime ) ) << endl ; |
| 1019 |
char* hostname = getenv("HOST") ; |
| 1020 |
if (hostname != 0x0) { |
| 1021 |
fichfinal << "Computer: " << hostname << endl ; |
| 1022 |
} |
| 1023 |
fichfinal << |
| 1024 |
"===================================================================" |
| 1025 |
<< endl << endl ; |
| 1026 |
|
| 1027 |
if ( star(1).is_relativistic() ) { |
| 1028 |
fichfinal << "Relativistic computation" ; |
| 1029 |
} |
| 1030 |
else { |
| 1031 |
fichfinal << "Newtonian computation" ; |
| 1032 |
} |
| 1033 |
|
| 1034 |
if ( star(1).is_irrotational() ) { |
| 1035 |
fichfinal << " Irrotational" << endl ; |
| 1036 |
} |
| 1037 |
else { |
| 1038 |
fichfinal << " Co-rotating" << endl ; |
| 1039 |
} |
| 1040 |
|
| 1041 |
fichfinal << star(1).get_eos() << endl ; |
| 1042 |
|
| 1043 |
fichfinal << "Omega = " << star.get_omega() * f_unit << " rad/s" |
| 1044 |
<< " Orbital frequency f = " |
| 1045 |
<< star.get_omega() / (2*M_PI) * f_unit << " Hz" << endl ; |
| 1046 |
fichfinal << "Omega_kepler = " << omega_kep * f_unit << " rad/s" << endl ; |
| 1047 |
fichfinal << "Coordinate separation : " << star.separation() / km |
| 1048 |
<< " km" << endl ; |
| 1049 |
fichfinal << "1/2 ADM mass : " << 0.5 * star.mass_adm() / msol |
| 1050 |
<< " Mo" << endl ; |
| 1051 |
fichfinal << "Total angular momentum : " |
| 1052 |
<< star.angu_mom()(2)/ ( qpig / (4* M_PI) * msol*msol) |
| 1053 |
<< " G M_sol^2 / c" << endl ; |
| 1054 |
cout << "1/2 ADM mass : " << 0.5 * star.mass_adm() / msol |
| 1055 |
<< " Mo" << endl ; |
| 1056 |
cout << "Total angular momentum : " |
| 1057 |
<< star.angu_mom()(2)/ ( qpig / (4* M_PI) * msol*msol) |
| 1058 |
<< " G M_sol^2 / c" << endl ; |
| 1059 |
|
| 1060 |
fichfinal << endl << "Number of steps : " << mer << endl ; |
| 1061 |
|
| 1062 |
for (int i=1 ; i<=2; i++) { |
| 1063 |
fichfinal << endl << |
| 1064 |
"===================================================================" |
| 1065 |
<< endl ; |
| 1066 |
fichfinal << " Star no. " << i << endl ; |
| 1067 |
fichfinal << |
| 1068 |
"===================================================================" |
| 1069 |
<< endl ; |
| 1070 |
fichfinal << "Grid : " << endl ; |
| 1071 |
fichfinal << "------ " << endl ; |
| 1072 |
fichfinal << *(star(i).get_mp().get_mg()) << endl ; |
| 1073 |
fichfinal << endl << "Physical characteristics : " << endl ; |
| 1074 |
fichfinal << "-------------------------" << endl ; |
| 1075 |
fichfinal << star(i) << endl ; |
| 1076 |
} |
| 1077 |
fichfinal << endl ; |
| 1078 |
|
| 1079 |
star.display_poly(fichfinal) ; // Reduced quantities for polytropic EOS |
| 1080 |
|
| 1081 |
fichfinal << endl << |
| 1082 |
"===================================================================" |
| 1083 |
<< endl ; |
| 1084 |
fichfinal << "Diff_ent : star 1 : " << differ[0](0) << " star 2 : " |
| 1085 |
<< differ[1](0) << endl ; |
| 1086 |
fichfinal << |
| 1087 |
"Relative difference between the baryon masses of the two stars : " |
| 1088 |
<< diff_mass << endl ; |
| 1089 |
fichfinal << "dH/dx at r = 0 : star 1 : " << dentdx[0] |
| 1090 |
<< " star 2 : " << dentdx[1] << endl ; |
| 1091 |
|
| 1092 |
|
| 1093 |
if ( star(1).is_relativistic() ) { |
| 1094 |
fichfinal << "Relative error on the virial theorem : " << endl ; |
| 1095 |
fichfinal << " VE(M)= " << star.virial() |
| 1096 |
<< " VE(GB)= "<< star.virial_gb() |
| 1097 |
<< " VE(FUS)= " << star.virial_fus() << endl ; |
| 1098 |
} |
| 1099 |
else { |
| 1100 |
fichfinal << "Relative error on the virial theorem : " |
| 1101 |
<< star.virial() << endl ; |
| 1102 |
} |
| 1103 |
|
| 1104 |
fichfinal << endl << |
| 1105 |
"================================================================" << endl ; |
| 1106 |
fichfinal << " PARAMETERS USED FOR THE COMPUTATION : " << endl ; |
| 1107 |
fichfinal << |
| 1108 |
"================================================================" << endl ; |
| 1109 |
fichfinal.close() ; |
| 1110 |
system("cat parcoal.d >> calcul.d") ; |
| 1111 |
|
| 1112 |
// Identification du code et de ses sous-routines (no. de version RCS) : |
| 1113 |
fichfinal.open("calcul.d", ios::app ) ; |
| 1114 |
fichfinal << endl << |
| 1115 |
"================================================================" << endl ; |
| 1116 |
fichfinal << " IDENTIFICATION OF THE CODE : " << endl ; |
| 1117 |
fichfinal << |
| 1118 |
"================================================================" << endl ; |
| 1119 |
fichfinal.close() ; |
| 1120 |
system("ident coal >> calcul.d") ; |
| 1121 |
|
| 1122 |
// Preparation for CPU infos printing : |
| 1123 |
fichfinal.open("calcul.d", ios::app ) ; |
| 1124 |
fichfinal << endl << |
| 1125 |
"================================================================" << endl ; |
| 1126 |
fichfinal << " CPU TIME and MEMORY infos : " << endl ; |
| 1127 |
fichfinal << |
| 1128 |
"================================================================" << endl ; |
| 1129 |
fichfinal << endl ; |
| 1130 |
fichfinal.close() ; |
| 1131 |
|
| 1132 |
|
| 1133 |
//----------------------------------------------- |
| 1134 |
// General features of the final configuration |
| 1135 |
// saved in a file with scientific notation and |
| 1136 |
// 14 digits for further reading by a code |
| 1137 |
//----------------------------------------------- |
| 1138 |
|
| 1139 |
ofstream seqfich("resformat.d") ; |
| 1140 |
if ( !seqfich.good() ) { |
| 1141 |
cout << "coal : problem with opening the file resformat.d !" << endl ; |
| 1142 |
abort() ; |
| 1143 |
} |
| 1144 |
star.write_global(seqfich) ; |
| 1145 |
seqfich.close() ; |
| 1146 |
|
| 1147 |
|
| 1148 |
if (graph == 1) { |
| 1149 |
|
| 1150 |
|
| 1151 |
//## double xdes_min = - star(1).ray_eq_pi() + star(1).get_mp().get_ori_x() ; |
| 1152 |
// xdes_min *= 1.5 ; |
| 1153 |
// double xdes_max = star(2).ray_eq_pi() + star(2).get_mp().get_ori_x() ; |
| 1154 |
// xdes_max *= 1.5 ; |
| 1155 |
// double ydes_min = - 2.5 * star(1).ray_eq_pis2() ; |
| 1156 |
// double ydes_max = 2.5 * star(2).ray_eq_pis2() ; |
| 1157 |
// |
| 1158 |
// des_coupe_bin_z(star(1).get_nbar()(), star(2).get_nbar()(), 0, |
| 1159 |
// xdes_min, xdes_max, ydes_min, ydes_max, "density (z=0)", |
| 1160 |
// &(star(1).get_ent()()), &(star(2).get_ent()()) ) ; |
| 1161 |
// |
| 1162 |
// des_coupe_bin_z(star(1).get_logn_auto()(), star(2).get_logn_auto()(), 0, |
| 1163 |
// xdes_min, xdes_max, ydes_min, ydes_max, "ln(N) (z=0)", |
| 1164 |
// &(star(1).get_ent()()), &(star(2).get_ent()()) ) ; |
| 1165 |
// |
| 1166 |
// des_coupe_z(star(1).get_logn_comp()(), 0., 1, "logn_comp (z=0)", |
| 1167 |
//## &(star(1).get_ent()()) ) ; |
| 1168 |
|
| 1169 |
} |
| 1170 |
|
| 1171 |
// Cleaning |
| 1172 |
// -------- |
| 1173 |
|
| 1174 |
delete peos1 ; |
| 1175 |
delete peos2 ; |
| 1176 |
|
| 1177 |
return EXIT_SUCCESS ; |
| 1178 |
|
| 1179 |
} |