From b651e10d513924d65461e2ea561c502bf1fc9960 Mon Sep 17 00:00:00 2001 From: ssnigdha Date: Fri, 30 Apr 2021 00:19:56 +0200 Subject: [PATCH 1/2] edited Tap step percent --- tutorials/control_loop.ipynb | 399 ++++++++++++++++++++++++++++++++--- 1 file changed, 369 insertions(+), 30 deletions(-) diff --git a/tutorials/control_loop.ipynb b/tutorials/control_loop.ipynb index 10bd13bc4..d89cf1cf4 100644 --- a/tutorials/control_loop.ipynb +++ b/tutorials/control_loop.ipynb @@ -16,7 +16,7 @@ }, { "cell_type": "code", - "execution_count": 73, + "execution_count": 1, "metadata": {}, "outputs": [ { @@ -65,7 +65,7 @@ " \n", " \n", " \n", - " 114\n", + " 114\n", " HV/MV Transformer 0\n", " 25 MVA 110/20 kV\n", " 58\n", @@ -89,7 +89,7 @@ " True\n", " \n", " \n", - " 142\n", + " 142\n", " HV/MV Transformer 1\n", " 25 MVA 110/20 kV\n", " 318\n", @@ -137,13 +137,15 @@ "[2 rows x 23 columns]" ] }, - "execution_count": 73, + "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Importing necessary packages\n", + "import sys\n", + "sys.path.extend([r\"C:\\Users\\ssnigdha\\PycharmProjects\\pandapower\"])\n", "import pandapower as pp\n", "from pandapower.networks import mv_oberrhein\n", "\n", @@ -160,7 +162,7 @@ }, { "cell_type": "code", - "execution_count": 74, + "execution_count": 2, "metadata": {}, "outputs": [ { @@ -171,7 +173,7 @@ "Name: vm_lv_pu, dtype: float64" ] }, - "execution_count": 74, + "execution_count": 2, "metadata": {}, "output_type": "execute_result" } @@ -190,7 +192,7 @@ }, { "cell_type": "code", - "execution_count": 75, + "execution_count": 3, "metadata": {}, "outputs": [ { @@ -201,7 +203,7 @@ "Name: tap_pos, dtype: int32" ] }, - "execution_count": 75, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } @@ -233,12 +235,12 @@ }, { "cell_type": "code", - "execution_count": 76, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "import pandapower.control as control\n", - "trafo_controller = control.DiscreteTapControl(net=net, tid=114, vm_lower_pu=0.99, vm_uppe_pur=1.01)" + "trafo_controller = control.DiscreteTapControl(net=net, tid=114, vm_lower_pu=0.99, vm_upper_pu=1.01)" ] }, { @@ -250,7 +252,7 @@ }, { "cell_type": "code", - "execution_count": 77, + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -274,32 +276,37 @@ " \n", " \n", " \n", - " controller\n", + " object\n", " in_service\n", " order\n", " level\n", + " initial_run\n", " recycle\n", " \n", " \n", " \n", " \n", - " 0\n", + " 0\n", " DiscreteTapControl of trafo 114\n", " True\n", " 0.0\n", " 0\n", - " False\n", + " True\n", + " {'trafo': True, 'gen': False, 'bus_pq': False}\n", " \n", " \n", "\n", "" ], "text/plain": [ - " controller in_service order level recycle\n", - "0 DiscreteTapControl of trafo 114 True 0.0 0 False" + " object in_service order level initial_run \\\n", + "0 DiscreteTapControl of trafo 114 True 0.0 0 True \n", + "\n", + " recycle \n", + "0 {'trafo': True, 'gen': False, 'bus_pq': False} " ] }, - "execution_count": 77, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -317,7 +324,7 @@ }, { "cell_type": "code", - "execution_count": 78, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -328,7 +335,7 @@ "Name: vm_lv_pu, dtype: float64" ] }, - "execution_count": 78, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -348,7 +355,7 @@ }, { "cell_type": "code", - "execution_count": 79, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -359,7 +366,318 @@ "Name: tap_pos, dtype: int32" ] }, - "execution_count": 79, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "net.trafo[\"tap_pos\"]" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "114 25 MVA 110/20 kV\n", + "142 25 MVA 110/20 kV\n", + "Name: std_type, dtype: object" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "net.trafo.std_type" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Discrete Tap Control: Alternative mode" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [], + "source": [ + "net.controller.drop([trafo_controller.index], inplace = True)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The tap step percent is an alternative way to Discrete Tap Control. It sets a single voltage instead of a deadband of permissable voltage and calculates the voltage limit for the upper and lower side by adding and subtracting the vm_delta_pu respectively. We define such a controller for the first transformer as an alternative to Discrete Tap Control in the oberrhein network with a voltage of 1.05 pu:" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0.0075 1.0425 1.0575\n" + ] + } + ], + "source": [ + "vm_delta_pu = net.trafo.at[142, \"tap_step_percent\"] / 100. * .5\n", + "vm_lower_pu = 1.05 - vm_delta_pu\n", + "vm_upper_pu = 1.05 + vm_delta_pu\n", + "print(vm_delta_pu,vm_lower_pu,vm_upper_pu)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We got the limit of upper side voltage by adding the vm_delta_pu to the set voltage and the lower side voltage limit by substracting the vm_delta_pu from the vm_set_pu." + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [], + "source": [ + "trafo_controller2 = control.DiscreteTapControl.from_tap_step_percent(net=net, tid=114, vm_set_pu=1.05, side=\"lv\", tol=1e-3, in_service=True, order=0,\n", + " drop_same_existing_ctrl=False, matching_params=None)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Here we added the tap step percent to the first transformer" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [], + "source": [ + "pp.runpp(net, run_control=True)" + ] + }, + { + "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", + "
objectin_serviceorderlevelinitial_runrecycle
0DiscreteTapControl of trafo 114True0.00True{'trafo': True, 'gen': False, 'bus_pq': False}
\n", + "
" + ], + "text/plain": [ + " object in_service order level initial_run \\\n", + "0 DiscreteTapControl of trafo 114 True 0.0 0 True \n", + "\n", + " recycle \n", + "0 {'trafo': True, 'gen': False, 'bus_pq': False} " + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "net.controller" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "114 1.048740\n", + "142 1.028804\n", + "Name: vm_lv_pu, dtype: float64" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "net.res_trafo.vm_lv_pu" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The voltage at transformer 114 is now changed to 1.048740 which is between the upper and lower limits" + ] + }, + { + "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", + " \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_mwq_hv_mvarp_lv_mwq_lv_mvarpl_mwql_mvari_hv_kai_lv_kavm_hv_puva_hv_degreevm_lv_puva_lv_degreeloading_percent
11417.2450993.741077-17.181802-2.5110610.0632981.2300160.0926190.4779691.00.01.048740-3.94403270.584884
14220.8630174.653035-20.784893-2.7894310.0781231.8636050.1121930.5884381.00.01.028804-4.94395385.502393
\n", + "
" + ], + "text/plain": [ + " p_hv_mw q_hv_mvar p_lv_mw q_lv_mvar pl_mw ql_mvar i_hv_ka \\\n", + "114 17.245099 3.741077 -17.181802 -2.511061 0.063298 1.230016 0.092619 \n", + "142 20.863017 4.653035 -20.784893 -2.789431 0.078123 1.863605 0.112193 \n", + "\n", + " i_lv_ka vm_hv_pu va_hv_degree vm_lv_pu va_lv_degree loading_percent \n", + "114 0.477969 1.0 0.0 1.048740 -3.944032 70.584884 \n", + "142 0.588438 1.0 0.0 1.028804 -4.943953 85.502393 " + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "net.res_trafo" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "114 -4\n", + "142 -3\n", + "Name: tap_pos, dtype: int32" + ] + }, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } @@ -368,6 +686,13 @@ "net.trafo[\"tap_pos\"]" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The tap position of the second transformer has been changed from -1 to -4:" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -379,7 +704,7 @@ }, { "cell_type": "code", - "execution_count": 80, + "execution_count": 17, "metadata": {}, "outputs": [], "source": [ @@ -395,18 +720,18 @@ }, { "cell_type": "code", - "execution_count": 81, + "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "114 0.998267\n", - "142 0.980000\n", + "114 1.04874\n", + "142 0.98000\n", "Name: vm_lv_pu, dtype: float64" ] }, - "execution_count": 81, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } @@ -425,18 +750,18 @@ }, { "cell_type": "code", - "execution_count": 82, + "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "114 -1.000000\n", + "114 -4.000000\n", "142 -0.067373\n", "Name: tap_pos, dtype: float64" ] }, - "execution_count": 82, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" } @@ -451,6 +776,20 @@ "source": [ "While this obviously would not possible in real transformers, it can be useful to assume continous taps in large scale studies to avoid big steps in the results." ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { @@ -469,7 +808,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.5" + "version": "3.8.8" } }, "nbformat": 4, From f5eafbd52a051f429e291f7c32a2528dfc8822d4 Mon Sep 17 00:00:00 2001 From: ssnigdha Date: Fri, 30 Apr 2021 14:42:11 +0200 Subject: [PATCH 2/2] removed manual path --- tutorials/control_loop.ipynb | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/tutorials/control_loop.ipynb b/tutorials/control_loop.ipynb index d89cf1cf4..29fdf8a71 100644 --- a/tutorials/control_loop.ipynb +++ b/tutorials/control_loop.ipynb @@ -144,8 +144,6 @@ ], "source": [ "# Importing necessary packages\n", - "import sys\n", - "sys.path.extend([r\"C:\\Users\\ssnigdha\\PycharmProjects\\pandapower\"])\n", "import pandapower as pp\n", "from pandapower.networks import mv_oberrhein\n", "\n", @@ -776,20 +774,6 @@ "source": [ "While this obviously would not possible in real transformers, it can be useful to assume continous taps in large scale studies to avoid big steps in the results." ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": {