initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / lagrangian / dieselSpray / spraySubModels / injectorModel / blobsSwirl / blobsSwirlInjector.C
blob7bf6571e178d941f6a875500c86563303ccb9158
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 namespace Foam
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 defineTypeNameAndDebug(blobsSwirlInjector, 0);
40 addToRunTimeSelectionTable
42     injectorModel,
43     blobsSwirlInjector,
44     dictionary
48 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
50 // Construct from components
51 blobsSwirlInjector::blobsSwirlInjector
53     const dictionary& dict,
54     spray& sm
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")),
66     
67     angle_(0.0),
68     u_(0.0),
69     x_(0.0),
70     h_(0.0)
73     if (sm.injectors().size() != coneAngle_.size())
74     {
75         FatalError << "blobsSwirlInjector::blobsSwirlInjector"
76             << "(const dictionary& dict, spray& sm)\n"
77             << "Wrong number of entries in innerAngle"
78             << abort(FatalError);
79     }
81     scalar referencePressure = sm.p().average().value();
83     // correct velocityProfile
84     forAll(sm.injectors(), i)
85     {
86         sm.injectors()[i].properties()->correctProfiles(sm.fuels(), referencePressure);
87     }
92 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
94 blobsSwirlInjector::~blobsSwirlInjector()
98 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
100 scalar blobsSwirlInjector::d0
102     const label n, 
103     const scalar t
104 ) const
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);
115     
116     scalar cosAngle = cos(angle_);   
118     scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), it.T(t), it.X()); 
119      
120     scalar deltaPressure = deltaPressureInj(t,n);
122     calculateHX(n, injectedMassFlow, deltaPressure, t);
123     
124     scalar kV = kv(n);
125     
126     scalar v = kV * sqrt(2.0*deltaPressure/rhoFuel);    
128     u_ = v * cosAngle;
129     
130     return h_;
131     
134 vector blobsSwirlInjector::direction
136     const label n,
137     const label hole,
138     const scalar time,
139     const scalar d
140 ) const
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;
149     
150     if (sm_.twoD())
151     {
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();
158         normal = alpha*
159         (
160             sm_.axisOfWedge()*cos(beta) +
161             sm_.axisOfWedgeNormal()*sin(beta)
162         );
163     }
164     else
165     {
166         normal = alpha*
167         (
168             injectors_[n].properties()->tan1(hole)*cos(beta) +
169             injectors_[n].properties()->tan2(hole)*sin(beta)
170         );
171     }
172     
173     // set the direction of injection by adding the normal vector
174     vector dir = dcorr*injectors_[n].properties()->direction(hole, time) + normal;
175     dir /= mag(dir);
177     return dir;
181 scalar blobsSwirlInjector::velocity
183     const label i,
184     const scalar time
185 ) const
187     return u_*sqrt(1.0 + pow(tan(angle_),2.0));
190 scalar blobsSwirlInjector::averageVelocity
192     const label i
193 ) const
194 {    
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());  
206     scalar kV = kv(i);
208     return  kV*sqrt(2.0*(injectionPressure-sm_.ambientPressure())/rhoFuel);
213 scalar blobsSwirlInjector::kv
215     const label inj
216 ) const
218     return cD_[inj]/cos(angle_) * sqrt((1.0 - x_)/(1.0 + x_));    
221 void blobsSwirlInjector::calculateHX
223     const label inj,
224     const scalar massFlow,
225     const scalar dPressure,
226     const scalar time
227 ) const
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();  
237     x_ = 0.0;
238     
239     h_ = 
240     sqrt
241     (
242         (
243             A_[inj] *
244             cTau_[inj] *
245             muFuel*
246             massFlow*
247             (1.0 + x_)
248         )
249         /
250         (
251             mathematicalConstant::pi*
252             injectorDiameter*
253             rhoFuel*
254             dPressure*
255             sqr(1.0 - x_)
256         )
257     );
258     
259     scalar hOLD = -100.0;
260     scalar xOLD = -100.0;
261     
262     label i;
263     
264     for(i=0; i<20; i++)
265     {
268         h_ = 
269         sqrt
270         (
271             (
272                 A_[inj] *
273                 cTau_[inj] *
274                 muFuel*
275                 massFlow*
276                 (1.0 + x_)
277             )
278             /
279             (
280                 mathematicalConstant::pi*
281                 injectorDiameter*
282                 rhoFuel*
283                 dPressure*
284                 sqr(1.0 - x_)
285             )
286         );
288         x_ = sqr(1.0 - 2.0 * h_/injectorDiameter);
290         hOLD = h_;
291         xOLD = x_;
292                    
293     }
295     x_ = sqr(1.0 - 2.0 * h_/injectorDiameter);
296       
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 // ************************************************************************* //