| 1 | /* |
| 2 | * Definition of Lorene class Binary_xcts |
| 3 | * |
| 4 | */ |
| 5 | |
| 6 | /* |
| 7 | * Copyright (c) 2010 Michal Bejger |
| 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_XCTS_H_ |
| 27 | #define __BINARY_XCTS_H_ |
| 28 | |
| 29 | /* |
| 30 | * $Id: binary_xcts.h,v 1.4 2014/10/13 08:52:32 j_novak Exp $ |
| 31 | * $Log: binary_xcts.h,v $ |
| 32 | * Revision 1.4 2014/10/13 08:52:32 j_novak |
| 33 | * Lorene classes and functions now belong to the namespace Lorene. |
| 34 | * |
| 35 | * Revision 1.3 2010/12/20 09:58:31 m_bejger |
| 36 | * Pointer to the linear momentum added |
| 37 | * |
| 38 | * Revision 1.2 2010/12/09 10:35:56 m_bejger |
| 39 | * Declaration of the virial theorem volume version added |
| 40 | * |
| 41 | * Revision 1.1 2010/05/04 07:44:02 m_bejger |
| 42 | * Initial version |
| 43 | * |
| 44 | * |
| 45 | * $Header: /cvsroot/Lorene/C++/Include/binary_xcts.h,v 1.4 2014/10/13 08:52:32 j_novak Exp $ |
| 46 | * |
| 47 | */ |
| 48 | |
| 49 | // Lorene headers |
| 50 | #include "star.h" |
| 51 | |
| 52 | namespace Lorene { |
| 53 | /** |
| 54 | * Binary systems in eXtended Conformal Thin Sandwich formulation. |
| 55 | * *** UNDER DEVELOPMENT *** \ingroup (star) |
| 56 | * |
| 57 | */ |
| 58 | |
| 59 | class Binary_xcts { |
| 60 | |
| 61 | // Data : |
| 62 | // ----- |
| 63 | protected: |
| 64 | |
| 65 | /// First star of the system |
| 66 | Star_bin_xcts star1 ; |
| 67 | |
| 68 | /// Second star of the system |
| 69 | Star_bin_xcts star2 ; |
| 70 | |
| 71 | /** Array of the two stars (to perform loops on the stars): |
| 72 | * \c et[0] contains the address of \c star1 and \c et[1] |
| 73 | * that of \c star2. |
| 74 | */ |
| 75 | Star_bin_xcts* et[2] ; |
| 76 | |
| 77 | /** Angular velocity with respect to an asymptotically inertial |
| 78 | * observer |
| 79 | */ |
| 80 | double omega ; |
| 81 | |
| 82 | /** Absolute X coordinate of the rotation axis |
| 83 | */ |
| 84 | double x_axe ; |
| 85 | |
| 86 | |
| 87 | // Derived data : |
| 88 | // ------------ |
| 89 | protected: |
| 90 | /// Total ADM mass of the system |
| 91 | mutable double* p_mass_adm ; |
| 92 | |
| 93 | /// Total Komar mass of the system |
| 94 | mutable double* p_mass_kom ; |
| 95 | |
| 96 | /// Total angular momentum of the system |
| 97 | mutable Tbl* p_angu_mom ; |
| 98 | |
| 99 | /// Total linear momentum of the system |
| 100 | mutable Tbl* p_lin_mom ; |
| 101 | |
| 102 | /// Total energy of the system |
| 103 | mutable double* p_total_ener ; |
| 104 | |
| 105 | /// Virial theorem error |
| 106 | mutable double* p_virial ; |
| 107 | |
| 108 | /// Virial theorem error (volume version) |
| 109 | mutable double* p_virial_vol ; |
| 110 | |
| 111 | // Constructors - Destructor |
| 112 | // ------------------------- |
| 113 | public: |
| 114 | /** Standard constructor. |
| 115 | * |
| 116 | * @param mp1 Mapping on which \c star1 will be defined |
| 117 | * @param nzet1 Number of domains occupied by \c star1 |
| 118 | * @param eos1 Equation of state of \c star1 |
| 119 | * @param irrot1 should be \c true if \c star1 is irrotational, |
| 120 | * \c false if \c star1 is corotating |
| 121 | * @param mp2 Mapping on which \c star2 will be defined |
| 122 | * @param nzet2 Number of domains occupied by \c star2 |
| 123 | * @param eos2 Equation of state of \c star2 |
| 124 | * @param irrot2 should be \c true if \c star2 is irrotational, |
| 125 | * \c false if \c star2 is corotating |
| 126 | */ |
| 127 | Binary_xcts(Map& mp1, int nzet1, const Eos& eos1, int irrot1, |
| 128 | Map& mp2, int nzet2, const Eos& eos2, int irrot2) ; |
| 129 | |
| 130 | |
| 131 | Binary_xcts(const Binary_xcts& ) ; ///< Copy constructor |
| 132 | |
| 133 | /** Constructor from a file (see \c sauve(FILE* )). |
| 134 | * |
| 135 | * @param mp1 Mapping on which \c star1 will be defined |
| 136 | * @param eos1 Equation of state of \c star1 |
| 137 | * @param mp2 Mapping on which \c star2 will be defined |
| 138 | * @param eos2 Equation of state of \c star2 |
| 139 | * @param fich input file (must have been created by the function |
| 140 | * \c sauve) |
| 141 | */ |
| 142 | Binary_xcts(Map& mp1, const Eos& eos1, Map& mp2, const Eos& eos2, |
| 143 | FILE* fich) ; |
| 144 | |
| 145 | ~Binary_xcts() ; ///< Destructor |
| 146 | |
| 147 | |
| 148 | |
| 149 | // Memory management |
| 150 | // ----------------- |
| 151 | protected: |
| 152 | |
| 153 | /// Deletes all the derived quantities |
| 154 | void del_deriv() const ; |
| 155 | |
| 156 | /// Sets to \c 0x0 all the pointers on derived quantities |
| 157 | void set_der_0x0() const ; |
| 158 | |
| 159 | |
| 160 | // Mutators / assignment |
| 161 | // --------------------- |
| 162 | public: |
| 163 | /// Assignment to another \c Binary_xcts |
| 164 | void operator=(const Binary_xcts&) ; |
| 165 | |
| 166 | /// Read/write of the star no. i |
| 167 | Star_bin_xcts& set(int i) { |
| 168 | assert( (i==1) || (i==2) ); |
| 169 | del_deriv() ; |
| 170 | return *et[i-1] ; |
| 171 | |
| 172 | } ; |
| 173 | |
| 174 | /// Sets the orbital angular velocity [\c f_unit] |
| 175 | double& set_omega() {return omega; } ; |
| 176 | |
| 177 | /// Sets the absolute coordinate X of the rotation axis [\c r_unit] |
| 178 | double& set_x_axe() {return x_axe; } ; |
| 179 | |
| 180 | |
| 181 | // Accessors |
| 182 | // --------- |
| 183 | public: |
| 184 | /// Returns a reference to the star no. i |
| 185 | const Star_bin_xcts& operator()(int i) const |
| 186 | { assert( (i==1) || (i==2) ); |
| 187 | return *et[i-1] ;} ; |
| 188 | |
| 189 | /// Returns the orbital angular velocity [\c f_unit] |
| 190 | double get_omega() const {return omega; } ; |
| 191 | |
| 192 | /// Returns the absolute coordinate X of the rotation axis [\c r_unit] |
| 193 | double get_x_axe() const {return x_axe; } ; |
| 194 | |
| 195 | /** Returns the coordinate separation of the two stellar |
| 196 | * centers [\c r_unit] |
| 197 | */ |
| 198 | double separation() const ; |
| 199 | |
| 200 | |
| 201 | // Outputs |
| 202 | // ------- |
| 203 | public: |
| 204 | void sauve(FILE *) const ; ///< Save in a file |
| 205 | |
| 206 | /// Display |
| 207 | friend ostream& operator<<(ostream&, const Binary_xcts& ) ; |
| 208 | |
| 209 | /// Display in polytropic units |
| 210 | void display_poly(ostream& ) const ; |
| 211 | |
| 212 | /** Write global quantities in a formatted file. |
| 213 | * This file can be read by an external program. |
| 214 | */ |
| 215 | void write_global(ostream& ) const ; |
| 216 | |
| 217 | private: |
| 218 | /// Operator >> (function called by the operator <<). |
| 219 | ostream& operator>>(ostream& ) const ; |
| 220 | |
| 221 | |
| 222 | // Computational routines |
| 223 | // ---------------------- |
| 224 | public: |
| 225 | |
| 226 | /// Total ADM mass |
| 227 | double mass_adm() const ; |
| 228 | |
| 229 | /// Total ADM mass (computed by a volume integral) |
| 230 | double mass_adm_vol() const ; |
| 231 | |
| 232 | /// Total Komar mass |
| 233 | double mass_kom() const ; |
| 234 | |
| 235 | /// Total Komar mass (computed by a volume integral) |
| 236 | double mass_kom_vol() const ; |
| 237 | |
| 238 | /** Total angular momentum. |
| 239 | * |
| 240 | * @return 1-D \c Tbl of size 3, according to |
| 241 | * \li \c angu_mom()(0) = \f$J^r\f$, |
| 242 | * \li \c angu_mom()(1) = \f$J^t\f$, |
| 243 | * \li \c angu_mom()(2) = \f$J^p\f$. |
| 244 | */ |
| 245 | const Tbl& angu_mom() const ; |
| 246 | |
| 247 | /** Total linear momentum. |
| 248 | */ |
| 249 | const Tbl& lin_mom() const ; |
| 250 | |
| 251 | /** Total energy (excluding the rest mass energy). |
| 252 | * |
| 253 | * In the Newtonian case, it is defined as the sum of kinetic, |
| 254 | * internal, and gravitational potential energies. |
| 255 | * |
| 256 | * In the relativistic case, it is defined as |
| 257 | * \f$M_{\rm ADM} - M_{\rm bar,1} - M_{\rm bar,2}\f$. |
| 258 | */ |
| 259 | double total_ener() const ; |
| 260 | |
| 261 | /** Estimates the relative error on the virial theorem |
| 262 | */ |
| 263 | double virial() const ; |
| 264 | |
| 265 | /** Estimates the relative error on the virial theorem |
| 266 | (volume version) */ |
| 267 | double virial_vol() const ; |
| 268 | |
| 269 | /** Estimates the relative error on the Hamiltonian constraint |
| 270 | */ |
| 271 | double ham_constr() const ; |
| 272 | |
| 273 | /** Estimates the relative error on the momentum constraint |
| 274 | */ |
| 275 | const Tbl& mom_constr() const ; |
| 276 | |
| 277 | /** Computes the orbital angular velocity \c omega and the |
| 278 | * position of the rotation axis \c x_axe. |
| 279 | * |
| 280 | * @param fact_omeg_min [input] : determines the lower bound of the |
| 281 | * interval \c [omega_min, omega_max] in which |
| 282 | * \c omega is searched by |
| 283 | * \c omega_min = fact_omeg_min * omega, |
| 284 | * where \c omega is the previous value of the |
| 285 | * angular velocity |
| 286 | * (typical value : \c fact_omeg_min = 0.5) |
| 287 | * |
| 288 | * @param fact_omeg_max [input] : determines the higher bound of the |
| 289 | * interval \c [omega_min, omega_max] in which |
| 290 | * \c omega is searched by |
| 291 | * \c omega_max = fact_omeg_max * omega, |
| 292 | * where \c omega is the previous value of the |
| 293 | * angular velocity. |
| 294 | * (typical value : \c fact_omeg_max = 1.5) |
| 295 | * |
| 296 | * @param xgg1 [output] : x coordinate (relative to star 1 mapping) |
| 297 | * of the ``center of mass'' of star 1 |
| 298 | * |
| 299 | * @param xgg2 [output] : x coordinate (relative to star 2 mapping) |
| 300 | * of the ``center of mass'' of star 2 |
| 301 | * |
| 302 | */ |
| 303 | void orbit(double fact_omeg_min, double fact_omeg_max, double& xgg1, |
| 304 | double& xgg2) ; |
| 305 | |
| 306 | /** Sets the orbital angular velocity to some 2-PN analytical |
| 307 | * value (Keplerian value in the Newtonian case) |
| 308 | */ |
| 309 | void analytical_omega() ; |
| 310 | |
| 311 | /** Sets some analytical template for the shift vector (via the |
| 312 | * members \c w_shift and \c khi_shift of the two |
| 313 | * \c Star_bin. |
| 314 | */ |
| 315 | void analytical_shift() ; |
| 316 | |
| 317 | } ; |
| 318 | |
| 319 | ostream& operator<<(ostream& , const Binary_xcts& ) ; |
| 320 | |
| 321 | } |
| 322 | #endif |