Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Viscosity and conductivity from CoolProp #1819

Merged
merged 23 commits into from
Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ad44f6f
suggestions from code review applied
PENGYAN777 Nov 11, 2022
11b8b24
Merge branch 'feature_coolprop' of https://github.com/PENGYAN777/SU2 …
PENGYAN777 Nov 11, 2022
9f6b7fb
Merge branch 'su2code:feature_coolprop' into feature_coolprop
PENGYAN777 Nov 11, 2022
9b32999
viscosity and conductivity from CoolProp
PENGYAN777 Nov 12, 2022
b140d70
delete unnecesssary files
PENGYAN777 Nov 12, 2022
f634f3f
git push
PENGYAN777 Nov 12, 2022
3f75e95
remove extra lines
PENGYAN777 Nov 12, 2022
e9d1e32
add: #ifdef USE_COOLPROP
PENGYAN777 Nov 12, 2022
ea9919a
add break for switch case
PENGYAN777 Nov 12, 2022
f9a37bb
add COOLPROP visocisty and conductivity for IncEuler solver
PENGYAN777 Nov 12, 2022
8bdd16d
add CoolProp conductivity for CConjugateHeatInterface.cpp
PENGYAN777 Nov 12, 2022
cba2e00
change according to code review
PENGYAN777 Nov 16, 2022
145a4b9
Merge branch 'develop' into feature_coolprop
bigfooted Nov 17, 2022
5b30117
move if use_coolprop
PENGYAN777 Nov 23, 2022
da9bec3
Apply suggestions from code review
PENGYAN777 Nov 24, 2022
75b6ffd
apply change from code review
PENGYAN777 Nov 24, 2022
df19e32
change from code review
PENGYAN777 Nov 24, 2022
c93a84a
change from code review
PENGYAN777 Nov 24, 2022
81fce82
change from code review
PENGYAN777 Nov 24, 2022
0cfb47f
new config file for CoolProp viscosity and conductivity model
PENGYAN777 Nov 24, 2022
d3fd9e1
change from code review
PENGYAN777 Nov 26, 2022
c75270f
Merge branch 'develop' into feature_coolprop
pcarruscag Nov 26, 2022
ead6ffe
Merge branch 'develop' into feature_coolprop
PENGYAN777 Nov 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Common/include/option_structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,11 +672,13 @@ enum class VISCOSITYMODEL {
CONSTANT, /*!< \brief Constant viscosity. */
SUTHERLAND, /*!< \brief Sutherlands Law viscosity. */
POLYNOMIAL, /*!< \brief Polynomial viscosity. */
COOLPROP, /*!< \brief CoolProp viscosity. */
};
static const MapType<std::string, VISCOSITYMODEL> ViscosityModel_Map = {
MakePair("CONSTANT_VISCOSITY", VISCOSITYMODEL::CONSTANT)
MakePair("SUTHERLAND", VISCOSITYMODEL::SUTHERLAND)
MakePair("POLYNOMIAL_VISCOSITY", VISCOSITYMODEL::POLYNOMIAL)
MakePair("COOLPROP", VISCOSITYMODEL::COOLPROP)
};

/*!
Expand All @@ -698,11 +700,13 @@ enum class CONDUCTIVITYMODEL {
CONSTANT, /*!< \brief Constant thermal conductivity. */
CONSTANT_PRANDTL, /*!< \brief Constant Prandtl number. */
POLYNOMIAL, /*!< \brief Polynomial thermal conductivity. */
COOLPROP, /*!< \brief COOLPROP thermal conductivity. */
};
static const MapType<std::string, CONDUCTIVITYMODEL> ConductivityModel_Map = {
MakePair("CONSTANT_CONDUCTIVITY", CONDUCTIVITYMODEL::CONSTANT)
MakePair("CONSTANT_PRANDTL", CONDUCTIVITYMODEL::CONSTANT_PRANDTL)
MakePair("POLYNOMIAL_CONDUCTIVITY", CONDUCTIVITYMODEL::POLYNOMIAL)
MakePair("COOLPROP", CONDUCTIVITYMODEL::COOLPROP)
};

