| 1 | /* |
| 2 | * Definition of Lorene class Hot_eos. |
| 3 | * |
| 4 | */ |
| 5 | |
| 6 | /* |
| 7 | * Copyright (c) 2015 Jerome Novak |
| 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 __HOTEOS_H_ |
| 27 | #define __HOTEOS_H_ |
| 28 | |
| 29 | /* |
| 30 | * $Id: hoteos.h,v 1.3 2015/12/08 10:52:17 j_novak Exp $ |
| 31 | * $Log: hoteos.h,v $ |
| 32 | * Revision 1.3 2015/12/08 10:52:17 j_novak |
| 33 | * New class Hoteos_tabul for tabulated temperature-dependent EoSs. |
| 34 | * |
| 35 | * Revision 1.2 2015/09/10 13:28:00 j_novak |
| 36 | * New methods for the class Hot_Eos |
| 37 | * |
| 38 | * Revision 1.1 2015/03/17 14:19:59 j_novak |
| 39 | * New class Hot_eos to deal with temperature-dependent EOSs. |
| 40 | * |
| 41 | * |
| 42 | * $Header: /cvsroot/Lorene/C++/Include/hoteos.h,v 1.3 2015/12/08 10:52:17 j_novak Exp $ |
| 43 | * |
| 44 | */ |
| 45 | |
| 46 | //C++ headers |
| 47 | #include "headcpp.h" |
| 48 | |
| 49 | //C headers |
| 50 | #include<cstdio> |
| 51 | #include "tbl.h" |
| 52 | |
| 53 | namespace Lorene{ |
| 54 | |
| 55 | class Scalar ; |
| 56 | class Param ; |
| 57 | class Eos ; |
| 58 | //------------------------------------// |
| 59 | // class Hot_eos // |
| 60 | //------------------------------------// |
| 61 | |
| 62 | /** |
| 63 | * Base class for temperature-dependent equations of state (abstract class). |
| 64 | * \ingroup(eos) |
| 65 | * |
| 66 | */ |
| 67 | class Hot_eos { |
| 68 | |
| 69 | // Data : |
| 70 | // ----- |
| 71 | protected: |
| 72 | string name ; ///< EOS name |
| 73 | |
| 74 | // Constructors - Destructor |
| 75 | // ------------------------- |
| 76 | protected: |
| 77 | Hot_eos() ; ///< Standard constructor |
| 78 | |
| 79 | /// Standard constructor from a name (string) |
| 80 | explicit Hot_eos(const string&) ; |
| 81 | |
| 82 | /// Standard constructor from a name (char*) |
| 83 | explicit Hot_eos(const char*) ; |
| 84 | |
| 85 | Hot_eos(const Hot_eos& ) ; ///< Copy constructor |
| 86 | |
| 87 | /** Constructor from a binary file (created by the function |
| 88 | * \c sauve(FILE*) ). |
| 89 | * This constructor is protected because any hot EOS construction |
| 90 | * from a binary file must be done via the function |
| 91 | * \c Hot_eos::hoteos_from_file(FILE*) . |
| 92 | */ |
| 93 | Hot_eos(FILE* ) ; |
| 94 | |
| 95 | /** Constructor from a formatted file. |
| 96 | * This constructor is protected because any hot EOS construction |
| 97 | * from a formatted file must be done via the function |
| 98 | * \c Hot_eos::hoteos_from_file(ifstream&) . |
| 99 | */ |
| 100 | Hot_eos(ifstream& ) ; |
| 101 | |
| 102 | public: |
| 103 | virtual ~Hot_eos() ; ///< Destructor |
| 104 | |
| 105 | // Derived data : |
| 106 | // ------------ |
| 107 | protected: |
| 108 | mutable Eos* p_cold_eos ; ///< Corresponding cold Eos. |
| 109 | |
| 110 | /// Deletes all the derived quantities |
| 111 | virtual void del_deriv() const ; |
| 112 | |
| 113 | /// Sets to \c 0x0 all the pointers on derived quantities |
| 114 | void set_der_0x0() const ; |
| 115 | |
| 116 | // Name manipulation |
| 117 | // ----------------- |
| 118 | public: |
| 119 | /// Returns the hot EOS name |
| 120 | const string& get_name() const {return name; }; |
| 121 | |
| 122 | /// Sets the hot EOS name |
| 123 | void set_name(const char* ) ; |
| 124 | |
| 125 | // Miscellaneous |
| 126 | // ------------- |
| 127 | public: |
| 128 | /** Construction of an EOS from a binary file. |
| 129 | * The file must have been created by the function \c sauve(FILE*) . |
| 130 | */ |
| 131 | static Hot_eos* hoteos_from_file(FILE* ) ; |
| 132 | |
| 133 | /** Construction of a hot EOS from a formatted file. |
| 134 | * |
| 135 | * The fist line of the file must start by the EOS number, according |
| 136 | * to the following conventions: |
| 137 | * - 1 = relativistic ideal gas (class \c Ideal_gas ). |
| 138 | * - 2 = non-relativistic ideal gas (class \c Ideal_gas_norel ). |
| 139 | * |
| 140 | * The second line in the file should contain a name given by the user to the EOS. |
| 141 | * The following lines should contain the EOS parameters (one |
| 142 | * parameter per line), in the same order than in the class declaration. |
| 143 | */ |
| 144 | static Hot_eos* hoteos_from_file(ifstream& ) ; |
| 145 | |
| 146 | /// Comparison operator (egality) |
| 147 | virtual bool operator==(const Hot_eos& ) const = 0 ; |
| 148 | |
| 149 | /// Comparison operator (difference) |
| 150 | virtual bool operator!=(const Hot_eos& ) const = 0 ; |
| 151 | |
| 152 | /** Returns a number to identify the sub-classe of \c Hot_eos the |
| 153 | * object belongs to. |
| 154 | */ |
| 155 | virtual int identify() const = 0 ; |
| 156 | |
| 157 | // Outputs |
| 158 | // ------- |
| 159 | |
| 160 | public: |
| 161 | virtual void sauve(FILE* ) const ; ///< Save in a file |
| 162 | |
| 163 | /// Display |
| 164 | friend ostream& operator<<(ostream& , const Hot_eos& ) ; |
| 165 | |
| 166 | protected: |
| 167 | virtual ostream& operator>>(ostream &) const = 0 ; ///< Operator >> |
| 168 | |
| 169 | public: |
| 170 | /// Returns the corresponding cold \c Eos. |
| 171 | virtual const Eos& new_cold_Eos() const = 0 ; |
| 172 | |
| 173 | |
| 174 | // Computational functions |
| 175 | // ----------------------- |
| 176 | protected: |
| 177 | /** General computational method for \c Scalar 's |
| 178 | * |
| 179 | * @param thermo1 [input] first thermodynamical quantity (for instance the |
| 180 | * enthalpy field) from which the thermodynamical quantity \c resu |
| 181 | * is to be computed. |
| 182 | * @param thermo2 [input] second thermodynamical quantity (for instance the |
| 183 | * entropy field) from which the thermodynamical quantity \c resu |
| 184 | * is to be computed. |
| 185 | * @param nzet [input] number of domains where \c resu is to be |
| 186 | * computed. |
| 187 | * @param l_min [input] index of the innermost domain is which \c resu |
| 188 | * is to be computed [default value: 0]; \c resu is computed only in |
| 189 | * domains whose indices are in \c [l_min,l_min+nzet-1] . In the other |
| 190 | * domains, it is set to zero. |
| 191 | * @param fait [input] pointer on the member function of class |
| 192 | * \c Hot_eos which performs the pointwise calculation. |
| 193 | * @param resu [output] result of the computation. |
| 194 | */ |
| 195 | void calcule(const Scalar& thermo1, const Scalar& thermo2, int nzet, int l_min, |
| 196 | double (Hot_eos::*fait)(double, double) const, Scalar& resu) const ; |
| 197 | |
| 198 | public: |
| 199 | /** Computes the baryon density from the log-enthalpy and entropy per baryon |
| 200 | * (virtual function implemented in the derived classes). |
| 201 | * |
| 202 | * @param ent [input, unit: \f$c^2\f$] log-enthalpy \e H defined by |
| 203 | * \f$H = c^2 \ln\left( {e+p \over m_B c^2 n} (to be modified) \right) \f$, |
| 204 | * where \e e is the (total) energy density, \e p the pressure, |
| 205 | * \e n the baryon density, and \f$m_B\f$ the baryon mass |
| 206 | * @param sb [input, unit: \f$k_B\f$] entropy per baryon \f$s_b\f$ |
| 207 | * |
| 208 | * @return baryon density [unit: \f$n_{\rm nuc} := 0.1 \ {\rm fm}^{-3}\f$] |
| 209 | * |
| 210 | */ |
| 211 | virtual double nbar_Hs_p(double ent, double sb) const = 0 ; |
| 212 | |
| 213 | /** Computes the baryon density field from the log-enthalpy field and |
| 214 | * entropy per baryon. |
| 215 | * |
| 216 | * @param ent [input, unit: \f$c^2\f$] log-enthalpy \e H defined by |
| 217 | * \f$H = c^2 \ln\left( {e+p \over m_B c^2 n} \right) \f$, |
| 218 | * where \e e is the (total) energy density, \e p the pressure, |
| 219 | * \e n the baryon density, and \f$m_B\f$ the baryon mass |
| 220 | * @param sb [input, unit: \f$k_B\f$] entropy per baryon \f$s_b\f$ |
| 221 | * @param nzet number of domains where the baryon density is to be |
| 222 | * computed. |
| 223 | * @param l_min index of the innermost domain is which the baryon |
| 224 | * density is |
| 225 | * to be computed [default value: 0]; the baryon density is |
| 226 | * computed only in domains whose indices are in |
| 227 | * \c [l_min,l_min+nzet-1] . In the other |
| 228 | * domains, it is set to zero. |
| 229 | * |
| 230 | * @return baryon density [unit: \f$n_{\rm nuc} := 0.1 \ {\rm fm}^{-3}\f$] |
| 231 | * |
| 232 | */ |
| 233 | Scalar nbar_Hs(const Scalar& ent, const Scalar& sb, int nzet, int l_min = 0) const ; |
| 234 | |
| 235 | /** Computes the total energy density from the log-enthalpy and entropy per baryon |
| 236 | * (virtual function implemented in the derived classes). |
| 237 | * |
| 238 | * @param ent [input, unit: \f$c^2\f$] log-enthalpy \e H defined by |
| 239 | * \f$H = c^2 \ln\left( {e+p \over m_B c^2 n} \right) \f$, |
| 240 | * where \e e is the (total) energy density, \e p the pressure, |
| 241 | * \e n the baryon density, and \f$m_B\f$ the baryon mass |
| 242 | * @param sb [input, unit: \f$k_B\f$] entropy per baryon \f$s_b\f$ |
| 243 | * |
| 244 | * @return energy density \e e [unit: \f$\rho_{\rm nuc} c^2\f$], where |
| 245 | * \f$\rho_{\rm nuc} := 1.66\ 10^{17} \ {\rm kg/m}^3\f$ |
| 246 | */ |
| 247 | virtual double ener_Hs_p(double ent, double sb) const = 0 ; |
| 248 | |
| 249 | /** Computes the total energy density from the log-enthalpy and entropy per baryon. |
| 250 | * |
| 251 | * @param ent [input, unit: \f$c^2\f$] log-enthalpy \e H defined by |
| 252 | * \f$H = c^2 \ln\left( {e+p \over m_B c^2 n} \right) \f$, |
| 253 | * where \e e is the (total) energy density, \e p the pressure, |
| 254 | * \e n the baryon density, and \f$m_B\f$ the baryon mass |
| 255 | * @param sb [input, unit: \f$k_B\f$] entropy per baryon \f$s_b\f$ |
| 256 | * @param nzet number of domains where the energy density is to be |
| 257 | * computed. |
| 258 | * @param l_min index of the innermost domain is which the energy |
| 259 | * density is |
| 260 | * to be computed [default value: 0]; the energy density is |
| 261 | * computed only in domains whose indices are in |
| 262 | * \c [l_min,l_min+nzet-1] . In the other |
| 263 | * domains, it is set to zero. |
| 264 | * |
| 265 | * @return energy density [unit: \f$\rho_{\rm nuc} c^2\f$], where |
| 266 | * \f$\rho_{\rm nuc} := 1.66\ 10^{17} \ {\rm kg/m}^3\f$ |
| 267 | */ |
| 268 | Scalar ener_Hs(const Scalar& ent, const Scalar& sb, int nzet, int l_min = 0) const ; |
| 269 | |
| 270 | /** Computes the pressure from the log-enthalpy and entropy per baryon |
| 271 | * (virtual function implemented in the derived classes). |
| 272 | * |
| 273 | * @param ent [input, unit: \f$c^2\f$] log-enthalpy \e H defined by |
| 274 | * \f$H = c^2 \ln\left( {e+p \over m_B c^2 n} \right) \f$, |
| 275 | * where \e e is the (total) energy density, \e p the pressure, |
| 276 | * \e n the baryon density, and \f$m_B\f$ the baryon mass |
| 277 | * @param sb [input, unit: \f$k_B\f$] entropy per baryon \f$s_b\f$ |
| 278 | * |
| 279 | * @return pressure \e p [unit: \f$\rho_{\rm nuc} c^2\f$], where |
| 280 | * \f$\rho_{\rm nuc} := 1.66\ 10^{17} \ {\rm kg/m}^3\f$ |
| 281 | */ |
| 282 | virtual double press_Hs_p(double ent, double sb) const = 0 ; |
| 283 | |
| 284 | /** Computes the pressure from the log-enthalpy and entropy per baryon. |
| 285 | * |
| 286 | * @param ent [input, unit: \f$c^2\f$] log-enthalpy \e H defined by |
| 287 | * \f$H = c^2 \ln\left( {e+p \over m_B c^2 n} \right) \f$, |
| 288 | * where \e e is the (total) energy density, \e p the pressure, |
| 289 | * \e n the baryon density, and \f$m_B\f$ the baryon mass |
| 290 | * @param sb [input, unit: \f$k_B\f$] entropy per baryon \f$s_b\f$ |
| 291 | * @param nzet number of domains where the pressure is to be |
| 292 | * computed. |
| 293 | * @param l_min index of the innermost domain is which the pressure is |
| 294 | * to be computed [default value: 0]; the pressure is computed |
| 295 | * only in domains whose indices are in \c [l_min,l_min+nzet-1] . |
| 296 | * In the other domains, it is set to zero. |
| 297 | * |
| 298 | * @return pressure [unit: \f$\rho_{\rm nuc} c^2\f$], where |
| 299 | * \f$\rho_{\rm nuc} := 1.66\ 10^{17} \ {\rm kg/m}^3\f$ |
| 300 | * |
| 301 | */ |
| 302 | Scalar press_Hs(const Scalar& ent, const Scalar& sb, int nzet, int l_min = 0) const ; |
| 303 | |
| 304 | /** Computes the temperature from the log-enthalpy and entropy per baryon |
| 305 | * (virtual function implemented in the derived classes). |
| 306 | * |
| 307 | * @param ent [input, unit: \f$c^2\f$] log-enthalpy \e H defined by |
| 308 | * \f$H = c^2 \ln\left( {e+p \over m_B c^2 n} (to be modified) \right) \f$, |
| 309 | * where \e e is the (total) energy density, \e p the pressure, |
| 310 | * \e n the baryon density, and \f$m_B\f$ the baryon mass |
| 311 | * @param sb [input, unit: \f$k_B\f$] entropy per baryon \f$s_b\f$ |
| 312 | * |
| 313 | * @return temperature [unit: MeV] |
| 314 | * |
| 315 | */ |
| 316 | virtual double temp_Hs_p(double ent, double sb) const = 0 ; |
| 317 | |
| 318 | /** Computes the temperature field from the log-enthalpy field and |
| 319 | * entropy per baryon. |
| 320 | * |
| 321 | * @param ent [input, unit: \f$c^2\f$] log-enthalpy \e H defined by |
| 322 | * \f$H = c^2 \ln\left( {e+p \over m_B c^2 n} \right) \f$, |
| 323 | * where \e e is the (total) energy density, \e p the pressure, |
| 324 | * \e n the baryon density, and \f$m_B\f$ the baryon mass |
| 325 | * @param sb [input, unit: \f$k_B\f$] entropy per baryon \f$s_b\f$ |
| 326 | * @param nzet number of domains where the baryon density is to be |
| 327 | * computed. |
| 328 | * @param l_min index of the innermost domain is which the baryon |
| 329 | * density is |
| 330 | * to be computed [default value: 0]; the baryon density is |
| 331 | * computed only in domains whose indices are in |
| 332 | * \c [l_min,l_min+nzet-1] . In the other |
| 333 | * domains, it is set to zero. |
| 334 | * |
| 335 | * @return temperature [unit: MeV] |
| 336 | * |
| 337 | */ |
| 338 | Scalar temp_Hs(const Scalar& ent, const Scalar& sb, int nzet, int l_min = 0) const ; |
| 339 | |
| 340 | }; |
| 341 | ostream& operator<<(ostream& , const Hot_eos& ) ; |
| 342 | |
| 343 | //------------------------------------// |
| 344 | // class Ideal_gas // |
| 345 | //------------------------------------// |
| 346 | |
| 347 | /** |
| 348 | * Ideal-gas (temperature-dependent) equation of state, with mass-term |
| 349 | * in the energy density. |
| 350 | * |
| 351 | * \f[ |
| 352 | * p(n, s_b) = \kappa n^\gamma e^{(\gamma-1)s_b}\ .\qquad (1) |
| 353 | * \f] |
| 354 | * and \f[ |
| 355 | * e(n, s_b) = \frac{\kappa}{\gamma - 1} n^\gamma e^{(\gamma-1)s_b} + m_0\, n\ . |
| 356 | * \qquad (2) \f] |
| 357 | * ### (to be written...) |
| 358 | * |
| 359 | *\ingroup (eos) |
| 360 | * |
| 361 | */ |
| 362 | class Ideal_gas : public Hot_eos { |
| 363 | |
| 364 | // Data : |
| 365 | //------- |
| 366 | |
| 367 | protected: |
| 368 | /// Adiabatic index \f$\gamma\f$ |
| 369 | double gam ; |
| 370 | |
| 371 | /** Pressure coefficient \f$\kappa\f$ (cf. Eq. (1)) |
| 372 | * [unit: \f$\rho_{\rm nuc} c^2 / n_{\rm nuc}^\gamma\f$], where |
| 373 | * \f$\rho_{\rm nuc} := 1.66\ 10^{17} \ {\rm kg/m}^3\f$ and |
| 374 | * \f$n_{\rm nuc} := 0.1 \ {\rm fm}^{-3}\f$. |
| 375 | */ |
| 376 | double kap ; |
| 377 | |
| 378 | /** Individual particule mass \f$m_0\f$ (cf. Eq. (2)) |
| 379 | * [unit: \f$m_B = 1.66\ 10^{-27} \ {\rm kg}\f$]. |
| 380 | */ |
| 381 | double m_0 ; |
| 382 | |
| 383 | double gam1 ; ///< \f$\gamma-1\f$ |
| 384 | double unsgam1 ; ///< \f$1/(\gamma-1)\f$ |
| 385 | double gam1sgamkap ; ///< \f$(\gamma-1) / (\gamma \kappa) m_0\f$ |
| 386 | |
| 387 | // Constructors - Destructor |
| 388 | // ------------------------- |
| 389 | public: |
| 390 | |
| 391 | /** Standard constructor. |
| 392 | * |
| 393 | * Unless specified, the individual particle mass \f$m_0\f$ is set |
| 394 | * to the mean baryon mass \f$m_B = 1.66\ 10^{-27} \ {\rm kg}\f$. |
| 395 | * |
| 396 | * @param gamma adiabatic index \f$\gamma\f$ |
| 397 | * @param kappa pressure coefficient \f$\kappa\f$ |
| 398 | * @param mass individual particule mass \f$m_0\f$ |
| 399 | */ |
| 400 | Ideal_gas(double gamma, double kappa, double mass=1.) ; |
| 401 | |
| 402 | Ideal_gas(const Ideal_gas& ) ; ///< Copy constructor |
| 403 | |
| 404 | protected: |
| 405 | /** Constructor from a binary file (created by the function |
| 406 | * \c sauve(FILE*) ). |
| 407 | * This constructor is protected because any hot EOS construction |
| 408 | * from a binary file must be done via the function |
| 409 | * \c Hot_eos::eos_from_file(FILE*) . |
| 410 | */ |
| 411 | Ideal_gas(FILE* ) ; |
| 412 | |
| 413 | /** Constructor from a formatted file. |
| 414 | * This constructor is protected because any EOS construction |
| 415 | * from a formatted file must be done via the function |
| 416 | * \c Hot_eos::hoteos_from_file(ifstream&) . |
| 417 | */ |
| 418 | Ideal_gas(ifstream& ) ; |
| 419 | |
| 420 | /// The construction functions from a file |
| 421 | friend Hot_eos* Hot_eos::hoteos_from_file(FILE* ) ; |
| 422 | friend Hot_eos* Hot_eos::hoteos_from_file(ifstream& ) ; |
| 423 | |
| 424 | public: |
| 425 | virtual ~Ideal_gas() ; ///< Destructor |
| 426 | |
| 427 | // Assignment |
| 428 | // ---------- |
| 429 | /// Assignment to another \c Ideal_gas |
| 430 | void operator=(const Ideal_gas& ) ; |
| 431 | |
| 432 | // Miscellaneous |
| 433 | // ------------- |
| 434 | |
| 435 | public : |
| 436 | /// Comparison operator (egality) |
| 437 | virtual bool operator==(const Hot_eos& ) const ; |
| 438 | |
| 439 | /// Comparison operator (difference) |
| 440 | virtual bool operator!=(const Hot_eos& ) const ; |
| 441 | |
| 442 | /** Returns a number to identify the sub-classe of \c Hot_eos the |
| 443 | * object belongs to. |
| 444 | */ |
| 445 | virtual int identify() const ; |
| 446 | |
| 447 | /// Returns the adiabatic index \f$\gamma\f$ (cf. Eq. (1)). |
| 448 | double get_gam() const ; |
| 449 | |
| 450 | /// Returns the pressure coefficient \f$\kappa\f$ (cf. Eq. (1)). |
| 451 | double get_kap() const ; |
| 452 | |
| 453 | /** Return the individual particule mass \f$m_0\f$ |
| 454 | * (cf. Eq. (1)) |
| 455 | */ |
| 456 | double get_m_0() const ; |
| 457 | |
| 458 | virtual const Eos& new_cold_Eos() const ; |
| 459 | |
| 460 | protected: |
| 461 | /** Computes the auxiliary quantities \c gam1 , \c unsgam1 , |
| 462 | * \c gam1sgamkap from the values of \c gam and \c kap |
| 463 | */ |
| 464 | void set_auxiliary() ; |
| 465 | |
| 466 | // Outputs |
| 467 | // ------- |
| 468 | |
| 469 | public: |
| 470 | virtual void sauve(FILE* ) const ; ///< Save in a file |
| 471 | |
| 472 | protected: |
| 473 | virtual ostream& operator>>(ostream &) const ; ///< Operator >> |
| 474 | |
| 475 | |
| 476 | // Computational functions |
| 477 | // ----------------------- |
| 478 | |
| 479 | public: |
| 480 | /** Computes the baryon density from the log-enthalpy and entropy per baryon |
| 481 | * (virtual function implemented in the derived classes). |
| 482 | * |
| 483 | * @param ent [input, unit: \f$c^2\f$] log-enthalpy \e H defined by |
| 484 | * \f$H = c^2 \ln\left( {e+p \over m_B c^2 n} (to be modified) \right) \f$, |
| 485 | * where \e e is the (total) energy density, \e p the pressure, |
| 486 | * \e n the baryon density, and \f$m_B\f$ the baryon mass |
| 487 | * @param sb [input, unit: \f$k_B\f$] entropy per baryon \f$s_b\f$ |
| 488 | * |
| 489 | * @return baryon density [unit: \f$n_{\rm nuc} := 0.1 \ {\rm fm}^{-3}\f$] |
| 490 | * |
| 491 | */ |
| 492 | virtual double nbar_Hs_p(double ent, double sb) const ; |
| 493 | |
| 494 | /** Computes the total energy density from the log-enthalpy and entropy per baryon |
| 495 | * (virtual function implemented in the derived classes). |
| 496 | * |
| 497 | * @param ent [input, unit: \f$c^2\f$] log-enthalpy \e H defined by |
| 498 | * \f$H = c^2 \ln\left( {e+p \over m_B c^2 n} \right) \f$, |
| 499 | * where \e e is the (total) energy density, \e p the pressure, |
| 500 | * \e n the baryon density, and \f$m_B\f$ the baryon mass |
| 501 | * @param sb [input, unit: \f$k_B\f$] entropy per baryon \f$s_b\f$ |
| 502 | * |
| 503 | * @return energy density \e e [unit: \f$\rho_{\rm nuc} c^2\f$], where |
| 504 | * \f$\rho_{\rm nuc} := 1.66\ 10^{17} \ {\rm kg/m}^3\f$ |
| 505 | */ |
| 506 | virtual double ener_Hs_p(double ent, double sb) const ; |
| 507 | |
| 508 | /** Computes the pressure from the log-enthalpy and entropy per baryon |
| 509 | * (virtual function implemented in the derived classes). |
| 510 | * |
| 511 | * @param ent [input, unit: \f$c^2\f$] log-enthalpy \e H defined by |
| 512 | * \f$H = c^2 \ln\left( {e+p \over m_B c^2 n} \right) \f$, |
| 513 | * where \e e is the (total) energy density, \e p the pressure, |
| 514 | * \e n the baryon density, and \f$m_B\f$ the baryon mass |
| 515 | * @param sb [input, unit: \f$k_B\f$] entropy per baryon \f$s_b\f$ |
| 516 | * |
| 517 | * @return pressure \e p [unit: \f$\rho_{\rm nuc} c^2\f$], where |
| 518 | * \f$\rho_{\rm nuc} := 1.66\ 10^{17} \ {\rm kg/m}^3\f$ |
| 519 | */ |
| 520 | virtual double press_Hs_p(double ent, double sb) const ; |
| 521 | |
| 522 | /** Computes the temperature from the log-enthalpy and entropy per baryon |
| 523 | * (virtual function implemented in the derived classes). |
| 524 | * |
| 525 | * @param ent [input, unit: \f$c^2\f$] log-enthalpy \e H defined by |
| 526 | * \f$H = c^2 \ln\left( {e+p \over m_B c^2 n} (to be modified) \right) \f$, |
| 527 | * where \e e is the (total) energy density, \e p the pressure, |
| 528 | * \e n the baryon density, and \f$m_B\f$ the baryon mass |
| 529 | * @param sb [input, unit: \f$k_B\f$] entropy per baryon \f$s_b\f$ |
| 530 | * |
| 531 | * @return temperature [unit: MeV] |
| 532 | * |
| 533 | */ |
| 534 | virtual double temp_Hs_p(double ent, double sb) const ; |
| 535 | |
| 536 | }; |
| 537 | |
| 538 | //------------------------------------// |
| 539 | // class Hoteos_tabul // |
| 540 | //------------------------------------// |
| 541 | |
| 542 | /** |
| 543 | * Hot (temperature-dependent) tabulated equation of state, read from a file. |
| 544 | * |
| 545 | * |
| 546 | *\ingroup (eos) |
| 547 | * |
| 548 | */ |
| 549 | class Hoteos_tabul : public Hot_eos { |
| 550 | |
| 551 | // Data : |
| 552 | //------- |
| 553 | |
| 554 | protected: |
| 555 | /// Name of the file containing the tabulated data |
| 556 | string tablename ; |
| 557 | |
| 558 | string authors ; ///<Authors - reference for the table |
| 559 | |
| 560 | /// Lower boundary of the enthalpy interval |
| 561 | double hmin ; |
| 562 | |
| 563 | /// Upper boundary of the enthalpy interval |
| 564 | double hmax ; |
| 565 | |
| 566 | /// Lower boundary of the entropy interval |
| 567 | double sbmin ; |
| 568 | |
| 569 | /// Upper boundary of the entropy interval |
| 570 | double sbmax ; |
| 571 | |
| 572 | /// Table of \f$H = \log ( e + P ) / n_B\f$ |
| 573 | Tbl* hhh ; |
| 574 | |
| 575 | /// Table of \f$s_B\f$, entropy per baryon (in units of Boltzmann constant). |
| 576 | Tbl* s_B ; |
| 577 | |
| 578 | /// Table of pressure $P$ |
| 579 | Tbl* ppp ; |
| 580 | |
| 581 | /// Table of \f$\partial P/\partial H\f$ |
| 582 | Tbl* dpdh ; |
| 583 | |
| 584 | /// Table of \f$\partial P/\partial s_B\f$ |
| 585 | Tbl* dpds ; |
| 586 | |
| 587 | /// Table of \f$\partial^2 P/\partial s_B \partial H\f$ |
| 588 | Tbl* d2p ; |
| 589 | |
| 590 | // Constructors - Destructor |
| 591 | // ------------------------- |
| 592 | public: |
| 593 | |
| 594 | /** Standard constructor from a filename. |
| 595 | */ |
| 596 | Hoteos_tabul(const string& filename) ; |
| 597 | |
| 598 | Hoteos_tabul(const Hoteos_tabul& ) ; ///< Copy constructor |
| 599 | |
| 600 | protected: |
| 601 | /** Constructor from a binary file (created by the function |
| 602 | * \c sauve(FILE*) ). |
| 603 | * This constructor is protected because any hot EOS construction |
| 604 | * from a binary file must be done via the function |
| 605 | * \c Hot_eos::eos_from_file(FILE*) . |
| 606 | */ |
| 607 | Hoteos_tabul(FILE* ) ; |
| 608 | |
| 609 | /** Constructor from a formatted file. |
| 610 | * This constructor is protected because any EOS construction |
| 611 | * from a formatted file must be done via the function |
| 612 | * \c Hot_eos::hoteos_from_file(ifstream&) . |
| 613 | */ |
| 614 | Hoteos_tabul(ifstream& ) ; |
| 615 | |
| 616 | /// The construction functions from a file |
| 617 | friend Hot_eos* Hot_eos::hoteos_from_file(FILE* ) ; |
| 618 | friend Hot_eos* Hot_eos::hoteos_from_file(ifstream& ) ; |
| 619 | |
| 620 | public: |
| 621 | virtual ~Hoteos_tabul() ; ///< Destructor |
| 622 | |
| 623 | /// Assignment to another \c Hoteos_tabul |
| 624 | void operator=(const Hoteos_tabul& ) ; |
| 625 | |
| 626 | // Miscellaneous |
| 627 | // ------------- |
| 628 | |
| 629 | protected: |
| 630 | /** Reads the file containing the table and initializes |
| 631 | * in the arrays \c hhh , \c s_B, \c ppp, ... |
| 632 | */ |
| 633 | void read_table() ; |
| 634 | |
| 635 | /// Sets all the arrays to the null pointer. |
| 636 | void set_arrays_0x0() ; |
| 637 | |
| 638 | public : |
| 639 | /// Comparison operator (egality) |
| 640 | virtual bool operator==(const Hot_eos& ) const ; |
| 641 | |
| 642 | /// Comparison operator (difference) |
| 643 | virtual bool operator!=(const Hot_eos& ) const ; |
| 644 | |
| 645 | /** Returns a number to identify the sub-classe of \c Hot_eos the |
| 646 | * object belongs to. |
| 647 | */ |
| 648 | virtual int identify() const ; |
| 649 | |
| 650 | virtual const Eos& new_cold_Eos() const ; |
| 651 | |
| 652 | // Outputs |
| 653 | // ------- |
| 654 | |
| 655 | public: |
| 656 | virtual void sauve(FILE* ) const ; ///< Save in a file |
| 657 | |
| 658 | protected: |
| 659 | virtual ostream& operator>>(ostream &) const ; ///< Operator >> |
| 660 | |
| 661 | |
| 662 | // Computational functions |
| 663 | // ----------------------- |
| 664 | |
| 665 | public: |
| 666 | /** Computes the baryon density from the log-enthalpy and entropy per baryon |
| 667 | * (virtual function implemented in the derived classes). |
| 668 | * |
| 669 | * @param ent [input, unit: \f$c^2\f$] log-enthalpy \e H defined by |
| 670 | * \f$H = c^2 \ln\left( {e+p \over m_B c^2 n} (to be modified) \right) \f$, |
| 671 | * where \e e is the (total) energy density, \e p the pressure, |
| 672 | * \e n the baryon density, and \f$m_B\f$ the baryon mass |
| 673 | * @param sb [input, unit: \f$k_B\f$] entropy per baryon \f$s_b\f$ |
| 674 | * |
| 675 | * @return baryon density [unit: \f$n_{\rm nuc} := 0.1 \ {\rm fm}^{-3}\f$] |
| 676 | * |
| 677 | */ |
| 678 | virtual double nbar_Hs_p(double ent, double sb) const ; |
| 679 | |
| 680 | /** Computes the total energy density from the log-enthalpy and entropy per baryon |
| 681 | * (virtual function implemented in the derived classes). |
| 682 | * |
| 683 | * @param ent [input, unit: \f$c^2\f$] log-enthalpy \e H defined by |
| 684 | * \f$H = c^2 \ln\left( {e+p \over m_B c^2 n} \right) \f$, |
| 685 | * where \e e is the (total) energy density, \e p the pressure, |
| 686 | * \e n the baryon density, and \f$m_B\f$ the baryon mass |
| 687 | * @param sb [input, unit: \f$k_B\f$] entropy per baryon \f$s_b\f$ |
| 688 | * |
| 689 | * @return energy density \e e [unit: \f$\rho_{\rm nuc} c^2\f$], where |
| 690 | * \f$\rho_{\rm nuc} := 1.66\ 10^{17} \ {\rm kg/m}^3\f$ |
| 691 | */ |
| 692 | virtual double ener_Hs_p(double ent, double sb) const ; |
| 693 | |
| 694 | /** Computes the pressure from the log-enthalpy and entropy per baryon |
| 695 | * (virtual function implemented in the derived classes). |
| 696 | * |
| 697 | * @param ent [input, unit: \f$c^2\f$] log-enthalpy \e H defined by |
| 698 | * \f$H = c^2 \ln\left( {e+p \over m_B c^2 n} \right) \f$, |
| 699 | * where \e e is the (total) energy density, \e p the pressure, |
| 700 | * \e n the baryon density, and \f$m_B\f$ the baryon mass |
| 701 | * @param sb [input, unit: \f$k_B\f$] entropy per baryon \f$s_b\f$ |
| 702 | * |
| 703 | * @return pressure \e p [unit: \f$\rho_{\rm nuc} c^2\f$], where |
| 704 | * \f$\rho_{\rm nuc} := 1.66\ 10^{17} \ {\rm kg/m}^3\f$ |
| 705 | */ |
| 706 | virtual double press_Hs_p(double ent, double sb) const ; |
| 707 | |
| 708 | /** Computes the temperature from the log-enthalpy and entropy per baryon |
| 709 | * (virtual function implemented in the derived classes). |
| 710 | * |
| 711 | * @param ent [input, unit: \f$c^2\f$] log-enthalpy \e H defined by |
| 712 | * \f$H = c^2 \ln\left( {e+p \over m_B c^2 n} (to be modified) \right) \f$, |
| 713 | * where \e e is the (total) energy density, \e p the pressure, |
| 714 | * \e n the baryon density, and \f$m_B\f$ the baryon mass |
| 715 | * @param sb [input, unit: \f$k_B\f$] entropy per baryon \f$s_b\f$ |
| 716 | * |
| 717 | * @return temperature [unit: MeV] |
| 718 | * |
| 719 | */ |
| 720 | virtual double temp_Hs_p(double ent, double sb) const ; |
| 721 | |
| 722 | }; |
| 723 | |
| 724 | } |
| 725 | #endif |