FreeFOAM The Cross-Platform CFD Toolkit
blobsSwirlInjector.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 "blobsSwirlInjector.H"
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 
35 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 
37 defineTypeNameAndDebug(blobsSwirlInjector, 0);
38 
40 (
41  injectorModel,
42  blobsSwirlInjector,
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  blobsSwirlInjectorDict_(dict.subDict(typeName + "Coeffs")),
58 
59  coneAngle_(blobsSwirlInjectorDict_.lookup("ConeAngle")),
60  coneInterval_(blobsSwirlInjectorDict_.lookup("ConeInterval")),
61 
62  cD_(blobsSwirlInjectorDict_.lookup("cD")),
63  cTau_(blobsSwirlInjectorDict_.lookup("cTau")),
64  A_(blobsSwirlInjectorDict_.lookup("A")),
65 
66  angle_(0.0),
67  u_(0.0),
68  x_(0.0),
69  h_(0.0)
70 {
71 
72  if (sm.injectors().size() != coneAngle_.size())
73  {
74  FatalError << "blobsSwirlInjector::blobsSwirlInjector"
75  << "(const dictionary& dict, spray& sm)\n"
76  << "Wrong number of entries in innerAngle"
77  << abort(FatalError);
78  }
79 
80  scalar referencePressure = sm.p().average().value();
81 
82  // correct velocityProfile
83  forAll(sm.injectors(), i)
84  {
85  sm.injectors()[i].properties()->correctProfiles(sm.fuels(), referencePressure);
86  }
87 
88 }
89 
90 
91 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
92 
94 {}
95 
96 
97 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
98 
100 (
101  const label n,
102  const scalar t
103 ) const
104 {
105  const injectorType& it = injectors_[n].properties();
106 
107  scalar c = rndGen_.scalar01();
108 
109  angle_ = coneAngle_[n]/2.0 + c * coneInterval_[n];
110 
111  angle_ *= mathematicalConstant::pi/180.0;
112 
113  scalar injectedMassFlow = it.massFlowRate(t);
114 
115  scalar cosAngle = cos(angle_);
116 
117  scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), it.T(t), it.X());
118 
119  scalar deltaPressure = deltaPressureInj(t,n);
120 
121  calculateHX(n, injectedMassFlow, deltaPressure, t);
122 
123  scalar kV = kv(n);
124 
125  scalar v = kV * sqrt(2.0*deltaPressure/rhoFuel);
126 
127  u_ = v * cosAngle;
128 
129  return h_;
130 
131 }
132 
134 (
135  const label n,
136  const label hole,
137  const scalar time,
138  const scalar d
139 ) const
140 {
141 
142  scalar alpha = sin(angle_);
143  scalar dcorr = cos(angle_);
144  scalar beta = 2.0*mathematicalConstant::pi*rndGen_.scalar01();
145 
146  // randomly distributed vector normal to the injection vector
148 
149  if (sm_.twoD())
150  {
151  scalar reduce = 0.01;
152  // correct beta if this is a 2D run
153  // map it onto the 'angleOfWedge'
154 
155  beta *= (1.0-2.0*reduce)*sm_.angleOfWedge()/(2.0*mathematicalConstant::pi);
156  beta += reduce*sm_.angleOfWedge();
157  normal = alpha*
158  (
159  sm_.axisOfWedge()*cos(beta) +
160  sm_.axisOfWedgeNormal()*sin(beta)
161  );
162  }
163  else
164  {
165  normal = alpha*
166  (
167  injectors_[n].properties()->tan1(hole)*cos(beta) +
168  injectors_[n].properties()->tan2(hole)*sin(beta)
169  );
170  }
171 
172  // set the direction of injection by adding the normal vector
173  vector dir = dcorr*injectors_[n].properties()->direction(hole, time) + normal;
174  dir /= mag(dir);
175 
176  return dir;
177 }
178 
179 
181 (
182  const label i,
183  const scalar time
184 ) const
185 {
186  return u_*sqrt(1.0 + pow(tan(angle_),2.0));
187 }
188 
190 (
191  const label i
192 ) const
193 {
194 
195  const injectorType& it = sm_.injectors()[i].properties();
196 
197  scalar dt = it.teoi() - it.tsoi();
198 
199 
200  scalar injectionPressure = averagePressure(i);
201 
202  scalar Tav = it.integrateTable(it.T())/dt;
203  scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), Tav, it.X());
204 
205  scalar kV = kv(i);
206 
207  return kV*sqrt(2.0*(injectionPressure-sm_.ambientPressure())/rhoFuel);
208 
209 }
210 
211 
212 scalar blobsSwirlInjector::kv
213 (
214  const label inj
215 ) const
216 {
217  return cD_[inj]/cos(angle_) * sqrt((1.0 - x_)/(1.0 + x_));
218 }
219 
220 void blobsSwirlInjector::calculateHX
221 (
222  const label inj,
223  const scalar massFlow,
224  const scalar dPressure,
225  const scalar time
226 ) const
227 {
228 
229  const injectorType& it = injectors_[inj].properties();
230 
231  scalar Tfuel = it.T(time);
232  scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), Tfuel, it.X());
233  scalar muFuel = sm_.fuels().mu(sm_.ambientPressure(), Tfuel, it.X());
234  scalar injectorDiameter = it.d();
235 
236  x_ = 0.0;
237 
238  h_ =
239  sqrt
240  (
241  (
242  A_[inj] *
243  cTau_[inj] *
244  muFuel*
245  massFlow*
246  (1.0 + x_)
247  )
248  /
249  (
251  injectorDiameter*
252  rhoFuel*
253  dPressure*
254  sqr(1.0 - x_)
255  )
256  );
257 
258  scalar hOLD = -100.0;
259  scalar xOLD = -100.0;
260 
261  label i;
262 
263  for(i=0; i<20; i++)
264  {
265 
266 
267  h_ =
268  sqrt
269  (
270  (
271  A_[inj] *
272  cTau_[inj] *
273  muFuel*
274  massFlow*
275  (1.0 + x_)
276  )
277  /
278  (
280  injectorDiameter*
281  rhoFuel*
282  dPressure*
283  sqr(1.0 - x_)
284  )
285  );
286 
287  x_ = sqr(1.0 - 2.0 * h_/injectorDiameter);
288 
289  hOLD = h_;
290  xOLD = x_;
291 
292  }
293 
294  x_ = sqr(1.0 - 2.0 * h_/injectorDiameter);
295 
296 }
297 
298 
299 
300 scalar blobsSwirlInjector::deltaPressureInj(const scalar time, const label inj) const
301 {
302  return injectors_[inj].properties()->injectionPressure(time) - sm_.ambientPressure();
303 }
304 
305 scalar blobsSwirlInjector::averagePressure(const label inj) const
306 {
307 
308  const injectorType& it = sm_.injectors()[inj].properties();
309 
310  scalar dt = it.teoi() - it.tsoi();
311  return it.integrateTable(it.injectionPressureProfile())/dt;
312 }
313 
314 } // End namespace Foam
315 
316 // ************************ vim: set sw=4 sts=4 et: ************************ //