Tank#

module wntr.network.elements

class Tank[source]#

Bases: Node

Tank class, inherited from Node.

Tank volume can be defined using a constant diameter or a volume curve. If the tank has a volume curve, the diameter has no effect on hydraulic simulations.

Constructor

This class is intended to be instantiated through the add_tank() method. Direct creation through the constructor is highly discouraged.

Parameters:
  • name (string) – Name of the tank.

  • wn (WaterNetworkModel) – WaterNetworkModel object the tank will belong to

Attributes

name

The name of the node (read only)

node_type

returns "Tank"

head

(read-only) the current simulation head at the node (total head)

demand

(read-only) the current simulation demand at the node (actual demand)

elevation

elevation to the bottom of the tank.

init_level

The initial tank level at the start of simulation

min_level

minimum level for the tank to be able to drain

max_level

maximum level before tank begins to overflow (if permitted)

diameter

diameter of the tank as a cylinder

min_vol

minimum volume to be able to drain (when using a tank curve)

vol_curve_name

Name of the volume curve to use, or None

vol_curve

The volume curve, if defined (read only)

overflow

Is this tank allowed to overflow

mixing_model

The mixing model to be used by EPANET.

mixing_fraction

for water quality simulations only, the compartment size for 2-compartment mixing

bulk_coeff

bulk reaction coefficient for this tank only; leave None to use global value

coordinates

The node coordinates, (x,y)

initial_quality

The initial quality (concentration) at the node

tag

A tag or label for the node

Read-only simulation results

head

(read-only) the current simulation head at the node (total head)

level

(read-only) the current simulation tank level (= head - elevation)

pressure

(read-only) the current simulation pressure (head - elevation)

quality

(read-only) the current simulation quality at the node

leak_demand

(read-only) the current simulation leak demand at the node

leak_status

(read-only) the current simulation leak status at the node

leak_area

(read-only) the current simulation leak area at the node

leak_discharge_coeff

(read-only) the current simulation leak discharge coefficient


__init__(name, wn)[source]#
add_leak(wn, area, discharge_coeff=0.75, start_time=None, end_time=None)[source]#

Add a leak to a tank.

Leaks are modeled by:

Q = discharge_coeff*area*sqrt(2*g*h)

where:

Q is the volumetric flow rate of water out of the leak g is the acceleration due to gravity h is the gauge head at the bottom of the tank, P_g/(rho*g); Note that this is not the hydraulic head (P_g + elevation)

Note that WNTR assumes the leak is at the bottom of the tank.

Parameters:
  • wn (WaterNetworkModel) – The WaterNetworkModel object containing the tank with the leak. This information is needed because the WaterNetworkModel object stores all controls, including when the leak starts and stops.

  • area (float) – Area of the leak in m^2.

  • discharge_coeff (float) – Leak discharge coefficient; Takes on values between 0 and 1.

  • start_time (int) – Start time of the leak in seconds. If the start_time is None, it is assumed that an external control will be used to start the leak (otherwise, the leak will not start).

  • end_time (int) – Time at which the leak is fixed in seconds. If the end_time is None, it is assumed that an external control will be used to end the leak (otherwise, the leak will not end).

get_volume(level=None)[source]#

Returns tank volume at a given level

Parameters:

level (float or NoneType (optional)) – The level at which the volume is to be calculated. If level=None, then the volume is calculated at the current tank level (self.level)

Returns:

vol – Tank volume at a given level

Return type:

float

remove_leak(wn)[source]#

Remove a leak from a tank

Parameters:

wn (WaterNetworkModel) – Water network model

to_dict()#

Dictionary representation of the node

to_ref()#
property bulk_coeff#

bulk reaction coefficient for this tank only; leave None to use global value

Type:

float

property coordinates#

The node coordinates, (x,y)

Type:

tuple

property demand#

(read-only) the current simulation demand at the node (actual demand)

Type:

float

property diameter#

diameter of the tank as a cylinder

Type:

float

property elevation#

elevation to the bottom of the tank. head = level + elevation

Type:

float

property head#

(read-only) the current simulation head at the node (total head)

Type:

float

property init_level#

The initial tank level at the start of simulation

property initial_quality#

The initial quality (concentration) at the node

Type:

float

property leak#

(read-only) the current simulation leak area at the node

Type:

float

property leak_area#

(read-only) the current simulation leak area at the node

Type:

float

property leak_demand#

(read-only) the current simulation leak demand at the node

Type:

float

property leak_discharge_coeff#

(read-only) the current simulation leak discharge coefficient

Type:

float

property leak_status#

(read-only) the current simulation leak status at the node

Type:

bool

property level#

(read-only) the current simulation tank level (= head - elevation)

Type:

float

property max_level#

maximum level before tank begins to overflow (if permitted)

Type:

float

property min_level#

minimum level for the tank to be able to drain

Type:

float

property min_vol#

minimum volume to be able to drain (when using a tank curve)

Type:

float

property mixing_fraction#

for water quality simulations only, the compartment size for 2-compartment mixing

Type:

float

property mixing_model#

The mixing model to be used by EPANET. This only affects water quality simulations and has no impact on the WNTRSimulator. Uses the MixType enum object, or it will convert string values from MIXED, 2COMP, FIFO and LIFO. By default, this is set to None, and will produce no output in the EPANET INP file and EPANET will assume complete and instantaneous mixing (MIXED).

property name#

The name of the node (read only)

Type:

str

property node_type#

returns "Tank"

property overflow#

Is this tank allowed to overflow

Type:

bool

property pressure#

(read-only) the current simulation pressure (head - elevation)

Type:

float

property quality#

(read-only) the current simulation quality at the node

Type:

float

property tag#

A tag or label for the node

Type:

str

property vol_curve#

The volume curve, if defined (read only)

Set this using the vol_curve_name.

property vol_curve_name#

Name of the volume curve to use, or None