Robust Pipeline Design¶
Descriptions of the basic functions are given below.
Function descriptions:
Last edited: January 20 2020
@author: FINE Developer Team (FZJ IEK3)
The approaches used are described in Robinius et. al. (2019) “Robust Optimal Discrete Arc Sizing for TreeShaped Potential Networks” and they are further developed with the help of Theorem 10 of Labbé et. al. (2019) “Bookings in the European gas market: characterisation of feasibility and computational complexity results” and Lemma 3.4 and 3.5 of Schewe et. al. (preprint 2020) “Computing Technical Capacities in the European EntryExit Gas Market is NPHard”

robustPipelineSizing.
getInjectionWithdrawalRates
(componentName='', esM=None, operationVariablesOptimumData=None)[source]¶ Determines the injection and withdrawal rates into a network from a component in an EnergySystemModel object or based on the fluid flow data.
Parameters:  componentName (string) – name of the network component in the EnergySystemModel class
(only required the fluid flows are to be obtained from the EnergySystemModel class)
* the default value is ‘’  esM (FINE EnergySystemModel) – EnergySystemModel object with an optimized Pyomo instance (only needs to be
specified if the operationVariablesOptimumData are to be obtained from the
EnergySystemModel object)
* the default value is None  operationVariablesOptimumData (pandas DataFrame with nonnegative floats) –
the injection and withdrawal rates into and out of the network can either be obtained from a DataFrame with the original fluid flows or an EnergySystemModel with an optimized Pyomo instance. In the former case, the argument is a pandas DataFrame with two index columns (specifying the names of the start and end node of a pipeline) and one index row (for the time steps). The data in the DataFrame denotes the flow coming from the start node and going to the end node [e.g. in kWh or Nm^3]. Example:
0 1 … 8759node1 node2 0.1 0.0 … 0.9 node2 node3 0.0 0.3 … 0.4 node2 node1 0.9 0.9 … 0.2 node3 node2 1.1 0.2 … 0.9
* the default value is None
Returns: injection and withdrawal rates (withdrawals from the network are positive while injections are negative)
Return type: pandas DataFrame
 componentName (string) – name of the network component in the EnergySystemModel class
(only required the fluid flows are to be obtained from the EnergySystemModel class)

robustPipelineSizing.
getNetworkLengthsFromESM
(componentName, esM)[source]¶ Obtains the pipeline lengths of a transmission component in an EnergySystemModel class.
Parameters:  componentName (string) – name of the network component in the EnergySystemModel class
(only required if the fluid flows are to be obtained from the EnergySystemModel class)
* the default value is ‘’  esM (FINE EnergySystemModel) – EnergySystemModel object with an optimized Pyomo instance (only needs to be
specified if the operationVariablesOptimumData are to be obtained from the
EnergySystemModel object)
* the default value is None
Returns: pipeline distances in the length unit specified in the esM object
Return type: pandas series
 componentName (string) – name of the network component in the EnergySystemModel class
(only required if the fluid flows are to be obtained from the EnergySystemModel class)

robustPipelineSizing.
getRefinedShapeFile
(shapeFilePath, regColumn1, regColumn2, dic_node_minPress, dic_node_maxPress, minPipeLength, maxPipeLength)[source]¶ If a pipe is longer than maxPipeLength than it will be split into several pipes with equidistant length, i.e., replace arc (u,v) by (u,v_1), (v_1,v_2),…, (v_n,v) with n = ceil(lengthOfPipe/maxPipeLength) 1
Parameters:  shapeFilePath (string) – path to a shape file which connects the gas injection/ withdrawal nodes with each other. The rows of the file describe connections between the injection/ withdrawal nodes. The required geometry of these connections is a shapely LineString. Additionally, the file has two columns holding the names of the two injection/ withdrawal nodes (start and end point of the LineString).
 regColumn1 (string) – name of the column which holds the name of the injection/ withdrawal node at the beginning of the line
 regColumn2 (string) – name of the column which holds the name of the injection/ withdrawal node at the end of the line
 dic_node_minPress (dictionary: key: node of the network, value: nonnegative float) – dictionary that contains for every node of the network its lower pressure bound in [bar]
 dic_node_maxPress (dictionary key: node of the network, value: nonnegative float) – dictionary that contains for every node of the network its upper pressure bound in [bar]. It holds: dic_node_minPress[index] <= dic_node_maxPress[index].
 minPipeLength (positive number) – desired minimum length of a pipe in [m], note: not always possible to achieve.
 maxPipeLength (positive number) – determines the maximal length of a pipe in [m].
