Real-Time Energy Management in Microgrids: Integrating T-Cell Optimization, Droop Control, and HIL Validation with OPAL-RT
Abstract
1. Introduction
- To design and implement a hierarchical control architecture combining centralized T-Cell optimization algorithm with decentralized voltage-based droop control.
- To develop a bio-inspired T-Cell algorithm tailored for real-time microgrid energy management and compare its effectiveness to existing metaheuristics (e.g., PSO, GA).
- To coordinate DERs and controllable loads via a JADE-based MASs with fault-tolerant, scalable control.
- To validate the proposed control system through HIL testing using OPAL-RT, Raspberry Pi, and real-time protocols (MQTT/Modbus).
- To demonstrate the framework’s effectiveness in reducing grid dependency, stabilizing voltage, and enhancing self-consumption under dynamic RESs and load conditions.
2. Theoretical Foundation
2.1. Hierarchical Three-Layer Architecture
2.1.1. Central Layer (MGCC)
- Calculates optimal DER setpoints (e.g., solar/wind power curtailment, battery charge/discharge schedules) using real-time data from smart meters;
- Forecasts renewable generation and load demand to minimize operational costs and grid dependency;
- Manages power exchange with the main grid, prioritizing self-consumption of locally generated energy.
2.1.2. Communication Layer
2.1.3. Local Layer
- Droop-Controlled DERs: Utilize P-V droop logic to dynamically adjust power output based on local voltage measurements;
- Load Controllers: Implement step-based adjustments to balance generation and consumption;
- Energy Storage Systems (ESS): Automatically switch between charging/discharging modes to stabilize voltage.
- Pout is the output power of the generator;
- Pref is the reference power (nominal output);
- Kv is the droop constant (a proportionality factor);
- Vset is the set voltage (voltage reference);
- Vmeasured is the measured voltage.
2.2. T-Cell Optimization Algorithm
2.2.1. Comparative Evaluation of Bio-Inspired Optimization Techniques
- A dual mechanism of proliferation and differentiation, enhancing both exploitation and exploration;
- The use of immune memory, which retains and reuses high-performing solutions during repetitive scenarios (e.g., daily load patterns);
- Embedded constraint handling through Equality Constraint Violation (ECV) and Inequality Constraint Status (ICS) indicators;
- A structure well-suited for real-time response in dynamic, decentralized microgrid systems.
2.2.2. Implementation of the T-Cell Algorithm for Microgrid Optimization
- T-Cells: Represent candidate solutions (DER setpoints, grid interaction schedules);
- Antigens: Symbolize optimization challenges (e.g., renewable intermittency, load surges);
- Immune Memory: Retains historical optimal solutions for rapid convergence during recurring scenarios (e.g., daily load patterns).
- Constraint Evaluation: Assess solutions based on equality and inequality constraints (ECV and ICS).
- Objective Function Evaluation: Compute the cost function for each solution, including energy costs and penalties for constraint violations.
- Proliferation: Clone the best-performing solutions to enhance exploration of the search space.
- Differentiation: Introduce mutations to cloned solutions to promote diversity and prevent premature convergence. Example: Adjust PV inverter setpoints by ±15% to explore unvisited regions of the search space.
- Ct: Time-varying electricity price (€/kWh)—represents the cost of power generation at time t.
- Pt: Power output from generation units (kW)—the primary decision variable.
- λ: Penalty coefficient for power imbalance (e.g., 10 €/kWh for unmet demand).
- ECV: Equality Constraint Violation = |Pgen − Pload + Ploss)|—measures deviation from power balance.
- µ: Penalty coefficient for limit violations (e.g., 5 €/kW for overgeneration).
- ICS: Inequality Constraint Status—quantifies violations of generation limits (Pmin < Pgen < Pmax).
2.3. Integration of JADE for Multi-Agent Optimization
- Key MASs Roles in the Framework:
- -
- Distributed Coordination:
- Each DER, load, and ESS operates as an autonomous agent capable of negotiating power setpoints via FIPA-compliant protocols (e.g., Contract Net).
- Agents self-organize during communication outages, enabling seamless transitions between control modes.
- -
- Hierarchical Control Enforcement:
- MGCC Agent: Hosts the T-Cell algorithm, distributing optimized setpoints.
- Edge Agents: Implement local droop control when central communication is unavailable.
- -
- Fault Tolerance Mechanisms:
- Directory Facilitator (DF) agent enables dynamic task reassignment.
- Self-healing capabilities through agent redundancy.
- MAS Advantages:
- Scalability: Plug-and-play integration of new components through standardized agent registration.
- Resilience: Distributed architecture maintains operation during partial failures through autonomous agent behavior.
- Standards Compliance: IEEE 2030.5 and FIPA compatibility ensures interoperability with commercial DER equipment.
3. Methodology
3.1. Real-Time Simulation and HIL Architecture
- OPAL-RT Real-Time Simulator: The simulator hosts the microgrid model, which includes photovoltaic systems, wind turbines, energy storage systems (ESSs), and load types, developed in MATLAB Simulink. It conducts high-fidelity simulations with a time step of 50 µs, replicating dynamic grid behavior under variable conditions.
- Raspberry Pi 4B Edge Node: The Raspberry Pi serves as a communication bridge between the MGCC and the OPAL-RT simulator. It runs decentralized droop control algorithms during communication failures, enhancing the reliability and stability of the system.
- JADE Multi-Agent Platform (in Figure 4): Hosted on a desktop workstation, this platform supports the MGCC and the T-Cell optimization algorithm. It facilitates the coordination of distributed energy resources (DERs), ESSs, and loads through centralized and decentralized mechanisms. The microgrid model is partitioned into two subsystems for deployment on OPAL-RT (Figure 5).
- Master Subsystem: Handles power flow computations and DER control logic.
- Slave Subsystem: Manages user interfaces and secondary tasks.
3.2. Hardware and MGCC Integration
3.3. Smart Metering Infrastructure
- MQTT (Message Queuing Telemetry Transport): A lightweight publish–subscribe protocol for transmitting DER setpoints (e.g., active power commands, ESS charge/discharge schedules) and grid interaction signals.
- Modbus TCP: A robust protocol for reliable transmission of voltage and power measurements from local controllers to the MGCC.
3.4. Decentralized Droop Control
- A variable load with a continuous range up to 4 kW, emulating residential or commercial demand patterns.
- A controllable step load, programmable in discrete levels of 0 kW, 1.2 kW, 2.4 kW, and 3.6 kW, enabling stress testing of load-following capabilities and control responsiveness.
3.5. Testing Scenarios and Validation
- Renewable Intermittency: Sudden variations in solar and wind generation are introduced to test ESS responses and droop control stabilization. Metrics such as voltage deviation and ESS charge/discharge rates are analyzed to ensure stable operation.
- Load Surge: Test dynamic load-shedding capabilities and DER ramp rates. The system’s ability to maintain grid balance under high demand conditions is validated through power flow adjustments and coordinated responses.
4. Results and Discussion
- Dynamically adjust DER setpoints via MQTT/Modbus protocols.
- Maintain stability under variable generation/load conditions.
4.1. Dynamic Energy Management Under Renewable Intermittency
4.2. Voltage Stabilization via Droop Control
4.3. Voltage Profile Improvements
4.4. Grid Dependency Reduction
5. Conclusions and Future Perspectives
Author Contributions
Funding
Data Availability Statement
Acknowledgments
Conflicts of Interest
Abbreviations
DER | Distributed Energy Resources |
EMS | Energy Management System |
ESS | Energy Storage System |
GA | Genetic Algorithm |
HIL | Hardware-in-the-Loop |
ICS | Inequality Constraint Status |
JADE | Java Agent Development Framework |
MAS | Multi-Agent System |
MG | Microgrid |
MGCC | Microgrid Central Controller |
MILP | Mixed-Integer Linear Programming |
MQTT | Message Queuing Telemetry Transport |
OPAL RT | OPAL Real-Time Simulator |
PSO | Particle Swarm Optimization |
PV | Photovoltaic |
RES | Renewable Energy Sources |
SM | Smart Meter |
SOC | State of Charge |
TCO | T-Cell Optimization |
References
- Mays, J. Generator Interconnection, Network Expansion, and Energy Transition. IEEE Trans. Energy Mark. Policy Regul. 2023, 1, 410–419. [Google Scholar] [CrossRef]
- Billanes, J.D.; Jørgensen, B.N.; Ma, Z. A Framework for Resilient Community Microgrids: Review of Operational Strategies and Performance Metrics. Energies 2025, 18, 405. [Google Scholar] [CrossRef]
- Khosravi, N.; Çelik, D.; Bevrani, H.; Echalih, S. Microgrid Stability: A Comprehensive Review of Challenges, Trends, and Emerging Solutions. Int. J. Electr. Power Energy Syst. 2025, 170, 110829. [Google Scholar] [CrossRef]
- Gao, Z.; Li, W.; Chen, T. Study on Frequency Stability Control Strategies for Microgrid Based on Hybrid Renewable Energy. Sci. Technol. Energ. Transit. 2024, 79, 54. [Google Scholar] [CrossRef]
- Khan, B.; Singh, P. Selecting a Meta-Heuristic Technique for Smart Micro-Grid Optimization Problem: A Comprehensive Analysis. IEEE Access 2017, 5, 13951–13977. [Google Scholar] [CrossRef]
- Minh, N.Q.; Linh, N.D.; Khiem, N.T. A Mixed-Integer Linear Programming Model for Microgrid Optimal Scheduling Considering BESS Degradation and RES Uncertainty. J. Energy Storage 2024, 104, 114663. [Google Scholar] [CrossRef]
- Al Maruf, A.; Dubey, A.; Roy, S. Small-Signal Dynamics Analysis of Lossy Inverter-Based Microgrids with Generalized Droop Controls. Electronics 2024, 14, 2149. [Google Scholar] [CrossRef]
- Nair, R.P.; Ponnusamy, K. Modeling and Simulation of Autonomous DC Microgrid with Variable Droop Controller. Appl. Sci. 2025, 15, 5080. [Google Scholar] [CrossRef]
- Tang, J.; Liu, Z.; Wang, Y.; Chen, X. Advanced Control Strategies for Microgrids: A Comprehensive Review of Droop Control and Virtual Impedance Techniques. Processes 2024, 13, 54. [Google Scholar] [CrossRef]
- Abdelwanis, M.I.; Elmezain, M.I. A Comprehensive Review of Hybrid AC/DC Networks: Insights into System Planning, Energy Management, Control, and Protection. Neural Comput. Appl. 2024, 36, 17961–17977. [Google Scholar] [CrossRef]
- Khan, M.Y.A.; Liu, H.; Zhang, Y.; Wang, J. Hybrid AC/DC Microgrid: Systematic Evaluation of Interlinking Converters, Control Strategies, and Protection Schemes—A Review. IEEE Access 2024, 12, 160097–160132. [Google Scholar] [CrossRef]
- Baidya, S.; Nandi, C. A Comprehensive Review on DC Microgrid Protection Schemes. Electr. Power Syst. Res. 2022, 210, 108051. [Google Scholar] [CrossRef]
- Uddin, M.; Mo, H.; Dong, D.; Elsawah, S.; Zhu, J.M.; Guerrero, J.M. Microgrids: A Review, Outstanding Issues and Future Trends. Energy Strateg. Rev. 2023, 49, 101127. [Google Scholar] [CrossRef]
- Shirkhani, M.; Tavoosi, J.; Danyali, S.; Sarvenoee, A.K.; Abdali, A.; Mohammadzadeh, A.; Zhang, C. A Review on Microgrid Decentralized Energy/Voltage Control Structures and Methods. Energy Rep. 2023, 10, 368–380. [Google Scholar] [CrossRef]
- Arévalo, P.; Benavides, D.; Ochoa-Correa, D.; Ríos, A.; Torres, D.; Villanueva-Machado, C.W. Smart Microgrid Management and Optimization: A Systematic Review Towards the Proposal of Smart Management Models. Algorithms 2025, 18, 429. [Google Scholar] [CrossRef]
- El Hafiane, D.; El Magri, A.; Chakir, H.E.; Lajouad, R.; Boudoudouh, S. A Multi-Agent System Approach for Real-Time Energy Management and Control in Hybrid Low-Voltage Microgrids. Results Eng. 2024, 24, 103035. [Google Scholar] [CrossRef]
- Taha, M.Q.; Kurnaz, S. Droop Control Optimization for Improved Power Sharing in AC Islanded Microgrids Based on Centripetal Force Gravity Search Algorithm. Energies 2023, 16, 7953. [Google Scholar] [CrossRef]
- Aghaee, F.; Mahdian Dehkordi, N.; Bayati, N.; Hajizadeh, A. Distributed Control Methods and Impact of Communication Failure in AC Microgrids: A Comparative Review. Electronics 2019, 8, 1265. [Google Scholar] [CrossRef]
- Arbab-Zavar, B.; Palacios-Garcia, E.J.; Vasquez, J.C.; Guerrero, J.M. Message Queuing Telemetry Transport Communication Infrastructure for Grid-Connected AC Microgrids Management. Energies 2021, 14, 5610. [Google Scholar] [CrossRef]
- Pop, C.B.; Cioara, T.; Anghel, I.; Antal, M.; Chifu, V.R.; Antal, C.; Salomie, I. Review of Bio-Inspired Optimization Applications in Renewable-Powered Smart Grids: Emerging Population-Based Metaheuristics. Energy Rep. 2022, 8, 11769–11798. [Google Scholar] [CrossRef]
- Harmouch, F.Z.; Ebrahim, A.F.; Esfahani, M.M.; Krami, N.; Hmina, N.; Mohammed, O.A. An Optimal Energy Management System for Real-Time Operation of Multiagent-Based Microgrids Using a T-Cell Algorithm. Energies 2019, 12, 3004. [Google Scholar] [CrossRef]
- Wang, X.; Zhu, H.; Luo, X.; Chang, S.; Guan, X. A Novel Optimal Dispatch Strategy for Hybrid Energy Ship Power System Based on the Improved NSGA II Algorithm. Electr. Power Syst. Res. 2024, 232, 110385. [Google Scholar] [CrossRef]
- Mylonopoulos, F.; Polinder, H.; Coraddu, A. A Comprehensive Review of Modeling and Optimization Methods for Ship Energy Systems. IEEE Access 2023, 11, 32697–32707. [Google Scholar] [CrossRef]
- Shan, Y.; Ma, L.; Yu, X. Hierarchical Control and Economic Optimization of Microgrids Considering the Randomness of Power Generation and Load Demand. Energies 2023, 16, 5503. [Google Scholar] [CrossRef]
- El Qasery, M.; Mahir, O.; Laamim, M.; Rochd, A.; Barkouki, B.E.L.; Abbou, A. Approach to Real Time Simulation and Hardware in the Loop for Microgrid Battery Management Systems. In Digital Technologies and Applications; Alden, R.E., Lewis, D.D., Ionel, D.M., Eds.; Lecture Notes in Networks and Systems; Springer: Cham, Switzerland, 2024; Volume 1101, pp. 359–368. [Google Scholar] [CrossRef]
- Golestan, S.; Golmohamadi, H.; Sinha, R.; Iov, F.; Bak-Jensen, B. Real-Time Simulation and Hardware-in-the-Loop Testing Based on OPAL-RT ePHASORSIM: A Review of Recent Advances and a Simple Validation in EV Charging Management Systems. Energies 2024, 17, 4893. [Google Scholar] [CrossRef]
- Powell, J.; McCafferty-Leroux, A.; Hilal, W.; Gadsden, S.A. Smart Grids: A Comprehensive Survey of Challenges, Industry Applications, and Future Trends. Energy Rep. 2024, 11, 5760–5785. [Google Scholar] [CrossRef]
- IEEE 2030.5-2018; IEEE Standard for Smart Energy Profile Application Protocol. IEEE Standards Association: Piscataway, NJ, USA, 2018.
Method | Adaptability to Real-Time Changes | Constraint Handling | Convergence Speed | Memory Mechanism | Microgrid Suitability |
---|---|---|---|---|---|
Genetic Algorithm | Moderate | Moderate | Slow | No | Common, but slow in dynamic systems |
Particle Swarm Opt | Moderate | Weak | Fast | No | Good static optimization |
Immune Algorithm | Good | Good | Medium | Partial | Better adaptation, moderate complexity |
T-Cell algorithm (Proposed) | High | Strong (ECV + ICS) | Fast and stable | Yes | Ideal for adaptive microgrid EMS |
Component | Core Functionality | Microgrid Relevance |
---|---|---|
Agent Management System | Remote Management Agent | Ensures continuous operation during DER reconfiguration |
Directory Facilitator | Agent discovery and registration | Enables plug-and-play integration of new DERs/loads |
Remote Management Agent | Human–machine interface | Provides operator oversight and intervention capability |
Performance Metric | No Control | T-Cell Algorithm Only | T-Cell Algorithm Droop |
---|---|---|---|
Grid Energy Import (kWh) | 30.22 (100%) | 5.38 (17.7%) | 2.69 (8.8%) |
Self-Consumption Rate (%) | — | 82% | 93% |
Voltage Deviation Range (V) | ±9 V | ±5 V | ±3 V |
Voltage Fluctuation Reduction (%) | — | ~44% | 70% |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Boukaibat, A.; Krami, N.; Rochdi, Y.; El Bakkali, Y.; Laamim, M.; Rochd, A. Real-Time Energy Management in Microgrids: Integrating T-Cell Optimization, Droop Control, and HIL Validation with OPAL-RT. Energies 2025, 18, 4035. https://doi.org/10.3390/en18154035
Boukaibat A, Krami N, Rochdi Y, El Bakkali Y, Laamim M, Rochd A. Real-Time Energy Management in Microgrids: Integrating T-Cell Optimization, Droop Control, and HIL Validation with OPAL-RT. Energies. 2025; 18(15):4035. https://doi.org/10.3390/en18154035
Chicago/Turabian StyleBoukaibat, Achraf, Nissrine Krami, Youssef Rochdi, Yassir El Bakkali, Mohamed Laamim, and Abdelilah Rochd. 2025. "Real-Time Energy Management in Microgrids: Integrating T-Cell Optimization, Droop Control, and HIL Validation with OPAL-RT" Energies 18, no. 15: 4035. https://doi.org/10.3390/en18154035
APA StyleBoukaibat, A., Krami, N., Rochdi, Y., El Bakkali, Y., Laamim, M., & Rochd, A. (2025). Real-Time Energy Management in Microgrids: Integrating T-Cell Optimization, Droop Control, and HIL Validation with OPAL-RT. Energies, 18(15), 4035. https://doi.org/10.3390/en18154035