liquidProperties::liquid: New generic liquid thermophysical properties class

Description
    Generic thermophysical properties class for a liquid in which the
    functions and coefficients for each property are run-time selected.

Property functions need only be specified for properties that are actually used
in the simulation, e.g. in the thermophysicalProperties.water dictionary of the
tutorials/multiphase/compressibleInterFoam/laminar/depthCharge2D case the water
properties can be specified directly as

mixture
{
    liquid
    {
        W       18.015;
        Tc      647.13;
        Pc      2.2055e+7;
        Vc      0.05595;
        Zc      0.229;
        Tt      273.16;
        Pt      6.113e+2;
        Tb      373.15;
        dipm    6.1709e-30;
        omega   0.3449;
        delta   4.7813e+4;

        rho
        {
            type    NSRDSfunc5;
            a       98.343885;
            b       0.30542;
            c       647.13;
            d       0.081;
        }

        Cp
        {
            type    NSRDSfunc0;
            a       15341.1046350264;
            b       -116.019983347211;
            c       0.451013044684985;
            d       -0.000783569247849015;
            e       5.20127671384957e-07;
            f       0;
        }

        h
        {
            type    NSRDSfunc0;
            a       -17957283.7993676;
            b       15341.1046350264;
            c       -58.0099916736053;
            d       0.150337681561662;
            e       -0.000195892311962254;
            f       1.04025534276991e-07;
        }

        mu
        {
            type    NSRDSfunc1;
            a       -51.964;
            b       3670.6;
            c       5.7331;
            d       -5.3495e-29;
            e       10;
        }

        kappa
        {
            type    NSRDSfunc0;
            a       -0.4267;
            b       0.0056903;
            c       -8.0065e-06;
            d       1.815e-09;
            e       0;
            f       0;
        }

        sigma
        {
            type    NSRDSfunc6;
            Tc      647.13;
            a       0.18548;
            b       2.717;
            c       -3.554;
            d       2.047;
            e       0;
        }
    }
}
This commit is contained in:
Henry Weller
2019-11-24 23:05:28 +00:00
parent c78536f511
commit 375e1f7c63
8 changed files with 562 additions and 18 deletions

View File

@ -1,5 +1,7 @@
thermophysicalFunctions/thermophysicalFunction/thermophysicalFunction.C
thermophysicalFunctions/noneFunc/noneFunc.C
NSRDSfunctions = thermophysicalFunctions/NSRDSfunctions
$(NSRDSfunctions)/NSRDSfunc0/NSRDSfunc0.C
$(NSRDSfunctions)/NSRDSfunc1/NSRDSfunc1.C
@ -20,6 +22,7 @@ thermophysicalProperties/thermophysicalProperties.C
liquidProperties/liquidProperties/liquidProperties.C
liquidProperties/liquidMixtureProperties/liquidMixtureProperties.C
liquidProperties/liquid/liquid.C
liquidProperties/H2O/H2O.C
liquidProperties/C7H16/C7H16.C
liquidProperties/C12H26/C12H26.C

View File

@ -0,0 +1,88 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2019 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "liquid.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(liquid, 0);
addToRunTimeSelectionTable(liquidProperties, liquid, dictionary);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::liquid::liquid(const dictionary& dict)
:
liquidProperties(dict),
rho_(thermophysicalFunction::New(dict, "rho")),
pv_(thermophysicalFunction::New(dict, "pv")),
hl_(thermophysicalFunction::New(dict, "hl")),
Cp_(thermophysicalFunction::New(dict, "Cp")),
h_(thermophysicalFunction::New(dict, "h")),
Cpg_(thermophysicalFunction::New(dict, "Cpg")),
B_(thermophysicalFunction::New(dict, "B")),
mu_(thermophysicalFunction::New(dict, "mu")),
mug_(thermophysicalFunction::New(dict, "mug")),
kappa_(thermophysicalFunction::New(dict, "kappa")),
kappag_(thermophysicalFunction::New(dict, "kappag")),
sigma_(thermophysicalFunction::New(dict, "sigma")),
D_(thermophysicalFunction::New(dict, "D"))
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::liquid::writeData(Ostream& os) const
{
liquidProperties::writeData(os); os << nl;
rho_->writeData(os); os << nl;
pv_->writeData(os); os << nl;
hl_->writeData(os); os << nl;
Cp_->writeData(os); os << nl;
h_->writeData(os); os << nl;
Cpg_->writeData(os); os << nl;
B_->writeData(os); os << nl;
mu_->writeData(os); os << nl;
mug_->writeData(os); os << nl;
kappa_->writeData(os); os << nl;
kappag_->writeData(os); os << nl;
sigma_->writeData(os); os << nl;
D_->writeData(os); os << endl;
}
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const liquid& l)
{
l.writeData(os);
return os;
}
// ************************************************************************* //

