{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Unbalanced power flow calculation with pandapower\n",
"\n",
"We will create a simple three bus system to demonstrate how to run unbalanced power flow calculations with pandapower. First, we create the three buses as follows:"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import pandapower as pp\n",
"\n",
"net = pp.create_empty_network()\n",
"b1 = pp.create_bus(net, 20.0)\n",
"b2 = pp.create_bus(net, 0.4)\n",
"b3 = pp.create_bus(net, 0.4)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The external grid connection can then be created with the short-circuit parameters s_sc_max_mva and rx_max as well as the parameters x0x_max and r0x0_max that define the zero sequence impedances. The ext_grid parameters are all defined in the [ext_grid parameter documentation](https://pandapower.readthedocs.io/en/develop/elements/ext_grid.html#input-parameters)."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pp.create_ext_grid(net, b1, s_sc_max_mva=1000, rx_max=0.1, x0x_max=1.0,\n",
" r0x0_max=0.1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The transformer requires the additional parameters vk0_percent, vkr0_percent, mag0_percent, mag0_rx, vector_group and si0_hv_partial for unbalanced calculation. The transformer parameters are all defined in the [transformer parameter documentation](https://pandapower.readthedocs.io/en/develop/elements/trafo.html#input-parameters)."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pp.create_transformer_from_parameters(net, b1, b2, sn_mva=0.63,\n",
" vn_hv_kv=20., vn_lv_kv=0.4,\n",
" vkr_percent=0.1, vk_percent=6,\n",
" vk0_percent=6, vkr0_percent=0.78125,\n",
" mag0_percent=100, mag0_rx=0.,\n",
" pfe_kw=0.1, i0_percent=0.1,\n",
" vector_group=\"Dyn\", shift_degree=150,\n",
" si0_hv_partial=0.9)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For lines, the zero sequence impedances r0_ohm_per_km, x0_ohm_per_km and c0_nf_per_km are required in addition to the balanced parameters. The line parameters are all defined in the [line parameter documentation](https://pandapower.readthedocs.io/en/develop/elements/line.html#input-parameters)."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pp.create_line_from_parameters(net, b2, b3, length_km=0.1, r0_ohm_per_km=0.0848,\n",
" x0_ohm_per_km=0.4649556, c0_nf_per_km=230.6,\n",
" max_i_ka=0.963, r_ohm_per_km=0.0212,\n",
" x_ohm_per_km=0.1162389, c_nf_per_km= 230)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Finally, to create an unbalanced power flow, we create an asymmetric load. The input parameters are all defined in the [asymmetric load parameter documentation](https://pandapower.readthedocs.io/en/develop/elements/asymmetric_load.html#input-parameters)."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pp.create_asymmetric_load(net, b3, p_a_mw=0.25, p_b_mw=0.18, p_c_mw=0.20, type=\"wye\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can now run an unbalanced power flow:"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"pp.runpp_3ph(net)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The results are stored in the result tables with suffix \"_3ph\", such as \"res_bus_3ph\", \"res_line_3ph\" etc.:"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" vm_a_pu | \n",
" va_a_degree | \n",
" vm_b_pu | \n",
" va_b_degree | \n",
" vm_c_pu | \n",
" va_c_degree | \n",
" p_a_mw | \n",
" q_a_mvar | \n",
" p_b_mw | \n",
" q_b_mvar | \n",
" p_c_mw | \n",
" q_c_mvar | \n",
" unbalance_percent | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 0.999949 | \n",
" -0.003361 | \n",
" 0.999975 | \n",
" -119.995771 | \n",
" 1.000076 | \n",
" 119.999132 | \n",
" -0.231404 | \n",
" -0.03769 | \n",
" -0.190675 | \n",
" -0.0338 | \n",
" -0.214458 | \n",
" -0.000469 | \n",
" 0.007796 | \n",
"
\n",
" \n",
" 1 | \n",
" 0.990176 | \n",
" -154.176770 | \n",
" 0.996375 | \n",
" 87.028465 | \n",
" 0.995592 | \n",
" -33.323592 | \n",
" 0.000000 | \n",
" 0.00000 | \n",
" 0.000000 | \n",
" 0.0000 | \n",
" 0.000000 | \n",
" 0.000000 | \n",
" 0.686886 | \n",
"
\n",
" \n",
" 2 | \n",
" 0.977551 | \n",
" -158.241097 | \n",
" 1.001594 | \n",
" 85.149362 | \n",
" 0.974593 | \n",
" -35.449411 | \n",
" 0.250000 | \n",
" 0.00000 | \n",
" 0.180000 | \n",
" 0.0000 | \n",
" 0.200000 | \n",
" 0.000000 | \n",
" 1.221488 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" vm_a_pu va_a_degree vm_b_pu va_b_degree vm_c_pu va_c_degree \\\n",
"0 0.999949 -0.003361 0.999975 -119.995771 1.000076 119.999132 \n",
"1 0.990176 -154.176770 0.996375 87.028465 0.995592 -33.323592 \n",
"2 0.977551 -158.241097 1.001594 85.149362 0.974593 -35.449411 \n",
"\n",
" p_a_mw q_a_mvar p_b_mw q_b_mvar p_c_mw q_c_mvar \\\n",
"0 -0.231404 -0.03769 -0.190675 -0.0338 -0.214458 -0.000469 \n",
"1 0.000000 0.00000 0.000000 0.0000 0.000000 0.000000 \n",
"2 0.250000 0.00000 0.180000 0.0000 0.200000 0.000000 \n",
"\n",
" unbalance_percent \n",
"0 0.007796 \n",
"1 0.686886 \n",
"2 1.221488 "
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"net.res_bus_3ph"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can check the voltage in all phases as well as the unbalance percentage according to IEC 62749:"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" vm_a_pu | \n",
" vm_b_pu | \n",
" vm_c_pu | \n",
" unbalance_percent | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 0.999949 | \n",
" 0.999975 | \n",
" 1.000076 | \n",
" 0.007796 | \n",
"
\n",
" \n",
" 1 | \n",
" 0.990176 | \n",
" 0.996375 | \n",
" 0.995592 | \n",
" 0.686886 | \n",
"
\n",
" \n",
" 2 | \n",
" 0.977551 | \n",
" 1.001594 | \n",
" 0.974593 | \n",
" 1.221488 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" vm_a_pu vm_b_pu vm_c_pu unbalance_percent\n",
"0 0.999949 0.999975 1.000076 0.007796\n",
"1 0.990176 0.996375 0.995592 0.686886\n",
"2 0.977551 1.001594 0.974593 1.221488"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"net.res_bus_3ph[[\"vm_a_pu\", \"vm_b_pu\", \"vm_c_pu\", \"unbalance_percent\"]]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The line and trafo results provide currents and loadings in different phases or overall loading, which is defined as the maximum of all phase loadings."
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" i_a_from_ka | \n",
" i_b_to_ka | \n",
" loading_b_percent | \n",
" loading_percent | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 1.107391 | \n",
" 0.778182 | \n",
" 80.808128 | \n",
" 114.993847 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" i_a_from_ka i_b_to_ka loading_b_percent loading_percent\n",
"0 1.107391 0.778182 80.808128 114.993847"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"net.res_line_3ph[[\"i_a_from_ka\", \"i_b_to_ka\", \"loading_b_percent\", \"loading_percent\"]]"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" i_a_hv_ka | \n",
" i_b_lv_ka | \n",
" loading_b_percent | \n",
" loading_percent | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 0.020305 | \n",
" 0.778182 | \n",
" 92.215451 | \n",
" 121.781392 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" i_a_hv_ka i_b_lv_ka loading_b_percent loading_percent\n",
"0 0.020305 0.778182 92.215451 121.781392"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"net.res_trafo_3ph[[\"i_a_hv_ka\", \"i_b_lv_ka\", \"loading_b_percent\", \"loading_percent\"]]"
]
}
],
"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
}