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 "pressureSwirlInjector.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "mathematicalConstants.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 defineTypeNameAndDebug(pressureSwirlInjector, 0);
40 addToRunTimeSelectionTable
43 pressureSwirlInjector,
48 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 // Construct from components
51 pressureSwirlInjector::pressureSwirlInjector
53 const dictionary& dict,
57 injectorModel(dict, sm),
58 pressureSwirlInjectorDict_(dict.subDict(typeName + "Coeffs")),
60 coneAngle_(pressureSwirlInjectorDict_.lookup("ConeAngle")),
61 coneInterval_(pressureSwirlInjectorDict_.lookup("ConeInterval")),
62 maxKv_(pressureSwirlInjectorDict_.lookup("maxKv")),
67 if (sm.injectors().size() != coneAngle_.size())
69 FatalError << "pressureSwirlInjector::pressureSwirlInjector"
70 << "(const dictionary& dict, spray& sm)\n"
71 << "Wrong number of entries in innerAngle"
75 scalar referencePressure = sm.p().average().value();
77 // correct velocityProfile
78 forAll(sm.injectors(), i)
80 sm.injectors()[i].properties()->correctProfiles(sm.fuels(), referencePressure);
86 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
88 pressureSwirlInjector::~pressureSwirlInjector()
92 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
94 scalar pressureSwirlInjector::d0
100 const injectorType& it = injectors_[n].properties();
102 scalar c = rndGen_.scalar01();
103 angle_ = coneAngle_[n] + 2.0 * coneInterval_[n] * (0.5 - c) ;
105 angle_ *= mathematicalConstant::pi/360.0;
107 scalar injectedMassFlow = it.massFlowRate(t);
109 scalar cosAngle = cos(angle_);
111 scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), it.T(t), it.X());
112 scalar injectorDiameter = it.d();
114 scalar deltaPressure = deltaPressureInj(t,n);
115 scalar kV = kv(n, injectedMassFlow, deltaPressure);
116 scalar v = kV * sqrt(2.0*deltaPressure/rhoFuel);
120 scalar A = injectedMassFlow/(mathematicalConstant::pi*rhoFuel*u_);
122 return (injectorDiameter-sqrt(pow(injectorDiameter,2)-4.0*A))/2.0;
125 vector pressureSwirlInjector::direction
134 scalar alpha = sin(angle_);
135 scalar dcorr = cos(angle_);
136 scalar beta = 2.0*mathematicalConstant::pi*rndGen_.scalar01();
138 // randomly distributed vector normal to the injection vector
139 vector normal = vector::zero;
143 scalar reduce = 0.01;
144 // correct beta if this is a 2D run
145 // map it onto the 'angleOfWedge'
147 beta *= (1.0-2.0*reduce)*sm_.angleOfWedge()/(2.0*mathematicalConstant::pi);
148 beta += reduce*sm_.angleOfWedge();
151 sm_.axisOfWedge()*cos(beta) +
152 sm_.axisOfWedgeNormal()*sin(beta)
159 injectors_[n].properties()->tan1(hole)*cos(beta) +
160 injectors_[n].properties()->tan2(hole)*sin(beta)
164 // set the direction of injection by adding the normal vector
165 vector dir = dcorr*injectors_[n].properties()->direction(hole, time) + normal;
172 scalar pressureSwirlInjector::velocity
178 return u_*sqrt(1.0 + pow(tan(angle_),2.0));
181 scalar pressureSwirlInjector::averageVelocity
187 const injectorType& it = sm_.injectors()[i].properties();
189 scalar dt = it.teoi() - it.tsoi();
191 scalar injectedMassFlow = it.mass()/(it.teoi()-it.tsoi());
193 scalar injectionPressure = averagePressure(i);
195 scalar Tav = it.integrateTable(it.T())/dt;
196 scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), Tav, it.X());
198 scalar kV = kv(i, injectedMassFlow, injectionPressure);
200 return kV*sqrt(2.0*(injectionPressure-sm_.ambientPressure())/rhoFuel);
204 scalar pressureSwirlInjector::kv
207 const scalar massFlow,
208 const scalar dPressure
212 const injectorType& it = injectors_[inj].properties();
214 scalar coneAngle = coneAngle_[inj];
216 coneAngle *= mathematicalConstant::pi/360.0;
218 scalar cosAngle = cos(coneAngle);
219 scalar Tav = it.integrateTable(it.T())/(it.teoi()-it.tsoi());
221 scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), Tav, it.X());
222 scalar injectorDiameter = it.d();
229 sqrt(rhoFuel/2.0/dPressure)
231 (mathematicalConstant::pi*pow(injectorDiameter, 2.0)*rhoFuel*cosAngle)
240 scalar pressureSwirlInjector::deltaPressureInj(const scalar time, const label inj) const
242 return injectors_[inj].properties()->injectionPressure(time) - sm_.ambientPressure();
245 scalar pressureSwirlInjector::averagePressure(const label inj) const
248 const injectorType& it = sm_.injectors()[inj].properties();
250 scalar dt = it.teoi() - it.tsoi();
251 return it.integrateTable(it.injectionPressureProfile())/dt;
254 } // End namespace Foam
256 // ************************************************************************* //