Skip to content

Commit e950c3e

Browse files
authored
Merge pull request #1819 from PENGYAN777/feature_coolprop
Viscosity and conductivity from CoolProp
2 parents bdc2bcd + ead6ffe commit e950c3e

15 files changed

+461
-11
lines changed

Common/include/option_structure.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -672,11 +672,13 @@ enum class VISCOSITYMODEL {
672672
CONSTANT, /*!< \brief Constant viscosity. */
673673
SUTHERLAND, /*!< \brief Sutherlands Law viscosity. */
674674
POLYNOMIAL, /*!< \brief Polynomial viscosity. */
675+
COOLPROP, /*!< \brief CoolProp viscosity. */
675676
};
676677
static const MapType<std::string, VISCOSITYMODEL> ViscosityModel_Map = {
677678
MakePair("CONSTANT_VISCOSITY", VISCOSITYMODEL::CONSTANT)
678679
MakePair("SUTHERLAND", VISCOSITYMODEL::SUTHERLAND)
679680
MakePair("POLYNOMIAL_VISCOSITY", VISCOSITYMODEL::POLYNOMIAL)
681+
MakePair("COOLPROP", VISCOSITYMODEL::COOLPROP)
680682
};
681683

682684
/*!
@@ -698,11 +700,13 @@ enum class CONDUCTIVITYMODEL {
698700
CONSTANT, /*!< \brief Constant thermal conductivity. */
699701
CONSTANT_PRANDTL, /*!< \brief Constant Prandtl number. */
700702
POLYNOMIAL, /*!< \brief Polynomial thermal conductivity. */
703+
COOLPROP, /*!< \brief COOLPROP thermal conductivity. */
701704
};
702705
static const MapType<std::string, CONDUCTIVITYMODEL> ConductivityModel_Map = {
703706
MakePair("CONSTANT_CONDUCTIVITY", CONDUCTIVITYMODEL::CONSTANT)
704707
MakePair("CONSTANT_PRANDTL", CONDUCTIVITYMODEL::CONSTANT_PRANDTL)
705708
MakePair("POLYNOMIAL_CONDUCTIVITY", CONDUCTIVITYMODEL::POLYNOMIAL)
709+
MakePair("COOLPROP", CONDUCTIVITYMODEL::COOLPROP)
706710
};
707711

708712
/*!

SU2_CFD/include/fluid/CCoolProp.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,5 @@ class CCoolProp final : public CFluidModel {
145145
* \return Value of the constant: Gamma
146146
*/
147147
su2double GetGamma(void) const { return Gamma; }
148+
148149
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
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+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
/*!
2+
* \file CCoolPropViscosity.hpp
3+
* \brief Defines CoolPropviscosity model.
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 "CCoolProp.hpp"
31+
#include "CViscosityModel.hpp"
32+
33+
#ifdef USE_COOLPROP
34+
#include "AbstractState.h"
35+
#include "CoolProp.h"
36+
#endif
37+
/*!
38+
* \class CCoolPropViscosity
39+
* \brief Defines CoolProp viscosity model.
40+
* \author P.Yan
41+
*/
42+
class CCoolPropViscosity final : public CViscosityModel {
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 viscosity model is available in CoolProp */
48+
const vector<string> fluidNameList = {"Air",
49+
"Ammonia",
50+
"Argon",
51+
"Benzene",
52+
"CarbonDioxide",
53+
"CycloHexane",
54+
"Cyclopentane",
55+
"DimethylEther",
56+
"Ethane",
57+
"Ethanol",
58+
"HeavyWater",
59+
"Helium",
60+
"Hydrogen",
61+
"HydrogenSulfide",
62+
"IsoButane",
63+
"Isopentane",
64+
"Methane",
65+
"Methanol",
66+
"Nitrogen",
67+
"Oxygen",
68+
"Propylene",
69+
"R11",
70+
"R116",
71+
"R12",
72+
"R123",
73+
"R1233zd(E)",
74+
"R1234yf",
75+
"R1234ze(E)",
76+
"R124",
77+
"R125",
78+
"R13",
79+
"R134a",
80+
"R14",
81+
"R141b",
82+
"R142b",
83+
"R143a",
84+
"R152A",
85+
"R218",
86+
"R22",
87+
"R227EA",
88+
"R23",
89+
"R236EA",
90+
"R236FA",
91+
"R245fa",
92+
"R32",
93+
"R404A",
94+
"R407C",
95+
"R410A",
96+
"R507A",
97+
"RC318",
98+
"SulfurHexafluoride",
99+
"Toluene",
100+
"Water",
101+
"m-Xylene",
102+
"n-Butane",
103+
"n-Decane",
104+
"n-Dodecane",
105+
"n-Heptane",
106+
"n-Hexane",
107+
"n-Nonane",
108+
"n-Octane",
109+
"n-Pentane",
110+
"n-Propane",
111+
"o-Xylene",
112+
"p-Xylene"};
113+
114+
public:
115+
/*!
116+
* \brief Constructor of the class.
117+
*/
118+
CCoolPropViscosity(const string& fluidname) {
119+
#ifdef USE_COOLPROP
120+
fluid_entity = std::unique_ptr<CoolProp::AbstractState>(CoolProp::AbstractState::factory("HEOS", fluidname));
121+
if (std::find(fluidNameList.begin(), fluidNameList.end(), fluidname) == fluidNameList.end()) {
122+
SU2_MPI::Error("Viscosity model not available for this fluid in CoolProp library.", CURRENT_FUNCTION);
123+
}
124+
#else
125+
SU2_MPI::Error(
126+
"SU2 was not compiled with CoolProp (-Denable-coolprop=true). Note that CoolProp cannot be used with "
127+
"directdiff or autodiff",
128+
CURRENT_FUNCTION);
129+
#endif
130+
}
131+
132+
/*!
133+
* \brief Set Viscosity.
134+
*/
135+
void SetViscosity(su2double t, su2double rho) override {
136+
#ifdef USE_COOLPROP
137+
fluid_entity->update(CoolProp::DmassT_INPUTS, rho, t);
138+
mu_ = fluid_entity->viscosity();
139+
#endif
140+
}
141+
};

