Examples for application of powerfactory exporter and controller.
The whole examples are based on the PowerFactory version 2024
, but should also work with 2022
.
The jupyter notebook powerfactory_export.ipynb is provided to get in touch with the usage of the powerfactory exporter. This example is based on the PowerFactory example project.
Within the exporter example three different predefined study cases ("Base", "Industry_Park", "Outage") are to be exported.
The exporter provides functions to export
- grid
topology
(raw assets), topology_case
(binary switching info and out of service info) andsteadystate_case
(operation points)
to three different json files using the power system data model (psdm) schema.
Please note, that default values for the PowerFactory installation path and the Python version are used.
If necessary, one can adapt powerfactory_path
, powerfactory_service_pack
and python_version
when initializing the PowerFactoryExporter.
By default, all assests of all active grids within the selected PowerFactory project are to be exported.
- The preferred way for export is to assign the desired study cases to the
export()
function call, see export example. - Alternatively, one can select study cases, operation scenarios and grid variations before export for more control, see control example 7-9.
The following figure provides a short overview of the dependencies within a PowerFactory project.
In the case an export of additional attribute data is required for elements of specified types, one can specify a dictionary and pass this as aditional parameter to the Exporter
class.
In our export example such a request is performed by specifying the dict element_specific_attrs
.
The jupyter notebook powerfactory_control.ipynb is provided to get in touch with the usage of the powerfactory control possibilities. First the simple grid HV_3_Bus is manipulated, then a more sophisticated control is exceuted at HV_9_Bus grid.
The example includes:
- General request of elements
- Selection of user defined elements (e.g. based on name or voltage level)
- Change of object's attribute values
- Definition of variable monitors and result objects
- Execution of load flow - symmetrical / unsymmetrical
- Preparation and execution of RMS/EMT simulations
- Export of results objects as well as user defined data to json or csv
- Request and change study cases, operation scenarios and network variations
As PowerFactory is started in engine mode, the user may want to take a quick look at the PowerFactory application GUI at runtime. To do so, insert the following code into your script to open the PF application window in non-interavtive mode. Attention: do not close the window by your own by clicking on the red cross, but process via the user input request.
See commented code in function run_three_bus_control_example()
in powerfactory_import.ipynb:
pfi.app.Show()
time.sleep(5) # wait for 5 seconds
input("Press Enter to continue...") # Wait for user input before proceeding
pfi.app.Hide()
The jupyter notebook powerfactory_import.ipynb is provided to see how to apply a raw import of a given (exported) PSDM grid representation.
Here, PSDM class objects
are generated out of a given json
-file.
The related PowerFactory example project PF2024_PowerFactory-Tools.pfd
is provided in grids.
The project contains:
- 3-bus high voltage grid
- a composition of a 9-bus high voltage grid and a 2-bus medium voltage industry grid
Furthermore, four predefined study cases are provided:
3_Bus
(only grid "HV_3_Bus" is active)Base
(only grid "HV_9_Bus" is active)Industry_Park
("HV_9_Bus" and "MV_2_Bus" are active)Outage
(only grid "HV_9_Bus" is active, additionally the operation case "outOfService_Set1" is applied)
This very simple example grid contains:
- 110 kV voltage level
- 3 nodes
- 3 branches
- 2 general loads
- 2 static generators
- 1 external grid
This example grid contains:
- 3 different voltage levels (110 kV, 20 kV, 0.4 kV)
- 9 nodes, including one detailed substation
- 9 branches
- 2 transformers (110/20 adn 20/0.4)
- 5 general loads, including different load models
- 1 MV load
- 2 LV loads
- 1 PV system
- 1 Battery system
- 3 Static generators, including station controller
- 1 compound generator model
- 2 fuses (1 line fuse and 1 element fuse)
- 2 external grids
- 1 optional connection to the MV_2_Bus grid
This grid is an extension to the 'HV_9_Bus' grid and contains:
- 20 kV voltage level
- 2 nodes
- 1 transformer (110/20) as connection to the HV_9_Bus grid
- 1 branch
- 1 general load (const. power)
- 1 passive asset (capacitor bank)