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.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.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.0)[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.
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
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
valve_closure(name, rule)[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]
valve_opening(name, rule)[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]
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]

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.