OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

Chomiak.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-2009 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "Chomiak.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "mathematicalConstants.H"
00030 
00031 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00032 
00033 namespace Foam
00034 {
00035 
00036 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00037 
00038 defineTypeNameAndDebug(ChomiakInjector, 0);
00039 
00040 addToRunTimeSelectionTable
00041 (
00042     injectorModel,
00043     ChomiakInjector,
00044     dictionary
00045 );
00046 
00047 
00048 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00049 
00050 // Construct from components
00051 ChomiakInjector::ChomiakInjector
00052 (
00053     const dictionary& dict,
00054     spray& sm
00055 )
00056 :
00057     injectorModel(dict, sm),
00058     ChomiakDict_(dict.subDict(typeName + "Coeffs")),
00059     dropletPDF_
00060     (
00061         pdf::New
00062         (
00063             ChomiakDict_.subDict("dropletPDF"),
00064             sm.rndGen()
00065         )
00066     ),
00067     maxSprayAngle_(ChomiakDict_.lookup("maxSprayConeAngle"))
00068 {
00069 
00070     if (sm.injectors().size() != maxSprayAngle_.size())
00071     {
00072         FatalError << "ChomiakInjector::ChomiakInjector"
00073             << "(const dictionary& dict, spray& sm)\n"
00074             << "Wrong number of entries in maxSprayAngle"
00075             << abort(FatalError);
00076     }
00077 
00078     scalar referencePressure = sm.p().average().value();
00079 
00080     // correct velocityProfile
00081     forAll(sm.injectors(), i)
00082     {
00083         sm.injectors()[i].properties()->correctProfiles(sm.fuels(), referencePressure);
00084     }
00085 
00086 }
00087 
00088 
00089 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00090 
00091 ChomiakInjector::~ChomiakInjector()
00092 {}
00093 
00094 
00095 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00096 
00097 scalar ChomiakInjector::d0
00098 (
00099     const label, 
00100     const scalar
00101 ) const
00102 {
00103     return dropletPDF_->sample();
00104 }
00105 
00106 
00107 vector ChomiakInjector::direction
00108 (
00109     const label n,
00110     const label hole,
00111     const scalar time,
00112     const scalar d
00113 ) const
00114 {
00115     scalar dMin = dropletPDF_->minValue();
00116     scalar dMax = dropletPDF_->maxValue();
00117 
00118     scalar angle = (d-dMax)*maxSprayAngle_[n]/(dMin-dMax)*mathematicalConstant::pi/360.0;
00119     scalar alpha = sin(angle);
00120     scalar dcorr = cos(angle);
00121 
00122     scalar beta = 2.0*mathematicalConstant::pi*rndGen_.scalar01();
00123 
00124     // randomly distributed vector normal to the injection vector
00125     vector normal = vector::zero;
00126     
00127     if (sm_.twoD())
00128     {
00129         scalar reduce = 0.01;
00130         // correct beta if this is a 2D run
00131         // map it onto the 'angleOfWedge'
00132         beta *= (1.0-2.0*reduce)*0.5*sm_.angleOfWedge()/mathematicalConstant::pi;
00133         beta += reduce*sm_.angleOfWedge();
00134 
00135         normal = alpha*
00136         (
00137             sm_.axisOfWedge()*cos(beta) +
00138             sm_.axisOfWedgeNormal()*sin(beta)
00139         );
00140 
00141     }
00142     else
00143     {
00144         normal = alpha*
00145         (
00146             injectors_[n].properties()->tan1(hole)*cos(beta) +
00147             injectors_[n].properties()->tan2(hole)*sin(beta)
00148         );
00149     }
00150     
00151     // set the direction of injection by adding the normal vector
00152     vector dir = dcorr*injectors_[n].properties()->direction(hole, time) + normal;
00153     dir /= mag(dir);
00154 
00155     return dir;
00156 
00157 }
00158 
00159 scalar ChomiakInjector::velocity
00160 (
00161     const label i,
00162     const scalar time
00163 ) const
00164 {
00165     const injectorType& it = sm_.injectors()[i].properties();
00166     if (it.pressureIndependentVelocity())
00167     {
00168         return it.getTableValue(it.velocityProfile(), time);
00169     }
00170     else
00171     {
00172         scalar Pref = sm_.ambientPressure();
00173         scalar Pinj = it.getTableValue(it.injectionPressureProfile(), time);
00174         scalar rho = sm_.fuels().rho(Pinj, it.T(time), it.X());
00175         scalar dp = max(0.0, Pinj - Pref);
00176         return sqrt(2.0*dp/rho);
00177     }
00178 }
00179 
00180 scalar ChomiakInjector::averageVelocity
00181 (
00182     const label i
00183 ) const
00184 {    
00185     const injectorType& it = sm_.injectors()[i].properties();
00186     scalar dt = it.teoi() - it.tsoi();
00187     return it.integrateTable(it.velocityProfile())/dt;
00188 }
00189 
00190 } // End namespace Foam
00191 
00192 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd