|
| 1 | +/*---------------------------------------------------------------------------*\ |
| 2 | + ========= | |
| 3 | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| 4 | + \\ / O peration | |
| 5 | + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation |
| 6 | + \\/ M anipulation | |
| 7 | +------------------------------------------------------------------------------- |
| 8 | +License |
| 9 | + This file is part of OpenFOAM. |
| 10 | +
|
| 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. |
| 15 | +
|
| 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 |
| 19 | + for more details. |
| 20 | +
|
| 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/>. |
| 23 | +
|
| 24 | +\*---------------------------------------------------------------------------*/ |
| 25 | + |
| 26 | +#include "eddyDissipationModel.H" |
| 27 | +#include "turbulenceModel.H" |
| 28 | +#include "turbulentFluidThermoModel.H" |
| 29 | +#include "volFields.H" |
| 30 | + |
| 31 | +namespace Foam |
| 32 | +{ |
| 33 | +namespace combustionModels |
| 34 | +{ |
| 35 | + |
| 36 | +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // |
| 37 | + |
| 38 | +template<class ReactionThermo> |
| 39 | +eddyDissipationModel<ReactionThermo>::eddyDissipationModel |
| 40 | +( |
| 41 | + const word& modelType, |
| 42 | + ReactionThermo& thermo, |
| 43 | + const compressibleTurbulenceModel& turb, |
| 44 | + const word& combustionProperties |
| 45 | +) |
| 46 | +: |
| 47 | + singleStepCombustion<ReactionThermo> |
| 48 | + ( |
| 49 | + modelType, |
| 50 | + thermo, |
| 51 | + turb, |
| 52 | + combustionProperties |
| 53 | + ), |
| 54 | + C_(readScalar(this->coeffs().lookup("C_EDC"))), |
| 55 | + Cd_(readScalar(this->coeffs().lookup("C_Diff"))), |
| 56 | + Cstiff_(readScalar(this->coeffs().lookup("C_Stiff"))), |
| 57 | + PV_ |
| 58 | + ( |
| 59 | + IOobject |
| 60 | + ( |
| 61 | + "PV", |
| 62 | + this->mesh().time().timeName(), |
| 63 | + this->mesh(), |
| 64 | + IOobject::NO_READ, |
| 65 | + IOobject::AUTO_WRITE |
| 66 | + ), |
| 67 | + this->mesh(), |
| 68 | + dimensionedScalar("zero",dimless,1.0) |
| 69 | + ) |
| 70 | +{} |
| 71 | + |
| 72 | + |
| 73 | +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // |
| 74 | + |
| 75 | +template<class ReactionThermo> |
| 76 | +eddyDissipationModel<ReactionThermo>::~eddyDissipationModel() |
| 77 | +{} |
| 78 | + |
| 79 | + |
| 80 | +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // |
| 81 | + |
| 82 | +template<class ReactionThermo> |
| 83 | +Foam::tmp<Foam::volScalarField> |
| 84 | +eddyDissipationModel<ReactionThermo>::rtTurb() const |
| 85 | +{ |
| 86 | + return C_*this->turbulence().epsilon()/ |
| 87 | + max(this->turbulence().k(), |
| 88 | + dimensionedScalar("SMALL",dimVelocity*dimVelocity,SMALL)); |
| 89 | +} |
| 90 | + |
| 91 | +template<class ReactionThermo> |
| 92 | +Foam::tmp<Foam::volScalarField> |
| 93 | +eddyDissipationModel<ReactionThermo>::rtDiff() const |
| 94 | +{ |
| 95 | + const CanteraMixture& mixture_ = dynamic_cast<const CanteraMixture&>(this->thermo()); |
| 96 | + const volScalarField& YO2 = mixture_.Y("O2"); |
| 97 | + const compressible::LESModel& lesModel = |
| 98 | + YO2.db().lookupObject<compressible::LESModel> |
| 99 | + ( |
| 100 | + turbulenceModel::propertiesName |
| 101 | + ); |
| 102 | + |
| 103 | + return Cd_*this->thermo().alpha()/this->rho()/sqr(lesModel.delta()); |
| 104 | +} |
| 105 | + |
| 106 | +template<class ReactionThermo> |
| 107 | +void eddyDissipationModel<ReactionThermo>::correct() |
| 108 | +{ |
| 109 | + //- Set the product volume field, needed by alphat BC |
| 110 | + calcPV(); |
| 111 | + |
| 112 | + this->wFuel_ == |
| 113 | + dimensionedScalar("zero", dimMass/pow3(dimLength)/dimTime, 0.0); |
| 114 | + |
| 115 | + // if (this->active()) |
| 116 | + { |
| 117 | + CanteraMixture& mixture_ = dynamic_cast<CanteraMixture&>(this->thermo()); |
| 118 | + this->singleMixture_.fresCorrect(); |
| 119 | + |
| 120 | + const label fuelI = this->singleMixture_.fuelIndex(); |
| 121 | + |
| 122 | + const volScalarField& YFuel = mixture_.Y(fuelI); |
| 123 | + |
| 124 | + const dimensionedScalar s = this->singleMixture_.s(); |
| 125 | + |
| 126 | + if (mixture_.species().contains("O2")) |
| 127 | + { |
| 128 | + const volScalarField& YO2 = mixture_.Y("O2"); |
| 129 | + |
| 130 | +// this->wFuel_ == |
| 131 | +// this->rho()/(this->mesh().time().deltaT()*C_) |
| 132 | +// *min(YFuel, YO2/s.value()); |
| 133 | + |
| 134 | +/* |
| 135 | + this->wFuel_ == |
| 136 | + C_ |
| 137 | + * this->rho() |
| 138 | + * this->turbulence().epsilon() |
| 139 | + / max(this->turbulence().k(), |
| 140 | + dimensionedScalar("SMALL",dimVelocity*dimVelocity,SMALL)) |
| 141 | + * min(YFuel, YO2/s.value()); |
| 142 | +*/ |
| 143 | + |
| 144 | +/* |
| 145 | + this->wFuel_ == |
| 146 | + this->rho() |
| 147 | + * min(YFuel, YO2/s.value()) |
| 148 | + * max(rtTurb(),rtDiff()); |
| 149 | +*/ |
| 150 | + |
| 151 | + volScalarField rt(max(rtTurb(),rtDiff())); |
| 152 | + |
| 153 | + // clipping of wFuel to prevent negative HRR |
| 154 | + // this->wFuel_ == |
| 155 | + // this->rho() |
| 156 | + // * min(max(0*YFuel,YFuel), max(0*YO2,YO2)/s.value()) |
| 157 | + // / this->mesh_.time().deltaT() * |
| 158 | + // min(1./ Cstiff_* (1 - exp(- Cstiff_*this->mesh_.time().deltaT() * rt)),1.0); |
| 159 | + |
| 160 | + this->wFuel_ == |
| 161 | + this->rho() |
| 162 | + * min(YFuel, YO2/s.value()) |
| 163 | + / this->mesh_.time().deltaT() / Cstiff_ |
| 164 | + * (1 - exp(- Cstiff_*this->mesh_.time().deltaT() * rt)); |
| 165 | + } |
| 166 | + } |
| 167 | +} |
| 168 | + |
| 169 | + |
| 170 | +template<class ReactionThermo> |
| 171 | +bool eddyDissipationModel<ReactionThermo>::read() |
| 172 | +{ |
| 173 | + if (singleStepCombustion<ReactionThermo>::read()) |
| 174 | + { |
| 175 | + this->coeffs().lookup("C") >> C_ ; |
| 176 | + return true; |
| 177 | + } |
| 178 | + else |
| 179 | + { |
| 180 | + return false; |
| 181 | + } |
| 182 | +} |
| 183 | + |
| 184 | +template<class ReactionThermo> |
| 185 | +label eddyDissipationModel<ReactionThermo>::getParameter() const |
| 186 | +{ |
| 187 | + return 123; |
| 188 | +} |
| 189 | + |
| 190 | +template<class ReactionThermo> |
| 191 | +void eddyDissipationModel<ReactionThermo>::calcPV() |
| 192 | +{ |
| 193 | + CanteraMixture& mixture_ = dynamic_cast<CanteraMixture&>(this->thermo()); |
| 194 | + //- Get species mass fraction |
| 195 | + const label fuelI = this->singleMixture_.fuelIndex(); |
| 196 | + const volScalarField& YFuel = mixture_.Y(fuelI); |
| 197 | + const volScalarField& YO2 = mixture_.Y("O2"); |
| 198 | + const volScalarField& YCO2 = mixture_.Y("CO2"); |
| 199 | + |
| 200 | + const dimensionedScalar s = this->singleMixture_.s(); |
| 201 | + |
| 202 | + //- Get Mspecies/Mfuel from reaction equation |
| 203 | + scalar rCO2(this->singleMixture_.specieStoichCoeffs() |
| 204 | + [mixture_.species()["CO2"]]); |
| 205 | + scalar rH2O(this->singleMixture_.specieStoichCoeffs() |
| 206 | + [mixture_.species()["H2O"]]); |
| 207 | + |
| 208 | + PV_ = (YCO2*(1.0+rH2O/rCO2)+SMALL)/(YCO2*(1.0+rH2O/rCO2)+SMALL + min(YFuel,YO2/s.value())*(1.0+s.value())); |
| 209 | + |
| 210 | + return; |
| 211 | +} |
| 212 | + |
| 213 | +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // |
| 214 | + |
| 215 | +} // End namespace combustionModels |
| 216 | +} // End namespace Foam |
| 217 | + |
| 218 | +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // |
0 commit comments