Returns: distances_new  pipeline distances in m
Return type: pandas series
Returns: dic_node_minPress_new  dictionary that contains for every node of the network its lower pressure bound in [bar]
Return type: dictionary key: node of the network, value: nonnegative float
Returns: dic_node_maxPress_new  dictionary that contains for every node of the network its upper pressure bound in [bar]
Return type: dictionary key: node of the network, value: nonnegative float
Returns: gdfNodes  GeoDataFrame with the nodes of the network and their names
Return type: geopandas GeoDataFrame
Returns: gdfEdges  GeoDataFrame with the edges of the network and the names of their start and end nodes
Return type: geopandas GeoDataFrame

robustPipelineSizing.
createNetwork
(distances)[source]¶ Creates undirected network/graph from given distances; updates distances such that either (u,v) or (v,u) are contained
Parameters: distances (pandas series) – pipeline distances in the length unit specified in the esM object Returns: graph of the network corresponding to the distances Return type: graph object of networkx Returns: pipeline distances in the length unit specified in the esM object Return type: pandas series

robustPipelineSizing.
createSteinerTree
(graph, distances, inner_nodes)[source]¶ Computes a steiner tree with minimal sum of pipeline lengths; updates distances such that only arcs of the spanning tree are contained with corresponding length
Parameters:  graph (networkx graph object) – an undirected networkx graph: Its edges have the attribute length which is the pipeline length in [m]
 distances (pandas series) – pipeline distances in the length unit specified in the esM object
:return spanning tree with sum of lengths of pipelines is minimal :rtype: graph object of networkx

robustPipelineSizing.
generateRobustScenarios
(injectionWithdrawalRates, graph, distances, dic_node_minPress, dic_node_maxPress, solver='glpk', threads=1, verbose=0)[source]¶ Compute for every node combination a special robust scenario according to Robinius et. al. (2019) and Labbé et. al. (2019)
Parameters:  injectionWithdrawalRates – injection and withdrawal rates (withdrawals from the network are positive while injections are negative) for every time step and node; unit [kg/s]
 graph (networkx graph object) – an undirected networkx graph: Its edges have the attribute length which is the pipeline length in [m]
 distances (pandas series) – pipeline distances in the length unit specified in the esM object
 threads (positive integer) – number of threads used for parallelization
 verbose (int) – if > 0, parallelization progress is displayed
Type: pandas dataframe
:return dictionary that contains for every node pair a dictionary containing all arc flows of the corresponding special scenario :rtype: dictionary key: (node1,node2), value: dictionary: key: arc, value: arc flow in [kg/s]
:return list of entry node :rtype: list of strings
:return list of exit node :rtype: list of strings

robustPipelineSizing.
computeSingleSpecialScenario
(graph, distances, entries, exits, startNode, endNode, dic_nodes_MinCapacity, dic_nodes_MaxCapacity, specialScenario=True, solver='glpk')[source]¶ Compute special robust scenario for given node combination according to Robinius et. al. (2019) and Labbé et. al. (2019)
Parameters:  graph (networkx graph object) – an undirected networkx graph: Its edges have the attribute length which is the pipeline length in [m]
 distances (pandas series) – pipeline distances in the length unit specified in the esM object
 entries (list of strings) – list of entry nodes of the network
 exits (list of strings) – list of exit nodes of the network
 startNode (string) – node of the network (starting node of the special scenario)
 endNode (string) – node of the network (end node of special scenario)
 dic_nodes_MinCapacity (dictionary: key: node of the network, value: float) – dictionary containing minimal capacity for each node
 dic_nodes_MaxCapacity (dictionary: key: node of the network, value: float) – dictionary containing maximal capacity for each node
 specialScenario – bool: True if we compute special robust scenario; False if we compute scenario for fixed
demand vector, e.g., for scenario of a time step :type specialScenario: bool
Parameters: solver (string, default 'glpk') – name of the optimization solver to use :return dictionary that contains for every arc the corresponding arc flows of the (special) scenario :rtype: dictionary key: arc, value: arc flow

robustPipelineSizing.
computeLargeMergedDiameters
(dic_subSetDiam_costs, nDigits=6)[source]¶ Compute merged diameters, i.e. compute equivalent single diameter for two looped pipes.
Parameters:  dic_subSetDiam_costs – dictionary containing diameters in [m] and costs in [Euro/m]
 nDigits (positive int) – number of digits used in the round function
