Internal Pipeflow Functions and Setup

Just for completeness, here is an overview over the auxiliary functions that are used internally in the pipeflow setup and were not yet described:

add_table_lookup(table_lookup, table_name, table_number)

Auxiliary function to add a lookup between table name in the pandapipes net and table number in the internal structure (pit).

Parameters:
  • table_lookup (dict) – The lookup dictionary from table names to internal number (n2t) and vice versa (t2n)

  • table_name (str) – Name of the table that shall be mapped to number

  • table_number (int) – Number under which the table is saved in the pit

Returns:

No output

create_empty_pit(net)

Creates an empty internal structure which is called pit (pandapipes internal tables). The structure is a dictionary which should contain one array for all nodes and one array for all branches of the net. It is very often referred to within the pipeflow. So the structure in general looks like this:

>>> net["_pit"] = {"node": np.array((no_nodes, col_nodes), dtype=np.float64),
>>>                "branch": np.array((no_branches, col_branches), dtype=np.float64)}
Parameters:

net (pandapipesNet) – The pandapipes net to which to add the empty structure

Returns:

pit - The dict of arrays with the internal node / branch structure

Return type:

dict

create_internal_results(net)

Initializes a dictionary that shall contain some internal results later.

Parameters:

net (pandapipesNet) – pandapipes net to which internal result dict will be added

Returns:

No output

create_lookups(net)

Create all lookups necessary for the pipeflow of the given net. The lookups are usually:

  • node_from_to: The start and end indices of all node component tables within the pit

  • branch_from_to: The start and end indices of all branch component tables within the pit

  • node_table: Dictionary to determine indices for node component tables (e.g. {“junction”: 0}). Can be arbitrary and strongly depends on the component order given by get_component_list.

  • branch_table: Dictionary to determine indices for branch component tables (e.g. {“pipe”: 0, “valve”: 1}). Can be arbitrary and strongly depends on the component order given by get_component_list.

  • node_index: Lookup from component index (e.g. junction 2) to pit index (e.g. 0) for nodes.

  • branch_index: Lookup from component index (e.g. pipe 1) to pit index (e.g. 5) for branches.

  • internal_nodes_lookup: Lookup for internal nodes of branch components that makes result extraction a lot easier.

Parameters:

net (pandapipesNet) – The pandapipes network for which to create the lookups

Returns:

No output

extract_all_results(net, calculation_mode)

Extract results from branch pit and node pit and write them to the different tables of the net, as defined by the component models.

Parameters:
  • net (str) – pandapipes net for which to extract results into net.res_xy

  • net – mode of the simulation (e.g. “hydraulics” or “heat” or “sequential” or “bidirectional”)

Returns:

No output

extract_results_active_pit(net, mode='hydraulics')

Extract the pipeflow results from the internal pit structure (“_active_pit”) to the general pit structure.

Parameters:
  • net (pandapipesNet) – The pandapipes net that the internal structure belongs to

  • mode (str, default "hydraulics") – defines whether results from hydraulic or temperature calculation are transferred

Returns:

No output

get_lookup(net, pit_type='node', lookup_type='index')

Returns internal lookups which are mostly defined in the function create_lookups.

Parameters:
  • net (pandapipesNet) – The pandapipes net for which the lookup is requested

  • pit_type (str) – Identifier which of the two pits (“branch” or “node”) the lookup belongs to

  • lookup_type (str) – Name of the lookup type

Returns:

lookup - A lookup (mostly a dict with mappings from pandapipesNet to internal structure)

Return type:

dict, np.array, ….

get_table_index_list(net, pit_array, pit_indices, pit_type='node')

Auxiliary function to get a list of tables and the table indices that belong to a number of pit indices.

Parameters:
  • net (pandapipesNet) – pandapipes net for which the list is requested

  • pit_array (np.array) – Internal structure from which to derive the tables and table indices

  • pit_indices (list, np.array, ....) – Indices for which the table name and index list are requested

  • pit_type (str, default "node") – Type of the pit (“node” or “branch”)

Returns:

List of table names and table indices belonging to the pit indices

get_table_name(table_lookup, table_number)

Auxiliary function to retrieve the pandapipes net table name for a given internal pit number from the table lookup.

Parameters:
  • table_lookup (dict) – The lookup dictionary from table names to internal number (n2t) and vice versa (t2n)

  • table_number (int) – Internal number of the table for which the name shall be retrieved

Returns:

table_name - pandapipes net table name for the internal pit number

Return type:

str

get_table_number(table_lookup, table_name)

Auxiliary function to retrieve the internal pit number for a given pandapipes net table name from the table lookup.

Parameters:
  • table_lookup (dict) – The lookup dictionary from table names to internal number (n2t) and vice versa (t2n)

  • table_name (str) – Name of the table for which the internal number shall be retrieved

Returns:

table_number - Internal number of the given table name within the pit

Return type:

int

initialize_pit(net)

Initializes and fills the internal structure which is called pit (pandapipes internal tables). The structure is a dictionary which should contain one array for all nodes and one array for all branches of the net (c.f. also create_empty_pit).

Parameters:

net (pandapipesNet) – The pandapipes network for which to create and fill the internal structure

Returns:

(node_pit, branch_pit) - The two internal structure arrays

Return type:

tuple(np.array)

write_internal_results(net, **kwargs)

Adds specified values to the internal result dictionary of the given pandapipes net. If internal results are not yet defined for the net, they are created as well.

Parameters:
  • net (pandapipesNet) – pandapipes net for which to update internal result dict

  • kwargs – Additional keyword arguments with the internal result values

Returns:

No output