pressurePIDControlInletVelocityFvPatchVectorField.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2015 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::pressurePIDControlInletVelocityFvPatchVectorField
28 
29 Group
30  grpInletBoundaryConditions
31 
32 Description
33  This boundary condition tries to generate an inlet velocity that maintains
34  a specified pressure drop between two face zones downstream. The zones
35  should fully span a duct through which all the inlet flow passes.
36 
37  An incompressible, lossless analysis of the flow between the inlet and the
38  two face-zones is performed. An ideal inlet velocity is thereby calculated
39  from the user-specified pressure drop. This analysis can include the
40  transient effect of the inlet velocity change. In this case, a shape factor
41  is included to represent non-linearity in the duct cross section.
42 
43  The average pressure drop between the two face zones is measured. The same
44  incompressible, lossless analysis is performed using this pressure drop.
45  The difference between the two computed velocities is considered as an
46  error. The ideal inlet is modified so as to drive this error to zero. This
47  is accomplished by means of a PID control algorithm, for which
48  non-dimensional gains are specified by the user.
49 
50  The shape factor takes a value of 0 for a linear change in cross sectional
51  area between the two face zones. A value of 1 represents a step change in
52  area at the mid-point between the zones. A smooth cubic or cosine profile
53  between two zones with zero divergence is typically represented by a factor
54  of between 0.2 and 0.25.
55 
56  \heading Patch usage
57 
58  \table
59  Property | Description | Required | Default value
60  upstream | upstream face zone name | yes |
61  downstream | downstream face zone name | yes |
62  deltaP | desired pressure drop | yes |
63  shapeFactor | non-linearity in the nozzle | no | 0
64  p | pressure field name | no | p
65  phi | flux field name | yes | phi
66  rho | density field name | no | none
67  P | proportional gain | yes |
68  I | integral gain | yes |
69  D | differential gain | yes |
70  \endtable
71 
72  Example of the boundary condition specification:
73 
74  \verbatim
75  myPatch
76  {
77  type pressurePIDControlInletVelocity;
78  upstream upstream;
79  downstream downstream;
80  deltaP 200;
81  shapeFactor 0;
82  p p;
83  phi phi;
84  rho none;
85  P 0.5;
86  I 0.5;
87  D 0.1;
88  value uniform (0 0 0);
89  }
90  \endverbatim
91 
92 SeeAlso
93  Foam::fixedValueFvPatchField
94 
95 SourceFiles
96  pressurePIDControlInletVelocityFvPatchVectorField.C
97 
98 \*---------------------------------------------------------------------------*/
99 
100 #ifndef pressurePIDControlInletVelocityFvPatchVectorField_H
101 #define pressurePIDControlInletVelocityFvPatchVectorField_H
102 
103 #include "fixedValueFvPatchFields.H"
104 #include "Switch.H"
105 
106 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
107 
108 namespace Foam
109 {
110 /*---------------------------------------------------------------------------*\
111  Class pressurePIDControlInletVelocityFvPatchVectorField Declaration
112 \*---------------------------------------------------------------------------*/
113 
114 class pressurePIDControlInletVelocityFvPatchVectorField
115 :
116  public fixedValueFvPatchVectorField
117 {
118  // Private data
119 
120  //- Name of the upstream face zone
121  const word upstreamName_;
122 
123  //- Name of the downstream face zone
124  const word downstreamName_;
125 
126  //- Desired pressure difference between upstream and downstream
127  const scalar deltaP_;
128 
129  //- Nozzle shape factor
130  const scalar shapeFactor_;
131 
132  //- Name of the pressure field
133  const word pName_;
134 
135  //- Name of the flux field
136  const word phiName_;
137 
138  //- Name of the density field (if any)
139  const word rhoName_;
140 
141  //- Proportional gain
142  const scalar P_;
143 
144  //- Integral gain
145  const scalar I_;
146 
147  //- Derivative gain
148  const scalar D_;
149 
150  //- Volumetric flow rate
151  scalar Q_;
152 
153  //- Error
154  scalar error_;
155 
156  //- Error integral w.r.t. time
157  scalar errorIntegral_;
158 
159  //- Old volumetric flow rate
160  scalar oldQ_;
161 
162  //- Old error
163  scalar oldError_;
164 
165  //- Old error integral w.r.t. time
166  scalar oldErrorIntegral_;
167 
168  //- Time index of the last update
169  label timeIndex_;
170 
171 
172  // Private member functions
173 
174  //- Return the pressure interpolated to the faces
175  const surfaceScalarField& facePressure() const;
176 
177  //- Calculate the average on a face zone
178  template <class Type>
179  void faceZoneAverage
180  (
181  const word& name,
183  scalar& area,
184  Type& average
185  ) const;
186 
187 
188 public:
189 
190  //- Runtime type information
191  TypeName("pressurePIDControlInletVelocity");
192 
193 
194  // Constructors
195 
196  //- Construct from patch and internal field
198  (
199  const fvPatch&,
201  );
202 
203  //- Construct from patch, internal field and dictionary
205  (
206  const fvPatch&,
208  const dictionary&
209  );
210 
211  //- Construct by mapping given
212  // flowRateInletVelocityFvPatchVectorField
213  // onto a new patch
215  (
217  const fvPatch&,
219  const fvPatchFieldMapper&
220  );
221 
222  //- Construct as copy
224  (
226  );
227 
228  //- Construct and return a clone
229  virtual tmp<fvPatchVectorField> clone() const
230  {
232  (
234  (
235  *this
236  )
237  );
238  }
239 
240  //- Construct as copy setting internal field reference
242  (
245  );
246 
247  //- Construct and return a clone setting internal field reference
249  (
251  ) const
252  {
254  (
256  (
257  *this,
258  iF
259  )
260  );
261  }
262 
263 
264  // Member functions
265 
266  //- Update the coefficients associated with the patch field
267  virtual void updateCoeffs();
268 
269  //- Write
270  virtual void write(Ostream&) const;
271 };
272 
273 
274 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
275 
276 } // End namespace Foam
277 
278 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
279 
280 #ifdef NoRepository
282 #endif
283 
284 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
285 
286 #endif
287 
288 // ************************************************************************* //
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::pressurePIDControlInletVelocityFvPatchVectorField::clone
virtual tmp< fvPatchVectorField > clone() const
Construct and return a clone.
Definition: pressurePIDControlInletVelocityFvPatchVectorField.H:283
pressurePIDControlInletVelocityFvPatchVectorFieldTemplates.C
Foam::pressurePIDControlInletVelocityFvPatchVectorField::pressurePIDControlInletVelocityFvPatchVectorField
pressurePIDControlInletVelocityFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.
Definition: pressurePIDControlInletVelocityFvPatchVectorField.C:69
Foam::pressurePIDControlInletVelocityFvPatchVectorField::TypeName
TypeName("pressurePIDControlInletVelocity")
Runtime type information.
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
Foam::pressurePIDControlInletVelocityFvPatchVectorField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: pressurePIDControlInletVelocityFvPatchVectorField.C:211
Switch.H
field
rDeltaTY field()
Foam::pressurePIDControlInletVelocityFvPatchVectorField::write
virtual void write(Ostream &) const
Write.
Definition: pressurePIDControlInletVelocityFvPatchVectorField.C:356
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
fixedValueFvPatchFields.H
Foam::fieldTypes::area
const wordList area
Standard area field types (scalar, vector, tensor, etc)
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::pressurePIDControlInletVelocityFvPatchVectorField
This boundary condition tries to generate an inlet velocity that maintains a specified pressure drop ...
Definition: pressurePIDControlInletVelocityFvPatchVectorField.H:168
Foam::GeometricField< scalar, fvsPatchField, surfaceMesh >
Foam::average
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &df)
Definition: DimensionedFieldFunctions.C:328
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54