FreeFOAM The Cross-Platform CFD Toolkit
pressureSwirlInjector.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
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 "pressureSwirlInjector.H"
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 
35 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 
37 defineTypeNameAndDebug(pressureSwirlInjector, 0);
38 
40 (
41  injectorModel,
42  pressureSwirlInjector,
43  dictionary
44 );
45 
46 
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 
49 // Construct from components
51 (
52  const dictionary& dict,
53  spray& sm
54 )
55 :
56  injectorModel(dict, sm),
57  pressureSwirlInjectorDict_(dict.subDict(typeName + "Coeffs")),
58 
59  coneAngle_(pressureSwirlInjectorDict_.lookup("ConeAngle")),
60  coneInterval_(pressureSwirlInjectorDict_.lookup("ConeInterval")),
61  maxKv_(pressureSwirlInjectorDict_.lookup("maxKv")),
62 
63  angle_(0.0)
64 {
65 
66  if (sm.injectors().size() != coneAngle_.size())
67  {
68  FatalError << "pressureSwirlInjector::pressureSwirlInjector"
69  << "(const dictionary& dict, spray& sm)\n"
70  << "Wrong number of entries in innerAngle"
71  << abort(FatalError);
72  }
73 
74  scalar referencePressure = sm.p().average().value();
75 
76  // correct velocityProfile
77  forAll(sm.injectors(), i)
78  {
79  sm.injectors()[i].properties()->correctProfiles(sm.fuels(), referencePressure);
80  }
81 
82 }
83 
84 
85 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
86 
88 {}
89 
90 
91 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
92 
94 (
95  const label n,
96  const scalar t
97 ) const
98 {
99  const injectorType& it = injectors_[n].properties();
100 
101  scalar c = rndGen_.scalar01();
102  angle_ = coneAngle_[n] + 2.0 * coneInterval_[n] * (0.5 - c) ;
103 
104  angle_ *= mathematicalConstant::pi/360.0;
105 
106  scalar injectedMassFlow = it.massFlowRate(t);
107 
108  scalar cosAngle = cos(angle_);
109 
110  scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), it.T(t), it.X());
111  scalar injectorDiameter = it.d();
112 
113  scalar deltaPressure = deltaPressureInj(t,n);
114  scalar kV = kv(n, injectedMassFlow, deltaPressure);
115  scalar v = kV * sqrt(2.0*deltaPressure/rhoFuel);
116 
117  u_ = v * cosAngle;
118 
119  scalar A = injectedMassFlow/(mathematicalConstant::pi*rhoFuel*u_);
120 
121  return (injectorDiameter-sqrt(pow(injectorDiameter,2)-4.0*A))/2.0;
122 }
123 
125 (
126  const label n,
127  const label hole,
128  const scalar time,
129  const scalar d
130 ) const
131 {
132 
133  scalar alpha = sin(angle_);
134  scalar dcorr = cos(angle_);
135  scalar beta = 2.0*mathematicalConstant::pi*rndGen_.scalar01();
136 
137  // randomly distributed vector normal to the injection vector
139 
140  if (sm_.twoD())
141  {
142  scalar reduce = 0.01;
143  // correct beta if this is a 2D run
144  // map it onto the 'angleOfWedge'
145 
146  beta *= (1.0-2.0*reduce)*sm_.angleOfWedge()/(2.0*mathematicalConstant::pi);
147  beta += reduce*sm_.angleOfWedge();
148  normal = alpha*
149  (
150  sm_.axisOfWedge()*cos(beta) +
151  sm_.axisOfWedgeNormal()*sin(beta)
152  );
153  }
154  else
155  {
156  normal = alpha*
157  (
158  injectors_[n].properties()->tan1(hole)*cos(beta) +
159  injectors_[n].properties()->tan2(hole)*sin(beta)
160  );
161  }
162 
163  // set the direction of injection by adding the normal vector
164  vector dir = dcorr*injectors_[n].properties()->direction(hole, time) + normal;
165  dir /= mag(dir);
166 
167  return dir;
168 }
169 
170 
172 (
173  const label i,
174  const scalar time
175 ) const
176 {
177  return u_*sqrt(1.0 + pow(tan(angle_),2.0));
178 }
179 
181 (
182  const label i
183 ) const
184 {
185 
186  const injectorType& it = sm_.injectors()[i].properties();
187 
188  scalar dt = it.teoi() - it.tsoi();
189 
190  scalar injectedMassFlow = it.mass()/(it.teoi()-it.tsoi());
191 
192  scalar injectionPressure = averagePressure(i);
193 
194  scalar Tav = it.integrateTable(it.T())/dt;
195  scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), Tav, it.X());
196 
197  scalar kV = kv(i, injectedMassFlow, injectionPressure);
198 
199  return kV*sqrt(2.0*(injectionPressure-sm_.ambientPressure())/rhoFuel);
200 }
201 
202 
203 scalar pressureSwirlInjector::kv
204 (
205  const label inj,
206  const scalar massFlow,
207  const scalar dPressure
208 ) const
209 {
210 
211  const injectorType& it = injectors_[inj].properties();
212 
213  scalar coneAngle = coneAngle_[inj];
214 
215  coneAngle *= mathematicalConstant::pi/360.0;
216 
217  scalar cosAngle = cos(coneAngle);
218  scalar Tav = it.integrateTable(it.T())/(it.teoi()-it.tsoi());
219 
220  scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), Tav, it.X());
221  scalar injectorDiameter = it.d();
222 
223  scalar kv = max
224  (
225  maxKv_[inj],
226  4.0*massFlow
227  *
228  sqrt(rhoFuel/2.0/dPressure)
229  /
230  (mathematicalConstant::pi*pow(injectorDiameter, 2.0)*rhoFuel*cosAngle)
231  );
232 
233  return min(1.0, kv);
234 }
235 
236 
237 
238 
239 scalar pressureSwirlInjector::deltaPressureInj(const scalar time, const label inj) const
240 {
241  return injectors_[inj].properties()->injectionPressure(time) - sm_.ambientPressure();
242 }
243 
244 scalar pressureSwirlInjector::averagePressure(const label inj) const
245 {
246 
247  const injectorType& it = sm_.injectors()[inj].properties();
248 
249  scalar dt = it.teoi() - it.tsoi();
250  return it.integrateTable(it.injectionPressureProfile())/dt;
251 }
252 
253 } // End namespace Foam
254 
255 // ************************ vim: set sw=4 sts=4 et: ************************ //