|
| 1 | +/*! |
| 2 | + * \file CCoolPropConductivity.hpp |
| 3 | + * \brief Defines laminar thermal conductivity model from CoolProp. |
| 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 | + |
| 30 | +#include "CConductivityModel.hpp" |
| 31 | +#include "CCoolProp.hpp" |
| 32 | + |
| 33 | +#ifdef USE_COOLPROP |
| 34 | +#include "AbstractState.h" |
| 35 | +#include "CoolProp.h" |
| 36 | +#endif |
| 37 | +/*! |
| 38 | + * \class CCoolPropConductivity |
| 39 | + * \brief Defines conductivity model from CoolProp. |
| 40 | + * \author P.Yan |
| 41 | + */ |
| 42 | +class CCoolPropConductivity final : public CConductivityModel { |
| 43 | + private: |
| 44 | +#ifdef USE_COOLPROP |
| 45 | + std::unique_ptr<CoolProp::AbstractState> fluid_entity; /*!< \brief fluid entity */ |
| 46 | +#endif |
| 47 | + /*!< \brief list of fluids whose conductivity model is available in CoolProp */ |
| 48 | + const vector<string> fluidNameList = { |
| 49 | + "Air", "Ammonia", "Argon", "Benzene", "CarbonDioxide", "Cyclopentane", "EthylBenzene", |
| 50 | + "Ethane", "Ethanol", "HeavyWater", "Helium", "Hydrogen", "IsoButane", "Isopentane", |
| 51 | + "Methane", "Methanol", "Nitrogen", "Oxygen", "Propylene", "ParaHydrogen", "R11", |
| 52 | + "R116", "R12", "R123", "R1234yf", "R1234ze(E)", "R124", "R125", |
| 53 | + "R13", "R134a", "R14", "R141b", "R142b", "R143a", "R152A", |
| 54 | + "R218", "R22", "R227EA", "R23", "R236EA", "R236FA", "R245fa", |
| 55 | + "R32", "R404A", "R407C", "R410A", "R507A", "RC318", "SulfurHexafluoride", |
| 56 | + "Toluene", "Water", "m-Xylene", "n-Butane", "n-Decane", "n-Dodecane", "n-Heptane", |
| 57 | + "n-Hexane", "n-Nonane", "n-Octane", "n-Pentane", "n-Propane", "o-Xylene", "p-Xylene"}; |
| 58 | + |
| 59 | + public: |
| 60 | + /*! |
| 61 | + * \brief Constructor of the class. |
| 62 | + */ |
| 63 | + CCoolPropConductivity(const string& fluidname) { |
| 64 | +#ifdef USE_COOLPROP |
| 65 | + fluid_entity = std::unique_ptr<CoolProp::AbstractState>(CoolProp::AbstractState::factory("HEOS", fluidname)); |
| 66 | + if (std::find(fluidNameList.begin(), fluidNameList.end(), fluidname) == fluidNameList.end()) { |
| 67 | + SU2_MPI::Error("Conductivity model not available for this fluid in CoolProp library.", CURRENT_FUNCTION); |
| 68 | + } |
| 69 | +#else |
| 70 | + SU2_MPI::Error( |
| 71 | + "SU2 was not compiled with CoolProp (-Denable-coolprop=true). Note that CoolProp cannot be used with " |
| 72 | + "directdiff or autodiff", |
| 73 | + CURRENT_FUNCTION); |
| 74 | +#endif |
| 75 | + } |
| 76 | + |
| 77 | + /*! |
| 78 | + * \brief Set thermal conductivity. |
| 79 | + */ |
| 80 | + void SetConductivity(su2double t, su2double rho, su2double, su2double, su2double, su2double, su2double) override { |
| 81 | +#ifdef USE_COOLPROP |
| 82 | + fluid_entity->update(CoolProp::DmassT_INPUTS, rho, t); |
| 83 | + kt_ = fluid_entity->conductivity(); |
| 84 | +#endif |
| 85 | + } |
| 86 | +}; |
0 commit comments