topotherm.postprocessing

Postprocessing of the results from the optimization. This includes the calculation of the diameter and mass flow of the pipes, and the elimination of unused pipes and nodes.

Functions

  • calc_diam_and_velocity : Calculate pipe diameter and velocity depending on the mass flow and pipe power.

  • sts : Postprocessing for the single time step model.

  • to_networkx_graph : Export the postprocessed, optimal district as a NetworkX graph.

  • mts : Postprocessing for the multiple time step model.

Functions

diameter_and_velocity(v, mass_lin, settings)

Equations for calculating the diameter and velocity of a pipe based on

calculate_hydraulics(power, settings)

Calculate mass flow, diameter, and velocity for each pipe given the

sts(model, matrices, settings)

Postprocessing for the single time step model. This includes the

mts(model, matrices, settings)

Postprocessing for the multiple time step model. This includes the

to_networkx_graph(matrices)

Convert incidence matrices to a directed NetworkX graph.

to_dataframe(matrices_optimal, matrices_init)

Export the postprocessed, optimal district as pandas DataFrames.

Module Contents

topotherm.postprocessing.diameter_and_velocity(v, mass_lin, settings)[source]

Equations for calculating the diameter and velocity of a pipe based on mass flow and power of the pipes

Parameters:
  • v (tuple of float) – Tuple containing the velocity and diameter ((velocity, diameter)).

  • mass_lin (float) – Mass flow of the pipe (kg/s).

  • settings (Settings) – Settings object containing water and piping parameters.

Returns:

Tuple containing:

  • velocityfloat

    Calculated velocity of the pipe (m/s).

  • diameterfloat

    Calculated diameter of the pipe (m).

Return type:

tuple of float

topotherm.postprocessing.calculate_hydraulics(power, settings)[source]

Calculate mass flow, diameter, and velocity for each pipe given the installed thermal power and the supply/return temperatures from settings.

Parameters:
  • power (np.ndarray) – Installed thermal power for each pipe.

  • settings (Settings) – Settings object containing temperature setpoints and water properties.

Returns:

Tuple containing:

  • mass_flownp.ndarray

    Mass flow for each pipe (kg/s).

  • diameternp.ndarray

    Pipe diameter (m).

  • velocitynp.ndarray

    Flow velocity (m/s).

Return type:

tuple of np.ndarray

topotherm.postprocessing.sts(model, matrices, settings)[source]

Postprocessing for the single time step model. This includes the calculation of the diameter and velocity of the pipes and the elimination of unused pipes and nodes.

Parameters:
  • model (pyo.ConcreteModel) – Solved Pyomo model.

  • matrices (dict) – Dictionary containing the matrices.

  • settings (tt.settings.Settings) – Settings for the optimization.

Returns:

Optimal variables and postprocessed data.

Return type:

dict

topotherm.postprocessing.mts(model, matrices, settings)[source]

Postprocessing for the multiple time step model. This includes the calculation of the diameter and velocity of the pipes and the elimination of unused pipes and nodes.

Parameters:
  • model (pyo.ConcreteModel) – Solved Pyomo model.

  • matrices (dict) – Dictionary containing the matrices.

  • settings (tt.settings.Settings) – Settings for the optimization.

Returns:

Optimal variables and postprocessed data.

Return type:

dict

topotherm.postprocessing.to_networkx_graph(matrices)[source]

Convert incidence matrices to a directed NetworkX graph. Includes the nodes and edges of the district, their length, and, if available, installed diameter, and power.

Parameters:

matrices (dict) – Dictionary containing the incidence matrices as output by topotherm.postprocessing.sts or as input to the model.

Returns:

NetworkX directed graph.

Return type:

nx.DiGraph

topotherm.postprocessing.to_dataframe(matrices_optimal, matrices_init)[source]

Export the postprocessed, optimal district as pandas DataFrames. Includes the nodes and edges of the district, their length, installed diameter, and power.

Parameters:
  • matrices_optimal (dict) – Solved and cleaned matrices as output by topotherm.postprocessing.sts.

  • matrices_init (dict) – Original matrices as output by topotherm.fileio.load.

Returns:

  • nodes (pd.DataFrame) – DataFrame of nodes.

  • edges (pd.DataFrame) – DataFrame of edges.

Return type:

Tuple[pandas.DataFrame, pandas.DataFrame]