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

CFS

\(\rm ft^3\,/\,s\)

is_traditional

GPM

\(\rm gal\,/\,min\)

is_traditional

MGD

\(\rm 10^6\,gal\,/\,day\)

is_traditional

IMGD

\(\rm 10^6\,Imp.\,gal\,/\,day\)

is_traditional

AFD

\(\rm acre\cdot\,ft\,/\,day\)

is_traditional

LPS

\(\rm L\,/\,s\)

is_metric

LPM

\(\rm L\,/\,min\)

is_metric

MLD

\(\rm ML\,/\,day\)

is_metric

CMH

\(\rm m^3\,\,hr\)

is_metric

CMD

\(\rm m^3\,/\,day\)

is_metric

SI

\(\rm m^3\,/\,s\)

Enum Member Attributes

factor

The conversion factor to convert units into SI units of \(m^3\,s^{-1}\).

is_traditional

True if flow unit is a US Customary (traditional) unit.

is_metric

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 the name property. The factor to convert to SI units is accessed using the factor 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 a FlowUnits 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 or is_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.


__init__(EN_id, flow_factor=1.0)[source]#
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:

float

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:

bool

property is_traditional#

True if flow unit is a US Customary (traditional) unit.

Traditional units include CFS, GPM, MGD, IMGD and AFD.

Examples

>>> FlowUnits.MGD.is_traditional
True
>>> FlowUnits.MLD.is_traditional
False
>>> FlowUnits.SI.is_traditional
False
Type:

bool