Skip to content

This repo contains some basic power system operations written in Python and formulated by cvxpy.

Notifications You must be signed in to change notification settings

xuwkk/power_system_operation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Power System Operation in Python

We are still at the early stage of the implementation. There will be more functionalities and flexible I/Os coming in the future. Please watch us progress to have the latest update.

Introduction

The main purpose of this repository is to

  1. Provide an efficient I/O for generating the power system testbed for optimization problem.
  2. Host a set of basic power system operation formulations for the future research and teaching purposes.
  3. The package also comes with an efficient modifications of the load, solar, and wind data that are suitable for the proposed power system case study. Therefore, it can be used to train machine and deep learning models with large training dataset.

Package Dependencies

cvxpy: is an open source Python-embedded modeling language for convex optimization problems. It lets you express your problem in a natural and matrix way that follows the math, rather than in the restrictive standard form required by different solvers.

Note: you may also need to have Gurobi, Mosek or other optimization software to efficiently solve the optimization problems, especially if integers are included. Please refer here for details.

PyPower: is a power flow and Optimal Power Flow (OPF) solver. It also hosts a set of commonly used power system testbeds. It is a part of MATPOWER to the Python programming language.

Other packages inlcudes

openpyxl, XlsxWriter

for efficient I/O of the .xlsx files.

References

The implementation of this repo follows the online cource here and the textbook Power System Operations here, both by Prof. Antonio Conejo. We also write a series of blog posts to explain the formulation used in the code, including:

Power System Operation

This repo contains some basic power system operations written in Python and formulated by cvxpy, such as:

  • Network Constrained Unit Commitment (with/out integer variables, and various tim e steps) (finished)
  • Economic Dispatch (finished)
  • Stochastic Unit Commitment (ongoing)

Data Generation

Note: the data generation is not necessary for power system operation. You can consider use this part to generate dataset for training machine learning models, such as load, solar, and wind forecasting.

Step one: Clean Raw Data

We use open source dataset from A Synthetic Texas Backbone Power System with Climate-Dependent Spatio-Temporal Correlated Profiles. You can download/read the descriptions of the dataset from the official webpage.

Please cite/recogenize the original authors if you use the dataset.

After download the the .zip file into the data/ and change the name into raw_data.zip, unzip the file by

unzip data/raw_data.zip -d data/

This will give a new folder data/Data_public/.

Then we need to group the feature-label pairs for each data (bus). There are 123 buses in the Texas backbone power system. To group the data, run

python data/group_data.py

Note: This may take several minutes but you only need to run this script once.

Step two: Generate Power Grid Case

The optimization formulation replies on reading system configuration from a .xlsx file. There are several ways to construct the configuration file, either from scratch or build it from existing configurations via the PyPower package. An example file can be found here.

We recommend to construct the .xlsx file from the basic PyPower file to avoid errors. The PyPower contains useful grid topology and parameters that can be directly read by the package. However, you must include several necessary extra configs (that are not covered by the PyPower) to support the full functionality of power system operation. For example, you need to specifiy the up and down cost and limit of the generators to formulate the UC. An example can be found here. The detailed description on how to construct the extra config file can be found here.

For instance, to generate the case14, run

no_load, no_solar, no_wind = from_pypower('case14', 'configs/case14_default.json')

The function from_pypower will generate the case14.xlsx file in the configs/ folder. It will also rescale the default load, solar, and wind data to the defined power_ratio in the config file.

Step Three: Assign and Rescale the Data to Load

The next step is to assign the grouped data to the buses defined in the configuration file. First, the grouped data will be first assigned to the solar or wind buses. Then, the remaining bus will be assigned with the remaining grouped data. The solar, wind, and load will be rescaled into their default values.

A new folder will be constructed with the modified grouped data in the sequence of the load.

Test Files

The package comes with several ready-to-use test files in test/. You can learn most of the operations by reading the test files.

Comments

This dataset and power system optimization toolbox has been used in our previous paper:

  1. E2E-AT: A Unified Framework for Tackling Uncertainty in Task-Aware End-to-End Learning
  2. Task-aware machine unlearning and its application in load forecasting

About

This repo contains some basic power system operations written in Python and formulated by cvxpy.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages