initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / lagrangian / dieselSpray / spraySubModels / injectorModel / pressureSwirl / pressureSwirlInjector.C
blobeb286bac36d3fc1340b6ec8b50bb99cba3ac6502
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 "pressureSwirlInjector.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "mathematicalConstants.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 namespace Foam
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 defineTypeNameAndDebug(pressureSwirlInjector, 0);
40 addToRunTimeSelectionTable
42     injectorModel,
43     pressureSwirlInjector,
44     dictionary
48 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
50 // Construct from components
51 pressureSwirlInjector::pressureSwirlInjector
53     const dictionary& dict,
54     spray& sm
57     injectorModel(dict, sm),
58     pressureSwirlInjectorDict_(dict.subDict(typeName + "Coeffs")),
60     coneAngle_(pressureSwirlInjectorDict_.lookup("ConeAngle")),
61     coneInterval_(pressureSwirlInjectorDict_.lookup("ConeInterval")),
62     maxKv_(pressureSwirlInjectorDict_.lookup("maxKv")),
64     angle_(0.0)
67     if (sm.injectors().size() != coneAngle_.size())
68     {
69         FatalError << "pressureSwirlInjector::pressureSwirlInjector"
70             << "(const dictionary& dict, spray& sm)\n"
71             << "Wrong number of entries in innerAngle"
72             << abort(FatalError);
73     }
75     scalar referencePressure = sm.p().average().value();
77     // correct velocityProfile
78     forAll(sm.injectors(), i)
79     {
80         sm.injectors()[i].properties()->correctProfiles(sm.fuels(), referencePressure);
81     }
86 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
88 pressureSwirlInjector::~pressureSwirlInjector()
92 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
94 scalar pressureSwirlInjector::d0
96     const label n, 
97     const scalar t
98 ) const
100     const injectorType& it = injectors_[n].properties();
102     scalar c = rndGen_.scalar01();
103     angle_ = coneAngle_[n]  + 2.0 * coneInterval_[n] * (0.5 - c) ;
105     angle_ *= mathematicalConstant::pi/360.0;
107     scalar injectedMassFlow = it.massFlowRate(t);
108     
109     scalar cosAngle = cos(angle_);   
111     scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), it.T(t), it.X()); 
112     scalar injectorDiameter = it.d();  
113      
114     scalar deltaPressure = deltaPressureInj(t,n);
115     scalar kV = kv(n, injectedMassFlow, deltaPressure);
116     scalar v = kV * sqrt(2.0*deltaPressure/rhoFuel);    
118     u_ = v * cosAngle;
119     
120     scalar A = injectedMassFlow/(mathematicalConstant::pi*rhoFuel*u_);
122     return (injectorDiameter-sqrt(pow(injectorDiameter,2)-4.0*A))/2.0;
125 vector pressureSwirlInjector::direction
127     const label n,
128     const label hole,
129     const scalar time,
130     const scalar d
131 ) const
134     scalar alpha = sin(angle_);
135     scalar dcorr = cos(angle_);
136     scalar beta = 2.0*mathematicalConstant::pi*rndGen_.scalar01();
138     // randomly distributed vector normal to the injection vector
139     vector normal = vector::zero;
140     
141     if (sm_.twoD())
142     {
143         scalar reduce = 0.01;
144         // correct beta if this is a 2D run
145         // map it onto the 'angleOfWedge'
147         beta *= (1.0-2.0*reduce)*sm_.angleOfWedge()/(2.0*mathematicalConstant::pi);
148         beta += reduce*sm_.angleOfWedge();
149         normal = alpha*
150         (
151             sm_.axisOfWedge()*cos(beta) +
152             sm_.axisOfWedgeNormal()*sin(beta)
153         );
154     }
155     else
156     {
157         normal = alpha*
158         (
159             injectors_[n].properties()->tan1(hole)*cos(beta) +
160             injectors_[n].properties()->tan2(hole)*sin(beta)
161         );
162     }
163     
164     // set the direction of injection by adding the normal vector
165     vector dir = dcorr*injectors_[n].properties()->direction(hole, time) + normal;
166     dir /= mag(dir);
168     return dir;
172 scalar pressureSwirlInjector::velocity
174     const label i,
175     const scalar time
176 ) const
178     return u_*sqrt(1.0 + pow(tan(angle_),2.0));
181 scalar pressureSwirlInjector::averageVelocity
183     const label i
184 ) const
185 {    
187     const injectorType& it = sm_.injectors()[i].properties();
189     scalar dt = it.teoi() - it.tsoi();
191     scalar injectedMassFlow = it.mass()/(it.teoi()-it.tsoi());
193     scalar injectionPressure = averagePressure(i);
195     scalar Tav = it.integrateTable(it.T())/dt;
196     scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), Tav, it.X());  
198     scalar kV = kv(i, injectedMassFlow, injectionPressure);
200     return  kV*sqrt(2.0*(injectionPressure-sm_.ambientPressure())/rhoFuel);
204 scalar pressureSwirlInjector::kv
206     const label inj,
207     const scalar massFlow,
208     const scalar dPressure
209 ) const
212     const injectorType& it = injectors_[inj].properties();
214     scalar coneAngle = coneAngle_[inj];
216     coneAngle *= mathematicalConstant::pi/360.0;
218     scalar cosAngle = cos(coneAngle);
219     scalar Tav = it.integrateTable(it.T())/(it.teoi()-it.tsoi());
221     scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), Tav, it.X()); 
222     scalar injectorDiameter = it.d();  
223      
224     scalar kv = max
225     (
226         maxKv_[inj], 
227         4.0*massFlow
228         *
229         sqrt(rhoFuel/2.0/dPressure)
230         /
231         (mathematicalConstant::pi*pow(injectorDiameter, 2.0)*rhoFuel*cosAngle)
232     );
234     return min(1.0, kv);   
240 scalar pressureSwirlInjector::deltaPressureInj(const scalar time, const label inj) const
242     return injectors_[inj].properties()->injectionPressure(time) - sm_.ambientPressure();   
245 scalar pressureSwirlInjector::averagePressure(const label inj) const
248     const injectorType& it = sm_.injectors()[inj].properties();
250     scalar dt = it.teoi() - it.tsoi();
251     return it.integrateTable(it.injectionPressureProfile())/dt;
254 } // End namespace Foam
256 // ************************************************************************* //