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 : The pypower case file.
OPTIONAL:
f_hz (float, 50)  The frequency of the network.
 validate_conversion (bool, False)  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 importable.
**kwargs keyword arguments for validate_from_ppc if validate_conversion is True
OUTPUT:
net : pandapower net.
EXAMPLE:
import pandapower.converter as pc
from pypower import case4gs
ppc_net = case4gs.case4gs()
net = pc.from_ppc(ppc_net, f_hz=60)

pandapower.converter.
validate_from_ppc
(ppc_net, net, pf_type='runpp', max_diff_values={'branch_q_mvar': 1e06, 'gen_q_mvar': 1e06, 'bus_va_degree': 1e05, 'gen_p_mw': 1e06, 'branch_p_mw': 1e06, 'bus_vm_pu': 1e06}, run=True)¶ This function validates the pypower case files to pandapower net structure conversion via a comparison of loadflow calculation results. (Hence the opf cost conversion is not validated.)
INPUT:
 ppc_net  The pypower case file, which must already contain the pypower powerflow
results or pypower must be importable.
net  The pandapower network.
OPTIONAL:
 pf_type (“runpp”, string)  Type of validated power flow. Possible are (“runpp”,
“rundcpp”, “runopp”, “rundcopp”)
max_diff_values  Dict of maximal allowed difference values. The keys must be ‘vm_pu’, ‘va_degree’, ‘p_branch_mw’, ‘q_branch_mvar’, ‘p_gen_mw’ and ‘q_gen_mvar’ and the values floats.
 run (True, bool or list of two bools)  changing the value to False avoids trying to run
(optimal) loadflows. Giving a list of two bools addresses first pypower and second pandapower.
OUTPUT:
conversion_success  conversion_success is returned as False if pypower or pandapower cannot calculate a powerflow or if the maximum difference values (max_diff_values ) cannot be hold.
EXAMPLE:
import pandapower.converter as pc
net = cv.from_ppc(ppc_net, f_hz=50)
conversion_success = cv.validate_from_ppc(ppc_net, net)
NOTE:
The user has to take care that the loadflow results already are included in the provided ppc_net or pypower is importable.

pandapower.converter.
to_ppc
(net, calculate_voltage_angles=False, trafo_model='t', switch_rx_ratio=2, check_connectivity=True, voltage_depend_loads=True, init='results', mode=None)¶ 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 Tmodel.
“pi”  transformer is modeled as equivalent PImodel. This is not recommended, since it is less exact than the Tmodel. It is only recommended for validation with other software that uses the pimodel.
switch_rx_ratio (float, 2)  rx_ratio of busbusswitches. If impedance is zero, buses connected by a closed busbus 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, True)  consideration of voltagedependent 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 constantpower 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 PQbuses 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.
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)