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 "pressureSwirlInjector.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "mathematicalConstants.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 defineTypeNameAndDebug(pressureSwirlInjector, 0);
36 addToRunTimeSelectionTable
39 pressureSwirlInjector,
45 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47 Foam::pressureSwirlInjector::pressureSwirlInjector
49 const dictionary& dict,
53 injectorModel(dict, sm),
54 pressureSwirlInjectorDict_(dict.subDict(typeName + "Coeffs")),
56 coneAngle_(pressureSwirlInjectorDict_.lookup("ConeAngle")),
57 coneInterval_(pressureSwirlInjectorDict_.lookup("ConeInterval")),
58 maxKv_(pressureSwirlInjectorDict_.lookup("maxKv")),
63 if (sm.injectors().size() != coneAngle_.size())
67 "pressureSwirlInjector::pressureSwirlInjector"
68 "(const dictionary& dict, spray& sm)"
69 ) << "Wrong number of entries in innerAngle" << nl
73 scalar referencePressure = sm.p().average().value();
75 // correct velocityProfile
76 forAll(sm.injectors(), i)
78 sm.injectors()[i].properties()->correctProfiles
87 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
89 Foam::pressureSwirlInjector::~pressureSwirlInjector()
93 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
95 Foam::scalar Foam::pressureSwirlInjector::d0
101 const injectorType& it = injectors_[n].properties();
103 scalar c = rndGen_.sample01<scalar>();
104 angle_ = coneAngle_[n] + 2.0*coneInterval_[n]*(0.5 - c);
106 angle_ *= constant::mathematical::pi/360.0;
108 scalar injectedMassFlow = it.massFlowRate(t);
110 scalar cosAngle = cos(angle_);
112 scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), it.T(t), it.X());
113 scalar injectorDiameter = it.d();
115 scalar deltaPressure = deltaPressureInj(t,n);
116 scalar kV = kv(n, injectedMassFlow, deltaPressure);
117 scalar v = kV*sqrt(2.0*deltaPressure/rhoFuel);
121 scalar A = injectedMassFlow/(constant::mathematical::pi*rhoFuel*u_);
123 return (injectorDiameter-sqrt(pow(injectorDiameter,2)-4.0*A))/2.0;
127 Foam::vector Foam::pressureSwirlInjector::direction
135 scalar alpha = sin(angle_);
136 scalar dcorr = cos(angle_);
137 scalar beta = constant::mathematical::twoPi*rndGen_.sample01<scalar>();
139 // randomly distributed vector normal to the injection vector
140 vector normal = vector::zero;
144 scalar reduce = 0.01;
145 // correct beta if this is a 2D run
146 // map it onto the 'angleOfWedge'
151 /(constant::mathematical::twoPi);
152 beta += reduce*sm_.angleOfWedge();
156 sm_.axisOfWedge()*cos(beta)
157 + sm_.axisOfWedgeNormal()*sin(beta)
165 injectors_[n].properties()->tan1(hole)*cos(beta)
166 + injectors_[n].properties()->tan2(hole)*sin(beta)
170 // set the direction of injection by adding the normal vector
172 dcorr*injectors_[n].properties()->direction(hole, time) + normal;
179 Foam::scalar Foam::pressureSwirlInjector::velocity
185 return u_*sqrt(1.0 + pow(tan(angle_),2.0));
189 Foam::scalar Foam::pressureSwirlInjector::averageVelocity(const label i) const
191 const injectorType& it = sm_.injectors()[i].properties();
193 scalar dt = it.teoi() - it.tsoi();
195 scalar injectedMassFlow = it.mass()/(it.teoi()-it.tsoi());
197 scalar injectionPressure = averagePressure(i);
199 scalar Tav = it.integrateTable(it.T())/dt;
200 scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), Tav, it.X());
202 scalar kV = kv(i, injectedMassFlow, injectionPressure);
204 return kV*sqrt(2.0*(injectionPressure-sm_.ambientPressure())/rhoFuel);
208 Foam::scalar Foam::pressureSwirlInjector::kv
211 const scalar massFlow,
212 const scalar dPressure
215 const injectorType& it = injectors_[inj].properties();
217 scalar coneAngle = coneAngle_[inj];
219 coneAngle *= constant::mathematical::pi/360.0;
221 scalar cosAngle = cos(coneAngle);
222 scalar Tav = it.integrateTable(it.T())/(it.teoi()-it.tsoi());
224 scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), Tav, it.X());
225 scalar injectorDiameter = it.d();
231 *sqrt(rhoFuel/2.0/dPressure)
232 /(constant::mathematical::pi*sqr(injectorDiameter)*rhoFuel*cosAngle)
239 Foam::scalar Foam::pressureSwirlInjector::deltaPressureInj
246 injectors_[inj].properties()->injectionPressure(time)
247 - sm_.ambientPressure();
251 Foam::scalar Foam::pressureSwirlInjector::averagePressure(const label inj) const
254 const injectorType& it = sm_.injectors()[inj].properties();
256 scalar dt = it.teoi() - it.tsoi();
257 return it.integrateTable(it.injectionPressureProfile())/dt;
261 // ************************************************************************* //