| 1 | /* |
| 2 | * Definition of class Bin_NS (binary neutron star exportation) |
| 3 | * |
| 4 | */ |
| 5 | |
| 6 | /* |
| 7 | * Copyright (c) 2002 Eric Gourgoulhon |
| 8 | * Copyright (c) 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 version 2 |
| 14 | * as published by the Free Software Foundation. |
| 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 | #ifndef __BIN_NS_H_ |
| 28 | #define __BIN_NS_H_ |
| 29 | |
| 30 | /* |
| 31 | * $Id: bin_ns.h,v 1.7 2014/10/13 08:54:05 j_novak Exp $ |
| 32 | * $Log: bin_ns.h,v $ |
| 33 | * Revision 1.7 2014/10/13 08:54:05 j_novak |
| 34 | * Lorene classes and functions now belong to the namespace Lorene. |
| 35 | * |
| 36 | * Revision 1.6 2014/10/06 15:13:25 j_novak |
| 37 | * Modified #include directives to use c++ syntax. |
| 38 | * |
| 39 | * Revision 1.5 2010/07/14 16:47:30 e_gourgoulhon |
| 40 | * Corrected error in the documentation for K_xx, K_xy, etc...: |
| 41 | * the components are the covariant ones, not the contravariant ones. |
| 42 | * |
| 43 | * Revision 1.4 2004/10/20 15:01:37 e_gourgoulhon |
| 44 | * Corrected error in the comments on the shift vector: |
| 45 | * corotating coordinates -> non rotating coordinates. |
| 46 | * |
| 47 | * Revision 1.3 2003/10/24 15:49:03 e_gourgoulhon |
| 48 | * Updated documentation. |
| 49 | * |
| 50 | * Revision 1.2 2003/01/09 11:08:00 j_novak |
| 51 | * headcpp.h is now compliant with C++ norm. |
| 52 | * The include files have been ordered, as well as the local_settings_linux |
| 53 | * |
| 54 | * Revision 1.1 2002/01/11 17:03:02 e_gourgoulhon |
| 55 | * Exportation of binary neutron stars configuration to a Cartesian grid |
| 56 | * |
| 57 | * |
| 58 | * $Header: /cvsroot/Lorene/Export/C++/Include/bin_ns.h,v 1.7 2014/10/13 08:54:05 j_novak Exp $ |
| 59 | * |
| 60 | */ |
| 61 | |
| 62 | // Headers C |
| 63 | #include <cstdio> |
| 64 | |
| 65 | #include <iostream> |
| 66 | #include <fstream> |
| 67 | |
| 68 | using namespace std ; |
| 69 | |
| 70 | namespace Lorene { |
| 71 | /** |
| 72 | * Binary neutron star configuration on a Cartesian grid. |
| 73 | * |
| 74 | * A binary black hole system is constructed on a Cartesian grid from |
| 75 | * data stored in a file resulting from a computation by Taniguchi |
| 76 | * and Gourgoulhon. |
| 77 | * |
| 78 | * Importation of Lorene data is performed by means of the constructor |
| 79 | * {\tt Bin\_NS::Bin\_NS(int, const double*, const double*, const double*, const char*)}. |
| 80 | * This constructor takes general arrays for the location of the Cartesian coordinates |
| 81 | * $(x, y, z)$, i.e. it does not assume that the grid is a uniform one. Note also |
| 82 | * that these arrays are 1-D, as well as all the metric fields, |
| 83 | * in order to be use with any ordering of the 3-D storage. |
| 84 | * |
| 85 | * This class is very simple, with all data members being public. |
| 86 | * A typical example of use is the following one |
| 87 | * |
| 88 | * \begin{verbatim} |
| 89 | * // Define the Cartesian grid by means of the arrays xg, yg, zg: |
| 90 | * for (int i=0; i<nb_points; i++) { |
| 91 | * xg[i] = ... |
| 92 | * yg[i] = ... |
| 93 | * zg[i] = ... |
| 94 | * } |
| 95 | * |
| 96 | * // Read the file containing the spectral data and evaluate |
| 97 | * // all the fields on the Cartesian grid : |
| 98 | * |
| 99 | * Bin_NS binary_system(nb_points, xg, yg, zg, datafile) ; |
| 100 | * |
| 101 | * // Extract what you need : |
| 102 | * |
| 103 | * double* gamma_xx = binary_system.g_xx ; // metric coefficient g_xx |
| 104 | * |
| 105 | * double* shift_x = binary_system.beta_x ; // x comp. of shift vector |
| 106 | * |
| 107 | * ... |
| 108 | * |
| 109 | * // Save everything in an ASCII file : |
| 110 | * |
| 111 | * ofstream file_ini("ini.d") ; |
| 112 | * binary_system.save_form(file_ini) ; |
| 113 | * file_ini.close() ; |
| 114 | * |
| 115 | * \end{verbatim} |
| 116 | * |
| 117 | * @version #$Id: bin_ns.h,v 1.7 2014/10/13 08:54:05 j_novak Exp $# |
| 118 | */ |
| 119 | |
| 120 | class Bin_NS { |
| 121 | |
| 122 | // Data : |
| 123 | // ----- |
| 124 | public: |
| 125 | /// Eos name star 1 |
| 126 | char eos_name1[100] ; |
| 127 | |
| 128 | /// Adiabatic index of EOS 1 if it is polytropic (0 otherwise) |
| 129 | double gamma_poly1 ; |
| 130 | |
| 131 | /** |
| 132 | * Polytropic constant of EOS 1 if it is polytropic (0 otherwise) |
| 133 | * [unit: $\rho_{\rm nuc} c^2 / n_{\rm nuc}^\gamma$] |
| 134 | */ |
| 135 | double kappa_poly1 ; |
| 136 | |
| 137 | /// Eos name star 2 |
| 138 | char eos_name2[100] ; |
| 139 | |
| 140 | /// Adiabatic index of EOS 2 if it is polytropic (0 otherwise) |
| 141 | double gamma_poly2 ; |
| 142 | |
| 143 | /** |
| 144 | * Polytropic constant of EOS 2 if it is polytropic (0 otherwise) |
| 145 | * [unit: $\rho_{\rm nuc} c^2 / n_{\rm nuc}^\gamma$] |
| 146 | */ |
| 147 | double kappa_poly2 ; |
| 148 | |
| 149 | /// Orbital angular velocity [unit: rad/s] |
| 150 | double omega ; |
| 151 | |
| 152 | /** Distance between the centers (maxiumum density) of the two neutron |
| 153 | * stars [unit: km] |
| 154 | */ |
| 155 | double dist ; |
| 156 | |
| 157 | /** Distance between the center of masses of two neutron stars |
| 158 | * [unit: km] |
| 159 | */ |
| 160 | double dist_mass ; |
| 161 | |
| 162 | /** Baryon mass of star 1 (less massive star) |
| 163 | * [unit: $M_\odot$] |
| 164 | */ |
| 165 | double mass1_b ; |
| 166 | |
| 167 | /** Baryon mass of star 2 (massive star) |
| 168 | * [unit: $M_\odot$] |
| 169 | */ |
| 170 | double mass2_b ; |
| 171 | |
| 172 | /** ADM mass of the binary system |
| 173 | * [unit: $M_\odot$] |
| 174 | */ |
| 175 | double mass_adm ; |
| 176 | |
| 177 | /** Total angular momentum of the binary system |
| 178 | * [unit: $GM_\odot^2/c$] |
| 179 | */ |
| 180 | double angu_mom ; |
| 181 | |
| 182 | /** Coordinate radius of star 1 (less massive star) |
| 183 | * parallel to the x axis toward the companion star |
| 184 | * [unit: km] |
| 185 | */ |
| 186 | double rad1_x_comp ; |
| 187 | |
| 188 | /** Coordinate radius of star 1 (less massive star) |
| 189 | * parallel to the y axis [unit: km]. |
| 190 | */ |
| 191 | double rad1_y ; |
| 192 | |
| 193 | /** Coordinate radius of star 1 (less massive star) |
| 194 | * parallel to the z axis [unit: km]. |
| 195 | */ |
| 196 | double rad1_z ; |
| 197 | |
| 198 | /** Coordinate radius of star 1 (less massive star) |
| 199 | * parallel to the x axis opposite to the companion star |
| 200 | * [unit: km]. |
| 201 | */ |
| 202 | double rad1_x_opp ; |
| 203 | |
| 204 | /** Coordinate radius of star 2 (massive star) |
| 205 | * parallel to the x axis toward the companion star |
| 206 | * [unit: km]. |
| 207 | */ |
| 208 | double rad2_x_comp ; |
| 209 | |
| 210 | /** Coordinate radius of star 2 (massive star) |
| 211 | * parallel to the y axis [unit: km]. |
| 212 | */ |
| 213 | double rad2_y ; |
| 214 | |
| 215 | /** Coordinate radius of star 2 (massive star) |
| 216 | * parallel to the z axis [unit: km]. |
| 217 | */ |
| 218 | double rad2_z ; |
| 219 | |
| 220 | /** Coordinate radius of star 2 (massive star) |
| 221 | * parallel to the x axis opposite to the companion star |
| 222 | * [unit: km]. |
| 223 | */ |
| 224 | double rad2_x_opp ; |
| 225 | |
| 226 | |
| 227 | /// Total number of grid points |
| 228 | int np ; |
| 229 | |
| 230 | /// 1-D array storing the values of coordinate x of the {\tt np} grid points [unit: km] |
| 231 | double* xx ; |
| 232 | |
| 233 | /// 1-D array storing the values of coordinate y of the {\tt np} grid points [unit: km] |
| 234 | double* yy ; |
| 235 | |
| 236 | /// 1-D array storing the values of coordinate z of the {\tt np} grid points [unit: km] |
| 237 | double* zz ; |
| 238 | |
| 239 | /// Lapse function $N$ at the {\tt np} grid points (1-D array) |
| 240 | double* nnn ; |
| 241 | |
| 242 | /// Component $\beta^x$ of the shift vector of non rotating coordinates [unit: $c$] |
| 243 | double* beta_x ; |
| 244 | |
| 245 | /// Component $\beta^y$ of the shift vector of non rotating coordinates [unit: $c$] |
| 246 | double* beta_y ; |
| 247 | |
| 248 | /// Component $\beta^z$ of the shift vector of non rotating coordinates [unit: $c$] |
| 249 | double* beta_z ; |
| 250 | |
| 251 | /// Metric coefficient $\gamma_{xx}$ at the grid points (1-D array) |
| 252 | double* g_xx ; |
| 253 | |
| 254 | /// Metric coefficient $\gamma_{xy}$ at the grid points (1-D array) |
| 255 | double* g_xy ; |
| 256 | |
| 257 | /// Metric coefficient $\gamma_{xz}$ at the grid points (1-D array) |
| 258 | double* g_xz ; |
| 259 | |
| 260 | /// Metric coefficient $\gamma_{yy}$ at the grid points (1-D array) |
| 261 | double* g_yy ; |
| 262 | |
| 263 | /// Metric coefficient $\gamma_{yz}$ at the grid points (1-D array) |
| 264 | double* g_yz ; |
| 265 | |
| 266 | /// Metric coefficient $\gamma_{zz}$ at the grid points (1-D array) |
| 267 | double* g_zz ; |
| 268 | |
| 269 | /// Component $K_{xx}$ of the extrinsic curvature at the grid points (1-D array) [unit: c/km] |
| 270 | double* k_xx ; |
| 271 | |
| 272 | /// Component $K_{xy}$ of the extrinsic curvature at the grid points (1-D array) [unit: c/km] |
| 273 | double* k_xy ; |
| 274 | |
| 275 | /// Component $K_{xz}$ of the extrinsic curvature at the grid points (1-D array) [unit: c/km] |
| 276 | double* k_xz ; |
| 277 | |
| 278 | /// Component $K_{yy}$ of the extrinsic curvature at the grid points (1-D array) [unit: c/km] |
| 279 | double* k_yy ; |
| 280 | |
| 281 | /// Component $K_{yz}$ of the extrinsic curvature at the grid points (1-D array) [unit: c/km] |
| 282 | double* k_yz ; |
| 283 | |
| 284 | /// Component $K_{zz}$ of the extrinsic curvature at the grid points (1-D array) [unit: c/km] |
| 285 | double* k_zz ; |
| 286 | |
| 287 | // Hydro components |
| 288 | //------------------ |
| 289 | /** Baryon density in the fluid frame at the {\tt np} grid points (1-D array) |
| 290 | * [unit: ${\rm kg \, m}^{-3}$] |
| 291 | */ |
| 292 | double* nbar ; |
| 293 | |
| 294 | /// Specific internal energy at the {\tt np} grid points (1-D array) [unit: $c^2$] |
| 295 | double* ener_spec ; |
| 296 | |
| 297 | /** Component $U^x$ of the fluid 3-velocity with respect to the Eulerian |
| 298 | * observer, at the {\tt np} grid points (1-D array) [unit: $c$] |
| 299 | */ |
| 300 | double* u_euler_x ; |
| 301 | |
| 302 | /** Component $U^y$ of the fluid 3-velocity with respect to the Eulerian |
| 303 | * observer, at the {\tt np} grid points (1-D array) [unit: $c$] |
| 304 | */ |
| 305 | double* u_euler_y ; |
| 306 | |
| 307 | /** Component $U^z$ of the fluid 3-velocity with respect to the Eulerian |
| 308 | * observer, at the {\tt np} grid points (1-D array) [unit: $c$] |
| 309 | */ |
| 310 | double* u_euler_z ; |
| 311 | |
| 312 | |
| 313 | // Constructors - Destructor |
| 314 | // ------------------------- |
| 315 | public: |
| 316 | /** Constructor from Lorene spectral data. |
| 317 | * |
| 318 | * This constructor takes general arrays {\tt xi, yi, zi} |
| 319 | * for the location of the Cartesian coordinates |
| 320 | * $(x, y, z)$, i.e. it does not assume that the grid is a uniform one. |
| 321 | * These arrays are 1-D to deal with any ordering of a 3-D storage. |
| 322 | * |
| 323 | * @param nbpoints [input] Total number of grid points |
| 324 | * @param xi [input] 1-D array (size {\tt nbpoints}) storing the |
| 325 | * values of coordinate x of the grid points [unit: km] |
| 326 | * @param yi [input] 1-D array (size {\tt nbpoints}) storing the |
| 327 | * values of coordinate y of the grid points [unit: km] |
| 328 | * @param zi [input] 1-D array (size {\tt nbpoints}) storing the |
| 329 | * values of coordinate z of the grid points [unit: km] |
| 330 | * @param filename [input] Name of the (binary) file containing the result |
| 331 | * of a computation by means of the multi-domain |
| 332 | * spectral method. |
| 333 | */ |
| 334 | Bin_NS(int nbpoints, const double* xi, const double* yi, |
| 335 | const double* zi, const char* filename) ; |
| 336 | |
| 337 | |
| 338 | /** Constructor from a binary file |
| 339 | * (previously created by {\tt save\_bin}) |
| 340 | */ |
| 341 | Bin_NS(FILE* ) ; |
| 342 | |
| 343 | /** Constructor from a formatted file |
| 344 | * (previously created by {\tt save\_form}) |
| 345 | */ |
| 346 | Bin_NS(ifstream& ) ; |
| 347 | |
| 348 | /// Destructor |
| 349 | ~Bin_NS() ; |
| 350 | |
| 351 | |
| 352 | // Memory management |
| 353 | // ----------------- |
| 354 | private: |
| 355 | |
| 356 | /// Allocate the memory for the arrays g\_ij, k\_ij, etc... |
| 357 | void alloc_memory() ; |
| 358 | |
| 359 | // Outputs |
| 360 | // ------- |
| 361 | public: |
| 362 | /** Save in a binary file. |
| 363 | * This file can be subsenquently read by the evolution code, |
| 364 | * or by the constructor {\tt Bin\_NS::Bin\_NS(FILE* )}. |
| 365 | */ |
| 366 | void save_bin(FILE* ) const ; |
| 367 | |
| 368 | /** Save in a formatted file. |
| 369 | * This file can be subsenquently read by the evolution code, |
| 370 | * or by the constructor {\tt Bin\_NS::Bin\_NS(ifstream\& )}. |
| 371 | */ |
| 372 | void save_form(ofstream& ) const ; |
| 373 | |
| 374 | /// Display |
| 375 | friend ostream& operator<<(ostream& , const Bin_NS& ) ; |
| 376 | |
| 377 | }; |
| 378 | |
| 379 | } |
| 380 | #endif |