{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Workarounds for the problem using grid equivalents\n", "This tutorial gives some suggestions to solve the difficulties that arise when using grid equivalent.\n", "In this tutorial, we still use the grid case9 as the test bed:\n", "\n", "- internal area (buses): [0, 3, 4, 8]\n", "- boundary buses: [4, 8] (boundary buses belong to the internal area)\n", "- external area (buses): [1, 2, 5, 6, 7] \n", "\n", "\"ALT\"" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandapower as pp\n", "import pandapower.networks\n", "from pandapower.grid_equivalents import get_equivalent\n", "from copy import deepcopy\n", "net = pp.networks.case9()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## A) dc line\n", "\n", "If the to-be-reduced grid has dc-lines. We need convert them before starting grid equivalent. First of all, let's create a dc-line. In the following, the line (index=2) between bus 4 and bus 8 is replaced by a dc-line" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "net.line.drop([2],inplace=True)\n", "pp.create_dcline(net, 4, 5, 50, 0.5, 0.7, 1.0, 1.0)\n", "pp.runpp(net)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now, we have got a grid with dc-line (see A)).\n", "\"ALT\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "using *_add_dcline_gens* the dc-lines are represented by generators. Then, we need to remote or disconnect the origin dc_line or close them. " ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "from pandapower.auxiliary import _add_dcline_gens\n", "net2 = deepcopy(net)\n", "_add_dcline_gens(net2)\n", "net2.dcline.in_service=False\n", "pp.runpp(net2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can compare the power flow results between *net1* and *net2* and carry out the grid equivalent process." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "hp.pandapower.grid_equivalents.get_equivalent - INFO: rei equivalent calculation started\n", "hp.pandapower.toolbox - INFO: dropped 3 gen elements\n", "hp.pandapower.toolbox - INFO: dropped 1 dcline elements\n", "hp.pandapower.toolbox - INFO: dropped 0 switches\n", "hp.pandapower.toolbox - INFO: dropped 4 lines with 0 line switches\n", "hp.pandapower.toolbox - INFO: dropped 1 load elements\n", "hp.pandapower.toolbox - INFO: dropped 1 lines with 0 line switches\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "net with dcline vm_pu va_degree p_mw q_mvar\n", "0 1.000000 0.000000 -87.837523 -30.233733\n", "1 1.000000 26.074443 -163.000000 -39.113351\n", "2 1.000000 32.268568 -85.000000 -2.118240\n", "3 0.983887 -2.947620 0.000000 0.000000\n", "4 1.000000 -11.008845 90.000000 30.000000\n", "5 1.000000 29.413484 0.000000 0.000000\n", "6 0.971830 21.570967 100.000000 35.000000\n", "7 0.980859 20.112778 0.000000 0.000000\n", "8 0.926759 0.514121 125.000000 50.000000\n", "net with represented dcline vm_pu va_degree p_mw q_mvar\n", "0 1.000000 0.000000 -87.837523 -30.233733\n", "1 1.000000 26.074443 -163.000000 -39.113351\n", "2 1.000000 32.268568 -85.000000 -2.118240\n", "3 0.983887 -2.947620 0.000000 0.000000\n", "4 1.000000 -11.008845 140.000000 -46.050989\n", "5 1.000000 29.413484 -49.050000 -12.806786\n", "6 0.971830 21.570967 100.000000 35.000000\n", "7 0.980859 20.112778 0.000000 0.000000\n", "8 0.926759 0.514121 125.000000 50.000000\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "hp.pandapower.toolbox - INFO: dropped 0 switches\n", "hp.pandapower.toolbox - INFO: dropped 1 ext_grid elements\n", "hp.pandapower.toolbox - INFO: dropped 2 lines with 0 line switches\n", "hp.pandapower.toolbox - INFO: dropped 1 lines with 0 line switches\n", "hp.pandapower.toolbox - INFO: dropped 1 dcline elements\n", "hp.pandapower.toolbox - INFO: dropped 0 switches\n", "hp.pandapower.toolbox - INFO: dropped 4 lines with 0 line switches\n", "hp.pandapower.toolbox - INFO: dropped 4 impedance elements\n", "hp.pandapower.toolbox - INFO: dropped 4 impedance elements\n", "hp.pandapower.toolbox - INFO: dropped 1 lines with 0 line switches\n", "hp.pandapower.toolbox - INFO: dropped 0 lines with 0 line switches\n", "hp.pandapower.toolbox - INFO: dropped 2 load elements\n", "hp.pandapower.toolbox - INFO: dropped 1 gen elements\n", "hp.pandapower.toolbox - INFO: dropped 2 ext_grid elements\n", "hp.pandapower.grid_equivalents.get_equivalent - INFO: \"rei\" equivalent finished in 1.35 seconds:\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "equivalent net vm_pu va_degree p_mw q_mvar\n", "0 1.000000 0.000000 -87.837523 -30.233733\n", "3 0.983887 -2.947620 0.000000 0.000000\n", "4 1.000000 -11.008845 140.000000 -46.050989\n", "8 0.926759 0.514121 124.608411 33.534278\n", "9 0.971830 21.570967 99.678777 9.765460\n", "10 1.000000 26.074443 -162.192474 -49.318707\n", "11 1.000000 32.268568 -85.000000 -2.118240\n", "12 1.000000 29.413484 -49.050000 -23.256786\n" ] } ], "source": [ "print(\"net with dcline\", net.res_bus)\n", "print(\"net with represented dcline\", net2.res_bus)\n", "net_eq = get_equivalent(net2, \"rei\", [4,8], [0])\n", "print(\"equivalent net\", net_eq.res_bus)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## B) slack in the external area\n", "\n", "In some cases, there are slack buses in the external area, see B). It could cause power flow problems during the grid equivalent calculation. In this case, we can consider the slack buses as the boundary to reserve them.\n", "In the grid *case9*, there are two generators in the external area. We activate their slack function and treat the corresponding buses as the boundary." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "hp.pandapower.grid_equivalents.get_equivalent - INFO: rei equivalent calculation started\n", "hp.pandapower.toolbox - INFO: dropped 2 gen elements\n", "hp.pandapower.toolbox - INFO: dropped 0 switches\n", "hp.pandapower.toolbox - INFO: dropped 5 lines with 0 line switches\n", "hp.pandapower.toolbox - INFO: dropped 1 load elements\n", "hp.pandapower.toolbox - INFO: dropped 1 lines with 0 line switches\n", "hp.pandapower.toolbox - INFO: dropped 0 switches\n", "hp.pandapower.toolbox - INFO: dropped 1 ext_grid elements\n", "hp.pandapower.toolbox - INFO: dropped 2 lines with 0 line switches\n", "hp.pandapower.toolbox - INFO: dropped 1 lines with 0 line switches\n", "hp.pandapower.toolbox - INFO: dropped 0 switches\n", "hp.pandapower.toolbox - INFO: dropped 5 lines with 0 line switches\n", "hp.pandapower.toolbox - INFO: dropped 3 impedance elements\n", "hp.pandapower.toolbox - INFO: dropped 3 impedance elements\n", "hp.pandapower.toolbox - INFO: dropped 1 lines with 0 line switches\n", "hp.pandapower.toolbox - INFO: dropped 0 lines with 0 line switches\n", "hp.pandapower.toolbox - INFO: dropped 2 load elements\n", "hp.pandapower.toolbox - INFO: dropped 2 ext_grid elements\n", "hp.pandapower.grid_equivalents.get_equivalent - INFO: \"rei\" equivalent finished in 0.58 seconds:\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "original net vm_pu va_degree p_mw q_mvar\n", "0 1.000000 0.000000 -127.525028 -21.454707\n", "1 1.000000 0.000000 -100.862955 -6.607394\n", "2 1.000000 0.000000 -89.753317 4.804554\n", "3 0.990370 -4.253458 0.000000 0.000000\n", "4 0.979249 -6.930476 90.000000 30.000000\n", "5 1.004194 -3.002286 0.000000 0.000000\n", "6 0.987125 -5.749658 100.000000 35.000000\n", "7 0.997864 -3.622033 0.000000 0.000000\n", "8 0.963808 -8.068145 125.000000 50.000000\n", "equivalent net vm_pu va_degree p_mw q_mvar\n", "0 1.000000 0.000000 -127.525028 -21.454707\n", "3 0.990370 -4.253458 0.000000 0.000000\n", "4 0.979249 -6.930476 89.278340 8.055702\n", "8 0.963808 -8.068145 124.576477 32.191499\n", "9 0.987125 -5.749658 99.315369 0.532046\n", "10 1.000000 0.000000 -100.055429 -16.812750\n", "11 1.000000 0.000000 -88.619419 -10.155545\n" ] } ], "source": [ "net = pp.networks.case9()\n", "net.gen.slack = True\n", "pp.runpp(net)\n", "boundary_buses = [4, 8, 1, 2]\n", "net_eq = get_equivalent(net, \"rei\", [4,8], [0])\n", "print(\"original net\", net.res_bus)\n", "print(\"equivalent net\", net_eq.res_bus)" ] } ], "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 }