To communicate to MATPOWER to exchange network data these functions are available.

pandapower.converter.from_mpc(mpc_file, f_hz=50, casename_mpc_file='mpc', validate_conversion=False)

This function converts a matpower case file (.mat) version 2 to a pandapower net.

Note: python is 0-based while Matlab is 1-based.


mpc_file - path to a matpower case file (.mat).


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

casename_mpc_file (str, ‘mpc’) - If mpc_file does not contain the arrays “gen”, “branch” and “bus” it will use the sub-struct casename_mpc_file


net - The pandapower network


import pandapower.converter as pc

pp_net = cv.from_mpc(‘case9.mat’, f_hz=60)

pandapower.converter.to_mpc(net, filename=None, init='results', calculate_voltage_angles=False, trafo_model='t', mode='pf')

This function converts a pandapower net to a matpower case files (.mat) version 2. Note: python is 0-based while Matlab is 1-based.


net - The pandapower net.


filename (None) - File path + name of the mat file which will be created. If None the mpc will only be returned

init (str, “results”) - initialization method of the loadflow For the conversion to a mpc, the following options can be chosen:

  • “flat”- flat start with voltage of 1.0pu and angle of 0° at all buses as initial solution
  • “results” - voltage vector of last loadflow from net.res_bus is copied to the mpc

calculate_voltage_angles (bool, False) - copy the voltage angles from pandapower to the mpc

If True, voltage angles are copied from pandapower to the mpc. In some cases with large differences in voltage angles (for example in case of transformers with high voltage shift), the difference between starting and end angle value is very large. In this case, the loadflow might be slow or it might not converge at all. That is why the possibility of neglecting the voltage angles of transformers and ext_grids is provided to allow and/or accelarate convergence for networks where calculation of voltage angles is not necessary.

The default value is False because pandapower was developed for distribution networks. Please be aware that this parameter has to be set to True in meshed network for correct results!

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

  • “t” - transformer is modelled as equivalent with the T-model. This is consistent with PowerFactory and is also more accurate than the PI-model. We recommend using this transformer model.
  • “pi” - transformer is modelled as equivalent PI-model. This is consistent with Sincal, but the method is questionable since the transformer is physically T-shaped. We therefore recommend the use of the T-model.


import pandapower.converter as pc

import pandapower.networks as pn

net = pn.case9()