{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Creating a pandapipes network including height differences"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This tutorial shows how to define junctions on different height levels. The following network will be created.\n",
"\n",
""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Empty network"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"At first, pandapipes is imported. We will then create an empty network container and specify the\n",
"fluid. The fluid water from the pandapipes library is used."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"import pandapipes as pp"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"net = pp.create_empty_network(fluid=\"water\") # create an empty network"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The create functions are used to create more components. The components will be added to the corresponding component tables."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Junctions"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"junction1 = pp.create_junction(net, pn_bar=1.0, tfluid_k=293.15, height_m = 352, name=\"Junction 1\")\n",
"junction2 = pp.create_junction(net, pn_bar=1.0, tfluid_k=293.15, height_m = 358, name=\"Junction 2\")\n",
"junction3 = pp.create_junction(net, pn_bar=1.0, tfluid_k=293.15, height_m = 361, name=\"Junction 3\")\n",
"junction4 = pp.create_junction(net, pn_bar=1.0, tfluid_k=293.15, height_m = 346, name=\"Junction 4\")\n",
"junction5 = pp.create_junction(net, pn_bar=1.0, tfluid_k=293.15, height_m = 400, name=\"Junction 5\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"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."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": " name pn_bar tfluid_k height_m in_service type\n0 Junction 1 1.0 293.15 352.0 True junction\n1 Junction 2 1.0 293.15 358.0 True junction\n2 Junction 3 1.0 293.15 361.0 True junction\n3 Junction 4 1.0 293.15 346.0 True junction\n4 Junction 5 1.0 293.15 400.0 True junction",
"text/html": "
\n\n
\n \n
\n
\n
name
\n
pn_bar
\n
tfluid_k
\n
height_m
\n
in_service
\n
type
\n
\n \n \n
\n
0
\n
Junction 1
\n
1.0
\n
293.15
\n
352.0
\n
True
\n
junction
\n
\n
\n
1
\n
Junction 2
\n
1.0
\n
293.15
\n
358.0
\n
True
\n
junction
\n
\n
\n
2
\n
Junction 3
\n
1.0
\n
293.15
\n
361.0
\n
True
\n
junction
\n
\n
\n
3
\n
Junction 4
\n
1.0
\n
293.15
\n
346.0
\n
True
\n
junction
\n
\n
\n
4
\n
Junction 5
\n
1.0
\n
293.15
\n
400.0
\n
True
\n
junction
\n
\n \n
\n
"
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"net.junction # show junction table"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In the next steps, more components are added."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### External Grid"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In the example, the external grid is connected to junction5. The pressure is at 0.5 bar."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": " name junction p_bar t_k in_service type\n0 Grid Connection 4 0.5 293.15 True pt",
"text/html": "
\n\n
\n \n
\n
\n
name
\n
junction
\n
p_bar
\n
t_k
\n
in_service
\n
type
\n
\n \n \n
\n
0
\n
Grid Connection
\n
4
\n
0.5
\n
293.15
\n
True
\n
pt
\n
\n \n
\n
"
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"medium_pressure_grid = pp.create_ext_grid(net, junction=junction5, p_bar=0.5, t_k=293.15, name=\"Grid Connection\")\n",
"\n",
"net.ext_grid # show external grid table"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Pipes"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The network contains four pipes. The lenghts and the junctions are displayed on the network\n",
"figure. Pipe 4 is defined using a roughness k_mm of 0.5 mm, which deviates from the default\n",
"value of 1 mm."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"pipe1 = pp.create_pipe_from_parameters(net, from_junction=junction1, to_junction=junction2, length_km=0.545, diameter_m=0.2, name=\"Pipe 1\")\n",
"pipe2 = pp.create_pipe_from_parameters(net, from_junction=junction2, to_junction=junction3, length_km=0.095, diameter_m=0.15, name=\"Pipe 2\")\n",
"pipe3 = pp.create_pipe_from_parameters(net, from_junction=junction1, to_junction=junction4, length_km=0.285, diameter_m=0.15, name=\"Pipe 3\")\n",
"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\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Up to now, the pipe components table looks like the table displayed in the following section:"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": " name from_junction to_junction std_type length_km diameter_m k_mm \\\n0 Pipe 1 0 1 None 0.545 0.20 1.0 \n1 Pipe 2 1 2 None 0.095 0.15 1.0 \n2 Pipe 3 0 3 None 0.285 0.15 1.0 \n3 Pipe 4 0 4 None 0.430 0.15 0.5 \n\n loss_coefficient alpha_w_per_m2k text_k qext_w sections in_service \\\n0 0.0 0.0 293.0 0.0 1 True \n1 0.0 0.0 293.0 0.0 1 True \n2 0.0 0.0 293.0 0.0 1 True \n3 0.0 0.0 293.0 0.0 1 True \n\n type \n0 pipe \n1 pipe \n2 pipe \n3 pipe ",
"text/html": "
\n\n
\n \n
\n
\n
name
\n
from_junction
\n
to_junction
\n
std_type
\n
length_km
\n
diameter_m
\n
k_mm
\n
loss_coefficient
\n
alpha_w_per_m2k
\n
text_k
\n
qext_w
\n
sections
\n
in_service
\n
type
\n
\n \n \n
\n
0
\n
Pipe 1
\n
0
\n
1
\n
None
\n
0.545
\n
0.20
\n
1.0
\n
0.0
\n
0.0
\n
293.0
\n
0.0
\n
1
\n
True
\n
pipe
\n
\n
\n
1
\n
Pipe 2
\n
1
\n
2
\n
None
\n
0.095
\n
0.15
\n
1.0
\n
0.0
\n
0.0
\n
293.0
\n
0.0
\n
1
\n
True
\n
pipe
\n
\n
\n
2
\n
Pipe 3
\n
0
\n
3
\n
None
\n
0.285
\n
0.15
\n
1.0
\n
0.0
\n
0.0
\n
293.0
\n
0.0
\n
1
\n
True
\n
pipe
\n
\n
\n
3
\n
Pipe 4
\n
0
\n
4
\n
None
\n
0.430
\n
0.15
\n
0.5
\n
0.0
\n
0.0
\n
293.0
\n
0.0
\n
1
\n
True
\n
pipe
\n
\n \n
\n
"
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"net.pipe # show pipe table"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The parameters `from_junction` and `to_junction` define the orientation of the pipe. If the flow\n",
"enters the pipe at the `from_junction` node and leaves it through the `to_junction` node, the\n",
"velocity will have a positive sign. Otherwise, it has a negative sign."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Sinks\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"With a sink, a constant mass flow can be defined. Here, we will create two sinks with mass flows of\n",
"277 g/s and 139 g/s. Sinks and sources are always assigned to a specific junction. The sign of the\n",
"mass flow is positive, if a mass flow is removed from the system."
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": " name junction mdot_kg_per_s scaling in_service type\n0 Sink 1 3 0.277 1.0 True sink\n1 Sink 2 2 0.139 1.0 True sink",
"text/html": "
\n\n
\n \n
\n
\n
name
\n
junction
\n
mdot_kg_per_s
\n
scaling
\n
in_service
\n
type
\n
\n \n \n
\n
0
\n
Sink 1
\n
3
\n
0.277
\n
1.0
\n
True
\n
sink
\n
\n
\n
1
\n
Sink 2
\n
2
\n
0.139
\n
1.0
\n
True
\n
sink
\n
\n \n
\n
"
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sink = pp.create_sink(net, junction=junction4, mdot_kg_per_s=0.277, name=\"Sink 1\")\n",
"sink = pp.create_sink(net, junction=junction3, mdot_kg_per_s=0.139, name=\"Sink 2\")\n",
"net.sink"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"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.\n",
"\n",
"Nevertheless, a distinction between laminar and turbulent flow will be added in the future."
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"pp.pipeflow(net, friction_model=\"nikuradse\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"The results are ready now and can be displayed with the following commands:"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"data": {
"text/plain": " p_bar t_k\n0 5.194289 293.15\n1 4.607432 293.15\n2 4.314000 293.15\n3 5.780977 293.15\n4 0.500000 293.15",
"text/html": "