* the default value is 6
Type: dictionary: key: diameter, value: costs
Return dic_newDiam_costs: dictionary containing merged diameters in [m] and costs in [Euro/m]
Return type: dictionary: key: diameter, value: costs
Return dic_newDiam_oldDiam: dictionary matching new diameters to old diameters
Return type: dictionary: key: new diameter, value: corresponding old diameter, which will be used in the looped pipe

robustPipelineSizing.
determinePressureDropCoef
(dic_scenario_flows, distances, dic_node_minPress, dic_node_maxPress, diameters, ir=0.2, rho_n=0.089882, T_m=293.15, T_n=273.15, p_n=1.01325, Z_n=1.00062387922965, nDigits=6)[source]¶ Compute for each scenario, diameter, and each arc the corresponding pressure drop
Parameters: dic_scenario_flows – dictionary that contains for every node pair a dictionary containing all arc flows in [kg/s] of the corresponding (special) scenario :type dic_scenario_flows: dictionary key: scenarioName (node1,node2), value: dictionary: key: arc, value: arc flow
Parameters:  distances (pandas series) – pipeline distances in the length unit specified in the esM object ([m])
 dic_node_minPress (dictionary: key: node of the network, value: nonnegative float) – dictionary that contains for every node of the network its lower pressure bound in [bar]
 dic_node_maxPress (dictionary key: node of the network, value: nonnegative float) – dictionary that contains for every node of the network its upper pressure bound in [bar]
It holds dic_node_minPress[index] <= dic_node_maxPress[index]
Parameters:  diameters – list of diameters in [m]
 ir (positive float; optional) – integral roughness of pipe in [mm]
* the default value is 0.2 (hydrogen, this value can also be used for methane)  rho_n (positive float; optional) – density at standard state in [kg/m^3]
* the default value is 0.089882 (hydrogen, you can use 0.71745877 for methane)  T_m (float; optional) – constant temperature in [kelvin]
* the default value is 20 + 273.15 (hydrogen, you can use 281.15 for methane)  T_n (float; optional) – temperature in standard state in [kelvin]
* the default value is 273.15 (hydrogen, this value can also be used for methane)  p_n (nonnegative float; optional) – pressure at standard state in [bar]
* the default value is 1.01325 (hydrogen, this value can also be used for methane)  Z_n (nonnegative float; optional) – realgasfactor of hydrogen at standard state
* the default value is 1.00062387922965 (hydrogen, you can use 0.997612687740414 for methane)  nDigits (positive int; optional) – number of digits used in the round function
* the default value is 6
Type: list of strictly positive numbers
:return dictionary that contains for every scenario and diameter the corresponding pressure drops :rtype: dictionary key: (diameter, scenario Name), value: dic: key: arc, value: pressure drop

robustPipelineSizing.
determineOptimalDiscretePipelineSelection
(graph, distances, dic_pressureDropCoef, specialScenarioNames, dic_node_minPress, dic_node_maxPress, dic_diam_costs, robust=True, solver='glpk', threads=4, verbose=0)[source]¶ Model of optimal pipeline sizing (diameter selection) w.r.t. to the given scenarios
Parameters:  graph (networkx graph object) – an undirected networkx graph: Its edges have the attribute length which is the pipeline length in [m]
 distances (pandas series) – pipeline distances in the length unit specified in the esM object ([m])
 dic_pressureDropCoef (dictionary: keys: scenarioName; value: dict: key: arc, value: pressure drop in [bar]) – dictionary that contains for every scenario and diameter the corresponding pressure drops in [bar]
 specialScenarioNames (list of tuples in the robust case, otherwise list of time Steps) – list of names of scenarios. In robust case tuples (startNode, endNode).
 dic_node_minPress (dictionary: key: node of the network, value: nonnegative float) – dictionary that contains for every node of the network its lower pressure bound in [bar]
 dic_node_maxPress (dictionary key: node of the network, value: nonnegative float) – dictionary that contains for every node of the network its upper pressure bound in [bar]
It holds dic_node_minPress[index] <= dic_node_maxPress[index]
Parameters:  dic_diam_costs (dictionary key: diameter, value: nonnegative float) – dictionary that contains for every diameter in [m] its costs [Euro/m]
 robust (bool) – Bool that is true, if we optimize w.r.t. robust scenarios, otherwise False.
