FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

blobsSwirlInjector.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "blobsSwirlInjector.H"
00027 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00028 #include <OpenFOAM/mathematicalConstants.H>
00029 
00030 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00031 
00032 namespace Foam
00033 {
00034 
00035 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00036 
00037 defineTypeNameAndDebug(blobsSwirlInjector, 0);
00038 
00039 addToRunTimeSelectionTable
00040 (
00041     injectorModel,
00042     blobsSwirlInjector,
00043     dictionary
00044 );
00045 
00046 
00047 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00048 
00049 // Construct from components
00050 blobsSwirlInjector::blobsSwirlInjector
00051 (
00052     const dictionary& dict,
00053     spray& sm
00054 )
00055 :
00056     injectorModel(dict, sm),
00057     blobsSwirlInjectorDict_(dict.subDict(typeName + "Coeffs")),
00058 
00059     coneAngle_(blobsSwirlInjectorDict_.lookup("ConeAngle")),
00060     coneInterval_(blobsSwirlInjectorDict_.lookup("ConeInterval")),
00061 
00062     cD_(blobsSwirlInjectorDict_.lookup("cD")),
00063     cTau_(blobsSwirlInjectorDict_.lookup("cTau")),
00064     A_(blobsSwirlInjectorDict_.lookup("A")),
00065     
00066     angle_(0.0),
00067     u_(0.0),
00068     x_(0.0),
00069     h_(0.0)
00070 {
00071 
00072     if (sm.injectors().size() != coneAngle_.size())
00073     {
00074         FatalError << "blobsSwirlInjector::blobsSwirlInjector"
00075             << "(const dictionary& dict, spray& sm)\n"
00076             << "Wrong number of entries in innerAngle"
00077             << abort(FatalError);
00078     }
00079 
00080     scalar referencePressure = sm.p().average().value();
00081 
00082     // correct velocityProfile
00083     forAll(sm.injectors(), i)
00084     {
00085         sm.injectors()[i].properties()->correctProfiles(sm.fuels(), referencePressure);
00086     }
00087 
00088 }
00089 
00090 
00091 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00092 
00093 blobsSwirlInjector::~blobsSwirlInjector()
00094 {}
00095 
00096 
00097 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00098 
00099 scalar blobsSwirlInjector::d0
00100 (
00101     const label n, 
00102     const scalar t
00103 ) const
00104 {
00105     const injectorType& it = injectors_[n].properties();
00106 
00107     scalar c = rndGen_.scalar01();
00108 
00109     angle_ = coneAngle_[n]/2.0 + c * coneInterval_[n];
00110 
00111     angle_ *= mathematicalConstant::pi/180.0;
00112 
00113     scalar injectedMassFlow = it.massFlowRate(t);
00114     
00115     scalar cosAngle = cos(angle_);   
00116 
00117     scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), it.T(t), it.X()); 
00118      
00119     scalar deltaPressure = deltaPressureInj(t,n);
00120 
00121     calculateHX(n, injectedMassFlow, deltaPressure, t);
00122     
00123     scalar kV = kv(n);
00124     
00125     scalar v = kV * sqrt(2.0*deltaPressure/rhoFuel);    
00126 
00127     u_ = v * cosAngle;
00128     
00129     return h_;
00130     
00131 }
00132 
00133 vector blobsSwirlInjector::direction
00134 (
00135     const label n,
00136     const label hole,
00137     const scalar time,
00138     const scalar d
00139 ) const
00140 {
00141 
00142     scalar alpha = sin(angle_);
00143     scalar dcorr = cos(angle_);
00144     scalar beta = 2.0*mathematicalConstant::pi*rndGen_.scalar01();
00145 
00146     // randomly distributed vector normal to the injection vector
00147     vector normal = vector::zero;
00148     
00149     if (sm_.twoD())
00150     {
00151         scalar reduce = 0.01;
00152         // correct beta if this is a 2D run
00153         // map it onto the 'angleOfWedge'
00154 
00155         beta *= (1.0-2.0*reduce)*sm_.angleOfWedge()/(2.0*mathematicalConstant::pi);
00156         beta += reduce*sm_.angleOfWedge();
00157         normal = alpha*
00158         (
00159             sm_.axisOfWedge()*cos(beta) +
00160             sm_.axisOfWedgeNormal()*sin(beta)
00161         );
00162     }
00163     else
00164     {
00165         normal = alpha*
00166         (
00167             injectors_[n].properties()->tan1(hole)*cos(beta) +
00168             injectors_[n].properties()->tan2(hole)*sin(beta)
00169         );
00170     }
00171     
00172     // set the direction of injection by adding the normal vector
00173     vector dir = dcorr*injectors_[n].properties()->direction(hole, time) + normal;
00174     dir /= mag(dir);
00175 
00176     return dir;
00177 }
00178 
00179 
00180 scalar blobsSwirlInjector::velocity
00181 (
00182     const label i,
00183     const scalar time
00184 ) const
00185 {
00186     return u_*sqrt(1.0 + pow(tan(angle_),2.0));
00187 }
00188 
00189 scalar blobsSwirlInjector::averageVelocity
00190 (
00191     const label i
00192 ) const
00193 {    
00194 
00195     const injectorType& it = sm_.injectors()[i].properties();
00196 
00197     scalar dt = it.teoi() - it.tsoi();
00198 
00199 
00200     scalar injectionPressure = averagePressure(i);
00201 
00202     scalar Tav = it.integrateTable(it.T())/dt;
00203     scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), Tav, it.X());  
00204 
00205     scalar kV = kv(i);
00206 
00207     return  kV*sqrt(2.0*(injectionPressure-sm_.ambientPressure())/rhoFuel);
00208 
00209 }
00210 
00211 
00212 scalar blobsSwirlInjector::kv
00213 (
00214     const label inj
00215 ) const
00216 {
00217     return cD_[inj]/cos(angle_) * sqrt((1.0 - x_)/(1.0 + x_));    
00218 }
00219 
00220 void blobsSwirlInjector::calculateHX
00221 (
00222     const label inj,
00223     const scalar massFlow,
00224     const scalar dPressure,
00225     const scalar time
00226 ) const
00227 {
00228 
00229     const injectorType& it = injectors_[inj].properties();
00230 
00231     scalar Tfuel = it.T(time);
00232     scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), Tfuel, it.X()); 
00233     scalar muFuel = sm_.fuels().mu(sm_.ambientPressure(), Tfuel, it.X()); 
00234     scalar injectorDiameter = it.d();  
00235 
00236     x_ = 0.0;
00237     
00238     h_ = 
00239     sqrt
00240     (
00241         (
00242             A_[inj] *
00243             cTau_[inj] *
00244             muFuel*
00245             massFlow*
00246             (1.0 + x_)
00247         )
00248         /
00249         (
00250             mathematicalConstant::pi*
00251             injectorDiameter*
00252             rhoFuel*
00253             dPressure*
00254             sqr(1.0 - x_)
00255         )
00256     );
00257     
00258     scalar hOLD = -100.0;
00259     scalar xOLD = -100.0;
00260     
00261     label i;
00262     
00263     for(i=0; i<20; i++)
00264     {
00265 
00266 
00267         h_ = 
00268         sqrt
00269         (
00270             (
00271                 A_[inj] *
00272                 cTau_[inj] *
00273                 muFuel*
00274                 massFlow*
00275                 (1.0 + x_)
00276             )
00277             /
00278             (
00279                 mathematicalConstant::pi*
00280                 injectorDiameter*
00281                 rhoFuel*
00282                 dPressure*
00283                 sqr(1.0 - x_)
00284             )
00285         );
00286 
00287         x_ = sqr(1.0 - 2.0 * h_/injectorDiameter);
00288 
00289         hOLD = h_;
00290         xOLD = x_;
00291                    
00292     }
00293 
00294     x_ = sqr(1.0 - 2.0 * h_/injectorDiameter);
00295       
00296 }
00297 
00298 
00299 
00300 scalar blobsSwirlInjector::deltaPressureInj(const scalar time, const label inj) const
00301 {
00302     return injectors_[inj].properties()->injectionPressure(time) - sm_.ambientPressure();   
00303 }
00304 
00305 scalar blobsSwirlInjector::averagePressure(const label inj) const
00306 {
00307 
00308     const injectorType& it = sm_.injectors()[inj].properties();
00309 
00310     scalar dt = it.teoi() - it.tsoi();
00311     return it.integrateTable(it.injectionPressureProfile())/dt;
00312 }
00313 
00314 } // End namespace Foam
00315 
00316 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines