1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "blobsSwirlInjector.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "mathematicalConstants.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 defineTypeNameAndDebug(blobsSwirlInjector, 0);
40 addToRunTimeSelectionTable
48 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 // Construct from components
51 blobsSwirlInjector::blobsSwirlInjector
53 const dictionary& dict,
57 injectorModel(dict, sm),
58 blobsSwirlInjectorDict_(dict.subDict(typeName + "Coeffs")),
60 coneAngle_(blobsSwirlInjectorDict_.lookup("ConeAngle")),
61 coneInterval_(blobsSwirlInjectorDict_.lookup("ConeInterval")),
63 cD_(blobsSwirlInjectorDict_.lookup("cD")),
64 cTau_(blobsSwirlInjectorDict_.lookup("cTau")),
65 A_(blobsSwirlInjectorDict_.lookup("A")),
73 if (sm.injectors().size() != coneAngle_.size())
75 FatalError << "blobsSwirlInjector::blobsSwirlInjector"
76 << "(const dictionary& dict, spray& sm)\n"
77 << "Wrong number of entries in innerAngle"
81 scalar referencePressure = sm.p().average().value();
83 // correct velocityProfile
84 forAll(sm.injectors(), i)
86 sm.injectors()[i].properties()->correctProfiles(sm.fuels(), referencePressure);
92 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
94 blobsSwirlInjector::~blobsSwirlInjector()
98 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
100 scalar blobsSwirlInjector::d0
106 const injectorType& it = injectors_[n].properties();
108 scalar c = rndGen_.scalar01();
110 angle_ = coneAngle_[n]/2.0 + c * coneInterval_[n];
112 angle_ *= mathematicalConstant::pi/180.0;
114 scalar injectedMassFlow = it.massFlowRate(t);
116 scalar cosAngle = cos(angle_);
118 scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), it.T(t), it.X());
120 scalar deltaPressure = deltaPressureInj(t,n);
122 calculateHX(n, injectedMassFlow, deltaPressure, t);
126 scalar v = kV * sqrt(2.0*deltaPressure/rhoFuel);
134 vector blobsSwirlInjector::direction
143 scalar alpha = sin(angle_);
144 scalar dcorr = cos(angle_);
145 scalar beta = 2.0*mathematicalConstant::pi*rndGen_.scalar01();
147 // randomly distributed vector normal to the injection vector
148 vector normal = vector::zero;
152 scalar reduce = 0.01;
153 // correct beta if this is a 2D run
154 // map it onto the 'angleOfWedge'
156 beta *= (1.0-2.0*reduce)*sm_.angleOfWedge()/(2.0*mathematicalConstant::pi);
157 beta += reduce*sm_.angleOfWedge();
160 sm_.axisOfWedge()*cos(beta) +
161 sm_.axisOfWedgeNormal()*sin(beta)
168 injectors_[n].properties()->tan1(hole)*cos(beta) +
169 injectors_[n].properties()->tan2(hole)*sin(beta)
173 // set the direction of injection by adding the normal vector
174 vector dir = dcorr*injectors_[n].properties()->direction(hole, time) + normal;
181 scalar blobsSwirlInjector::velocity
187 return u_*sqrt(1.0 + pow(tan(angle_),2.0));
190 scalar blobsSwirlInjector::averageVelocity
196 const injectorType& it = sm_.injectors()[i].properties();
198 scalar dt = it.teoi() - it.tsoi();
201 scalar injectionPressure = averagePressure(i);
203 scalar Tav = it.integrateTable(it.T())/dt;
204 scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), Tav, it.X());
208 return kV*sqrt(2.0*(injectionPressure-sm_.ambientPressure())/rhoFuel);
213 scalar blobsSwirlInjector::kv
218 return cD_[inj]/cos(angle_) * sqrt((1.0 - x_)/(1.0 + x_));
221 void blobsSwirlInjector::calculateHX
224 const scalar massFlow,
225 const scalar dPressure,
230 const injectorType& it = injectors_[inj].properties();
232 scalar Tfuel = it.T(time);
233 scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), Tfuel, it.X());
234 scalar muFuel = sm_.fuels().mu(sm_.ambientPressure(), Tfuel, it.X());
235 scalar injectorDiameter = it.d();
251 mathematicalConstant::pi*
259 scalar hOLD = -100.0;
260 scalar xOLD = -100.0;
280 mathematicalConstant::pi*
288 x_ = sqr(1.0 - 2.0 * h_/injectorDiameter);
295 x_ = sqr(1.0 - 2.0 * h_/injectorDiameter);
301 scalar blobsSwirlInjector::deltaPressureInj(const scalar time, const label inj) const
303 return injectors_[inj].properties()->injectionPressure(time) - sm_.ambientPressure();
306 scalar blobsSwirlInjector::averagePressure(const label inj) const
309 const injectorType& it = sm_.injectors()[inj].properties();
311 scalar dt = it.teoi() - it.tsoi();
312 return it.integrateTable(it.injectionPressureProfile())/dt;
315 } // End namespace Foam
317 // ************************************************************************* //