{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Minimal Example pandapipes\n", "\n", "## Creating a low pressure gas network\n", "\n", "We consider the following simple 3-junction example network with an ideal valve as a minimal example:\n", "\n", "\n", "\n", "The above network can be created in pandapipes as follows:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandapipes as pp\n", "\n", "#create empty net\n", "net = pp.create_empty_network(fluid=\"lgas\")\n", "\n", "# create junction\n", "j1 = pp.create_junction(net, pn_bar=1.05, tfluid_k=293.15, name=\"Junction 1\")\n", "j2 = pp.create_junction(net, pn_bar=1.05, tfluid_k=293.15, name=\"Junction 2\") \n", "j3 = pp.create_junction(net, pn_bar=1.05, tfluid_k=293.15, name=\"Junction 3\") \n", "\n", "# create junction elements\n", "ext_grid = pp.create_ext_grid(net, junction=j1, p_bar=1.1, t_k=293.15, name=\"Grid Connection\")\n", "sink = pp.create_sink(net, junction=j3, mdot_kg_per_s=0.045, name=\"Sink\")\n", "\n", "# create branch element\n", "pipe = pp.create_pipe_from_parameters(net, from_junction=j1, to_junction=j2, length_km=0.1, diameter_m=0.05, name=\"Pipe 1\")\n", "valve = pp.create_valve(net, from_junction=j2, to_junction=j3, diameter_m=0.05, opened=True, name=\"Valve 1\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note that the fluid used here is lgas. You can find 5 predefined fluids in pandapipes:\n", " - lgas\n", " - hgas\n", " - hydrogen\n", " - water\n", " - air\n", "\n", "And that the predefined valve element is an ideal valve. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Data Structure\n", "\n", "Each dataframe in a pandapipes net object contains the information about one pandapipes element, such as pipe, sink, valve etc." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": " name pn_bar tfluid_k height_m in_service type\n0 Junction 1 1.05 293.15 0.0 True junction\n1 Junction 2 1.05 293.15 0.0 True junction\n2 Junction 3 1.05 293.15 0.0 True junction", "text/html": "
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
namepn_bartfluid_kheight_min_servicetype
0Junction 11.05293.150.0Truejunction
1Junction 21.05293.150.0Truejunction
2Junction 31.05293.150.0Truejunction
\n
" }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "net.junction" ] }, { "cell_type": "code", "execution_count": 3, "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.1 0.05 1.0 \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 \n\n type \n0 pipe ", "text/html": "
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
namefrom_junctionto_junctionstd_typelength_kmdiameter_mk_mmloss_coefficientalpha_w_per_m2ktext_kqext_wsectionsin_servicetype
0Pipe 101None0.10.051.00.00.0293.00.01Truepipe
\n
" }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "net.pipe" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": " name junction p_bar t_k in_service type\n0 Grid Connection 0 1.1 293.15 True pt", "text/html": "
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
namejunctionp_bart_kin_servicetype
0Grid Connection01.1293.15Truept
\n
" }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "net.ext_grid" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Pipe Flow\n", "\n", "We now run a pipe flow:\n" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "hp.pandapipes.pipeflow - INFO: niter 0\n", "hp.pandapipes.pipeflow - INFO: niter 1\n", "hp.pandapipes.pipeflow - INFO: niter 2\n", "hp.pandapipes.pipeflow - INFO: niter 3\n", "hp.pandapipes.pipeflow - INFO: ---------------------------------------------------------------------------------\n", "hp.pandapipes.pipeflow - INFO: Calculation completed. Preparing results...\n", "hp.pandapipes.pipeflow - INFO: Converged after 4 iterations.\n", "hp.pandapipes.pipeflow - INFO: Norm of residual: 1.6351116571833302e-08\n", "hp.pandapipes.pipeflow - INFO: tol_p: 0.0001\n", "hp.pandapipes.pipeflow - INFO: tol_v: 0.0001\n" ] } ], "source": [ "pp.pipeflow(net)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And check out at the results for junctions and pipes:" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": " p_bar t_k\n0 1.100000 293.15\n1 0.913916 293.15\n2 0.913916 293.15", "text/html": "
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
p_bart_k
01.100000293.15
10.913916293.15
20.913916293.15
\n
" }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "net.res_junction" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "They're is no pressure loss between junction 2 and junction 3 because of the ideal valve." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": " v_from_m_per_s v_to_m_per_s v_mean_m_per_s p_from_bar p_to_bar \\\n0 15.766074 17.295535 16.483877 1.1 0.913916 \n\n t_from_k t_to_k mdot_from_kg_per_s mdot_to_kg_per_s vdot_norm_m3_per_s \\\n0 293.15 293.15 0.045 -0.045 0.06044 \n\n reynolds lambda normfactor_from normfactor_to \n0 96710.314701 0.049222 0.512189 0.561877 ", "text/html": "
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
v_from_m_per_sv_to_m_per_sv_mean_m_per_sp_from_barp_to_bart_from_kt_to_kmdot_from_kg_per_smdot_to_kg_per_svdot_norm_m3_per_sreynoldslambdanormfactor_fromnormfactor_to
015.76607417.29553516.4838771.10.913916293.15293.150.045-0.0450.0604496710.3147010.0492220.5121890.561877
\n
" }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "net.res_pipe" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Closed valve\n", "\n", "We now close the valve between junction 2 and junction 3:" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "# Problem can not run pipeflow if valve closed\n", "net.valve.opened = False" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The closed valve cuts the sink from the external grid:\n", "\n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This can be verified by running a power flow and inspecting the results. The pressure and temperature at junction 2 is given as NaN:" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "scrolled": true }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "hp.pandapipes.pipeflow_setup - INFO: Setting the following nodes out of service for hydraulics calculation in connectivity check:\n", "In table junction: [2]\n", "hp.pandapipes.pipeflow - INFO: niter 0\n", "hp.pandapipes.pipeflow - INFO: niter 1\n", "hp.pandapipes.pipeflow - INFO: ---------------------------------------------------------------------------------\n", "hp.pandapipes.pipeflow - INFO: Calculation completed. Preparing results...\n", "hp.pandapipes.pipeflow - INFO: Converged after 2 iterations.\n", "hp.pandapipes.pipeflow - INFO: Norm of residual: 6.635561679383765e-07\n", "hp.pandapipes.pipeflow - INFO: tol_p: 0.0001\n", "hp.pandapipes.pipeflow - INFO: tol_v: 0.0001\n" ] }, { "data": { "text/plain": " p_bar t_k\n0 1.1 293.15\n1 1.1 293.15\n2 NaN NaN", "text/html": "
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
p_bart_k
01.1293.15
11.1293.15
2NaNNaN
\n
" }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pp.pipeflow(net)\n", "net.res_junction" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Also the results from the pipe show that the mass flow is almost zero and the speed of the mass flow is zero. " ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": " v_from_m_per_s v_to_m_per_s v_mean_m_per_s p_from_bar p_to_bar \\\n0 0.0 0.0 0.0 1.1 1.1 \n\n t_from_k t_to_k mdot_from_kg_per_s mdot_to_kg_per_s vdot_norm_m3_per_s \\\n0 293.15 293.15 0.0 -0.0 0.0 \n\n reynolds lambda normfactor_from normfactor_to \n0 0.0 0.04856 0.512189 0.512189 ", "text/html": "
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
v_from_m_per_sv_to_m_per_sv_mean_m_per_sp_from_barp_to_bart_from_kt_to_kmdot_from_kg_per_smdot_to_kg_per_svdot_norm_m3_per_sreynoldslambdanormfactor_fromnormfactor_to
00.00.00.01.11.1293.15293.150.0-0.00.00.00.048560.5121890.512189
\n
" }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "net.res_pipe" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.4" } }, "nbformat": 4, "nbformat_minor": 2 }