| 1 | /* |
| 2 | * Definition of Lorene class Binary |
| 3 | * |
| 4 | */ |
| 5 | |
| 6 | /* |
| 7 | * Copyright (c) 2004 Limousin Francois |
| 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 version 2 |
| 13 | * as published by the Free Software Foundation. |
| 14 | * |
| 15 | * LORENE is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with LORENE; if not, write to the Free Software |
| 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 23 | * |
| 24 | */ |
| 25 | |
| 26 | #ifndef __BINARY_H_ |
| 27 | #define __BINARY_H_ |
| 28 | |
| 29 | /* |
| 30 | * $Id: binary.h,v 1.10 2014/10/13 08:52:32 j_novak Exp $ |
| 31 | * $Log: binary.h,v $ |
| 32 | * Revision 1.10 2014/10/13 08:52:32 j_novak |
| 33 | * Lorene classes and functions now belong to the namespace Lorene. |
| 34 | * |
| 35 | * Revision 1.9 2006/04/11 14:26:12 f_limousin |
| 36 | * New version of the code : improvement of the computation of some |
| 37 | * critical sources, estimation of the dirac gauge, helical symmetry... |
| 38 | * |
| 39 | * Revision 1.8 2005/11/08 20:17:55 f_limousin |
| 40 | * Add function dirac_gauge() used to impose Dirac gauge during an iteration. |
| 41 | * |
| 42 | * Revision 1.7 2005/09/15 15:56:28 e_gourgoulhon |
| 43 | * Made the documentation compliant with Doxygen. |
| 44 | * |
| 45 | * Revision 1.6 2005/09/13 19:38:32 f_limousin |
| 46 | * Reintroduction of the resolution of the equations in cartesian coordinates. |
| 47 | * |
| 48 | * Revision 1.5 2004/07/21 11:45:20 f_limousin |
| 49 | * Add function mass_adm_vol() to compute the ADM mass of the system |
| 50 | * with a volume integral instead of a surface one. |
| 51 | * |
| 52 | * Revision 1.4 2004/05/25 14:50:06 f_limousin |
| 53 | * Add the virial theorem for conformally flat configurations. |
| 54 | * |
| 55 | * Revision 1.3 2004/01/20 15:25:39 f_limousin |
| 56 | * Nex class binary |
| 57 | * |
| 58 | * |
| 59 | * $Header: /cvsroot/Lorene/C++/Include/binary.h,v 1.10 2014/10/13 08:52:32 j_novak Exp $ |
| 60 | * |
| 61 | */ |
| 62 | |
| 63 | // Lorene headers |
| 64 | #include "star.h" |
| 65 | |
| 66 | namespace Lorene { |
| 67 | /** |
| 68 | * Binary systems. *** UNDER DEVELOPMENT *** \ingroup (star) |
| 69 | * |
| 70 | * @version #$Id: binary.h,v 1.10 2014/10/13 08:52:32 j_novak Exp $# |
| 71 | */ |
| 72 | |
| 73 | class Binary { |
| 74 | |
| 75 | // Data : |
| 76 | // ----- |
| 77 | protected: |
| 78 | |
| 79 | /// First star of the system |
| 80 | Star_bin star1 ; |
| 81 | |
| 82 | /// Second star of the system |
| 83 | Star_bin star2 ; |
| 84 | |
| 85 | /** Array of the two stars (to perform loops on the stars): |
| 86 | * \c et[0] contains the address of \c star1 and \c et[1] |
| 87 | * that of \c star2. |
| 88 | */ |
| 89 | Star_bin* et[2] ; |
| 90 | |
| 91 | /** Angular velocity with respect to an asymptotically inertial |
| 92 | * observer |
| 93 | */ |
| 94 | double omega ; |
| 95 | |
| 96 | /** Absolute X coordinate of the rotation axis |
| 97 | */ |
| 98 | double x_axe ; |
| 99 | |
| 100 | |
| 101 | // Derived data : |
| 102 | // ------------ |
| 103 | protected: |
| 104 | /// Total ADM mass of the system |
| 105 | mutable double* p_mass_adm ; |
| 106 | |
| 107 | /// Total Komar mass of the system |
| 108 | mutable double* p_mass_kom ; |
| 109 | |
| 110 | /// Total angular momentum of the system |
| 111 | mutable Tbl* p_angu_mom ; |
| 112 | |
| 113 | /// Total energy of the system |
| 114 | mutable double* p_total_ener ; |
| 115 | |
| 116 | /// Virial theorem error |
| 117 | mutable double* p_virial ; |
| 118 | |
| 119 | /// Relative error on the Hamiltonian constraint |
| 120 | mutable double* p_ham_constr ; |
| 121 | |
| 122 | /// Relative error on the momentum constraint |
| 123 | mutable Tbl* p_mom_constr ; |
| 124 | |
| 125 | |
| 126 | |
| 127 | // Constructors - Destructor |
| 128 | // ------------------------- |
| 129 | public: |
| 130 | /** Standard constructor. |
| 131 | * |
| 132 | * @param mp1 Mapping on which \c star1 will be defined |
| 133 | * @param nzet1 Number of domains occupied by \c star1 |
| 134 | * @param eos1 Equation of state of \c star1 |
| 135 | * @param irrot1 should be \c true if \c star1 is irrotational, |
| 136 | * \c false if \c star1 is corotating |
| 137 | * @param mp2 Mapping on which \c star2 will be defined |
| 138 | * @param nzet2 Number of domains occupied by \c star2 |
| 139 | * @param eos2 Equation of state of \c star2 |
| 140 | * @param irrot2 should be \c true if \c star2 is irrotational, |
| 141 | * \c false if \c star2 is corotating |
| 142 | * @param conf_flat should be \c true for a 3-metric conformally |
| 143 | * flat and \c false for a more general one. |
| 144 | */ |
| 145 | Binary(Map& mp1, int nzet1, const Eos& eos1, int irrot1, |
| 146 | Map& mp2, int nzet2, const Eos& eos2, int irrot2, |
| 147 | int conf_flat) ; |
| 148 | |
| 149 | |
| 150 | Binary(const Binary& ) ; ///< Copy constructor |
| 151 | |
| 152 | /** Constructor from a file (see \c sauve(FILE* )). |
| 153 | * |
| 154 | * @param mp1 Mapping on which \c star1 will be defined |
| 155 | * @param eos1 Equation of state of \c star1 |
| 156 | * @param mp2 Mapping on which \c star2 will be defined |
| 157 | * @param eos2 Equation of state of \c star2 |
| 158 | * @param fich input file (must have been created by the function |
| 159 | * \c sauve) |
| 160 | */ |
| 161 | Binary(Map& mp1, const Eos& eos1, Map& mp2, const Eos& eos2, |
| 162 | FILE* fich) ; |
| 163 | |
| 164 | ~Binary() ; ///< Destructor |
| 165 | |
| 166 | |
| 167 | |
| 168 | // Memory management |
| 169 | // ----------------- |
| 170 | protected: |
| 171 | |
| 172 | /// Deletes all the derived quantities |
| 173 | void del_deriv() const ; |
| 174 | |
| 175 | /// Sets to \c 0x0 all the pointers on derived quantities |
| 176 | void set_der_0x0() const ; |
| 177 | |
| 178 | |
| 179 | // Mutators / assignment |
| 180 | // --------------------- |
| 181 | public: |
| 182 | /// Assignment to another \c Binary |
| 183 | void operator=(const Binary&) ; |
| 184 | |
| 185 | /// Read/write of the star no. i |
| 186 | Star_bin& set(int i) |
| 187 | { assert( (i==1) || (i==2) ); |
| 188 | del_deriv() ; |
| 189 | return *et[i-1] ;} ; |
| 190 | |
| 191 | /// Sets the orbital angular velocity [\c f_unit] |
| 192 | double& set_omega() {return omega; } ; |
| 193 | |
| 194 | /// Sets the absolute coordinate X of the rotation axis [\c r_unit] |
| 195 | double& set_x_axe() {return x_axe; } ; |
| 196 | |
| 197 | |
| 198 | // Accessors |
| 199 | // --------- |
| 200 | public: |
| 201 | /// Returns a reference to the star no. i |
| 202 | const Star_bin& operator()(int i) const |
| 203 | { assert( (i==1) || (i==2) ); |
| 204 | return *et[i-1] ;} ; |
| 205 | |
| 206 | /// Returns the orbital angular velocity [\c f_unit] |
| 207 | double get_omega() const {return omega; } ; |
| 208 | |
| 209 | /// Returns the absolute coordinate X of the rotation axis [\c r_unit] |
| 210 | double get_x_axe() const {return x_axe; } ; |
| 211 | |
| 212 | /** Returns the coordinate separation of the two stellar |
| 213 | * centers [\c r_unit] |
| 214 | */ |
| 215 | double separation() const ; |
| 216 | |
| 217 | |
| 218 | // Outputs |
| 219 | // ------- |
| 220 | public: |
| 221 | void sauve(FILE *) const ; ///< Save in a file |
| 222 | |
| 223 | /// Display |
| 224 | friend ostream& operator<<(ostream& , const Binary& ) ; |
| 225 | |
| 226 | /// Display in polytropic units |
| 227 | void display_poly(ostream& ) const ; |
| 228 | |
| 229 | /** Write global quantities in a formatted file. |
| 230 | * This file can be read by an external program. |
| 231 | */ |
| 232 | void write_global(ostream& ) const ; |
| 233 | |
| 234 | private: |
| 235 | /// Operator >> (function called by the operator <<). |
| 236 | ostream& operator>>(ostream& ) const ; |
| 237 | |
| 238 | |
| 239 | // Computational routines |
| 240 | // ---------------------- |
| 241 | public: |
| 242 | |
| 243 | /// Total ADM mass |
| 244 | double mass_adm() const ; |
| 245 | |
| 246 | /// Total ADM mass (computed by a volume integral) |
| 247 | double mass_adm_vol() const ; |
| 248 | |
| 249 | /// Total Komar mass |
| 250 | double mass_kom() const ; |
| 251 | |
| 252 | /// Total Komar mass (computed by a volume integral) |
| 253 | double mass_kom_vol() const ; |
| 254 | |
| 255 | /** Total angular momentum. |
| 256 | * |
| 257 | * @return 1-D \c Tbl of size 3, according to |
| 258 | * \li \c angu_mom()(0) = \f$J^r\f$, |
| 259 | * \li \c angu_mom()(1) = \f$J^t\f$, |
| 260 | * \li \c angu_mom()(2) = \f$J^p\f$. |
| 261 | */ |
| 262 | const Tbl& angu_mom() const ; |
| 263 | |
| 264 | /** Total energy (excluding the rest mass energy). |
| 265 | * |
| 266 | * In the Newtonian case, it is defined as the sum of kinetic, |
| 267 | * internal, and gravitational potential energies. |
| 268 | * |
| 269 | * In the relativistic case, it is defined as |
| 270 | * \f$M_{\rm ADM} - M_{\rm bar,1} - M_{\rm bar,2}\f$. |
| 271 | */ |
| 272 | double total_ener() const ; |
| 273 | |
| 274 | /** Estimates the relative error on the virial theorem |
| 275 | */ |
| 276 | double virial() const ; |
| 277 | |
| 278 | /** Estimates the relative error on the Hamiltonian constraint |
| 279 | */ |
| 280 | double ham_constr() const ; |
| 281 | |
| 282 | /** Estimates the relative error on the momentum constraint |
| 283 | */ |
| 284 | const Tbl& mom_constr() const ; |
| 285 | |
| 286 | /** Computes the orbital angular velocity \c omega and the |
| 287 | * position of the rotation axis \c x_axe. |
| 288 | * |
| 289 | * @param fact_omeg_min [input] : determines the lower bound of the |
| 290 | * interval \c [omega_min, omega_max] in which |
| 291 | * \c omega is searched by |
| 292 | * \c omega_min = fact_omeg_min * omega, |
| 293 | * where \c omega is the previous value of the |
| 294 | * angular velocity |
| 295 | * (typical value : \c fact_omeg_min = 0.5) |
| 296 | * |
| 297 | * @param fact_omeg_max [input] : determines the higher bound of the |
| 298 | * interval \c [omega_min, omega_max] in which |
| 299 | * \c omega is searched by |
| 300 | * \c omega_max = fact_omeg_max * omega, |
| 301 | * where \c omega is the previous value of the |
| 302 | * angular velocity. |
| 303 | * (typical value : \c fact_omeg_max = 1.5) |
| 304 | * |
| 305 | * @param xgg1 [output] : x coordinate (relative to star 1 mapping) |
| 306 | * of the ``center of mass'' of star 1 |
| 307 | * |
| 308 | * @param xgg2 [output] : x coordinate (relative to star 2 mapping) |
| 309 | * of the ``center of mass'' of star 2 |
| 310 | * |
| 311 | */ |
| 312 | void orbit(double fact_omeg_min, double fact_omeg_max, double& xgg1, |
| 313 | double& xgg2) ; |
| 314 | |
| 315 | /** Sets the orbital angular velocity to some 2-PN analytical |
| 316 | * value (Keplerian value in the Newtonian case) |
| 317 | */ |
| 318 | void analytical_omega() ; |
| 319 | |
| 320 | /** Sets some analytical template for the shift vector (via the |
| 321 | * members \c w_shift and \c khi_shift of the two |
| 322 | * \c Star_bin. |
| 323 | */ |
| 324 | void analytical_shift() ; |
| 325 | |
| 326 | /** |
| 327 | * Calculates \c decouple which is used to obtain |
| 328 | * \c qq_auto by the formula : |
| 329 | * \c qq_auto = \c decouple * \c qq. |
| 330 | * (see the membre \c Scalar \c decouple for more |
| 331 | * precisions about its value). |
| 332 | * |
| 333 | */ |
| 334 | void fait_decouple () ; |
| 335 | |
| 336 | /// Function used to impose Dirac gauge during an iteration |
| 337 | void dirac_gauge() ; |
| 338 | |
| 339 | /// Function testing the helical symmetry |
| 340 | void helical() ; |
| 341 | |
| 342 | |
| 343 | }; |
| 344 | ostream& operator<<(ostream& , const Binary& ) ; |
| 345 | |
| 346 | } |
| 347 | #endif |