gridos 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gridos-0.1.0/CHANGELOG.md +30 -0
- gridos-0.1.0/CONTRIBUTING.md +106 -0
- gridos-0.1.0/LICENSE +21 -0
- gridos-0.1.0/MANIFEST.in +16 -0
- gridos-0.1.0/PKG-INFO +270 -0
- gridos-0.1.0/README.md +211 -0
- gridos-0.1.0/data/sample_load_profile.csv +34 -0
- gridos-0.1.0/data/sample_solar_irradiance.csv +34 -0
- gridos-0.1.0/pyproject.toml +110 -0
- gridos-0.1.0/requirements/base.txt +18 -0
- gridos-0.1.0/requirements/dev.txt +11 -0
- gridos-0.1.0/requirements/ml.txt +7 -0
- gridos-0.1.0/requirements/prod.txt +5 -0
- gridos-0.1.0/setup.cfg +4 -0
- gridos-0.1.0/src/gridos/__init__.py +10 -0
- gridos-0.1.0/src/gridos/adapters/__init__.py +12 -0
- gridos-0.1.0/src/gridos/adapters/base.py +116 -0
- gridos-0.1.0/src/gridos/adapters/dnp3.py +97 -0
- gridos-0.1.0/src/gridos/adapters/iec61850.py +99 -0
- gridos-0.1.0/src/gridos/adapters/modbus.py +177 -0
- gridos-0.1.0/src/gridos/adapters/mqtt.py +178 -0
- gridos-0.1.0/src/gridos/adapters/opcua.py +139 -0
- gridos-0.1.0/src/gridos/api/__init__.py +6 -0
- gridos-0.1.0/src/gridos/api/dependencies.py +101 -0
- gridos-0.1.0/src/gridos/api/routes/__init__.py +3 -0
- gridos-0.1.0/src/gridos/api/routes/control.py +68 -0
- gridos-0.1.0/src/gridos/api/routes/devices.py +85 -0
- gridos-0.1.0/src/gridos/api/routes/forecast.py +77 -0
- gridos-0.1.0/src/gridos/api/routes/optimization.py +126 -0
- gridos-0.1.0/src/gridos/api/routes/telemetry.py +122 -0
- gridos-0.1.0/src/gridos/api/websocket_manager.py +120 -0
- gridos-0.1.0/src/gridos/config.py +170 -0
- gridos-0.1.0/src/gridos/digital_twin/__init__.py +10 -0
- gridos-0.1.0/src/gridos/digital_twin/engine.py +353 -0
- gridos-0.1.0/src/gridos/digital_twin/ml/__init__.py +11 -0
- gridos-0.1.0/src/gridos/digital_twin/ml/anomaly_detector.py +187 -0
- gridos-0.1.0/src/gridos/digital_twin/ml/forecaster.py +332 -0
- gridos-0.1.0/src/gridos/digital_twin/ml/trainer.py +190 -0
- gridos-0.1.0/src/gridos/digital_twin/models/__init__.py +25 -0
- gridos-0.1.0/src/gridos/digital_twin/models/battery.py +121 -0
- gridos-0.1.0/src/gridos/digital_twin/models/bus.py +80 -0
- gridos-0.1.0/src/gridos/digital_twin/models/ev_charger.py +136 -0
- gridos-0.1.0/src/gridos/digital_twin/models/line.py +107 -0
- gridos-0.1.0/src/gridos/digital_twin/models/load.py +94 -0
- gridos-0.1.0/src/gridos/digital_twin/models/pv.py +104 -0
- gridos-0.1.0/src/gridos/digital_twin/models/transformer.py +106 -0
- gridos-0.1.0/src/gridos/edge/__init__.py +6 -0
- gridos-0.1.0/src/gridos/edge/local_cache.py +234 -0
- gridos-0.1.0/src/gridos/edge/sync.py +114 -0
- gridos-0.1.0/src/gridos/main.py +130 -0
- gridos-0.1.0/src/gridos/models/__init__.py +30 -0
- gridos-0.1.0/src/gridos/models/common.py +318 -0
- gridos-0.1.0/src/gridos/models/iec61850.py +200 -0
- gridos-0.1.0/src/gridos/optimization/__init__.py +10 -0
- gridos-0.1.0/src/gridos/optimization/dispatch.py +149 -0
- gridos-0.1.0/src/gridos/optimization/scheduler.py +315 -0
- gridos-0.1.0/src/gridos/security/__init__.py +6 -0
- gridos-0.1.0/src/gridos/security/auth.py +222 -0
- gridos-0.1.0/src/gridos/storage/__init__.py +10 -0
- gridos-0.1.0/src/gridos/storage/base.py +127 -0
- gridos-0.1.0/src/gridos/storage/influxdb.py +201 -0
- gridos-0.1.0/src/gridos/storage/timescaledb.py +221 -0
- gridos-0.1.0/src/gridos/utils/__init__.py +5 -0
- gridos-0.1.0/src/gridos/utils/helpers.py +149 -0
- gridos-0.1.0/src/gridos/utils/logging.py +117 -0
- gridos-0.1.0/src/gridos/utils/metrics.py +176 -0
- gridos-0.1.0/src/gridos.egg-info/PKG-INFO +270 -0
- gridos-0.1.0/src/gridos.egg-info/SOURCES.txt +69 -0
- gridos-0.1.0/src/gridos.egg-info/dependency_links.txt +1 -0
- gridos-0.1.0/src/gridos.egg-info/requires.txt +36 -0
- gridos-0.1.0/src/gridos.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to GridOS will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [0.1.0] - 2025-03-06
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- **Core Models**: Pydantic v2 data models for DER telemetry, device info, and control commands
|
|
12
|
+
- **Protocol Adapters**: Base adapter framework with Modbus TCP, MQTT, DNP3, IEC 61850, and OPC-UA implementations
|
|
13
|
+
- **Storage Backends**: InfluxDB 2.x and TimescaleDB storage backends with async interfaces
|
|
14
|
+
- **Digital Twin Engine**: Physics-based models for Bus, Line, Transformer, Load, PV, Battery, and EV Charger
|
|
15
|
+
- **Power Flow Solver**: Simplified backward/forward sweep for radial distribution networks
|
|
16
|
+
- **ML Forecasting**: LSTM-based time-series forecaster with PyTorch (persistence fallback)
|
|
17
|
+
- **Anomaly Detection**: Isolation Forest detector with scikit-learn (threshold fallback)
|
|
18
|
+
- **MILP Optimiser**: PuLP-based energy management scheduler with greedy heuristic fallback
|
|
19
|
+
- **Real-time Dispatch**: Schedule-to-device dispatch engine via adapter layer
|
|
20
|
+
- **REST API**: FastAPI-based API with device, telemetry, control, forecast, and optimisation endpoints
|
|
21
|
+
- **WebSocket**: Live telemetry streaming with per-device subscriptions
|
|
22
|
+
- **Edge Support**: SQLite store-and-forward cache with cloud sync
|
|
23
|
+
- **Security**: API key and JWT authentication with role-based access control
|
|
24
|
+
- **Utilities**: Structured JSON logging, Prometheus metrics, helper functions
|
|
25
|
+
- **Docker**: Multi-stage Dockerfile and Docker Compose with InfluxDB
|
|
26
|
+
- **Kubernetes**: Deployment manifests with HPA auto-scaling
|
|
27
|
+
- **CI/CD**: GitHub Actions workflows for linting, testing, security scanning, and Docker builds
|
|
28
|
+
- **Documentation**: Architecture guide, API reference, deployment guide
|
|
29
|
+
- **Sample Data**: Load profile and solar irradiance CSV datasets
|
|
30
|
+
- **Quick Start**: Demo script showcasing all major features
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Contributing to GridOS
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to GridOS! This document provides guidelines and instructions for contributing to the project.
|
|
4
|
+
|
|
5
|
+
## Code of Conduct
|
|
6
|
+
|
|
7
|
+
By participating in this project, you agree to abide by our [Code of Conduct](CODE_OF_CONDUCT.md).
|
|
8
|
+
|
|
9
|
+
## How to Contribute
|
|
10
|
+
|
|
11
|
+
### Reporting Issues
|
|
12
|
+
|
|
13
|
+
- Use [GitHub Issues](https://github.com/your-org/GridOS/issues) to report bugs or request features
|
|
14
|
+
- Search existing issues before creating a new one
|
|
15
|
+
- Include steps to reproduce, expected behaviour, and actual behaviour for bugs
|
|
16
|
+
- Include your environment details (OS, Python version, GridOS version)
|
|
17
|
+
|
|
18
|
+
### Submitting Changes
|
|
19
|
+
|
|
20
|
+
1. **Fork** the repository
|
|
21
|
+
2. **Create a branch** from `develop`:
|
|
22
|
+
```bash
|
|
23
|
+
git checkout -b feature/your-feature-name develop
|
|
24
|
+
```
|
|
25
|
+
3. **Make your changes** following the coding standards below
|
|
26
|
+
4. **Write tests** for new functionality
|
|
27
|
+
5. **Run the test suite**:
|
|
28
|
+
```bash
|
|
29
|
+
pytest tests/ -v --cov=gridos
|
|
30
|
+
```
|
|
31
|
+
6. **Run linting**:
|
|
32
|
+
```bash
|
|
33
|
+
ruff check src/ tests/
|
|
34
|
+
ruff format src/ tests/
|
|
35
|
+
```
|
|
36
|
+
7. **Commit** with a clear message:
|
|
37
|
+
```bash
|
|
38
|
+
git commit -m "feat: add support for SunSpec protocol adapter"
|
|
39
|
+
```
|
|
40
|
+
8. **Push** and create a **Pull Request** against `develop`
|
|
41
|
+
|
|
42
|
+
### Commit Message Format
|
|
43
|
+
|
|
44
|
+
We follow [Conventional Commits](https://www.conventionalcommits.org/):
|
|
45
|
+
|
|
46
|
+
| Prefix | Description |
|
|
47
|
+
|--------|-------------|
|
|
48
|
+
| `feat:` | New feature |
|
|
49
|
+
| `fix:` | Bug fix |
|
|
50
|
+
| `docs:` | Documentation changes |
|
|
51
|
+
| `test:` | Adding or updating tests |
|
|
52
|
+
| `refactor:` | Code refactoring |
|
|
53
|
+
| `perf:` | Performance improvement |
|
|
54
|
+
| `ci:` | CI/CD changes |
|
|
55
|
+
| `chore:` | Maintenance tasks |
|
|
56
|
+
|
|
57
|
+
### Coding Standards
|
|
58
|
+
|
|
59
|
+
- **Python 3.10+** with type hints on all public functions
|
|
60
|
+
- **Pydantic v2** for data models
|
|
61
|
+
- **async/await** for all I/O operations
|
|
62
|
+
- **Ruff** for linting and formatting
|
|
63
|
+
- **pytest** for testing with >80% coverage target
|
|
64
|
+
- **Docstrings** in NumPy style for all public classes and functions
|
|
65
|
+
- **Logging** via `logging.getLogger(__name__)` — no `print()` statements
|
|
66
|
+
|
|
67
|
+
### Adding a New Protocol Adapter
|
|
68
|
+
|
|
69
|
+
1. Create `src/gridos/adapters/your_protocol.py`
|
|
70
|
+
2. Inherit from `BaseAdapter`
|
|
71
|
+
3. Implement `connect()`, `disconnect()`, `read_telemetry()`, `write_command()`
|
|
72
|
+
4. Add tests in `tests/test_adapters.py`
|
|
73
|
+
5. Update `src/gridos/adapters/__init__.py`
|
|
74
|
+
6. Document in `docs/architecture.md`
|
|
75
|
+
|
|
76
|
+
### Adding a New Physics Model
|
|
77
|
+
|
|
78
|
+
1. Create `src/gridos/digital_twin/models/your_component.py`
|
|
79
|
+
2. Implement `update(dt, grid_state)` method
|
|
80
|
+
3. Register in `GridModel` class
|
|
81
|
+
4. Add tests in `tests/test_digital_twin.py`
|
|
82
|
+
|
|
83
|
+
## Development Setup
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Clone your fork
|
|
87
|
+
git clone https://github.com/your-username/GridOS.git
|
|
88
|
+
cd GridOS
|
|
89
|
+
|
|
90
|
+
# Create virtual environment
|
|
91
|
+
python -m venv .venv
|
|
92
|
+
source .venv/bin/activate
|
|
93
|
+
|
|
94
|
+
# Install in development mode
|
|
95
|
+
pip install -e ".[dev]"
|
|
96
|
+
|
|
97
|
+
# Run tests
|
|
98
|
+
pytest tests/ -v
|
|
99
|
+
|
|
100
|
+
# Run linting
|
|
101
|
+
ruff check src/ tests/
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Questions?
|
|
105
|
+
|
|
106
|
+
Open a [Discussion](https://github.com/your-org/GridOS/discussions) or reach out to the maintainers.
|
gridos-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 GridOS Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
gridos-0.1.0/MANIFEST.in
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
include LICENSE
|
|
2
|
+
include README.md
|
|
3
|
+
include CHANGELOG.md
|
|
4
|
+
include CONTRIBUTING.md
|
|
5
|
+
include pyproject.toml
|
|
6
|
+
include requirements/*.txt
|
|
7
|
+
|
|
8
|
+
recursive-include src/gridos *.py *.pyi
|
|
9
|
+
recursive-include data *.csv *.json
|
|
10
|
+
|
|
11
|
+
prune tests
|
|
12
|
+
prune notebooks
|
|
13
|
+
prune k8s
|
|
14
|
+
prune docker
|
|
15
|
+
prune scripts
|
|
16
|
+
prune .github
|
gridos-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gridos
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: GridOS — Open Energy Operating System: vendor-neutral middleware for Distributed Energy Resources.
|
|
5
|
+
Author: GridOS Contributors
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/iceccarelli/GridOS
|
|
8
|
+
Project-URL: Documentation, https://github.com/iceccarelli/GridOS/tree/main/docs
|
|
9
|
+
Project-URL: Repository, https://github.com/iceccarelli/GridOS
|
|
10
|
+
Project-URL: Issues, https://github.com/iceccarelli/GridOS/issues
|
|
11
|
+
Project-URL: Changelog, https://github.com/iceccarelli/GridOS/blob/main/CHANGELOG.md
|
|
12
|
+
Keywords: energy,smart-grid,DER,digital-twin,microgrid,SCADA,IoT,IEC61850,Modbus,MQTT
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: fastapi>=0.110.0
|
|
27
|
+
Requires-Dist: uvicorn[standard]>=0.27.0
|
|
28
|
+
Requires-Dist: pydantic>=2.6.0
|
|
29
|
+
Requires-Dist: pydantic-settings>=2.1.0
|
|
30
|
+
Requires-Dist: httpx>=0.27.0
|
|
31
|
+
Requires-Dist: structlog>=24.1.0
|
|
32
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
33
|
+
Requires-Dist: numpy>=1.26.0
|
|
34
|
+
Requires-Dist: pandas>=2.2.0
|
|
35
|
+
Requires-Dist: pyyaml>=6.0
|
|
36
|
+
Provides-Extra: ml
|
|
37
|
+
Requires-Dist: scikit-learn>=1.4.0; extra == "ml"
|
|
38
|
+
Requires-Dist: torch>=2.2.0; extra == "ml"
|
|
39
|
+
Requires-Dist: pulp>=2.8.0; extra == "ml"
|
|
40
|
+
Requires-Dist: matplotlib>=3.8.0; extra == "ml"
|
|
41
|
+
Requires-Dist: joblib>=1.3.0; extra == "ml"
|
|
42
|
+
Provides-Extra: adapters
|
|
43
|
+
Requires-Dist: pymodbus>=3.6.0; extra == "adapters"
|
|
44
|
+
Requires-Dist: paho-mqtt>=2.0.0; extra == "adapters"
|
|
45
|
+
Requires-Dist: asyncua>=1.1.0; extra == "adapters"
|
|
46
|
+
Provides-Extra: storage
|
|
47
|
+
Requires-Dist: influxdb-client[async]>=1.40.0; extra == "storage"
|
|
48
|
+
Requires-Dist: asyncpg>=0.29.0; extra == "storage"
|
|
49
|
+
Provides-Extra: dev
|
|
50
|
+
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
51
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
|
|
52
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
|
|
53
|
+
Requires-Dist: black>=24.1.0; extra == "dev"
|
|
54
|
+
Requires-Dist: ruff>=0.2.0; extra == "dev"
|
|
55
|
+
Requires-Dist: mypy>=1.8.0; extra == "dev"
|
|
56
|
+
Requires-Dist: pre-commit>=3.6.0; extra == "dev"
|
|
57
|
+
Requires-Dist: jupyter>=1.0.0; extra == "dev"
|
|
58
|
+
Dynamic: license-file
|
|
59
|
+
|
|
60
|
+
# GridOS — Open Energy Operating System
|
|
61
|
+
|
|
62
|
+
[](LICENSE)
|
|
63
|
+
[](https://www.python.org/downloads/)
|
|
64
|
+
[](https://pypi.org/project/gridos/)
|
|
65
|
+
[](https://pypi.org/project/gridos/)
|
|
66
|
+
[](https://github.com/iceccarelli/GridOS/pkgs/container/gridos)
|
|
67
|
+
[](https://github.com/iceccarelli/GridOS/actions/workflows/ci.yml)
|
|
68
|
+
[](https://fastapi.tiangolo.com/)
|
|
69
|
+
[](https://github.com/astral-sh/ruff)
|
|
70
|
+
|
|
71
|
+
**GridOS** is a vendor-neutral, open-source middleware platform that unifies **Distributed Energy Resources (DERs)** — solar inverters, batteries, EV chargers, smart loads — behind a single, standards-based API. It provides real-time telemetry ingestion, digital-twin simulation, ML-driven forecasting, and optimal energy dispatch, enabling utilities, aggregators, and microgrid operators to accelerate the energy transition.
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Key Features
|
|
76
|
+
|
|
77
|
+
| Capability | Description |
|
|
78
|
+
|---|---|
|
|
79
|
+
| **Multi-Protocol Adapters** | Modbus TCP/RTU, MQTT, DNP3, IEC 61850, OPC-UA — connect any DER out of the box. |
|
|
80
|
+
| **Common Information Model** | Pydantic models aligned with IEC 61968/61850 for interoperable data exchange. |
|
|
81
|
+
| **Time-Series Storage** | Pluggable backends for InfluxDB 2.x and TimescaleDB with async I/O. |
|
|
82
|
+
| **Digital Twin Engine** | Physics-based component models (bus, line, transformer, PV, battery, EV charger) with simplified power-flow simulation. |
|
|
83
|
+
| **ML Forecasting** | LSTM-based load and solar forecasting plus Isolation Forest anomaly detection. |
|
|
84
|
+
| **MILP Optimization** | Mixed-Integer Linear Programming scheduler for optimal battery dispatch and demand response. |
|
|
85
|
+
| **REST + WebSocket API** | FastAPI-powered endpoints with live telemetry streaming via WebSockets. |
|
|
86
|
+
| **Edge Support** | SQLite-based store-and-forward cache for intermittent connectivity. |
|
|
87
|
+
| **Cloud-Native Deployment** | Docker Compose, Kubernetes manifests, and GitHub Actions CI/CD included. |
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Architecture Overview
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
┌──────────────────────────────────────────────────────────┐
|
|
95
|
+
│ GridOS Platform │
|
|
96
|
+
│ │
|
|
97
|
+
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌─────────┐ │
|
|
98
|
+
│ │ Modbus │ │ MQTT │ │ DNP3 │ │ IEC61850│ │
|
|
99
|
+
│ │ Adapter │ │ Adapter │ │ Adapter │ │ Adapter │ │
|
|
100
|
+
│ └────┬─────┘ └────┬─────┘ └────┬─────┘ └────┬────┘ │
|
|
101
|
+
│ │ │ │ │ │
|
|
102
|
+
│ └──────────────┼──────────────┼──────────────┘ │
|
|
103
|
+
│ ▼ │
|
|
104
|
+
│ ┌───────────────┐ │
|
|
105
|
+
│ │ CIM Models │ │
|
|
106
|
+
│ │ (Pydantic) │ │
|
|
107
|
+
│ └───────┬───────┘ │
|
|
108
|
+
│ │ │
|
|
109
|
+
│ ┌────────────┼────────────┐ │
|
|
110
|
+
│ ▼ ▼ ▼ │
|
|
111
|
+
│ ┌────────────┐ ┌──────────┐ ┌──────────────┐ │
|
|
112
|
+
│ │ Time-Series│ │ Digital │ │ Optimization │ │
|
|
113
|
+
│ │ Storage │ │ Twin │ │ (MILP) │ │
|
|
114
|
+
│ └────────────┘ │ Engine │ └──────────────┘ │
|
|
115
|
+
│ └──────────┘ │
|
|
116
|
+
│ │ │
|
|
117
|
+
│ ┌───────┴───────┐ │
|
|
118
|
+
│ │ FastAPI + │ │
|
|
119
|
+
│ │ WebSocket │ │
|
|
120
|
+
│ └───────────────┘ │
|
|
121
|
+
└──────────────────────────────────────────────────────────┘
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## Installation
|
|
127
|
+
|
|
128
|
+
### Option 1: Install from PyPI (Recommended)
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
pip install gridos
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
With optional dependencies:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
# Machine learning (LSTM forecasting, anomaly detection)
|
|
138
|
+
pip install gridos[ml]
|
|
139
|
+
|
|
140
|
+
# Protocol adapters (Modbus, MQTT, OPC-UA)
|
|
141
|
+
pip install gridos[adapters]
|
|
142
|
+
|
|
143
|
+
# Storage backends (InfluxDB, TimescaleDB)
|
|
144
|
+
pip install gridos[storage]
|
|
145
|
+
|
|
146
|
+
# Everything
|
|
147
|
+
pip install gridos[ml,adapters,storage]
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Option 2: Run with Docker
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
docker pull ghcr.io/iceccarelli/gridos:latest
|
|
154
|
+
docker run -p 8000:8000 ghcr.io/iceccarelli/gridos:latest
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
The API is now available at `http://localhost:8000/docs`.
|
|
158
|
+
|
|
159
|
+
### Option 3: Run with Docker Compose (Full Stack)
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
git clone https://github.com/iceccarelli/GridOS.git
|
|
163
|
+
cd GridOS
|
|
164
|
+
docker-compose up -d
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
This starts GridOS alongside InfluxDB, TimescaleDB, and Grafana.
|
|
168
|
+
|
|
169
|
+
### Option 4: Install from Source
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
git clone https://github.com/iceccarelli/GridOS.git
|
|
173
|
+
cd GridOS
|
|
174
|
+
|
|
175
|
+
python -m venv .venv
|
|
176
|
+
source .venv/bin/activate
|
|
177
|
+
|
|
178
|
+
# Install with dev dependencies
|
|
179
|
+
pip install -e ".[dev]"
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## Quick Start
|
|
185
|
+
|
|
186
|
+
### Configuration
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
# Copy the example environment file
|
|
190
|
+
cp .env.example .env
|
|
191
|
+
|
|
192
|
+
# Edit .env with your settings (storage URLs, broker addresses, etc.)
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Run the API Server
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
uvicorn gridos.main:app --host 0.0.0.0 --port 8000 --reload
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
The interactive API documentation is available at `http://localhost:8000/docs`.
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## Project Structure
|
|
206
|
+
|
|
207
|
+
```
|
|
208
|
+
GridOS/
|
|
209
|
+
├── src/gridos/ # Core Python package
|
|
210
|
+
│ ├── models/ # Pydantic CIM models
|
|
211
|
+
│ ├── adapters/ # Protocol adapters (Modbus, MQTT, DNP3, …)
|
|
212
|
+
│ ├── storage/ # Time-series backends (InfluxDB, TimescaleDB)
|
|
213
|
+
│ ├── digital_twin/ # Simulation engine + ML modules
|
|
214
|
+
│ ├── optimization/ # MILP scheduler and dispatch
|
|
215
|
+
│ ├── api/ # FastAPI routes and WebSocket manager
|
|
216
|
+
│ ├── edge/ # Edge caching (SQLite store-and-forward)
|
|
217
|
+
│ ├── security/ # API key + JWT authentication
|
|
218
|
+
│ └── utils/ # Logging, metrics, and shared utilities
|
|
219
|
+
├── tests/ # Pytest test suite (70 tests)
|
|
220
|
+
├── notebooks/ # Jupyter demo notebooks
|
|
221
|
+
├── data/ # Sample datasets
|
|
222
|
+
├── docs/ # Architecture, API reference, developer guide
|
|
223
|
+
├── k8s/ # Kubernetes manifests
|
|
224
|
+
├── scripts/ # Utility and demo scripts
|
|
225
|
+
└── requirements/ # Dependency files (base, ml, dev, prod)
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## Running Tests
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
pytest tests/ -v --cov=gridos --cov-report=term-missing
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## Notebooks
|
|
239
|
+
|
|
240
|
+
Explore the interactive Jupyter notebooks in `notebooks/`:
|
|
241
|
+
|
|
242
|
+
1. **Data Ingestion Demo** — Connect adapters and ingest telemetry.
|
|
243
|
+
2. **Digital Twin Simulation** — Build a grid model and run power-flow.
|
|
244
|
+
3. **Forecasting with ML** — Train an LSTM on solar generation data.
|
|
245
|
+
4. **Optimization Scheduler** — Solve optimal battery dispatch with MILP.
|
|
246
|
+
5. **API Client** — Interact with the REST API programmatically.
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## Contributing
|
|
251
|
+
|
|
252
|
+
We welcome contributions from the community. Please read [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on how to get started.
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
## Security
|
|
257
|
+
|
|
258
|
+
If you discover a security vulnerability, please follow the responsible disclosure process described in [SECURITY.md](SECURITY.md).
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## License
|
|
263
|
+
|
|
264
|
+
GridOS is released under the [MIT License](LICENSE).
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
## Acknowledgements
|
|
269
|
+
|
|
270
|
+
GridOS builds on the shoulders of outstanding open-source projects including FastAPI, Pydantic, PuLP, scikit-learn, InfluxDB, TimescaleDB, and many others. We are grateful to the energy systems research community for the standards and models that inform this work.
|
gridos-0.1.0/README.md
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# GridOS — Open Energy Operating System
|
|
2
|
+
|
|
3
|
+
[](LICENSE)
|
|
4
|
+
[](https://www.python.org/downloads/)
|
|
5
|
+
[](https://pypi.org/project/gridos/)
|
|
6
|
+
[](https://pypi.org/project/gridos/)
|
|
7
|
+
[](https://github.com/iceccarelli/GridOS/pkgs/container/gridos)
|
|
8
|
+
[](https://github.com/iceccarelli/GridOS/actions/workflows/ci.yml)
|
|
9
|
+
[](https://fastapi.tiangolo.com/)
|
|
10
|
+
[](https://github.com/astral-sh/ruff)
|
|
11
|
+
|
|
12
|
+
**GridOS** is a vendor-neutral, open-source middleware platform that unifies **Distributed Energy Resources (DERs)** — solar inverters, batteries, EV chargers, smart loads — behind a single, standards-based API. It provides real-time telemetry ingestion, digital-twin simulation, ML-driven forecasting, and optimal energy dispatch, enabling utilities, aggregators, and microgrid operators to accelerate the energy transition.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Key Features
|
|
17
|
+
|
|
18
|
+
| Capability | Description |
|
|
19
|
+
|---|---|
|
|
20
|
+
| **Multi-Protocol Adapters** | Modbus TCP/RTU, MQTT, DNP3, IEC 61850, OPC-UA — connect any DER out of the box. |
|
|
21
|
+
| **Common Information Model** | Pydantic models aligned with IEC 61968/61850 for interoperable data exchange. |
|
|
22
|
+
| **Time-Series Storage** | Pluggable backends for InfluxDB 2.x and TimescaleDB with async I/O. |
|
|
23
|
+
| **Digital Twin Engine** | Physics-based component models (bus, line, transformer, PV, battery, EV charger) with simplified power-flow simulation. |
|
|
24
|
+
| **ML Forecasting** | LSTM-based load and solar forecasting plus Isolation Forest anomaly detection. |
|
|
25
|
+
| **MILP Optimization** | Mixed-Integer Linear Programming scheduler for optimal battery dispatch and demand response. |
|
|
26
|
+
| **REST + WebSocket API** | FastAPI-powered endpoints with live telemetry streaming via WebSockets. |
|
|
27
|
+
| **Edge Support** | SQLite-based store-and-forward cache for intermittent connectivity. |
|
|
28
|
+
| **Cloud-Native Deployment** | Docker Compose, Kubernetes manifests, and GitHub Actions CI/CD included. |
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Architecture Overview
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
┌──────────────────────────────────────────────────────────┐
|
|
36
|
+
│ GridOS Platform │
|
|
37
|
+
│ │
|
|
38
|
+
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌─────────┐ │
|
|
39
|
+
│ │ Modbus │ │ MQTT │ │ DNP3 │ │ IEC61850│ │
|
|
40
|
+
│ │ Adapter │ │ Adapter │ │ Adapter │ │ Adapter │ │
|
|
41
|
+
│ └────┬─────┘ └────┬─────┘ └────┬─────┘ └────┬────┘ │
|
|
42
|
+
│ │ │ │ │ │
|
|
43
|
+
│ └──────────────┼──────────────┼──────────────┘ │
|
|
44
|
+
│ ▼ │
|
|
45
|
+
│ ┌───────────────┐ │
|
|
46
|
+
│ │ CIM Models │ │
|
|
47
|
+
│ │ (Pydantic) │ │
|
|
48
|
+
│ └───────┬───────┘ │
|
|
49
|
+
│ │ │
|
|
50
|
+
│ ┌────────────┼────────────┐ │
|
|
51
|
+
│ ▼ ▼ ▼ │
|
|
52
|
+
│ ┌────────────┐ ┌──────────┐ ┌──────────────┐ │
|
|
53
|
+
│ │ Time-Series│ │ Digital │ │ Optimization │ │
|
|
54
|
+
│ │ Storage │ │ Twin │ │ (MILP) │ │
|
|
55
|
+
│ └────────────┘ │ Engine │ └──────────────┘ │
|
|
56
|
+
│ └──────────┘ │
|
|
57
|
+
│ │ │
|
|
58
|
+
│ ┌───────┴───────┐ │
|
|
59
|
+
│ │ FastAPI + │ │
|
|
60
|
+
│ │ WebSocket │ │
|
|
61
|
+
│ └───────────────┘ │
|
|
62
|
+
└──────────────────────────────────────────────────────────┘
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Installation
|
|
68
|
+
|
|
69
|
+
### Option 1: Install from PyPI (Recommended)
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
pip install gridos
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
With optional dependencies:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# Machine learning (LSTM forecasting, anomaly detection)
|
|
79
|
+
pip install gridos[ml]
|
|
80
|
+
|
|
81
|
+
# Protocol adapters (Modbus, MQTT, OPC-UA)
|
|
82
|
+
pip install gridos[adapters]
|
|
83
|
+
|
|
84
|
+
# Storage backends (InfluxDB, TimescaleDB)
|
|
85
|
+
pip install gridos[storage]
|
|
86
|
+
|
|
87
|
+
# Everything
|
|
88
|
+
pip install gridos[ml,adapters,storage]
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Option 2: Run with Docker
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
docker pull ghcr.io/iceccarelli/gridos:latest
|
|
95
|
+
docker run -p 8000:8000 ghcr.io/iceccarelli/gridos:latest
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
The API is now available at `http://localhost:8000/docs`.
|
|
99
|
+
|
|
100
|
+
### Option 3: Run with Docker Compose (Full Stack)
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
git clone https://github.com/iceccarelli/GridOS.git
|
|
104
|
+
cd GridOS
|
|
105
|
+
docker-compose up -d
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
This starts GridOS alongside InfluxDB, TimescaleDB, and Grafana.
|
|
109
|
+
|
|
110
|
+
### Option 4: Install from Source
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
git clone https://github.com/iceccarelli/GridOS.git
|
|
114
|
+
cd GridOS
|
|
115
|
+
|
|
116
|
+
python -m venv .venv
|
|
117
|
+
source .venv/bin/activate
|
|
118
|
+
|
|
119
|
+
# Install with dev dependencies
|
|
120
|
+
pip install -e ".[dev]"
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Quick Start
|
|
126
|
+
|
|
127
|
+
### Configuration
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
# Copy the example environment file
|
|
131
|
+
cp .env.example .env
|
|
132
|
+
|
|
133
|
+
# Edit .env with your settings (storage URLs, broker addresses, etc.)
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Run the API Server
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
uvicorn gridos.main:app --host 0.0.0.0 --port 8000 --reload
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
The interactive API documentation is available at `http://localhost:8000/docs`.
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## Project Structure
|
|
147
|
+
|
|
148
|
+
```
|
|
149
|
+
GridOS/
|
|
150
|
+
├── src/gridos/ # Core Python package
|
|
151
|
+
│ ├── models/ # Pydantic CIM models
|
|
152
|
+
│ ├── adapters/ # Protocol adapters (Modbus, MQTT, DNP3, …)
|
|
153
|
+
│ ├── storage/ # Time-series backends (InfluxDB, TimescaleDB)
|
|
154
|
+
│ ├── digital_twin/ # Simulation engine + ML modules
|
|
155
|
+
│ ├── optimization/ # MILP scheduler and dispatch
|
|
156
|
+
│ ├── api/ # FastAPI routes and WebSocket manager
|
|
157
|
+
│ ├── edge/ # Edge caching (SQLite store-and-forward)
|
|
158
|
+
│ ├── security/ # API key + JWT authentication
|
|
159
|
+
│ └── utils/ # Logging, metrics, and shared utilities
|
|
160
|
+
├── tests/ # Pytest test suite (70 tests)
|
|
161
|
+
├── notebooks/ # Jupyter demo notebooks
|
|
162
|
+
├── data/ # Sample datasets
|
|
163
|
+
├── docs/ # Architecture, API reference, developer guide
|
|
164
|
+
├── k8s/ # Kubernetes manifests
|
|
165
|
+
├── scripts/ # Utility and demo scripts
|
|
166
|
+
└── requirements/ # Dependency files (base, ml, dev, prod)
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Running Tests
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
pytest tests/ -v --cov=gridos --cov-report=term-missing
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## Notebooks
|
|
180
|
+
|
|
181
|
+
Explore the interactive Jupyter notebooks in `notebooks/`:
|
|
182
|
+
|
|
183
|
+
1. **Data Ingestion Demo** — Connect adapters and ingest telemetry.
|
|
184
|
+
2. **Digital Twin Simulation** — Build a grid model and run power-flow.
|
|
185
|
+
3. **Forecasting with ML** — Train an LSTM on solar generation data.
|
|
186
|
+
4. **Optimization Scheduler** — Solve optimal battery dispatch with MILP.
|
|
187
|
+
5. **API Client** — Interact with the REST API programmatically.
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Contributing
|
|
192
|
+
|
|
193
|
+
We welcome contributions from the community. Please read [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on how to get started.
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## Security
|
|
198
|
+
|
|
199
|
+
If you discover a security vulnerability, please follow the responsible disclosure process described in [SECURITY.md](SECURITY.md).
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## License
|
|
204
|
+
|
|
205
|
+
GridOS is released under the [MIT License](LICENSE).
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## Acknowledgements
|
|
210
|
+
|
|
211
|
+
GridOS builds on the shoulders of outstanding open-source projects including FastAPI, Pydantic, PuLP, scikit-learn, InfluxDB, TimescaleDB, and many others. We are grateful to the energy systems research community for the standards and models that inform this work.
|