| 1 | /* |
| 2 | * Definition of Lorene class Binaire |
| 3 | * |
| 4 | */ |
| 5 | |
| 6 | /* |
| 7 | * Copyright (c) 2000-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 | |
| 28 | #ifndef __BINAIRE_H_ |
| 29 | #define __BINAIRE_H_ |
| 30 | |
| 31 | /* |
| 32 | * $Id: binaire.h,v 1.6 2014/10/13 08:52:32 j_novak Exp $ |
| 33 | * $Log: binaire.h,v $ |
| 34 | * Revision 1.6 2014/10/13 08:52:32 j_novak |
| 35 | * Lorene classes and functions now belong to the namespace Lorene. |
| 36 | * |
| 37 | * Revision 1.5 2009/06/18 18:42:13 k_taniguchi |
| 38 | * Defined a slightly modified code to determine |
| 39 | * the orbital angular velocity. |
| 40 | * |
| 41 | * Revision 1.4 2003/09/15 15:09:47 e_gourgoulhon |
| 42 | * Added the member function write_global. |
| 43 | * |
| 44 | * Revision 1.3 2002/06/17 14:05:16 j_novak |
| 45 | * friend functions are now also declared outside the class definition |
| 46 | * |
| 47 | * Revision 1.2 2001/12/20 13:00:31 k_taniguchi |
| 48 | * Addition of the Komar mass, the virial error by Gourgoulhon and Bonazzola, and the virial error by Friedman, Uryu, and Shibata. |
| 49 | * |
| 50 | * Revision 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon |
| 51 | * LORENE |
| 52 | * |
| 53 | * Revision 2.11 2001/02/28 14:27:32 keisuke |
| 54 | * *** empty log message *** |
| 55 | * |
| 56 | * Revision 2.10 2000/07/07 14:10:04 eric |
| 57 | * AJout de display_poly. |
| 58 | * |
| 59 | * Revision 2.9 2000/03/17 15:26:53 eric |
| 60 | * Ajout de la fonction analytical_omega. |
| 61 | * |
| 62 | * Revision 2.8 2000/03/15 16:43:12 eric |
| 63 | * Ajout de la fonction analytical_shift(). |
| 64 | * |
| 65 | * Revision 2.7 2000/03/13 14:24:50 eric |
| 66 | * Ajout des membres p_ham_constr et p_mom_constr ainsi que des |
| 67 | * fonctions de calcul associees (verification des equations de contrainte). |
| 68 | * |
| 69 | * Revision 2.6 2000/02/18 14:52:05 eric |
| 70 | * Ajout des membres p_virial et p_total_ener et des fonctions de calcul |
| 71 | * associees. |
| 72 | * |
| 73 | * Revision 2.5 2000/02/12 17:36:39 eric |
| 74 | * Ajout de la fonction separation(). |
| 75 | * |
| 76 | * Revision 2.4 2000/02/12 17:09:02 eric |
| 77 | * Ajout de la fonction orbit. |
| 78 | * |
| 79 | * Revision 2.3 2000/02/04 17:15:05 eric |
| 80 | * Ajout du membre ref_triad. |
| 81 | * |
| 82 | * Revision 2.2 2000/02/02 10:13:08 eric |
| 83 | * Ajout des fonctions de lecture/ecriture omega, x_axe. |
| 84 | * |
| 85 | * Revision 2.1 2000/01/31 17:01:46 eric |
| 86 | * *** empty log message *** |
| 87 | * |
| 88 | * Revision 2.0 2000/01/31 15:57:39 eric |
| 89 | * *** empty log message *** |
| 90 | * |
| 91 | * |
| 92 | * $Header: /cvsroot/Lorene/C++/Include/binaire.h,v 1.6 2014/10/13 08:52:32 j_novak Exp $ |
| 93 | * |
| 94 | */ |
| 95 | |
| 96 | #include "etoile.h" |
| 97 | |
| 98 | namespace Lorene { |
| 99 | /** |
| 100 | * Binary systems. |
| 101 | * |
| 102 | * @version #$Id: binaire.h,v 1.6 2014/10/13 08:52:32 j_novak Exp $# |
| 103 | */ |
| 104 | class Binaire { |
| 105 | |
| 106 | // Data : |
| 107 | // ----- |
| 108 | private: |
| 109 | /** Cartesian triad of the absolute reference frame |
| 110 | * |
| 111 | */ |
| 112 | const Base_vect_cart ref_triad ; |
| 113 | |
| 114 | /// First star of the system |
| 115 | Etoile_bin star1 ; |
| 116 | |
| 117 | /// Second star of the system |
| 118 | Etoile_bin star2 ; |
| 119 | |
| 120 | /** Array of the two stars (to perform loops on the stars): |
| 121 | * {\tt et[0]} contains the address of {\tt star1} and {\tt et[1]} |
| 122 | * that of {\tt star2}. |
| 123 | */ |
| 124 | Etoile_bin* et[2] ; |
| 125 | |
| 126 | /** Angular velocity with respect to an asymptotically inertial |
| 127 | * observer |
| 128 | */ |
| 129 | double omega ; |
| 130 | |
| 131 | /** Absolute X coordinate of the rotation axis |
| 132 | */ |
| 133 | double x_axe ; |
| 134 | |
| 135 | // Derived data : |
| 136 | // ------------ |
| 137 | private: |
| 138 | /// Total ADM mass of the system |
| 139 | mutable double* p_mass_adm ; |
| 140 | |
| 141 | /// Total Komar mass of the system |
| 142 | mutable double* p_mass_kom ; |
| 143 | |
| 144 | /// Total angular momentum of the system |
| 145 | mutable Tbl* p_angu_mom ; |
| 146 | |
| 147 | /// Total energy of the system |
| 148 | mutable double* p_total_ener ; |
| 149 | |
| 150 | /// Virial theorem error |
| 151 | mutable double* p_virial ; |
| 152 | |
| 153 | /// Virial theorem error by E.Gourgoulhon and S.Bonazzola. |
| 154 | mutable double* p_virial_gb ; |
| 155 | |
| 156 | /// Virial theorem error by J.L.Friedman, K.Uryu, and M.Shibata. |
| 157 | mutable double* p_virial_fus ; |
| 158 | |
| 159 | /// Relative error on the Hamiltonian constraint |
| 160 | mutable double* p_ham_constr ; |
| 161 | |
| 162 | /// Relative error on the momentum constraint |
| 163 | mutable Tbl* p_mom_constr ; |
| 164 | |
| 165 | |
| 166 | // Constructors - Destructor |
| 167 | // ------------------------- |
| 168 | public: |
| 169 | /** Standard constructor. |
| 170 | * |
| 171 | * @param mp1 Mapping on which {\tt star1} will be defined |
| 172 | * @param nzet1 Number of domains occupied by {\tt star1} |
| 173 | * @param eos1 Equation of state of {\tt star1} |
| 174 | * @param irrot1 should be {\tt true} if {\tt star1} is irrotational, |
| 175 | * {\tt false} if {\tt star1} is corotating |
| 176 | * @param mp2 Mapping on which {\tt star2} will be defined |
| 177 | * @param nzet2 Number of domains occupied by {\tt star2} |
| 178 | * @param eos2 Equation of state of {\tt star2} |
| 179 | * @param irrot2 should be {\tt true} if {\tt star2} is irrotational, |
| 180 | * {\tt false} if {\tt star2} is corotating |
| 181 | * @param relat should be {\tt true} for a relativistic configuration, |
| 182 | * {\tt false} for a Newtonian one |
| 183 | * |
| 184 | */ |
| 185 | Binaire(Map& mp1, int nzet1, const Eos& eos1, int irrot1, |
| 186 | Map& mp2, int nzet2, const Eos& eos2, int irrot2, |
| 187 | int relat) ; |
| 188 | |
| 189 | |
| 190 | Binaire(const Binaire& ) ; /// Copy constructor |
| 191 | |
| 192 | /** Constructor from a file (see {\tt sauve(FILE* )}). |
| 193 | * |
| 194 | * @param mp1 Mapping on which {\tt star1} will be defined |
| 195 | * @param eos1 Equation of state of {\tt star1} |
| 196 | * @param mp2 Mapping on which {\tt star2} will be defined |
| 197 | * @param eos2 Equation of state of {\tt star2} |
| 198 | * @param fich input file (must have been created by the function |
| 199 | * {\tt sauve}) |
| 200 | */ |
| 201 | Binaire(Map& mp1, const Eos& eos1, Map& mp2, const Eos& eos2, |
| 202 | FILE* fich) ; |
| 203 | |
| 204 | ~Binaire() ; /// Destructor |
| 205 | |
| 206 | |
| 207 | // Memory management |
| 208 | // ----------------- |
| 209 | private: |
| 210 | /// Deletes all the derived quantities |
| 211 | void del_deriv() const ; |
| 212 | |
| 213 | /// Sets to {\tt 0x0} all the pointers on derived quantities |
| 214 | void set_der_0x0() const ; |
| 215 | |
| 216 | // Mutators / assignment |
| 217 | // --------------------- |
| 218 | public: |
| 219 | /// Assignment to another {\tt Binaire} |
| 220 | void operator=(const Binaire&) ; |
| 221 | |
| 222 | /// Read/write of the star no. i |
| 223 | Etoile_bin& set(int i) |
| 224 | { assert( (i==1) || (i==2) ); |
| 225 | del_deriv() ; |
| 226 | return *et[i-1] ;} ; |
| 227 | |
| 228 | /// Sets the orbital angular velocity [{\tt f\_unit}] |
| 229 | double& set_omega() {return omega; } ; |
| 230 | |
| 231 | /// Sets the absolute coordinate X of the rotation axis [{\tt r\_unit}] |
| 232 | double& set_x_axe() {return x_axe; } ; |
| 233 | |
| 234 | |
| 235 | // Accessors |
| 236 | // --------- |
| 237 | public: |
| 238 | /// Returns a reference to the star no. i |
| 239 | const Etoile_bin& operator()(int i) const |
| 240 | { assert( (i==1) || (i==2) ); |
| 241 | return *et[i-1] ;} ; |
| 242 | |
| 243 | /// Returns the orbital angular velocity [{\tt f\_unit}] |
| 244 | double get_omega() const {return omega; } ; |
| 245 | |
| 246 | /// Returns the absolute coordinate X of the rotation axis [{\tt r\_unit}] |
| 247 | double get_x_axe() const {return x_axe; } ; |
| 248 | |
| 249 | /** Returns the coordinate separation of the two stellar |
| 250 | * centers [{\tt r\_unit}] |
| 251 | */ |
| 252 | double separation() const ; |
| 253 | |
| 254 | // Outputs |
| 255 | // ------- |
| 256 | public: |
| 257 | void sauve(FILE *) const ; /// Save in a file |
| 258 | |
| 259 | /// Display |
| 260 | friend ostream& operator<<(ostream& , const Binaire& ) ; |
| 261 | |
| 262 | /// Display in polytropic units |
| 263 | void display_poly(ostream& ) const ; |
| 264 | |
| 265 | /** Write global quantities in a formatted file. |
| 266 | * This file can be read by an external program. |
| 267 | */ |
| 268 | void write_global(ostream& ) const ; |
| 269 | |
| 270 | private: |
| 271 | /// Operator >> (function called by the operator <<). |
| 272 | ostream& operator>>(ostream& ) const ; |
| 273 | |
| 274 | |
| 275 | // Computational routines |
| 276 | // ---------------------- |
| 277 | public: |
| 278 | /// Total ADM mass |
| 279 | double mass_adm() const ; |
| 280 | |
| 281 | /// Total Komar mass |
| 282 | double mass_kom() const ; |
| 283 | |
| 284 | /** Total angular momentum. |
| 285 | * |
| 286 | * @return 1-D {\tt Tbl} of size 3, according to \\ |
| 287 | * {\tt angu\_mom()(0)} = $J^X$, \\ |
| 288 | * {\tt angu\_mom()(1)} = $J^Y$, \\ |
| 289 | * {\tt angu\_mom()(2)} = $J^Z$. |
| 290 | */ |
| 291 | const Tbl& angu_mom() const ; |
| 292 | |
| 293 | /** Total energy (excluding the rest mass energy). |
| 294 | * |
| 295 | * In the Newtonian case, it is defined as the sum of kinetic, |
| 296 | * internal, and gravitational potential energies. |
| 297 | * |
| 298 | * In the relativistic case, it is defined as |
| 299 | * $M_{\rm ADM} - M_{\rm bar,1} - M_{\rm bar,2}$. |
| 300 | */ |
| 301 | double total_ener() const ; |
| 302 | |
| 303 | /** Estimates the relative error on the virial theorem |
| 304 | * (for a relativistic one, |
| 305 | * it returns $|1 - M_{\rm Komar} / M_{\rm ADM}|$) |
| 306 | */ |
| 307 | double virial() const ; |
| 308 | |
| 309 | /** Estimates the relative error on the virial theorem |
| 310 | * calculated by E.Gourgoulhon and S.Bonazzola |
| 311 | * (Class. Quantum Grav. 11, 443 (1994): Eq.(29)) |
| 312 | * normalized by $2 \pi G$. |
| 313 | */ |
| 314 | double virial_gb() const ; |
| 315 | |
| 316 | /** Estimates the relative error on the virial theorem |
| 317 | * calculated by J.L.Friedman, K.Uryu, and M.Shibata |
| 318 | * (PRD accepted, gr-qc/0108070) |
| 319 | * |
| 320 | * The expression used in the LORENE is Eq.(5.7) in the paper |
| 321 | * by M.Shibata and K.Uryu (PRD64, 104017 (2001)) |
| 322 | */ |
| 323 | double virial_fus() const ; |
| 324 | |
| 325 | /** Estimates the relative error on the Hamiltonian constraint |
| 326 | * equation by comparing $\underline\Delta\ln A$ with |
| 327 | * \begin{equation} |
| 328 | * -4\pi A^2 E - {A^2\over 4} K_{ij} K^{ij} - {1\over 2} |
| 329 | * {\overline\nabla}_i \ln A {\overline\nabla}^i \ln A |
| 330 | * \end{equation} |
| 331 | */ |
| 332 | double ham_constr() const ; |
| 333 | |
| 334 | /** Estimates the relative error on the momentum constraint |
| 335 | * equation by comparing ${\overline\nabla}_j K^{ij}$ with |
| 336 | * \begin{equation} |
| 337 | * 8\pi J^i - 5 K^{ij} {\overline\nabla}_j \ln A |
| 338 | * \end{equation} |
| 339 | */ |
| 340 | const Tbl& mom_constr() const ; |
| 341 | |
| 342 | /** Computes the orbital angular velocity {\tt omega} and the |
| 343 | * position of the rotation axis {\tt x\_axe}. |
| 344 | * |
| 345 | * @param fact_omeg_min [input] : determines the lower bound of the |
| 346 | * interval {\tt [omega\_min, omega\_max]} in which |
| 347 | * {\tt omega} is searched by |
| 348 | * {\tt omega\_min = fact\_omeg\_min * omega}, |
| 349 | * where {\tt omega} is the previous value of the |
| 350 | * angular velocity |
| 351 | * (typical value : {\tt fact\_omeg\_min = 0.5}) |
| 352 | * |
| 353 | * @param fact_omeg_max [input] : determines the higher bound of the |
| 354 | * interval {\tt [omega\_min, omega\_max]} in which |
| 355 | * {\tt omega} is searched by |
| 356 | * {\tt omega\_max = fact\_omeg\_max * omega}, |
| 357 | * where {\tt omega} is the previous value of the |
| 358 | * angular velocity. |
| 359 | * (typical value : {\tt fact\_omeg\_max = 1.5}) |
| 360 | * |
| 361 | * @param xgg1 [output] : x coordinate (relative to star 1 mapping) |
| 362 | * of the ``center of mass'' of star 1 |
| 363 | * |
| 364 | * @param xgg2 [output] : x coordinate (relative to star 2 mapping) |
| 365 | * of the ``center of mass'' of star 2 |
| 366 | * |
| 367 | */ |
| 368 | void orbit(double fact_omeg_min, double fact_omeg_max, double& xgg1, |
| 369 | double& xgg2) ; |
| 370 | |
| 371 | /** Computes the orbital angular velocity {\tt omega} and the |
| 372 | * position of the rotation axis {\tt x\_axe}. |
| 373 | * |
| 374 | * @param fact_omeg_min [input] : determines the lower bound of the |
| 375 | * interval {\tt [omega\_min, omega\_max]} in which |
| 376 | * {\tt omega} is searched by |
| 377 | * {\tt omega\_min = fact\_omeg\_min * omega}, |
| 378 | * where {\tt omega} is the previous value of the |
| 379 | * angular velocity |
| 380 | * (typical value : {\tt fact\_omeg\_min = 0.5}) |
| 381 | * |
| 382 | * @param fact_omeg_max [input] : determines the higher bound of the |
| 383 | * interval {\tt [omega\_min, omega\_max]} in which |
| 384 | * {\tt omega} is searched by |
| 385 | * {\tt omega\_max = fact\_omeg\_max * omega}, |
| 386 | * where {\tt omega} is the previous value of the |
| 387 | * angular velocity. |
| 388 | * (typical value : {\tt fact\_omeg\_max = 1.5}) |
| 389 | * |
| 390 | * @param mass1 [input] : baryon rest mass of NS1 |
| 391 | * |
| 392 | * @param mass2 [input] : baryon rest mass of NS2 |
| 393 | * |
| 394 | * @param xgg1 [output] : x coordinate (relative to star 1 mapping) |
| 395 | * of the ``center of mass'' of star 1 |
| 396 | * |
| 397 | * @param xgg2 [output] : x coordinate (relative to star 2 mapping) |
| 398 | * of the ``center of mass'' of star 2 |
| 399 | * |
| 400 | */ |
| 401 | void orbit_eqmass(double fact_omeg_min, double fact_omeg_max, |
| 402 | double mass1, double mass2, |
| 403 | double& xgg1, double& xgg2) ; |
| 404 | |
| 405 | /** Sets the orbital angular velocity to some 2-PN analytical |
| 406 | * value (Keplerian value in the Newtonian case) |
| 407 | */ |
| 408 | void analytical_omega() ; |
| 409 | |
| 410 | /** Sets some analytical template for the shift vector (via the |
| 411 | * members {\tt w\_shift} and {\tt khi\_shift} of the two |
| 412 | * {\tt Etoile\_bin}. |
| 413 | */ |
| 414 | void analytical_shift() ; |
| 415 | |
| 416 | }; |
| 417 | ostream& operator<<(ostream& , const Binaire& ) ; |
| 418 | |
| 419 | } |
| 420 | #endif |