:return dictionary that contains for every arc the optimal diameter in [m] :rtype dictionary: key: arc, value: optimal diameter
Parameters:  solver (string, default 'glpk') – name of the optimization solver to use
 threads (positive integer) – number of threads used for optimization (if gurobi is used)
 verbose (int) – if > 0, parallelization progress is displayed
:return dictionary that contains for every scenario the corresponding pressure levels :rtype dictionary: key: scenarioName, value: dict: key: node, value: pressure level of node

robustPipelineSizing.
postprocessing
(graph, distances, dic_arc_diam, dic_scenario_flows, dic_node_minPress, dic_node_maxPress, threads=1, verbose=0)[source]¶ ” Compute “more” accurate pressure levels for the considered scenarios in the network with optimal diameters Apply postprocessing of Master’s thesis with adaption that we possibly consider every node for fixing its pressure level to the upper pressure bound.
Parameters:  graph (networkx graph object) – an undirected networkx graph: Its edges have the attribute length which is the pipeline length in [m]
 distances (pandas series) – pipeline distances in the length unit specified in the esM object ([m])
 dic_arc_diam – dictionary containing for each arc the optimal diameter in [m]
 dic_scenario_flows – dictionary that contains for every node pair a dictionary containing all
Type: dictionary: key: arc, value: optimal diameter
arc flows in [kg/s] of the corresponding (special) scenario :type dic_scenario_flows: dictionary key: scenarioName (node1,node2), value: dictionary: key: arc, value: arc flow
Parameters:  dic_node_minPress (dictionary: key: node of the network, value: nonnegative float) – dictionary that contains for every node of the network its lower pressure bound in [bar]
 dic_node_maxPress (dictionary key: node of the network, value: nonnegative float) – dictionary that contains for every node of the network its upper pressure bound in [bar]
 threads (positive integer) – number of threads used for parallelization
 verbose (int) – if > 0, parallelization progress is displayed
It holds dic_node_minPress[index] <= dic_node_maxPress[index]
Returns: dictionary that contains for every scenario the corresponding pressure levels in [bar] Return type: dictionary key: scenarioName, value: dic: key: arc, value pressure level Returns: dictionary that contains for every scenario the maximal pressure bound violation in [bar] Return type: dictionary key: scenarioName, value: float = maximal pressure bound violation

robustPipelineSizing.
computePressureAtNode
(validation, node, nodeUpperBound, graph, dic_arc_diam, distances, dic_scenario_flows, dic_node_minPress, dic_node_maxPress, tmp_violation, dic_node_pressure, ir=0.2, rho_n=0.089882, T_m=293.15, T_n=273.15, p_n=1.01325, Z_n=1.00062387922965, nDigits=6)[source]¶ ” Compute pressure levels recursive for given scenario and node that is fixed to its upper pressure level
Parameters:  validation – boolean that is False, if the computed pressure levels are infeasible
 node (str) – node of the network for which we currently consider for computing the pressure levels
 nodeUpperBound – node which pressure level is fixed to the upper bound
 graph (networkx graph object) – an undirected networkx graph: Its edges have the attribute length which is the pipeline length in [m]
 dic_arc_diam – dictionary containing for each arc the optimal diameter in [m]
 distances (pandas series) – pipeline distances in the length unit specified in the esM object ([m])
 dic_scenario_flows – dictionary scenario and corresponding flows in [kg/s]
 dic_node_minPress (dictionary: key: node of the network, value: nonnegative float) – dictionary that contains for every node of the network its lower pressure bound in [bar]
 dic_node_maxPress (dictionary key: node of the network, value: nonnegative float) – dictionary that contains for every node of the network its upper pressure bound in [bar]
Rtype validation: bool
Type: dictionary: key: arc, value: optimal diameter
Type: dictionary: key: arc, value: arc flow
It holds dic_node_minPress[index] <= dic_node_maxPress[index]
Parameters:  tmp_violation (float) – violation of the current pressure bounds in [bar]
 dic_node_pressure (dictionary key: node of the network, value: nonnegative float) – dictionary that contains node pressure levels in [bar]
 ir (positive float) – integral roughness of pipe in [mm]
