diff --git a/src/thermophysicalModels/specie/include/thermoPhysicsTypes.H b/src/thermophysicalModels/specie/include/thermoPhysicsTypes.H index 04cecc04..828140f2 100644 --- a/src/thermophysicalModels/specie/include/thermoPhysicsTypes.H +++ b/src/thermophysicalModels/specie/include/thermoPhysicsTypes.H @@ -43,6 +43,7 @@ Description #include "thermo.H" #include "sutherlandTransport.H" #include "constTransport.H" +#include "canteraTransport.H" #include "icoPolynomial.H" #include "hPolynomialThermo.H" @@ -79,6 +80,19 @@ namespace Foam > > gasHThermoPhysics; + typedef + canteraTransport + < + species::thermo + < + janafThermo + < + perfectGas + >, + sensibleEnthalpy + > + > canteraGasHThermoPhysics; + typedef constTransport < diff --git a/src/thermophysicalModels/specie/transport/cantera/canteraTransport.C b/src/thermophysicalModels/specie/transport/cantera/canteraTransport.C new file mode 100644 index 00000000..43d62d94 --- /dev/null +++ b/src/thermophysicalModels/specie/transport/cantera/canteraTransport.C @@ -0,0 +1,89 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-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 "canteraTransport.H" +#include "IOstreams.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::canteraTransport::canteraTransport(Istream& is) +: + Thermo(is), + As_(readScalar(is)), + Ts_(readScalar(is)) +{ + is.check("canteraTransport::canteraTransport(Istream&)"); +} + + +template +Foam::canteraTransport::canteraTransport(const dictionary& dict) +: + Thermo(dict), + As_(readScalar(dict.subDict("transport").lookup("As"))), + Ts_(readScalar(dict.subDict("transport").lookup("Ts"))) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +void Foam::canteraTransport::write(Ostream& os) const +{ + os << this->specie::name() << endl; + os << token::BEGIN_BLOCK << incrIndent << nl; + + Thermo::write(os); + + dictionary dict("transport"); + dict.add("As", As_); + dict.add("Ts", Ts_); + os << indent << dict.dictName() << dict; + + os << decrIndent << token::END_BLOCK << nl; +} + +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // + +template +Foam::Ostream& Foam::operator<< +( + Ostream& os, + const canteraTransport& st +) +{ + os << static_cast(st) << tab << st.As_ << tab << st.Ts_; + + os.check + ( + "Ostream& operator<<(Ostream&, const canteraTransport&)" + ); + + return os; +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/specie/transport/cantera/canteraTransport.H b/src/thermophysicalModels/specie/transport/cantera/canteraTransport.H new file mode 100644 index 00000000..1283e2f4 --- /dev/null +++ b/src/thermophysicalModels/specie/transport/cantera/canteraTransport.H @@ -0,0 +1,245 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2013 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::canteraTransport + +Description + Transport package using Sutherland's formula. + + Templated into a given thermodynamics package (needed for thermal + conductivity). + + Dynamic viscosity [kg/m.s] + \f[ + \mu = A_s \frac{\sqrt{T}}{1 + T_s / T} + \f] + +SourceFiles + canteraTransportI.H + canteraTransport.C + +\*---------------------------------------------------------------------------*/ + +#ifndef canteraTransport_H +#define canteraTransport_H + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of friend functions and operators + +template class canteraTransport; + +template +inline canteraTransport operator+ +( + const canteraTransport&, + const canteraTransport& +); + +template +inline canteraTransport operator- +( + const canteraTransport&, + const canteraTransport& +); + +template +inline canteraTransport operator* +( + const scalar, + const canteraTransport& +); + +template +inline canteraTransport operator== +( + const canteraTransport&, + const canteraTransport& +); + +template +Ostream& operator<< +( + Ostream&, + const canteraTransport& +); + + +/*---------------------------------------------------------------------------*\ + Class canteraTransport Declaration +\*---------------------------------------------------------------------------*/ + +template +class canteraTransport +: + public Thermo +{ + // Private data + + // Sutherland's coefficients + scalar As_, Ts_; + + + // Private Member Functions + + //- Calculate the Sutherland coefficients + // given two viscosities and temperatures + inline void calcCoeffs + ( + const scalar mu1, const scalar T1, + const scalar mu2, const scalar T2 + ); + + +public: + + // Constructors + + //- Construct from components + inline canteraTransport + ( + const Thermo& t, + const scalar As, + const scalar Ts + ); + + //- Construct from two viscosities + inline canteraTransport + ( + const Thermo& t, + const scalar mu1, const scalar T1, + const scalar mu2, const scalar T2 + ); + + //- Construct as named copy + inline canteraTransport(const word&, const canteraTransport&); + + //- Construct from Istream + canteraTransport(Istream&); + + //- Construct from dictionary + canteraTransport(const dictionary& dict); + + //- 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 + + //- Return the instantiated type name + static word typeName() + { + return "cantera<" + Thermo::typeName() + '>'; + } + + //- Dynamic viscosity [kg/ms] + inline scalar mu(const scalar p, const scalar T) const; + + //- Thermal conductivity [W/mK] + inline scalar kappa(const scalar p, const scalar T) const; + + //- Thermal diffusivity of enthalpy [kg/ms] + 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; + + + // Member operators + + inline canteraTransport& operator=(const canteraTransport&); + + inline void operator+=(const canteraTransport&); + + inline void operator-=(const canteraTransport&); + + inline void operator*=(const scalar); + + + // Friend operators + + friend canteraTransport operator+ + ( + const canteraTransport&, + const canteraTransport& + ); + + friend canteraTransport operator- + ( + const canteraTransport&, + const canteraTransport& + ); + + friend canteraTransport operator* + ( + const scalar, + const canteraTransport& + ); + + friend canteraTransport operator== + ( + const canteraTransport&, + const canteraTransport& + ); + + + // Ostream Operator + + friend Ostream& operator<< + ( + Ostream&, + const canteraTransport& + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "canteraTransportI.H" + +#ifdef NoRepository +# include "canteraTransport.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/thermophysicalModels/specie/transport/cantera/canteraTransportI.H b/src/thermophysicalModels/specie/transport/cantera/canteraTransportI.H new file mode 100644 index 00000000..b1ced0a1 --- /dev/null +++ b/src/thermophysicalModels/specie/transport/cantera/canteraTransportI.H @@ -0,0 +1,306 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2013 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 "specie.H" + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template +inline void Foam::canteraTransport::calcCoeffs +( + const scalar mu1, const scalar T1, + const scalar mu2, const scalar T2 +) +{ + scalar rootT1 = sqrt(T1); + scalar mu1rootT2 = mu1*sqrt(T2); + scalar mu2rootT1 = mu2*rootT1; + + Ts_ = (mu2rootT1 - mu1rootT2)/(mu1rootT2/T1 - mu2rootT1/T2); + + As_ = mu1*(1.0 + Ts_/T1)/rootT1; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +inline Foam::canteraTransport::canteraTransport +( + const Thermo& t, + const scalar As, + const scalar Ts +) +: + Thermo(t), + As_(As), + Ts_(Ts) +{} + + +template +inline Foam::canteraTransport::canteraTransport +( + const Thermo& t, + const scalar mu1, const scalar T1, + const scalar mu2, const scalar T2 +) +: + Thermo(t) +{ + calcCoeffs(mu1, T1, mu2, T2); +} + + +template +inline Foam::canteraTransport::canteraTransport +( + const word& name, + const canteraTransport& st +) +: + Thermo(name, st), + As_(st.As_), + Ts_(st.Ts_) +{} + + +template +inline Foam::autoPtr > +Foam::canteraTransport::clone() const +{ + return autoPtr > + ( + new canteraTransport(*this) + ); +} + + +template +inline Foam::autoPtr > +Foam::canteraTransport::New +( + Istream& is +) +{ + return autoPtr > + ( + new canteraTransport(is) + ); +} + + +template +inline Foam::autoPtr > +Foam::canteraTransport::New +( + const dictionary& dict +) +{ + return autoPtr > + ( + new canteraTransport(dict) + ); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +inline Foam::scalar Foam::canteraTransport::mu +( + const scalar p, + const scalar T +) const +{ + return As_*::sqrt(T)/(1.0 + Ts_/T); +} + + +template +inline Foam::scalar Foam::canteraTransport::kappa +( + const scalar p, const scalar T +) const +{ + scalar Cv_ = this->Cv(p, T); + return mu(p, T)*Cv_*(1.32 + 1.77*this->R()/Cv_); +} + + +template +inline Foam::scalar Foam::canteraTransport::alphah +( + const scalar p, + const scalar T +) const +{ + + return kappa(p, T)/this->Cpv(p, T); +} + + +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + +template +inline Foam::canteraTransport& +Foam::canteraTransport::operator= +( + const canteraTransport& st +) +{ + Thermo::operator=(st); + + As_ = st.As_; + Ts_ = st.Ts_; + + return *this; +} + + +template +inline void Foam::canteraTransport::operator+= +( + const canteraTransport& st +) +{ + scalar molr1 = this->nMoles(); + + Thermo::operator+=(st); + + molr1 /= this->nMoles(); + scalar molr2 = st.nMoles()/this->nMoles(); + + As_ = molr1*As_ + molr2*st.As_; + Ts_ = molr1*Ts_ + molr2*st.Ts_; +} + + +template +inline void Foam::canteraTransport::operator-= +( + const canteraTransport& st +) +{ + scalar molr1 = this->nMoles(); + + Thermo::operator-=(st); + + molr1 /= this->nMoles(); + scalar molr2 = st.nMoles()/this->nMoles(); + + As_ = molr1*As_ - molr2*st.As_; + Ts_ = molr1*Ts_ - molr2*st.Ts_; +} + + +template +inline void Foam::canteraTransport::operator*= +( + const scalar s +) +{ + Thermo::operator*=(s); +} + + +// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // + +template +inline Foam::canteraTransport Foam::operator+ +( + const canteraTransport& st1, + const canteraTransport& st2 +) +{ + Thermo t + ( + static_cast(st1) + static_cast(st2) + ); + + scalar molr1 = st1.nMoles()/t.nMoles(); + scalar molr2 = st2.nMoles()/t.nMoles(); + + return canteraTransport + ( + t, + molr1*st1.As_ + molr2*st2.As_, + molr1*st1.Ts_ + molr2*st2.Ts_ + ); +} + + +template +inline Foam::canteraTransport Foam::operator- +( + const canteraTransport& st1, + const canteraTransport& st2 +) +{ + Thermo t + ( + static_cast(st1) - static_cast(st2) + ); + + scalar molr1 = st1.nMoles()/t.nMoles(); + scalar molr2 = st2.nMoles()/t.nMoles(); + + return canteraTransport + ( + t, + molr1*st1.As_ - molr2*st2.As_, + molr1*st1.Ts_ - molr2*st2.Ts_ + ); +} + + +template +inline Foam::canteraTransport Foam::operator* +( + const scalar s, + const canteraTransport& st +) +{ + return canteraTransport + ( + s*static_cast(st), + st.As_, + st.Ts_ + ); +} + + +template +inline Foam::canteraTransport Foam::operator== +( + const canteraTransport& st1, + const canteraTransport& st2 +) +{ + return st2 - st1; +} + + +// ************************************************************************* //