{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Minimal Example pandapower\n", "\n", "\n", "## Creating a Power System\n", "\n", "We consider the following simple 3-bus example network as a minimal example:\n", "\n", "\n", "\n", "The above network can be created in pandapower as follows:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import pandapower as pp\n", "\n", "#create empty net\n", "net = pp.create_empty_network()\n", "\n", "#create buses\n", "bus1 = pp.create_bus(net, vn_kv=20., name=\"Bus 1\")\n", "bus2 = pp.create_bus(net, vn_kv=0.4, name=\"Bus 2\")\n", "bus3 = pp.create_bus(net, vn_kv=0.4, name=\"Bus 3\")\n", "\n", "#create bus elements\n", "pp.create_ext_grid(net, bus=bus1, vm_pu=1.02, name=\"Grid Connection\")\n", "pp.create_load(net, bus=bus3, p_kw=100, q_kvar=50, name=\"Load\")\n", "\n", "#create branch elements\n", "trafo = pp.create_transformer(net, hv_bus=bus1, lv_bus=bus2, std_type=\"0.4 MVA 20/0.4 kV\", name=\"Trafo\")\n", "line = pp.create_line(net, from_bus=bus2, to_bus=bus3, length_km=0.1, std_type=\"NAYY 4x50 SE\", name=\"Line\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Data Structure\n", "\n", "Each dataframe in a pandapower net object contains the information about one pandapower element, such as line, load transformer etc." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "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", "
namevn_kvtypezonein_service
0Bus 120.0bNoneTrue
1Bus 20.4bNoneTrue
2Bus 30.4bNoneTrue
\n", "
" ], "text/plain": [ " name vn_kv type zone in_service\n", "0 Bus 1 20.0 b None True\n", "1 Bus 2 0.4 b None True\n", "2 Bus 3 0.4 b None True" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "net.bus" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "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", "
namestd_typefrom_busto_buslength_kmr_ohm_per_kmx_ohm_per_kmc_nf_per_kmmax_i_kadfparalleltypein_service
0LineNAYY 4x50 SE120.10.6420.083210.00.1421.01csTrue
\n", "
" ], "text/plain": [ " name std_type from_bus to_bus length_km r_ohm_per_km \\\n", "0 Line NAYY 4x50 SE 1 2 0.1 0.642 \n", "\n", " x_ohm_per_km c_nf_per_km max_i_ka df parallel type in_service \n", "0 0.083 210.0 0.142 1.0 1 cs True " ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "net.line" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
namestd_typehv_buslv_bussn_kvavn_hv_kvvn_lv_kvvsc_percentvscr_percentpfe_kw...tp_sidetp_midtp_mintp_maxtp_st_percenttp_st_degreetp_posparalleldfin_service
0Trafo0.4 MVA 20/0.4 kV01400.020.00.46.01.4251.35...hv0-222.50.0011.0True
\n", "

1 rows × 22 columns

\n", "
" ], "text/plain": [ " name std_type hv_bus lv_bus sn_kva vn_hv_kv vn_lv_kv \\\n", "0 Trafo 0.4 MVA 20/0.4 kV 0 1 400.0 20.0 0.4 \n", "\n", " vsc_percent vscr_percent pfe_kw ... tp_side tp_mid tp_min \\\n", "0 6.0 1.425 1.35 ... hv 0 -2 \n", "\n", " tp_max tp_st_percent tp_st_degree tp_pos parallel df in_service \n", "0 2 2.5 0.0 0 1 1.0 True \n", "\n", "[1 rows x 22 columns]" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "net.trafo" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "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", "
namebusp_kwq_kvarconst_z_percentconst_i_percentsn_kvascalingin_servicetype
0Load2100.050.00.00.0NaN1.0TrueNone
\n", "
" ], "text/plain": [ " name bus p_kw q_kvar const_z_percent const_i_percent sn_kva \\\n", "0 Load 2 100.0 50.0 0.0 0.0 NaN \n", "\n", " scaling in_service type \n", "0 1.0 True None " ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "net.load" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note that line and transformer are created from the standard type library. The electric parameters of are automatically filled in from the standard type library." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Power Flow\n", "\n", "We now run a power flow:" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "pp.runpp(net)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And look at the results:" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "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", "
vm_puva_degreep_kwq_kvar
01.0200000.000000-107.265391-52.675195
11.008843-0.7601260.0000000.000000
20.9644310.115859100.00000050.000000
\n", "
" ], "text/plain": [ " vm_pu va_degree p_kw q_kvar\n", "0 1.020000 0.000000 -107.265391 -52.675195\n", "1 1.008843 -0.760126 0.000000 0.000000\n", "2 0.964431 0.115859 100.000000 50.000000" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "net.res_bus" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "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", "
p_from_kwq_from_kvarp_to_kwq_to_kvarpl_kwql_kvari_from_kai_to_kai_kaloading_percent
0105.39239150.696119-100.0-50.05.3923910.6961190.1673250.1673260.167326117.835208
\n", "
" ], "text/plain": [ " p_from_kw q_from_kvar p_to_kw q_to_kvar pl_kw ql_kvar i_from_ka \\\n", "0 105.392391 50.696119 -100.0 -50.0 5.392391 0.696119 0.167325 \n", "\n", " i_to_ka i_ka loading_percent \n", "0 0.167326 0.167326 117.835208 " ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "net.res_line" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "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", "
p_hv_kwq_hv_kvarp_lv_kwq_lv_kvarpl_kwql_kvari_hv_kai_lv_kaloading_percent
0107.26539152.675195-105.392391-50.6961191.8729991.9790760.0033820.16732529.289513
\n", "
" ], "text/plain": [ " p_hv_kw q_hv_kvar p_lv_kw q_lv_kvar pl_kw ql_kvar i_hv_ka \\\n", "0 107.265391 52.675195 -105.392391 -50.696119 1.872999 1.979076 0.003382 \n", "\n", " i_lv_ka loading_percent \n", "0 0.167325 29.289513 " ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "net.res_trafo" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Tap Changers\n", "\n", "We now lower the tap changer position, from position 0 to -1 and run another power flow:" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "net.trafo.tp_pos.at[trafo] = -1\n", "pp.runpp(net)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Looking at the results shows that bus voltages at the low voltage side of the transformer have increased:" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "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", "
vm_puva_degreep_kwq_kvar
01.0200000.000000-107.015048-52.52886
11.035301-0.7202450.0000000.00000
20.9921350.109513100.00000050.00000
\n", "
" ], "text/plain": [ " vm_pu va_degree p_kw q_kvar\n", "0 1.020000 0.000000 -107.015048 -52.52886\n", "1 1.035301 -0.720245 0.000000 0.00000\n", "2 0.992135 0.109513 100.000000 50.00000" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "net.res_bus" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Switches\n", "\n", "We now create an open switch at the load bus:" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pp.create_switch(net, bus=bus3, element=line, et=\"l\", closed=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The open switch cuts the load bus from power supply:\n", " \n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This can be verified by running a power flow and inspecting the results. The voltage at bus 2 is given as NaN:" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "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", "
vm_puva_degreep_kwq_kvar
01.0200000.000000-1.4774560.00101
11.046129-0.0056370.0000000.00000
2NaNNaN0.0000000.00000
\n", "
" ], "text/plain": [ " vm_pu va_degree p_kw q_kvar\n", "0 1.020000 0.000000 -1.477456 0.00101\n", "1 1.046129 -0.005637 0.000000 0.00000\n", "2 NaN NaN 0.000000 0.00000" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pp.runpp(net)\n", "net.res_bus" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The load does not feed in:" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
p_kwq_kvar
00.00.0
\n", "
" ], "text/plain": [ " p_kw q_kvar\n", "0 0.0 0.0" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "net.res_load" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And the line is in open loop operation:" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "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", "
p_from_kwq_from_kvarp_to_kwq_to_kvarpl_kwql_kvari_from_kai_to_kai_kaloading_percent
01.225726e-10-0.001155-4.643684e-132.090631e-121.221082e-10-0.0011550.0000022.954807e-150.0000020.001122
\n", "
" ], "text/plain": [ " p_from_kw q_from_kvar p_to_kw q_to_kvar pl_kw \\\n", "0 1.225726e-10 -0.001155 -4.643684e-13 2.090631e-12 1.221082e-10 \n", "\n", " ql_kvar i_from_ka i_to_ka i_ka loading_percent \n", "0 -0.001155 0.000002 2.954807e-15 0.000002 0.001122 " ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "net.res_line" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Topological Analysis\n", "\n", "The structure of the network can also be directly analyzed with the topology package. It uses an interface to the NetworkX library for graph searches. There are some predefined search algorithms, such as searching for unsupplied buses:" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{2}" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import pandapower.topology as top\n", "top.unsupplied_buses(net)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The package correctly determines that bus 2 is cut from power supply. When we close the switch, there are no unsupplied buses anymore:" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "set()" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "net.switch.closed.at[0] = True\n", "top.unsupplied_buses(net)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Apart from predefined search functions, it is also possible to translate the pandapower network into a NetworkX graph and run searches directly on that graph.\n", "\n", "Suppose we want to find all buses that are on the same voltage level as the load bus. We then translate the grid into a graph but excluding the transformer:" ] }, { "cell_type": "code", "execution_count": 18, "metadata": { "collapsed": true }, "outputs": [], "source": [ "mg = top.create_nxgraph(net, include_trafos=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And search for all buses that are connected to the load bus in that graph:" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[2, 1]" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "list(top.connected_component(mg, 2))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The graph search finds all buses that are on the same voltage level. Searches like these can be used for feeder identification and many more applications." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Short Circuit Analysis\n", "\n", "pandapower includes a short circuit module that complies with IEC 60909. To run a short circuit analysis, we need to define short circuit parameters for the external grid:" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [], "source": [ "net.ext_grid[\"s_sc_max_mva\"] = 100\n", "net.ext_grid[\"rx_max\"] = 0.1" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we can calculate short circuits. Here, we calculate a three phase short circuit current with a fault impedance of 2 Ohms:" ] }, { "cell_type": "code", "execution_count": 21, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import pandapower.shortcircuit as sc\n", "sc.calc_sc(net, case=\"max\", ip=True, r_fault_ohm=2.)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Initial and peak short circuit currents are given for faults at all buses:" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "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", "
ikss_kaip_ka
02.5347074.317318
10.1266310.182666
20.1226980.176991
\n", "
" ], "text/plain": [ " ikss_ka ip_ka\n", "0 2.534707 4.317318\n", "1 0.126631 0.182666\n", "2 0.122698 0.176991" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "net.res_bus_sc" ] } ], "metadata": { "kernelspec": { "display_name": "Python [conda root]", "language": "python", "name": "conda-root-py" }, "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.5.3" } }, "nbformat": 4, "nbformat_minor": 2 }