Skip to content

ALZ-11/campus-energy-optimization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rooftop Solar PV Microgrid Sizing & ML Yield Forecasting

This repository contains a feasibility study and machine learning forecasting pipeline initiated in late 2023 to model the future rooftop solar photovoltaic (PV) microgrid at the École Centrale Casablanca campus in Bouskoura, Morocco (coordinates: 33.4806° N, -7.6183° W).

The study models the grid's performance for the target operational year of 2025 by establishing a realistic physical system layout through standard flat-roof geometric spacing and thermodynamic thermal-loss constraints. It trains an XGBoost model on real-world PV SCADA telemetry to emulate hardware performance, and transposes those learned physical relationships to Casablanca’s actual weather to generate accurate, loss-adjusted generation forecasts.


Project Deliverables


1. Project Context & Objectives

In 2023, it was estimated that the university campus consumes $1,546,749\text{ kWh/year}$. Following a facilities and residential expansion plan, the annual demand was projected to rise to $2,162,213\text{ kWh/year}$. This study evaluates the maximum feasible on-site rooftop PV generation potential across 35 residential pavilions, the main Pedagogical Buildings, and the Galilée Building to offset the campus's rising utility costs and carbon footprint.


2. Physical System Sizing & Layout

In order to resolve the physical limitations of rooftop arrays, we implemented standard flat-roof layout constraints:

  • 50% Spacing Rule: Flat roofs require tilted panels (fixed at $30^\circ$ South-facing to optimize winter generation). To prevent tilted rows from casting shadows on one another, a flat-roof utilization factor of $50%$ was applied.
  • System Sizing Breakdown:
    • 35 Pavilions: $35 \times 70\text{ m}^2 \text{ roof area} = 2,450\text{ m}^2$
    • Pedagogical Buildings: $7,000\text{ m}^2 \text{ roof area}$
    • Galilée Building: $800\text{ m}^2 \text{ roof area}$
    • Total Usable Roof Area: $10,250\text{ m}^2 \times 0.50 = \mathbf{5,125\text{ m}^2}$
  • Module Selection: Tesla Solar Plasma TS545PR ($545\text{ Wp}$, Mono PERC, $2.58\text{ m}^2$ per panel)
  • Total Physical Capacity: $$\text{Total Modules} = \frac{5,125\text{ m}^2}{2.58\text{ m}^2} \approx 1,986\text{ panels}$$ $$\text{Total Capacity} = 1,986 \text{ panels} \times 0.545\text{ kWp} = \mathbf{1,082.37\text{ kWp}}$$

3. ML Pipeline

Our forecasting model was trained on a real-world PV SCADA database (Rostamipour & Ghayeni 2026) consisting of 90 days of continuous 30-minute inverter telemetry and collocated weather station readings.

Data Processing Steps:

  1. Temperature Unit Mismatch: logging mismatches were found where one weather station switched outputs from Celsius to Fahrenheit ($^\circ\text{F}$), creating outliers. These were isolated and corrected to Celsius.
  2. Electrical Scaling Glitches: Some inverters logged DC power in Watts instead of Kilowatts, creating impossible power spikes. These were normalized back to Kilowatts.
  3. Inverter Efficiency Correlation Audit: A correlation audit proved that logged inverter efficiency was independent of all physical parameters ($r < 0.02$), behaving as a static constant ($96.99% \pm 0.86%$). We treated efficiency as a fixed system parameter ($97%$) and excluded it from the ML pipeline to prevent overfitting on random sensor noise.
  4. Temporal Split: To prevent data leakage, we sorted the dataset chronologically and split it: the first $80%$ of the timeline (spring) for training ($14,332$ rows) and the remaining $20%$ (early summer) for testing ($3,583$ rows).
  5. Solar Geometry Features: Added solar zenith angles (computed via pvlib) and direct/diffuse irradiance splits to allow the model to understand the sun's trajectory relative to the tilted panels.
  6. Inverter One-Hot Encoding: Handled a systematic $24.8%$ output discrepancy between the 8 physical string inverters across the solar field by one-hot encoding the inverter IDs.

