mbsimhydraulics 4.0.0 MBSim Hydraulics Module

pressure_loss.h
1 /* Copyright (C) 2004-2009 MBSim Development Team
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 *
17 * Contact: markus.ms.schneider@gmail.com
18 */
19
20 #ifndef _PRESSURE_LOSS_H_
21 #define _PRESSURE_LOSS_H_
22
23 #include "mbsim/element.h"
24 #include <mbsim/functions/function.h>
25
26 namespace MBSimHydraulics {
27
28 class HydlinePressureloss;
29 class HLine;
30 // class RigidLine;
31 // class ClosableRigidLine;
32 // class PlaneLeakage0DOF;
33
35 class PressureLoss : public MBSim::Function<double(double)> {
36 public:
37 PressureLoss() = default;
38 virtual void setLine(const HLine *line_) { line = line_; }
39 // void init(InitStage stage, const MBSim::InitConfigSet &config);
40 protected:
41 const HLine *line{nullptr};
42 bool initialized{false};
43 };
44
45
47 class LinePressureLoss : public PressureLoss {
48 public:
49 LinePressureLoss() : PressureLoss() {}
50 };
51
52
54 class SerialResistanceLinePressureLoss : public LinePressureLoss {
55 public:
56 SerialResistanceLinePressureLoss() : LinePressureLoss() {}
57 ~SerialResistanceLinePressureLoss() override;
58 void setLine(const HLine *line_) override { line = line_; for(auto & i : slp) i->setLine(line); }
59 void addLinePressureLoss(LinePressureLoss * l) { slp.push_back(l); slp[slp.size()-1]->setParent(this); }
60 double operator()(const double& Q) override;
61 void init(MBSim::Element::InitStage stage, const MBSim::InitConfigSet &config) override;
62 void initializeUsingXML(xercesc::DOMElement * element) override;
63 void setDynamicSystemSolver(MBSim::DynamicSystemSolver *ds) override;
64 private:
65 std::vector<LinePressureLoss*> slp;
66 };
67
68
70 class ParallelResistanceLinePressureLoss : public LinePressureLoss {
71 public:
72 ParallelResistanceLinePressureLoss() : LinePressureLoss() {}
73 void setLine(const HLine *line_) override { line = line_; pl->setLine(line); }
74 void setLinePressureLoss(LinePressureLoss * pl_, int number_) {pl=pl_; number=double(number_); }
75 double operator()(const double& Q) override;
76 void init(MBSim::Element::InitStage stage, const MBSim::InitConfigSet &config) override;
77 void initializeUsingXML(xercesc::DOMElement * element) override;
78 private:
79 LinePressureLoss* pl{nullptr};
80 double number{0};
81 };
82
83
85 class ZetaLinePressureLoss : public LinePressureLoss {
86 public:
87 ZetaLinePressureLoss() : LinePressureLoss() {};
88 void setZeta(double zeta_) {c=zeta_; }
89 double operator()(const double& Q) override;
90 void initializeUsingXML(xercesc::DOMElement *element) override;
91 private:
92 double c{0};
93 };
94
95
97 class ZetaPosNegLinePressureLoss : public LinePressureLoss {
98 public:
99 ZetaPosNegLinePressureLoss() : LinePressureLoss() {};
100 void setZetaPos(double zeta_) {cPos=zeta_; }
101 void setZetaNeg(double zeta_) {cNeg=zeta_; }
102 double operator()(const double& Q) override;
103 void initializeUsingXML(xercesc::DOMElement *element) override;
104 private:
105 double cPos{0}, cNeg{0};
106 };
107
108
110 class LaminarTubeFlowLinePressureLoss : public LinePressureLoss {
111 public:
112 LaminarTubeFlowLinePressureLoss() : LinePressureLoss() {}
113 double operator()(const double& Q) override;
114 private:
115 double c{0};
116 };
117
118
120 class TurbulentTubeFlowLinePressureLoss : public LinePressureLoss {
121 public:
122 TurbulentTubeFlowLinePressureLoss() : LinePressureLoss() {}
123 ~TurbulentTubeFlowLinePressureLoss() override;
124 void setReferenceDiameter(double dRef_) {dRef=dRef_; }
125 void setHydraulicDiameter(double dHyd_, double dHydNeg_=0);
126 void setSurfaceRoughness(double k_) {k=k_; }
127 double operator()(const double& Q) override;
128 void init(MBSim::Element::InitStage stage, const MBSim::InitConfigSet &config) override;
129 void initializeUsingXML(xercesc::DOMElement *element) override;
130 private:
131 double c{0}, dRef{0}, dHyd{0}, dHydNeg{0}, k{0}, ReynoldsFactor{0}, ReynoldsFactorNeg{0};
132 MBSim::Function<double(double)> * lambdaTabular{nullptr};
133 };
134
135
137 class CurveFittedLinePressureLoss : public LinePressureLoss {
138 public:
139 CurveFittedLinePressureLoss() : LinePressureLoss() {}
140 void setFactors(double aPos_, double bPos_, double aNeg_, double bNeg_, double dRef_, double dHyd_) { aPos=aPos_; bPos=bPos_; aNeg=aNeg_; bNeg=bNeg_; dRef=dRef_; dHyd=dHyd_; }
141 double operator()(const double& Q) override;
142 void initializeUsingXML(xercesc::DOMElement *element) override;
143 private:
144 double dRef{0}, dHyd{0};
145 double aPos{0}, bPos{0}, aNeg{0}, bNeg{0};
146 double ReynoldsFactor{0};
147 };
148
149
151 class TabularLinePressureLoss : public LinePressureLoss {
152 public:
153 TabularLinePressureLoss() : LinePressureLoss() {};
154 ~TabularLinePressureLoss() override { delete zetaTabular; }
155 void setZetaTabular(MBSim::Function<double(double)> * zetaTabular_) {
156 zetaTabular=zetaTabular_;
157 zetaTabular->setParent(this);
158 zetaTabular->setName("Zeta");
159 }
160 double operator()(const double& Q) override;
161 void initializeUsingXML(xercesc::DOMElement *element) override;
162 void init(MBSim::Element::InitStage stage, const MBSim::InitConfigSet &config) override;
163 private:
164 MBSim::Function<double(double)> * zetaTabular{nullptr};
165 };
166
167
169 class ClosablePressureLoss : public PressureLoss {
170 public:
171 ClosablePressureLoss() : PressureLoss() {}
172 };
173
174
176 class RelativeAreaZetaClosablePressureLoss : public ClosablePressureLoss {
177 public:
178 RelativeAreaZetaClosablePressureLoss() : ClosablePressureLoss() {}
179 void setZeta(double zeta_) {c=zeta_; }
180 void setZetaNegative(double zeta_) {cNeg=zeta_; }
181 double operator()(const double& Q) override;
182 void initializeUsingXML(xercesc::DOMElement *element) override;
183 private:
184 double c{0}, cNeg{-1.};
185 };
186
187
189 class GapHeightClosablePressureLoss : public ClosablePressureLoss {
190 public:
191 GapHeightClosablePressureLoss() : ClosablePressureLoss() {}
192 void setLength(double l_) {l=l_; }
193 void setWidth(double b_) {b=b_; }
194 double operator()(const double& Q) override;
195 void initializeUsingXML(xercesc::DOMElement *element) override;
196 private:
197 double c{0}, l, b;
198 };
199
200
202 class ReynoldsClosablePressureLoss : public ClosablePressureLoss {
203 public:
204 ReynoldsClosablePressureLoss() : ClosablePressureLoss() {}
205 double operator()(const double& Q) override;
206 private:
207 double nu{0}, lambdaSlope{0}, lambdaOffset{0}, zetaFactor{0};
208 };
209
210
212 class RelativeAlphaClosablePressureLoss : public ClosablePressureLoss {
213 public:
214 RelativeAlphaClosablePressureLoss() : ClosablePressureLoss() {}
215 void setAlpha(double alpha_) {alpha=alpha_; assert(alpha>.01); assert(alpha<=1.); }
216 double operator()(const double& Q) override;
217 void initializeUsingXML(xercesc::DOMElement *element) override;
218 private:
219 double alpha{0}, alpha2{0}, c{0};
220 };
221
222
224 class CheckvalveClosablePressureLoss : public ClosablePressureLoss {
225 public:
226 CheckvalveClosablePressureLoss() : ClosablePressureLoss() {}
227 void setBallRadius(double rBall_) {rBall=rBall_; }
228 double getBallRadius() const {return rBall; }
229 virtual double calcBallForceArea() {return -1.; }
230 void initializeUsingXML(xercesc::DOMElement *element) override;
231 protected:
232 double rBall{0};
233 };
234
235
237 class GammaCheckvalveClosablePressureLoss : public CheckvalveClosablePressureLoss {
238 public:
239 GammaCheckvalveClosablePressureLoss() : CheckvalveClosablePressureLoss() {}
240 void setAlpha(double alpha_) {alpha=alpha_; }
241 void setGamma(double gamma_) {gamma=gamma_; }
242 double calcBallForceArea() override {return M_PI*rBall*rBall*sin(gamma)*sin(gamma); }
243 double operator()(const double& Q) override;
244 void initializeUsingXML(xercesc::DOMElement *element) override;
245 private:
246 double alpha{0}, gamma{0}, c{0}, siga{0}, coga{0};
247 };
248
249
251 class IdelchickCheckvalveClosablePressureLoss : public CheckvalveClosablePressureLoss {
252 public:
253 IdelchickCheckvalveClosablePressureLoss() : CheckvalveClosablePressureLoss() {}
254 double operator()(const double& Q) override;
255 private:
256 double d0{0}, c{0};
257 };
258
259
261 class ConeCheckvalveClosablePressureLoss : public CheckvalveClosablePressureLoss {
262 public:
263 ConeCheckvalveClosablePressureLoss() : CheckvalveClosablePressureLoss() {}
264 void setAlpha(double alpha_) {alpha=alpha_; }
265 double operator()(const double& Q) override;
266 void initializeUsingXML(xercesc::DOMElement *element) override;
267 private:
268 double alpha{0};
269 double numer[2], denom[2], c{0};
270 };
271
272
274 class LeakagePressureLoss : public PressureLoss {
275 public:
276 LeakagePressureLoss() : PressureLoss() {}
277 protected:
278 bool stateless{true};
279 };
280
281
283 class PlaneLeakagePressureLoss : public LeakagePressureLoss {
284 public:
285 PlaneLeakagePressureLoss() : LeakagePressureLoss() {}
286 double operator()(const double& pVorQ) override;
287 private:
288 double pVfac{0}, xdfac{0};
289 };
290
291
292
294 class CircularLeakagePressureLoss : public LeakagePressureLoss {
295 public:
296 CircularLeakagePressureLoss() : LeakagePressureLoss() {}
297 };
298
299
301 class EccentricCircularLeakagePressureLoss : public CircularLeakagePressureLoss {
302 public:
303 EccentricCircularLeakagePressureLoss() : CircularLeakagePressureLoss() {}
304 void setEccentricity(double ecc_) {ecc=ecc_; }
305 double operator()(const double& pVorQ) override;
306 void initializeUsingXML(xercesc::DOMElement *element) override;
307 private:
308 double ecc{0}, pVfac{0}, xdfac{0};
309 };
310
311
313 class RealCircularLeakagePressureLoss : public CircularLeakagePressureLoss {
314 public:
315 RealCircularLeakagePressureLoss() : CircularLeakagePressureLoss() {}
316 double operator()(const double& pVorQ) override;
317 private:
318 double pVfac{0}, vIfac{0}, vOfac{0};
319 };
320
321
323 class UnidirectionalPressureLoss : public PressureLoss {
324 public:
325 UnidirectionalPressureLoss() : PressureLoss() {}
326 };
327
328
330 class UnidirectionalZetaPressureLoss : public UnidirectionalPressureLoss {
331 public:
332 UnidirectionalZetaPressureLoss() : UnidirectionalPressureLoss() {}
333 void setZeta(double zeta_) {c=zeta_; }
334 double operator()(const double& Q) override;
335 void initializeUsingXML(xercesc::DOMElement *element) override;
336 private:
337 double c{0};
338 };
339
340
341 // // class PositiveFlowLimittingPressureLoss : public VariablePressureLoss {
342 // // public:
343 // // PositiveFlowLimittingPressureLoss(const std::string &name, Signal * checkSizeSignal) : VariablePressureLoss(name, checkSizeSignal) {}
344 // // bool isUnilateral() {return true; }
345 // // void update(const double& Q);
346 // // double operator()(const double& Q) {pLoss=0; return pLoss; }
347 // // protected:
348 // // double QLimit;
349 // // };
350 // //
351 // // class RegularizedPositiveFlowLimittingPressureLoss : public PositiveFlowLimittingPressureLoss {
352 // // public:
353 // // RegularizedPositiveFlowLimittingPressureLoss(const std::string &name, Signal * checkSizeSignal, double zeta1_,double offset_) : PositiveFlowLimittingPressureLoss(name, checkSizeSignal), zeta1(zeta1_), offset(offset_) {assert(offset>0); }
354 // // bool isUnilateral() {return false; }
355 // // double operator()(const double& Q);
356 // // private:
357 // // double zeta1, offset;
358 // // double zeta;
359 // // };
360 // //
361 // // class NegativeFlowLimittingPressureLoss : public VariablePressureLoss {
362 // // public:
363 // // NegativeFlowLimittingPressureLoss(const std::string &name, Signal * checkSizeSignal) : VariablePressureLoss(name, checkSizeSignal) {}
364 // // bool isUnilateral() {return true; }
365 // // void update(const double& Q);
366 // // double operator()(const double& Q) {pLoss=0; return pLoss; }
367 // // };
368
369 }
370
371 #endif /* ----- #ifndef _PRESSURE_LOSS_H_ ----- */
MBSimHydraulics::RelativeAreaZetaClosablePressureLoss
Definition: pressure_loss.h:176
MBSimHydraulics::RelativeAlphaClosablePressureLoss
Definition: pressure_loss.h:212
MBSimHydraulics::UnidirectionalPressureLoss
Definition: pressure_loss.h:323
MBSim::DynamicSystemSolver
MBSimHydraulics::LinePressureLoss
Definition: pressure_loss.h:47
MBSimHydraulics::ConeCheckvalveClosablePressureLoss
Definition: pressure_loss.h:261
MBSimHydraulics::HLine
Definition: hline.h:40
MBSimHydraulics::ClosablePressureLoss
Definition: pressure_loss.h:169
MBSimHydraulics::ReynoldsClosablePressureLoss
Definition: pressure_loss.h:202
MBSim::Element::ds
DynamicSystemSolver * ds
MBSimHydraulics::CurveFittedLinePressureLoss
Definition: pressure_loss.h:137
MBSimHydraulics::UnidirectionalZetaPressureLoss
Definition: pressure_loss.h:330
MBSimHydraulics::PressureLoss
Definition: pressure_loss.h:35
MBSimHydraulics::ParallelResistanceLinePressureLoss
Definition: pressure_loss.h:70
MBSimHydraulics::LeakagePressureLoss
Definition: pressure_loss.h:274
MBSimHydraulics::GapHeightClosablePressureLoss
Definition: pressure_loss.h:189
MBSim::Element::InitStage
InitStage
MBSimHydraulics::ZetaLinePressureLoss
Definition: pressure_loss.h:85
MBSimHydraulics::IdelchickCheckvalveClosablePressureLoss
Definition: pressure_loss.h:251
MBSimHydraulics::TurbulentTubeFlowLinePressureLoss
Definition: pressure_loss.h:120
MBSimHydraulics::SerialResistanceLinePressureLoss
Definition: pressure_loss.h:54
MBSim::Function
MBSimHydraulics::EccentricCircularLeakagePressureLoss
Definition: pressure_loss.h:301
MBSimHydraulics::GammaCheckvalveClosablePressureLoss
Definition: pressure_loss.h:237
MBSimHydraulics::LaminarTubeFlowLinePressureLoss
Definition: pressure_loss.h:110
MBSimHydraulics::RealCircularLeakagePressureLoss
Definition: pressure_loss.h:313
MBSim::Element::setName
void setName(const std::string &str)
MBSimHydraulics::PlaneLeakagePressureLoss
Definition: pressure_loss.h:283
MBSimHydraulics::CheckvalveClosablePressureLoss
Definition: pressure_loss.h:224
MBSimHydraulics::TabularLinePressureLoss
Definition: pressure_loss.h:151
MBSimHydraulics::CircularLeakagePressureLoss
Definition: pressure_loss.h:294
MBSimHydraulics::ZetaPosNegLinePressureLoss
Definition: pressure_loss.h:97