From: michael Date: Mon, 17 May 2021 15:06:28 +0000 (+0200) Subject: Created a class for stiffened gas EOS X-Git-Tag: V9_7_0 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8d929de9719de184e2a25badfad25968281b5d1a;p=tools%2Fsolverlab.git Created a class for stiffened gas EOS --- diff --git a/CoreFlows/CMakeLists.txt b/CoreFlows/CMakeLists.txt index 80d0ccb..76353a5 100755 --- a/CoreFlows/CMakeLists.txt +++ b/CoreFlows/CMakeLists.txt @@ -46,6 +46,7 @@ set( CoreFlows_INCLUDES ${CDMATH_INCLUDES} # ${PETSC_INCLUDES} # ${CoreFlows_MODELS}/inc # + ${CoreFlows_MODELS}/inc/EOS # ) # add_subdirectory (${CoreFlows_MODELS}) diff --git a/CoreFlows/Models/inc/CMakeLists.txt b/CoreFlows/Models/inc/CMakeLists.txt index a165746..9a85cad 100755 --- a/CoreFlows/Models/inc/CMakeLists.txt +++ b/CoreFlows/Models/inc/CMakeLists.txt @@ -8,8 +8,10 @@ SET(include_models_HXX DiffusionEquation.hxx StationaryDiffusionEquation.hxx LinearElasticityModel.hxx - Fluide.h ProblemFluid.hxx utilitaire_algebre.h + EOS/Fluide.h + EOS/StiffenedGas.hxx +# EOS/IAPWS97.h ) INSTALL(FILES ${include_models_HXX} DESTINATION include) diff --git a/CoreFlows/Models/inc/EOS/Fluide.h b/CoreFlows/Models/inc/EOS/Fluide.h new file mode 100755 index 0000000..79e62cb --- /dev/null +++ b/CoreFlows/Models/inc/EOS/Fluide.h @@ -0,0 +1,72 @@ +#ifndef FLUIDE_H +#define FLUIDE_H + +#include +#include "math.h" +#include "CdmathException.hxx" + +/*! \class Fluide Fluide.hxx "Fluide.hxx" + * \brief Fluid thermodynamics properties + * \details Provides pressure, density, temperature, internal energy, enthalpy, viscosity and conductivity + */ + +using namespace std; + +class Fluide{ + protected: + double _mu, _lambda,_Cv, _Cp,_Tref,_gamma, _p0, _q,_dragCoeff; + public: + Fluide(){_mu=0; _lambda=0;_Cv=0;_Cp=0;_Tref=0;_dragCoeff=0;_gamma=0; _p0=0; _q=0;} + virtual ~Fluide(){}; + + //Stiffened gas equation of state + double getPressure(double rhoe,const double rho) { + return (_gamma - 1) * (rhoe - rho*_q) - _gamma*_p0; + }; + double getPressureFromEnthalpy(double h,const double rho) { + return (_gamma - 1)/_gamma * rho * (h - _q) - _p0; + }; + /*For the newton scheme in the IsothermalTwoFluid model */ + double getPressureDerivativeRhoE() { return _gamma - 1; } + double getDensityFromEnthalpy(double p, double h) + { + return _gamma*(p+_p0)/((_gamma-1)*(h-_q)); + } + double vitesseSonEnthalpie(double h) { return sqrt((_gamma-1)*h); }; + double vitesseSonTemperature(const double T, const double rho) + { + double h= getEnthalpy(T,rho); + return vitesseSonEnthalpie(h); + } + + double getViscosity(double T) {return _mu;}; + double getConductivity(double T) {return _lambda;}; + double getDragCoeffs(double T) { return _dragCoeff;}; + void setViscosity(double mu) { _mu=mu;}; + void setConductivity(double lambda) { _lambda= lambda;}; + void setDragCoeffs(double dragCoeff) {_dragCoeff=dragCoeff;}; + //return constants gamma, cp, cv, p0, q + double constante(string name) + { + if(name== "gamma") + return _gamma; + else if (name == "cv"||name == "Cv") + return _Cv; + else if (name == "cp"||name == "Cp") + return _Cp; + else if(name=="p0") + return _p0; + else if(name=="q") + return _q; + else + throw CdmathException("Unknown constant: "+name); + } + virtual double getDensity(double p, double T)=0; + virtual double getTemperatureFromPressure(const double p, const double rho)=0; + virtual double getTemperatureFromEnthalpy(const double h, const double rho)=0; + virtual double getInternalEnergy(double T, double rho)=0; + virtual double getEnthalpy(double T, double rho)=0; + +}; + +#endif diff --git a/CoreFlows/Models/inc/EOS/IAPWS97.hxx b/CoreFlows/Models/inc/EOS/IAPWS97.hxx new file mode 100644 index 0000000..f997940 --- /dev/null +++ b/CoreFlows/Models/inc/EOS/IAPWS97.hxx @@ -0,0 +1,58 @@ +#ifndef IAPWS97_H +#define IAPWS97_H + +#include +#include "CdmathException.hxx" +#include "Fluide.h" + +/*! \class IAPWS97 IAPWS97.hxx "IAPWS97.hxx" + * \brief IAPWS97 release of water and steam thermodynamics properties (freesteam library) + * \details Provides pressure, density, temperature, internal energy, enthalpy, viscosity and conductivity + */ + +using namespace std; + +//The IAPWS-IF97 law implemented by the freesteam team +class FluideIAPWS97:public Fluide{ + protected: + + public: + FluideIAPWS97(){} + virtual ~FluideIAPWS97(){}; + + //Stiffened gas equation of state + double getPressure(double rhoe,const double rho) { + return (_gamma - 1) * (rhoe - rho*_q) - _gamma*_p0; + }; + double getPressureFromEnthalpy(double h,const double rho) { + return (_gamma - 1)/_gamma * rho * (h - _q) - _p0; + }; + //For the newton scheme in the IsothermalTwoFluid model + double getPressureDerivativeRhoE() { return _gamma - 1; } + double getDensityFromEnthalpy(double p, double h) { return rhomass_phmass(p,h); } + double vitesseSonEnthalpie(double h, double p) { return speed_sound(T_phmass(p,h), p); }; + double vitesseSonTemperature(const double T, const double rho) { return speed_sound(T,rho); } + + double getViscosity(double T, rho) {return visc(T, rho);}; + double getConductivity(double T, double p) {return tcond(T,p,getDensity(T,p);}; + //return constants gamma, cp, cv, p0, q + double constante(string name, double T, double p) + { + if(name== "gamma") + return cpmass(T,p)/cvmass(T,p); + else if (name == "cv"||name == "Cv") + return cvmass(T,p); + else if (name == "cp"||name == "Cp") + return cpmass(T,p); + else + throw CdmathException("Unknown constant: "+name); + } + double getDensity(double p, double T) { return rhomass(T,p); } + double getTemperatureFromPressure(const double p, const double rho) { return T_phmass(p,h); } + double getTemperatureFromEnthalpy(const double h, const double rho) { return T_phmass(p,h); } + double getInternalEnergy(double T, double rho) { return umass(T,rho); } + double getEnthalpy(double T, double rho) { return hmass(T,rho); } + +}; + +#endif diff --git a/CoreFlows/Models/inc/EOS/StiffenedGas.hxx b/CoreFlows/Models/inc/EOS/StiffenedGas.hxx new file mode 100644 index 0000000..c1e4b88 --- /dev/null +++ b/CoreFlows/Models/inc/EOS/StiffenedGas.hxx @@ -0,0 +1,75 @@ +#ifndef STIFFENEDGAS_H +#define STIFFENEDGAS_H + +#include +#include "math.h" +#include "CdmathException.hxx" +#include "Fluide.h" + +/*! \class StiffenedGas StiffenedGas.hxx "StiffenedGas.hxx" + * \brief Stiffened Gas law approximating water and steam : P = (gamma - 1) * (rho * e - rho * q) - gamma * p0 + * \details Provides pressure, density, temperature, internal energy, enthalpy, viscosity and conductivity + */ + +using namespace std; + +// A standard stiffened gas class + +/*! \class StiffenedGas Fluide.hxx "Fluide.hxx" + * \brief Class implementing a standard stiffened gas law between pressure, density and internal energy + * \details + */ +class StiffenedGas:public Fluide{ + private: + double _e_ref;//Stiffened gas law : P=(gamma - 1) * rho e(T) - _gamma*_p0 + public: + StiffenedGas():Fluide(){_e_ref=0;}; + //Perfect gas EOS + StiffenedGas( double gamma, double cv, double T_ref, double e_ref); + //Stiffened gas law fitting reference pressure, density and sound speed + StiffenedGas(double rho_ref, double p_ref, double T_ref, double e_ref, double soundSpeed_ref, double heatCap_ref); + + double getInternalEnergy(double T, double rho=0); + double getEnthalpy(double T, double rho); + double getTemperatureFromPressure(double p, double rho); + double getTemperatureFromEnthalpy(const double h, const double rho); + double getDensity(double p, double T); + + // Functions used to compute the Roe matrix for the five equation model (Kieu) + /* get differential of the density rho = rho(P,e) + * wrt the pressure (const e) wrt the internal energy (const P) */ + double getJumpDensPress(const double e_l, const double e_r); + double getJumpDensInternalEnergy(const double p_l,const double p_r,const double e_l,const double e_r); + double getJumpInternalEnergyTemperature(); + double getDiffDensPress(const double e); + double getDiffDensInternalEnergy(const double p,const double e); + double getDiffInternalEnergyTemperature(); + /* get differential of the density rho = rho(P,h) + * wrt the pressure (const h) wrt the enthalpy (const P) */ + double getDiffDensEnthalpyPressconstant(const double p, const double h); + double getDiffDensPressEnthalpyconstant(const double h); +}; + +// S. Dellacherie stiffened gas class + +/*! \class StiffenedGasDellacherie Fluide.hxx "Fluide.hxx" + * \brief Class implementing a particular stiffened gas law including saturation properties + * \details + */ +class StiffenedGasDellacherie:public Fluide{ + private: + double _h_ref;//Stiffened gas law according to S. Dellacherie : P=(gamma - 1) * rho (e(T)-q) - _gamma*_p0 + public: + StiffenedGasDellacherie():Fluide(){_h_ref=0;}; + /* Loi des gaz raidis avec coefficients imposés suivant S. Dellacherie*/ + StiffenedGasDellacherie( double gamma, double p0, double q, double cv); + + double getInternalEnergy(double T, double rho); + double getEnthalpy(double T, double rho=0); + double getTemperatureFromPressure(double p, double rho); + double getTemperatureFromEnthalpy(const double h, const double rho=0); + double getDensity(double p, double T); + + }; + +#endif diff --git a/CoreFlows/Models/inc/Fluide.h b/CoreFlows/Models/inc/Fluide.h deleted file mode 100755 index a43e67a..0000000 --- a/CoreFlows/Models/inc/Fluide.h +++ /dev/null @@ -1,130 +0,0 @@ -#ifndef FLUIDE_H -#define FLUIDE_H - -#include -#include "math.h" -#include "CdmathException.hxx" - -/*! \class Fluide Fluide.hxx "Fluide.hxx" - * \brief Fluid thermodynamics properties - * \details Provides pressure, density, temperature, internal energy, enthalpy, viscosity and conductivity - */ - -using namespace std; - -class Fluide{ - protected: - double _mu, _lambda,_Cv, _Cp,_Tref,_gamma, _p0, _q,_dragCoeff; - public: - Fluide(){_mu=0; _lambda=0;_Cv=0;_Cp=0;_Tref=0;_dragCoeff=0;_gamma=0; _p0=0; _q=0;} - virtual ~Fluide(){}; - - //Stiffened gas equation of state - double getPressure(double rhoe,const double rho) { - return (_gamma - 1) * (rhoe - rho*_q) - _gamma*_p0; - }; - double getPressureFromEnthalpy(double h,const double rho) { - return (_gamma - 1)/_gamma * rho * (h - _q) - _p0; - }; - /*For the newton scheme in the IsothermalTwoFluid model */ - double getPressureDerivativeRhoE() { return _gamma - 1; } - double getDensityFromEnthalpy(double p, double h) - { - return _gamma*(p+_p0)/((_gamma-1)*(h-_q)); - } - double vitesseSonEnthalpie(double h) { return sqrt((_gamma-1)*h); }; - double vitesseSonTemperature(const double T, const double rho) - { - double h= getEnthalpy(T,rho); - return vitesseSonEnthalpie(h); - } - - double getViscosity(double T) {return _mu;}; - double getConductivity(double T) {return _lambda;}; - double getDragCoeffs(double T) { return _dragCoeff;}; - void setViscosity(double mu) { _mu=mu;}; - void setConductivity(double lambda) { _lambda= lambda;}; - void setDragCoeffs(double dragCoeff) {_dragCoeff=dragCoeff;}; - //return constants gamma, cp, cv, p0, q - double constante(string name) - { - if(name== "gamma") - return _gamma; - else if (name == "cv"||name == "Cv") - return _Cv; - else if (name == "cp"||name == "Cp") - return _Cp; - else if(name=="p0") - return _p0; - else if(name=="q") - return _q; - else - throw CdmathException("Unknown constant: "+name); - } - virtual double getDensity(double p, double T)=0; - virtual double getTemperatureFromPressure(const double p, const double rho)=0; - virtual double getTemperatureFromEnthalpy(const double h, const double rho)=0; - virtual double getInternalEnergy(double T, double rho)=0; - virtual double getEnthalpy(double T, double rho)=0; - -}; - -// A standard stiffened gas class - -/*! \class StiffenedGas Fluide.hxx "Fluide.hxx" - * \brief Class implementing a standard stiffened gas law between pressure, density and internal energy - * \details - */ -class StiffenedGas:public Fluide{ - private: - double _e_ref;//Stiffened gas law : P=(gamma - 1) * rho e(T) - _gamma*_p0 - public: - StiffenedGas():Fluide(){_e_ref=0;}; - //Perfect gas EOS - StiffenedGas( double gamma, double cv, double T_ref, double e_ref); - //Stiffened gas law fitting reference pressure, density and sound speed - StiffenedGas(double rho_ref, double p_ref, double T_ref, double e_ref, double soundSpeed_ref, double heatCap_ref); - - double getInternalEnergy(double T, double rho=0); - double getEnthalpy(double T, double rho); - double getTemperatureFromPressure(double p, double rho); - double getTemperatureFromEnthalpy(const double h, const double rho); - double getDensity(double p, double T); - - // Functions used to compute the Roe matrix for the five equation model (Kieu) - /* get differential of the density rho = rho(P,e) - * wrt the pressure (const e) wrt the internal energy (const P) */ - double getJumpDensPress(const double e_l, const double e_r); - double getJumpDensInternalEnergy(const double p_l,const double p_r,const double e_l,const double e_r); - double getJumpInternalEnergyTemperature(); - double getDiffDensPress(const double e); - double getDiffDensInternalEnergy(const double p,const double e); - double getDiffInternalEnergyTemperature(); - /* get differential of the density rho = rho(P,h) - * wrt the pressure (const h) wrt the enthalpy (const P) */ - double getDiffDensEnthalpyPressconstant(const double p, const double h); - double getDiffDensPressEnthalpyconstant(const double h); -}; - -// S. Dellacherie stiffened gas class - -/*! \class StiffenedGasDellacherie Fluide.hxx "Fluide.hxx" - * \brief Class implementing a particular stiffened gas law including saturation properties - * \details - */ -class StiffenedGasDellacherie:public Fluide{ - private: - double _h_ref;//Stiffened gas law according to S. Dellacherie : P=(gamma - 1) * rho (e(T)-q) - _gamma*_p0 - public: - StiffenedGasDellacherie():Fluide(){_h_ref=0;}; - /* Loi des gaz raidis avec coefficients imposés suivant S. Dellacherie*/ - StiffenedGasDellacherie( double gamma, double p0, double q, double cv); - - double getInternalEnergy(double T, double rho); - double getEnthalpy(double T, double rho=0); - double getTemperatureFromPressure(double p, double rho); - double getTemperatureFromEnthalpy(const double h, const double rho=0); - double getDensity(double p, double T); - - }; -#endif diff --git a/CoreFlows/Models/inc/SinglePhase.hxx b/CoreFlows/Models/inc/SinglePhase.hxx index a8ccd91..f012b59 100755 --- a/CoreFlows/Models/inc/SinglePhase.hxx +++ b/CoreFlows/Models/inc/SinglePhase.hxx @@ -16,6 +16,7 @@ #define SINGLEPHASE_HXX_ #include "ProblemFluid.hxx" +#include "StiffenedGas.hxx" class SinglePhase : public ProblemFluid{ public : @@ -140,6 +141,8 @@ public : * */ bool iterateTimeStep(bool &ok); + //EOS functions + StiffenedGas getFluidEOS(){ return *dynamic_cast(_fluides[0]); } double getReferencePressure() { return _Pref; }; double getReferenceTemperature() { return _Tref; }; diff --git a/CoreFlows/Models/src/CMakeLists.txt b/CoreFlows/Models/src/CMakeLists.txt index ce2f420..5e55783 100755 --- a/CoreFlows/Models/src/CMakeLists.txt +++ b/CoreFlows/Models/src/CMakeLists.txt @@ -15,9 +15,10 @@ SET(src_models_CXX DiffusionEquation.cxx StationaryDiffusionEquation.cxx # LinearElasticityModel.cxx - Fluide.cxx ProblemFluid.cxx utilitaire_algebre.cxx + EOS/StiffenedGas.cxx +# EOS/IAPWS97.cxx ) ADD_LIBRARY(CoreFlowsLibs SHARED ${src_models_CXX}) diff --git a/CoreFlows/Models/src/DriftModel.cxx b/CoreFlows/Models/src/DriftModel.cxx index baa394d..0181fe1 100755 --- a/CoreFlows/Models/src/DriftModel.cxx +++ b/CoreFlows/Models/src/DriftModel.cxx @@ -5,6 +5,7 @@ * Author: Michael Ndjinga */ #include "DriftModel.hxx" +#include "StiffenedGas.hxx" using namespace std; diff --git a/CoreFlows/Models/src/EOS/StiffenedGas.cxx b/CoreFlows/Models/src/EOS/StiffenedGas.cxx new file mode 100755 index 0000000..6164691 --- /dev/null +++ b/CoreFlows/Models/src/EOS/StiffenedGas.cxx @@ -0,0 +1,144 @@ +#include "StiffenedGas.hxx" +#include + +//Perfect gas EOS Loi d'etat gaz parfait +StiffenedGas::StiffenedGas( double gamma, double cv, double T_ref, double e_ref): Fluide() +{ + if(gamma -1<=0) + throw CdmathException("StiffenedGas::StiffenedGas: gamma<1"); + _gamma=gamma; + _Cv=cv; + _Cp=_gamma*_Cv; + _p0=0; + _Tref=T_ref; + _e_ref=e_ref; + _q=0; + cout<<"Perfect gas EOS P=(gamma - 1) * rho e with parameter"<< " gamma= " << _gamma< +#include "StiffenedGas.hxx" using namespace std; diff --git a/CoreFlows/Models/src/Fluide.cxx b/CoreFlows/Models/src/Fluide.cxx deleted file mode 100755 index b6b4f6f..0000000 --- a/CoreFlows/Models/src/Fluide.cxx +++ /dev/null @@ -1,144 +0,0 @@ -#include "Fluide.h" -#include - -//Perfect gas EOS Loi d'etat gaz parfait -StiffenedGas::StiffenedGas( double gamma, double cv, double T_ref, double e_ref): Fluide() -{ - if(gamma -1<=0) - throw CdmathException("StiffenedGas::StiffenedGas: gamma<1"); - _gamma=gamma; - _Cv=cv; - _Cp=_gamma*_Cv; - _p0=0; - _Tref=T_ref; - _e_ref=e_ref; - _q=0; - cout<<"Perfect gas EOS P=(gamma - 1) * rho e with parameter"<< " gamma= " << _gamma< -#include -#include -#include - -class fluid -{ -public : - fluid() { fluide = 0; }; - void set_fluid(Nom &nom) - { - Noms liste(2); liste(0) = "Na"; liste(1) = "LBe"; - fluide = liste.rang(nom); - if (fluide == -1) - { - if (!Process::me()) Cerr << "fluide " << nom << " non reconnu parmi : " << liste << finl; - Process::exit(); - } - } - - //proprietes physiques - /* Lois physiques du sodium issues de fits sur DEN/DANS/DM2S/STMF/LMES/RT/12-018/A */ - int fluide; - #define Tk ((T) + 273.15) - #define Ksil (fluide ? 3.022e-11 : 1e-9) - - /* inverse de la densite du liquide (hors pression) */ - inline double IRhoL(double T) - { - return fluide ? (9.03e-5 + Tk * (1.003e-8 + Tk * 2.01e-12)) - : (9.829728e-4 + Tk * (2.641186e-7 + Tk * (-3.340743e-11 + Tk * 6.680973e-14))); - } - - /* sa derivee */ - inline double DTIRhoL(double T) - { - return fluide ? (1.003e-8 + 2.01e-12 * 2) - : (2.641186e-7 + Tk * (-3.340743e-11 * 2 + Tk * 6.680973e-14 * 3)); - } - - /* densite du liquide */ - inline double RhoL(double T, double P) - { - return exp(Ksil * (P - 1e5)) / IRhoL(T); - } - - /* enthalpie du liquide */ - inline double HL(double T, double P) - { - return (fluide ? 97.98e3 + Tk * (159 + Tk * (-2.72e-2 / 2 + Tk * 7.12e-6 / 3)) - : 2992600 / Tk - 365487.2 + Tk * (1658.2 + Tk * (-.42395 + Tk * 1.4847e-4))) - + (IRhoL(T) - Tk * DTIRhoL(T)) * (1 - exp(Ksil*(1e5 - P))) / Ksil; - } - - /* derivees */ - inline double DTHL(double T, double P) - { - return (fluide ? 159 + Tk * (-2.72e-2 + Tk * 7.12e-6) - : -2992600 / (Tk*Tk) + 1658.2 + Tk * (-.42395 * 2 + Tk * 1.4847e-4 * 3)) - - Tk * (fluide ? 0 : -3.340743e-11 * 2 + Tk * 6.680973e-14 * 6) * (1 - exp(Ksil*(1e5 - P))) / Ksil; - } - - /* inverses par methode de Newton */ - inline double TLh(double h, double T0, double P) - { - double T = T0, sec; int i; - for (i = 0; i < 100 && dabs( sec = HL(T, P) - h ) > 1e-8; i++) - T -= sec / DTHL(T, P); - return i < 100 ? T : -1e10; - } - /* derivees */ - inline double DTRhoL(double T, double P) - { - return - exp(Ksil * (P - 1e5)) * DTIRhoL(T) / (IRhoL(T) * IRhoL(T)); - } - inline double DPRhoL(double T, double P) - { - return Ksil * RhoL(T, P); - } - - /* derivees */ - inline double DPHL(double T, double P) - { - return (IRhoL(T) - Tk * DTIRhoL(T)) * exp(Ksil * (1e5 - P)); - } - - /* energie volumique du liquide */ - inline double EL(double T, double P) - { - return HL(T, P) * RhoL(T, P); - } - /* derivees */ - inline double DTEL(double T, double P) - { - return DTHL(T, P) * RhoL(T, P) + HL(T, P) * DTRhoL(T, P); - } - inline double DPEL(double T, double P) - { - return DPHL(T, P) * RhoL(T, P) + HL(T, P) * DPRhoL(T, P); - } - - inline double TLe(double e, double T0, double P) - { - double T = T0, sec; int i; - for (i = 0; i < 100 && dabs( sec = EL(T, P) - e ) > 1e-3; i++) - T -= sec / DTEL(T, P); - return i < 100 ? T : -1e10; - } - - /* viscosite du liquide*/ - inline double MuL( double T ) - { - return fluide ? 4.94e-4 * exp(754.1 / Tk) - : exp( -6.4406 - 0.3958 * log(Tk) + 556.835 / Tk ); - } - /* conductivite du liquide */ - inline double LambdaL( double T ) - { - return fluide ? 3.61 + Tk * (1.517e-2 - Tk * 1.741e-6) - : max(124.67 + Tk * (-.11381 + Tk * (5.5226e-5 - Tk * 1.1848e-8)), 0.045); - } - /* tension superficielle */ - inline double SigmaL(double T) - { - return 0.2405 * pow(1 - Tk / 2503.7, 1.126); - } - /* Nusselt du liquide -> Skupinski */ - inline double NuL(double T, double P, double w, double Dh) - { - double Pe = RhoL(T, P) * dabs(w) * Dh * DTHL(T, P) / LambdaL(T); - return 4.82 + 0.0185 * pow(Pe, 0.827); - } - /* temperature de saturation */ - inline double Tsat( double P ) - { - double A = 7.8130, B = 11209, C = 5.249e5; - return 2 * C / ( -B + sqrt(B*B + 4 * A * C - 4 * C * log(P / 1e6))) - 273.15; - } - /* sa derivee */ - inline double DTsat( double P ) - { - double A = 7.8130, B = 11209, C = 5.249e5, Tsk = Tsat(P) + 273.15; - return Tsk * Tsk / ( P * sqrt(B*B + 4 * A * C - 4 * C * log(P / 1e6))); - } - /* pression de vapeur saturante */ - inline double Psat( double T ) - { - double A = 7.8130, B = 11209, C = 5.249e5; - return 1e6 * exp(A - B / Tk - C / (Tk * Tk)); - } - /* sa derivee */ - inline double DPsat( double T ) - { - double B = 11209, C = 5.249e5; - return (B / (Tk * Tk) + 2 * C / (Tk * Tk * Tk)) * Psat(T); - } - /* enthalpie massique de saturation */ - inline double Hsat( double P ) - { - return HL(Tsat(P), P); - } - /* sa derivee */ - inline double DHsat( double P ) - { - return DTsat(P) * DTHL(Tsat(P), P) + DPHL(Tsat(P), P); - } - /* chaleur latente, a prendre a Tsat */ - inline double Lvap( double P ) - { - double Tc = 2503.7, Tsk = Tsat(P) + 273.15; - return 3.9337e5 * ( 1 - Tsk / Tc) + 4.3986e6 * pow( 1 - Tsk / Tc, .29302); - } - - /* sa derivee */ - inline double DLvap( double P ) - { - double Tc = 2503.7, Tsk = Tsat(P) + 273.15; - return DTsat(P) * (-3.9337e5 / Tc - 4.3986e6 * .29302 * pow( 1 - Tsk / Tc, .29302 - 1) / Tc); - } - - /* densite de la vapeur : (gaz parfait) * f1(Tsat) * f2(DTsat)*/ - #define f1(Ts) (2.49121 + Ts * (-5.53796e-3 + Ts * (7.5465e-6 + Ts * (-4.20217e-9 + Ts * 8.59212e-13)))) - #define Df1(Ts) (-5.53796e-3 + Ts * (2 * 7.5465e-6 + Ts * (-3 * 4.20217e-9 + Ts * 4 * 8.59212e-13))) - #define f2(dT) (1 + dT * (-5e-4 + dT * (6.25e-7 - dT * 4.1359e-25))) - #define Df2(dT) (-5e-4 + dT * (2 * 6.25e-7 - dT * 3 * 4.1359e-25)) - inline double RhoV( double T, double P ) - { - double Tsk = Tsat(P) + 273.15, dT = Tk - Tsk; - return P * 2.7650313e-3 * f1(Tsk) * f2(dT) / Tk; - } - /* ses derivees */ - inline double DTRhoV( double T, double P ) - { - double Tsk = Tsat(P) + 273.15, dT = Tk - Tsk; - return P * 2.7650313e-3 * f1(Tsk) * (Df2(dT) - f2(dT) / Tk) / Tk; - } - inline double DPRhoV( double T, double P ) - { - double Tsk = Tsat(P) + 273.15, dT = Tk - Tsk; - return 2.7650313e-3 * (f1(Tsk) * f2(dT) + P * DTsat(P) * (Df1(Tsk) * f2(dT) - f1(Tsk) * Df2(dT))) / Tk; - } - #undef f1 - #undef Df1 - #undef f2 - #undef Df2 - /* inverse de la densite de la vapeur */ - inline double IRhoV( double T, double P ) - { - return 1 / RhoV(T, P); - } - /* ses derivees */ - inline double DTIRhoV( double T, double P ) - { - return -DTRhoV(T, P) / (RhoV(T, P) * RhoV(T, P)); - } - inline double DPIRhoV( double T, double P ) - { - return -DPRhoV(T, P) / (RhoV(T, P) * RhoV(T, P)); - } - /* enthalpie de la vapeur */ - #define CpVs(Ts) (-1223.89 + Ts * (14.1191 + Ts * (-1.62025e-2 + Ts * 5.76923e-6))) - #define DCpVs(Ts) (14.1191 + Ts * (- 2 * 1.62025e-2 + Ts * 3 * 5.76923e-6)) - inline double HV( double T, double P) - { - double Ts = Tsat(P), dT = T - Ts, Cp0 = 910, k = -4.6e-3; - return HL(Ts, P) + Lvap(P) + Cp0 * dT + (Cp0 - CpVs(Ts)) * (1 - exp(k * dT)) / k; - } - /* ses derivees */ - inline double DTHV( double T, double P) - { - double Ts = Tsat(P), dT = T - Ts, Cp0 = 910, k = -4.6e-3; - return Cp0 - (Cp0 - CpVs(Ts)) * exp(k * dT); - } - inline double DPHV( double T, double P) - { - double Ts = Tsat(P), dT = T - Ts, Cp0 = 910, k = -4.6e-3; - return DPHL(Ts, P) + DLvap(P) + DTsat(P) * (DTHL(Ts, P) - Cp0 - DCpVs(Ts) * (1 - exp(k * dT)) / k + (Cp0 - CpVs(Ts)) * exp(k * dT)); - } - #undef CpVs - #undef DCpVs - /* energie volumique de la vapeur */ - inline double EV( double T, double P) - { - return RhoV(T, P) * HV(T, P); - } - /* ses derivees */ - inline double DTEV(double T, double P) - { - return DTRhoV(T, P) * HV(T, P) + RhoV(T, P) * DTHV(T, P); - } - inline double DPEV(double T, double P) - { - return DPRhoV(T, P) * HV(T, P) + RhoV(T, P) * DPHV(T, P); - } - - /* conductivite de la vapeur */ - inline double LambdaV( double T ) - { - return 0.045; - } - - /* viscosite de la vapeur */ - inline double MuV( double T ) - { - return 2.5e-6 + 1.5e-8 * Tk; - } - - /* Nusselt de la vapeur -> Dittus/ Boetler */ - inline double NuV(double T, double P, double w, double Dh) - { - double Re = RhoV(T, P) * dabs(w) * Dh / MuV(T), Pr = MuV(T) * DTHV(T, P) / LambdaV(T); - return 0.023 * pow(Re, 0.8) * pow(Pr, 0.4); - } - - inline double Rho( double T, double x, double P ) - { - return 1 / ( (1-x)/RhoL(T, P) + x / RhoV(T, P) ); - } - - #undef Tk - #undef Ksil -}; -#endif diff --git a/CoreFlows/examples/C/testEOS.cxx b/CoreFlows/examples/C/testEOS.cxx index 2ce3f06..56e864d 100755 --- a/CoreFlows/examples/C/testEOS.cxx +++ b/CoreFlows/examples/C/testEOS.cxx @@ -1,4 +1,4 @@ -#include "Fluide.h" +#include "StiffenedGas.hxx" #include #include diff --git a/CoreFlows/swig/CoreFlows.i b/CoreFlows/swig/CoreFlows.i index b8964de..a3f8ddf 100755 --- a/CoreFlows/swig/CoreFlows.i +++ b/CoreFlows/swig/CoreFlows.i @@ -24,6 +24,7 @@ namespace std { #include "StationaryDiffusionEquation.hxx" #include "SinglePhase.hxx" #include "Fluide.h" +#include "StiffenedGas.hxx" %} @@ -37,4 +38,5 @@ namespace std { %include "StationaryDiffusionEquation.hxx" %include "SinglePhase.hxx" %include "Fluide.h" +%include "StiffenedGas.hxx"