Skip to content

Commit 0d359a6

Browse files
authored
Merge branch 'develop' into fix_sst_axisymmetry
2 parents 870f509 + 9f76df4 commit 0d359a6

21 files changed

Lines changed: 584 additions & 21 deletions

.github/workflows/regression.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
config_set: [BaseMPI, ReverseMPI, ForwardMPI, BaseNoMPI, ReverseNoMPI, ForwardNoMPI, BaseOMP, ReverseOMP, ForwardOMP]
2727
include:
2828
- config_set: BaseMPI
29-
flags: '-Denable-pywrapper=true -Denable-tests=true --warnlevel=3 --werror'
29+
flags: '-Denable-pywrapper=true -Denable-coolprop=true -Denable-tests=true --warnlevel=2 --werror'
3030
- config_set: ReverseMPI
3131
flags: '-Denable-autodiff=true -Denable-normal=false -Denable-pywrapper=true -Denable-tests=true --warnlevel=3 --werror'
3232
- config_set: ForwardMPI
@@ -52,12 +52,12 @@ jobs:
5252
key: ${{ matrix.config_set }}-${{ github.sha }}
5353
restore-keys: ${{ matrix.config_set }}
5454
- name: Pre Cleanup
55-
uses: docker://ghcr.io/su2code/su2/build-su2:220614-1237
55+
uses: docker://ghcr.io/su2code/su2/build-su2:221027-0442
5656
with:
5757
entrypoint: /bin/rm
5858
args: -rf install install_bin.tgz src ccache ${{ matrix.config_set }}
5959
- name: Build
60-
uses: docker://ghcr.io/su2code/su2/build-su2:220614-1237
60+
uses: docker://ghcr.io/su2code/su2/build-su2:221027-0442
6161
with:
6262
args: -b ${{github.ref}} -f "${{matrix.flags}}"
6363
- name: Compress binaries
@@ -68,7 +68,7 @@ jobs:
6868
name: ${{ matrix.config_set }}
6969
path: install_bin.tgz
7070
- name: Post Cleanup
71-
uses: docker://ghcr.io/su2code/su2/build-su2:220614-1237
71+
uses: docker://ghcr.io/su2code/su2/build-su2:221027-0442
7272
with:
7373
entrypoint: /bin/rm
7474
args: -rf install install_bin.tgz src ccache ${{ matrix.config_set }}

.gitmodules

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
url = https://github.com/mesonbuild/meson
1515
[submodule "subprojects/Mutationpp"]
1616
path = subprojects/Mutationpp
17-
url = https://github.com/mutationpp/Mutationpp.git
17+
url = https://github.com/mutationpp/Mutationpp.git
18+
[submodule "subprojects/CoolProp"]
19+
path = subprojects/CoolProp
20+
url = https://github.com/CoolProp/CoolProp.git
1821
[submodule "externals/opdi"]
1922
path = externals/opdi
2023
url = https://github.com/SciCompKL/OpDiLib

AUTHORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ Patrick Mischke
109109
Paul Urbanczyk
110110
Paul Zhang
111111
Pedro Gomes
112+
Peng Yan
112113
Pete Bachant
113114
RaulFeijo55
114115
Ruben Sanchez

Common/include/CConfig.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class CConfig {
8080
su2double EA_ScaleFactor; /*!< \brief Equivalent Area scaling factor */
8181
su2double AdjointLimit; /*!< \brief Adjoint variable limit */
8282
string* ConvField; /*!< \brief Field used for convergence check.*/
83+
string FluidName; /*!< \brief name of the applied fluid. */
8384

8485
string* WndConvField; /*!< \brief Function where to apply the windowed convergence criteria for the time average of the unsteady (single zone) flow problem. */
8586
unsigned short nConvField; /*!< \brief Number of fields used to monitor convergence.*/
@@ -3752,6 +3753,11 @@ class CConfig {
37523753
*/
37533754
unsigned short GetKind_FluidModel(void) const { return Kind_FluidModel; }
37543755

3756+
/*!
3757+
* \brief Returns the name of the fluid we are using in CoolProp.
3758+
*/
3759+
string GetFluid_Name(void) const { return FluidName; }
3760+
37553761
/*!
37563762
* \brief Option to define the density model for incompressible flows.
37573763
* \return Density model option

Common/include/option_structure.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,7 @@ enum ENUM_FLUIDMODEL {
569569
MUTATIONPP = 7, /*!< \brief Mutation++ gas model for nonequilibrium flow. */
570570
SU2_NONEQ = 8, /*!< \brief User defined gas model for nonequilibrium flow. */
571571
FLUID_MIXTURE = 9, /*!< \brief Species mixture model. */
572+
COOLPROP = 10, /*!< \brief Thermodynamics library. */
572573
};
573574
static const MapType<std::string, ENUM_FLUIDMODEL> FluidModel_Map = {
574575
MakePair("STANDARD_AIR", STANDARD_AIR)
@@ -581,6 +582,7 @@ static const MapType<std::string, ENUM_FLUIDMODEL> FluidModel_Map = {
581582
MakePair("MUTATIONPP", MUTATIONPP)
582583
MakePair("SU2_NONEQ", SU2_NONEQ)
583584
MakePair("FLUID_MIXTURE", FLUID_MIXTURE)
585+
MakePair("COOLPROP", COOLPROP)
584586
};
585587

586588
/*!

Common/src/CConfig.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,8 @@ void CConfig::SetConfig_Options() {
11501150
/*!\par CONFIG_CATEGORY: FluidModel \ingroup Config*/
11511151
/*!\brief FLUID_MODEL \n DESCRIPTION: Fluid model \n OPTIONS: See \link FluidModel_Map \endlink \n DEFAULT: STANDARD_AIR \ingroup Config*/
11521152
addEnumOption("FLUID_MODEL", Kind_FluidModel, FluidModel_Map, STANDARD_AIR);
1153+
/*!\brief FLUID_NAME \n DESCRIPTION: Fluid name \n OPTIONS: see coolprop homepage \n DEFAULT: nitrogen \ingroup Config*/
1154+
addStringOption("FLUID_NAME", FluidName, string("nitrogen"));
11531155

11541156

11551157
/*!\par CONFIG_CATEGORY: Freestream Conditions \ingroup Config*/
@@ -3383,6 +3385,11 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i
33833385
}
33843386
#endif
33853387

3388+
/*--- Check if CoolProp is used with non-dimensionalization. ---*/
3389+
if (Kind_FluidModel == COOLPROP && Ref_NonDim != DIMENSIONAL) {
3390+
SU2_MPI::Error("CoolProp can not be used with non-dimensionalization.", CURRENT_FUNCTION);
3391+
}
3392+
33863393
/*--- STL_BINARY output not implemented yet, but already a value in option_structure.hpp---*/
33873394
for (unsigned short iVolumeFile = 0; iVolumeFile < nVolumeOutputFiles; iVolumeFile++) {
33883395
if (VolumeOutputFiles[iVolumeFile] == OUTPUT_TYPE::STL_BINARY){
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
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+
};

SU2_CFD/obj/Makefile.am

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ libSU2Core_sources = ../src/definition_structure.cpp \
5454
../src/fluid/CFluidScalar.cpp \
5555
../src/fluid/CPengRobinson.cpp \
5656
../src/fluid/CVanDerWaalsGas.cpp \
57+
../src/fluid/CCoolProp.cpp \
5758
../src/fluid/CNEMOGas.cpp \
5859
../src/fluid/CSU2TCLib.cpp \
5960
../src/fluid/CMutationTCLib.cpp \
@@ -246,6 +247,11 @@ su2_cfd_cxx_flags += @MUTATIONPP_CXX@
246247
su2_cfd_ldadd += @MUTATIONPP_LD@
247248
# endif
248249

250+
251+
su2_cfd_cxx_flags += @CoolProp_CXX@
252+
su2_cfd_ldadd += @CoolProp_LD@
253+
254+
249255
if BUILD_NORMAL
250256
libSU2Core_a_SOURCES = $(libSU2Core_sources)
251257
libSU2Core_a_CXXFLAGS = $(libSU2Core_cxx_flags)

SU2_CFD/src/fluid/CCoolProp.cpp

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
/*!
2+
* \file CCoolProp.cpp
3+
* \brief Source of the fluid 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+
#include "../../include/fluid/CCoolProp.hpp"
29+
30+
#ifdef USE_COOLPROP
31+
#include "CoolProp.h"
32+
#include "AbstractState.h"
33+
34+
CCoolProp::CCoolProp(string fluidname) : CFluidModel() {
35+
fluid_entity = std::unique_ptr<CoolProp::AbstractState>(CoolProp::AbstractState::factory("HEOS",fluidname));
36+
Gas_Constant = fluid_entity->gas_constant()/fluid_entity->molar_mass();
37+
Pressure_Critical = fluid_entity->p_critical();
38+
Temperature_Critical = fluid_entity->T_critical();
39+
acentric_factor = fluid_entity->acentric_factor();
40+
}
41+
42+
CCoolProp::~CCoolProp() {}
43+
44+
void CCoolProp::SetTDState_rhoe(su2double rho, su2double e) {
45+
//cout<<"p "<<Pressure<<"Pc "<<Pressure_Critical<<"T "<<Temperature<<"Tc"<<Temperature_Critical<<endl;
46+
Density = rho;
47+
StaticEnergy = e;
48+
fluid_entity->update(CoolProp::DmassUmass_INPUTS, Density, StaticEnergy);
49+
Cp = fluid_entity->cpmass();
50+
Cv = fluid_entity->cvmass();
51+
Gamma = Cp / Cv;
52+
Pressure = fluid_entity->p();
53+
Temperature = fluid_entity->T();
54+
Entropy = fluid_entity->smass();
55+
dPdrho_e = fluid_entity->first_partial_deriv(CoolProp::iP, CoolProp::iDmass, CoolProp::iUmass);
56+
dPde_rho = fluid_entity->first_partial_deriv(CoolProp::iP, CoolProp::iUmass, CoolProp::iDmass);
57+
dTdrho_e = fluid_entity->first_partial_deriv(CoolProp::iT, CoolProp::iDmass, CoolProp::iUmass);
58+
dTde_rho = fluid_entity->first_partial_deriv(CoolProp::iT, CoolProp::iUmass, CoolProp::iDmass);
59+
if (fluid_entity->phase() == 6) {
60+
fluid_entity->specify_phase(CoolProp::iphase_gas);
61+
SetTDState_PT(Pressure,Temperature);
62+
}
63+
else{
64+
SoundSpeed2 = pow(fluid_entity->speed_sound(), 2);
65+
}
66+
}
67+
68+
void CCoolProp::SetTDState_PT(su2double P, su2double T) {
69+
fluid_entity->update(CoolProp::PT_INPUTS, P, T);
70+
su2double rho = fluid_entity->rhomass();
71+
su2double e = fluid_entity->umass();
72+
SetTDState_rhoe(rho, e);
73+
}
74+
75+
void CCoolProp::SetTDState_Prho(su2double P, su2double rho) {
76+
fluid_entity->update(CoolProp::DmassP_INPUTS, rho, P);
77+
su2double e = fluid_entity->umass();
78+
SetTDState_rhoe(rho, e);
79+
}
80+
81+
void CCoolProp::SetEnergy_Prho(su2double P, su2double rho) {
82+
fluid_entity->update(CoolProp::DmassP_INPUTS, rho, P);
83+
StaticEnergy = fluid_entity->umass();
84+
}
85+
86+
void CCoolProp::SetTDState_hs(su2double h, su2double s) {
87+
fluid_entity->update(CoolProp::HmassSmass_INPUTS, h, s);
88+
su2double rho = fluid_entity->rhomass();
89+
su2double e = fluid_entity->umass();
90+
SetTDState_rhoe(rho, e);
91+
}
92+
93+
void CCoolProp::SetTDState_Ps(su2double P, su2double s) {
94+
fluid_entity->update(CoolProp::PSmass_INPUTS, P, s);
95+
su2double Rho = fluid_entity->rhomass();
96+
su2double e = fluid_entity->umass();
97+
SetTDState_rhoe(Rho, e);
98+
}
99+
100+
void CCoolProp::SetTDState_rhoT(su2double rho, su2double T) {
101+
fluid_entity->update(CoolProp::DmassT_INPUTS, rho, T);
102+
su2double Rho = fluid_entity->rhomass();
103+
su2double e = fluid_entity->umass();
104+
SetTDState_rhoe(Rho, e);
105+
}
106+
107+
void CCoolProp::ComputeDerivativeNRBC_Prho(su2double P, su2double rho) {
108+
SetTDState_Prho(P, rho);
109+
dhdrho_P = fluid_entity->first_partial_deriv(CoolProp::iHmass,CoolProp::iDmass,CoolProp::iP);
110+
dhdP_rho = fluid_entity->first_partial_deriv(CoolProp::iHmass,CoolProp::iP,CoolProp::iDmass);
111+
dsdP_rho = fluid_entity->first_partial_deriv(CoolProp::iSmass,CoolProp::iP,CoolProp::iDmass);
112+
dsdrho_P = fluid_entity->first_partial_deriv(CoolProp::iSmass,CoolProp::iDmass,CoolProp::iP);
113+
}
114+
115+
#else
116+
CCoolProp::CCoolProp(string fluidname) {
117+
SU2_MPI::Error("SU2 was not compiled with CoolProp (-Denable-coolprop=true). Note that CoolProp cannot be used with directdiff or autodiff", CURRENT_FUNCTION);
118+
}
119+
#endif

0 commit comments

Comments
 (0)