* the default value is 0.2 (hydrogen, this value can also be used for methane)  rho_n (positive float) – density at standard state in [kg/m^3]
* the default value is 0.089882 (hydrogen, you can use 0.71745877 for methane)  T_m (float) – constant temperature in [kelvin]
* the default value is 20 + 273.15 (hydrogen, you can use 281.15 for methane)  T_n (float) – temperature in standard state in [kelvin]
* the default value is 273.15 (hydrogen, this value can also be used for methane)  p_n (nonnegative float) – pressure at standard state in [bar]
* the default value is 1.01325 (hydrogen, this value can also be used for methane)  Z_n (nonnegative float) – realgasfactor of hydrogen at standard state
* the default value is 1.00062387922965 (hydrogen, you can use 0.997612687740414 for methane)  nDigits (positive int) – number of digits used in the pandas round function. Is applied to the
specified or determined injection and withdrawal rates.
* the default value is 6
Return validation: boolean that is true, if the computed pressure levels are feasible
Return type: :return maximal violation of the pressure bounds w.r.t. the computed pressure levels in [bar] :rtype: float

robustPipelineSizing.
computePressureStartnodeArc
(arc, pressureEndNode, dic_scenario_flows, dic_arc_diam, distances, ir=0.2, rho_n=0.089882, T_m=293.15, T_n=273.15, p_n=1.01325, Z_n=1.00062387922965, tol=0.0001)[source]¶ ” For given arc and pressure level of endNode compute the pressure of the startNode by solving the corresponding equation system
Parameters:  arc (tuple) – arc of the network for which we know the pressure at the endNode, i.e. the node which receives gas
 pressureEndNode (nonnegative float) – pressure level of endNode
 dic_scenario_flows – dictionary scenario and corresponding flows in [kg/s]; note arc flow of arc has to be
positive :type: dictionary: key: arc, value: arc flow
Parameters:  dic_arc_diam – dictionary containing for each arc the optimal diameter in [m]
 distances (pandas series) – pipeline distances in the length unit specified in the esM object ([m])
 ir (positive float) – integral roughness of pipe in [mm]
* the default value is 0.2 (hydrogen, this value can also be used for methane)  rho_n (positive float) – density at standard state in [kg/m^3]
* the default value is 0.089882 (hydrogen, you can use 0.71745877 for methane)  T_m (float) – constant temperature in [kelvin]
* the default value is 20 + 273.15 (hydrogen, you can use 281.15 for methane)  T_n (float) – temperature in standard state in [kelvin]
* the default value is 273.15 (hydrogen, this value can also be used for methane)  p_n (nonnegative float) – pressure at standard state in [bar]
* the default value is 1.01325 (hydrogen, this value can also be used for methane)  Z_n (nonnegative float) – realgasfactor of hydrogen at standard state
* the default value is 1.00062387922965 (hydrogen, you can use 0.997612687740414 for methane)  tol (nonnegative float) – tolerance to which accuracy we solve the equation system
* the default value is 10^4
Type: dictionary: key: arc, value: optimal diameter
Returns: pressure level of startNode in [bar]
Return type:

robustPipelineSizing.
computePressureEndnodeArc
(arc, pressureStartNode, dic_scenario_flows, dic_arc_diam, distances, ir=0.2, rho_n=0.089882, T_m=293.15, T_n=273.15, p_n=1.01325, Z_n=1.00062387922965)[source]¶ ” For given arc and pressure level of startNode compute the pressure of the endNode
Parameters:  arc (tuple) – arc of the network for which we know the pressure at the endNode, i.e. the node which receives gas
 pressureStartNode (nonnegative float) – pressure level of endNode
 dic_scenario_flows – dictionary scenario and corresponding flows in [kg/s]
 dic_arc_diam – dictionary containing for each arc the optimal diameter in [m]
 distances (pandas series) – pipeline distances in the length unit specified in the esM object ([m])
 ir (positive float) – integral roughness of pipe in [mm]
* the default value is 0.2 (hydrogen, this value can also be used for methane)  rho_n (positive float) – density at standard state in [kg/m^3]
* the default value is 0.089882 (hydrogen, you can use 0.71745877 for methane)  T_m (float) – constant temperature in [kelvin]
* the default value is 20 + 273.15 (hydrogen, you can use 281.15 for methane)  T_n (float) – temperature in standard state in [kelvin]
* the default value is 273.15 (hydrogen, this value can also be used for methane)  p_n (nonnegative float) – pressure at standard state in [bar]
* the default value is 1.01325 (hydrogen, this value can also be used for methane)  Z_n (nonnegative float) – realgasfactor of hydrogen at standard state
* the default value is 1.00062387922965 (hydrogen, you can use 0.997612687740414 for methane)
Type: dictionary: key: arc, value: arc flow
Type: dictionary: key: arc, value: optimal diameter
Returns: pressure level of endNode in [bar]
Return type:

