How matrixeigs/energy_management_system works
Project Type and Purpose
• This is a specialized full-stack computational platform—“Universal Energy Management System (EMS)”—for coordinating multiple hybrid AC/DC microgrids (MGs) in a microgrid park.
• It ingests data (historical, web-scraped, weather), applies forecasting, then sequentially drives unit commitment, optimal power flow, and economic dispatch, using configurable models and solvers. A local EMS manages individual MGs, and a universal EMS orchestrates at park level.
High-Level Architecture Components
a. Entry & Orchestration
• universal_ems.py (top-level orchestration)
• start_up/start_up_uems.py and start_up/start_up_lems.py (bootstrapping universal & local EMS instances)
b. Configuration
• configuration/ (all configuration loaders, defaults, database connection, converters)
c. Data Ingestion & Management
• data_management/ (SQL scripts, database management, information collection and web_scraping)
• External data sources (weather station, historical data files)
• Central time-series database
d. Modelling Library
• modelling/ (Protobuf schemas, generators, loads, ESS, converters, transmission_lines, power_flow indexing)
• information_exchange.proto & dynamic_operation.proto (for internal message definitions)
e. Computing Pipeline
• forecasting/ (long, mid, short-term forecasting modules)
• unit_commitment/ (input_check → formulation → solving → output_check)
• optimal_power_flow/ (similar pipeline for OPF)
• economic_dispatch/ (pipeline for economic dispatch)
f. Solvers
• solvers/ (convex_optimization, interior_point_method, mix_integer_solvers, Gurobi)
g. Logging
• log/ (detailed step-by-step logs for each stage)
h. Local EMS
• local_ems.py (manages single MG operation)
i. Static Info
• start_up/static_information.py (initial network topology, device specs)
Relationships & Data Flows
• On startup: start_up → configuration → static_information → initialize databases & connections.
• Data ingestion: data_management reads from SQL, web, API → writes to time-series database.
• Forecasting consumes historical data → produces forecasts.
• Unit commitment consumes forecasts + static network models → formulates MILP → solvers → UC schedules.
• Optimal power flow takes UC schedules → network model → formulates convex QCQP → solvers → set points.
• Economic dispatch refines set points across MG park → final dispatch decisions.
• local_ems applies decisions to each MG; universal_ems aggregates status.
• Throughout: modelling library provides shared data structures; configuration drives parameterization; logging captures every stage.
Architectural Patterns & Principles
• Pipeline pattern: sequential stages (forecast → UC → OPF → ED).
• Modular separation: clear boundaries between ingestion, modelling, computation, and orchestration.
• Abstraction via Protobuf: standard message formats for inter-module communication.
• Pluggable solvers: strategy pattern for solver choice.