SU2_CFD/src/fluid/CCoolProp.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ CCoolProp::CCoolProp(string fluidname) : CFluidModel() {
4242
CCoolProp::~CCoolProp() {}
4343

4444
void CCoolProp::SetTDState_rhoe(su2double rho, su2double e) {
45-
//cout<<"p "<<Pressure<<"Pc "<<Pressure_Critical<<"T "<<Temperature<<"Tc"<<Temperature_Critical<<endl;
4645
Density = rho;
4746
StaticEnergy = e;
4847
fluid_entity->update(CoolProp::DmassUmass_INPUTS, Density, StaticEnergy);

SU2_CFD/src/fluid/CFluidModel.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,16 @@
4141
#include "../../include/fluid/CPolynomialConductivityRANS.hpp"
4242
#include "../../include/fluid/CPolynomialViscosity.hpp"
4343
#include "../../include/fluid/CSutherland.hpp"
44+
#include "../../include/fluid/CCoolPropViscosity.hpp"
4445
#include "../../include/fluid/CConstantLewisDiffusivity.hpp"
46+
#include "../../include/fluid/CCoolPropConductivity.hpp"
4547

4648
unique_ptr<CViscosityModel> CFluidModel::MakeLaminarViscosityModel(const CConfig* config, unsigned short iSpecies) {
4749
switch (config->GetKind_ViscosityModel()) {
4850
case VISCOSITYMODEL::CONSTANT:
4951
return unique_ptr<CConstantViscosity>(new CConstantViscosity(config->GetMu_ConstantND(iSpecies)));
52+
case VISCOSITYMODEL::COOLPROP:
53+
return unique_ptr<CCoolPropViscosity>(new CCoolPropViscosity(config->GetFluid_Name()));
5054
case VISCOSITYMODEL::SUTHERLAND:
5155
return unique_ptr<CSutherland>(new CSutherland(config->GetMu_RefND(iSpecies),
5256
config->GetMu_Temperature_RefND(iSpecies),
@@ -77,6 +81,16 @@ unique_ptr<CConductivityModel> CFluidModel::MakeThermalConductivityModel(const C
7781
new CConstantConductivity(config->GetThermal_Conductivity_ConstantND(iSpecies)));
7882
}
7983
break;
84+
case CONDUCTIVITYMODEL::COOLPROP:
85+
if (config->GetKind_ConductivityModel_Turb() == CONDUCTIVITYMODEL_TURB::CONSTANT_PRANDTL) {
86+
return unique_ptr<CConstantConductivityRANS>(
87+
new CConstantConductivityRANS(config->GetThermal_Conductivity_ConstantND(iSpecies),
88+
config->GetPrandtl_Turb(iSpecies)));
89+
} else {
90+
return unique_ptr<CCoolPropConductivity>(
91+
new CCoolPropConductivity(config->GetFluid_Name()));
92+
}
93+
break;
8094
case CONDUCTIVITYMODEL::CONSTANT_PRANDTL:
8195
if (config->GetKind_ConductivityModel_Turb() == CONDUCTIVITYMODEL_TURB::CONSTANT_PRANDTL) {
8296
return unique_ptr<CConstantPrandtlRANS>(

SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,13 @@ void CConjugateHeatInterface::GetDonor_Variable(CSolver *donor_solution, CGeomet
104104
switch (donor_config->GetKind_ConductivityModel()) {
105105

106106
case CONDUCTIVITYMODEL::CONSTANT:
107+
case CONDUCTIVITYMODEL::COOLPROP:
107108
thermal_conductivity = thermal_conductivityND*donor_config->GetThermal_Conductivity_Ref();
108109
break;
109-
110110
case CONDUCTIVITYMODEL::CONSTANT_PRANDTL:
111111
thermal_conductivity = thermal_conductivityND*donor_config->GetGas_Constant_Ref()
112112
*donor_config->GetViscosity_Ref();
113113
break;
114-
115114
case CONDUCTIVITYMODEL::POLYNOMIAL:
116115
SU2_MPI::Error("Polynomial Conductivity model not implemented for CHT interface.", CURRENT_FUNCTION);
117116
break;

SU2_CFD/src/output/CFlowOutput.cpp

+14-1
Original file line numberDiff line numberDiff line change
@@ -2402,6 +2402,10 @@ void CFlowOutput::WriteForcesBreakdown(const CConfig* config, const CSolver* flo
24022402
file << "Laminar Viscosity (non-dim): " << config->GetMu_ConstantND() << "\n";
24032403
break;
24042404

2405+
case VISCOSITYMODEL::COOLPROP:
2406+
file << "Viscosity Model: CoolProp \n";
2407+
break;
2408+
24052409
case VISCOSITYMODEL::SUTHERLAND:
24062410
file << "Viscosity Model: SUTHERLAND \n";
24072411
file << "Ref. Laminar Viscosity: " << config->GetMu_Ref();
@@ -2432,7 +2436,9 @@ void CFlowOutput::WriteForcesBreakdown(const CConfig* config, const CSolver* flo
24322436
file << "Molecular Conductivity: " << config->GetThermal_Conductivity_Constant() << " W/m^2.K.\n";
24332437
file << "Molecular Conductivity (non-dim): " << config->GetThermal_Conductivity_ConstantND() << "\n";
24342438
break;
2435-
2439+
case CONDUCTIVITYMODEL::COOLPROP:
2440+
file << "Conductivity Model: COOLPROP \n";
2441+
break;
24362442
default:
24372443
break;
24382444
}
@@ -2724,6 +2730,10 @@ void CFlowOutput::WriteForcesBreakdown(const CConfig* config, const CSolver* flo
27242730
file << "Laminar Viscosity (non-dim): " << config->GetMu_ConstantND() << "\n";
27252731
break;
27262732

2733+
case VISCOSITYMODEL::COOLPROP:
2734+
file << "Viscosity Model: CoolProp \n";
2735+
break;
2736+
27272737
case VISCOSITYMODEL::SUTHERLAND:
27282738
file << "Viscosity Model: SUTHERLAND \n";
27292739
file << "Ref. Laminar Viscosity: " << config->GetMu_Ref();
@@ -2769,6 +2779,9 @@ void CFlowOutput::WriteForcesBreakdown(const CConfig* config, const CSolver* flo
27692779
file << "Molecular Conductivity: " << config->GetThermal_Conductivity_Constant() << " W/m^2.K.\n";
27702780
file << "Molecular Conductivity (non-dim): " << config->GetThermal_Conductivity_ConstantND() << "\n";
27712781
break;
2782+
case CONDUCTIVITYMODEL::COOLPROP:
2783+
file << "Conductivity Model: COOLPROP \n";
2784+
break;
27722785

27732786
case CONDUCTIVITYMODEL::POLYNOMIAL:
27742787
file << "Viscosity Model: POLYNOMIAL \n";

0 commit comments

Comments
 (0)