robustPipelineSizing.
computeTimeStepFlows
(injectionWithdrawalRates, distances, graph, entries, exits, threads=1, verbose=0, solver='glpk')[source]¶ ” Compute for each timeStep and demands given by injectionWithdrawalRates the corresponding flow values
Param: injectionWithdrawalRates: injection and withdrawal rates (withdrawals from the network are positive while injections are negative) in [kg^3/s]
Parameters:  distances (pandas series) – pipeline distances in the length unit specified in the esM object ([m])
 graph (networkx graph object) – an undirected networkx graph: Its edges have the attribute length which is the pipeline length in [m]
 entries (list of str) – list of entry nodes of the network
 exits (list of str) – list of exit nodes of the network
 threads (positive integer) – number of threads used for parallelization
 verbose (int) – if > 0, parallelization progress is displayed
 solver (string, default 'glpk') – name of the optimization solver to use
Returns: dictionary that contains for every time step the corresponding flows in [kg/s]
Return type: dictionary key: timeStep, value: dict: key: arc, value: arc flow

robustPipelineSizing.
networkRefinement
(distances, maxPipeLength, dic_node_minPress, dic_node_maxPress)[source]¶ If a pipe is longer than maxPipeLength than it will be split into several pipes with equidistant length, i.e., replace arc (u,v) by (u,v_1), (v_1,v_2),…, (v_n,v) with n = ceil(lengthOfPipe/maxPipeLength) 1 # TODO this function is only used for testing
Parameters:  distances (pandas series) – pipeline distances in the length unit specified in the esM object
 maxPipeLength (positive number) – determines the maximal length of a pipe in [m].
 dic_node_minPress (dictionary: key: node of the network, value: nonnegative float) – dictionary that contains for every node of the network its lower pressure bound in [bar]
 dic_node_maxPress (dictionary key: node of the network, value: nonnegative float) – dictionary that contains for every node of the network its upper pressure bound in [bar]
It holds dic_node_minPress[index] <= dic_node_maxPress[index]
Returns: graph of the network corresponding to the distances Return type: graph object of networkx Returns: pipeline distances in the length unit specified in the esM object Return type: pandas series Returns: dic_node_minPress dictionary that contains for every node of the network its lower pressure bound in [bar] Return type: dictionary key: node of the network, value: nonnegative float :return dic_node_maxPress dictionary that contains for every node of the network its upper pressure bound in [bar] :rtype: dictionary key: node of the network, value: nonnegative float

robustPipelineSizing.
determineDiscretePipelineDesign
(robust, injectionWithdrawalRates, distances, dic_node_minPress, dic_node_maxPress, dic_diameter_costs=None, dic_candidateMergedDiam_costs=None, gdfEdges=None, regColumn1='nodeIn', regColumn2='nodeOut', solver='glpk', opexForDiameters=None, economicLifetime=30, interestRate=0.08, costUnit='€', ir=0.2, rho_n=0.089882, T_m=293.15, T_n=273.15, p_n=1.01325, Z_n=1.00062387922965, originalFluidFlows=None, nDigits=6, verbose=0, threads=1)[source]¶ We compute a robust (depending on parameter robust) optimal pipeline design, i.e. for a given network, we compute a minimal spanning tree w.r.t. its total length. Afterward, we compute our robust (special) scenarios, see Robinius et. al.. Also we compute for every timeStep of injectionWithdrawalRates the corresponding flows. We compute merged diameters according to list candidatesMergedDiameter, i.e. we compute a equivalent single diameter for two parallel pipes with the same diameter If robust is True, then we compute the corresponding pressure drops for every diameter and robust scenario. If robust is False, then we compute for every timeStep the corresponding pressure drops for every diameter and timeStep. If robust is True, then we compute optimal diameters by a MIP for the robust scenarios. If robust is False, then we compute optimal diameters by a MIP for the timeStep scenarios. Not Robust Version! In a postprocessing step, we compute “precise” pressure levels for the robust scenarios and the timeStep scenarios.
Note that if robust is False, then the network may be infeasible for robust scenarios which can occur in the network!
Parameters:  robust (bool) – Bool that is true, we build a robust pipeline network, otherwise not
 injectionWithdrawalRates (pandas DataFrame with floats) –
