tsnet.network package

Submodules

tsnet.network.control module

The tsnet.network.control module includes method to define network controls of the pump and valve.These control modify parameters in the network during transient simulation.

tsnet.network.control.valveclosing(dt, tf, valve_op)[source]

Define valve operation curve (percentage open v.s. time)

Parameters:
  • dt (float) – Time step
  • tf (float) – Simulation Time
  • valve_op (list) – Contains parameters to define valve operation rule valve_op = [tc,ts,se,m] tc : the duration takes to close the valve [s] ts : closure start time [s] se : final open percentage [s] m : closure constant [unitless]
Returns:

s – valve operation curve

Return type:

list

tsnet.network.control.valveopening(dt, tf, valve_op)[source]

Define valve operation curve (percentage open v.s. time)

Parameters:
  • dt (float) – Time step
  • tf (float) – Simulation Time
  • valve_op (list) – Contains parameters to define valve operation rule valve_op = [tc,ts,se,m] tc : the duration takes to close the valve [s] ts : closure start time [s] se : final open percentage [s] m : closure constant [unitless]
Returns:

s – valve operation curve

Return type:

list

tsnet.network.control.pumpclosing(dt, tf, pump_op)[source]

Define pump operation curve (percentage open v.s. time)

Parameters:
  • dt (float) – Time step
  • tf (float) – Simulation Time
  • valve_op (list) – Contains parameters to define valve operation rule valve_op = [tc,ts,se,m] tc : the duration takes to close the valve [s] ts : closure start time [s] se : final open percentage [s] m : closure constant [unitless]
Returns:

s – valve operation curve

Return type:

list

tsnet.network.control.pumpopening(dt, tf, pump_op)[source]

Define pump operation curve (percentage open v.s. time)

Parameters:
  • dt (float) – Time step
  • tf (float) – Simulation Time
  • pump_op (list) – Contains parameters to define pump operation rule pump_op = [tc,ts,se,m] tc : the duration takes to start up the pump [s] ts : open start time [s] se : final open percentage [s] m : closure constant [unitless]
Returns:

s – valve operation curve

Return type:

list

tsnet.network.control.burstsetting(dt, tf, ts, tc, final_burst_coeff)[source]

Calculate the burst area as a function of simulation time

Parameters:
  • dt (float) – Time step
  • tf (float) – Simulation Time
  • ts (float) – Burst start time
  • tc (float) – Time for burst to fully develop
  • final_burst_coeff (list or float) – Final emitter coefficient at the burst nodes
tsnet.network.control.demandpulse(dt, tf, tc, ts, tp, dp)[source]

Calculate demand pulse multiplier

Parameters dt : float

Time step
tf : float
Simulation Time
tc : float
Total pulse duration
ts : float
Pulse start time
tp : float
Pulse increase time
dp : float
Pulse multiplier

tsnet.network.discretize module

The tsnet.network.discretize contains methods to perform spatial and temporal discretization by adjusting wave speed and time step to solve compatibility equations in case of uneven wave travel time.

tsnet.network.discretize.discretization(tm, dt)[source]

Discretize in temporal and spatial space using wave speed adjustment scheme.

Parameters:
  • tm (tsnet.network.geometry.TransientModel) – Network
  • dt (float) – User defined time step
Returns:

tm – Network with updated parameters

Return type:

tsnet.network.geometry.TransientModel

tsnet.network.discretize.max_time_step(tm)[source]

Determine the maximum time step based on Courant’s criteria.

Parameters:tm (tsnet.network.geometry.TransientModel) – Network
Returns:max_dt – Maximum time step allowed for this network
Return type:float
tsnet.network.discretize.discretization_N(tm, dt)[source]

Discretize in temporal and spatial space using wave speed adjustment scheme.

Parameters:
  • tm (tsnet.network.geometry.TransientModel) – Network
  • dt (float) – User defined time step
Returns:

tm – Network with updated parameters

Return type:

tsnet.network.geometry.TransientModel

tsnet.network.discretize.max_time_step_N(tm, N)[source]

Determine the maximum time step based on Courant’s criteria.

Parameters:tm (tsnet.network.geometry.TransientModel) – Network
Returns:max_dt – Maximum time step allowed for this network
Return type:float
tsnet.network.discretize.cal_N(tm, dt)[source]

Determine the number of computation unites ($N_i$) for each pipes.

Parameters:
  • tm (tsnet.network.geometry.TransientModel) – Network
  • dt (float) – Time step for transient simulation
tsnet.network.discretize.adjust_wavev(tm)[source]

Adjust wave speed and time step to solve compatibility equations.

Parameters:tm (tsnet.network.geometry.TransientModel) – Network
Returns:
  • tm (tsnet.network.geometry.TransientModel) – Network with adjusted wave speed.
  • dt (float) – Adjusted time step

tsnet.network.model module

The tsnet.network.geometry read in the geometry defined by EPANet .inp file, and assign additional parameters needed in transient simulation later in tsnet.

class tsnet.network.model.TransientModel(inp_file)[source]

Bases: wntr.network.model.WaterNetworkModel

Transient model class. :param inp_file_name: Directory and filename of EPANET inp file to load into the

WaterNetworkModel object.
set_wavespeed(wavespeed=1200, pipes=None)[source]

Set wave speed for pipes in the network

Parameters:
  • wavespeed (float or int or list, optional) – If given as float or int, set the value as wavespeed for all pipe; If given as list set the corresponding value to each pipe, by default 1200.
  • pipes (str or list, optional) – The list of pipe to define wavespeed, by default all pipe in the network.
set_roughness(roughness, pipes=None)[source]

Set roughness coefficient for pipes in the network

Parameters:
  • roughness (float or int or list) – If given as float or int, set the value as roughness for all pipe; If given as list set the corresponding value to each pipe. Make sure to define it using the same method (H-W or D-W) as defined in .inp file.
  • pipes (str or list, optional) – The list of pipe to define roughness coefficient, by default all pipe in the network.
set_time(tf, dt=None)[source]

Set time step and duration for the simulation.

Parameters:
  • tf (float) – Simulation period
  • dt (float, optional) – time step, by default maximum allowed dt
set_time_N(tf, N=2)[source]

Set time step and duration for the simulation.

Parameters:
  • tf (float) – Simulation period
  • N (integer) – Number of segments in the critical pipe
add_leak(name, coeff)[source]

Add leak to the transient model

Parameters:
  • name (str, optional) – The name of the leak nodes, by default None
  • coeff (list or float, optional) – Emitter coefficient at the leak nodes, by default None
add_burst(name, ts, tc, final_burst_coeff)[source]

Add leak to the transient model

Parameters:
  • name (str) – The name of the leak nodes, by default None
  • ts (float) – Burst start time
  • tc (float) – Time for burst to fully develop
  • final_burst_coeff (list or float) – Final emitter coefficient at the burst nodes
add_blockage(name, percentage)[source]

Add blockage to the transient model

Parameters:
  • name (str) – The name of the blockage nodes, by default None
  • percentage (list or float) – The percentage of the blockage flow discharge
valve_closure(name, rule, curve=None)[source]

Set valve closure rule

Parameters:
  • name (str) – The name of the valve to close
  • rule (list) – Contains paramters to define valve operation rule rule = [tc,ts,se,m] tc : the duration takes to close the valve [s] ts : closure start time [s] se : final open percentage [s] m : closure constant [unitless]
  • curve (list) – [(open_percentage[i], 1/kl[i]) for i ] List of open percentage and the corresponding inverse of valve coefficient
valve_opening(name, rule, curve=None)[source]

Set valve opening rule

Parameters:
  • name (str) – The name of the valve to close
  • rule (list) – Contains paramters to define valve operation rule rule = [tc,ts,se,m] tc : the duration takes to open the valve [s] ts : opening start time [s] se : final open percentage [s] m : closure constant [unitless]
  • curve (list) – [(open_percentage[i], kl[i]) for i ] List of open percentage and the corresponding valve coefficient
pump_shut_off(name, rule)[source]

Set pump shut off rule

Parameters:
  • name (str) – The name of the pump to shut off
  • rule (list) – Contains paramaters to define valve operation rule rule = [tc,ts,se,m] tc : the duration takes to close the pump [s] ts : closure start time [s] se : final open percentage [s] m : closure constant [unitless]
pump_start_up(name, rule)[source]

Set pump start up rule

Parameters:
  • name (str) – The name of the pump to shut off
  • rule (list) – Contains paramaters to define valve operation rule rule = [tc,ts,se,m] tc : the duration takes to close the valve [s] ts : closure start time [s] se : final open percentage [s] m : closure constant [unitless]
add_demand_pulse(name, rule)[source]

Add demand pulse to junction

Parameters:
  • name (str or list) –
    The name of junctions to add demand pulse
    rule : list

    Contains paramters to define valve operation rule

  • = [tc,ts,stay,dp,m] (rule) – tc : total duration of the pulse [s] [s] ts : start time of demand [s] stay: duration of the demand to stay at peak level [s] dp : demand pulse multiplier [uniteless]
add_surge_tank(name, shape, tank_type='open')[source]

Add surge tank

Parameters:
  • name (str) – the name of the node to add a surge tank
  • shape (list) –
    if closed: [As, Ht, Hs]
    As : cross-sectional area of the surge tank Ht : tank height Hs : initial water height in the surge tank

    if open: [As]

  • tank_type (int) – type of the surge tank, “closed” or “open”, by default ‘open’
detect_pressure_change(name, threshold, drift, show=False, ax=None)[source]

Detect pressure change in simulation results

Parameters:
  • name (str) – The name of the node
  • threshold (positive number, optional (default = 1)) – amplitude threshold for the change in the data.
  • drift (positive number, optional (default = 0)) – drift term that prevents any change in the absence of change.
  • show (bool, optional (default = True)) – True (1) plots data in matplotlib figure, False (0) don’t plot.
  • ax (a matplotlib.axes.Axes instance, optional (default = None)) –
plot_node_head(name, ax=None)[source]

Detect pressure change in simulation results

Parameters:
  • name (str or list) – The name of node
  • ax (a matplotlib.axes.Axes instance, optional (default = None)) –

tsnet.network.topology module

The tsnet.network.topology figure out the topology, i.e., upstream and downstream adjacent links for each pipe, and store the information in lists.

tsnet.network.topology.topology(wn)[source]

Figure out the topology of the network

Parameters:
  • wn (wntr.network.model.WaterNetworkModel) – .inp file used for EPAnet simulation
  • npipe (integer) – Number of pipes
Returns:

  • links1 (list) – The id of adjacent pipe on the start node. The sign represents the direction of the pipe. + : flowing into the junction - : flowing out from the junction
  • links2 (list) – The id of adjacent pipe on the end node. The sign represents the direction of the pipe. + : flowing into the junction - : flowing out from the junction
  • utype (list) – The type of the upstream adjacent links. If the link is not pipe, the name of that link will also be included. If there is no upstream link, the type of the start node will be recorded.
  • dtype (list) – The type of the downstream adjacent links. If the link is not pipe, the name of that link will also be included. If there is no downstream link, the type of the end node will be recorded.

Module contents

The tsnet.network package contains methods to define 1. a water network geometry, 2. network topology, 3. network control, and 4 .spatial and temporal discretization.