Skip to content

About

A full-stack, intelligent power grid monitoring platform, integrating grid2op with Machine learning-based anomaly detection and load prediction. The system enables early warning of potential grid failures and generates standardized anomaly analysis reports.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Project Design & Implementation Document

Demo

Grid.Demo.mp4

1. Project Background & Motivation

With recent events causing Jamaica's power grid to fail for long periods, particularly caused by the worsening weather patterns. My aim was to develop a full-stack, intelligent power grid monitoring and auxiliary decision-making platform. By integrating a power grid simulation framework with machine learning-based anomaly detection and load prediction. The system enables early warning of potential grid failures (line overloads, voltage violations) and generates standardized anomaly analysis reports.

2. System Architecture Design

  • Frontend: A Single Page Application built with Vite + React + TypeScript, responsible for spatial topology visualization and time-series data rendering.
  • API: An asynchronous RESTful API built with FastAPI. FastAPI was chosen for its asynchronous nature which performs well for high-frequency time-series data streams.
  • Simulation & Algorithm: The core physics engine utilizes Grid2Opcombined with a two machine learning models, predicting the value of the highest load in the next 30 mins (~6 steps in Grid2op) and anomaly detection.
  • Database: PostgreSQL + TimeScaleDB for historical time-series data persistence; Open-Meteo API for real-world meteorological boundary conditions.
Architecture

3. Tech Stack

Component Tech Stack
Simulation Grid2Op (l2rpn_neurips_2020_track1_small)
Backend FastAPI + Uvicorn
Frontend React + TypeScript + Leaflet
Database PostgreSQL + TimeScaleDB
Reports WeasyPrint + Jinja2

4. Features

  • Grid Simulation : Using Grid2Op to simulate a realistic power grid.

  • Real-Time Grid Topology : Using the user's location and their countries substation data gathered from earth-osm to recreate the country's ten closest substations to the user to generate a grid topology on react-leaflet, as well as creating a ring-based grid system if the country's data is not found.

  • Anomaly Detection & Highest Load Prediction : Based on features including highest load, the power production for both renewable and non-renewable generators, load drop, rolling mean and standard deviation, the difference between the power generated vs the power used and the active/reactive power consumption. These features were generated from Grid2Op to train a LGBMClassifier to predict anomalies within the grid and a LGBMRegressor to predict the highest load in the system in the next 30 mins (~6 steps in Grid2Op).

  • Top 5 Load Time Series Chart : A time series plot of the top five highest loads in the grid using recharts.

  • Report Generation : Generates a report based on the most recent anomalies.

5. Model Evaluations

Grid Anomaly Classfication Model

classifier_eval
Classification

The dataset held high imbalance, as such a precision-recall curve was the best method to visulalize the performance of the model. The model had strong performance having an average precision of 0.97.

Load Prediction Model

load_eval
1000672300

The model held strong performance in the range of 0.65 rho to 0.90 rho, and began underestimating at >0.90 due to the rarity of these cases from the simulated data. The model made predominant usage of max_rho for predicting the target_rho, but also made use of power production and consumption. The rolling variables had much smaller influence on the prediction. There was only a 1.14% error when predicting, and only ~3.3% of the variation remains unexplained.

Colab used to evaluate model

https://colab.research.google.com/drive/1GGFtfbIZ2igx6gKjMGZXHP8VJ-__kYIm?usp=sharing

Run Locally

Clone the project

  git clone https://github.com/ty-dotcom/Grid-Monitoring-System.git

Download and setup PostgreSQL and TimeScaleDB

https://www.postgresql.org https://timescaledb.org

  1. Copy backend/.env.example to backend/.env:
  cp backend/.env.example backend/.env
  1. Edit your backend/.env and add your PostgreSQL credentials.

  2. Ensure grid_db database exists and TimeScaleDB is installed, afterwhich run

  SELECT create_hypertable('grid_metrics', 'time', chunk_time_interval => INTERVAL '5 mins');

Using separate terminals/IDE

Go to the frontend directory

  cd Grid-Monitoring-System/frontend

Install dependencies

  npm install

Go to the backend directory

  cd Grid-Monitoring-System/backend

Install python requirements

  pip install -r requirements-dev.txt

Otherwise run python code using an IDE. Start the Backend server (Using Command Line).

  python main.py

Start the Client server

  npm run start

About

A full-stack, intelligent power grid monitoring platform, integrating grid2op with Machine learning-based anomaly detection and load prediction. The system enables early warning of potential grid failures and generates standardized anomaly analysis reports.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages