Metrics, plotting, and more for the PyG OPFDataset.
Project description
opf-dataset-utils
In this package we provide utils to support working with the OPFDataset.
We implement:
- Efficient OPF related calculations to be used as metrics or in a physics informed setting:
- Power Flow errors
- Branch powers
- Costs
- Inequalities
- Data visualization
- Enums for indexing the OPFData JSON format
- And more...
Installation
Installation is currently available directly from GitHub:
pip install git+https://github.com/viktor-ktorvi/opf-dataset-utils.git
Usage
Plotting
See scripts/draw.py for a full example.
from opf_dataset_utils.plotting.draw import draw_graph
draw_graph(dataset[0], ax=ax, node_size=300)
OPF calculations
Power flow errors
See scripts/power_flow_errors.py for a full example.
from opf_dataset_utils.physics.errors.power_flow import calculate_power_flow_errors
print("Mean power flow errors:")
print(f"\tSolution: {calculate_power_flow_errors(batch, batch.y_dict).abs().mean():.5e}")
print(f"\tUntrained model prediction: {calculate_power_flow_errors(batch, predictions).abs().mean():.5f}")
Mean power flow errors:
Solution: 1.28563e-06 [p.u.]
Untrained model prediction: 413350.84375 [p.u.]
Costs
See scripts/costs.py for a full example.
from opf_dataset_utils.costs import (
calculate_costs_per_generator,
calculate_costs_per_grid,
)
costs_per_grid = calculate_costs_per_grid(data, data.y_dict)
costs_per_generator = calculate_costs_per_generator(data, data.y_dict)
Inequality violations
See scripts/inequality_errors.py for a full example.
from opf_dataset_utils.enumerations import EdgeTypes
from opf_dataset_utils.physics.errors.inequality.voltage import calculate_upper_voltage_angle_difference_errors
from opf_dataset_utils.physics.errors.inequality.generator_power import calculate_lower_active_power_errors
upper_voltage_angle_violations_transformer = calculate_upper_voltage_angle_difference_errors(data, data.y_dict, EdgeTypes.TRANSFORMER)
lower_active_power_generation_violations = calculate_lower_active_power_errors(data, data.y_dict)
# etc.
Branch power flows
See scripts/branch_powers.py for a full example.
from opf_dataset_utils.enumerations import EdgeTypes
from opf_dataset_utils.physics.power import calculate_branch_powers
ac_line_powers_from, ac_line_powers_to = calculate_branch_powers(batch, batch.y_dict, EdgeTypes.AC_LINE)
transformer_powers_from, transformer_powers_to = calculate_branch_powers(batch, batch.y_dict, EdgeTypes.TRANSFORMER)
Etc.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
opf_dataset_utils-0.0.1.tar.gz
(12.3 kB
view details)
Built Distribution
File details
Details for the file opf_dataset_utils-0.0.1.tar.gz
.
File metadata
- Download URL: opf_dataset_utils-0.0.1.tar.gz
- Upload date:
- Size: 12.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.11.9 Linux/5.15.153.1-microsoft-standard-WSL2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4eaa35ca035e342c87d1a8205dc192345fc83f8ce8af4ca2517bc1f6fd2631bc |
|
MD5 | af6f67d25e867073cf9782a4ca86a9fd |
|
BLAKE2b-256 | 82083caa4c6506ac00dc8c0ccc5feb55fcc42233aaa8a3ce424870b6e366f28e |
File details
Details for the file opf_dataset_utils-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: opf_dataset_utils-0.0.1-py3-none-any.whl
- Upload date:
- Size: 17.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.11.9 Linux/5.15.153.1-microsoft-standard-WSL2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | afbb67214165adffe21b6eca7d09d2f424cfbc04a6b175146104f275026e4743 |
|
MD5 | 286e10b556973ab49ff5a4335b7f159f |
|
BLAKE2b-256 | def0acdb636e9ded42c014eee5f4850f92d65d787869f89b1a4db7f7d4ebe629 |