View File

@ -0,0 +1,162 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2019 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 <http://www.gnu.org/licenses/>.
Class
Foam::liquid
Description
Generic thermophysical properties class for a liquid in which the
functions and coefficients for each property are run-time selected.
SourceFiles
liquid.C
\*---------------------------------------------------------------------------*/
#ifndef liquid_H
#define liquid_H
#include "liquidProperties.H"
#include "thermophysicalFunction.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class liquid Declaration
\*---------------------------------------------------------------------------*/
class liquid
:
public liquidProperties
{
// Private Data
autoPtr<thermophysicalFunction> rho_;
autoPtr<thermophysicalFunction> pv_;
autoPtr<thermophysicalFunction> hl_;
autoPtr<thermophysicalFunction> Cp_;
autoPtr<thermophysicalFunction> h_;
autoPtr<thermophysicalFunction> Cpg_;
autoPtr<thermophysicalFunction> B_;
autoPtr<thermophysicalFunction> mu_;
autoPtr<thermophysicalFunction> mug_;
autoPtr<thermophysicalFunction> kappa_;
autoPtr<thermophysicalFunction> kappag_;
autoPtr<thermophysicalFunction> sigma_;
autoPtr<thermophysicalFunction> D_;
public:
friend class liquidProperties;
//- Runtime type information
TypeName("liquid");
// Constructors
//- Construct from dictionary
liquid(const dictionary& dict);
//- Construct and return clone
virtual autoPtr<liquidProperties> clone() const
{
return autoPtr<liquidProperties>(new liquid(*this));
}
// Member Functions
//- Liquid density [kg/m^3]
inline scalar rho(scalar p, scalar T) const;
//- Vapour pressure [Pa]
inline scalar pv(scalar p, scalar T) const;
//- Heat of vapourisation [J/kg]
inline scalar hl(scalar p, scalar T) const;
//- Liquid heat capacity [J/kg/K]
inline scalar Cp(scalar p, scalar T) const;
//- Liquid enthalpy [J/kg]
inline scalar h(scalar p, scalar T) const;
//- Ideal gas heat capacity [J/kg/K]
inline scalar Cpg(scalar p, scalar T) const;
//- Second Virial Coefficient [m^3/kg]
inline scalar B(scalar p, scalar T) const;
//- Liquid viscosity [Pa s]
inline scalar mu(scalar p, scalar T) const;
//- Vapour viscosity [Pa s]
inline scalar mug(scalar p, scalar T) const;
//- Liquid thermal conductivity [W/m/K]
inline scalar kappa(scalar p, scalar T) const;
//- Vapour thermal conductivity [W/m/K]
inline scalar kappag(scalar p, scalar T) const;
//- Surface tension [N/m]
inline scalar sigma(scalar p, scalar T) const;
//- Vapour diffusivity [m^2/s]
inline scalar D(scalar p, scalar T) const;
//- Vapour diffusivity [m^2/s] with specified binary pair
inline scalar D(scalar p, scalar T, scalar Wb) const;
// I-O
//- Write the function coefficients
void writeData(Ostream& os) const;
//- Ostream Operator
friend Ostream& operator<<(Ostream& os, const liquid& l);
};
Ostream& operator<<(Ostream& os, const liquid& l);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "liquidI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,111 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2019 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
inline Foam::scalar Foam::liquid::rho(scalar p, scalar T) const
{
return rho_->f(p, T);
}
inline Foam::scalar Foam::liquid::pv(scalar p, scalar T) const
{
return pv_->f(p, T);
}
inline Foam::scalar Foam::liquid::hl(scalar p, scalar T) const
{
return hl_->f(p, T);
}
inline Foam::scalar Foam::liquid::Cp(scalar p, scalar T) const
{
return Cp_->f(p, T);
}
inline Foam::scalar Foam::liquid::h(scalar p, scalar T) const
{
return h_->f(p, T);
}
inline Foam::scalar Foam::liquid::Cpg(scalar p, scalar T) const
{
return Cpg_->f(p, T);
}
inline Foam::scalar Foam::liquid::B(scalar p, scalar T) const
{
return B_->f(p, T);
}
inline Foam::scalar Foam::liquid::mu(scalar p, scalar T) const
{
return mu_->f(p, T);
}
inline Foam::scalar Foam::liquid::mug(scalar p, scalar T) const
{
return mug_->f(p, T);
}
inline Foam::scalar Foam::liquid::kappa(scalar p, scalar T) const
{
return kappa_->f(p, T);
}
inline Foam::scalar Foam::liquid::kappag(scalar p, scalar T) const
{
return kappag_->f(p, T);
}
inline Foam::scalar Foam::liquid::sigma(scalar p, scalar T) const
{
return sigma_->f(p, T);
}
inline Foam::scalar Foam::liquid::D(scalar p, scalar T) const
{
return D_->f(p, T);
}
inline Foam::scalar Foam::liquid::D(scalar p, scalar T, scalar Wb) const
{
// Currently ignoring the Wb argument
return D_->f(p, T);
}
// ************************************************************************* //

