From 792efbfc9252fd6ae015f94a68dc830be7bfe313 Mon Sep 17 00:00:00 2001 From: Henry <Henry> Date: Wed, 6 Feb 2013 10:53:37 +0000 Subject: [PATCH] perfectFluid: Added R as an independent parameter --- .../perfectFluid/perfectFluid.C | 4 ++++ .../perfectFluid/perfectFluid.H | 14 ++++++++++- .../perfectFluid/perfectFluidI.H | 23 +++++++++++++++++-- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/thermophysicalModels/specie/equationOfState/perfectFluid/perfectFluid.C b/src/thermophysicalModels/specie/equationOfState/perfectFluid/perfectFluid.C index 844f293e2dd..cc6eb7c5921 100644 --- a/src/thermophysicalModels/specie/equationOfState/perfectFluid/perfectFluid.C +++ b/src/thermophysicalModels/specie/equationOfState/perfectFluid/perfectFluid.C @@ -32,6 +32,7 @@ template<class Specie> Foam::perfectFluid<Specie>::perfectFluid(Istream& is) : Specie(is), + R_(readScalar(is)), rho0_(readScalar(is)) { is.check("perfectFluid<Specie>::perfectFluid(Istream& is)"); @@ -42,6 +43,7 @@ template<class Specie> Foam::perfectFluid<Specie>::perfectFluid(const dictionary& dict) : Specie(dict), + R_(readScalar(dict.subDict("equationOfState").lookup("R"))), rho0_(readScalar(dict.subDict("equationOfState").lookup("rho0"))) {} @@ -54,6 +56,7 @@ void Foam::perfectFluid<Specie>::write(Ostream& os) const Specie::write(os); dictionary dict("equationOfState"); + dict.add("R", R_); dict.add("rho0", rho0_); os << indent << dict.dictName() << dict; @@ -66,6 +69,7 @@ template<class Specie> Foam::Ostream& Foam::operator<<(Ostream& os, const perfectFluid<Specie>& pf) { os << static_cast<const Specie&>(pf) + << token::SPACE << pf.R_ << token::SPACE << pf.rho0_; os.check("Ostream& operator<<(Ostream&, const perfectFluid<Specie>&)"); diff --git a/src/thermophysicalModels/specie/equationOfState/perfectFluid/perfectFluid.H b/src/thermophysicalModels/specie/equationOfState/perfectFluid/perfectFluid.H index 76cf80c4a8f..5494d9cbaf1 100644 --- a/src/thermophysicalModels/specie/equationOfState/perfectFluid/perfectFluid.H +++ b/src/thermophysicalModels/specie/equationOfState/perfectFluid/perfectFluid.H @@ -94,15 +94,24 @@ class perfectFluid { // Private data + //- Fluid constant + scalar R_; + //- The reference density scalar rho0_; + public: // Constructors //- Construct from components - inline perfectFluid(const Specie& sp, const scalar rho0); + inline perfectFluid + ( + const Specie& sp, + const scalar R, + const scalar rho0 + ); //- Construct from Istream perfectFluid(Istream&); @@ -140,6 +149,9 @@ public: //- Is the equation of state is isochoric i.e. rho = const static const bool isochoric = false; + //- Return fluid constant [J/(kg K)] + inline scalar R() const; + //- Return density [kg/m^3] inline scalar rho(scalar p, scalar T) const; diff --git a/src/thermophysicalModels/specie/equationOfState/perfectFluid/perfectFluidI.H b/src/thermophysicalModels/specie/equationOfState/perfectFluid/perfectFluidI.H index 21fc092fe2a..4cb0d91cfe9 100644 --- a/src/thermophysicalModels/specie/equationOfState/perfectFluid/perfectFluidI.H +++ b/src/thermophysicalModels/specie/equationOfState/perfectFluid/perfectFluidI.H @@ -31,10 +31,12 @@ template<class Specie> inline Foam::perfectFluid<Specie>::perfectFluid ( const Specie& sp, + const scalar R, const scalar rho0 ) : Specie(sp), + R_(R), rho0_(rho0) {} @@ -49,6 +51,7 @@ inline Foam::perfectFluid<Specie>::perfectFluid ) : Specie(name, pf), + R_(pf.R_), rho0_(pf.rho0_) {} @@ -82,6 +85,13 @@ Foam::perfectFluid<Specie>::New // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +template<class Specie> +inline Foam::scalar Foam::perfectFluid<Specie>::R() const +{ + return R_; +} + + template<class Specie> inline Foam::scalar Foam::perfectFluid<Specie>::rho(scalar p, scalar T) const { @@ -106,7 +116,7 @@ inline Foam::scalar Foam::perfectFluid<Specie>::Z(scalar, scalar) const template<class Specie> inline Foam::scalar Foam::perfectFluid<Specie>::cpMcv(scalar, scalar) const { - return this->RR; + return 0; } @@ -125,6 +135,7 @@ inline void Foam::perfectFluid<Specie>::operator+= molr1 /= this->nMoles(); scalar molr2 = pf.nMoles()/this->nMoles(); + R_ = 1.0/(molr1/R_ + molr2/pf.R_); rho0_ = molr1*rho0_ + molr2*pf.rho0_; } @@ -142,6 +153,7 @@ inline void Foam::perfectFluid<Specie>::operator-= molr1 /= this->nMoles(); scalar molr2 = pf.nMoles()/this->nMoles(); + R_ = 1.0/(molr1/R_ - molr2/pf.R_); rho0_ = molr1*rho0_ - molr2*pf.rho0_; } @@ -170,6 +182,7 @@ inline Foam::perfectFluid<Specie> Foam::operator+ ( static_cast<const Specie&>(pf1) + static_cast<const Specie&>(pf2), + 1.0/(molr1/pf1.R_ + molr2/pf2.R_), molr1*pf1.rho0_ + molr2*pf2.rho0_ ); } @@ -190,6 +203,7 @@ inline Foam::perfectFluid<Specie> Foam::operator- ( static_cast<const Specie&>(pf1) - static_cast<const Specie&>(pf2), + 1.0/(molr1/pf1.R_ - molr2/pf2.R_), molr1*pf1.rho0_ - molr2*pf2.rho0_ ); } @@ -202,7 +216,12 @@ inline Foam::perfectFluid<Specie> Foam::operator* const perfectFluid<Specie>& pf ) { - return perfectFluid<Specie>(s*static_cast<const Specie&>(pf), pf.rho0_); + return perfectFluid<Specie> + ( + s*static_cast<const Specie&>(pf), + pf.R_, + pf.rho0_ + ); } -- GitLab