OpenFOAM logo
Open Source CFD Toolkit

hConstThermoI.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) 1991-2005 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Description
00026     Constant properties thermodynamics package
00027     templated ito the equationOfState.
00028 
00029 \*---------------------------------------------------------------------------*/
00030 
00031 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00032 
00033 namespace Foam
00034 {
00035 
00036 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00037 
00038 // Construct from components
00039 template<class equationOfState>
00040 inline hConstThermo<equationOfState>::hConstThermo
00041 (
00042     const equationOfState& st,
00043     const scalar cp,
00044     const scalar hf
00045 )
00046 :
00047     equationOfState(st),
00048     CP(cp),
00049     Hf(hf)
00050 {}
00051 
00052 
00053 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00054 
00055 // Construct as named copy
00056 template<class equationOfState>
00057 inline hConstThermo<equationOfState>::hConstThermo
00058 (
00059     const word& name,
00060     const hConstThermo& ct
00061 )
00062 :
00063     equationOfState(name, ct),
00064     CP(ct.CP),
00065     Hf(ct.Hf)
00066 {}
00067 
00068 
00069 // Construct and return a clone
00070 template<class equationOfState>
00071 inline autoPtr<hConstThermo<equationOfState> > hConstThermo<equationOfState>::
00072 clone() const
00073 {
00074     return autoPtr<hConstThermo<equationOfState> >
00075     (
00076         new hConstThermo<equationOfState>(*this)
00077     );
00078 }
00079 
00080 
00081 // Selector from Istream
00082 template<class equationOfState>
00083 inline autoPtr<hConstThermo<equationOfState> > hConstThermo<equationOfState>::
00084 New(Istream& is)
00085 {
00086     return autoPtr<hConstThermo<equationOfState> >
00087     (
00088         new hConstThermo<equationOfState>(is)
00089     );
00090 }
00091 
00092 
00093 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00094 
00095 //- Heat capacity at constant pressure [J/(kmol K)]
00096 template<class equationOfState>
00097 inline scalar hConstThermo<equationOfState>::cp(const scalar) const
00098 {
00099     return CP*this->W();
00100 }
00101 
00102 
00103 //- Enthalpy [J/kmol]
00104 template<class equationOfState>
00105 inline scalar hConstThermo<equationOfState>::h(const scalar T) const
00106 {
00107     return (CP*T + Hf)*this->W();
00108 }
00109 
00110 
00111 //- Entropy [J/(kmol K)]
00112 template<class equationOfState>
00113 inline scalar hConstThermo<equationOfState>::s(const scalar T) const
00114 {
00115     notImplemented("scalar hConstThermo<equationOfState>::s(const scalar T) const");
00116     return T;
00117 }
00118 
00119 /*
00120 //- Temperature from Enthalpy given an initial temperature T0
00121 template<class equationOfState>
00122 inline scalar hConstThermo<equationOfState>::TH(const scalar h, const scalar T0) const
00123 {
00124     return (h - Hf)/Cp(T0);
00125 }
00126 
00127 
00128 //- Temperature from internal energy given an initial temperature T0
00129 template<class equationOfState>
00130 inline scalar hConstThermo<equationOfState>::TE(const scalar e, const scalar T0) const
00131 {
00132     return (e - Hf)/Cv(T0);
00133 }
00134 */
00135 
00136 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00137 
00138 template<class equationOfState>
00139 inline hConstThermo<equationOfState>& hConstThermo<equationOfState>::operator=
00140 (
00141     const hConstThermo& ct
00142 )
00143 {
00144     equationOfState::operator=(ct);
00145 
00146     CP = ct.CP;
00147     Hf = ct.Hf;
00148 
00149     return *this;
00150 }
00151 
00152 
00153 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
00154 
00155 template<class equationOfState>
00156 inline hConstThermo<equationOfState> operator+
00157 (
00158     const hConstThermo<equationOfState>& ct1,
00159     const hConstThermo<equationOfState>& ct2
00160 )
00161 {
00162     equationOfState eofs
00163     (
00164         static_cast<const equationOfState&>(ct1)
00165         + static_cast<const equationOfState&>(ct2)
00166     );
00167 
00168     return hConstThermo<equationOfState>
00169     (
00170         eofs,
00171         ct1.nMoles()/eofs.nMoles()*ct1.CP + ct2.nMoles()/eofs.nMoles()*ct2.CP,
00172         ct1.nMoles()/eofs.nMoles()*ct1.Hf + ct2.nMoles()/eofs.nMoles()*ct2.Hf
00173     );
00174 }
00175 
00176 
00177 template<class equationOfState>
00178 inline hConstThermo<equationOfState> operator-
00179 (
00180     const hConstThermo<equationOfState>& ct1,
00181     const hConstThermo<equationOfState>& ct2
00182 )
00183 {
00184     equationOfState eofs
00185     (
00186         static_cast<const equationOfState&>(ct1)
00187       - static_cast<const equationOfState&>(ct2)
00188     );
00189 
00190     return hConstThermo<equationOfState>
00191     (
00192         eofs,
00193         ct1.nMoles()/eofs.nMoles()*ct1.CP - ct2.nMoles()/eofs.nMoles()*ct2.CP,
00194         ct1.nMoles()/eofs.nMoles()*ct1.Hf - ct2.nMoles()/eofs.nMoles()*ct2.Hf
00195     );
00196 }
00197 
00198 
00199 template<class equationOfState>
00200 inline hConstThermo<equationOfState> operator*
00201 (
00202     const scalar s,
00203     const hConstThermo<equationOfState>& ct
00204 )
00205 {
00206     return hConstThermo<equationOfState>
00207     (
00208         s*static_cast<const equationOfState&>(ct),
00209         ct.CP,
00210         ct.Hf
00211     );
00212 }
00213 
00214 
00215 template<class equationOfState>
00216 inline hConstThermo<equationOfState> operator==
00217 (
00218     const hConstThermo<equationOfState>& ct1,
00219     const hConstThermo<equationOfState>& ct2
00220 )
00221 {
00222     return ct2 - ct1;
00223 }
00224 
00225 
00226 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00227 
00228 } // End namespace Foam
00229 
00230 // ************************************************************************* //
For further information go to www.openfoam.org