-
Notifications
You must be signed in to change notification settings - Fork 913
CoolProp fluid model #1806
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
Merged
Merged
CoolProp fluid model #1806
Changes from all commits
Commits
Show all changes
64 commits
Select commit
Hold shift + click to select a range
2f87fc3
CoolProp link failed
PENGYAN777 a84244f
fmt.h not found
PENGYAN777 430ebed
Merge branch 'su2code:develop' into develop
PENGYAN777 0ab0e1b
immitate mutation++
PENGYAN777 416678a
immitate mutationpp
PENGYAN777 6dd71a2
Merge branch 'su2code:develop' into develop
PENGYAN777 7752ec7
configuration succeed
PENGYAN777 c8f2a47
Merge branch 'su2code:develop' into develop
PENGYAN777 32ebb3c
Merge branch 'su2code:develop' into develop
PENGYAN777 ea23e57
build succedd, but FLUID_MODEL=CoolProp failed
PENGYAN777 4e9897c
can not read FLUID_NAME
PENGYAN777 e72bba8
Merge branch 'su2code:develop' into develop
PENGYAN777 a6ce86a
Merge branch 'develop' into develop
bigfooted 6b13b55
update fmtlib
PENGYAN777 82614e7
remove unnecessary files
PENGYAN777 c7b65f3
latest version
PENGYAN777 1d6b67a
output CoolProp gas constant
PENGYAN777 690a753
output gas constant from CoolProp
PENGYAN777 dcfd998
N2 succeed but MM failed
PENGYAN777 ef2c930
avoid new and delete pointer
PENGYAN777 dfe17a1
add testcases N2, O2, CO2, MM
PENGYAN777 a355362
Merge branch 'develop' into develop
pcarruscag fe11f8c
fxi format
PENGYAN777 14bc67e
fix format
PENGYAN777 abdf76d
Merge branch 'develop' into develop
PENGYAN777 ccba012
Merge branch 'develop' into develop
pcarruscag 8dd1099
let github find coolprop
PENGYAN777 5eef0f4
Merge branch 'develop' of https://github.com/PENGYAN777/SU2 into develop
PENGYAN777 4304e1e
let github find coolprop
PENGYAN777 2e74c55
let github find coolprop
PENGYAN777 6f9dad1
let github find coolprop
PENGYAN777 426f010
fix codeFactor issue
PENGYAN777 5feb077
Apply suggestions from code review
pcarruscag df8ffa9
Apply suggestions from code review
pcarruscag bfed1ec
Update SU2_CFD/src/fluid/CCoolProp.cpp
pcarruscag d5e03fc
Apply suggestions from code review
pcarruscag faeaed2
Merge branch 'develop' into develop
pcarruscag 8956d8e
add regression test
PENGYAN777 9c881ab
delete unnecessary files
PENGYAN777 bbae14f
add cmake for github
PENGYAN777 1cf9e54
import cmake for github
PENGYAN777 2eac113
import cmake for github
PENGYAN777 1bb0f44
avoid two-phase flow
PENGYAN777 8738b64
update soundspeed for two-phase low
PENGYAN777 501224d
aviod two phase state
PENGYAN777 6a5aa3a
compile coolprop with cmake
PENGYAN777 38a591f
load cmake for coolprop
PENGYAN777 238a108
let cmake find ninja
PENGYAN777 b28c6e0
retrive: find ninja
PENGYAN777 ee3a389
Merge pull request #1782 from PENGYAN777/develop
pcarruscag 7cccf4e
add current dir to path to build coolprop
pcarruscag b53f601
different method of getting current dir
pcarruscag b9d4f69
point cmake directly instead of using the environment
pcarruscag db4dfaf
Update meson.build
pcarruscag b45d0f8
Update .github/workflows/regression.yml
pcarruscag acf4d16
supress warnings in coolprop
pcarruscag 1831b1e
Update SU2_CFD/include/fluid/CCoolProp.hpp
pcarruscag d0d7b4b
test to push to feature_coolprop
PENGYAN777 bf90da2
error if CoolProp used with non-dimensionalization
PENGYAN777 9814678
error if coolprop used with non-dimensionalization
PENGYAN777 7c845b0
Update Common/src/CConfig.cpp
pcarruscag 741b344
Merge pull request #1814 from PENGYAN777/feature_coolprop
pcarruscag 1b099d6
Merge branch 'develop' into feature_coolprop
pcarruscag c5fd919
Apply suggestions from code review
pcarruscag File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| /*! | ||
| * \file CCoolProp.hpp | ||
| * \brief Defines the state-of-the-art fluid model from CoolProp library. | ||
| * \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 "CFluidModel.hpp" | ||
| #if defined(HAVE_COOLPROP) && !defined(CODI_FORWARD_TYPE) && !defined(CODI_REVERSE_TYPE) | ||
| #define USE_COOLPROP | ||
| namespace CoolProp { | ||
| class AbstractState; | ||
| } | ||
| #endif | ||
| #include <memory> | ||
|
|
||
|
|
||
| /*! | ||
| * \class CCoolProp | ||
| * \brief Child class for defining fluid model from CoolProp library. | ||
| * \author: P.Yan | ||
| */ | ||
| class CCoolProp final : public CFluidModel { | ||
| private: | ||
| su2double Gamma{1.4}; /*!< \brief Ratio of Specific Heats. */ | ||
| su2double Gas_Constant{297}; /*!< \brief specific Gas Constant. */ | ||
| su2double Pressure_Critical{0.0}; /*!< \brief critical pressure */ | ||
| su2double Temperature_Critical{0.0}; /*!< \brief critical temperature */ | ||
| su2double acentric_factor{0.0}; /*!< \brief acentric factor */ | ||
| #ifdef USE_COOLPROP | ||
| std::unique_ptr<CoolProp::AbstractState> fluid_entity; /*!< \brief fluid entity */ | ||
| #endif | ||
|
|
||
| public: | ||
| /*! | ||
| * \brief Constructor of the class. | ||
| */ | ||
| CCoolProp(string fluidname); | ||
|
|
||
| #ifdef USE_COOLPROP | ||
| /*! | ||
| * \brief Destructor of the class. | ||
| * \note Needs to be defined in the .cpp to allow using only a forward declaration of CoolProp::AbstractState. | ||
| */ | ||
| ~CCoolProp(); | ||
|
|
||
| /*! | ||
| * \brief Set the Dimensionless State using Density and Internal Energy | ||
| * \param[in] rho - first thermodynamic variable. | ||
| * \param[in] e - second thermodynamic variable. | ||
| */ | ||
| void SetTDState_rhoe(su2double rho, su2double e) override; | ||
|
|
||
| /*! | ||
| * \brief Set the Dimensionless State using Pressure and Temperature | ||
| * \param[in] P - first thermodynamic variable. | ||
| * \param[in] T - second thermodynamic variable. | ||
| */ | ||
| void SetTDState_PT(su2double P, su2double T) override; | ||
|
|
||
| /*! | ||
| * \brief Set the Dimensionless State using Pressure and Density | ||
| * \param[in] P - first thermodynamic variable. | ||
| * \param[in] rho - second thermodynamic variable. | ||
| */ | ||
| void SetTDState_Prho(su2double P, su2double rho) override; | ||
|
|
||
| /*! | ||
| * \brief Set the Dimensionless Internal Energy using Pressure and Density | ||
| * \param[in] P - first thermodynamic variable. | ||
| * \param[in] rho - second thermodynamic variable. | ||
| */ | ||
| void SetEnergy_Prho(su2double P, su2double rho) override; | ||
|
|
||
| /*! | ||
| * \brief Set the Dimensionless State using Enthalpy and Entropy | ||
| * \param[in] th1 - first thermodynamic variable (h). | ||
| * \param[in] th2 - second thermodynamic variable (s). | ||
| */ | ||
| void SetTDState_hs(su2double h, su2double s) override; | ||
|
|
||
| /*! | ||
| * \brief Set the Dimensionless State using Density and Temperature | ||
| * \param[in] th1 - first thermodynamic variable (rho). | ||
| * \param[in] th2 - second thermodynamic variable (T). | ||
| */ | ||
| void SetTDState_rhoT(su2double rho, su2double T) override; | ||
|
|
||
| /*! | ||
| * \brief Set the Dimensionless State using Pressure and Entropy | ||
| * \param[in] th1 - first thermodynamic variable (P). | ||
| * \param[in] th2 - second thermodynamic variable (s). | ||
| */ | ||
| void SetTDState_Ps(su2double P, su2double s) override; | ||
|
|
||
| /*! | ||
| * \brief compute some derivatives of enthalpy and entropy needed for subsonic inflow BC | ||
| * \param[in] th1 - first thermodynamic variable (P). | ||
| * \param[in] th2 - second thermodynamic variable (rho). | ||
| */ | ||
| void ComputeDerivativeNRBC_Prho(su2double P, su2double rho) override; | ||
| #endif | ||
|
|
||
| /*! | ||
| * \brief Get the value of the critical pressure. | ||
| * \return Critical pressure. | ||
| */ | ||
| su2double GetPressure_Critical(void) const { return Pressure_Critical; } | ||
|
|
||
| /*! | ||
| * \brief Get the value of the critical temperature. | ||
| * \return Critical temperature. | ||
| */ | ||
| su2double GetTemperature_Critical(void) const { return Temperature_Critical; } | ||
|
|
||
| /*! | ||
| * \brief Get the value of specific gas constant. | ||
| * \return Value of the constant: Gamma | ||
| */ | ||
| su2double GetGas_Constant(void) const { return Gas_Constant; } | ||
|
|
||
| /*! | ||
| * \brief Get the value of specific gas constant. | ||
| * \return Value of the constant: Gamma | ||
| */ | ||
| su2double GetGamma(void) const { return Gamma; } | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| /*! | ||
| * \file CCoolProp.cpp | ||
| * \brief Source of the fluid 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/>. | ||
| */ | ||
|
|
||
| #include "../../include/fluid/CCoolProp.hpp" | ||
|
|
||
| #ifdef USE_COOLPROP | ||
| #include "CoolProp.h" | ||
| #include "AbstractState.h" | ||
|
|
||
| CCoolProp::CCoolProp(string fluidname) : CFluidModel() { | ||
| fluid_entity = std::unique_ptr<CoolProp::AbstractState>(CoolProp::AbstractState::factory("HEOS",fluidname)); | ||
| Gas_Constant = fluid_entity->gas_constant()/fluid_entity->molar_mass(); | ||
| Pressure_Critical = fluid_entity->p_critical(); | ||
| Temperature_Critical = fluid_entity->T_critical(); | ||
| acentric_factor = fluid_entity->acentric_factor(); | ||
| } | ||
|
|
||
| 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); | ||
| Cp = fluid_entity->cpmass(); | ||
| Cv = fluid_entity->cvmass(); | ||
| Gamma = Cp / Cv; | ||
| Pressure = fluid_entity->p(); | ||
| Temperature = fluid_entity->T(); | ||
| Entropy = fluid_entity->smass(); | ||
| dPdrho_e = fluid_entity->first_partial_deriv(CoolProp::iP, CoolProp::iDmass, CoolProp::iUmass); | ||
| dPde_rho = fluid_entity->first_partial_deriv(CoolProp::iP, CoolProp::iUmass, CoolProp::iDmass); | ||
| dTdrho_e = fluid_entity->first_partial_deriv(CoolProp::iT, CoolProp::iDmass, CoolProp::iUmass); | ||
| dTde_rho = fluid_entity->first_partial_deriv(CoolProp::iT, CoolProp::iUmass, CoolProp::iDmass); | ||
| if (fluid_entity->phase() == 6) { | ||
| fluid_entity->specify_phase(CoolProp::iphase_gas); | ||
| SetTDState_PT(Pressure,Temperature); | ||
| } | ||
| else{ | ||
| SoundSpeed2 = pow(fluid_entity->speed_sound(), 2); | ||
| } | ||
| } | ||
|
|
||
| void CCoolProp::SetTDState_PT(su2double P, su2double T) { | ||
| fluid_entity->update(CoolProp::PT_INPUTS, P, T); | ||
| su2double rho = fluid_entity->rhomass(); | ||
| su2double e = fluid_entity->umass(); | ||
| SetTDState_rhoe(rho, e); | ||
| } | ||
|
|
||
| void CCoolProp::SetTDState_Prho(su2double P, su2double rho) { | ||
| fluid_entity->update(CoolProp::DmassP_INPUTS, rho, P); | ||
| su2double e = fluid_entity->umass(); | ||
| SetTDState_rhoe(rho, e); | ||
| } | ||
|
|
||
| void CCoolProp::SetEnergy_Prho(su2double P, su2double rho) { | ||
| fluid_entity->update(CoolProp::DmassP_INPUTS, rho, P); | ||
| StaticEnergy = fluid_entity->umass(); | ||
| } | ||
|
|
||
| void CCoolProp::SetTDState_hs(su2double h, su2double s) { | ||
| fluid_entity->update(CoolProp::HmassSmass_INPUTS, h, s); | ||
| su2double rho = fluid_entity->rhomass(); | ||
| su2double e = fluid_entity->umass(); | ||
| SetTDState_rhoe(rho, e); | ||
| } | ||
|
|
||
| void CCoolProp::SetTDState_Ps(su2double P, su2double s) { | ||
| fluid_entity->update(CoolProp::PSmass_INPUTS, P, s); | ||
| su2double Rho = fluid_entity->rhomass(); | ||
| su2double e = fluid_entity->umass(); | ||
| SetTDState_rhoe(Rho, e); | ||
| } | ||
|
|
||
| void CCoolProp::SetTDState_rhoT(su2double rho, su2double T) { | ||
| fluid_entity->update(CoolProp::DmassT_INPUTS, rho, T); | ||
| su2double Rho = fluid_entity->rhomass(); | ||
| su2double e = fluid_entity->umass(); | ||
| SetTDState_rhoe(Rho, e); | ||
| } | ||
|
|
||
| void CCoolProp::ComputeDerivativeNRBC_Prho(su2double P, su2double rho) { | ||
| SetTDState_Prho(P, rho); | ||
| dhdrho_P = fluid_entity->first_partial_deriv(CoolProp::iHmass,CoolProp::iDmass,CoolProp::iP); | ||
| dhdP_rho = fluid_entity->first_partial_deriv(CoolProp::iHmass,CoolProp::iP,CoolProp::iDmass); | ||
| dsdP_rho = fluid_entity->first_partial_deriv(CoolProp::iSmass,CoolProp::iP,CoolProp::iDmass); | ||
| dsdrho_P = fluid_entity->first_partial_deriv(CoolProp::iSmass,CoolProp::iDmass,CoolProp::iP); | ||
| } | ||
|
|
||
| #else | ||
| CCoolProp::CCoolProp(string fluidname) { | ||
| 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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.