Add architecture documentation and diagrams (PDF/PNG/Mermaid)

This commit is contained in:
Eric F
2026-06-08 17:47:13 -04:00
parent ecd382fa74
commit 91506a6634
4 changed files with 490 additions and 77 deletions

View File

@@ -1,90 +1,279 @@
# Cariflex - Documentation Complète # Cariflex - Architecture d'Intégration EMS
## Architecture Globale > Documentation de l'architecture Cariflex - Plateforme d'Energy Management System
## 1. Vue d'ensemble
Cariflex est une plateforme EMS (Energy Management System) pour la Martinique, intégrant :
- **FlexMeasures** : Moteur central de forecasting, scheduling et ingestion
- **CitrineOS** : Charge Station Management System (CSMS) pour bornes EV
- **EVerest** : Middleware de communication avec les bornes (OCPP/ISO 15118)
- **Grid Singularity** : Plateforme de marché énergétique peer-to-peer
- **OPLEM** : Optimisation des marchés locaux d'énergie
- **HAMLET** : Simulation multi-agents pour LEM (Local Energy Market)
- **OpenLEADR** : Communication OpenADR avec le DSO
---
## 2. Architecture Fonctionnelle
``` ```
┌─────────────────────────────────────────────────────────────────────────┐ ┌─────────────────────────────────────────────────────────────────────────────
│ CARIFLEX PLATFORM CARIFLEX EMS
│ Caribbean Flexibility — Martinique │ ├─────────────────────────────────────────────────────────────────────────────┤
├─────────────────────────────────────────────────────────────────────────┤
│ │ │ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ ┌──────────────────────────────────────────────────────────────────────┐ │
│ │ DSO Layer Market Layer │ R&D Layer │ │ │ EXTERNAL DATA SOURCES
│ │ │ │ │ │
│ │ ENEDIS/RTE │ │ Flex Ready® │ │ OPLEM │ │ │ ┌────────────┐ ┌────────────┐ ┌────────────┐ ┌────────────┐ │
│ │ OpenADR 2.0b │ │ Aggregator │ │ HAMLET │ │ │ │ │ EPEX SPOT │ │ ENTSO-E │ │ Weather │DSO
│ │ API │ │ lemlab │ │ │ Day-ahead │ Prices/CO2 │ │ API │ │ OpenADR
│ └─────┬───────┘ └──────┬───────┘ └──────┬────── │ └─────┬──────┘ └─────┬──────┘ └─────┬──────┘ └─────┬──────┘
│ │ │ └────────┼───────────────┼───────────────┼───────────────┼────────────┘
┌──────▼───────────────────▼───────────────────▼───────┐ │ │ │ │
FLEXMEASURES (Core RM) ▼ ▼
│ ┌─────────┐ ┌──────────┐ ┌──────────┐ ┌─────────┐ │ │ ┌──────────────────────────────────────────────────────────────────────┐
│ │ │Scheduling│ │Forecasting│ │ Reporting │ │ APIs │ │ │ FLEXMEASURES EMS
│ │ └─────────┘ └──────────┘ └──────────┘ └─────────┘ │ │
────────────────────────────────────────────────────── │ ┌────────────────────────────────────────────────────────────────┐
│ │ INGESTION │ │
┌───────────────────────▼───────────────────────────────┐ │ │ │ │
│ │ IoT Layer │ │ │ Sources:
│ │ MQTT (Mosquitto/EMQX/BunkerM) → Telegraf → InfluxDB │ │ │ │ • Simulator Cariflex (API REST, 30s interval) │ │
└───────────────────────┬───────────────────────────────┘ • MQTT brokers (Smart City format → FM format) │ │
│ │ • CitrineOS (OCPP 2.0.1 → FM API)
┌───────────────────────▼───────────────────────────────┐ │ │ • Weather API (Solcast/Météo) │ │
│ │ Assets (40) │ │ • EPEX SPOT (Day-ahead prices via entsoe-py) │ │
│ │ 10 PV (5kWc) │ 10 Battery (100kWh) │ 10 EVSE (22kW) │ 10 EV (75kWh) │ │ │ │ │
└───────────────────────────────────────────────────────┘ Data Model: │ │
│ │ │ Assets (40) ──► Sensors (40) ──► Beliefs (timed values) │ │ │
│ │ │ • 10 PV (sensors 41-50) │ │ │
│ │ │ • 10 Batteries (sensors 51-60) │ │ │
│ │ │ • 10 EV Chargers (sensors 61-70) │ │ │
│ │ │ • 10 EVs V2G (sensors 71-80) │ │ │
│ │ └────────────────────────────────────────────────────────────────┘ │ │
│ │ │ │
│ │ ┌────────────────────────────────────────────────────────────────┐ │ │
│ │ │ FORECASTING │ │ │
│ │ │ │ │ │
│ │ │ Current: │ │ │
│ │ │ • CLI: `flexmeasures add forecasts --sensor <id>` │ │ │
│ │ │ • 82 forecast beliefs per PV sensor (24h horizon) │ │ │
│ │ │ • Autoregressive model (TrainPredictPipeline) │ │ │
│ │ │ │ │ │
│ │ │ TODO: │ │ │
│ │ │ • Automatic forecasting via cron job │ │ │
│ │ │ • Weather-based PV forecasting (Solcast API) │ │ │
│ │ │ • Price forecasting (EPEX SPOT via entsoe-py) │ │ │
│ │ │ • CO2 intensity forecasting (ENTSO-E) │ │ │
│ │ └────────────────────────────────────────────────────────────────┘ │ │
│ │ │ │
│ │ ┌────────────────────────────────────────────────────────────────┐ │ │
│ │ │ SCHEDULING │ │ │
│ │ │ │ │ │
│ │ │ Current: │ │ │
│ │ │ • StorageScheduler (batteries, EVs) │ │ │
│ │ │ • Flex-model: soc_min, soc_max, power_capacity, efficiency │ │ │
│ │ │ │ │ │
│ │ │ TODO: │ │ │
│ │ │ • Automatic scheduling via API trigger │ │ │
│ │ │ • Grid services scheduling (OpenADR ↔ DSO) │ │ │
│ │ │ • Market-based scheduling (Grid Singularity integration) │ │ │
│ │ └────────────────────────────────────────────────────────────────┘ │ │
│ └──────────────────────────────────────────────────────────────────────┘ │
│ │ │ │
│ ┌───────────────────────────────────────────────────── │ ┌──────────────────────────────────────────────────────────────────────┐
│ │ Visualization Layer │ │ DEVICE LAYER │ │
│ │ Grafana (supervision) │ Metabase (reporting) │ │ │
───────────────────────────────────────────────────── │ ┌────────────────────┐ ┌────────────────────┐ ┌────────────────┐ │
└─────────────────────────────────────────────────────────────────────────┘ │ │ │ CITRINEOS │ │ EVEREST │ │ OPENLEADR │ │ │
│ │ │ (CSMS) │ │ (Middleware) │ │ (VEN Client) │ │ │
│ │ │ │ │ │ │ │ │ │
│ │ │ • OCPP 2.0.1 │ │ • ISO 15118-2 │ │ • OpenADR 2.0b│ │ │
│ │ │ • Charge Points │ │ • OCPP 1.6/2.0.1 │ │ • DSO signals │ │ │
│ │ │ • Transactions │ │ • Smart Charging │ │ • Flexibility │ │ │
│ │ │ • Remote control │ │ • Power mgmt │ │ requests │ │ │
│ │ │ │ │ │ │ │ │ │
│ │ │ → FM API │ │ → CitrineOS OCPP │ │ → FM API │ │ │
│ │ └────────────────────┘ └────────────────────┘ └────────────────┘ │ │
│ │ │ │
│ │ ┌────────────────────────────────────────────────────────────────┐ │ │
│ │ │ DEVICES │ │ │
│ │ │ │ │ │
│ │ │ 10 PV Panels (5kWc) │ Modbus TCP │ │ │
│ │ │ 10 Batteries (100kWh) │ Modbus TCP │ │ │
│ │ │ 10 EV Chargers (22kW) │ OCPP 2.0.1 (CitrineOS) │ │ │
│ │ │ 10 EVs (75kWh V2G) │ ISO 15118 (EVerest) │ │ │
│ │ └────────────────────────────────────────────────────────────────┘ │ │
│ └──────────────────────────────────────────────────────────────────────┘ │
│ │
│ ┌──────────────────────────────────────────────────────────────────────┐ │
│ │ MARKET LAYER (R&D) │ │
│ │ │ │
│ │ ┌────────────────────┐ ┌────────────────────┐ ┌────────────────┐ │ │
│ │ │ GRID SINGULARITY │ │ OPLEM │ │ HAMLET │ │ │
│ │ │ gsy-e (88 stars) │ │ oplem (pip) │ │ (conda hamlet) │ │ │
│ │ │ │ │ │ │ │ │ │
│ │ │ • P2P energy │ │ • Local market │ │ • Multi-agent │ │ │
│ │ │ trading │ │ optimization │ │ simulation │ │ │
│ │ │ • Market clearing │ │ • Prosumer │ │ • Battery/EV │ │ │
│ │ │ • Price discovery │ │ optimization │ │ agents │ │ │
│ │ │ │ │ │ │ │ │ │
│ │ │ ← FM schedules │ │ ← FM sensor data │ │ ← FM forecasts │ │ │
│ │ └────────────────────┘ └────────────────────┘ └────────────────┘ │ │
│ └──────────────────────────────────────────────────────────────────────┘ │
│ │
│ ┌──────────────────────────────────────────────────────────────────────┐ │
│ │ VISUALIZATION LAYER │ │
│ │ │ │
│ │ ┌────────────────────┐ ┌────────────────────┐ ┌────────────────┐ │ │
│ │ │ GRAFANA │ │ METABASE │ │ CARIFLEX UI │ │ │
│ │ │ (Port 3001) │ │ │ │ (Port 5000) │ │ │
│ │ │ │ │ │ │ │ │ │
│ │ │ • 4 timeseries │ │ • SQL analytics │ │ • Asset map │ │ │
│ │ │ • 1 table (assets) │ │ • Reporting │ │ • Schedules │ │ │
│ │ │ • PostgreSQL FM │ │ • Data exploration │ │ • Forecasts │ │ │
│ │ └────────────────────┘ └────────────────────┘ └────────────────┘ │ │
│ └──────────────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────────┘
``` ```
## Standards Interopérabilité ---
| Standard | Organisation | Usage | API | ## 3. Flux de Données
|----------|-------------|-------|-----|
| **Flex Ready®** | GIMELEC/RTE/ENEDIS | Bâtiment ↔ Réseau | Aggregator + Supplier |
| **IEC 62746-4** | IEC | Interfaces ressources côté demande | — |
| **S2** | S2Standard.org | CEM/RM | WebSocket |
| **OpenADR 2.0b** | OpenADR Alliance | Réponse à la demande | REST |
| **OpenLEADR** | OpenLEADR | Passerelle OpenADR | Python lib |
## Actifs Cariflex
| Type | Nb | Capacité | Localisation |
|------|-----|----------|--------------|
| Panneau PV | 10 | 5 kWc | Fort-de-France, Lamentin, Schoelcher |
| Batterie | 10 | 100 kWh | Saint-Joseph, Marin, Vauclin, Sainte-Marie |
| Borne VE | 10 | 22 kW | Diamant, Trois-Ilets, Salée, François, Robert |
| Véhicule Électrique | 10 | 75 kWh (V2G) | Lorrain, Robert, Basse-Pointe, Grand-Rivière, etc. |
## Flux de Données
### 3.1 Ingestion
``` ```
Capteurs IoT → MQTT → Telegraf → InfluxDB Devices → MQTT/OCPP → FM API → PostgreSQL
FlexMeasures (scheduling/forecast) FM Worker (RQ Queue)
┌─────────┼─────────┐ Beliefs (timed data)
↓ ↓ ↓
Grafana Metabase S2 CEM
(viz) (report) (DSO)
``` ```
## Fichiers de Configuration ### 3.2 Forecasting
```
Historical Data → TrainPredictPipeline → Forecast Beliefs
↓ ↓
PostgreSQL PostgreSQL
Grafana
```
| Fichier | Description | ### 3.3 Scheduling
|---------|-------------| ```
| `config/flexmeasures-config.cfg` | Config FlexMeasures Cariflex | Grid Request (OpenADR) → FM API → StorageScheduler → Schedule
| `config/map-init-patch.js` | Patch carte OSM |
| `scripts/init_flexmeasures_db.py` | Création des assets | Flex Model (soc_min, soc_max, power_capacity)
| `scripts/telegraf-cariflex.conf` | Config Telegraf MQTT→InfluxDB |
Device Commands (OCPP)
```
## URLs ---
| Service | URL | ## 4. Intégrations à Développer
|---------|-----|
| FlexMeasures | https://flexmeasures.digitribe.fr | ### 4.1 CitrineOS ↔ FlexMeasures
| Grafana | https://grafana.digitribe.fr | ```
| Metabase | https://metabase.digitribe.fr | CitrineOS (CSMS) → OCPP 2.0.1 → Charge Points
REST API → FM API (sensor data, transactions)
FM Scheduling → Charge profiles → CitrineOS
```
### 4.2 EVerest ↔ CitrineOS
```
EVerest (Middleware) → OCPP 2.0.1 → CitrineOS
ISO 15118 → EV communication
Smart Charging → Power management
```
### 4.3 Grid Singularity ↔ FlexMeasures
```
Grid Singularity (Market) → gsy-e-sdk → FM API
P2P trading → Price signals
FM Scheduling → Battery/EV schedules
```
### 4.4 OPLEM ↔ FlexMeasures
```
OPLEM (Optimization) → FM sensor data
Local market optimization
FM Scheduling → Device schedules
```
### 4.5 HAMLET ↔ FlexMeasures
```
HAMLET (Simulation) → FM forecasts
Multi-agent simulation
Strategy validation → FM scheduling
```
### 4.6 OpenLEADR ↔ FlexMeasures
```
DSO (OpenADR VTN) → OpenLEADR (VEN) → FM API
Flexibility requests
FM Scheduling → Grid services
```
---
## 5. Configuration Requise
### 5.1 FlexMeasures
```yaml
# Environment variables
FLEXMEASURES_ENV=production
FLEXMEASURES_REDIS_URL=flexmeasures-redis
FLEXMEASURES_REDIS_PORT=6379
FLEXMEASURES_REDIS_DB_NR=0
FLEXMEASURES_REDIS_PASSWORD=***
SQLALCHEMY_DATABASE_URI=postgresql://flexmeasures:***@flexmeasures-db:5432/flexmeasures
# Config file
FLEXMEASURES_MENU_LOGO_PATH=/ui/static/images/cariflex-logo.jpg
FLEXMEASURES_PLATFORM_NAME=Cariflex
```
### 5.2 Grafana Datasource
```json
{
"name": "PostgreSQL-FlexMeasures",
"type": "postgres",
"url": "flexmeasures-db:5432",
"database": "flexmeasures",
"user": "flexmeasures"
}
```
### 5.3 MQTT Brokers (TODO)
```yaml
# New brokers needed for Cariflex (format compatible FM)
- cariflex-mqtt: MQTT broker for Cariflex devices
- Topics: cariflex/sensors/{asset_type}/{asset_id}/power
- Format: {"value": float, "unit": "kW|kWh", "timestamp": ISO8601}
```
---
## 6. Prochaines Étapes
1. **Intégrer CitrineOS** : Connecter via OCPP 2.0.1 aux bornes EV
2. **Intégrer EVerest** : Configurer ISO 15118 pour V2G
3. **Intégrer OpenLEADR** : Connecter au DSO pour flexibilité
4. **Créer brokers MQTT Cariflex** : Format compatible FM
5. **Automatiser forecasting/scheduling** : Cron jobs ou scheduler
6. **Intégrer Grid Singularity** : P2P trading
7. **Documentation complète** : API, déploiement, fonctionnement

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 KiB

View File

@@ -0,0 +1,224 @@
# Cariflex - Diagrammes d'Architecture
## 1. Architecture Générale
```mermaid
graph TB
subgraph EXTERNAL["External Layer"]
EPEX["EPEX SPOT<br/>Day-ahead Prices"]
ENTSOE["ENTSO-E<br/>CO2/Prices"]
WEATHER["Weather API<br/>Solcast/Météo"]
DSO["DSO/TSO<br/>OpenADR/S2"]
end
subgraph INTEGRATION["Integration Layer"]
FM["FlexMeasures EMS<br/>━━━━━━━━━━━━━━<br/>• Ingestion<br/>• Forecasting<br/>• Scheduling<br/>• Reporting"]
CITRINEOS["CitrineOS<br/>CSMS<br/>━━━━━━━━━━━━━━<br/>• OCPP 2.0.1<br/>• Charge Points<br/>• Transactions"]
EVEREST["EVerest<br/>Middleware<br/>━━━━━━━━━━━━━━<br/>• ISO 15118<br/>• Smart Charging<br/>• Power Mgmt"]
OPENLEADR["OpenLEADR<br/>VEN Client<br/>━━━━━━━━━━━━━━<br/>• OpenADR 2.0b<br/>• DSO Signals<br/>• Flexibility"]
end
subgraph MARKET["Market Layer (R&D)"]
GSY["Grid Singularity<br/>gsy-e<br/>━━━━━━━━━━━━━━<br/>• P2P Trading<br/>• Market Clearing<br/>• Price Discovery"]
OPLEM["OPLEM<br/>━━━━━━━━━━━━━━<br/>• Local Market<br/>• Prosumer Opt."]
HAMLET["HAMLET<br/>━━━━━━━━━━━━━━<br/>• Multi-agent<br/>• Simulation"]
end
subgraph DEVICES["Device Layer"]
PV["10 PV Panels<br/>5kWc each"]
BAT["10 Batteries<br/>100kWh each"]
EV["10 EVs<br/>75kWh V2G"]
CHG["10 EV Chargers<br/>22kW each"]
end
subgraph VIZ["Visualization"]
GRAFANA["Grafana<br/>Dashboards"]
METABASE["Metabase<br/>Analytics"]
CARIFLEX_UI["Cariflex UI<br/>FM Frontend"]
end
%% External to Integration
EPEX -->|"Prices"| FM
ENTSOE -->|"CO2/Prices"| FM
WEATHER -->|"Irradiance"| FM
DSO -->|"Flex Requests"| OPENLEADR
%% Integration to FM
CITRINEOS -->|"OCPP/REST"| FM
EVEREST -->|"OCPP"| CITRINEOS
OPENLEADR -->|"REST API"| FM
%% Market to FM
GSY <--->|"gsy-e-sdk"| FM
OPLEM <--->|"sensor data"| FM
HAMLET <--->|"forecasts"| FM
%% Devices
PV -->|"Modbus"| FM
BAT -->|"Modbus"| FM
EV -->|"ISO 15118"| EVEREST
CHG -->|"OCPP 2.0.1"| CITRINEOS
%% FM to Viz
FM -->|"PostgreSQL"| GRAFANA
FM -->|"PostgreSQL"| METABASE
FM -->|"REST API"| CARIFLEX_UI
style FM fill:#2196F3,stroke:#1565C0,color:#fff
style CITRINEOS fill:#4CAF50,stroke:#388E3C,color:#fff
style EVEREST fill:#FF9800,stroke:#F57C00,color:#fff
style OPENLEADR fill:#9C27B0,stroke:#7B1FA2,color:#fff
style GSY fill:#00BCD4,stroke:#0097A7,color:#fff
```
## 2. Flux de Données - Ingestion
```mermaid
sequenceDiagram
participant Device as Device (PV/BAT/EV)
participant MQTT as MQTT Broker
participant FM_API as FlexMeasures API
participant Worker as FM Worker (RQ)
participant DB as PostgreSQL
participant Grafana as Grafana
Device->>MQTT: Publish sensor data (30s)
MQTT->>FM_API: REST POST /sensors/{id}/data
FM_API->>Worker: Enqueue ingestion job
Worker->>DB: Save beliefs (timed data)
Grafana->>DB: Query data (timeseries)
```
## 3. Flux de Données - Forecasting
```mermaid
sequenceDiagram
participant Cron as Cron Job / Scheduler
participant FM_CLI as FM CLI
participant Pipeline as TrainPredictPipeline
participant DB as PostgreSQL
participant Grafana as Grafana
Cron->>FM_CLI: Trigger forecast (daily)
FM_CLI->>Pipeline: Train model (30 days history)
Pipeline->>Pipeline: Predict (24h horizon)
Pipeline->>DB: Save 82 forecast beliefs
Grafana->>DB: Display forecast vs actual
```
## 4. Flux de Données - Scheduling
```mermaid
sequenceDiagram
participant DSO as DSO (OpenADR VTN)
participant OpenLEADR as OpenLEADR (VEN)
participant FM_API as FlexMeasures API
participant Scheduler as StorageScheduler
participant DB as PostgreSQL
participant CitrineOS as CitrineOS (CSMS)
DSO->>OpenLEADR: Flexibility request
OpenLEADR->>FM_API: POST /sensors/{id}/schedules/trigger
FM_API->>Scheduler: Create schedule job
Scheduler->>Scheduler: Optimize (soc_min, soc_max, power)
Scheduler->>DB: Save schedule beliefs
Scheduler->>CitrineOS: Send charging profile
CitrineOS->>CitrineOS: Apply to charge point
```
## 5. Intégration Grid Singularity
```mermaid
sequenceDiagram
participant GSY as Grid Singularity Exchange
participant SDK as gsy-e-sdk
participant FM_API as FlexMeasures API
participant Scheduler as FM Scheduler
participant DB as PostgreSQL
GSY->>SDK: Market prices / orders
SDK->>FM_API: POST /sensors/{id}/data (price signals)
FM_API->>DB: Save price beliefs
Scheduler->>DB: Read prices + forecasts
Scheduler->>Scheduler: Optimize schedule
Scheduler->>DB: Save optimal schedule
FM_API->>SDK: Report flexibility offered
SDK->>GSY: Submit bids/offers
```
## 6. Intégration OPLEM
```mermaid
sequenceDiagram
participant OPLEM as OPLEM Optimizer
participant FM_DB as FM PostgreSQL
participant Scheduler as FM Scheduler
participant Devices as Devices
OPLEM->>FM_DB: Read sensor data (SOC, power)
OPLEM->>OPLEM: Optimize local market
OPLEM->>Scheduler: Send optimal setpoints
Scheduler->>Devices: Apply commands
Devices->>FM_DB: Report actual values
```
## 7. Intégration HAMLET
```mermaid
sequenceDiagram
participant HAMLET as HAMLET Simulator
participant FM_API as FlexMeasures API
participant Scheduler as FM Scheduler
HAMLET->>FM_API: Read forecasts
HAMLET->>HAMLET: Run multi-agent simulation
HAMLET->>FM_API: Validate strategies
FM_API->>Scheduler: Apply validated schedule
```
## 8. Architecture Réseau
```mermaid
graph LR
subgraph Docker["Docker Network: cariflex-internal"]
FM_SRV["flexmeasures-server:5000"]
FM_WRK["flexmeasures-worker:5000"]
FM_DB["flexmeasures-db:5432"]
FM_REDIS["flexmeasures-redis:6379"]
CITRINEOS["citrineos-server:8080"]
EVEREST["everest:8080"]
GSY["gsy-e:8080"]
end
subgraph Traefik["Traefik (websecure)"]
ROUTER["Router: cariflex.digitribe.fr"]
end
ROUTER -->|"HTTPS"| FM_SRV
FM_SRV -->|"REST"| FM_WRK
FM_WRK -->|"RQ"| FM_REDIS
FM_WRK -->|"SQL"| FM_DB
FM_SRV -->|"SQL"| FM_DB
CITRINEOS -->|"REST"| FM_SRV
EVEREST -->|"OCPP"| CITRINEOS
GSY -->|"REST"| FM_SRV
```
## 9. TODO - Intégrations à Développer
| Intégration | Priorité | Complexité | Statut |
|-------------|----------|------------|--------|
| CitrineOS ↔ FM | Haute | Moyenne | ⏳ À faire |
| EVerest ↔ CitrineOS | Haute | Moyenne | ⏳ À faire |
| OpenLEADR ↔ FM | Haute | Faible | ⏳ À faire |
| Grid Singularity ↔ FM | Moyenne | Élevée | ⏳ À faire |
| OPLEM ↔ FM | Moyenne | Moyenne | ⏳ À faire |
| HAMLET ↔ FM | Basse | Élevée | ⏳ À faire |
| MQTT Brokers Cariflex | Haute | Moyenne | ⏳ À faire |