View File

@ -0,0 +1,71 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2019 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "noneFunc.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(noneFunc, 0);
addToRunTimeSelectionTable(thermophysicalFunction, noneFunc, dictionary);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::noneFunc::noneFunc(const dictionary& dict)
:
dictName_(dict.name())
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::scalar Foam::noneFunc::f(scalar p, scalar T) const
{
FatalErrorInFunction
<< "Required Function " << nl
<< " " << dictName_ << nl
<< " is not defined."
<< exit(FatalError);
return 0;
}
void Foam::noneFunc::writeData(Ostream& os) const
{}
// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const noneFunc& f)
{
return os;
}
// ************************************************************************* //

View File

@ -0,0 +1,96 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2019 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 <http://www.gnu.org/licenses/>.
Class
Foam::noneFunc
Description
Undefined function which returns an error when called.
\*---------------------------------------------------------------------------*/
#ifndef noneFunc_H
#define noneFunc_H
#include "thermophysicalFunction.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of friend functions and operators
class noneFunc;
Ostream& operator<<(Ostream& os, const noneFunc& f);
/*---------------------------------------------------------------------------*\
Class noneFunc Declaration
\*---------------------------------------------------------------------------*/
class noneFunc
:
public thermophysicalFunction
{
// Private member data
//- Name of dictionary from which this function is instantiated
fileName dictName_;
public:
//- Runtime type information
TypeName("none");
// Constructors
//- Construct from dictionary
noneFunc(const dictionary& dict);
// Member Functions
//- Evaluate the function and return the result
scalar f(scalar p, scalar T) const;
//- Write the function coefficients
void writeData(Ostream& os) const;
// Ostream Operator
friend Ostream& operator<<(Ostream& os, const noneFunc& f);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "thermophysicalFunction.H"
#include "HashTable.H"
#include "noneFunc.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -39,7 +39,8 @@ namespace Foam
Foam::autoPtr<Foam::thermophysicalFunction> Foam::thermophysicalFunction::New
(
const dictionary& dict
const dictionary& dict,
const word& name
)
{
if (debug)
@ -49,23 +50,31 @@ Foam::autoPtr<Foam::thermophysicalFunction> Foam::thermophysicalFunction::New
<< endl;
}
const word thermophysicalFunctionType(dict.lookup("functionType"));
if (dict.isDict(name))
{
const dictionary& funcDict(dict.subDict(name));
const word thermophysicalFunctionType(funcDict.lookup("type"));
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(thermophysicalFunctionType);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorInFunction
<< "Unknown thermophysicalFunction type "
<< thermophysicalFunctionType
<< nl << nl
<< "Valid thermophysicalFunction types are :" << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< abort(FatalError);
}
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorInFunction
<< "Unknown thermophysicalFunction type "
<< thermophysicalFunctionType
<< nl << nl
<< "Valid thermophysicalFunction types are :" << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< abort(FatalError);
}
return autoPtr<thermophysicalFunction>(cstrIter()(dict));
return autoPtr<thermophysicalFunction>(cstrIter()(funcDict));
}
else
{
return autoPtr<thermophysicalFunction>(new noneFunc(dict.name()/name));
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -76,7 +76,11 @@ public:
{}
//- Return pointer to new thermophysicalFunction created from dict
static autoPtr<thermophysicalFunction> New(const dictionary& dict);
static autoPtr<thermophysicalFunction> New
(
const dictionary& dict,
const word& name
);
//- Destructor