FreeFOAM The Cross-Platform CFD Toolkit
Chomiak.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "Chomiak.H"
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 
35 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 
37 defineTypeNameAndDebug(ChomiakInjector, 0);
38 
40 (
41  injectorModel,
42  ChomiakInjector,
43  dictionary
44 );
45 
46 
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 
49 // Construct from components
51 (
52  const dictionary& dict,
53  spray& sm
54 )
55 :
56  injectorModel(dict, sm),
57  ChomiakDict_(dict.subDict(typeName + "Coeffs")),
58  dropletPDF_
59  (
61  (
62  ChomiakDict_.subDict("dropletPDF"),
63  sm.rndGen()
64  )
65  ),
66  maxSprayAngle_(ChomiakDict_.lookup("maxSprayConeAngle"))
67 {
68 
69  if (sm.injectors().size() != maxSprayAngle_.size())
70  {
71  FatalError << "ChomiakInjector::ChomiakInjector"
72  << "(const dictionary& dict, spray& sm)\n"
73  << "Wrong number of entries in maxSprayAngle"
74  << abort(FatalError);
75  }
76 
77  scalar referencePressure = sm.p().average().value();
78 
79  // correct velocityProfile
80  forAll(sm.injectors(), i)
81  {
82  sm.injectors()[i].properties()->correctProfiles(sm.fuels(), referencePressure);
83  }
84 
85 }
86 
87 
88 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
89 
91 {}
92 
93 
94 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
95 
97 (
98  const label,
99  const scalar
100 ) const
101 {
102  return dropletPDF_->sample();
103 }
104 
105 
107 (
108  const label n,
109  const label hole,
110  const scalar time,
111  const scalar d
112 ) const
113 {
114  scalar dMin = dropletPDF_->minValue();
115  scalar dMax = dropletPDF_->maxValue();
116 
117  scalar angle = (d-dMax)*maxSprayAngle_[n]/(dMin-dMax)*mathematicalConstant::pi/360.0;
118  scalar alpha = sin(angle);
119  scalar dcorr = cos(angle);
120 
121  scalar beta = 2.0*mathematicalConstant::pi*rndGen_.scalar01();
122 
123  // randomly distributed vector normal to the injection vector
125 
126  if (sm_.twoD())
127  {
128  scalar reduce = 0.01;
129  // correct beta if this is a 2D run
130  // map it onto the 'angleOfWedge'
131  beta *= (1.0-2.0*reduce)*0.5*sm_.angleOfWedge()/mathematicalConstant::pi;
132  beta += reduce*sm_.angleOfWedge();
133 
134  normal = alpha*
135  (
136  sm_.axisOfWedge()*cos(beta) +
137  sm_.axisOfWedgeNormal()*sin(beta)
138  );
139 
140  }
141  else
142  {
143  normal = alpha*
144  (
145  injectors_[n].properties()->tan1(hole)*cos(beta) +
146  injectors_[n].properties()->tan2(hole)*sin(beta)
147  );
148  }
149 
150  // set the direction of injection by adding the normal vector
151  vector dir = dcorr*injectors_[n].properties()->direction(hole, time) + normal;
152  dir /= mag(dir);
153 
154  return dir;
155 
156 }
157 
159 (
160  const label i,
161  const scalar time
162 ) const
163 {
164  const injectorType& it = sm_.injectors()[i].properties();
166  {
167  return it.getTableValue(it.velocityProfile(), time);
168  }
169  else
170  {
171  scalar Pref = sm_.ambientPressure();
172  scalar Pinj = it.getTableValue(it.injectionPressureProfile(), time);
173  scalar rho = sm_.fuels().rho(Pinj, it.T(time), it.X());
174  scalar dp = max(0.0, Pinj - Pref);
175  return sqrt(2.0*dp/rho);
176  }
177 }
178 
180 (
181  const label i
182 ) const
183 {
184  const injectorType& it = sm_.injectors()[i].properties();
185  scalar dt = it.teoi() - it.tsoi();
186  return it.integrateTable(it.velocityProfile())/dt;
187 }
188 
189 } // End namespace Foam
190 
191 // ************************ vim: set sw=4 sts=4 et: ************************ //