ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / lagrangian / dieselSpray / spraySubModels / injectorModel / blobsSwirl / blobsSwirlInjector.C
blob72cc08c6879bd4cc74379da52e53aeccf04436c2
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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
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
19     for more details.
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 "blobsSwirlInjector.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "unitConversion.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 namespace Foam
34     defineTypeNameAndDebug(blobsSwirlInjector, 0);
36     addToRunTimeSelectionTable
37     (
38         injectorModel,
39         blobsSwirlInjector,
40         dictionary
41     );
45 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
47 Foam::blobsSwirlInjector::blobsSwirlInjector
49     const dictionary& dict,
50     spray& sm
53     injectorModel(dict, sm),
54     blobsSwirlInjectorDict_(dict.subDict(typeName + "Coeffs")),
56     coneAngle_(blobsSwirlInjectorDict_.lookup("ConeAngle")),
57     coneInterval_(blobsSwirlInjectorDict_.lookup("ConeInterval")),
59     cD_(blobsSwirlInjectorDict_.lookup("cD")),
60     cTau_(blobsSwirlInjectorDict_.lookup("cTau")),
61     A_(blobsSwirlInjectorDict_.lookup("A")),
63     angle_(0.0),
64     u_(0.0),
65     x_(0.0),
66     h_(0.0)
69     if (sm.injectors().size() != coneAngle_.size())
70     {
71         FatalError
72             << "blobsSwirlInjector::blobsSwirlInjector"
73             << "(const dictionary& dict, spray& sm)\n"
74             << "Wrong number of entries in innerAngle"
75             << abort(FatalError);
76     }
78     scalar referencePressure = sm.p().average().value();
80     // correct velocityProfile
81     forAll(sm.injectors(), i)
82     {
83         sm.injectors()[i].properties()->correctProfiles
84         (
85             sm.fuels(),
86             referencePressure
87         );
88     }
92 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
94 Foam::blobsSwirlInjector::~blobsSwirlInjector()
98 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
100 Foam::scalar Foam::blobsSwirlInjector::d0
102     const label n,
103     const scalar t
104 ) const
106     const injectorType& it = injectors_[n].properties();
108     scalar c = rndGen_.sample01<scalar>();
110     angle_ = degToRad(coneAngle_[n]/2.0 + c*coneInterval_[n]);
112     scalar injectedMassFlow = it.massFlowRate(t);
114     scalar cosAngle = cos(angle_);
116     scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), it.T(t), it.X());
118     scalar deltaPressure = deltaPressureInj(t,n);
120     calculateHX(n, injectedMassFlow, deltaPressure, t);
122     scalar kV = kv(n);
124     scalar v = kV*sqrt(2.0*deltaPressure/rhoFuel);
126     u_ = v*cosAngle;
128     return h_;
132 Foam::vector Foam::blobsSwirlInjector::direction
134     const label n,
135     const label hole,
136     const scalar time,
137     const scalar d
138 ) const
140     scalar alpha = sin(angle_);
141     scalar dcorr = cos(angle_);
142     scalar beta = constant::mathematical::twoPi*rndGen_.sample01<scalar>();
144     // randomly distributed vector normal to the injection vector
145     vector normal = vector::zero;
147     if (sm_.twoD())
148     {
149         scalar reduce = 0.01;
150         // correct beta if this is a 2D run
151         // map it onto the 'angleOfWedge'
153         beta *=
154             (1.0 - 2.0*reduce)
155            *sm_.angleOfWedge()
156            /(constant::mathematical::twoPi);
157         beta += reduce*sm_.angleOfWedge();
158         normal =
159             alpha
160            *(
161                 sm_.axisOfWedge()*cos(beta)
162               + sm_.axisOfWedgeNormal()*sin(beta)
163             );
164     }
165     else
166     {
167         normal =
168             alpha
169            *(
170                 injectors_[n].properties()->tan1(hole)*cos(beta)
171               + injectors_[n].properties()->tan2(hole)*sin(beta)
172             );
173     }
175     // set the direction of injection by adding the normal vector
176     vector dir =
177         dcorr*injectors_[n].properties()->direction(hole, time)
178       + normal;
179     dir /= mag(dir);
181     return dir;
185 Foam::scalar Foam::blobsSwirlInjector::velocity
187     const label i,
188     const scalar time
189 ) const
191     return u_*sqrt(1.0 + pow(tan(angle_),2.0));
195 Foam::scalar Foam::blobsSwirlInjector::averageVelocity(const label i) const
197     const injectorType& it = sm_.injectors()[i].properties();
199     scalar dt = it.teoi() - it.tsoi();
202     scalar injectionPressure = averagePressure(i);
204     scalar Tav = it.integrateTable(it.T())/dt;
205     scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), Tav, it.X());
207     scalar kV = kv(i);
209     return  kV*sqrt(2.0*(injectionPressure-sm_.ambientPressure())/rhoFuel);
213 Foam::scalar Foam::blobsSwirlInjector::kv(const label inj) const
215     return cD_[inj]/cos(angle_) * sqrt((1.0 - x_)/(1.0 + x_));
219 void Foam::blobsSwirlInjector::calculateHX
221     const label inj,
222     const scalar massFlow,
223     const scalar dPressure,
224     const scalar time
225 ) const
227     const injectorType& it = injectors_[inj].properties();
229     scalar Tfuel = it.T(time);
230     scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), Tfuel, it.X());
231     scalar muFuel = sm_.fuels().mu(sm_.ambientPressure(), Tfuel, it.X());
232     scalar injectorDiameter = it.d();
234     x_ = 0.0;
236     h_ =
237         sqrt
238         (
239             (A_[inj]*cTau_[inj]*muFuel*massFlow*(1.0 + x_))
240            /(
241                 constant::mathematical::pi
242                *injectorDiameter
243                *rhoFuel
244                *dPressure
245                *sqr(1.0 - x_)
246             )
247         );
249     label i;
251     for (i=0; i<20; i++)
252     {
253         h_ =
254             sqrt
255             (
256                 (A_[inj]*cTau_[inj]*muFuel*massFlow*(1.0 + x_))
257                /(
258                     constant::mathematical::pi
259                    *injectorDiameter
260                    *rhoFuel
261                    *dPressure
262                    *sqr(1.0 - x_)
263                 )
264             );
266         x_ = sqr(1.0 - 2.0*h_/injectorDiameter);
267     }
269     x_ = sqr(1.0 - 2.0*h_/injectorDiameter);
273 Foam::scalar Foam::blobsSwirlInjector::deltaPressureInj
275     const scalar time,
276     const label inj
277 ) const
279     return
280         injectors_[inj].properties()->injectionPressure(time)
281       - sm_.ambientPressure();
285 Foam::scalar Foam::blobsSwirlInjector::averagePressure(const label inj) const
287     const injectorType& it = sm_.injectors()[inj].properties();
289     scalar dt = it.teoi() - it.tsoi();
290     return it.integrateTable(it.injectionPressureProfile())/dt;
294 // ************************************************************************* //