eelib.core.grid.powerfactory.powerfactory_model
eElib Powerfactory grid model.
Have a look at https://www.digsilent.de/en/powerfactory.html for more information. PowerFactory is a commercial application, where official licences are required to perform calculations. This model only presents a suitable python interface for using Powerfactory in eELib simulations.
Instructions on how to use this model:
1. First of all, as mentioned you need the PowerFactory application and a valid license, which is commercial (free only for academic use). The path to the PowerFactory program (which includes .pyd and .pyi file) has to be given either in your .env or as part of the grid_params in the .json input file.
2. To run simulations with the model, you need a grid file (extension .dz) as an input, whose path is given in the .json input file in the “grid” section.
3. To set up a correct scenario script, you should have a look at the exemplary “test_scenario_grid.py” of the eELib. You should adapt the scenario name, the path to the grid model in the SIM_CONFIG and the creation of the grid model to the following format:
grid = getattr(grid_sim, sim_config_grid["model"])(
gridfile=scenario_data["grid"],
grid_params=scenario_data["grid_parameter"],
debug=scenario_config["debug"],
)
Copyright (c) DIgSILENT
Module Contents
Classes
An electrical grid model in Power Factory style. |
Attributes
- _logger
- OUTPUT_ATTRS
- RENAMING_ATTRS
- class Powerfactory(ename: str, gridfile: str, sim_start: str, debug: bool = False, powerfactory_path: str | None = None, line_loading_max: float = 100, trafo_loading_max: float = 100, bus_vm_max_lv: float = 1.1, bus_vm_min_lv: float = 0.9, bus_vm_max_mv: float = 1.1, bus_vm_min_mv: float = 0.9, bus_vm_max_hv: float = 1.1, bus_vm_min_hv: float = 0.95, bus_vm_max_ehv: float = 1.1, bus_vm_min_ehv: float = 1.0)
Bases:
objectAn electrical grid model in Power Factory style.
- _VALID_PARAMETERS
- ename
- components_map
- gridfile
- sim_start
- timestep = '0'
- powerflow_results
- grid_status
- ptdf_mat = '[]'
- vpif_mat = '[]'
- calc_grid = 'False'
- limits
- powerfactory_path
- app
- user
- complevel = '7'
- debug = 'False'
- gridobjects = '[]'
- classmethod get_valid_parameters() dict
Returns dictionary containing valid parameter types and values.
- Returns:
valid parameters for this model
- Return type:
dict
- _load_case(file_path: str)
Loads a powerfactory grid. The grid should be ready in a .pfd or similar dataformat of powerfactory.
- Parameters:
file_path (str) – file path to the grid file
- Raises:
ValueError – if handling for this type of grid file is not implemented or given grid cannot be activated or imported
- _get_slack() tuple
Create entity of the slack bus.
- Returns:
zero with index of slack bus
- Return type:
tuple
- _get_buses() list
Create entities of the buses.
- Returns:
list of tuples, with indices of busses and their nominal voltage in kV
- Return type:
list
- _get_loads() list
Create load entities.
- Returns:
- list of load with tuples about bus index, active/reactive power, scaling factor
and their status
- Return type:
list
- _get_lines() list
Create branches entities.
- Returns:
- list of grid lines with tuples about bus indices, their length,
impedance/reactance/capacitance, maximum current and their status
- Return type:
list
- _get_trafos() list
Create trafo entities.
- Returns:
- list of trafos with tuples about bus indices, max. power, nominal voltages,
short circuit voltages, iron losses, open-loop current, phase shift, tap status and their status
- Return type:
list
- set_inputs(etype: str, idx: int, data: dict, static: dict)
Setting the input from the simulator.
- Parameters:
etype (str) – entity type of element to be set
idx (int) – index of element in element list
data (dict) – input data to be set, key (parameter) and corresponding value
static (dict) – static values of this entity
- Raises:
KeyError – If field for grid trafo is not possible to set (only ‘tap_pos’ available)
ValueError – Error if no possible entity type was given
- _powerflow(options: dict | None = None)
Runs load flow calculation. Conduct power flow for the saved grid with its options from powerfactory.
- Parameters:
options (dict | None, optional) – Dict of PowerFactory attributes to set in load flow object. Possible attributes can be found by hovering over options in PowerFactory load flow command (
*.ComLdf). Defaults to None.- Raises:
ValueError – If load flow failed in inner or outer loop.
- step(timestep: int)
Performs simulation step of eELib powerfactory grid model.
- Parameters:
timestep (int) – Current simulation time
- _store_power_flow_results()
Retrieve the results of the power flow and store them.
- _get_powerflow_result_component(eid: str) dict
Retrieve the results of the power flow for a specific component.
- Parameters:
eid (str) – Entity ID of the component to be searched for
- Returns:
dict with the results from the power flow for the component
- Return type:
dict
- _get_grid_status()
Analyse the status of the grid and its component at the current step in time.
- _get_status_bus(comp_idx: int) dict
Analyse the status of a grid bus at the current step in time.
- Parameters:
comp_idx (int) – index of the (bus) component in the corresponding grid.bus table
- Returns:
Status for the bus including limits and congestion status
- Return type:
dict
- _get_status_line(comp_idx: int, comp_type: str) dict
Analyse the status of a grid line at the current step in time.
- Parameters:
comp_idx (int) – index of the (line) component in the grid.line/.trafo table
comp_type (str) – whether it is a trafo or a line
- Returns:
Status for the line including limits and active/reactive power values
- Return type:
dict
- _calc_ptdf()
Calculate the DC Power Transfer Distribution Matrix of the Grid. WIP: Not implemented yet!
Orientation is as follows: One list for every branch (consequence), one element in each list for every bus (cause). E.g. for a 3-Bus radial grid the matrix will look like this: [[0, -1, -1], [0, 0, -1], [0, 0, 0]].
- _calc_vpif()
Calculate the AC Voltage Power Impact Factor Matrix of the (current) Grid. WIP: Not implemented yet!
The jacobian matrix is calculated in every iteration of powerflow calculation. The matrix of the last iteration is stored and will be accessed here as a sensitivity of adaptions. Direction corresponds to PSC (power consumption decreases voltage magnitude). Orientation is as follows: One list for every bus (consequence, adjustment of vm_pu), one element in each list for every bus times two (cause, first adaption of active power P afterwards adaption of reactive power Q). E.g. for a 2-bus grid the matrix will look like this: [[B1dP->B1dVm, B2dP->B1dVm, B1dQ->B1dVm, B2dQ->B1dVm], … … [B1dP->B2dVm, B2dP->B2dVm, B1dQ->B2dVm, B2dQ->B2dVm]].