This tutorial describes how to run the Power Flow via PandaModels.jl calling PowerModels.jl package. Power Flow function in PowerModels is built based on JuMP.jl environment, thus same as OPF we need to set model parameter while calling PF function:
Note: In order to compare the results of DC-PF between PowerModels and PYPOWER / matpower calculations, you need to set the model to "DCMPPowerModel". This direct current model should be equal to the results of matpower calculations, while model="DCPPowerModel" is the linearized model from AC model. For more information please check here.
So here is an example of how it works. First, we create a simple grid in pandapower:
import copy
import numpy as np
import pandapower as pp
import pandapower.networks as nw
net = nw.simple_four_bus_system()
net.trafo.loc[0, "shift_degree"] = 0.
Then run ac power flow and get voltage angle and amplitude for buses:
try:
pp.runpm_pf(net, pm_model="ACPPowerModel", calculate_voltage_angles=True)
except Exception as err:
print(err)
hp.pandapower.opf.make_objective - WARNING: no costs are given - overall generated power is minimized
Cannot be performed
Also, there more parameters and options that you can add as input while calling the Optimization Problem from PandaModles:
parameter | description | type | default |
---|---|---|---|
correct_pm_network_data | checks if network data is correct. If not tries to correct it | bool | True |
silence | Suppresses information and warning messages output by PowerModels | bool | True |
pm_model | PowerModels.jl model to use | str | "ACPPowerModel" |
pm_solver | "main" solver | str | "ipopt" |
pm_mip_solver | mixed integer solver | str | "cbc" |
pm_nl_solver | nonlinear solver | str | "ipopt" |
pm_tol | default desired convergence tolerance for solver to use | float | 1e-8 |
pm_log_level | solver log level in power models | int | 0 |
delete_buffer_file | If True, the .json file used by PandaModels will be deleted after optimization. | bool | True |
va_pm = copy.deepcopy(net.res_bus.va_degree)
vm_pm = copy.deepcopy(net.res_bus.vm_pu)
run the powerflow from pypower:
pp.runpp(net)
va_pp = copy.deepcopy(net.res_bus.va_degree)
vm_pp = copy.deepcopy(net.res_bus.vm_pu)
lets compare the results:
np.allclose(va_pm, va_pp)
False
np.allclose(vm_pm, vm_pp)
False