From 0dd91a9dc46deb65ebe11988f40f72afebfe7e0d Mon Sep 17 00:00:00 2001 From: sergio Date: Thu, 24 Sep 2020 14:17:24 -0700 Subject: [PATCH] ENH: Adding tabulated transport and thermo. TUT: multiphase/icoReactingMultiPhaseInterFoam/inertMultiphaseMultiComponent --- .../basic/rhoThermo/rhoThermos.C | 42 +++- .../icoTabulated/icoTabulated.H | 10 +- .../thermo/hTabulated/hTabulatedThermo.C | 82 +++++++ .../thermo/hTabulated/hTabulatedThermo.H | 205 ++++++++++++++++++ .../thermo/hTabulated/hTabulatedThermoI.H | 142 ++++++++++++ .../transport/tabulated/tabulatedTransport.C | 80 +++++++ .../transport/tabulated/tabulatedTransport.H | 183 ++++++++++++++++ .../transport/tabulated/tabulatedTransportI.H | 111 ++++++++++ .../thermophysicalProperties/Make/files | 3 +- ...tedNonUniformTableThermophysicalFunction.C | 140 ++++++++++++ ...tedNonUniformTableThermophysicalFunction.H | 124 +++++++++++ .../constant/thermophysicalProperties.mercury | 30 ++- 12 files changed, 1138 insertions(+), 14 deletions(-) create mode 100644 src/thermophysicalModels/specie/thermo/hTabulated/hTabulatedThermo.C create mode 100644 src/thermophysicalModels/specie/thermo/hTabulated/hTabulatedThermo.H create mode 100644 src/thermophysicalModels/specie/thermo/hTabulated/hTabulatedThermoI.H create mode 100644 src/thermophysicalModels/specie/transport/tabulated/tabulatedTransport.C create mode 100644 src/thermophysicalModels/specie/transport/tabulated/tabulatedTransport.H create mode 100644 src/thermophysicalModels/specie/transport/tabulated/tabulatedTransportI.H create mode 100644 src/thermophysicalModels/thermophysicalProperties/thermophysicalFunctions/integratedNonUniformTable/integratedNonUniformTableThermophysicalFunction.C create mode 100644 src/thermophysicalModels/thermophysicalProperties/thermophysicalFunctions/integratedNonUniformTable/integratedNonUniformTableThermophysicalFunction.H diff --git a/src/thermophysicalModels/basic/rhoThermo/rhoThermos.C b/src/thermophysicalModels/basic/rhoThermo/rhoThermos.C index 92116fc82d..1b964ba69c 100644 --- a/src/thermophysicalModels/basic/rhoThermo/rhoThermos.C +++ b/src/thermophysicalModels/basic/rhoThermo/rhoThermos.C @@ -43,6 +43,7 @@ License #include "hConstThermo.H" #include "eConstThermo.H" #include "janafThermo.H" +#include "hTabulatedThermo.H" #include "sensibleEnthalpy.H" #include "sensibleInternalEnergy.H" #include "thermo.H" @@ -54,6 +55,7 @@ License #include "icoPolynomial.H" #include "hPolynomialThermo.H" #include "polynomialTransport.H" +#include "tabulatedTransport.H" #include "heRhoThermo.H" #include "pureMixture.H" @@ -101,6 +103,18 @@ makeThermos specie ); +makeThermos +( + rhoThermo, + heRhoThermo, + pureMixture, + tabulatedTransport, + sensibleEnthalpy, + hTabulatedThermo, + perfectGas, + specie +); + makeThermos ( rhoThermo, @@ -137,6 +151,18 @@ makeThermos specie ); +makeThermos +( + rhoThermo, + heRhoThermo, + pureMixture, + tabulatedTransport, + sensibleEnthalpy, + hTabulatedThermo, + icoTabulated, + specie +); + makeThermos ( rhoThermo, @@ -245,6 +271,18 @@ makeThermos specie ); +makeThermos +( + rhoThermo, + heRhoThermo, + pureMixture, + tabulatedTransport, + sensibleEnthalpy, + janafThermo, + icoTabulated, + specie +); + makeThermos ( rhoThermo, @@ -348,9 +386,9 @@ makeThermos rhoThermo, heRhoThermo, pureMixture, - constTransport, + tabulatedTransport, sensibleInternalEnergy, - hConstThermo, + hTabulatedThermo, icoTabulated, specie ); diff --git a/src/thermophysicalModels/specie/equationOfState/icoTabulated/icoTabulated.H b/src/thermophysicalModels/specie/equationOfState/icoTabulated/icoTabulated.H index fa9c127206..e2e908e927 100644 --- a/src/thermophysicalModels/specie/equationOfState/icoTabulated/icoTabulated.H +++ b/src/thermophysicalModels/specie/equationOfState/icoTabulated/icoTabulated.H @@ -135,19 +135,19 @@ public: //- Return density [kg/m^3] inline scalar rho(scalar p, scalar T) const; - //- Return enthalpy contribution [J/kg] + //- Return enthalpy departure [J/kg] inline scalar H(const scalar p, const scalar T) const; - //- Return Cp contribution [J/(kg K] + //- Return Cp departure [J/(kg K] inline scalar Cp(scalar p, scalar T) const; - //- Return internal energy contribution [J/kg] + //- Return internal energy departure [J/kg] inline scalar E(const scalar p, const scalar T) const; - //- Return Cv contribution [J/(kg K] + //- Return Cv departure [J/(kg K] inline scalar Cv(scalar p, scalar T) const; - //- Return entropy contribution to the integral of Cp/T [J/kg/K] + //- Return entropy departure to the integral of Cp/T [J/kg/K] inline scalar S(const scalar p, const scalar T) const; //- Return compressibility [s^2/m^2] diff --git a/src/thermophysicalModels/specie/thermo/hTabulated/hTabulatedThermo.C b/src/thermophysicalModels/specie/thermo/hTabulated/hTabulatedThermo.C new file mode 100644 index 0000000000..14aa2c9512 --- /dev/null +++ b/src/thermophysicalModels/specie/thermo/hTabulated/hTabulatedThermo.C @@ -0,0 +1,82 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2020 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 "hTabulatedThermo.H" +#include "IOstreams.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::hTabulatedThermo::hTabulatedThermo +( + const dictionary& dict +) +: + EquationOfState(dict), + Hf_(dict.subDict("thermodynamics").get("Hf")), + Sf_(dict.subDict("thermodynamics").get("Sf")), + Cp_("Cp", dict.subDict("thermodynamics")) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +void Foam::hTabulatedThermo::write +( + Ostream& os +) const +{ + EquationOfState::write(os); + + // Entries in dictionary format + { + os.beginBlock("thermodynamics"); + os.writeEntry("Hf", Hf_); + os.writeEntry("Sf", Sf_); + os.writeEntry("Cp", Cp_); + os.endBlock(); + } +} + + +// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // + +template +Foam::Ostream& Foam::operator<< +( + Ostream& os, + const hTabulatedThermo& pt +) +{ + pt.write(os); + return os; +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/specie/thermo/hTabulated/hTabulatedThermo.H b/src/thermophysicalModels/specie/thermo/hTabulated/hTabulatedThermo.H new file mode 100644 index 0000000000..9aa40bd719 --- /dev/null +++ b/src/thermophysicalModels/specie/thermo/hTabulated/hTabulatedThermo.H @@ -0,0 +1,205 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2020 OpenFOAM Foundation +------------------------------------------------------------------------------- +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::hTabulatedThermo + +Description + Enthalpy based thermodynamics package using non-uniform tabulated data for + heat capacity vs temperature. + +Usage + + \table + Property | Description + Hf | Heat of formation + Sf | Standard entropy + Cp | Specific heat at constant pressure vs temperature table + \endtable + + Example of the specification of the thermodynamic properties: + \verbatim + thermodynamics + { + Hf 0; + Sf 0; + Cp + ( + (200 1005) + (350 1010) + (400 1020) + ); + } + \endverbatim + +SourceFiles + hTabulatedThermoI.H + hTabulatedThermo.C + +See also + Foam::thermophysicalFunctions::nonUniformTable + +\*---------------------------------------------------------------------------*/ + +#ifndef hTabulatedThermo_H +#define hTabulatedThermo_H + +#include "integratedNonUniformTableThermophysicalFunction.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward Declarations + +template +class hTabulatedThermo; + +template +Ostream& operator<< +( + Ostream&, + const hTabulatedThermo& +); + + +/*---------------------------------------------------------------------------*\ + Class hTabulatedThermo Declaration +\*---------------------------------------------------------------------------*/ + +template +class hTabulatedThermo +: + public EquationOfState +{ + // Private Typedefs + + typedef thermophysicalFunctions::integratedNonUniformTable + integratedNonUniformTable; + + + // Private Data + + //- Heat of formation + scalar Hf_; + + //- Standard entropy + scalar Sf_; + + //- Specific heat at constant pressure table [J/kg/K] + integratedNonUniformTable Cp_; + + //- Enthalphy uniform table; + //nonUniformTable hCoeffs_; + + +public: + + // Constructors + + //- Construct from dictionary + explicit hTabulatedThermo(const dictionary& dict); + + //- Construct as a named copy + inline hTabulatedThermo(const word&, const hTabulatedThermo&); + + + // Member Functions + + //- The instantiated type name + static word typeName() + { + return "hTabulated<" + EquationOfState::typeName() + '>'; + } + + //- Limit the temperature to be in the temperature range + // Currently no limit applied + inline scalar limit(const scalar T) const; + + + // Fundamental Properties + + //- Heat capacity at constant pressure [J/kg/K] + inline scalar Cp(const scalar p, const scalar T) const; + + //- Absolute enthalpy [J/kg] + inline scalar Ha(const scalar p, const scalar T) const; + + //- Sensible enthalpy [J/kg] + inline scalar Hs(const scalar p, const scalar T) const; + + //- Chemical enthalpy [J/kg] + inline scalar Hc() const; + + //- Entropy [J/kg/K] + inline scalar S(const scalar p, const scalar T) const; + + + #include "HtoEthermo.H" + + + // Derivative term used for Jacobian + + //- Derivative of Gibbs free energy w.r.t. temperature + inline scalar dGdT(const scalar p, const scalar T) const; + + //- Temperature derivative of heat capacity at constant pressure + inline scalar dCpdT(const scalar p, const scalar T) const; + + + // I-O + + //- Write to Ostream + void write(Ostream& os) const; + + + // Ostream Operator + + friend Ostream& operator<< + ( + Ostream&, + const hTabulatedThermo& + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "hTabulatedThermoI.H" + +#ifdef NoRepository + #include "hTabulatedThermo.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/thermophysicalModels/specie/thermo/hTabulated/hTabulatedThermoI.H b/src/thermophysicalModels/specie/thermo/hTabulated/hTabulatedThermoI.H new file mode 100644 index 0000000000..4975a3e71e --- /dev/null +++ b/src/thermophysicalModels/specie/thermo/hTabulated/hTabulatedThermoI.H @@ -0,0 +1,142 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2020 OpenFOAM Foundation +------------------------------------------------------------------------------- +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 "hTabulatedThermo.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +inline Foam::hTabulatedThermo::hTabulatedThermo +( + const word& name, + const hTabulatedThermo& pt +) +: + EquationOfState(name, pt), + Hf_(pt.Hf_), + Sf_(pt.Sf_), + Cp_(pt.Cp_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +inline Foam::scalar Foam::hTabulatedThermo::limit +( + const scalar T +) const +{ + return T; +} + + +template +inline Foam::scalar Foam::hTabulatedThermo::Cp +( + const scalar p, + const scalar T +) const +{ + return Cp_.f(p, T) + EquationOfState::Cp(p, T); +} + + +template +inline Foam::scalar Foam::hTabulatedThermo::Ha +( + const scalar p, + const scalar T +) const +{ + return Hs(p, T) + Hf_; +} + + +template +inline Foam::scalar Foam::hTabulatedThermo::Hs +( + const scalar p, + const scalar T +) const +{ + return Cp_.intfdT(p, T) + EquationOfState::H(p, T); +} + + +template +inline Foam::scalar Foam::hTabulatedThermo::Hc() +const +{ + return Hf_; +} + + +template +inline Foam::scalar Foam::hTabulatedThermo::S +( + const scalar p, + const scalar T +) const +{ + return Cp_.intfByTdT(p, T) + EquationOfState::Sp(p, T) + Sf_; +} + + +template +inline Foam::scalar Foam::hTabulatedThermo::dGdT +( + const scalar p, + const scalar T +) const +{ + return 0; +} + + +// template +// inline Foam::scalar Foam::hTabulatedThermo::Gstd +// ( +// const scalar T +// ) const +// { +// return Cp_.intfdT(Pstd, T) + Hf_ - (Cp_.intfByTdT(Pstd, T) + Sf_)*T; +// } + + +template +inline Foam::scalar Foam::hTabulatedThermo::dCpdT +( + const scalar p, + const scalar T +) const +{ + return Cp_.dfdT(p, T); +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/specie/transport/tabulated/tabulatedTransport.C b/src/thermophysicalModels/specie/transport/tabulated/tabulatedTransport.C new file mode 100644 index 0000000000..cca2c4b1fc --- /dev/null +++ b/src/thermophysicalModels/specie/transport/tabulated/tabulatedTransport.C @@ -0,0 +1,80 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2020 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 "tabulatedTransport.H" +#include "IOstreams.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::tabulatedTransport::tabulatedTransport +( + const dictionary& dict +) +: + Thermo(dict), + mu_("mu", dict.subDict("transport")), + kappa_("kappa", dict.subDict("transport")) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +void Foam::tabulatedTransport::write(Ostream& os) const +{ + os.beginBlock(this->name()); + + Thermo::write(os); + + { + os.beginBlock("transport"); + os.writeEntry("mu", mu_.values()); + os.writeEntry("kappa", kappa_.values()); + os.endBlock(); + } + + os.endBlock(); +} + + +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // + +template +Foam::Ostream& Foam::operator<< +( + Ostream& os, + const tabulatedTransport& pt +) +{ + pt.write(os); + return os; +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/specie/transport/tabulated/tabulatedTransport.H b/src/thermophysicalModels/specie/transport/tabulated/tabulatedTransport.H new file mode 100644 index 0000000000..07dc6ee0c7 --- /dev/null +++ b/src/thermophysicalModels/specie/transport/tabulated/tabulatedTransport.H @@ -0,0 +1,183 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2020 OpenFOAM Foundation +------------------------------------------------------------------------------- +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::tabulatedTransport + +Description + Transport properties package using non-uniform tabulated data for + viscosity and thermal conductivity vs temperature. + +Usage + + \table + Property | Description + mu | Dynamic viscosity vs temperature table + kappa | Thermal conductivity vs temperature table + \endtable + + Example of the specification of the transport properties: + \verbatim + transport + { + mu + ( + (200 1.82e-05) + (350 2.61e-05) + (400 3.93e-05) + ); + + kappa + ( + (200 2.56e-5) + (350 3.33e-5) + (400 4.72e-5) + ); + } + \endverbatim + +SourceFiles + tabulatedTransportI.H + tabulatedTransport.C + +See also + Foam::thermophysicalFunctions::nonUniformTable + +\*---------------------------------------------------------------------------*/ + +#ifndef tabulatedTransport_H +#define tabulatedTransport_H + +#include "nonUniformTableThermophysicalFunction.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward Declarations +template class tabulatedTransport; + +template +Ostream& operator<<(Ostream&, const tabulatedTransport&); + + +/*---------------------------------------------------------------------------*\ + Class tabulatedTransport Declaration +\*---------------------------------------------------------------------------*/ + +template +class tabulatedTransport +: + public Thermo +{ + // Private Data + + //- Dynamic viscosity table [Pa.s] + nonUniformTable mu_; + + //- Thermal conductivity table [W/m/K] + nonUniformTable kappa_; + + + // Private Member Functions + + //- Construct from components + inline tabulatedTransport + ( + const Thermo& t, + const nonUniformTable& muPoly, + const nonUniformTable& kappaPoly + ); + + +public: + + // Constructors + + //- Construct as named copy + inline tabulatedTransport(const word&, const tabulatedTransport&); + + //- Construct from dictionary + explicit tabulatedTransport(const dictionary& dict); + + //- Return a clone + inline autoPtr clone() const; + + // Selector from dictionary + inline static autoPtr New(const dictionary& dict); + + + // Member Functions + + //- The instantiated type name + static word typeName() + { + return "tabulated<" + Thermo::typeName() + '>'; + } + + //- Dynamic viscosity [kg/m/s] + inline scalar mu(const scalar p, const scalar T) const; + + //- Thermal conductivity [W/m/K] + inline scalar kappa(const scalar p, const scalar T) const; + + //- Thermal diffusivity of enthalpy [kg/m/s] + inline scalar alphah(const scalar p, const scalar T) const; + + // Species diffusivity + // inline scalar D(const scalar p, const scalar T) const; + + //- Write to Ostream + void write(Ostream& os) const; + + + // Ostream Operator + + friend Ostream& operator<< + ( + Ostream&, + const tabulatedTransport& + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "tabulatedTransportI.H" + +#ifdef NoRepository + #include "tabulatedTransport.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/thermophysicalModels/specie/transport/tabulated/tabulatedTransportI.H b/src/thermophysicalModels/specie/transport/tabulated/tabulatedTransportI.H new file mode 100644 index 0000000000..87dcdeeb33 --- /dev/null +++ b/src/thermophysicalModels/specie/transport/tabulated/tabulatedTransportI.H @@ -0,0 +1,111 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2020 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 "specie.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +inline Foam::tabulatedTransport::tabulatedTransport +( + const Thermo& t, + const nonUniformTable& mu, + const nonUniformTable& kappa +) +: + Thermo(t), + mu_(mu), + kappa_(kappa) +{} + + +template +inline Foam::tabulatedTransport::tabulatedTransport +( + const word& name, + const tabulatedTransport& pt +) +: + Thermo(name, pt), + mu_(pt.mu_), + kappa_(pt.kappa_) +{} + + +template +inline Foam::autoPtr> +Foam::tabulatedTransport::clone() const +{ + return autoPtr>::New(*this); +} + + +template +inline Foam::autoPtr> +Foam::tabulatedTransport::New(const dictionary& dict) +{ + return autoPtr>::New(dict); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +inline Foam::scalar Foam::tabulatedTransport::mu +( + const scalar p, + const scalar T +) const +{ + return mu_.f(p, T); +} + + +template +inline Foam::scalar Foam::tabulatedTransport::kappa +( + const scalar p, + const scalar T +) const +{ + return kappa_.f(p, T); +} + + +template +inline Foam::scalar Foam::tabulatedTransport::alphah +( + const scalar p, + const scalar T +) const +{ + return kappa(p, T)/this->Cp(p, T); +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/thermophysicalProperties/Make/files b/src/thermophysicalModels/thermophysicalProperties/Make/files index a8f3fce2c9..d428e419d2 100644 --- a/src/thermophysicalModels/thermophysicalProperties/Make/files +++ b/src/thermophysicalModels/thermophysicalProperties/Make/files @@ -11,10 +11,11 @@ $(NSRDSfunctions)/NSRDSfunc6/NSRDSfunc6.C $(NSRDSfunctions)/NSRDSfunc7/NSRDSfunc7.C $(NSRDSfunctions)/NSRDSfunc14/NSRDSfunc14.C -APIfunctions = thermophysicalFunctions/APIfunctions +APIfunctions = thermophysicalFunctions/APIfunctions $(APIfunctions)/APIdiffCoefFunc/APIdiffCoefFunc.C thermophysicalFunctions/nonUniformTable/nonUniformTableThermophysicalFunction.C +thermophysicalFunctions/integratedNonUniformTable/integratedNonUniformTableThermophysicalFunction.C thermophysicalProperties/thermophysicalProperties.C diff --git a/src/thermophysicalModels/thermophysicalProperties/thermophysicalFunctions/integratedNonUniformTable/integratedNonUniformTableThermophysicalFunction.C b/src/thermophysicalModels/thermophysicalProperties/thermophysicalFunctions/integratedNonUniformTable/integratedNonUniformTableThermophysicalFunction.C new file mode 100644 index 0000000000..42706b7a43 --- /dev/null +++ b/src/thermophysicalModels/thermophysicalProperties/thermophysicalFunctions/integratedNonUniformTable/integratedNonUniformTableThermophysicalFunction.C @@ -0,0 +1,140 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2020 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 "integratedNonUniformTableThermophysicalFunction.H" +#include "specie.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace thermophysicalFunctions +{ + defineTypeNameAndDebug(integratedNonUniformTable, 0); + + addToRunTimeSelectionTable + ( + thermophysicalFunction, + integratedNonUniformTable, + dictionary + ); +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::thermophysicalFunctions::integratedNonUniformTable:: +integratedNonUniformTable +( + const word& name, + const dictionary& dict +) +: + nonUniformTable(name, dict), + intf_(values().size()), + intfByT_(values().size()) +{ + intf_[0] = 0; + intfByT_[0] = 0; + + for (label i = 1; i < intf_.size(); ++i) + { + intf_[i] = intf_[i-1] + intfdT(0, values()[i].first()); + intfByT_[i] = intfByT_[i-1] + intfByTdT(0, values()[i].first()); + } + + const scalar intfStd = intfdT(Pstd, Tstd); + const scalar intfByTStd = intfByTdT(Pstd, Tstd); + + forAll(intf_, i) + { + intf_[i] -= intfStd; + intfByT_[i] -= intfByTStd; + } +} + + +Foam::thermophysicalFunctions::integratedNonUniformTable:: +integratedNonUniformTable +( + const dictionary& dict +) +: + integratedNonUniformTable("values", dict) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::scalar Foam::thermophysicalFunctions::integratedNonUniformTable::intfdT +( + scalar p, + scalar T +) const +{ + const label i = index(p, T); + const scalar Ti = values()[i].first(); + const scalar fi = values()[i].second(); + const scalar dT = T - Ti; + const scalar lambda = dT/(values()[i + 1].first() - Ti); + + return + intf_[i] + + (fi + 0.5*lambda*(values()[i + 1].second() - fi))*dT; +} + + +Foam::scalar Foam::thermophysicalFunctions::integratedNonUniformTable::intfByTdT +( + scalar p, + scalar T +) const +{ + const label i = index(p, T); + const scalar Ti = values()[i].first(); + const scalar fi = values()[i].second(); + const scalar gradf = + (values()[i + 1].second() - fi)/(values()[i + 1].first() - Ti); + + return + intfByT_[i] + ((fi - gradf*Ti)*log(T/Ti) + gradf*(T - Ti)); +} + + +void Foam::thermophysicalFunctions::integratedNonUniformTable::writeData +( + Ostream& os +) const +{ + nonUniformTable::writeData(os); +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/thermophysicalProperties/thermophysicalFunctions/integratedNonUniformTable/integratedNonUniformTableThermophysicalFunction.H b/src/thermophysicalModels/thermophysicalProperties/thermophysicalFunctions/integratedNonUniformTable/integratedNonUniformTableThermophysicalFunction.H new file mode 100644 index 0000000000..dc81290c1f --- /dev/null +++ b/src/thermophysicalModels/thermophysicalProperties/thermophysicalFunctions/integratedNonUniformTable/integratedNonUniformTableThermophysicalFunction.H @@ -0,0 +1,124 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2020 OpenFOAM Foundation +------------------------------------------------------------------------------- +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::thermophysicalFunctions::integratedNonUniformTable + +Description + Non-uniform tabulated property function that linearly interpolates between + the values. + + To speed-up the search of the non-uniform table a uniform jump-table is + created on construction which is used for fast indirect addressing into + the table. + +Usage + \integratedNonUniformTable + Property | Description + values | List of (temperature property) value pairs + \endintegratedNonUniformTable + + Example for the density of water between 280 and 350K + \verbatim + rho + { + type integratedNonUniformTable; + + values + ( + (280 999.87) + (300 995.1) + (350 973.7) + ); + } + \endverbatim + +\*---------------------------------------------------------------------------*/ + +#ifndef integratedNonUniformTableThermophysicalFunction_H +#define integratedNonUniformTableThermophysicalFunction_H + +#include "nonUniformTableThermophysicalFunction.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace thermophysicalFunctions +{ + +/*---------------------------------------------------------------------------*\ + Class integratedNonUniformTable Declaration +\*---------------------------------------------------------------------------*/ + +class integratedNonUniformTable +: + public nonUniformTable +{ + // Private Data + + List intf_; + + List intfByT_; + + +public: + + //- Runtime type information + TypeName("integratedNonUniformTable"); + + + // Constructors + + //- Construct from entry name and dictionary + integratedNonUniformTable(const word& name, const dictionary& dict); + + //- Construct from dictionary, using "values" for the lookup + explicit integratedNonUniformTable(const dictionary& dict); + + + // Member Functions + + //- Integrate the function and return the result + scalar intfdT(scalar p, scalar T) const; + + //- Integrate the function divided by T and return the result + scalar intfByTdT(scalar p, scalar T) const; + + //- Write the function coefficients + void writeData(Ostream& os) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace thermophysicalFunctions +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/tutorials/multiphase/icoReactingMultiPhaseInterFoam/inertMultiphaseMultiComponent/constant/thermophysicalProperties.mercury b/tutorials/multiphase/icoReactingMultiPhaseInterFoam/inertMultiphaseMultiComponent/constant/thermophysicalProperties.mercury index 3875ea01e1..175652f773 100644 --- a/tutorials/multiphase/icoReactingMultiPhaseInterFoam/inertMultiphaseMultiComponent/constant/thermophysicalProperties.mercury +++ b/tutorials/multiphase/icoReactingMultiPhaseInterFoam/inertMultiphaseMultiComponent/constant/thermophysicalProperties.mercury @@ -18,8 +18,8 @@ thermoType { type heRhoThermo; mixture pureMixture; - transport const; - thermo hConst; + transport tabulated; + thermo hTabulated; equationOfState icoTabulated; specie specie; energy sensibleEnthalpy; @@ -43,13 +43,31 @@ mixture } thermodynamics { - Cp 139; - Hf 0.0; + Hf 0; + Sf 0; + Cp + ( + (200 139) + (350 140) + (400 145) + ); } + transport { - mu 0.0015; - Pr 0.8; + mu + ( + (200 0.0015) + (350 0.002) + (400 0.0025) + ); + + kappa + ( + (200 2.56e-2) + (350 3.33e-2) + (400 4.72e-2) + ); } }