BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / lagrangian / dieselSpray / spraySubModels / injectorModel / definedPressureSwirl / definedPressureSwirl.C
blob8662dbd3ce9ccdd79ba30352e1b5d46a9d0598e2
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 "definedPressureSwirl.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "mathematicalConstants.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 namespace Foam
34     defineTypeNameAndDebug(definedPressureSwirlInjector, 0);
36     addToRunTimeSelectionTable
37     (
38         injectorModel,
39         definedPressureSwirlInjector,
40         dictionary
41     );
45 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
47 Foam::definedPressureSwirlInjector::definedPressureSwirlInjector
49     const dictionary& dict,
50     spray& sm
53     injectorModel(dict, sm),
54     definedPressureSwirlInjectorDict_(dict.subDict(typeName + "Coeffs")),
56     coneAngle_(definedPressureSwirlInjectorDict_.lookup("ConeAngle")),
57     coneInterval_(definedPressureSwirlInjectorDict_.lookup("ConeInterval")),
58     maxKv_(definedPressureSwirlInjectorDict_.lookup("maxKv")),
60     angle_(0.0)
63     scalar referencePressure = sm.p().average().value();
65     // correct velocityProfile
66     forAll(sm.injectors(), i)
67     {
68         sm.injectors()[i].properties()->correctProfiles
69         (
70             sm.fuels(),
71             referencePressure
72         );
73     }
77 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
79 Foam::definedPressureSwirlInjector::~definedPressureSwirlInjector()
83 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
85 Foam::scalar Foam::definedPressureSwirlInjector::d0
87     const label n,
88     const scalar t
89 ) const
91     const injectorType& it = injectors_[n].properties();
93     scalar c = rndGen_.sample01<scalar>();
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 liquidMixtureProperties& 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();
107     for (label i = 0; i < Nf ; i++)
108     {
110         if
111         (
112             fuels.properties()[i].pv(sm_.ambientPressure(), Tinj)
113          >= 0.999*sm_.ambientPressure()
114         )
115         {
116 //          The fuel is boiling.....
117 //          Calculation of the boiling temperature
119             scalar tBoilingSurface = Tinj ;
121             label Niter = 200;
123             for (label k=0; k< Niter ; k++)
124             {
125                 scalar pBoil =
126                     fuels.properties()[i].pv(pressure, tBoilingSurface);
128                 if (pBoil > pressure)
129                 {
130                     tBoilingSurface =
131                         tBoilingSurface - (Tinj-temperature)/Niter;
132                 }
133                 else
134                 {
135                     break;
136                 }
138             }
140             scalar hl =
141                 fuels.properties()[i].hl
142                 (
143                     sm_.ambientPressure(),
144                     tBoilingSurface
145                 );
146             scalar iTp =
147                 fuels.properties()[i].h(sm_.ambientPressure(), Tinj)
148               - sm_.ambientPressure()
149                /fuels.properties()[i].rho(sm_.ambientPressure(), Tinj);
150             scalar iTb =
151                 fuels.properties()[i].h(sm_.ambientPressure(), tBoilingSurface)
152               - sm_.ambientPressure()
153                /fuels.properties()[i].rho
154                 (
155                     sm_.ambientPressure(),
156                     tBoilingSurface
157                 );
159             chi += it.X()[i]*(iTp-iTb)/hl;
160         }
161     }
163     // bounding chi
165     chi = max(chi, 0.0);
166     chi = min(chi, 1.0);
168     angle_ =
169         angle_ + (144.0 - angle_) * sqr(chi) + 2.0*coneInterval*(0.5 - c);
171     // end modifications
173     angle_ *= constant::mathematical::pi/360.0;
175     scalar injectedMassFlow = it.massFlowRate(t);
177     scalar cosAngle = cos(angle_);
179     scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), it.T(t), it.X());
180     scalar injectorDiameter = it.d();
182     scalar deltaPressure = deltaPressureInj(t,n);
184     scalar kV = kv(n, injectedMassFlow, deltaPressure, t);
186     scalar v = kV*sqrt(2.0*deltaPressure/rhoFuel);
188     u_ = v*cosAngle;
190     scalar A = injectedMassFlow/(constant::mathematical::pi*rhoFuel*u_);
192     // Not using the authors definition for sheet thickness
193     // modified by multiplying the sheet tickness for the cone angle cosinus.
195     scalar angleT = angle_;
196     return
197         (injectorDiameter - sqrt(sqr(injectorDiameter) - 4.0*A))
198        *cos(angleT)/2.0;
200     //  original implementation
201     // return (injectorDiameter-sqrt(sqr(injectorDiameter) - 4.0*A))/2.0;
205 Foam::vector Foam::definedPressureSwirlInjector::direction
207     const label n,
208     const label hole,
209     const scalar time,
210     const scalar d
211 ) const
213     scalar alpha = sin(angle_);
214     scalar dcorr = cos(angle_);
215     scalar beta = constant::mathematical::twoPi*rndGen_.sample01<scalar>();
217     // randomly distributed vector normal to the injection vector
218     vector normal = vector::zero;
220     if (sm_.twoD())
221     {
222         scalar reduce = 0.01;
223         // correct beta if this is a 2D run
224         // map it onto the 'angleOfWedge'
226         beta *=
227             (1.0 - 2.0*reduce)
228            *sm_.angleOfWedge()
229            /(constant::mathematical::twoPi);
230         beta += reduce*sm_.angleOfWedge();
231         normal =
232             alpha
233            *(
234                 sm_.axisOfWedge()*cos(beta)
235               + sm_.axisOfWedgeNormal()*sin(beta)
236             );
237     }
238     else
239     {
240         normal =
241             alpha
242            *(
243                 injectors_[n].properties()->tan1(hole)*cos(beta)
244               + injectors_[n].properties()->tan2(hole)*sin(beta)
245             );
246     }
248     // set the direction of injection by adding the normal vector
249     vector dir =
250         dcorr*injectors_[n].properties()->direction(hole, time) + normal;
251     dir /= mag(dir);
253     return dir;
257 Foam::scalar Foam::definedPressureSwirlInjector::velocity
259     const label i,
260     const scalar time
261 ) const
263     return u_*sqrt(1.0 + pow(tan(angle_),2.0));
267 Foam::scalar Foam::definedPressureSwirlInjector::averageVelocity
269     const label i
270 ) const
272     const injectorType& it = sm_.injectors()[i].properties();
274     scalar dt = it.teoi() - it.tsoi();
276     scalar injectedMassFlow = it.mass()/(it.teoi()-it.tsoi());
278     scalar injectionPressure = averagePressure(i);
280     scalar Tav = it.integrateTable(it.T())/dt;
281     scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), Tav, it.X());
283     scalar kV = kv(i, injectedMassFlow, injectionPressure, 0);
285     return  kV*sqrt(2.0*(injectionPressure-sm_.ambientPressure())/rhoFuel);
289 Foam::scalar Foam::definedPressureSwirlInjector::kv
291     const label inj,
292     const scalar massFlow,
293     const scalar dPressure,
294     const scalar t
295 ) const
297     const injectorType& it = injectors_[inj].properties();
299     scalar coneAngle = it.getTableValue(coneAngle_, t);
301     coneAngle *= constant::mathematical::pi/360.0;
303     scalar cosAngle = cos(coneAngle);
304     scalar Tav = it.integrateTable(it.T())/(it.teoi() - it.tsoi());
306     scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), Tav, it.X());
307     scalar injectorDiameter = it.d();
309     scalar kv = max
310     (
311         it.getTableValue(maxKv_, t),
312         4.0*massFlow
313        *sqrt(rhoFuel/2.0/dPressure)
314        /(constant::mathematical::pi*sqr(injectorDiameter)*rhoFuel*cosAngle)
315     );
317     return min(1.0, kv);
321 Foam::scalar Foam::definedPressureSwirlInjector::deltaPressureInj
323     const scalar time,
324     const label inj
325 ) const
327     return
328         injectors_[inj].properties()->injectionPressure(time)
329       - sm_.ambientPressure();
333 Foam::scalar
334 Foam::definedPressureSwirlInjector::averagePressure(const label inj) const
336     const injectorType& it = sm_.injectors()[inj].properties();
338     scalar dt = it.teoi() - it.tsoi();
339     return it.integrateTable(it.injectionPressureProfile())/dt;
343 // ************************************************************************* //