FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

hPolynomialThermoI.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 2008-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "hPolynomialThermo.H"
00027 
00028 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00029 
00030 template<class EquationOfState, int PolySize>
00031 inline Foam::hPolynomialThermo<EquationOfState, PolySize>::hPolynomialThermo
00032 (
00033     const EquationOfState& pt,
00034     const scalar Hf,
00035     const scalar Sf,
00036     const Polynomial<PolySize>& CpPoly,
00037     const typename Polynomial<PolySize>::intPolyType& hPoly,
00038     const Polynomial<PolySize>& sPoly
00039 )
00040 :
00041     EquationOfState(pt),
00042     Hf_(Hf),
00043     Sf_(Sf),
00044     CpPolynomial_(CpPoly),
00045     hPolynomial_(hPoly),
00046     sPolynomial_(sPoly)
00047 {}
00048 
00049 
00050 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00051 
00052 template<class EquationOfState, int PolySize>
00053 inline Foam::hPolynomialThermo<EquationOfState, PolySize>::hPolynomialThermo
00054 (
00055     const hPolynomialThermo& pt
00056 )
00057 :
00058     EquationOfState(pt),
00059     Hf_(pt.Hf_),
00060     Sf_(pt.Sf_),
00061     CpPolynomial_(pt.CpPolynomial_),
00062     hPolynomial_(pt.hPolynomial_),
00063     sPolynomial_(pt.sPolynomial_)
00064 {}
00065 
00066 
00067 template<class EquationOfState, int PolySize>
00068 inline Foam::hPolynomialThermo<EquationOfState, PolySize>::hPolynomialThermo
00069 (
00070     const word& name,
00071     const hPolynomialThermo& pt
00072 )
00073 :
00074     EquationOfState(name, pt),
00075     Hf_(pt.Hf_),
00076     Sf_(pt.Sf_),
00077     CpPolynomial_(pt.CpPolynomial_),
00078     hPolynomial_(pt.hPolynomial_),
00079     sPolynomial_(pt.sPolynomial_)
00080 {}
00081 
00082 
00083 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00084 
00085 template<class EquationOfState, int PolySize>
00086 inline Foam::scalar Foam::hPolynomialThermo<EquationOfState, PolySize>::cp
00087 (
00088     const scalar T
00089 ) const
00090 {
00091     return CpPolynomial_.evaluate(T);
00092 }
00093 
00094 
00095 template<class EquationOfState, int PolySize>
00096 inline Foam::scalar Foam::hPolynomialThermo<EquationOfState, PolySize>::h
00097 (
00098     const scalar T
00099 ) const
00100 {
00101     return hPolynomial_.evaluate(T);
00102 }
00103 
00104 
00105 template<class EquationOfState, int PolySize>
00106 inline Foam::scalar Foam::hPolynomialThermo<EquationOfState, PolySize>::hs
00107 (
00108     const scalar T
00109 ) const
00110 {
00111     return h(T) - hc();
00112 }
00113 
00114 
00115 template<class EquationOfState, int PolySize>
00116 inline Foam::scalar Foam::hPolynomialThermo<EquationOfState, PolySize>::hc()
00117 const
00118 {
00119     return Hf_;
00120 }
00121 
00122 
00123 template<class EquationOfState, int PolySize>
00124 inline Foam::scalar Foam::hPolynomialThermo<EquationOfState, PolySize>::s
00125 (
00126     const scalar T
00127 ) const
00128 {
00129     return sPolynomial_.evaluate(T);
00130 }
00131 
00132 
00133 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00134 
00135 template<class EquationOfState, int PolySize>
00136 inline Foam::hPolynomialThermo<EquationOfState, PolySize>&
00137 Foam::hPolynomialThermo<EquationOfState, PolySize>::operator=
00138 (
00139     const hPolynomialThermo<EquationOfState, PolySize>& pt
00140 )
00141 {
00142     EquationOfState::operator=(pt);
00143 
00144     Hf_ = pt.Hf_;
00145     Sf_ = pt.Sf_;
00146     CpPolynomial_ = pt.CpPolynomial_;
00147     hPolynomial_ = pt.hPolynomial_;
00148     sPolynomial_ = pt.sPolynomial_;
00149 
00150     return *this;
00151 }
00152 
00153 
00154 template<class EquationOfState, int PolySize>
00155 inline void Foam::hPolynomialThermo<EquationOfState, PolySize>::operator+=
00156 (
00157     const hPolynomialThermo<EquationOfState, PolySize>& pt
00158 )
00159 {
00160     scalar molr1 = this->nMoles();
00161 
00162     EquationOfState::operator+=(pt);
00163 
00164     molr1 /= this->nMoles();
00165     scalar molr2 = pt.nMoles()/this->nMoles();
00166 
00167     Hf_ = molr1*Hf_ + molr2*pt.Hf_;
00168     Sf_ = molr1*Sf_ + molr2*pt.Sf_;
00169     CpPolynomial_ = molr1*CpPolynomial_ + molr2*pt.CpPolynomial_;
00170     hPolynomial_ = molr1*hPolynomial_ + molr2*pt.hPolynomial_;
00171     sPolynomial_ = molr1*sPolynomial_ + molr2*pt.sPolynomial_;
00172 }
00173 
00174 
00175 template<class EquationOfState, int PolySize>
00176 inline void Foam::hPolynomialThermo<EquationOfState, PolySize>::operator-=
00177 (
00178     const hPolynomialThermo<EquationOfState, PolySize>& pt
00179 )
00180 {
00181     scalar molr1 = this->nMoles();
00182 
00183     EquationOfState::operator-=(pt);
00184 
00185     molr1 /= this->nMoles();
00186     scalar molr2 = pt.nMoles()/this->nMoles();
00187 
00188     Hf_ = molr1*Hf_ - molr2*pt.Hf_;
00189     Sf_ = molr1*Sf_ - molr2*pt.Sf_;
00190     CpPolynomial_ = molr1*CpPolynomial_ - molr2*pt.CpPolynomial_;
00191     hPolynomial_ = molr1*hPolynomial_ - molr2*pt.hPolynomial_;
00192     sPolynomial_ = molr1*sPolynomial_ - molr2*pt.sPolynomial_;
00193 }
00194 
00195 
00196 template<class EquationOfState, int PolySize>
00197 inline void Foam::hPolynomialThermo<EquationOfState, PolySize>::operator*=
00198 (
00199     const scalar s
00200 )
00201 {
00202     EquationOfState::operator*=(s);
00203 }
00204 
00205 
00206 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
00207 
00208 template<class EquationOfState, int PolySize>
00209 inline Foam::hPolynomialThermo<EquationOfState, PolySize> Foam::operator+
00210 (
00211     const hPolynomialThermo<EquationOfState, PolySize>& pt1,
00212     const hPolynomialThermo<EquationOfState, PolySize>& pt2
00213 )
00214 {
00215     EquationOfState eofs = pt1;
00216     eofs += pt2;
00217 
00218     scalar molr1 = pt1.nMoles()/eofs.nMoles();
00219     scalar molr2 = pt2.nMoles()/eofs.nMoles();
00220 
00221     return hPolynomialThermo<EquationOfState, PolySize>
00222     (
00223         eofs,
00224         molr1*pt1.Hf_ + molr2*pt2.Hf_,
00225         molr1*pt1.Sf_ + molr2*pt2.Sf_,
00226         molr1*pt1.CpPolynomial_ + molr2*pt2.CpPolynomial_,
00227         molr1*pt1.hPolynomial_ + molr2*pt2.hPolynomial_,
00228         molr1*pt1.sPolynomial_ + molr2*pt2.sPolynomial_
00229     );
00230 }
00231 
00232 
00233 template<class EquationOfState, int PolySize>
00234 inline Foam::hPolynomialThermo<EquationOfState, PolySize> Foam::operator-
00235 (
00236     const hPolynomialThermo<EquationOfState, PolySize>& pt1,
00237     const hPolynomialThermo<EquationOfState, PolySize>& pt2
00238 )
00239 {
00240     EquationOfState eofs = pt1;
00241     eofs -= pt2;
00242 
00243     scalar molr1 = pt1.nMoles()/eofs.nMoles();
00244     scalar molr2 = pt2.nMoles()/eofs.nMoles();
00245 
00246     return hPolynomialThermo<EquationOfState, PolySize>
00247     (
00248         eofs,
00249         molr1*pt1.Hf_ - molr2*pt2.Hf_,
00250         molr1*pt1.Sf_ - molr2*pt2.Sf_,
00251         molr1*pt1.CpPolynomial_ - molr2*pt2.CpPolynomial_,
00252         molr1*pt1.hPolynomial_ - molr2*pt2.hPolynomial_,
00253         molr1*pt1.sPolynomial_ - molr2*pt2.sPolynomial_
00254     );
00255 }
00256 
00257 
00258 template<class EquationOfState, int PolySize>
00259 inline Foam::hPolynomialThermo<EquationOfState, PolySize> Foam::operator*
00260 (
00261     const scalar s,
00262     const hPolynomialThermo<EquationOfState, PolySize>& pt
00263 )
00264 {
00265     return hPolynomialThermo<EquationOfState, PolySize>
00266     (
00267         s*static_cast<const EquationOfState&>(pt),
00268         pt.Hf_,
00269         pt.Sf_,
00270         pt.CpPolynomial_,
00271         pt.hPolynomial_,
00272         pt.sPolynomial_
00273     );
00274 }
00275 
00276 
00277 template<class EquationOfState, int PolySize>
00278 inline Foam::hPolynomialThermo<EquationOfState, PolySize> Foam::operator==
00279 (
00280     const hPolynomialThermo<EquationOfState, PolySize>& pt1,
00281     const hPolynomialThermo<EquationOfState, PolySize>& pt2
00282 )
00283 {
00284     return pt2 - pt1;
00285 }
00286 
00287 
00288 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines