OpenFOAM logo
Open Source CFD Toolkit

eConstThermoI.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 derived from the basic
00027     thermo package data type specieThermo.
00028 
00029 \*---------------------------------------------------------------------------*/
00030 
00031 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00032 
00033 namespace Foam
00034 {
00035 
00036 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00037 
00038 // Construct from components
00039 inline eConstThermo::eConstThermo
00040 (
00041     const specieThermo& st,
00042     const scalar cv,
00043     const scalar hf
00044 )
00045 :
00046     specieThermo(st),
00047     CV(cv),
00048     Hf(hf)
00049 {}
00050 
00051 
00052 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00053 
00054 //- Construct as named copy
00055 inline eConstThermo::eConstThermo(const word& name, const eConstThermo& ct)
00056 :
00057     specieThermo(name, ct),
00058     CV(ct.CV),
00059     Hf(ct.Hf)
00060 {}
00061 
00062 
00063 // Construct and return a clone
00064 template<class equationOfState>
00065 inline autoPtr<eConstThermo<equationOfState> > eConstThermo<equationOfState>::
00066 clone() const
00067 {
00068     return autoPtr<eConstThermo<equationOfState> >
00069     (
00070         new eConstThermo<equationOfState>(*this)
00071     );
00072 }
00073 
00074 
00075 // Selector from Istream
00076 template<class equationOfState>
00077 inline autoPtr<eConstThermo<equationOfState> > eConstThermo<equationOfState>::
00078 New(Istream& is)
00079 {
00080     return autoPtr<eConstThermo<equationOfState> >
00081     (
00082         new eConstThermo<equationOfState>(is)
00083     );
00084 }
00085 
00086 
00087 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00088 
00089 //- Heat capacity at constant pressure [J/(kmol K)]
00090 inline scalar eConstThermo::cp(const scalar) const
00091 {
00092     return CV*W() + RR;
00093 }
00094 
00095 
00096 //- Enthalpy [J/kmol]
00097 inline scalar eConstThermo::h(const scalar T) const
00098 {
00099     return cp(T)*T + Hf*W();
00100 }
00101 
00102 
00103 //- Entropy [J/(kmol K)]
00104 inline scalar eConstThermo::s(const scalar T) const
00105 {
00106     notImplemented("scalar eConstThermo::s(const scalar T) const");
00107     return T;
00108 }
00109 
00110 
00111 //- Temperature from Enthalpy given an initial temperature T0
00112 inline scalar eConstThermo::TH(const scalar h, const scalar T0) const
00113 {
00114     return (h - Hf)/Cp(T0);
00115 }
00116 
00117 
00118 //- Temperature from internal energy given an initial temperature T0
00119 inline scalar eConstThermo::TE(const scalar e, const scalar) const
00120 {
00121     return (e - Hf)/CV;
00122 }
00123 
00124 
00125 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00126 
00127 inline  eConstThermo& eConstThermo::operator=
00128 (
00129     const eConstThermo& ct
00130 )
00131 {
00132     specieThermo::operator=(ct);
00133 
00134     CV = ct.CV;
00135     Hf = ct.Hf;
00136 
00137     return *this;
00138 }
00139 
00140 
00141 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
00142 
00143 inline eConstThermo operator+
00144 (
00145     const eConstThermo& ct1,
00146     const eConstThermo& ct2
00147 )
00148 {
00149     specieThermo st(((const specieThermo&)ct1) + ((const specieThermo&)ct2));
00150 
00151     return eConstThermo
00152     (
00153         st,
00154         ct1.nMoles()/st.nMoles()*ct1.CV + ct2.nMoles()/st.nMoles()*ct2.CV,
00155         ct1.nMoles()/st.nMoles()*ct1.Hf + ct2.nMoles()/st.nMoles()*ct2.Hf
00156     );
00157 }
00158 
00159 
00160 inline eConstThermo operator-
00161 (
00162     const eConstThermo& ct1,
00163     const eConstThermo& ct2
00164 )
00165 {
00166     specieThermo st(((const specieThermo&)ct1) - ((const specieThermo&)ct2));
00167 
00168     return eConstThermo
00169     (
00170         st,
00171         ct1.nMoles()/st.nMoles()*ct1.CV - ct2.nMoles()/st.nMoles()*ct2.CV,
00172         ct1.nMoles()/st.nMoles()*ct1.Hf - ct2.nMoles()/st.nMoles()*ct2.Hf
00173     );
00174 }
00175 
00176 
00177 inline eConstThermo operator*
00178 (
00179     const scalar s,
00180     const eConstThermo& ct
00181 )
00182 {
00183     return eConstThermo
00184     (
00185         s*((const specieThermo&)ct),
00186         ct.CV,
00187         ct.Hf
00188     );
00189 }
00190 
00191 
00192 inline eConstThermo operator==
00193 (
00194     const eConstThermo& ct1,
00195     const eConstThermo& ct2
00196 )
00197 {
00198     return ct2 - ct1;
00199 }
00200 
00201 
00202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00203 
00204 } // End namespace Foam
00205 
00206 // ************************************************************************* //
For further information go to www.openfoam.org