#!/usr/bin/env python # coding: utf-8 # # Creating a pandapipes network including height differences # This tutorial shows how to define junctions on different height levels. The following network will be created. # # # ### Empty network # At first, pandapipes is imported. We will then create an empty network container and specify the # fluid. The fluid water from the pandapipes library is used. # In[1]: import pandapipes as pp # In[2]: net = pp.create_empty_network(fluid="water") # create an empty network # The create functions are used to create more components. The components will be added to the corresponding component tables. # ### Junctions # In[3]: junction1 = pp.create_junction(net, pn_bar=1.0, tfluid_k=293.15, height_m = 352, name="Junction 1") junction2 = pp.create_junction(net, pn_bar=1.0, tfluid_k=293.15, height_m = 358, name="Junction 2") junction3 = pp.create_junction(net, pn_bar=1.0, tfluid_k=293.15, height_m = 361, name="Junction 3") junction4 = pp.create_junction(net, pn_bar=1.0, tfluid_k=293.15, height_m = 346, name="Junction 4") junction5 = pp.create_junction(net, pn_bar=1.0, tfluid_k=293.15, height_m = 400, name="Junction 5") # The junctions are now stored in the net and can be called. Some parameters, which were not explicitly mentioned in the last section, were defined using default values. Note that the parameters of the junctions above contain the parameter height_m, which defines the height above sea level of the junction. The stored potential energy is automatically respected by pandapipes. # In[4]: net.junction # show junction table # In the next steps, more components are added. # ### External Grid # In the example, the external grid is connected to junction5. The pressure is at 0.5 bar. # In[5]: medium_pressure_grid = pp.create_ext_grid(net, junction=junction5, p_bar=0.5, t_k=293.15, name="Grid Connection") net.ext_grid # show external grid table # ### Pipes # The network contains four pipes. The lenghts and the junctions are displayed on the network # figure. Pipe 4 is defined using a roughness k_mm of 0.5 mm, which deviates from the default # value of 1 mm. # In[6]: pipe1 = pp.create_pipe_from_parameters(net, from_junction=junction1, to_junction=junction2, length_km=0.545, diameter_m=0.2, name="Pipe 1") pipe2 = pp.create_pipe_from_parameters(net, from_junction=junction2, to_junction=junction3, length_km=0.095, diameter_m=0.15, name="Pipe 2") pipe3 = pp.create_pipe_from_parameters(net, from_junction=junction1, to_junction=junction4, length_km=0.285, diameter_m=0.15, name="Pipe 3") pipe4 = pp.create_pipe_from_parameters(net, from_junction=junction1, to_junction=junction5, length_km=0.43, diameter_m=0.15, k_mm=0.5, name="Pipe 4") # Up to now, the pipe components table looks like the table displayed in the following section: # In[7]: net.pipe # show pipe table # The parameters `from_junction` and `to_junction` define the orientation of the pipe. If the flow # enters the pipe at the `from_junction` node and leaves it through the `to_junction` node, the # velocity will have a positive sign. Otherwise, it has a negative sign. # ### Sinks # # With a sink, a constant mass flow can be defined. Here, we will create two sinks with mass flows of # 277 g/s and 139 g/s. Sinks and sources are always assigned to a specific junction. The sign of the # mass flow is positive, if a mass flow is removed from the system. # In[8]: sink = pp.create_sink(net, junction=junction4, mdot_kg_per_s=0.277, name="Sink 1") sink = pp.create_sink(net, junction=junction3, mdot_kg_per_s=0.139, name="Sink 2") net.sink # The calculation is now started. The pipe friction can be respected using different models. By default, the Nikuradse model is used. A distinction between laminar and turbulent flow is not implemented in pandapipes. Typically, pipe calculation software detects the kind of flow. However, for pandapipes applications, we usually can expect turbulent flow conditions. # # Nevertheless, a distinction between laminar and turbulent flow will be added in the future. # In[9]: pp.pipeflow(net, friction_model="nikuradse") # The results are ready now and can be displayed with the following commands: # In[10]: net.res_junction # calculated pressure and temperature at junctions # In[11]: net.res_pipe # velocities, mass flows through pipes and other results # ## Plotting # # Using matplotlib, the network can easily be plotted. # In[12]: import matplotlib from pandapipes.plotting.simple_plot import simple_plot as sp sp(net, plot_sinks = True) # As long as no coordinates have been explicitly added to the junctions, automatically generated coordinates are used.