/*!
Expand Down
1 change: 1 addition & 0 deletions SU2_CFD/include/fluid/CCoolProp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,5 @@ class CCoolProp final : public CFluidModel {
* \return Value of the constant: Gamma
*/
su2double GetGamma(void) const { return Gamma; }

};
86 changes: 86 additions & 0 deletions SU2_CFD/include/fluid/CCoolPropConductivity.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*!
* \file CCoolPropConductivity.hpp
* \brief Defines laminar thermal conductivity model from CoolProp.
* \author P.YAn, G. Gori, A. Guardone
* \version 7.4.0 "Blackbird"
*
* SU2 Project Website: https://su2code.github.io
*
* The SU2 Project is maintained by the SU2 Foundation
* (http://su2foundation.org)
*
* Copyright 2012-2022, SU2 Contributors (cf. AUTHORS.md)
*
* SU2 is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* SU2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with SU2. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include "CConductivityModel.hpp"
#include "CCoolProp.hpp"

#ifdef USE_COOLPROP
#include "AbstractState.h"
#include "CoolProp.h"
#endif
/*!
* \class CCoolPropConductivity
* \brief Defines conductivity model from CoolProp.
* \author P.Yan
*/
class CCoolPropConductivity final : public CConductivityModel {
private:
#ifdef USE_COOLPROP
std::unique_ptr<CoolProp::AbstractState> fluid_entity; /*!< \brief fluid entity */
#endif
/*!< \brief list of fluids whose conductivity model is available in CoolProp */
const vector<string> fluidNameList = {
"Air", "Ammonia", "Argon", "Benzene", "CarbonDioxide", "Cyclopentane", "EthylBenzene",
"Ethane", "Ethanol", "HeavyWater", "Helium", "Hydrogen", "IsoButane", "Isopentane",
"Methane", "Methanol", "Nitrogen", "Oxygen", "Propylene", "ParaHydrogen", "R11",
"R116", "R12", "R123", "R1234yf", "R1234ze(E)", "R124", "R125",
"R13", "R134a", "R14", "R141b", "R142b", "R143a", "R152A",
"R218", "R22", "R227EA", "R23", "R236EA", "R236FA", "R245fa",
"R32", "R404A", "R407C", "R410A", "R507A", "RC318", "SulfurHexafluoride",
"Toluene", "Water", "m-Xylene", "n-Butane", "n-Decane", "n-Dodecane", "n-Heptane",
"n-Hexane", "n-Nonane", "n-Octane", "n-Pentane", "n-Propane", "o-Xylene", "p-Xylene"};

public:
/*!
* \brief Constructor of the class.
*/
CCoolPropConductivity(const string& fluidname) {
#ifdef USE_COOLPROP
fluid_entity = std::unique_ptr<CoolProp::AbstractState>(CoolProp::AbstractState::factory("HEOS", fluidname));
if (std::find(fluidNameList.begin(), fluidNameList.end(), fluidname) == fluidNameList.end()) {
SU2_MPI::Error("Conductivity model not available for this fluid in CoolProp library.", CURRENT_FUNCTION);
}
#else
SU2_MPI::Error(
"SU2 was not compiled with CoolProp (-Denable-coolprop=true). Note that CoolProp cannot be used with "
"directdiff or autodiff",
CURRENT_FUNCTION);
#endif
}

/*!
* \brief Set thermal conductivity.
*/
void SetConductivity(su2double t, su2double rho, su2double, su2double, su2double, su2double, su2double) override {
#ifdef USE_COOLPROP
fluid_entity->update(CoolProp::DmassT_INPUTS, rho, t);
kt_ = fluid_entity->conductivity();
#endif
}
};
141 changes: 141 additions & 0 deletions SU2_CFD/include/fluid/CCoolPropViscosity.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/*!
* \file CCoolPropViscosity.hpp
* \brief Defines CoolPropviscosity model.
* \author P.Yan, G. Gori, A. Guardone,
* \version 7.4.0 "Blackbird"
*
* SU2 Project Website: https://su2code.github.io
*
* The SU2 Project is maintained by the SU2 Foundation
* (http://su2foundation.org)
*
* Copyright 2012-2022, SU2 Contributors (cf. AUTHORS.md)
*
* SU2 is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* SU2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with SU2. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include "CCoolProp.hpp"
#include "CViscosityModel.hpp"

#ifdef USE_COOLPROP
#include "AbstractState.h"
#include "CoolProp.h"
#endif
/*!
* \class CCoolPropViscosity
* \brief Defines CoolProp viscosity model.
* \author P.Yan
*/
class CCoolPropViscosity final : public CViscosityModel {
private:
#ifdef USE_COOLPROP
std::unique_ptr<CoolProp::AbstractState> fluid_entity; /*!< \brief fluid entity */
#endif
/*!< \brief list of fluids whose viscosity model is available in CoolProp */
const vector<string> fluidNameList = {"Air",
"Ammonia",
"Argon",
"Benzene",
"CarbonDioxide",
"CycloHexane",
"Cyclopentane",
"DimethylEther",
"Ethane",
"Ethanol",
"HeavyWater",
"Helium",
"Hydrogen",
"HydrogenSulfide",
"IsoButane",
"Isopentane",
"Methane",
"Methanol",
"Nitrogen",
"Oxygen",
"Propylene",
"R11",
"R116",
"R12",
"R123",
"R1233zd(E)",
"R1234yf",
"R1234ze(E)",
"R124",
"R125",
"R13",
"R134a",
"R14",
"R141b",
"R142b",
"R143a",
"R152A",
"R218",
"R22",
"R227EA",
"R23",
"R236EA",
"R236FA",
"R245fa",
"R32",
"R404A",
"R407C",
"R410A",
"R507A",
"RC318",
"SulfurHexafluoride",
"Toluene",
"Water",
"m-Xylene",
"n-Butane",
"n-Decane",
"n-Dodecane",
"n-Heptane",
"n-Hexane",
"n-Nonane",
"n-Octane",
"n-Pentane",
"n-Propane",
"o-Xylene",
"p-Xylene"};

public:
/*!
* \brief Constructor of the class.
*/
CCoolPropViscosity(const string& fluidname) {
#ifdef USE_COOLPROP
fluid_entity = std::unique_ptr<CoolProp::AbstractState>(CoolProp::AbstractState::factory("HEOS", fluidname));
if (std::find(fluidNameList.begin(), fluidNameList.end(), fluidname) == fluidNameList.end()) {
SU2_MPI::Error("Viscosity model not available for this fluid in CoolProp library.", CURRENT_FUNCTION);
}
#else
SU2_MPI::Error(
"SU2 was not compiled with CoolProp (-Denable-coolprop=true). Note that CoolProp cannot be used with "
"directdiff or autodiff",
CURRENT_FUNCTION);
#endif
}

/*!
* \brief Set Viscosity.
*/
void SetViscosity(su2double t, su2double rho) override {
#ifdef USE_COOLPROP
fluid_entity->update(CoolProp::DmassT_INPUTS, rho, t);
mu_ = fluid_entity->viscosity();
#endif
}
};
1 change: 0 additions & 1 deletion SU2_CFD/src/fluid/CCoolProp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ CCoolProp::CCoolProp(string fluidname) : CFluidModel() {
CCoolProp::~CCoolProp() {}

void CCoolProp::SetTDState_rhoe(su2double rho, su2double e) {
//cout<<"p "<<Pressure<<"Pc "<<Pressure_Critical<<"T "<<Temperature<<"Tc"<<Temperature_Critical<<endl;
Density = rho;
StaticEnergy = e;
fluid_entity->update(CoolProp::DmassUmass_INPUTS, Density, StaticEnergy);
Expand Down
14 changes: 14 additions & 0 deletions SU2_CFD/src/fluid/CFluidModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,16 @@
#include "../../include/fluid/CPolynomialConductivityRANS.hpp"
#include "../../include/fluid/CPolynomialViscosity.hpp"
#include "../../include/fluid/CSutherland.hpp"
#include "../../include/fluid/CCoolPropViscosity.hpp"
#include "../../include/fluid/CConstantLewisDiffusivity.hpp"
#include "../../include/fluid/CCoolPropConductivity.hpp"

unique_ptr<CViscosityModel> CFluidModel::MakeLaminarViscosityModel(const CConfig* config, unsigned short iSpecies) {
switch (config->GetKind_ViscosityModel()) {
case VISCOSITYMODEL::CONSTANT:
return unique_ptr<CConstantViscosity>(new CConstantViscosity(config->GetMu_ConstantND(iSpecies)));
case VISCOSITYMODEL::COOLPROP:
return unique_ptr<CCoolPropViscosity>(new CCoolPropViscosity(config->GetFluid_Name()));
case VISCOSITYMODEL::SUTHERLAND:
return unique_ptr<CSutherland>(new CSutherland(config->GetMu_RefND(iSpecies),
config->GetMu_Temperature_RefND(iSpecies),
Expand Down Expand Up @@ -77,6 +81,16 @@ unique_ptr<CConductivityModel> CFluidModel::MakeThermalConductivityModel(const C
new CConstantConductivity(config->GetThermal_Conductivity_ConstantND(iSpecies)));
}
break;
case CONDUCTIVITYMODEL::COOLPROP:
if (config->GetKind_ConductivityModel_Turb() == CONDUCTIVITYMODEL_TURB::CONSTANT_PRANDTL) {
return unique_ptr<CConstantConductivityRANS>(
new CConstantConductivityRANS(config->GetThermal_Conductivity_ConstantND(iSpecies),
config->GetPrandtl_Turb(iSpecies)));
} else {
return unique_ptr<CCoolPropConductivity>(
new CCoolPropConductivity(config->GetFluid_Name()));
}
break;
case CONDUCTIVITYMODEL::CONSTANT_PRANDTL:
if (config->GetKind_ConductivityModel_Turb() == CONDUCTIVITYMODEL_TURB::CONSTANT_PRANDTL) {
return unique_ptr<CConstantPrandtlRANS>(
Expand Down
3 changes: 1 addition & 2 deletions SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,13 @@ void CConjugateHeatInterface::GetDonor_Variable(CSolver *donor_solution, CGeomet
switch (donor_config->GetKind_ConductivityModel()) {

case CONDUCTIVITYMODEL::CONSTANT:
case CONDUCTIVITYMODEL::COOLPROP:
thermal_conductivity = thermal_conductivityND*donor_config->GetThermal_Conductivity_Ref();
break;

case CONDUCTIVITYMODEL::CONSTANT_PRANDTL:
thermal_conductivity = thermal_conductivityND*donor_config->GetGas_Constant_Ref()
*donor_config->GetViscosity_Ref();
break;

case CONDUCTIVITYMODEL::POLYNOMIAL:
SU2_MPI::Error("Polynomial Conductivity model not implemented for CHT interface.", CURRENT_FUNCTION);
break;
Expand Down
15 changes: 14 additions & 1 deletion SU2_CFD/src/output/CFlowOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2402,6 +2402,10 @@ void CFlowOutput::WriteForcesBreakdown(const CConfig* config, const CSolver* flo
file << "Laminar Viscosity (non-dim): " << config->GetMu_ConstantND() << "\n";
break;

case VISCOSITYMODEL::COOLPROP:
file << "Viscosity Model: CoolProp \n";
break;

case VISCOSITYMODEL::SUTHERLAND:
file << "Viscosity Model: SUTHERLAND \n";
file << "Ref. Laminar Viscosity: " << config->GetMu_Ref();
Expand Down Expand Up @@ -2432,7 +2436,9 @@ void CFlowOutput::WriteForcesBreakdown(const CConfig* config, const CSolver* flo
file << "Molecular Conductivity: " << config->GetThermal_Conductivity_Constant() << " W/m^2.K.\n";
file << "Molecular Conductivity (non-dim): " << config->GetThermal_Conductivity_ConstantND() << "\n";
break;

case CONDUCTIVITYMODEL::COOLPROP:
file << "Conductivity Model: COOLPROP \n";
break;
default:
break;
}
Expand Down Expand Up @@ -2724,6 +2730,10 @@ void CFlowOutput::WriteForcesBreakdown(const CConfig* config, const CSolver* flo
file << "Laminar Viscosity (non-dim): " << config->GetMu_ConstantND() << "\n";
break;

case VISCOSITYMODEL::COOLPROP:
file << "Viscosity Model: CoolProp \n";
break;

case VISCOSITYMODEL::SUTHERLAND:
file << "Viscosity Model: SUTHERLAND \n";
file << "Ref. Laminar Viscosity: " << config->GetMu_Ref();
Expand Down Expand Up @@ -2769,6 +2779,9 @@ void CFlowOutput::WriteForcesBreakdown(const CConfig* config, const CSolver* flo
file << "Molecular Conductivity: " << config->GetThermal_Conductivity_Constant() << " W/m^2.K.\n";
file << "Molecular Conductivity (non-dim): " << config->GetThermal_Conductivity_ConstantND() << "\n";
break;
case CONDUCTIVITYMODEL::COOLPROP:
file << "Conductivity Model: COOLPROP \n";
break;

case CONDUCTIVITYMODEL::POLYNOMIAL:
file << "Viscosity Model: POLYNOMIAL \n";
Expand Down
Loading