|
| 1 | +/*! |
| 2 | + * \file CCoolProp.hpp |
| 3 | + * \brief Defines the state-of-the-art fluid model from CoolProp library. |
| 4 | + * \author P. Yan, G. Gori, A. Guardone |
| 5 | + * \version 7.4.0 "Blackbird" |
| 6 | + * |
| 7 | + * SU2 Project Website: https://su2code.github.io |
| 8 | + * |
| 9 | + * The SU2 Project is maintained by the SU2 Foundation |
| 10 | + * (http://su2foundation.org) |
| 11 | + * |
| 12 | + * Copyright 2012-2022, SU2 Contributors (cf. AUTHORS.md) |
| 13 | + * |
| 14 | + * SU2 is free software; you can redistribute it and/or |
| 15 | + * modify it under the terms of the GNU Lesser General Public |
| 16 | + * License as published by the Free Software Foundation; either |
| 17 | + * version 2.1 of the License, or (at your option) any later version. |
| 18 | + * |
| 19 | + * SU2 is distributed in the hope that it will be useful, |
| 20 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 22 | + * Lesser General Public License for more details. |
| 23 | + * |
| 24 | + * You should have received a copy of the GNU Lesser General Public |
| 25 | + * License along with SU2. If not, see <http://www.gnu.org/licenses/>. |
| 26 | + */ |
| 27 | + |
| 28 | +#pragma once |
| 29 | +#include "CFluidModel.hpp" |
| 30 | +#if defined(HAVE_COOLPROP) && !defined(CODI_FORWARD_TYPE) && !defined(CODI_REVERSE_TYPE) |
| 31 | +#define USE_COOLPROP |
| 32 | +namespace CoolProp { |
| 33 | + class AbstractState; |
| 34 | +} |
| 35 | +#endif |
| 36 | +#include <memory> |
| 37 | + |
| 38 | + |
| 39 | +/*! |
| 40 | + * \class CCoolProp |
| 41 | + * \brief Child class for defining fluid model from CoolProp library. |
| 42 | + * \author: P.Yan |
| 43 | + */ |
| 44 | +class CCoolProp final : public CFluidModel { |
| 45 | + private: |
| 46 | + su2double Gamma{1.4}; /*!< \brief Ratio of Specific Heats. */ |
| 47 | + su2double Gas_Constant{297}; /*!< \brief specific Gas Constant. */ |
| 48 | + su2double Pressure_Critical{0.0}; /*!< \brief critical pressure */ |
| 49 | + su2double Temperature_Critical{0.0}; /*!< \brief critical temperature */ |
| 50 | + su2double acentric_factor{0.0}; /*!< \brief acentric factor */ |
| 51 | +#ifdef USE_COOLPROP |
| 52 | + std::unique_ptr<CoolProp::AbstractState> fluid_entity; /*!< \brief fluid entity */ |
| 53 | +#endif |
| 54 | + |
| 55 | + public: |
| 56 | + /*! |
| 57 | + * \brief Constructor of the class. |
| 58 | + */ |
| 59 | + CCoolProp(string fluidname); |
| 60 | + |
| 61 | +#ifdef USE_COOLPROP |
| 62 | + /*! |
| 63 | + * \brief Destructor of the class. |
| 64 | + * \note Needs to be defined in the .cpp to allow using only a forward declaration of CoolProp::AbstractState. |
| 65 | + */ |
| 66 | + ~CCoolProp(); |
| 67 | + |
| 68 | + /*! |
| 69 | + * \brief Set the Dimensionless State using Density and Internal Energy |
| 70 | + * \param[in] rho - first thermodynamic variable. |
| 71 | + * \param[in] e - second thermodynamic variable. |
| 72 | + */ |
| 73 | + void SetTDState_rhoe(su2double rho, su2double e) override; |
| 74 | + |
| 75 | + /*! |
| 76 | + * \brief Set the Dimensionless State using Pressure and Temperature |
| 77 | + * \param[in] P - first thermodynamic variable. |
| 78 | + * \param[in] T - second thermodynamic variable. |
| 79 | + */ |
| 80 | + void SetTDState_PT(su2double P, su2double T) override; |
| 81 | + |
| 82 | + /*! |
| 83 | + * \brief Set the Dimensionless State using Pressure and Density |
| 84 | + * \param[in] P - first thermodynamic variable. |
| 85 | + * \param[in] rho - second thermodynamic variable. |
| 86 | + */ |
| 87 | + void SetTDState_Prho(su2double P, su2double rho) override; |
| 88 | + |
| 89 | + /*! |
| 90 | + * \brief Set the Dimensionless Internal Energy using Pressure and Density |
| 91 | + * \param[in] P - first thermodynamic variable. |
| 92 | + * \param[in] rho - second thermodynamic variable. |
| 93 | + */ |
| 94 | + void SetEnergy_Prho(su2double P, su2double rho) override; |
| 95 | + |
| 96 | + /*! |
| 97 | + * \brief Set the Dimensionless State using Enthalpy and Entropy |
| 98 | + * \param[in] th1 - first thermodynamic variable (h). |
| 99 | + * \param[in] th2 - second thermodynamic variable (s). |
| 100 | + */ |
| 101 | + void SetTDState_hs(su2double h, su2double s) override; |
| 102 | + |
| 103 | + /*! |
| 104 | + * \brief Set the Dimensionless State using Density and Temperature |
| 105 | + * \param[in] th1 - first thermodynamic variable (rho). |
| 106 | + * \param[in] th2 - second thermodynamic variable (T). |
| 107 | + */ |
| 108 | + void SetTDState_rhoT(su2double rho, su2double T) override; |
| 109 | + |
| 110 | + /*! |
| 111 | + * \brief Set the Dimensionless State using Pressure and Entropy |
| 112 | + * \param[in] th1 - first thermodynamic variable (P). |
| 113 | + * \param[in] th2 - second thermodynamic variable (s). |
| 114 | + */ |
| 115 | + void SetTDState_Ps(su2double P, su2double s) override; |
| 116 | + |
| 117 | + /*! |
| 118 | + * \brief compute some derivatives of enthalpy and entropy needed for subsonic inflow BC |
| 119 | + * \param[in] th1 - first thermodynamic variable (P). |
| 120 | + * \param[in] th2 - second thermodynamic variable (rho). |
| 121 | + */ |
| 122 | + void ComputeDerivativeNRBC_Prho(su2double P, su2double rho) override; |
| 123 | +#endif |
| 124 | + |
| 125 | + /*! |
| 126 | + * \brief Get the value of the critical pressure. |
| 127 | + * \return Critical pressure. |
| 128 | + */ |
| 129 | + su2double GetPressure_Critical(void) const { return Pressure_Critical; } |
| 130 | + |
| 131 | + /*! |
| 132 | + * \brief Get the value of the critical temperature. |
| 133 | + * \return Critical temperature. |
| 134 | + */ |
| 135 | + su2double GetTemperature_Critical(void) const { return Temperature_Critical; } |
| 136 | + |
| 137 | + /*! |
| 138 | + * \brief Get the value of specific gas constant. |
| 139 | + * \return Value of the constant: Gamma |
| 140 | + */ |
| 141 | + su2double GetGas_Constant(void) const { return Gas_Constant; } |
| 142 | + |
| 143 | + /*! |
| 144 | + * \brief Get the value of specific gas constant. |
| 145 | + * \return Value of the constant: Gamma |
| 146 | + */ |
| 147 | + su2double GetGamma(void) const { return Gamma; } |
| 148 | +}; |
0 commit comments