1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "multiComponentMixture.H"
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 template<class ThermoType>
31 const ThermoType& Foam::multiComponentMixture<ThermoType>::constructSpeciesData
33 const dictionary& thermoDict
41 new ThermoType(thermoDict.subDict(species_[i]))
45 return speciesData_[0];
49 template<class ThermoType>
50 void Foam::multiComponentMixture<ThermoType>::correctMassFractions()
52 // It changes Yt patches to "calculated"
53 volScalarField Yt("Yt", 1.0*Y_[0]);
55 for (label n=1; n<Y_.size(); n++)
67 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
69 template<class ThermoType>
70 Foam::multiComponentMixture<ThermoType>::multiComponentMixture
72 const dictionary& thermoDict,
73 const wordList& specieNames,
74 const HashPtrTable<ThermoType>& specieThermoData,
78 basicMultiComponentMixture(thermoDict, specieNames, mesh),
79 speciesData_(species_.size()),
80 mixture_("mixture", *specieThermoData[specieNames[0]])
87 new ThermoType(*specieThermoData[species_[i]])
91 correctMassFractions();
95 template<class ThermoType>
96 Foam::multiComponentMixture<ThermoType>::multiComponentMixture
98 const dictionary& thermoDict,
102 basicMultiComponentMixture(thermoDict, thermoDict.lookup("species"), mesh),
103 speciesData_(species_.size()),
104 mixture_("mixture", constructSpeciesData(thermoDict))
106 correctMassFractions();
110 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
112 template<class ThermoType>
113 const ThermoType& Foam::multiComponentMixture<ThermoType>::cellMixture
118 mixture_ = Y_[0][celli]/speciesData_[0].W()*speciesData_[0];
120 for (label n=1; n<Y_.size(); n++)
122 mixture_ += Y_[n][celli]/speciesData_[n].W()*speciesData_[n];
129 template<class ThermoType>
130 const ThermoType& Foam::multiComponentMixture<ThermoType>::patchFaceMixture
137 Y_[0].boundaryField()[patchi][facei]
138 /speciesData_[0].W()*speciesData_[0];
140 for (label n=1; n<Y_.size(); n++)
143 Y_[n].boundaryField()[patchi][facei]
144 /speciesData_[n].W()*speciesData_[n];
151 template<class ThermoType>
152 void Foam::multiComponentMixture<ThermoType>::read
154 const dictionary& thermoDict
159 speciesData_[i] = ThermoType(thermoDict.subDict(species_[i]));
164 template<class ThermoType>
165 Foam::scalar Foam::multiComponentMixture<ThermoType>::nMoles
170 return speciesData_[specieI].nMoles();
174 template<class ThermoType>
175 Foam::scalar Foam::multiComponentMixture<ThermoType>::W
180 return speciesData_[specieI].W();
184 template<class ThermoType>
185 Foam::scalar Foam::multiComponentMixture<ThermoType>::Cp
191 return speciesData_[specieI].Cp(T);
195 template<class ThermoType>
196 Foam::scalar Foam::multiComponentMixture<ThermoType>::Cv
202 return speciesData_[specieI].Cv(T);
206 template<class ThermoType>
207 Foam::scalar Foam::multiComponentMixture<ThermoType>::H
213 return speciesData_[specieI].H(T);
217 template<class ThermoType>
218 Foam::scalar Foam::multiComponentMixture<ThermoType>::Hs
224 return speciesData_[specieI].Hs(T);
228 template<class ThermoType>
229 Foam::scalar Foam::multiComponentMixture<ThermoType>::Hc
234 return speciesData_[specieI].Hc();
238 template<class ThermoType>
239 Foam::scalar Foam::multiComponentMixture<ThermoType>::S
245 return speciesData_[specieI].S(T);
249 template<class ThermoType>
250 Foam::scalar Foam::multiComponentMixture<ThermoType>::E
256 return speciesData_[specieI].E(T);
260 template<class ThermoType>
261 Foam::scalar Foam::multiComponentMixture<ThermoType>::G
267 return speciesData_[specieI].G(T);
271 template<class ThermoType>
272 Foam::scalar Foam::multiComponentMixture<ThermoType>::A
278 return speciesData_[specieI].A(T);
282 template<class ThermoType>
283 Foam::scalar Foam::multiComponentMixture<ThermoType>::mu
289 return speciesData_[specieI].mu(T);
293 template<class ThermoType>
294 Foam::scalar Foam::multiComponentMixture<ThermoType>::kappa
300 return speciesData_[specieI].kappa(T);
304 template<class ThermoType>
305 Foam::scalar Foam::multiComponentMixture<ThermoType>::alpha
311 return speciesData_[specieI].alpha(T);
315 // ************************************************************************* //