the argument is a pandas DataFrame with the index column denoting the timesteps and the index row denoting the name of the network’s nodes. Injection are denoted with negative floats and withdrawal with positive floats in [kg/s]. Example:
node1 node2 node30 4 2 2 1 3 1.5 1.5 … … … … 8759 0 1 1.
 distances (pandas Series) –
the parameter is a pandas Series with the indices being tuples of the network’s nodes and the values being the lengths of the pipelines in [m]. Example:
(node1, node2) 1000 (node2, node3) 50000 (node2, node1) 1000 (node3, node2) 50000
 dic_node_minPress (dictionary: key: node of the network, value: nonnegative float) – dictionary that contains for every node of the network its lower pressure bound in [bar]
 dic_node_maxPress (dictionary key: node of the network, value: nonnegative float) – dictionary that contains for every node of the network its upper pressure bound in [bar]
It holds dic_node_minPress[index] <= dic_node_maxPress[index]
Parameters: dic_diameter_costs – dictionary that contains all diameters in [m] as keys and the values are the corresponding costs in [Euro/m]. Default Value is a preselection of diameters and its costs. if None, then we chose the following preselection of diameters and costs dic_diameter_costs = {0.1063: 37.51, 0.1307: 38.45, 0.1593: 39.64, 0.2065: 42.12, 0.2588: 45.26, 0.3063: 48.69, 0.3356: 51.07, 0.3844: 55.24, 0.432: 59.86, 0.4796: 64.98, 0.527: 70.56, 0.578: 76.61, 0.625: 82.99, 0.671: 89.95, 0.722: 97.38, 0.7686: 105.28, 0.814: 113.63, 0.864: 122.28, 0.915: 131.56, 0.96: 141.3, 1.011: 151.5, 1.058: 162.17, 1.104: 173.08, 1.155: 184.67, 1.249: 209.24, 1.342: 235.4, 1.444: 263.66, 1.536: 293.78} :type dic_diameter_costs: dict with keys: diameters, values: cost for pipeline; optional
Parameters:  dic_candidateMergedDiam_costs (dict with keys: diameters, values: cost for pipeline; optional) –
dictionary that contains a set of diameters in [m] as keys and the values are the corresponding costs in [Euro/m]. This diameters are then used to compute a single equivalent diameter for two looped (parallel) pipes with the considered diameter.
* the default value is empty dictionary {}  gdfEdges (GeoDataFrame or None: optional, default is None) – GeoDataFrame with the edges of the network and the names of their start and end nodes. Required for georeferenced result visualization. Should be obtained from the getRefinedShapeFile function.
 regColumn1 (string, optional, default is 'nodeIn') – name of the column in gdfEdges which holds the name of the injection/ withdrawal node at the beginning of the line. Required if gdfEdges is specified.
 regColumn2 (string, optional, default is 'nodeOut') – name of the column in gdfEdges which holds the name of the injection/ withdrawal node at the end of the line. Required if gdfEdges is specified.
 solver (string, default 'glpk') – name of the optimization solver to use
 ir (positive float) – integral roughness of pipe in [mm]
* the default value is 0.2 (hydrogen, this value can also be used for methane)  rho_n (positive float) – density at standard state in [kg/m^3]
* the default value is 0.089882 (hydrogen, you can use 0.71745877 for methane)  T_m (float) – constant temperature in [kelvin]
* the default value is 20 + 273.15 (hydrogen, you can use 281.15 for methane)  T_n (float) – temperature in standard state in [kelvin]
* the default value is 273.15 (hydrogen, this value can also be used for methane)  p_n (nonnegative float) – pressure at standard state in [bar]
* the default value is 1.01325 (hydrogen, this value can also be used for methane)  Z_n (nonnegative float) – realgasfactor of hydrogen at standard state
* the default value is 1.00062387922965 (hydrogen, you can use 0.997612687740414 for methane)
# TODO @Juelich where to use param originalFluidFlows: string that specifies the considered fluid
* the default value is NoneParameters:  nDigits (positive int) – number of digits used in the round function
* the default value is 6  verbose (integer (0, 1 or 2)) –
defines how verbose the console logging is:
 0: general model logging, warnings and optimization solver logging are displayed.
 1: warnings are displayed.
 2: no general model logging or warnings are displayed, the optimization solver logging is set to a
 minimum.
