FlowUnits#
module wntr.epanet.util
- class FlowUnits[source]#
Bases:
Enum
Epanet Units Enum class
EPANET has defined unit codes that are used in its INP input files. This enumerated type class provides the appropriate values, rather than setting up a large number of constants. Additionally, each Enum value has a property that identifies it as either traditional or metric flow unit. EPANET does not use fully SI units - these are provided for WNTR compatibility.
Enum Members
\(\rm ft^3\,/\,s\)
\(\rm gal\,/\,min\)
\(\rm 10^6\,gal\,/\,day\)
\(\rm 10^6\,Imp.\,gal\,/\,day\)
\(\rm acre\cdot\,ft\,/\,day\)
\(\rm L\,/\,s\)
\(\rm L\,/\,min\)
\(\rm ML\,/\,day\)
\(\rm m^3\,\,hr\)
\(\rm m^3\,/\,day\)
\(\rm m^3\,/\,s\)
Enum Member Attributes
The conversion factor to convert units into SI units of \(m^3\,s^{-1}\).
True if flow unit is a US Customary (traditional) unit.
True if flow unit is an SI Derived (metric) unit.
Examples
>>> from wntr.epanet import FlowUnits >>> FlowUnits.GPM <FlowUnits.GPM: (1, 6.30901964e-05)>
Units can be converted to the EPANET integer values by casting as an
int
and can be converted to a string by accessing thename
property. The factor to convert to SI units is accessed using thefactor
property.>>> FlowUnits.LPS.name 'LPS' >>> int(FlowUnits.LPS) 5
The reverse is also true, where an
int
from an EPANET run or the string from and input file can be used to get aFlowUnits
object.>>> FlowUnits(4) <FlowUnits.AFD: (4, 0.014276410185185185)> >>> FlowUnits['CMD'] <FlowUnits.CMD: (9, 1.1574074074074073e-05)>
Units can be checked for metric or US customary status using the
is_traditional
oris_metric
options.>>> FlowUnits.GPM.is_traditional True >>> FlowUnits.GPM.is_metric False
Conversion can be done using the factor attribute. For example, to convert 10 AFD to SI units, and to convert 10 MGD to MLD,
>>> 10 * FlowUnits.AFD.factor 0.14276410185185184 >>> 10 * FlowUnits.MGD.factor / FlowUnits.MLD.factor 37.85411784000001
Note
This Enum uses a value of 0 for one of its members, and therefore acts in a non-standard way when evaluating truth values. Use
None
/is None
to check for truth values for variables storing a FlowUnits.
- AFD = (4, 0.014276410185185185)#
- CFS = (0, 0.0283168466)#
- CMD = (9, 1.1574074074074073e-05)#
- CMH = (8, 0.0002777777777777778)#
- GPM = (1, 6.30901964e-05)#
- IMGD = (3, 0.05261678240740741)#
- LPM = (6, 1.6666666666666667e-05)#
- LPS = (5, 0.001)#
- MGD = (2, 0.043812636388888895)#
- MLD = (7, 0.011574074074074073)#
- SI = (11, 1.0)#
- property factor#
The conversion factor to convert units into SI units of \(m^3\,s^{-1}\).
Letting values in the original units be \(v\), and the resulting values in SI units be \(s\), the conversion factor, \(f\), such that
\[v f = s\]- Type:
- property is_metric#
True if flow unit is an SI Derived (metric) unit.
Metric units include LPS, LPM, MLD, CMH, and CMD. This ‘does not’ include FlowUnits.SI itself, only ‘derived’ units.
Examples
>>> FlowUnits.MGD.is_metric False >>> FlowUnits.MLD.is_metric True >>> FlowUnits.SI.is_metric False
- Type: