{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Simple 2 bus Example\n", "\n", "This tutorial shows how to perform three phase load flow in an unbalanced system.\n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Three phase or unbalanced load flow is performed using the function \n", " pp.runpp_3ph(net) " ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "import pandapower as pp" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Create Buses\n", "After this import we can start by creating an empty network and two 110 kV buses \n", "\n", "# Create External Grid\n", "For negative and zero sequence networks. \n", "The following data is needed in addition to a voltage reference.\n", "- s_sc_max_mva\n", "- rx_max\n", "- r0x0_max\n", "- x0x_max\n" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "net = pp.create_empty_network(sn_mva = 100 )\n", "bus_eg = pp.create_bus(net, vn_kv = 110, name = \"Ext. Grid\")\n", "bus_load = pp.create_bus(net, vn_kv = 110, name = \"Load\")\n", "\n", "pp.create_ext_grid(net, bus=bus_eg, vm_pu= 1.0, name=\"Grid Connection\",\n", " s_sc_max_mva=5000,rx_max=0.1,r0x0_max= 0.1,x0x_max=1.0)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Creating Lines and transformers\n", "\n", "Just like balanced load flow there are two ways of creating lines and transformers:\n", "- Create using a Standard type from standard type library/ Customized standard type\n", "- Create directly from parameters\n", "\n", "# Create element using a Customized Standard type \n", "\n", "**This is useful for large networks with many lines and transformers**\n" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "#Line Type created\n", "pp.create_std_type(net, {\"r0_ohm_per_km\": 0.0848, \"x0_ohm_per_km\": 0.4649556, \"c0_nf_per_km\":\\\n", " 230.6,\"max_i_ka\": 0.963, \"r_ohm_per_km\": 0.0212, \"x_ohm_per_km\": 0.1162389,\n", " \"c_nf_per_km\": 230}, name=\"example_type\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "After a Standard type has been created with zero sequence parameters, there are two more steps required:\n", "- Create a line using **pp.create_line** with the standard type\n", "- Use **pp.add_zero_impedance_parameters** function to insert them into network elements line and trafo from standard types\n", "\n" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "\n", "# Actual line created with the length of the line in km\n", "pp.create_line(net, from_bus = bus_eg, to_bus = bus_load, length_km = 50.0, std_type=\"example_type\")\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Create Unbalanced Load\n", "We can create three phase loads by specifying P, Q values in each phase.\n", "The default values are set to zero.\n", "\n", "Connection type of load can be specified while creating a three phase load\n", "\n", "**'wye' (Default)** - 3 phase phase-earth load\n", "\n", "**'delta'** - 3 phase delta load" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#This function creates an unbalanced load\n", "pp.create_asymmetric_load(net, bus_load, p_a_mw=50, q_a_mvar=50, p_b_mw=10, q_b_mvar=15,\n", " p_c_mw=10, q_c_mvar=5)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# add_zero_impedance_parameters\n", "\n", "This function is required when lines and transformers are created using standard types.\n", "\n", "This adds the zero sequence parameters from standard type to the network elements trafo and line\n", "\n", "# runpp_3ph\n", "\n", "This function performs the calculation and returns results in result tables:\n", "\n", "-res_element_3ph " ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Empty DataFrame\n", "Columns: [name, std_type, hv_bus, lv_bus, sn_mva, vn_hv_kv, vn_lv_kv, vk_percent, vkr_percent, pfe_kw, i0_percent, shift_degree, tap_side, tap_neutral, tap_min, tap_max, tap_step_percent, tap_step_degree, tap_pos, tap_phase_shifter, parallel, df, in_service, vector_group, vk0_percent, vkr0_percent, mag0_percent, mag0_rx, si0_hv_partial, xn_ohm]\n", "Index: []\n", "\n", "[0 rows x 30 columns]\n", "----------------\n" ] }, { "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", " \n", "
vm_a_puva_a_degreevm_b_puva_b_degreevm_c_puva_c_degreep_a_mwq_a_mvarp_b_mwq_b_mvarp_c_mwq_c_mvarunbalance_percent
00.967429-1.0512531.013028-119.4706541.019784120.471400-55.707739-60.797345-8.7799370.880937-9.37392811.4416661.985821
10.749574-9.0102131.091380-124.1057921.051243125.89450450.00000050.00000010.00000015.00000010.0000005.0000006.642212
\n", "
" ], "text/plain": [ " vm_a_pu va_a_degree vm_b_pu va_b_degree vm_c_pu va_c_degree \\\n", "0 0.967429 -1.051253 1.013028 -119.470654 1.019784 120.471400 \n", "1 0.749574 -9.010213 1.091380 -124.105792 1.051243 125.894504 \n", "\n", " p_a_mw q_a_mvar p_b_mw q_b_mvar p_c_mw q_c_mvar \\\n", "0 -55.707739 -60.797345 -8.779937 0.880937 -9.373928 11.441666 \n", "1 50.000000 50.000000 10.000000 15.000000 10.000000 5.000000 \n", "\n", " unbalance_percent \n", "0 1.985821 \n", "1 6.642212 " ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pp.add_zero_impedance_parameters(net)\n", "pp.runpp_3ph(net)\n", "print(net.trafo)\n", "print(\"----------------\")\n", "net.res_bus_3ph" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The convergence of load flow can be checked with the following:" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "net['converged']" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 3 Bus system with a transformer in between External Grid and Distribution system\n", "\n", "" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Empty DataFrame\n", "Columns: [name, std_type, hv_bus, lv_bus, sn_mva, vn_hv_kv, vn_lv_kv, vk_percent, vkr_percent, pfe_kw, i0_percent, shift_degree, tap_side, tap_neutral, tap_min, tap_max, tap_step_percent, tap_step_degree, tap_pos, tap_phase_shifter, parallel, df, in_service]\n", "Index: []\n", "\n", "[0 rows x 23 columns]\n", "-----------------------------------\n" ] } ], "source": [ "net = pp.create_empty_network(sn_mva=100)\n", "\n", "bus_eg = pp.create_bus(net, 10)\n", "bus_lv = pp.create_bus(net, 0.4)\n", "bus_load = pp.create_bus(net, 0.4 )\n", "\n", "pp.create_ext_grid(net, bus_eg, s_sc_max_mva=10000, rx_max=0.1)\n", "net.ext_grid[\"r0x0_max\"] = 0.1\n", "net.ext_grid[\"x0x_max\"] = 1.0\n", "print(net.trafo)\n", "print('-----------------------------------')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Create line and transformer using parameters.\n", "\n", "Creates a transformer using parameters" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pp.create_transformer_from_parameters(net, hv_bus=bus_eg, lv_bus=bus_lv, \n", " sn_mva= 1.6, vn_hv_kv= 10, \n", " vn_lv_kv= 0.4, vk_percent= 6, \n", " vkr_percent= 0.78125, pfe_kw= 2.7, \n", " i0_percent= 0.16875, shift_degree= 0, \n", " tap_side= 'lv',tap_neutral= 0,\n", " tap_min= -2, tap_max= 2,\n", " tap_step_degree= 0,\n", " tap_step_percent= 2.5,\n", " tap_phase_shifter= False,\n", " vk0_percent= 6, vkr0_percent= 0.78125, \n", " mag0_percent= 100, mag0_rx= 0.,\n", " si0_hv_partial= 0.9,vector_group= \"Dyn\",\n", " parallel=1,tap_pos=0,\n", " index=pp.get_free_id(net.trafo)+1,\n", " )\n", "pp.create_line_from_parameters(net, bus_lv, bus_load, length_km=0.5,r_ohm_per_km= 0.1941, x_ohm_per_km= 0.07476991,\n", " c_nf_per_km= 1160., max_i_ka= 0.421,\n", " endtemp_degree= 70.0, r0_ohm_per_km= 0.7766,\n", " x0_ohm_per_km= 0.2990796,\n", " c0_nf_per_km= 496.2 ,index=pp.get_free_id(net.line)+1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " Reset index of transformer to prevent KeyError" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "net.trafo.reset_index(inplace=True, drop=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Create Asymmetric load\n", "\n", "Just like before create three phase load with three phase power values" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#Creates a 3 phase wye load\n", "pp.create_asymmetric_load(net, bus_load, p_a_mw=0.0300, q_a_mvar=0.0048, p_b_mw=0.0280, q_b_mvar=0.0036,\n", " p_c_mw=0.027, q_c_mvar=0.0043,type='wye')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Run Asymmetric load flow for the network\n", "\n", "Same as before, add zero sequence parameters and run 3 phase load flow.\n" ] }, { "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", " \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", " \n", "
vm_a_puva_a_degreevm_b_puva_b_degreevm_c_puva_c_degreep_a_mwq_a_mvarp_b_mwq_b_mvarp_c_mwq_c_mvarunbalance_percent
01.000000-0.0000191.000000-119.9999891.000000120.000007-0.031954-0.005008-0.030429-0.005846-0.030466-0.0041070.000033
10.998897-0.2041550.999061-120.1879090.999050119.8192850.0000000.0000000.0000000.0000000.0000000.0000000.011346
20.928733-0.9036320.945275-121.3936160.948877119.4988430.0300000.0048000.0280000.0036000.0270000.0043000.214209
\n", "
" ], "text/plain": [ " vm_a_pu va_a_degree vm_b_pu va_b_degree vm_c_pu va_c_degree \\\n", "0 1.000000 -0.000019 1.000000 -119.999989 1.000000 120.000007 \n", "1 0.998897 -0.204155 0.999061 -120.187909 0.999050 119.819285 \n", "2 0.928733 -0.903632 0.945275 -121.393616 0.948877 119.498843 \n", "\n", " p_a_mw q_a_mvar p_b_mw q_b_mvar p_c_mw q_c_mvar \\\n", "0 -0.031954 -0.005008 -0.030429 -0.005846 -0.030466 -0.004107 \n", "1 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 \n", "2 0.030000 0.004800 0.028000 0.003600 0.027000 0.004300 \n", "\n", " unbalance_percent \n", "0 0.000033 \n", "1 0.011346 \n", "2 0.214209 " ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pp.add_zero_impedance_parameters(net)\n", "pp.runpp_3ph(net)\n", "net.res_bus_3ph" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.9.13" } }, "nbformat": 4, "nbformat_minor": 2 }