Skip to content

Real-time grid digital twin for Germany's energy transition. Features <50ms physics loop, VDE-AR-N 4110 compliance validation, Monte Carlo robustness testing (n=50 AR(1) uncertainty), and production-ready CI/CD architecture.

License

Notifications You must be signed in to change notification settings

omari91/berlin-grid-project

Repository files navigation

Berlin Grid Real-Time Simulation Framework A Scalable Architecture for Probabilistic Edge Control

Author: Clifford Ondieki
Purpose: Demonstrate scalable real-time edge control (Redispatch 3.0) and grid hosting-capacity analytics using real German grid data.
Compliant targets: VDE-AR-N 4110, §14a EnWG.

🚀 Key Features

This repository implements a streaming digital twin with real-time validation:

Core Capabilities

  • Real-Time Streaming Architecture – Streaming microkernel with <10 µs P99 Jitter, enabling deterministic control for hard real-time requirements.
  • Hardware Benchmarking – High-throughput vectorization sustained at ~30 Million ops/sec on standard x86 hardware.
  • Convergent Control Logic – Ablation study proving the Fuzzy Logic controller converges to 97% of optimal efficiency under heavy congestion while eliminating binary oscillation.
  • Physics-Integrated Stochasticity – Monte Carlo simulations (n=50) propagating AR(1) correlated uncertainty through the AC Power Flow solver to verify voltage stability.
  • Data-Agnostic Design – Decoupled architecture robust to topological scope mismatches.

Technical Stack

  • Typed Python modules with Pydantic data models
  • Pandapower for AC network simulation (Warm-Start Newton-Raphson)
  • Fuzzy (sigmoid) smoothing control algorithm
  • CI/CD pipeline (pytest, mypy, Docker)
  • Comprehensive documentation (METHODOLOGY.md)

⏱️ Real-Time Performance

The StreamingDigitalTwin class validates edge-readiness via tick-by-tick simulation:

# Measured on x86_64 Linux (Single Core)
Avg Latency: 4.35 µs
P99 Jitter:  9.94 µs (Deterministic)
Throughput:  ~230,000 Ops/Sec (Streaming Mode)

Conclusion: The architecture exceeds 50Hz grid cycle requirements (<20ms) by three orders of magnitude, making it deployment-ready for ARM gateways (e.g., Raspberry Pi).


📈 Controller Convergence (Ablation Study)

A sensitivity sweep compares the Fuzzy Logic controller against a standard Hard Cutoff baseline across congestion severities.

Scenario Limit Behavior Efficiency Gap
Light Congestion 28.0 MW Proactive: Dampens voltage ripple +550 MWh (Stability Premium)
Heavy Congestion 22.0 MW Convergent: Enforces physical limits +34.5 MWh (3% Gap)

Key Insight: In deep congestion, the Fuzzy Controller automatically tightens to achieve 97% of the theoretical optimal efficiency of a binary relay, while retaining the benefits of smooth, differentiable control action.


⚡ Multi-Constraint Validation

Pandapower AC power flow runs continuously in the loop to verify constraints:

Solver: Newton-Raphson (Warm-Start Optimized)
✓ Voltage Stability: Monitored continuously (0.90–1.10 p.u.)
✓ Thermal Loading: Transformers and lines checked dynamically at every tick.
✓ Stability: Smooth control response verified under dynamic load conditions.

Note: Initial validation against open-source upstream telemetry revealed a topological scope mismatch ($\rho &lt; 0.37$). Consequently, this framework focuses on architectural robustness and internal consistency rather than calibrating to mismatched open datasets.


🎲 Stochastic Robustness

Monte Carlo simulation (n=50) with documented uncertainty models:

  • PV Generation Error: Auto-Regressive AR(1) with high persistence ($\phi=0.95$).
  • EV Charging Variability: Random arrival ($\phi=0.10$) for stochastic plug-in times.
  • Result: Voltage confidence intervals (95% CI) remain bounded within safety margins despite correlated perturbations.

Quick Start

  1. Clone repository:
git clone [https://github.com/omari91/berlin-grid-project.git](https://github.com/omari91/berlin-grid-project.git)
cd berlin-grid-project
  1. Create virtual environment & install:
python3 -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate
pip install -r requirements.txt
  1. Add data: Create a data/ folder and add the required Energienetze Berlin CSVs (file names specified in main.py).

  2. Run simulation:

python main.py
  1. Run tests:
pytest -q

Project Structure

berlin-grid-project/
├── data/                   # (excluded from repo) raw CSVs
├── docs/                   # mkdocs documentation
├── output/                 # generated graphs & artifacts
├── src/                    # typed source modules
├── tests/                  # pytest tests
├── .github/workflows/      # CI/CD pipeline
├── Dockerfile
├── METHODOLOGY.md          # Academic methodology (6 sections)
├── PORTFOLIO.md            # Portfolio highlights
├── requirements.txt
├── requirements-dev.txt
├── main.py                 # Golden master (working analysis)
├── mkdocs.yml
└── README.md

Note: The root main.py contains the validated analysis script with all features described above. The src/ directory provides a refactored, enterprise-grade modular version with CI/CD.


📚 Documentation

  • METHODOLOGY.md – Complete engineering methodology aligned with ISO/IEC Digital Twin standards
  • PORTFOLIO.md – Recruiter-friendly project highlights
  • docs/ – MkDocs technical documentation

🛠️ Skills Demonstrated

  • Programming: Python (pandas, numpy, pandapower, matplotlib, seaborn)
  • Power Systems Engineering: Grid resilience, voltage stability, Redispatch 3.0, §14a EnWG
  • Real-Time Systems: Streaming data processing, latency optimization, edge computing
  • Software Engineering: Testing (pytest), CI/CD (GitHub Actions), Containerization (Docker)
  • Stochastic Modeling: Monte Carlo simulation, uncertainty quantification
  • German Energy Regulations: EnWG §14a, VDE-AR-N 4110

Licensing

MIT License recommended.


Contact

Clifford Ondieki
📧 [email protected]
🎓 M.Sc. Electrical Engineering (graduating 2026)
🔗 LinkedIn | GitHub www.cliffordomari.com

About

Real-time grid digital twin for Germany's energy transition. Features <50ms physics loop, VDE-AR-N 4110 compliance validation, Monte Carlo robustness testing (n=50 AR(1) uncertainty), and production-ready CI/CD architecture.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published