| 1 |
/* |
| 2 |
* Test program for solving Roche-like binaries |
| 3 |
* Fixing the orbital separation and the central value of the star |
| 4 |
*/ |
| 5 |
|
| 6 |
/* |
| 7 |
* Copyright (c) 1999-2001 Keisuke Taniguchi |
| 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 test_roche_C[] = "$Header: /cvsroot/Lorene/Codes/Bin_star/test_roche.C,v 1.3 2014/10/06 15:09:43 j_novak Exp $" ; |
| 28 |
|
| 29 |
/* |
| 30 |
* $Id: test_roche.C,v 1.3 2014/10/06 15:09:43 j_novak Exp $ |
| 31 |
* $Log: test_roche.C,v $ |
| 32 |
* Revision 1.3 2014/10/06 15:09:43 j_novak |
| 33 |
* Modified #include directives to use c++ syntax. |
| 34 |
* |
| 35 |
* Revision 1.2 2003/01/09 11:07:49 j_novak |
| 36 |
* headcpp.h is now compliant with C++ norm. |
| 37 |
* The include files have been ordered, as well as the local_settings_linux |
| 38 |
* |
| 39 |
* Revision 1.1.1.1 2001/11/20 15:19:31 e_gourgoulhon |
| 40 |
* LORENE |
| 41 |
* |
| 42 |
* Revision 1.1 1999/12/24 11:08:16 keisuke |
| 43 |
* Initial revision |
| 44 |
* |
| 45 |
* |
| 46 |
* $Header: /cvsroot/Lorene/Codes/Bin_star/test_roche.C,v 1.3 2014/10/06 15:09:43 j_novak Exp $ |
| 47 |
* |
| 48 |
*/ |
| 49 |
|
| 50 |
// headers C |
| 51 |
#include <cstdlib> |
| 52 |
#include <cmath> |
| 53 |
|
| 54 |
// headers Lorene |
| 55 |
#include "type_parite.h" |
| 56 |
#include "cmp.h" |
| 57 |
#include "utilitaires.h" |
| 58 |
#include "graphique.h" |
| 59 |
#include "param.h" |
| 60 |
|
| 61 |
// Local prototypes: |
| 62 |
Cmp eos_local(const Cmp& ent, int nzet, double n_index) ; |
| 63 |
double funct_zero_ent(double r, const Param& par) ; |
| 64 |
|
| 65 |
//********************************************************************** |
| 66 |
|
| 67 |
void main(){ |
| 68 |
|
| 69 |
// Identification of all the subroutines called by the code : |
| 70 |
|
| 71 |
system("ident test_roche > identif_roche.d") ; |
| 72 |
|
| 73 |
//----------------------------------------------------------------------- |
| 74 |
// Input from file "part.d" |
| 75 |
//----------------------------------------------------------------------- |
| 76 |
|
| 77 |
int type_t, type_p, nt, np, nz, l; |
| 78 |
char blabla[80]; |
| 79 |
double n_index, R_sep, p_ratio ; |
| 80 |
|
| 81 |
//---------------------------------------------------- |
| 82 |
// Declear the polytropic index |
| 83 |
//---------------------------------------------------- |
| 84 |
cout << "Input the polytropic index : " ; |
| 85 |
cin >> n_index ; |
| 86 |
cout << "Input the orbital separation : " ; |
| 87 |
cin >> R_sep ; |
| 88 |
cout << "Input the ratio M_1/M_2 : " ; |
| 89 |
cin >> p_ratio ; |
| 90 |
|
| 91 |
ifstream fich("part.d") ; |
| 92 |
fich >> nt; fich.getline(blabla, 80); |
| 93 |
fich >> np; fich.getline(blabla, 80); |
| 94 |
fich >> nz; fich.getline(blabla, 80); |
| 95 |
|
| 96 |
cout << "nb de points en phi : np = " << np << endl; |
| 97 |
cout << "nb de points en theta : nt = " << nt << endl; |
| 98 |
cout << "nb de zones : nz = " << nz << endl; |
| 99 |
|
| 100 |
// initialisation des tableaux decrivant chaque zone |
| 101 |
|
| 102 |
int* nr = new int[nz]; |
| 103 |
int* nt_tab = new int[nz]; |
| 104 |
int* np_tab = new int[nz]; |
| 105 |
double* bornes = new double[nz+1]; |
| 106 |
int* type_r = new int[nz]; |
| 107 |
|
| 108 |
fich >> bornes[nz] ; fich.getline(blabla, 80) ; |
| 109 |
for (l=0; l<nz; l++) { |
| 110 |
fich >> nr[l]; |
| 111 |
fich >> bornes[l]; |
| 112 |
fich >> type_r[l]; fich.getline(blabla, 80); |
| 113 |
np_tab[l] = np ; |
| 114 |
nt_tab[l] = nt ; |
| 115 |
} |
| 116 |
if (type_r[nz-1]==UNSURR) bornes[nz] = 1./bornes[nz] ; |
| 117 |
|
| 118 |
fich.close(); |
| 119 |
|
| 120 |
|
| 121 |
//----------------------------------------------------------------------- |
| 122 |
// Construction of a multi-grid |
| 123 |
//----------------------------------------------------------------------- |
| 124 |
|
| 125 |
type_t = SYM ; |
| 126 |
type_p = NONSYM ; |
| 127 |
|
| 128 |
Mg3d mg(nz, nr, type_r, nt_tab, type_t, np_tab, type_p) ; |
| 129 |
|
| 130 |
cout << endl << "Grid mg : " << mg << endl ; |
| 131 |
|
| 132 |
//----------------------------------------------------------------------- |
| 133 |
// Construction of a mapping |
| 134 |
//----------------------------------------------------------------------- |
| 135 |
|
| 136 |
Map_af mp(mg, bornes) ; |
| 137 |
cout << "Mapping mp : " << mp << endl ; |
| 138 |
|
| 139 |
//----------------------------------------------------------------------- |
| 140 |
// Construction of a Cmp |
| 141 |
//----------------------------------------------------------------------- |
| 142 |
|
| 143 |
//---------------------- |
| 144 |
// Spherical Star |
| 145 |
//---------------------- |
| 146 |
Cmp rho(mp) ; |
| 147 |
|
| 148 |
// Initial density profile |
| 149 |
//------------------------- |
| 150 |
rho = 1 ; // rho = 1 in internal domains |
| 151 |
rho.annule(nz-1) ; // rho = 0 in external domain |
| 152 |
|
| 153 |
rho.set_dzpuis(4) ; |
| 154 |
rho.std_base_scal() ; // Sets the standard basis for spectral expansions |
| 155 |
|
| 156 |
Cmp pot_star(mp) ; |
| 157 |
Cmp rho_prev_star(mp) ; |
| 158 |
|
| 159 |
Cmp ent_star(mp) ; |
| 160 |
double ent_star_c = 1 ; // central value of enthalpy |
| 161 |
double ent_star_s = 0 ; // surface value of enthalpy |
| 162 |
|
| 163 |
int nr_star = mg.get_nr(nz-2) ; |
| 164 |
|
| 165 |
do { |
| 166 |
|
| 167 |
// Solving the Poisson equation |
| 168 |
//------------------------------ |
| 169 |
pot_star = - rho.poisson() ; |
| 170 |
|
| 171 |
// Obtaining "lambda" in order to rescale the mapping |
| 172 |
//---------------------------------------------------- |
| 173 |
double pot_star_c = pot_star(0,0,0,0) ; |
| 174 |
double pot_star_s = pot_star(nz-2,0,0,nr_star-1) ; |
| 175 |
|
| 176 |
double lambda2_star = (ent_star_s - ent_star_c) / |
| 177 |
(pot_star_s - pot_star_c) ; |
| 178 |
cout << "lambda2_star : " << lambda2_star << endl ; |
| 179 |
|
| 180 |
// New potential after rescaling |
| 181 |
//------------------------------- |
| 182 |
pot_star = lambda2_star * pot_star ; |
| 183 |
pot_star_c *= lambda2_star ; |
| 184 |
|
| 185 |
// First integral of motion |
| 186 |
// ------------------------- |
| 187 |
ent_star = ent_star_c + pot_star - pot_star_c ; |
| 188 |
// enthalpy is just the same as the Lane-Emden function Theta |
| 189 |
|
| 190 |
// Rescale of the mapping |
| 191 |
//------------------------ |
| 192 |
mp.homothetie( sqrt(lambda2_star) ) ; |
| 193 |
|
| 194 |
// EOS : rho = rho(H) |
| 195 |
//-------------------- |
| 196 |
rho_prev_star = rho ; |
| 197 |
rho = pow(abs(ent_star), n_index) ; |
| 198 |
|
| 199 |
rho.annule(nz-1) ; |
| 200 |
rho.set_dzpuis(4) ; |
| 201 |
rho.std_base_scal() ; |
| 202 |
|
| 203 |
cout << max(abs(rho - rho_prev_star)) << endl; |
| 204 |
cout << "Maximum difference between rho and rho_prev : " |
| 205 |
<< max(diffrel(rho, rho_prev_star)) << endl ; |
| 206 |
|
| 207 |
} while(max(diffrel(rho, rho_prev_star)) > 1.e-6) ; |
| 208 |
|
| 209 |
arrete() ; |
| 210 |
|
| 211 |
// Mass of the star |
| 212 |
//------------------ |
| 213 |
double mass = rho.integrale() ; |
| 214 |
|
| 215 |
//--------------- |
| 216 |
// Binary |
| 217 |
//--------------- |
| 218 |
const Coord& r = mp.r ; |
| 219 |
const Coord& x = mp.x ; |
| 220 |
const Coord& y = mp.y ; |
| 221 |
const Coord& z = mp.z ; |
| 222 |
const Coord& sint = mp.sint ; |
| 223 |
|
| 224 |
Cmp pot(mp) ; |
| 225 |
Cmp pot2(mp) ; |
| 226 |
Cmp pot3(mp) ; |
| 227 |
Cmp disp(mp) ; |
| 228 |
Cmp rho_pot3(mp) ; |
| 229 |
Cmp rho_disp(mp) ; |
| 230 |
Cmp rho_prev(mp) ; |
| 231 |
Cmp rot(mp) ; |
| 232 |
|
| 233 |
Cmp ent(mp) ; |
| 234 |
double ent_c = 1 ; |
| 235 |
double ent_s = 0 ; |
| 236 |
|
| 237 |
double cc ; |
| 238 |
double cc_prev ; |
| 239 |
double rel_cc ; |
| 240 |
cc = 0 ; |
| 241 |
|
| 242 |
cout << "mass = " << mass << endl ; |
| 243 |
double mass_prev ; |
| 244 |
double rel_mass ; |
| 245 |
|
| 246 |
double omega2 ; |
| 247 |
double omega2_prev ; |
| 248 |
double rel_omega ; |
| 249 |
omega2 = mass * (1 + p_ratio) / (M_PI * p_ratio * R_sep * R_sep * R_sep) ; |
| 250 |
cout << "omega^2 = " << omega2 << endl ; |
| 251 |
|
| 252 |
double r_x ; |
| 253 |
int nr_s = mg.get_nr(nz-2) ; |
| 254 |
|
| 255 |
arrete() ; |
| 256 |
|
| 257 |
do { |
| 258 |
|
| 259 |
// Solving the Poisson equation |
| 260 |
//------------------------------ |
| 261 |
pot = - rho.poisson() ; |
| 262 |
|
| 263 |
// Angular velocity |
| 264 |
//------------------ |
| 265 |
omega2_prev = omega2 ; |
| 266 |
pot3 = (R_sep - x) / pow((R_sep-x) * (R_sep-x) + y*y + z*z, 1.5) ; |
| 267 |
disp = x ; |
| 268 |
|
| 269 |
rho_pot3 = rho * pot3 ; |
| 270 |
rho_pot3.annule(nz-1) ; |
| 271 |
rho_pot3.set_dzpuis(4) ; |
| 272 |
rho_pot3.std_base_scal() ; |
| 273 |
|
| 274 |
rho_disp = rho * disp ; |
| 275 |
rho_disp.annule(nz-1) ; |
| 276 |
rho_disp.set_dzpuis(4) ; |
| 277 |
rho_disp.std_base_scal() ; |
| 278 |
|
| 279 |
double integ1 = rho_pot3.integrale() ; |
| 280 |
double integ2 = rho_disp.integrale() ; |
| 281 |
|
| 282 |
// cout << "Integrales : " << endl |
| 283 |
// << integ1 << endl << integ2 << endl ; |
| 284 |
|
| 285 |
omega2 = (1/(p_ratio * M_PI)) * integ1 / |
| 286 |
(R_sep/(1+p_ratio) - integ2 / mass) ; |
| 287 |
|
| 288 |
cout << "Omega^2/(pi G rho_c) : " << omega2 << endl ; |
| 289 |
|
| 290 |
rel_omega = fabs(1. - omega2_prev / omega2) ; |
| 291 |
cout << "Relative error in Omega^2 : " << rel_omega << endl ; |
| 292 |
|
| 293 |
// Obtaining "lambda" in order to rescale the mapping |
| 294 |
//---------------------------------------------------- |
| 295 |
double pot_c = pot(0,0,0,0) ; |
| 296 |
r_x = mp.val_r(nz-2,1.,M_PI/2,0) ; |
| 297 |
cout << "Radius x : " << r_x << endl ; |
| 298 |
double pot_sx = pot.val_point(r_x,M_PI/2,0) ; |
| 299 |
cout << pot_c << endl << pot_sx << endl ; |
| 300 |
|
| 301 |
double lambda2 = (ent_c - ent_s + |
| 302 |
0.25 * mass * |
| 303 |
(1/(R_sep - r_x) - 1/R_sep) / (p_ratio * M_PI) + |
| 304 |
0.125 * omega2 * |
| 305 |
(-2. * R_sep * r_x / (1+p_ratio) + r_x * r_x)) / |
| 306 |
(pot_c - pot_sx) ; |
| 307 |
|
| 308 |
cout << "lambda2 : " << lambda2 << endl ; |
| 309 |
|
| 310 |
// Integration constant |
| 311 |
//---------------------- |
| 312 |
cc_prev = cc ; |
| 313 |
cc = ent_c - pot_c - 0.25 * mass / (p_ratio * M_PI * R_sep) |
| 314 |
-0.125 * omega2 * R_sep * R_sep / ((1+p_ratio) * (1+p_ratio)) ; |
| 315 |
cout << "Integration constant : " << cc << endl ; |
| 316 |
|
| 317 |
rel_cc = fabs(1. - cc_prev / cc) ; |
| 318 |
cout << "Relative error in cc : " << rel_cc << endl ; |
| 319 |
|
| 320 |
// New potential after rescaling |
| 321 |
//------------------------------- |
| 322 |
pot = lambda2 * pot ; |
| 323 |
pot_c = lambda2 * pot_c ; |
| 324 |
pot_sx = lambda2 * pot_sx ; |
| 325 |
|
| 326 |
// First integration of motion |
| 327 |
//----------------------------- |
| 328 |
rot = 0.125 * omega2 * (- 2*R_sep*x/(1+p_ratio) + x*x + y*y) ; |
| 329 |
rot.annule(nz-1) ; |
| 330 |
pot2 = 1./pow( (R_sep - x) * (R_sep - x) + y*y + z*z, 0.5) - 1/R_sep ; |
| 331 |
// pot2.set_dzpuis(4) ; |
| 332 |
// pot2.std_base_scal() ; |
| 333 |
|
| 334 |
ent = ent_c - pot_c + pot + |
| 335 |
0.25 * mass * pot2 / (p_ratio * M_PI) + rot ; |
| 336 |
ent.annule(nz-1) ; |
| 337 |
// ent.set_dzpuis(4) ; |
| 338 |
// ent.std_base_scal() ; |
| 339 |
|
| 340 |
|
| 341 |
// Rescaling of the map |
| 342 |
//---------------------- |
| 343 |
mp.homothetie( sqrt(lambda2) ) ; |
| 344 |
|
| 345 |
rho_prev = rho ; |
| 346 |
|
| 347 |
// EOS : rho = rho(H) |
| 348 |
//-------------------- |
| 349 |
rho = eos_local(ent, nz-1, n_index) ; |
| 350 |
|
| 351 |
rho.set_dzpuis(4) ; |
| 352 |
rho.std_base_scal() ; |
| 353 |
|
| 354 |
cout << max(abs(rho - rho_prev)) << endl ; |
| 355 |
|
| 356 |
// Mass of the star |
| 357 |
//------------------ |
| 358 |
mass_prev = mass ; |
| 359 |
mass = rho.integrale() ; |
| 360 |
cout << "Mass/rho_c : " << mass << endl ; |
| 361 |
|
| 362 |
rel_mass = fabs(1. - mass_prev/mass) ; |
| 363 |
cout << "Relative error in Mass : " << rel_mass << endl ; |
| 364 |
|
| 365 |
cout << "Maximum difference between rho and rho_prev : " |
| 366 |
<< max(diffrel(rho, rho_prev)) << endl ; |
| 367 |
|
| 368 |
} while(max(diffrel(rho, rho_prev)) > 1.e-4) ; |
| 369 |
|
| 370 |
cout << "Coef of rho : " << endl ; |
| 371 |
rho.affiche_seuil(cout) ; |
| 372 |
|
| 373 |
cout << "Coef of pot : " << endl ; |
| 374 |
pot.affiche_seuil(cout) ; |
| 375 |
|
| 376 |
arrete() ; |
| 377 |
cout << "Value of pot at the origin : " << pot(0,0,0,0) << endl ; |
| 378 |
cout << "Value of pot at the surface (r=ray) : " |
| 379 |
<< pot(nz-1,0,0,0) << endl ; |
| 380 |
cout << "Value of pot at the surface (r=ray) : " |
| 381 |
<< pot(nz-2,0,0,nr_s-1) << endl ; |
| 382 |
// arrete() ; |
| 383 |
|
| 384 |
// Checking whether or not the potential satisfies the Poisson equation |
| 385 |
//---------------------------------------------------------------------- |
| 386 |
Cmp lap = - pot.laplacien() ; |
| 387 |
|
| 388 |
cout << "max( |lap(pot) - rho| ) " << max(abs(lap - rho)) << endl ; |
| 389 |
cout << "relative error : " << diffrel(lap, rho) << endl ; |
| 390 |
|
| 391 |
// Searching the radius to the x-axis direction |
| 392 |
//---------------------------------------------- |
| 393 |
Param par_funct_zero_x ; |
| 394 |
par_funct_zero_x.add_cmp(ent) ; |
| 395 |
double phi_search_x = 0 ; |
| 396 |
double theta_search_x = M_PI/2 ; |
| 397 |
par_funct_zero_x.add_double(theta_search_x, 0) ; |
| 398 |
par_funct_zero_x.add_double(phi_search_x, 1) ; |
| 399 |
|
| 400 |
double r_min_search_x = 0 ; |
| 401 |
double r_max_search_x = r_x ; |
| 402 |
double precis_x = 1e-10 ; |
| 403 |
int nitermax_x = 100 ; |
| 404 |
int niter_x ; |
| 405 |
|
| 406 |
double radius_x = zerosec(funct_zero_ent, par_funct_zero_x, |
| 407 |
r_min_search_x, r_max_search_x, precis_x, |
| 408 |
nitermax_x, niter_x) ; |
| 409 |
|
| 410 |
cout << "Radius of the star in the x-axis direction : " << radius_x |
| 411 |
<< endl ; |
| 412 |
|
| 413 |
// Searching the radius opposite to the x-axis direction |
| 414 |
//------------------------------------------------------- |
| 415 |
Param par_funct_zero_xopp ; |
| 416 |
par_funct_zero_xopp.add_cmp(ent) ; |
| 417 |
double phi_search_xopp = M_PI ; |
| 418 |
double theta_search_xopp = M_PI/2 ; |
| 419 |
par_funct_zero_xopp.add_double(theta_search_xopp, 0) ; |
| 420 |
par_funct_zero_xopp.add_double(phi_search_xopp, 1) ; |
| 421 |
|
| 422 |
double r_min_search_xopp = 0 ; |
| 423 |
double r_max_search_xopp = r_x ; |
| 424 |
double precis_xopp = 1e-10 ; |
| 425 |
int nitermax_xopp = 100 ; |
| 426 |
int niter_xopp ; |
| 427 |
|
| 428 |
double radius_xopp = zerosec(funct_zero_ent, par_funct_zero_xopp, |
| 429 |
r_min_search_xopp, r_max_search_xopp, precis_xopp, |
| 430 |
nitermax_xopp, niter_xopp) ; |
| 431 |
|
| 432 |
cout << "Radius of the star opposite to the x-axis direction : " |
| 433 |
<< radius_xopp << endl ; |
| 434 |
|
| 435 |
// Searching the radius to the y-axis direction |
| 436 |
//---------------------------------------------- |
| 437 |
Param par_funct_zero_y ; |
| 438 |
par_funct_zero_y.add_cmp(ent) ; |
| 439 |
double phi_search_y = M_PI/2 ; |
| 440 |
double theta_search_y = M_PI/2 ; |
| 441 |
par_funct_zero_y.add_double(theta_search_y, 0) ; |
| 442 |
par_funct_zero_y.add_double(phi_search_y, 1) ; |
| 443 |
|
| 444 |
double r_min_search_y = 0 ; |
| 445 |
double r_max_search_y = r_x ; |
| 446 |
double precis_y = 1e-10 ; |
| 447 |
int nitermax_y = 100 ; |
| 448 |
int niter_y ; |
| 449 |
|
| 450 |
double radius_y = zerosec(funct_zero_ent, par_funct_zero_y, |
| 451 |
r_min_search_y, r_max_search_y, precis_y, |
| 452 |
nitermax_y, niter_y) ; |
| 453 |
|
| 454 |
cout << "Radius of the star in the y-axis direction : " << radius_y |
| 455 |
<< endl ; |
| 456 |
|
| 457 |
// Searching the radius to the north pole |
| 458 |
//---------------------------------------- |
| 459 |
Param par_funct_zero_z ; |
| 460 |
par_funct_zero_z.add_cmp(ent) ; |
| 461 |
double phi_search_z = 0 ; |
| 462 |
double theta_search_z = 0 ; |
| 463 |
par_funct_zero_z.add_double(theta_search_z, 0) ; |
| 464 |
par_funct_zero_z.add_double(phi_search_z, 1) ; |
| 465 |
|
| 466 |
double r_min_search_z = 0 ; |
| 467 |
double r_max_search_z = r_x ; |
| 468 |
double precis_z = 1e-10 ; |
| 469 |
int nitermax_z = 100 ; |
| 470 |
int niter_z ; |
| 471 |
|
| 472 |
double radius_z = zerosec(funct_zero_ent, par_funct_zero_z, |
| 473 |
r_min_search_z, r_max_search_z, precis_z, |
| 474 |
nitermax_z, niter_z) ; |
| 475 |
|
| 476 |
cout << "Radius of the star in the z-axis direction : " << radius_z |
| 477 |
<< endl ; |
| 478 |
|
| 479 |
// Radius of the star |
| 480 |
//-------------------- |
| 481 |
double ray = mp.val_r(nz-2,1.,M_PI/2,0) ; |
| 482 |
cout << "Radius of the star in the x-axis direction : " << ray << endl ; |
| 483 |
|
| 484 |
cout << "The ratios of the axes : " << endl |
| 485 |
<< "a_2/a_1 : " << radius_y/radius_x << endl |
| 486 |
<< "a_3/a_1 : " << radius_z/radius_x << endl ; |
| 487 |
|
| 488 |
// Angular velocity |
| 489 |
//------------------ |
| 490 |
double omega = sqrt(omega2) ; |
| 491 |
|
| 492 |
cout << "Angular velocity of the star Omega/(pi G rho_c)^{1/2} : " |
| 493 |
<< omega << endl ; |
| 494 |
cout << "Angular velocity Omega^2/(pi G rho_c) : " << omega2 << endl ; |
| 495 |
|
| 496 |
arrete() ; |
| 497 |
|
| 498 |
// Total energy of the binary system |
| 499 |
//----------------------------------- |
| 500 |
|
| 501 |
// Internal energy |
| 502 |
Cmp rho_n(mp) ; |
| 503 |
|
| 504 |
rho_n = pow(abs(rho), 1 + 1/n_index) ; |
| 505 |
rho_n.annule(nz-1) ; |
| 506 |
rho_n.set_dzpuis(4) ; |
| 507 |
rho_n.std_base_scal() ; |
| 508 |
|
| 509 |
double energy_internal = 4. * M_PI * |
| 510 |
(1 / (1 + n_index)) * rho_n.integrale() * ray / (mass * mass) ; |
| 511 |
cout << "Internal energy of the Roche binary system : E_int/(GM^2/ray) : " |
| 512 |
<< n_index * energy_internal << endl ; |
| 513 |
|
| 514 |
// Self-gravity energy |
| 515 |
Cmp rho_pot(mp) ; |
| 516 |
rho_pot = rho * pot ; |
| 517 |
rho_pot.annule(nz-1) ; |
| 518 |
rho_pot.set_dzpuis(4) ; |
| 519 |
rho_pot.std_base_scal() ; |
| 520 |
double energy_selfgrav = -2. * M_PI * rho_pot.integrale() * ray / |
| 521 |
(mass * mass) ; |
| 522 |
cout << |
| 523 |
"Self-gravity energy of the Roche binary system : E_self/(GM^2/ray) : " |
| 524 |
<< energy_selfgrav << endl ; |
| 525 |
|
| 526 |
// Interaction energy |
| 527 |
Cmp pot21(mp) ; |
| 528 |
Cmp rho_pot21(mp) ; |
| 529 |
pot21 = 1/pow((R_sep-x) * (R_sep-x) + y*y + z*z, 0.5) ; |
| 530 |
rho_pot21 = rho * pot21 ; |
| 531 |
rho_pot21.annule(nz-1) ; |
| 532 |
rho_pot21.set_dzpuis(4) ; |
| 533 |
rho_pot21.std_base_scal() ; |
| 534 |
double energy_interact = -0.5 * rho_pot21.integrale() * ray / |
| 535 |
(mass * p_ratio) ; |
| 536 |
cout << |
| 537 |
"Interaction energy of the Roche binary system : E_ext/(GM^2/ray) : " |
| 538 |
<< energy_interact << endl ; |
| 539 |
|
| 540 |
// Kinetic energy |
| 541 |
Cmp rr(mp) ; |
| 542 |
Cmp rho_quad(mp) ; |
| 543 |
rr = r * r * sint * sint - 2.*R_sep*x/(1+p_ratio) ; |
| 544 |
rho_quad = rho * rr ; |
| 545 |
rho_quad.annule(nz-1) ; |
| 546 |
rho_quad.set_dzpuis(4) ; |
| 547 |
rho_quad.std_base_scal() ; |
| 548 |
double energy_kinetic = 0.5 * M_PI * omega2 * |
| 549 |
( pow(R_sep/(1+p_ratio), 2) + rho_quad.integrale() / mass ) * ray/mass ; |
| 550 |
cout << "Kinetic energy of the Roche binary system : E_kinet/(GM^2/ray) : " |
| 551 |
<< energy_kinetic << endl ; |
| 552 |
|
| 553 |
double energy_total = n_index * energy_internal + energy_selfgrav |
| 554 |
+ energy_kinetic + energy_interact ; |
| 555 |
|
| 556 |
cout << "Total energy of the Roche binary system : E/(GM^2/ray) : " |
| 557 |
<< energy_total << endl ; |
| 558 |
|
| 559 |
// Angular momentum |
| 560 |
//------------------ |
| 561 |
double angmom = sqrt(M_PI) * omega * |
| 562 |
( mass * pow(R_sep/(1+p_ratio), 2) + rho_quad.integrale() ) / |
| 563 |
sqrt( mass * mass * mass * ray ) ; |
| 564 |
|
| 565 |
cout << |
| 566 |
"Angular momentum of the Roche binary system : J/(GM^3 ray)^{1/2} : " |
| 567 |
<< angmom << endl ; |
| 568 |
|
| 569 |
// Virial relation |
| 570 |
//----------------- |
| 571 |
double virial = 3. * energy_internal + energy_selfgrav |
| 572 |
+ 2. * energy_kinetic + energy_interact ; |
| 573 |
cout << "Virial relation : " << virial << endl ; |
| 574 |
|
| 575 |
//------------------------------------------ |
| 576 |
// Plot the figures |
| 577 |
//------------------------------------------ |
| 578 |
double rmax ; |
| 579 |
cout << "r_max ?" << endl ; |
| 580 |
cin >> rmax ; |
| 581 |
|
| 582 |
des_profile(rho, 0., rmax, M_PI/2, 0., "rho/rho_c","rho (x direction)") ; |
| 583 |
des_profile(rho, 0.,rmax,M_PI/2,M_PI/2,"rho/rho_c","rho (y direction)") ; |
| 584 |
des_profile(rho, 0., rmax, 0., 0., "rho/rho_c", "rho (z direction)") ; |
| 585 |
|
| 586 |
des_profile(ent,0.,rmax,M_PI/2,0.,"enthalpy","enthalpy (x direction)") ; |
| 587 |
des_profile(ent,0.,rmax,M_PI/2,M_PI/2,"enthalpy", |
| 588 |
"enthalpy (y direction)") ; |
| 589 |
des_profile(ent,0.,rmax,0.,0.,"enthalpy","enthalpy (z direction)") ; |
| 590 |
|
| 591 |
/* |
| 592 |
des_profile(rho_n,0.,rmax,M_PI/2,0.,"rho_n","rho_n (x direction)") ; |
| 593 |
des_profile(rho_n,0.,rmax,M_PI/2,M_PI/2,"rho_n","rho_n (y direction)") ; |
| 594 |
des_profile(rho_n,0.,rmax,0.,0.,"rho_n","rho_n (z direction)") ; |
| 595 |
|
| 596 |
des_profile(rho_pot,0.,rmax,M_PI/2,0.,"rho_pot","rho_pot (x direction)") ; |
| 597 |
des_profile(rho_pot,0.,rmax,M_PI/2,M_PI/2,"rho_pot", |
| 598 |
"rho_pot (y direction)") ; |
| 599 |
des_profile(rho_pot,0.,rmax,0.,0.,"rho_pot","rho_pot (z direction)") ; |
| 600 |
|
| 601 |
des_profile(rho_pot21,0.,rmax,M_PI/2,0.,"rho_pot21", |
| 602 |
"rho_pot21 (x direction)") ; |
| 603 |
des_profile(rho_pot21,0.,rmax,M_PI/2,M_PI/2,"rho_pot21", |
| 604 |
"rho_pot21 (y direction)") ; |
| 605 |
des_profile(rho_pot21,0.,rmax,0.,0.,"rho_pot21", |
| 606 |
"rho_pot21 (z direction)") ; |
| 607 |
|
| 608 |
des_profile(rho_quad,0.,rmax,M_PI/2,0.,"rho_quad", |
| 609 |
"rho_quad (x direction)") ; |
| 610 |
des_profile(rho_quad,0.,rmax,M_PI/2,M_PI/2,"rho_quad", |
| 611 |
"rho_quad (y direction)") ; |
| 612 |
des_profile(rho_quad,0.,rmax,0.,0.,"rho_quad","rho_quad (z direction)") ; |
| 613 |
*/ |
| 614 |
|
| 615 |
des_coupe_x(rho, 0., -rmax, rmax, -rmax, rmax, "rho (y-z plane)", &ent) ; |
| 616 |
des_coupe_y(rho, 0., -rmax, rmax, -rmax, rmax, "rho (z-x plane)", &ent) ; |
| 617 |
des_coupe_z(rho, 0., -rmax, rmax, -rmax, rmax, "rho (x-y plane)", &ent) ; |
| 618 |
|
| 619 |
des_coef_xi(rho.va, 0, 0, 0, 1.e-14, "log|c_i|", "domain no. 0") ; |
| 620 |
des_coef_theta(rho.va, 0, 0, 0) ; |
| 621 |
des_coef_phi(rho.va, 0, 0, 0) ; |
| 622 |
|
| 623 |
des_coef_xi(rho.va, 1, 0, 0, 1.e-14, "log|c_i|", "domain no. 1") ; |
| 624 |
des_coef_theta(rho.va, 0, 0, 0) ; |
| 625 |
des_coef_phi(rho.va, 0, 0, 0) ; |
| 626 |
|
| 627 |
exit(-1) ; |
| 628 |
|
| 629 |
} |
| 630 |
|