Import the pandapower library and the neccessary methods for the conversion as follows:
import os
import pandapower as pp
from pandapower.converter import from_cim as cim2pp
First we start by defining the path of the CGMES zip files, which can convert to PandaPower. When using the ENTSO-E test models, make sure to include the Boundary profiles as well. Then call the converter.
# folder_path points to the directory where the CIM .zip-Files are stored:
folder_path = os.path.join(os.getcwd(), 'example_cim')
# cgmes_files is a list containing paths to both files needed for the CIM converter:
cgmes_files = [os.path.join(folder_path, 'CGMES_v2.4.15_SmallGridTestConfiguration_Boundary_v3.0.0.zip'),
os.path.join(folder_path, 'CGMES_v2.4.15_SmallGridTestConfiguration_BaseCase_Complete_v3.0.0.zip')]
for f in cgmes_files:
if not os.path.exists(f):
raise UserWarning(f"Wrong path specified for the CGMES file {f}")
net = cim2pp.from_cim(file_list=cgmes_files, use_GL_or_DL_profile='DL')
print('Conversion successful')
Conversion successful
Once the network is converted to pandapower, we can run a power flow:
pp.runpp(net)
print(net.res_bus.iloc[0:5]) # print first few bus results
vm_pu va_degree p_mw q_mvar 0 0.974052 -18.213450 39.0 10.000000 1 1.050000 -1.952397 -220.0 -38.767059 2 0.945710 -8.057535 33.0 15.000000 3 0.973778 -18.504162 20.0 9.000000 4 0.966486 -18.585519 90.0 30.000000
Preliminary requirements:
https://pandapower.readthedocs.io/en/latest/plotting/matplotlib/generic.html and then run the cells below.
import pandapower.plotting as plt
import pandapower.plotting.colormaps as cmaps
cmap_list = [(0.9, "blue"), (1.0, "green"), (1.1, "red")]
cmap, norm = cmaps.cmap_continuous(cmap_list)
bc = plt.create_bus_collection(net,net.bus.index.values,cmap=cmap)
lc = plt.create_line_collection(net,net.line.index.values,use_bus_geodata=True)
tc = plt.create_trafo_collection(net,net.trafo.index.values)
plt.draw_collections([bc,lc,tc])
<Axes: >