EPANET  3.0
EPANET Development Project
valve.h
Go to the documentation of this file.
1 /* EPANET 3
2  *
3  * Copyright (c) 2016 Open Water Analytics
4  * Licensed under the terms of the MIT License (see the LICENSE file for details).
5  *
6  */
7 
10 
11 #ifndef VALVE_H_
12 #define VALVE_H_
13 
14 #include "Elements/link.h"
15 
16 #include <string>
17 
18 class Network;
19 
24 
25 class Valve: public Link
26 {
27  public:
28 
29  enum ValveType {
30  PRV,
31  PSV,
32  FCV,
33  TCV,
34  PBV,
35  GPV
36  };
37  static const char* ValveTypeWords[];
38 
39  // Constructor/Destructor
40  Valve(std::string name_);
41  ~Valve();
42 
43  // Methods
44  int type();
45  std::string typeStr();
46  void convertUnits(Network* nw);
47  double convertSetting(Network* nw, double s);
48 
49  void setInitFlow();
50  void setInitStatus(int s);
51  void setInitSetting(double s);
52  void initialize(bool initFlow);
53 
54  bool isPRV();
55  bool isPSV();
56 
57  void findHeadLoss(Network* nw, double q);
58  void updateStatus(double q, double h1, double h2);
59  bool changeStatus(int newStatus,
60  bool makeChange,
61  const std::string reason,
62  std::ostream& msgLog);
63  bool changeSetting(double newSetting,
64  bool makeChange,
65  const std::string reason,
66  std::ostream& msgLog);
67  void validateStatus(Network* nw, double qTol);
68 
69  double getVelocity();
70  double getRe(const double q, const double viscos);
71  double getSetting(Network* nw);
72 
73  // Properties
75  double lossFactor;
76 
77  protected:
78  void findOpenHeadLoss(double q);
79  void findPbvHeadLoss(double q);
80  void findTcvHeadLoss(double q);
81  void findGpvHeadLoss(Network* nw, double q);
82  void findFcvHeadLoss(double q);
83  int updatePrvStatus(double q, double h1, double h2);
84  int updatePsvStatus(double q, double h1, double h2);
85 
87  double elev;
88 };
89 
90 //-----------------------------------------------------------------------------
91 // Inline Functions
92 //-----------------------------------------------------------------------------
93 
94 inline
95 int Valve::type() { return Link::VALVE; }
96 
97 inline
98 bool Valve::isPRV() { return valveType == PRV; }
99 
100 inline
101 bool Valve::isPSV() { return valveType == PSV; }
102 
103 #endif
flow control valve
Definition: valve.h:32
general purpose valve
Definition: valve.h:35
ValveType
Definition: valve.h:29
A Link that controls flow or pressure.
Definition: valve.h:25
double elev
elevation of PRV/PSV valve
Definition: valve.h:87
ValveType valveType
valve type
Definition: valve.h:74
bool hasFixedStatus
true if Open/Closed status is fixed
Definition: valve.h:86
double lossFactor
minor loss factor
Definition: valve.h:75
pressure sustaining valve
Definition: valve.h:31
pressure breaker valve
Definition: valve.h:34
pressure reducing valve
Definition: valve.h:30
Contains the data elements that describe a pipe network.
Definition: network.h:41
throttle control valve
Definition: valve.h:33