Comparative Model Performance (On Unseen Test Set):

Both machine learning models were evaluated on the chronologically unseen test set:

Model Architecture R-squared ($R^2$) MAE (kW) RMSE (kW)
Random Forest $0.6802$ $15.0533\text{ kW}$ $21.0272\text{ kW}$
XGBoost (Our Model) $0.6903$ $14.6817\text{ kW}$ $20.6905\text{ kW}$

4. Transposition to Bouskoura, Morocco

Using the NASA POWER API, we retrieved a complete, hourly weather dataset for Bouskoura for the year 2025 ($8,760$ hours).

  • Cleaning Sentinel Values: We audited the raw NASA dataset, located 24 corrupted hourly irradiance readings logged as the sentinel -999.0, and resolved them using linear time-series interpolation.
  • Zenith Calculations: We used pvlib to calculate the solar zenith angle for every hour of 2025 based on the campus coordinates.
  • Daytime Prediction Constraint: To prevent training errors, we filtered the Bouskoura dataset to isolate the $4,015$ active daytime hours (GHI > 50 W/m²). We scaled and predicted only on these daytime hours, and then reconstructed the full 8,760-hour calendar year by mapping the predictions back into a timeline of zeros (representing nighttime).
  • System Sizing Scaling: Since our XGBoost model was trained on a single $170\text{ kW}$ SCADA inverter system, we scaled the predictions to match the proposed $1,082.37\text{ kWp}$ campus array: $$\text{Campus Power (kW)} = \frac{\text{Predicted Power (kW)}}{170.0} \times 1,082.37$$

5. Sizing & Generation Findings

The transposed machine learning model predicts a realistic, thermally degraded annual energy output of $1,411,959.07\text{ kWh/year}$ (approx. $1.41\text{ GWh/year}$).

A. Expected Sizing Range (With a $\pm6%$ Margin): $$\text{Expected Annual Generation} = \mathbf{1,327,228\text{ to } 1,496,660\text{ kWh/year}}$$

This corresponds to a realistic system yield of $1,304.51\text{ kWh/kWp/year}$.

B. Campus Demand Coverage:

  • Current Demand Coverage: This system covers $91.28%$ of the school's 2023 annual consumption ($1,546,749\text{ kWh}$).
  • Future Demand Coverage: This system covers $65.30%$ of the school's projected annual consumption ($2,162,213\text{ kWh}$).

C. Monthly Generation Profile:

Model-Predicted Monthly Generation (2025):
January    :  86,790.26 kWh
February   :  87,618.63 kWh
March      : 111,497.59 kWh
April      : 120,230.19 kWh
May        : 146,647.90 kWh
June       : 149,063.21 kWh
July       : 158,681.13 kWh (Summer Solstice Peak)
August     : 152,824.90 kWh
September  : 130,890.91 kWh
October    : 109,158.59 kWh
November   :  88,469.24 kWh
December   :  70,086.52 kWh (Winter Solstice Trough)

6. Symmetrical Reproduction Steps

To execute the data pipeline and reproduce the predictions:

  1. Clone this repository:
    git clone https://github.com/ALZ-11/campus-energy-optimization
    cd campus-energy-optimization
  2. Install all dependencies:
    pip install -r requirements.txt
  3. Place the Raw SCADA Files: Download the raw files from the Mendeley Data Repository and place them as:
    • data/raw/Inverter SCADA.csv
    • data/raw/Meteorological data.csv
  4. Run the Notebook: Open and execute all cells in notebooks/campus-energy-optimization.ipynb. The notebook will automatically clean the SCADA data, train the XGBoost model, query the live NASA POWER API for Bouskoura's 2025 weather, and generate the final monthly yield forecasts.

About

Feasibility study and machine learning forecasting pipeline (XGBoost) for a 1.08 MWp rooftop solar PV microgrid at École Centrale Casablanca. Integrates live NASA POWER meteorology and physical flat-roof spacing constraints.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors