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 "blobsSwirlInjector.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "unitConversion.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 defineTypeNameAndDebug(blobsSwirlInjector, 0);
36 addToRunTimeSelectionTable
45 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47 Foam::blobsSwirlInjector::blobsSwirlInjector
49 const dictionary& dict,
53 injectorModel(dict, sm),
54 blobsSwirlInjectorDict_(dict.subDict(typeName + "Coeffs")),
56 coneAngle_(blobsSwirlInjectorDict_.lookup("ConeAngle")),
57 coneInterval_(blobsSwirlInjectorDict_.lookup("ConeInterval")),
59 cD_(blobsSwirlInjectorDict_.lookup("cD")),
60 cTau_(blobsSwirlInjectorDict_.lookup("cTau")),
61 A_(blobsSwirlInjectorDict_.lookup("A")),
69 if (sm.injectors().size() != coneAngle_.size())
72 << "blobsSwirlInjector::blobsSwirlInjector"
73 << "(const dictionary& dict, spray& sm)\n"
74 << "Wrong number of entries in innerAngle"
78 scalar referencePressure = sm.p().average().value();
80 // correct velocityProfile
81 forAll(sm.injectors(), i)
83 sm.injectors()[i].properties()->correctProfiles
92 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
94 Foam::blobsSwirlInjector::~blobsSwirlInjector()
98 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
100 Foam::scalar Foam::blobsSwirlInjector::d0
106 const injectorType& it = injectors_[n].properties();
108 scalar c = rndGen_.sample01<scalar>();
110 angle_ = degToRad(coneAngle_[n]/2.0 + c*coneInterval_[n]);
112 scalar injectedMassFlow = it.massFlowRate(t);
114 scalar cosAngle = cos(angle_);
116 scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), it.T(t), it.X());
118 scalar deltaPressure = deltaPressureInj(t,n);
120 calculateHX(n, injectedMassFlow, deltaPressure, t);
124 scalar v = kV*sqrt(2.0*deltaPressure/rhoFuel);
132 Foam::vector Foam::blobsSwirlInjector::direction
140 scalar alpha = sin(angle_);
141 scalar dcorr = cos(angle_);
142 scalar beta = constant::mathematical::twoPi*rndGen_.sample01<scalar>();
144 // randomly distributed vector normal to the injection vector
145 vector normal = vector::zero;
149 scalar reduce = 0.01;
150 // correct beta if this is a 2D run
151 // map it onto the 'angleOfWedge'
156 /(constant::mathematical::twoPi);
157 beta += reduce*sm_.angleOfWedge();
161 sm_.axisOfWedge()*cos(beta)
162 + sm_.axisOfWedgeNormal()*sin(beta)
170 injectors_[n].properties()->tan1(hole)*cos(beta)
171 + injectors_[n].properties()->tan2(hole)*sin(beta)
175 // set the direction of injection by adding the normal vector
177 dcorr*injectors_[n].properties()->direction(hole, time)
185 Foam::scalar Foam::blobsSwirlInjector::velocity
191 return u_*sqrt(1.0 + pow(tan(angle_),2.0));
195 Foam::scalar Foam::blobsSwirlInjector::averageVelocity(const label i) const
197 const injectorType& it = sm_.injectors()[i].properties();
199 scalar dt = it.teoi() - it.tsoi();
202 scalar injectionPressure = averagePressure(i);
204 scalar Tav = it.integrateTable(it.T())/dt;
205 scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), Tav, it.X());
209 return kV*sqrt(2.0*(injectionPressure-sm_.ambientPressure())/rhoFuel);
213 Foam::scalar Foam::blobsSwirlInjector::kv(const label inj) const
215 return cD_[inj]/cos(angle_) * sqrt((1.0 - x_)/(1.0 + x_));
219 void Foam::blobsSwirlInjector::calculateHX
222 const scalar massFlow,
223 const scalar dPressure,
227 const injectorType& it = injectors_[inj].properties();
229 scalar Tfuel = it.T(time);
230 scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), Tfuel, it.X());
231 scalar muFuel = sm_.fuels().mu(sm_.ambientPressure(), Tfuel, it.X());
232 scalar injectorDiameter = it.d();
239 (A_[inj]*cTau_[inj]*muFuel*massFlow*(1.0 + x_))
241 constant::mathematical::pi
256 (A_[inj]*cTau_[inj]*muFuel*massFlow*(1.0 + x_))
258 constant::mathematical::pi
266 x_ = sqr(1.0 - 2.0*h_/injectorDiameter);
269 x_ = sqr(1.0 - 2.0*h_/injectorDiameter);
273 Foam::scalar Foam::blobsSwirlInjector::deltaPressureInj
280 injectors_[inj].properties()->injectionPressure(time)
281 - sm_.ambientPressure();
285 Foam::scalar Foam::blobsSwirlInjector::averagePressure(const label inj) const
287 const injectorType& it = sm_.injectors()[inj].properties();
289 scalar dt = it.teoi() - it.tsoi();
290 return it.integrateTable(it.injectionPressureProfile())/dt;
294 // ************************************************************************* //