Note: if required, the optimization solver logging can be separately enabled in the optimizationSpecs of the optimize function.
* the default value is 0
Returns: tuple (dic_arc_optimalDiameters, dic_scen_PressLevels, dic_scen_MaxViolPress, dic_timeStep_PressLevels, dic_timeStep_MaxViolPress, gdfEdges), with:  dic_arc_optimalDiameters dictionary  pressure levels of postprocessing of robust scenarios dic_scen_PressLevels  violation of pressure bounds of robust scenarios in optimized network determined by postprocessing  dic_scen_MaxViolPress: maximum pressure violation in robust scenarios  pressure levels of postprocessing of timeSteps dic_timeStep_PressLevels  violation of pressure bounds of timeStep scenarios in optimized network determined by postprocessing  dic_timeStep_MaxViolPress: maximum pressure violation in timestep scenarios  geopandas GeoDataFrame (information about diameters in ‘diam’ column and number of pipelines in
’nbPipes’); None if kwarg gdfEdges was specified as being Node
Return type: return types:  dic_arc_optimalDiameters: dictionary, key: arcs, values: (numberOfPipes, diameter) note usually numberOfPipes
is 1, but if we have chosen a merged diameter, then we have two parallel pipes with the same diameter, i.e. numberOfPipes is 2.
 dic_scen_PressLevels: dictionary, key: nodePair, value: dict: key: arc, value: pressure level in [bar]
 dic_scen_MaxViolPress: dictionary, key: nodePair, value: dict: key: arc, value: nonnegative number (zero means no pressure violation)
 dic_timeStep_PressLevels: dictionary, key: timeStep, value: dict: key: arc, value: pressure level in [bar]
 dic_timeStep_MaxViolPress: dictionary, key: nodePair, value: dict: key: arc, value: nonnegative number (zero means no pressure violation)
 gdfEdges: geopandas geodataframe; None if kwarg gdfEdges was specified as being Node

robustPipelineSizing.
plotOptimizedNetwork
(gdf_pipes, figsize=(4, 4), nodesColumn='nodes', diamColumn='diam', nbPipesColumn='nbPipes', line_scaling=1, gdf_regions=None, pressureLevels=None, pMin=50, pMax=100, cmap='Spectral_r', cbxShift=0.32, cbyShift=0.08, cbWidth=0.4, fontsize=10, cbTitle='Pressure [bar]')[source]¶ Plot optimized network, visualizing chosen pipe diameters and, if selected, pressure levels of a scenario.
Parameters:  gdf_pipes (geopandas GeoDataFrame) – GeoDataFrame, containing information about the diameters, number of pipes and routes of the pipeline network
 figsize (tuple, optional) – figure size, defaults to (4,4)
 nodesColumn (str, optional) – name of the column in gdf_pipes containing a tuple (startNode, endNode) with the name of the nodes being strings, defaults to ‘nodes’
 diamColumn (str, optional) – name of the column in gdf_pipes containing the diameters of the pipelines in m, defaults to ‘diam’
 nbPipesColumn (str, optional) – name of the column in gdf_pipes containing the number of parallel pipes along a connection (maximum parallel pipes: 2), defaults to ‘nbPipes’
 line_scaling (int, optional) – scaling factor for line width, defaults to 1
 gdf_regions (geopandas GeoDataFrame, optional) – GeoDataFrame for background plotting, defaults to None
 pressureLevels (dictionary or series with keys/ indices being the nodes of the network, optional) – pressure levels at each node for one scenario/ timestep, defaults to None
 pMin (int, optional) – minimum pressure of colorbar, defaults to 50
 pMax (int, optional) – maximum pressure of colorbar, defaults to 100
 cmap (str, optional) – colormap name, defaults to ‘Spectral_r’
 cbxShift (float, optional) – colorbar x shift, defaults to 0.32
 cbyShift (float, optional) – colorbar y shift, defaults to 0.08
 cbWidth (float, optional) – colorbar width, defaults to 0.4
 fontsize (int, optional) – fontsize of legend and colorbar, defaults to 10
 cbTitle (str, optional) – colorbar title, defaults to ‘Pressure [bar]’
Returns: tuple (fig, ax)
Return type:  fig: matplotlib figure
 ax: matplotlib axis