40Foam::pressurePIDControlInletVelocityFvPatchVectorField::facePressure()
const
42 const word pfName(pName_ +
"f");
67Foam::pressurePIDControlInletVelocityFvPatchVectorField::
68pressurePIDControlInletVelocityFvPatchVectorField
75 upstreamName_(
word::null),
76 downstreamName_(
word::null),
85 Q_(-
gSum(*this & patch().Sf())),
95Foam::pressurePIDControlInletVelocityFvPatchVectorField::
96pressurePIDControlInletVelocityFvPatchVectorField
105 upstreamName_(ptf.upstreamName_),
106 downstreamName_(ptf.downstreamName_),
107 deltaP_(ptf.deltaP_),
108 shapeFactor_(ptf.shapeFactor_),
110 phiName_(ptf.phiName_),
111 rhoName_(ptf.rhoName_),
117 errorIntegral_(ptf.errorIntegral_),
119 oldError_(ptf.oldError_),
120 oldErrorIntegral_(ptf.oldErrorIntegral_),
121 timeIndex_(ptf.timeIndex_)
125Foam::pressurePIDControlInletVelocityFvPatchVectorField::
126pressurePIDControlInletVelocityFvPatchVectorField
136 deltaP_(
dict.get<scalar>(
"deltaP")),
137 shapeFactor_(
dict.getOrDefault<scalar>(
"shapeFactor", 0)),
138 pName_(
dict.getOrDefault<
word>(
"p",
"p")),
139 phiName_(
dict.getOrDefault<
word>(
"phi",
"phi")),
140 rhoName_(
dict.getOrDefault<
word>(
"rho",
"none")),
141 P_(
dict.get<scalar>(
"P")),
142 I_(
dict.get<scalar>(
"I")),
143 D_(
dict.get<scalar>(
"D")),
144 Q_(-
gSum(*this & patch().Sf())),
145 error_(
dict.getOrDefault<scalar>(
"error", 0)),
146 errorIntegral_(
dict.getOrDefault<scalar>(
"errorIntegral", 0)),
149 oldErrorIntegral_(0),
154Foam::pressurePIDControlInletVelocityFvPatchVectorField::
155pressurePIDControlInletVelocityFvPatchVectorField
161 upstreamName_(ptf.upstreamName_),
162 downstreamName_(ptf.downstreamName_),
163 deltaP_(ptf.deltaP_),
164 shapeFactor_(ptf.shapeFactor_),
166 phiName_(ptf.phiName_),
167 rhoName_(ptf.rhoName_),
173 errorIntegral_(ptf.errorIntegral_),
175 oldError_(ptf.oldError_),
176 oldErrorIntegral_(ptf.oldErrorIntegral_),
177 timeIndex_(ptf.timeIndex_)
181Foam::pressurePIDControlInletVelocityFvPatchVectorField::
182pressurePIDControlInletVelocityFvPatchVectorField
189 upstreamName_(ptf.upstreamName_),
190 downstreamName_(ptf.downstreamName_),
191 deltaP_(ptf.deltaP_),
192 shapeFactor_(ptf.shapeFactor_),
194 phiName_(ptf.phiName_),
195 rhoName_(ptf.rhoName_),
201 errorIntegral_(ptf.errorIntegral_),
203 oldError_(ptf.oldError_),
204 oldErrorIntegral_(ptf.oldErrorIntegral_),
205 timeIndex_(ptf.timeIndex_)
222 const scalar deltaT(db().time().deltaTValue());
227 db().lookupObject<surfaceScalarField>(phiName_)
231 if (timeIndex_ != db().time().
timeIndex())
233 timeIndex_ = db().time().timeIndex();
236 oldErrorIntegral_ = errorIntegral_;
250 rho =
gSum(rhoField*patch().magSf())/
gSum(patch().magSf());
255 <<
"The dimensions of the field " << phiName_
256 <<
"are not recognised. The dimensions are " <<
phi.
dimensions()
258 <<
" for an incompressible case, or "
264 const scalar patchA =
gSum(patch().magSf());
265 Q_ = -
gSum(*
this & patch().Sf());
270 faceZoneAverage(upstreamName_,
mesh.
Cf(), Aa, xa);
271 faceZoneAverage(downstreamName_,
mesh.
Cf(), Ab, xb);
272 const scalar
L =
mag(xa - xb);
273 const scalar LbyALinear =
L/(Aa - Ab)*
log(Aa/Ab);
274 const scalar LbyAStep =
L/2*(1/Aa + 1/Ab);
275 const scalar LbyA = (1 - shapeFactor_)*LbyALinear + shapeFactor_*LbyAStep;
281 scalar deltaP = deltaP_;
285 faceZoneAverage(upstreamName_, facePressure(), Aa, pa);
286 faceZoneAverage(downstreamName_, facePressure(), Ab, pb);
292 <<
"The pressure field name, 'p' is \"" << pName_ <<
"\", "
293 <<
"but a field of that name was not found. The inlet velocity "
294 <<
"will be set to an analytical value calculated from the "
295 <<
"specified pressure drop. No PID control will be done and "
296 <<
"transient effects will be ignored. This behaviour is designed "
297 <<
"to be appropriate for potentialFoam solutions. If you are "
298 <<
"getting this warning from another solver, you have probably "
299 <<
"specified an incorrect pressure name."
304 scalar QTarget, QMeasured;
305 const scalar a = (1/
sqr(Ab) - 1/
sqr(Aa))/(2*
rho);
308 const scalar
b = LbyA/deltaT;
309 const scalar c = - LbyA/deltaT*oldQ_ ;
310 QTarget = (-
b +
sqrt(
sqr(
b) - 4*a*(c - deltaP_)))/(2*a);
311 QMeasured = (-
b +
sqrt(
sqr(
b) - 4*a*(c - deltaP)))/(2*a);
315 QTarget =
sqrt(deltaP_/a);
316 QMeasured =
sqrt(deltaP/a);
320 error_ = QTarget - QMeasured;
321 errorIntegral_ = oldErrorIntegral_ + 0.5*(error_ + oldError_);
322 const scalar errorDifferential = oldError_ - error_;
332 + D_*errorDifferential
340 const scalar
error = deltaP/deltaP_ - 1;
341 const scalar newQ = -
gSum(*
this & patch().Sf());
342 Info<<
"pressurePIDControlInletVelocityFvPatchField " << patch().name()
348 << (
error < 0 ?
"below" :
"above") <<
" the target)" <<
endl;
374 writeEntry(
"value",
os);
Macros for easy insertion into run-time selection tables.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const dimensionSet & dimensions() const
Return dimensions.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Ostream & writeEntryIfDifferent(const word &key, const T &value1, const T &value2)
Write a keyword/value entry only when the two values differ.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
Class to handle errors and exceptions in a simple, consistent stream-based manner.
This boundary condition supplies a fixed value constraint, and is the base class for a number of othe...
virtual bool write()
Write the output fields.
Mesh data needed to do the Finite Volume discretisation.
const surfaceVectorField & Cf() const
Return face centres as surfaceVectorField.
A FieldMapper for finite-volume patch fields.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
This boundary condition tries to generate an inlet velocity that maintains a specified pressure drop ...
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Lookup type of boundary radiation properties.
bool steady() const noexcept
True if default ddtScheme is steady-state.
A class for handling words, derived from Foam::string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
#define makePatchTypeField(PatchTypeField, typePatchTypeField)
#define WarningInFunction
Report a warning using Foam::Warning.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Type gSum(const FieldField< Field, Type > &f)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
GeometricField< scalar, fvPatchField, volMesh > volScalarField
const dimensionSet dimArea(sqr(dimLength))
const dimensionSet dimVelocity
messageStream Info
Information stream (stdout output on master, null elsewhere)
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
dimensionedScalar log(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > linearInterpolate(const GeometricField< Type, fvPatchField, volMesh > &vf)
const dimensionSet dimDensity
errorManipArg< error, int > exit(error &err, const int errNo=1)
const vector L(dict.get< vector >("L"))