propellerDiskTemplates.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2024 OpenFOAM Foundation
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 "propellerDisk.H"
27 #include "fvMatrix.H"
28 #include "pimpleNoLoopControl.H"
29 #include "mathematicalConstants.H"
30 
31 using namespace Foam::constant::mathematical;
32 
33 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
34 
35 template<class AlphaFieldType, class RhoFieldType>
36 void Foam::fv::propellerDisk::addActuationDiskAxialInertialResistance
37 (
38  vectorField& Usource,
39  const AlphaFieldType& alpha,
40  const RhoFieldType& rho,
42 ) const
43 {
44  const labelUList& cells = set_.cells();
45  const scalarField& V = mesh().V();
46 
48  (
49  IOobject
50  (
51  typedName("force"),
52  mesh().time().name(),
53  mesh(),
56  ),
57  mesh(),
58  dimensionedVector(rho.dimensions()*U.dimensions()/dimTime, Zero)
59  );
60 
61  const vector centre = diskCentre();
62  const scalar delta = diskThickness(centre);
63 
64  // hub radius
65  const scalar rHub = 0.5*dHub_;
66 
67  // propeller radius
68  const scalar rProp = 0.5*dProp_;
69 
70  // Unit normal
71  const vector nHat = normalised(diskNormal_);
72 
73  // Disk area
74  const scalar A = (rProp - rHub)*(rProp - rHub)*pi;
75 
76  // Get reference to the n value
77  const scalar& n = this->n();
78 
79  // Evaluate advance number J,
80  // the volumetric mean advance speed of the disk
81  const scalar J = this->J(U, nHat);
82 
83  // Calculate the mean velocity through the disk
84  const scalar Udisk = n*dProp_*J;
85 
86  // ... and the volumetric flux through the disk
87  const scalar phiDisk = Udisk*A;
88 
89  if (phiDisk > small)
90  {
91  // Correction of advance number J based on mometum theory
92  // using the propeller curve Kt(J) and Kq(J)
93 
94  vector2D KtandKq(propellerFunction_->value(J));
95  scalar Kt = KtandKq.x();
96  scalar Kq = KtandKq.y();
97 
98  // Evaluate thrust based on Kt
99  // Thrust units are force/rho = [m^4/s^2]
100  scalar T = Kt*sqr(n)*pow4(dProp_);
101 
102  // Correction for speed based on momentum theory
103  const scalar Ucorr = T/(2*phiDisk);
104  const scalar Jcorr = (Udisk - Ucorr)/(n*dProp_);
105 
106  // Update Kt and Kq based on the corrected J value
107  KtandKq = propellerFunction_->value(Jcorr);
108  Kt = KtandKq.x();
109  Kq = KtandKq.y();
110  T = Kt*sqr(n)*pow4(dProp_);
111  const scalar Q = Kq*sqr(n)*pow5(dProp_);
112 
113  // Correct the rotation speed from the current propulsion force
114  correctn(T);
115 
116  // Distribute momentum source
117 
118  const scalar Ax =
119  (105/8.0)*T/(delta*pi*(rProp - rHub)*(3*rHub + 4*rProp));
120  const scalar At =
121  (105/8.0)*Q/(delta*pi*rProp*(rProp - rHub)*(3*rHub + 4*rProp));
122 
123  forAll(cells, i)
124  {
125  const label celli = cells[i];
126 
127  const vector r = mesh().cellCentres()[celli] - centre;
128  const scalar magr = mag(r);
129 
130  if (magr > rHub)
131  {
132  const scalar rPrime = magr/rProp;
133  const scalar rHubPrime = rHub/rProp;
134 
135  // Normalised radius
136  const scalar rStar =
137  min((rPrime - rHubPrime)/(1 - rHubPrime), 1);
138 
139  const scalar Faxial = Ax*rStar*sqrt(1 - rStar);
140  const scalar Ftangential =
141  At*rStar*sqrt(1 - rStar)
142  /(rStar*(1 - rHubPrime) + rHubPrime);
143 
144  // A unit normal vector to the direction of the tangent
145  const vector radiusOrtho = normalised(r ^ nHat);
146  const vector rotationVector = radiusOrtho*rotationDir_;
147 
148  force[celli] =
149  alpha[celli]*rho[celli]
150  *(Faxial*nHat + Ftangential*rotationVector);
151 
152  Usource[celli] += V[celli]*force[celli];
153  }
154  }
155 
156  if
157  (
158  mesh().lookupObject<pimpleNoLoopControl>("solutionControl")
159  .finalIter()
160  )
161  {
162  if (logFile_.valid())
163  {
164  logFile_->writeTime(n, J, Jcorr, Udisk, Ucorr, Kt, Kq, T, Q);
165  }
166 
167  if (mesh().time().writeTime())
168  {
169  force.write();
170  }
171  }
172  }
173 }
174 
175 
176 // ************************************************************************* //
static const Foam::dimensionedScalar A("A", Foam::dimPressure, 611.21)
scalar delta
label n
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const cellShapeList & cells
U
Definition: pEqn.H:72
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
mathematical constants.
Vector2D< scalar > vector2D
vector2D obtained from generic Vector2D
Definition: vector2D.H:49
static const zero Zero
Definition: zero.H:97
dimensionedScalar pow5(const dimensionedScalar &ds)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
dimensionedSymmTensor sqr(const dimensionedVector &dv)
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
const dimensionSet dimTime
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensionSet normalised(const dimensionSet &)
Definition: dimensionSet.C:510
dimensioned< scalar > mag(const dimensioned< Type > &)
word typedName(Name name)
Return the name of the object within the given type.
Definition: typeInfo.H:176
dimensionedScalar pow4(const dimensionedScalar &ds)
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
Field< vector > vectorField
Specialisation of Field<T> for vector.
UList< label > labelUList
Definition: UList.H:65
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)