From 70ea2f82d2d25812702071b60bf173ca8700bf10 Mon Sep 17 00:00:00 2001 From: sergio Date: Tue, 8 May 2012 17:37:53 +0100 Subject: [PATCH] ENH: adding pressurePerfectGas equestion of state --- .../mixtures/basicMixture/basicMixtures.C | 25 +++ .../basic/rhoThermo/hRhoThermo/hRhoThermos.C | 28 +++ .../rhoThermo/hsRhoThermo/hsRhoThermos.C | 27 +++ src/thermophysicalModels/specie/Make/files | 1 + .../pressurePerfectGas/pressurePerfectGas.C | 71 ++++++++ .../pressurePerfectGas/pressurePerfectGas.H | 160 +++++++++++++++++ .../pressurePerfectGas/pressurePerfectGasI.H | 163 ++++++++++++++++++ 7 files changed, 475 insertions(+) create mode 100644 src/thermophysicalModels/specie/equationOfState/pressurePerfectGas/pressurePerfectGas.C create mode 100644 src/thermophysicalModels/specie/equationOfState/pressurePerfectGas/pressurePerfectGas.H create mode 100644 src/thermophysicalModels/specie/equationOfState/pressurePerfectGas/pressurePerfectGasI.H diff --git a/src/thermophysicalModels/basic/mixtures/basicMixture/basicMixtures.C b/src/thermophysicalModels/basic/mixtures/basicMixture/basicMixtures.C index d140d3dcf1..7239d8d332 100644 --- a/src/thermophysicalModels/basic/mixtures/basicMixture/basicMixtures.C +++ b/src/thermophysicalModels/basic/mixtures/basicMixture/basicMixtures.C @@ -32,6 +32,7 @@ Description #include "makeBasicMixture.H" #include "perfectGas.H" +#include "pressurePerfectGas.H" #include "incompressible.H" #include "eConstThermo.H" @@ -119,6 +120,30 @@ makeBasicPolyMixture 8 ); +makeBasicMixture +( + pureMixture, + constTransport, + hConstThermo, + pressurePerfectGas +); + +makeBasicMixture +( + pureMixture, + sutherlandTransport, + hConstThermo, + pressurePerfectGas +); + +makeBasicMixture +( + pureMixture, + sutherlandTransport, + janafThermo, + pressurePerfectGas +); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/thermophysicalModels/basic/rhoThermo/hRhoThermo/hRhoThermos.C b/src/thermophysicalModels/basic/rhoThermo/hRhoThermo/hRhoThermos.C index a1d44bb9b8..7da039e267 100644 --- a/src/thermophysicalModels/basic/rhoThermo/hRhoThermo/hRhoThermos.C +++ b/src/thermophysicalModels/basic/rhoThermo/hRhoThermo/hRhoThermos.C @@ -26,6 +26,7 @@ License #include "makeBasicRhoThermo.H" #include "perfectGas.H" +#include "pressurePerfectGas.H" #include "incompressible.H" #include "hConstThermo.H" @@ -99,6 +100,33 @@ makeBasicRhoPolyThermo 8 ); +makeBasicRhoThermo +( + hRhoThermo, + pureMixture, + constTransport, + hConstThermo, + pressurePerfectGas +); + +makeBasicRhoThermo +( + hRhoThermo, + pureMixture, + sutherlandTransport, + hConstThermo, + pressurePerfectGas +); + +makeBasicRhoThermo +( + hRhoThermo, + pureMixture, + sutherlandTransport, + janafThermo, + pressurePerfectGas +); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/thermophysicalModels/basic/rhoThermo/hsRhoThermo/hsRhoThermos.C b/src/thermophysicalModels/basic/rhoThermo/hsRhoThermo/hsRhoThermos.C index 8acf748c42..260eebe8ec 100644 --- a/src/thermophysicalModels/basic/rhoThermo/hsRhoThermo/hsRhoThermos.C +++ b/src/thermophysicalModels/basic/rhoThermo/hsRhoThermo/hsRhoThermos.C @@ -26,6 +26,7 @@ License #include "makeBasicRhoThermo.H" #include "perfectGas.H" +#include "pressurePerfectGas.H" #include "hConstThermo.H" #include "janafThermo.H" @@ -71,6 +72,32 @@ makeBasicRhoThermo perfectGas ); +makeBasicRhoThermo +( + hsRhoThermo, + pureMixture, + constTransport, + hConstThermo, + pressurePerfectGas +); + +makeBasicRhoThermo +( + hsRhoThermo, + pureMixture, + sutherlandTransport, + hConstThermo, + pressurePerfectGas +); + +makeBasicRhoThermo +( + hsRhoThermo, + pureMixture, + sutherlandTransport, + janafThermo, + pressurePerfectGas +); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/thermophysicalModels/specie/Make/files b/src/thermophysicalModels/specie/Make/files index 2be4ebfff1..29d3c029ef 100644 --- a/src/thermophysicalModels/specie/Make/files +++ b/src/thermophysicalModels/specie/Make/files @@ -7,6 +7,7 @@ $(atomicWeights)/atomicWeights.C $(specie)/specie.C $(equationOfState)/perfectGas/perfectGas.C $(equationOfState)/incompressible/incompressible.C +$(equationOfState)/pressurePerfectGas/pressurePerfectGas.C $(reactions)/makeChemkinReactions.C $(reactions)/makeReactionThermoReactions.C $(reactions)/makeLangmuirHinshelwoodReactions.C diff --git a/src/thermophysicalModels/specie/equationOfState/pressurePerfectGas/pressurePerfectGas.C b/src/thermophysicalModels/specie/equationOfState/pressurePerfectGas/pressurePerfectGas.C new file mode 100644 index 0000000000..4a58751472 --- /dev/null +++ b/src/thermophysicalModels/specie/equationOfState/pressurePerfectGas/pressurePerfectGas.C @@ -0,0 +1,71 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM 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 General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "pressurePerfectGas.H" +#include "IOstreams.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::pressurePerfectGas::pressurePerfectGas(Istream& is) +: + specie(is), + pRef_(readScalar(is)) +{ + is.check("pressurePerfectGas::pressurePerfectGas(Istream& is)"); +} + + +Foam::pressurePerfectGas::pressurePerfectGas(const dictionary& dict) +: + specie(dict), + pRef_(readScalar(dict.subDict("equationOfState").lookup("pRef"))) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::pressurePerfectGas::write(Ostream& os) const +{ + specie::write(os); + dictionary dict("equationOfState"); + dict.add("pRef", pRef_); + + os << indent << dict.dictName() << dict; +} + + +// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // + +Foam::Ostream& Foam::operator<<(Ostream& os, const pressurePerfectGas& pg) +{ + os << static_cast(pg) + << token::SPACE << pg.pRef_; + + os.check("Ostream& operator<<(Ostream& os, const pressurePerfectGas& st)"); + return os; +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/specie/equationOfState/pressurePerfectGas/pressurePerfectGas.H b/src/thermophysicalModels/specie/equationOfState/pressurePerfectGas/pressurePerfectGas.H new file mode 100644 index 0000000000..40f4938568 --- /dev/null +++ b/src/thermophysicalModels/specie/equationOfState/pressurePerfectGas/pressurePerfectGas.H @@ -0,0 +1,160 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM 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 General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::pressurePerfectGas + +Description + Perfect gas equation of state usign a reference pressure + +SourceFiles + pressurePerfectGasI.H + pressurePerfectGas.C + +\*---------------------------------------------------------------------------*/ + +#ifndef pressurePerfectGas_H +#define pressurePerfectGas_H + +#include "specie.H" +#include "autoPtr.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class pressurePerfectGas Declaration +\*---------------------------------------------------------------------------*/ + +class pressurePerfectGas +: + public specie +{ + // Private data + + //- Reference pressure + scalar pRef_; + + +public: + + // Constructors + + //- Construct from components + inline pressurePerfectGas(const specie& sp); + + //- Construct from Istream + pressurePerfectGas(Istream&); + + //- Construct from dictionary + pressurePerfectGas(const dictionary& dict); + + //- Construct as named copy + inline pressurePerfectGas(const word& name, const pressurePerfectGas&); + + //- Construct and return a clone + inline autoPtr clone() const; + + // Selector from Istream + inline static autoPtr New(Istream& is); + + // Selector from dictionary + inline static autoPtr New(const dictionary& dict); + + + // Member functions + + // Fundamental properties + + //- Return density [kg/m^3] + inline scalar rho(scalar p, scalar T) const; + + //- Return compressibility rho/p [s^2/m^2] + inline scalar psi(scalar p, scalar T) const; + + //- Return compression factor [] + inline scalar Z(scalar p, scalar T) const; + + + // I-O + + //- Write to Ostream + void write(Ostream& os) const; + + + // Member operators + + inline void operator+=(const pressurePerfectGas&); + inline void operator-=(const pressurePerfectGas&); + + inline void operator*=(const scalar); + + + // Friend operators + + inline friend pressurePerfectGas operator+ + ( + const pressurePerfectGas&, + const pressurePerfectGas& + ); + + inline friend pressurePerfectGas operator- + ( + const pressurePerfectGas&, + const pressurePerfectGas& + ); + + inline friend pressurePerfectGas operator* + ( + const scalar s, + const pressurePerfectGas& + ); + + inline friend pressurePerfectGas operator== + ( + const pressurePerfectGas&, + const pressurePerfectGas& + ); + + + // Ostream Operator + + friend Ostream& operator<<(Ostream&, const pressurePerfectGas&); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "pressurePerfectGasI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/thermophysicalModels/specie/equationOfState/pressurePerfectGas/pressurePerfectGasI.H b/src/thermophysicalModels/specie/equationOfState/pressurePerfectGas/pressurePerfectGasI.H new file mode 100644 index 0000000000..99512ecaee --- /dev/null +++ b/src/thermophysicalModels/specie/equationOfState/pressurePerfectGas/pressurePerfectGasI.H @@ -0,0 +1,163 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM 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 General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "pressurePerfectGas.H" + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +inline Foam::pressurePerfectGas::pressurePerfectGas(const specie& sp) +: + specie(sp) +{} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +inline Foam::pressurePerfectGas::pressurePerfectGas +( + const word& name, + const pressurePerfectGas& pg +) +: + specie(name, pg) +{} + + +inline Foam::autoPtr Foam::pressurePerfectGas:: +clone() const +{ + return autoPtr(new pressurePerfectGas(*this)); +} + + +inline Foam::autoPtr Foam::pressurePerfectGas::New +( + Istream& is +) +{ + return autoPtr(new pressurePerfectGas(is)); +} + + +inline Foam::autoPtr Foam::pressurePerfectGas::New +( + const dictionary& dict +) +{ + return autoPtr(new pressurePerfectGas(dict)); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +inline Foam::scalar Foam::pressurePerfectGas::rho(scalar p, scalar T) const +{ + return pRef_/(R()*T); +} + + +inline Foam::scalar Foam::pressurePerfectGas::psi(scalar, scalar T) const +{ + return 0.0; +} + + +inline Foam::scalar Foam::pressurePerfectGas::Z(scalar, scalar) const +{ + return 0.0; +} + + +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + +inline void Foam::pressurePerfectGas::operator+=(const pressurePerfectGas& pg) +{ + specie::operator+=(pg); +} + + +inline void Foam::pressurePerfectGas::operator-=(const pressurePerfectGas& pg) +{ + specie::operator-=(pg); +} + + +inline void Foam::pressurePerfectGas::operator*=(const scalar s) +{ + specie::operator*=(s); +} + + +// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // + +inline Foam::pressurePerfectGas Foam::operator+ +( + const pressurePerfectGas& pg1, + const pressurePerfectGas& pg2 +) +{ + return pressurePerfectGas + ( + static_cast(pg1) + + static_cast(pg2) + ); +} + + +inline Foam::pressurePerfectGas Foam::operator- +( + const pressurePerfectGas& pg1, + const pressurePerfectGas& pg2 +) +{ + return pressurePerfectGas + ( + static_cast(pg1) + - static_cast(pg2) + ); +} + + +inline Foam::pressurePerfectGas Foam::operator* +( + const scalar s, + const pressurePerfectGas& pg +) +{ + return pressurePerfectGas(s*static_cast(pg)); +} + + +inline Foam::pressurePerfectGas Foam::operator== +( + const pressurePerfectGas& pg1, + const pressurePerfectGas& pg2 +) +{ + return pg2 - pg1; +} + + +// ************************************************************************* //