| 1 | /* |
| 2 | * Definition of Lorene class Eos_fitting |
| 3 | * Eos_fit_SLy4 |
| 4 | * Eos_fit_FPS |
| 5 | * Eos_fit_AkmalPR |
| 6 | * |
| 7 | */ |
| 8 | |
| 9 | /* |
| 10 | * Copyright (c) 2004 Keisuke Taniguchi |
| 11 | * |
| 12 | * This file is part of LORENE. |
| 13 | * |
| 14 | * LORENE is free software; you can redistribute it and/or modify |
| 15 | * it under the terms of the GNU General Public License version 2 |
| 16 | * as published by the Free Software Foundation. |
| 17 | * |
| 18 | * LORENE is distributed in the hope that it will be useful, |
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 | * GNU General Public License for more details. |
| 22 | * |
| 23 | * You should have received a copy of the GNU General Public License |
| 24 | * along with LORENE; if not, write to the Free Software |
| 25 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 26 | * |
| 27 | */ |
| 28 | |
| 29 | #ifndef __EOS_FITTING_H_ |
| 30 | #define __EOS_FITTING_H_ |
| 31 | |
| 32 | /* |
| 33 | * $Id: eos_fitting.h,v 1.4 2014/10/13 08:52:33 j_novak Exp $ |
| 34 | * $Log: eos_fitting.h,v $ |
| 35 | * Revision 1.4 2014/10/13 08:52:33 j_novak |
| 36 | * Lorene classes and functions now belong to the namespace Lorene. |
| 37 | * |
| 38 | * Revision 1.3 2014/10/06 15:09:39 j_novak |
| 39 | * Modified #include directives to use c++ syntax. |
| 40 | * |
| 41 | * Revision 1.2 2005/05/22 20:50:39 k_taniguchi |
| 42 | * Introduction of a new class Eos_fit_AkmalPR. |
| 43 | * |
| 44 | * Revision 1.1 2004/09/26 18:50:00 k_taniguchi |
| 45 | * Initial revision |
| 46 | * |
| 47 | * |
| 48 | * |
| 49 | * $Header: /cvsroot/Lorene/C++/Include/eos_fitting.h,v 1.4 2014/10/13 08:52:33 j_novak Exp $ |
| 50 | * |
| 51 | */ |
| 52 | |
| 53 | // Standard C++ |
| 54 | #include "headcpp.h" |
| 55 | |
| 56 | // Headers C |
| 57 | #include <cstdio> |
| 58 | #include <cassert> |
| 59 | |
| 60 | // Lorene classes |
| 61 | #include "eos.h" |
| 62 | #include "param.h" |
| 63 | |
| 64 | // External classes which appear in the declaration of class Eos_fitting: |
| 65 | namespace Lorene { |
| 66 | class Tbl ; |
| 67 | class Cmp ; |
| 68 | class Param ; |
| 69 | class Eos ; |
| 70 | |
| 71 | //-----------------------------------------------------------------------// |
| 72 | // class Eos_fitting for the analytical fitting of realistic EOS // |
| 73 | //-----------------------------------------------------------------------// |
| 74 | |
| 75 | /** |
| 76 | * Base class for the analytically fitted equation of state. |
| 77 | * \ingroup(eos) |
| 78 | * |
| 79 | */ |
| 80 | class Eos_fitting : public Eos { |
| 81 | |
| 82 | // Data : |
| 83 | // ----- |
| 84 | protected: |
| 85 | /// Name of the file containing the fitting data |
| 86 | char dataname[160] ; |
| 87 | |
| 88 | /// Array of the coefficients of the fitting data |
| 89 | double* pp ; |
| 90 | |
| 91 | // Constructors - Destructor |
| 92 | // ------------------------- |
| 93 | protected: |
| 94 | |
| 95 | /** Standard constructor |
| 96 | * |
| 97 | * @param name Name of the fitted EOS |
| 98 | * @param data Name of the file containing the fitting data |
| 99 | * @param path Path to the directory containing the EOS file |
| 100 | */ |
| 101 | Eos_fitting(const char* name_i, const char* data, const char* path) ; |
| 102 | |
| 103 | // Eos_fitting(const Eos_fitting& ) ; ///< Copy constructor |
| 104 | |
| 105 | protected: |
| 106 | /** Constructor from a binary file (created by the function |
| 107 | * \c sauve(FILE*) ). |
| 108 | * This constructor is protected because any EOS construction |
| 109 | * from a binary file must be done via the function |
| 110 | * \c Eos::eos_from_file(FILE*) . |
| 111 | */ |
| 112 | Eos_fitting(FILE* ) ; |
| 113 | |
| 114 | /** Constructor from a formatted file. |
| 115 | * This constructor is protected because any EOS construction |
| 116 | * from a formatted file must be done via the function |
| 117 | * \c Eos::eos_from_file(ifstream&) . |
| 118 | * |
| 119 | * @param ist input file stream containing a name as first line |
| 120 | * @param data Name of the file containing the fitting data |
| 121 | */ |
| 122 | Eos_fitting(ifstream& ist, const char* data) ; |
| 123 | |
| 124 | /// The construction functions from a file |
| 125 | friend Eos* Eos::eos_from_file(FILE* ) ; |
| 126 | friend Eos* Eos::eos_from_file(ifstream& ) ; |
| 127 | |
| 128 | public: |
| 129 | virtual ~Eos_fitting() ; ///< Destructor |
| 130 | |
| 131 | // Outputs |
| 132 | // ------- |
| 133 | public: |
| 134 | virtual void sauve(FILE *) const ; ///< Save in a file |
| 135 | |
| 136 | // Miscellaneous |
| 137 | // ------------- |
| 138 | protected: |
| 139 | /** Reading coefficients of the fitting equation for the energy |
| 140 | * density, the pressure, and the enthalpy |
| 141 | */ |
| 142 | void read_coef() ; |
| 143 | |
| 144 | // Computational functions |
| 145 | // ----------------------- |
| 146 | public: |
| 147 | /** Computes the baryon density from the log-enthalpy. |
| 148 | * |
| 149 | * @param ent [input, unit: \f$c^2\f$] log-enthalpy \e H |
| 150 | * |
| 151 | * @param par possible extra parameters of the EOS |
| 152 | * @return baryon density \e n |
| 153 | * [unit: \f$n_{\rm nuc} := 0.1 \ {\rm fm}^{-3}\f$] |
| 154 | * |
| 155 | */ |
| 156 | virtual double nbar_ent_p(double ent, const Param* par=0x0) const ; |
| 157 | |
| 158 | /** Computes the total energy density from the log-enthalpy. |
| 159 | * |
| 160 | * @param ent [input, unit: \f$c^2\f$] log-enthalpy \e H |
| 161 | * |
| 162 | * @param par possible extra parameters of the EOS |
| 163 | * @return energy density \e e [unit: \f$\rho_{\rm nuc} c^2\f$], |
| 164 | * where \f$\rho_{\rm nuc} := 1.66\ 10^{17} \ {\rm kg/m}^3\f$ |
| 165 | */ |
| 166 | virtual double ener_ent_p(double ent, const Param* par=0x0) const ; |
| 167 | |
| 168 | /** Computes the pressure from the log-enthalpy. |
| 169 | * |
| 170 | * @param ent [input, unit: \f$c^2\f$] log-enthalpy \e H |
| 171 | * |
| 172 | * @param par possible extra parameters of the EOS |
| 173 | * @return pressure \e p [unit: \f$\rho_{\rm nuc} c^2\f$], where |
| 174 | * \f$\rho_{\rm nuc} := 1.66\ 10^{17} \ {\rm kg/m}^3\f$ |
| 175 | */ |
| 176 | virtual double press_ent_p(double ent, const Param* par=0x0) const ; |
| 177 | |
| 178 | /** Computes the logarithmic derivative \f$d\ln n/d\ln H\f$ |
| 179 | * from the log-enthalpy. |
| 180 | * |
| 181 | * @param ent [input, unit: \f$c^2\f$] log-enthalpy \e H |
| 182 | * |
| 183 | * @param par possible extra parameters of the EOS |
| 184 | * @return dln(n)/dln(H) |
| 185 | */ |
| 186 | virtual double der_nbar_ent_p(double ent, const Param* par=0x0) const ; |
| 187 | |
| 188 | /** Computes the logarithmic derivative \f$d\ln e/d\ln H\f$ |
| 189 | * from the log-enthalpy. |
| 190 | * |
| 191 | * @param ent [input, unit: \f$c^2\f$] log-enthalpy \e H |
| 192 | * |
| 193 | * @param par possible extra parameters of the EOS |
| 194 | * @return dln(e)/dln(H) |
| 195 | */ |
| 196 | virtual double der_ener_ent_p(double ent, const Param* par=0x0) const ; |
| 197 | |
| 198 | /** Computes the logarithmic derivative \f$d\ln p/d\ln H\f$ |
| 199 | * from the log-enthalpy. |
| 200 | * |
| 201 | * @param ent [input, unit: \f$c^2\f$] log-enthalpy \e H |
| 202 | * |
| 203 | * @param par possible extra parameters of the EOS |
| 204 | * @return dln(p)/dln(H) |
| 205 | */ |
| 206 | virtual double der_press_ent_p(double ent, const Param* par=0x0) const ; |
| 207 | |
| 208 | }; |
| 209 | |
| 210 | |
| 211 | //--------------------------------------// |
| 212 | // class Eos_fit_SLy4 // |
| 213 | //--------------------------------------// |
| 214 | |
| 215 | /** |
| 216 | * Fitted equation of state of SLy4. \ingroup(eos) |
| 217 | * |
| 218 | */ |
| 219 | class Eos_fit_SLy4 : public Eos_fitting { |
| 220 | |
| 221 | // Constructors - Destructor |
| 222 | // ------------------------- |
| 223 | public: |
| 224 | |
| 225 | /** Standard constructor |
| 226 | * |
| 227 | * @param path Path to the directory containing the EOS file |
| 228 | */ |
| 229 | Eos_fit_SLy4(const char* path) ; |
| 230 | |
| 231 | protected: |
| 232 | /** Constructor from a binary file (created by the function |
| 233 | * \c sauve(FILE*) ). |
| 234 | * This constructor is protected because any EOS construction |
| 235 | * from a binary file must be done via the function |
| 236 | * \c Eos::eos_from_file(FILE*) . |
| 237 | */ |
| 238 | Eos_fit_SLy4(FILE* ) ; |
| 239 | |
| 240 | /** Constructor from a formatted file. |
| 241 | * This constructor is protected because any EOS construction |
| 242 | * from a formatted file must be done via the function |
| 243 | * \c Eos::eos_from_file(ifstream&) . |
| 244 | * |
| 245 | * @param ist input file stream containing a name as first line |
| 246 | * @param data Name of the file containing the fitting data |
| 247 | */ |
| 248 | Eos_fit_SLy4(ifstream& ) ; |
| 249 | |
| 250 | /// The construction functions from a file |
| 251 | friend Eos* Eos::eos_from_file(FILE* ) ; |
| 252 | friend Eos* Eos::eos_from_file(ifstream& ) ; |
| 253 | |
| 254 | public: |
| 255 | virtual ~Eos_fit_SLy4() ; ///< Destructor |
| 256 | |
| 257 | // Outputs |
| 258 | // ------- |
| 259 | protected: |
| 260 | virtual ostream& operator>>(ostream &) const ; ///< Operator >> |
| 261 | |
| 262 | // Miscellaneous |
| 263 | // ------------- |
| 264 | public : |
| 265 | /// Comparison operator (egality) |
| 266 | virtual bool operator==(const Eos& ) const ; |
| 267 | |
| 268 | /// Comparison operator (difference) |
| 269 | virtual bool operator!=(const Eos& ) const ; |
| 270 | |
| 271 | /** Returns a number to identify the sub-classe of \c Eos the |
| 272 | * object belongs to. |
| 273 | */ |
| 274 | virtual int identify() const ; |
| 275 | |
| 276 | }; |
| 277 | |
| 278 | |
| 279 | //-------------------------------------// |
| 280 | // class Eos_fit_FPS // |
| 281 | //-------------------------------------// |
| 282 | |
| 283 | /** |
| 284 | * Fitted equation of state of FPS. \ingroup(eos) |
| 285 | * |
| 286 | */ |
| 287 | class Eos_fit_FPS : public Eos_fitting { |
| 288 | |
| 289 | // Constructors - Destructor |
| 290 | // ------------------------- |
| 291 | public: |
| 292 | |
| 293 | /** Standard constructor |
| 294 | * |
| 295 | * @param path Path to the directory containing the EOS file |
| 296 | */ |
| 297 | Eos_fit_FPS(const char* path) ; |
| 298 | |
| 299 | protected: |
| 300 | /** Constructor from a binary file (created by the function |
| 301 | * \c sauve(FILE*) ). |
| 302 | * This constructor is protected because any EOS construction |
| 303 | * from a binary file must be done via the function |
| 304 | * \c Eos::eos_from_file(FILE*) . |
| 305 | */ |
| 306 | Eos_fit_FPS(FILE* ) ; |
| 307 | |
| 308 | /** Constructor from a formatted file. |
| 309 | * This constructor is protected because any EOS construction |
| 310 | * from a formatted file must be done via the function |
| 311 | * \c Eos::eos_from_file(ifstream&) . |
| 312 | * |
| 313 | * @param ist input file stream containing a name as first line |
| 314 | * @param data Name of the file containing the fitting data |
| 315 | */ |
| 316 | Eos_fit_FPS(ifstream& ) ; |
| 317 | |
| 318 | /// The construction functions from a file |
| 319 | friend Eos* Eos::eos_from_file(FILE* ) ; |
| 320 | friend Eos* Eos::eos_from_file(ifstream& ) ; |
| 321 | |
| 322 | public: |
| 323 | virtual ~Eos_fit_FPS() ; ///< Destructor |
| 324 | |
| 325 | // Outputs |
| 326 | // ------- |
| 327 | protected: |
| 328 | virtual ostream& operator>>(ostream &) const ; ///< Operator >> |
| 329 | |
| 330 | // Miscellaneous |
| 331 | // ------------- |
| 332 | public : |
| 333 | /// Comparison operator (egality) |
| 334 | virtual bool operator==(const Eos& ) const ; |
| 335 | |
| 336 | /// Comparison operator (difference) |
| 337 | virtual bool operator!=(const Eos& ) const ; |
| 338 | |
| 339 | /** Returns a number to identify the sub-classe of \c Eos the |
| 340 | * object belongs to. |
| 341 | */ |
| 342 | virtual int identify() const ; |
| 343 | |
| 344 | }; |
| 345 | |
| 346 | |
| 347 | //-----------------------------------------// |
| 348 | // class Eos_fit_AkmalPR // |
| 349 | //-----------------------------------------// |
| 350 | |
| 351 | /** |
| 352 | * Fitted equation of state of AkmalPR. \ingroup(eos) |
| 353 | * |
| 354 | */ |
| 355 | class Eos_fit_AkmalPR : public Eos_fitting { |
| 356 | |
| 357 | // Constructors - Destructor |
| 358 | // ------------------------- |
| 359 | public: |
| 360 | |
| 361 | /** Standard constructor |
| 362 | * |
| 363 | * @param path Path to the directory containing the EOS file |
| 364 | */ |
| 365 | Eos_fit_AkmalPR(const char* path) ; |
| 366 | |
| 367 | protected: |
| 368 | /** Constructor from a binary file (created by the function |
| 369 | * \c sauve(FILE*) ). |
| 370 | * This constructor is protected because any EOS construction |
| 371 | * from a binary file must be done via the function |
| 372 | * \c Eos::eos_from_file(FILE*) . |
| 373 | */ |
| 374 | Eos_fit_AkmalPR(FILE* ) ; |
| 375 | |
| 376 | /** Constructor from a formatted file. |
| 377 | * This constructor is protected because any EOS construction |
| 378 | * from a formatted file must be done via the function |
| 379 | * \c Eos::eos_from_file(ifstream&) . |
| 380 | * |
| 381 | * @param ist input file stream containing a name as first line |
| 382 | * @param data Name of the file containing the fitting data |
| 383 | */ |
| 384 | Eos_fit_AkmalPR(ifstream& ) ; |
| 385 | |
| 386 | /// The construction functions from a file |
| 387 | friend Eos* Eos::eos_from_file(FILE* ) ; |
| 388 | friend Eos* Eos::eos_from_file(ifstream& ) ; |
| 389 | |
| 390 | public: |
| 391 | virtual ~Eos_fit_AkmalPR() ; ///< Destructor |
| 392 | |
| 393 | // Outputs |
| 394 | // ------- |
| 395 | protected: |
| 396 | virtual ostream& operator>>(ostream &) const ; ///< Operator >> |
| 397 | |
| 398 | // Miscellaneous |
| 399 | // ------------- |
| 400 | public : |
| 401 | /// Comparison operator (egality) |
| 402 | virtual bool operator==(const Eos& ) const ; |
| 403 | |
| 404 | /// Comparison operator (difference) |
| 405 | virtual bool operator!=(const Eos& ) const ; |
| 406 | |
| 407 | /** Returns a number to identify the sub-classe of \c Eos the |
| 408 | * object belongs to. |
| 409 | */ |
| 410 | virtual int identify() const ; |
| 411 | |
| 412 | }; |
| 413 | |
| 414 | } |
| 415 | #endif |