Merge /u/wyldckat/foam-extend32/ branch master into master
[foam-extend-3.2.git] / src / lagrangian / dieselSpray / spraySubModels / injectorModel / definedPressureSwirl / definedPressureSwirl.C
blobe9acb3564326d5583d376737fb7d903ed90d39e1
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend 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 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "definedPressureSwirl.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "mathematicalConstants.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 namespace Foam
35 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 defineTypeNameAndDebug(definedPressureSwirlInjector, 0);
39 addToRunTimeSelectionTable
41     injectorModel,
42     definedPressureSwirlInjector,
43     dictionary
47 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
49 // Construct from components
50 definedPressureSwirlInjector::definedPressureSwirlInjector
52     const dictionary& dict,
53     spray& sm
56     injectorModel(dict, sm),
57     definedPressureSwirlInjectorDict_(dict.subDict(typeName + "Coeffs")),
59     coneAngle_(definedPressureSwirlInjectorDict_.lookup("ConeAngle")),
60     coneInterval_(definedPressureSwirlInjectorDict_.lookup("ConeInterval")),
61     maxKv_(definedPressureSwirlInjectorDict_.lookup("maxKv")),
63     angle_(0.0)
66     scalar referencePressure = sm.p().average().value();
68     // correct velocityProfile
69     forAll(sm.injectors(), i)
70     {
71         sm.injectors()[i].properties()->correctProfiles(sm.fuels(), referencePressure);
72     }
77 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
79 definedPressureSwirlInjector::~definedPressureSwirlInjector()
83 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
85 scalar definedPressureSwirlInjector::d0
87     const label n,
88     const scalar t
89 ) const
91     const injectorType& it = injectors_[n].properties();
93     scalar c = rndGen_.scalar01();
94     scalar coneAngle = it.getTableValue(coneAngle_, t);
95     scalar coneInterval = it.getTableValue(coneInterval_, t);
96     angle_ = coneAngle ;
98 //  modifications to take account of flash boiling....
100     const liquidMixture& fuels = sm_.fuels();
101     scalar chi = 0.0;
102     scalar Tinj = it.T(t);
103     label Nf = fuels.components().size();
104     scalar temperature = sm_.ambientTemperature();
105     scalar pressure = sm_.ambientPressure();
108     for(label i = 0; i < Nf ; i++)
109     {
111         if(fuels.properties()[i].pv(sm_.ambientPressure(), Tinj) >= 0.999*sm_.ambientPressure())
112         {
114 //          The fuel is boiling.....
115 //          Calculation of the boiling temperature
117             scalar tBoilingSurface = Tinj ;
119             label Niter = 200;
121             for(label k=0; k< Niter ; k++)
122             {
124                 scalar pBoil = fuels.properties()[i].pv(pressure, tBoilingSurface);
126                 if(pBoil > pressure)
127                 {
128                     tBoilingSurface = tBoilingSurface - (Tinj-temperature)/Niter;
129                 }
130                 else
131                 {
132                     break;
133                 }
135             }
137             scalar hl = fuels.properties()[i].hl(sm_.ambientPressure(), tBoilingSurface);
138             scalar iTp = fuels.properties()[i].h(sm_.ambientPressure(), Tinj) - sm_.ambientPressure()/fuels.properties()[i].rho(sm_.ambientPressure(), Tinj);
139             scalar iTb = fuels.properties()[i].h(sm_.ambientPressure(), tBoilingSurface) - sm_.ambientPressure()/fuels.properties()[i].rho(sm_.ambientPressure(), tBoilingSurface);
141             chi += it.X()[i]*(iTp-iTb)/hl;
143         }
144     }
146     //  bounding chi
148     chi = max(chi, 0.0);
149     chi = min(chi, 1.0);
151     angle_ = angle_ + (144.0 - angle_) * sqr(chi) + 2.0 * coneInterval * (0.5 - c);
153 //  end modifications
155     angle_ *= mathematicalConstant::pi/360.0;
157     scalar injectedMassFlow = it.massFlowRate(t);
159     scalar cosAngle = cos(angle_);
161     scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), it.T(t), it.X());
162     scalar injectorDiameter = it.d();
164     scalar deltaPressure = deltaPressureInj(t,n);
166     scalar kV = kv(n, injectedMassFlow, deltaPressure, t);
168     scalar v = kV * sqrt(2.0*deltaPressure/rhoFuel);
170     u_ = v * cosAngle;
172     scalar A = injectedMassFlow/(mathematicalConstant::pi*rhoFuel*u_);
176     TL
177     The formula for the sheet tickness proposed by the authors is,
178     in my opinion, "strange".....
179     I modified it multiplying the sheet tickness for the cone angle cosinus.
183     scalar angleT = angle_;
184     return (injectorDiameter-sqrt(pow(injectorDiameter,2.0)-4.0*A))*cos(angleT)/2.0;
186 //  original implementation
189     return (injectorDiameter-sqrt(pow(injectorDiameter,2)-4.0*A))/2.0;
195 vector definedPressureSwirlInjector::direction
197     const label n,
198     const label hole,
199     const scalar time,
200     const scalar d
201 ) const
204     scalar alpha = sin(angle_);
205     scalar dcorr = cos(angle_);
206     scalar beta = 2.0*mathematicalConstant::pi*rndGen_.scalar01();
208     // randomly distributed vector normal to the injection vector
209     vector normal = vector::zero;
211     if (sm_.twoD())
212     {
213         scalar reduce = 0.01;
214         // correct beta if this is a 2D run
215         // map it onto the 'angleOfWedge'
217         beta *= (1.0-2.0*reduce)*sm_.angleOfWedge()/(2.0*mathematicalConstant::pi);
218         beta += reduce*sm_.angleOfWedge();
219         normal = alpha*
220         (
221             sm_.axisOfWedge()*cos(beta) +
222             sm_.axisOfWedgeNormal()*sin(beta)
223         );
224     }
225     else
226     {
227         normal = alpha*
228         (
229             injectors_[n].properties()->tan1(hole)*cos(beta) +
230             injectors_[n].properties()->tan2(hole)*sin(beta)
231         );
232     }
234     // set the direction of injection by adding the normal vector
235     vector dir = dcorr*injectors_[n].properties()->direction(hole, time) + normal;
236     dir /= mag(dir);
238     return dir;
242 scalar definedPressureSwirlInjector::velocity
244     const label i,
245     const scalar time
246 ) const
248     return u_*sqrt(1.0 + pow(tan(angle_),2.0));
251 scalar definedPressureSwirlInjector::averageVelocity
253     const label i
254 ) const
257     const injectorType& it = sm_.injectors()[i].properties();
259     scalar dt = it.teoi() - it.tsoi();
261     scalar injectedMassFlow = it.mass()/(it.teoi()-it.tsoi());
263     scalar injectionPressure = averagePressure(i);
265     scalar Tav = it.integrateTable(it.T())/dt;
266     scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), Tav, it.X());
268     scalar kV = kv(i, injectedMassFlow, injectionPressure, 0);
270     return  kV*sqrt(2.0*(injectionPressure-sm_.ambientPressure())/rhoFuel);
275 scalar definedPressureSwirlInjector::kv
277     const label inj,
278     const scalar massFlow,
279     const scalar dPressure,
280     const scalar t
281 ) const
284     const injectorType& it = injectors_[inj].properties();
286     scalar coneAngle = it.getTableValue(coneAngle_, t);
288     coneAngle *= mathematicalConstant::pi/360.0;
290     scalar cosAngle = cos(coneAngle);
291     scalar Tav = it.integrateTable(it.T())/(it.teoi()-it.tsoi());
293     scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), Tav, it.X());
294     scalar injectorDiameter = it.d();
296     scalar kv = max
297     (
298         it.getTableValue(maxKv_, t),
299         4.0*massFlow
300         *
301         sqrt(rhoFuel/2.0/dPressure)
302         /
303         (mathematicalConstant::pi*pow(injectorDiameter, 2.0)*rhoFuel*cosAngle)
304     );
306     return min(1.0,kv);
312 scalar definedPressureSwirlInjector::deltaPressureInj(const scalar time, const label inj) const
314     return injectors_[inj].properties()->injectionPressure(time) - sm_.ambientPressure();
317 scalar definedPressureSwirlInjector::averagePressure(const label inj) const
320     const injectorType& it = sm_.injectors()[inj].properties();
322     scalar dt = it.teoi() - it.tsoi();
323     return it.integrateTable(it.injectionPressureProfile())/dt;
326 } // End namespace Foam
328 // ************************************************************************* //