PYPOWER

The following functions are provided to enable a network data exchange with PYPOWER.

pandapower.converter.from_ppc(ppc, f_hz=50, validate_conversion=False, **kwargs)

This function converts pypower case files to pandapower net structure.

INPUT:

ppc (dict) - The pypower case file.

f_hz (int) - The frequency of the network, by default 50

validate_conversion (bool) - If True, validate_from_ppc is run after conversion. For running the validation, the ppc must already contain the pypower powerflow results or pypower must be installed, by default False

kwargs (dict) - keyword arguments for:
  • validate_from_ppc if validate_conversion is True

  • tap_side

  • check_costs is passed as “check” to create_pwl_costs() and create_poly_costs()

OUTPUT:

net - ppc converted to pandapower net structure

EXAMPLES:
>>> import pandapower
>>> from pandapower.test.converter.test_from_ppc import get_testgrids
>>> ppc = get_testgrids('pypower_cases', 'case4gs.json')
>>> net = pandapower.converter.from_ppc(ppc, f_hz=60)
pandapower.converter.validate_from_ppc(ppc, net, max_diff_values={'branch_p_mw': 1e-06, 'branch_q_mvar': 1e-06, 'bus_va_degree': 1e-05, 'bus_vm_pu': 1e-06, 'gen_p_mw': 1e-06, 'gen_q_mvar': 1e-06})

This function validates the conversion of a pypower case file (ppc) to a pandapower net. It compares the power flow calculation results which must be provided within the ppc and the net.

INPUT:

ppc - dict

net - pandapower.pandapowerNet

max_diff_values - dict, optional by default { “bus_vm_pu”: 1e-6, “bus_va_degree”: 1e-5, “branch_p_mw”: 1e-6,

“branch_q_mvar”: 1e-6, “gen_p_mw”: 1e-6, “gen_q_mvar”: 1e-6}

OUTPUT: pf_match - Whether the power flow results matches.

EXAMPLES:
>>> import pandapower
>>> from pandapower.test.converter.test_from_ppc import get_testgrids
>>> ppc = get_testgrids('pypower_cases', 'case4gs.json')
>>> net = pandapower.converter.from_ppc(ppc, f_hz=50)
>>> pandapower.runpp(net)
>>> pf_match = pandapower.converter.validate_from_ppc(ppc, net)
pandapower.converter.to_ppc(net, calculate_voltage_angles=False, trafo_model='t', switch_rx_ratio=2, check_connectivity=True, voltage_depend_loads=False, init='results', mode=None, take_slack_vm_limits=True)

This function converts a pandapower net to a pypower case file.

INPUT:

net - The pandapower net.

OPTIONAL:

calculate_voltage_angles (bool, False) - consider voltage angles in loadflow calculation

If True, voltage angles of ext_grids and transformer shifts are considered in the loadflow calculation. Considering the voltage angles is only necessary in meshed networks that are usually found in higher networks.

trafo_model (str, “t”) - transformer equivalent circuit model pandapower provides two equivalent circuit models for the transformer:

  • “t” - transformer is modeled as equivalent with the T-model.

  • “pi” - transformer is modeled as equivalent PI-model.

The “pi” - Model is not recommended, since it is less exact than the T-model. It is only recommended for validation with other software that uses the pi-model.

switch_rx_ratio (float, 2) - rx_ratio of bus-bus-switches. If impedance is zero, buses connected by a closed bus-bus switch are fused to model an ideal bus. Otherwise, they are modelled as branches with resistance defined as z_ohm column in switch table and this parameter

check_connectivity (bool, True) - Perform an extra connectivity test after the conversion from pandapower to PYPOWER

If True, an extra connectivity test based on SciPy Compressed Sparse Graph Routines is perfomed. If check finds unsupplied buses, they are set out of service in the ppc

voltage_depend_loads (bool, False) - consideration of voltage-dependent loads. If False, net.load.const_z_percent and net.load.const_i_percent are not considered, i.e. net.load.p_mw and net.load.q_mvar are considered as constant-power loads.

init (str, “results”) - initialization method of the converter pandapower ppc converter supports two methods for initializing the converter:

  • “flat” - flat start with voltage of 1.0pu and angle of 0° at all PQ-buses and 0° for PV buses as initial solution

  • “results” - voltage vector from net.res_bus is used as initial solution.

mode (str, None) - mode of power flow calculation type (“pf” - power flow, “opf” - optimal power flow or “sc” - short circuit). “mode” influences for instance whether opf cost data will be converted or which slack bus voltage limits are respected. If “mode” is None, cost data will be respected via mode=”opf” if cost data are existing.

take_slack_vm_limits (bool, True) - Per default the voltage magnitude limits are assumed as setpoint of the slack unit (usually net.ext_grid.vm_pu). To replace that by values from net.bus[[“min_vm_pu”, “max_vm_pu”]], take_slack_vm_limits can be set to False.

OUTPUT:

ppc - The Pypower casefile for usage with pypower

EXAMPLE:
>>> import pandapower.converter as pc
>>> import pandapower.networks as pn
>>> net = pn.case9()
>>> ppc = pc.to_ppc(net)