Next Article in Journal
Techniques of Control for Energy Optimization in Actuators, Motors, and Power Generation Systems
Previous Article in Journal
Total Internal Reflection End-Pumped Solar Laser with the Solar-to-Laser Conversion Efficiency of 6.09%
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Real-Time Energy Management in Microgrids: Integrating T-Cell Optimization, Droop Control, and HIL Validation with OPAL-RT

1
National School of Applied Sciences, Ibn Tofail University, Kenitra 14000, Morocco
2
Research Platform in Solar and Renewable Energies, Green Energy Park, Benguerir 43150, Morocco
*
Author to whom correspondence should be addressed.
Energies 2025, 18(15), 4035; https://doi.org/10.3390/en18154035
Submission received: 12 June 2025 / Revised: 18 July 2025 / Accepted: 28 July 2025 / Published: 29 July 2025

Abstract

Modern microgrids face critical challenges in maintaining stability and efficiency due to renewable energy intermittency and dynamic load demands. This paper proposes a novel real-time energy management framework that synergizes a bio-inspired T-Cell optimization algorithm with decentralized voltage-based droop control to address these challenges. A JADE-based multi-agent system (MAS) orchestrates coordination between the T-Cell optimizer and edge-level controllers, enabling scalable and fault-tolerant decision-making. The T-Cell algorithm, inspired by adaptive immune system dynamics, optimizes global power distribution through the MAS platform, while droop control ensures local voltage stability via autonomous adjustments by distributed energy resources (DERs). The framework is rigorously validated through Hardware-in-the-Loop (HIL) testing using OPAL-RT, which interfaces MATLAB/Simulink models with Raspberry Pi for real-time communication (MQTT/Modbus protocols). Experimental results demonstrate a 91% reduction in grid dependency, 70% mitigation of voltage fluctuations, and a 93% self-consumption rate, significantly enhancing power quality and resilience. By integrating centralized optimization with decentralized control through MAS coordination, the hybrid approach achieves scalable, self-organizing microgrid operation under variable generation and load conditions. This work advances the practical deployment of adaptive energy management systems, offering a robust solution for sustainable and resilient microgrids.

1. Introduction

Microgrids, localized energy networks integrating renewable energy sources (RESs) such as solar and wind, have emerged as key components of the global energy transition [1]. They enhance grid resilience, reduce reliance on fossil fuels, and improve access to electricity in remote or underserved regions [2]. However, their operational efficiency is challenged by the inherent intermittency of RESs generation and dynamic load demands, which collectively impact voltage/frequency profiles and increase dependency on the main grid [3,4].
Existing energy management strategies for microgrids broadly fall into two categories: centralized optimization and decentralized control. Centralized approaches, such as Mixed-Integer Linear Programming (MILP) and metaheuristic algorithms (e.g., Genetic Algorithms, Particle Swarm Optimization), prioritize global cost minimization but often suffer from high computational latency and communication bottlenecks, limiting their real-time adaptability [5,6]. Conversely, decentralized strategies like droop control enable distributed energy resources (DERs) to autonomously adjust power outputs based on local voltage/frequency measurements, ensuring rapid stabilization during disturbances [7,8]. However, these methods lack system-wide coordination, often leading to suboptimal energy allocation and operational inefficiencies [9].
Despite the wide adoption of distributed systems in microgrid architectures, their classification criteria remain inconsistent across the technical literature and research institutions. Some studies emphasize the nature of energy sources (renewable vs. dispatchable), while others categorize systems based on control strategies (centralized, decentralized, or hybrid) or power flow topology (AC, DC, or hybrid microgrids) [10,11,12]. These divergent perspectives complicate the standardization of system design and evaluation, highlighting the need for a consistent and unified taxonomy [13].
Recent hybrid frameworks attempt to bridge this gap by combining centralized and decentralized paradigms, but many adopt fragmented architectures that fail to harmonize global optimization with local responsiveness [14,15]. For instance, multi-agent systems (MASs) optimize DER coordination at the central layer but overlook real-time voltage regulation [16], while standalone droop control stabilizes local voltages without holistic cost optimization [17].
To address these limitations, this work proposes a hierarchical three-layer control architecture that unifies centralized intelligence with decentralized adaptability. At the base layer, the Local Control Layer employs droop-controlled DERs to autonomously stabilize voltages during communication failures or sudden load changes [18]. The intermediate smart metering infrastructure facilitates bidirectional data exchange between edge devices and the central controller using lightweight protocols (MQTT/Modbus), ensuring real-time coordination [19]. At the apex, the Microgrid Central Controller (MGCC) hosts a bio-inspired T-Cell optimization algorithm, which mimics immune system adaptation through proliferation (replicating high-performance solutions) and differentiation (introducing variation through mutation) to dynamically allocate DER setpoints and grid interactions [20,21].
Furthermore, recent research has explored the integration of distributed energy management strategies in shipboard hybrid power systems, which face similar challenges such as dynamic load variability, space constraints, and resilience under fault conditions. For instance, NSGA-II-based dispatch strategies have shown promising results in optimizing hybrid marine energy systems by balancing fuel consumption, emissions, and power quality [22,23]. These marine applications underscore the broader relevance of adaptive energy control methods like the one proposed in this study.
This architecture introduces three key innovations: first, the T-Cell algorithm leverages immune memory mechanisms to rapidly adapt to RESs fluctuations, outperforming conventional PSO/GA in nonlinear and dynamic environments. Second, the layered framework resolves the centralized–decentralized trade-off, enabling concurrent global cost optimization and local stability [24]. Third, the system is rigorously validated via HIL testing using OPAL-RT OP5707XG, MATLAB/Simulink R2022b, and Raspberry Pi 4B, demonstrating seamless integration between real-time control, optimization, and communication [25,26].
Experimental results (Section 4) show that this hierarchical architecture reduces grid dependency by 91% and voltage fluctuations by 70% compared to forecast-driven baselines [3], achieving a 93% self-consumption rate. These advancements provide a scalable blueprint for adaptive microgrids, aligning with smart grid interoperability standards and decentralized energy trends [27].
The main objectives of this research are as follows:
  • 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.
The remainder of this paper is organized as follows: Section 2 presents the theoretical foundation, including the hierarchical control architecture, the T-Cell optimization algorithm, and the integration of JADE for multi-agent coordination. Section 3 describes the methodology, focusing on the real-time HIL validation using OPAL-RT and Raspberry Pi-based control implementation. Section 4 analyzes the results, demonstrating the effectiveness of the proposed approach in optimizing energy management and improving microgrid stability. Finally, Section 5 concludes the paper and suggests future research directions.

2. Theoretical Foundation

This section presents the theoretical pillars of the proposed microgrid framework, focusing on its hierarchical control structure, bio-inspired optimization techniques, and decentralized control mechanisms. By integrating the T-Cell algorithm—a centralized optimization strategy modeled after immune system dynamics—with decentralized voltage-based droop control, the framework achieves a balance between system-wide coordination and localized adaptability. This hybrid design ensures scalability, resilience during communication failures, and real-time responsiveness to fluctuating renewable generation and variable loads.

2.1. Hierarchical Three-Layer Architecture

The proposed microgrid control framework adopts a hierarchical architecture to balance centralized optimization with decentralized adaptability. As illustrated in Figure 1, the system is structured into three layers:

2.1.1. Central Layer (MGCC)

The MGCC operates as the brain of the microgrid, executing the T-Cell optimization algorithm to coordinate distributed energy resources (DERs), storage systems, and loads. Hosted on the JADE multi-agent platform, the 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.
During communication failures, the MGCC delegates control to local layers, ensuring uninterrupted operation.

2.1.2. Communication Layer

The hierarchical architecture integrates a smart metering infrastructure to enable real-time coordination between centralized and decentralized control. At the Local Layer, smart meters (SMs) collect voltage and power measurements from DERs, loads, and ESS. These SMs communicate with an LV concentrator/manager, which bridges the Local Layer (Modbus TCP) and Central Layer (MQTT), ensuring compliance with IEEE 2030.5 smart grid standards [28]. This design ensures reliable data exchange and fault tolerance during communication outages.

2.1.3. Local Layer

At the network edge, local controllers enable autonomous operation during disturbances or communication outages through voltage-based droop control and adaptive load management. Key components include
  • 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.
Droop-Controlled DERs: The microgeneration controllers serve as the interface between renewable energy units and the microgrid architecture. These inverters regulate active power based on reference setpoints provided by the MGCC, enabling both power limitation and local voltage support through P-V droop functionality as illustrated in Figure 2. The voltage-based droop control mechanism enables inverters to autonomously adjust their output power in response to voltage deviations. When the voltage exceeds the predefined deadband, the output power is reduced accordingly. In contrast, when the voltage falls below the deadband threshold, the power output increases when sufficient capacity exists. This operational behavior is governed by the droop equation.
P o u t = P r e f + K v V s e t V m e a s u r e d             i f   V s e t V m e a s u r e d > Δ V d e a d b a n d P r e f                                                     i f   V s e t V m e a s u r e d < Δ V d e a d b a n d
where
  • 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.
ΔVdeadband is the voltage deviation threshold within which the power output remains constant. Active power control has to be implemented considering the different microgeneration technologies. For the PV panels, active power variations are achieved by modifying the maximum power point tracking algorithm, thus temporally degrading the efficiency of the PV panels. In the case of the micro-WT inverter, a dump load is used to dissipate the power surplus that cannot be accommodated by the LV grid.
Load Controllers: The Load Controller (LC) manages controllable loads using a step-based approach (0 W, 1200 W, 2400 W, 3600 W), offering finer granularity than traditional on/off switching. It adjusts load consumption based on real-time voltage and generation data from power analyzers. The LC integrates with smart meters for remote control, enabling dynamic optimization. This enhances flexibility, improves voltage stability, and ensures efficient energy usage while preserving user comfort and system resilience.
Energy Storage Systems (ESS): ESS plays a vital role in voltage regulation by automatically transitioning between charging and discharging. During overvoltage, the ESS absorbs power; during under voltage, it injects power to stabilize the system. This autonomous switching maintains network stability without relying on constant central supervision.
In parallel to the decentralized mechanisms detailed above, global coordination is handled via a bio-inspired optimization strategy—the T-Cell algorithm—which is presented in the following section.

2.2. T-Cell Optimization Algorithm

The integration of bio-inspired optimization methods into energy management systems (EMSs) is gaining popularity due to their ability to manage nonlinear, constrained optimization problems. However, classical methods such as GA and PSO often struggle in real-time, dynamic microgrid environments.
To overcome these issues, this work proposes a T-Cell optimization algorithm, modeled after the adaptive immune response, enabling fast convergence, robust constraint handling, and real-time adaptability under fluctuating RESs and load profiles.

2.2.1. Comparative Evaluation of Bio-Inspired Optimization Techniques

Table 1 provides a comparative overview of the main characteristics of conventional bio-inspired optimization techniques and the proposed T-Cell algorithm in the context of real-time microgrid energy management.
The T-Cell algorithm stands out due to
  • 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

The proposed T-Cell optimization algorithm is inspired by how biological T-cells identify and respond to pathogens by evolving dynamically over time. This bio-inspired mechanism is well suited to manage distributed energy resources (DERs) in highly variable microgrid environments.
Translating this into 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).
The T-Cell optimization algorithm follows the steps illustrated in Figure 3, as detailed below:
Population Initialization: Generate an initial set of solutions (T-cells) randomly within feasible DER operational limits. Example: Initial setpoints for PV inverters (0–5 kW) and ESS charge rates (0–2 kW).
  • 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.
Selection: Retain the best solutions for the next generation based on fitness. The optimization problem is formulated as follows:
C o s t = t = 1 T ( C t · P t + λ · E C V + μ   ·   I C S )
where
  • 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

The proposed EMS leverages a JADE-based MASs to harmonize centralized optimization (T-Cell algorithm) and decentralized control (droop control). The MASs adheres to IEEE FIPA standards, ensuring interoperability with industrial DERs and smart meters.
  • 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.
The operational workflow of this MAS implementation is detailed in Section 3.4.

3. Methodology

This study outlines an experimental framework designed to validate the hierarchical microgrid control system. The methodology integrates HIL simulations, edge computing, and real-time communication protocols to rigorously test the integration of the T-cell optimization algorithm and decentralized droop control strategies. By combining these elements, the framework ensures a robust and scalable system capable of mitigating renewable interference, maintaining grid stability, and improving operational resilience.

3.1. Real-Time Simulation and HIL Architecture

The validation platform is built on three core components, as illustrated in Figure 4:
  • 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.
Real-time C code is generated from the Simulink model and deployed on OPAL-RT CPUs, ensuring seamless execution and accurate simulation.

3.2. Hardware and MGCC Integration

To enable dynamic and adaptive microgrid management, the proposed architecture integrates both hardware-level communication protocols and centralized intelligence through the MGCC, implemented on the JADE multi-agent platform.
Hosted on a desktop workstation, the MGCC executes the T-Cell optimization algorithm, coordinating DERs and ESSs to minimize grid dependency while ensuring stability. It continuously updates optimization strategies using real-time data from the smart metering infrastructure and forecasts of generation and consumption patterns. Figure 6 illustrates the data flow between the MGCC, Raspberry Pi, and OPAL-RT components, emphasizing the integration of optimization logic with real-time simulation and decentralized fallback.

3.3. Smart Metering Infrastructure

The smart metering infrastructure was implemented to enable real-time coordination between the hierarchical control layers. The communication layer leverages two standardized protocols for bidirectional data exchange:
  • 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.
A Raspberry Pi 4B serves as both a smart meter emulator and an edge gateway, hosting the LV concentrator/manager software. It performs real-time protocol translation between Modbus TCP (local layer) and MQTT (central layer), while also ensuring the bidirectional flow of control commands and measurement data between the MGCC and the microgrid. This setup guarantees low-latency communication, with data exchanged at 100 ms intervals to maintain system responsiveness
Figure 7 presents the detailed architecture of real-time communication between the OPAL-RT simulator, Raspberry Pi 4B, and the MGCC running the JADE platform.
To address potential communication delays that could affect system synchronization and control responsiveness, several mitigation strategies have been integrated. First, MQTT was selected for its lightweight architecture and reduced overhead, which minimizes latency. Second, time-synchronized exchanges at fixed intervals ensure consistent data flow. Third, local controllers implement autonomous fallback strategies—such as droop control and short-term setpoint buffering—to maintain voltage stability even during temporary communication outages. These measures collectively enhance the robustness and fault tolerance of the energy management framework.
To ensure fault tolerance, the infrastructure integrates adaptive control mechanisms. For instance, during sudden solar generation drops, voltage deviations detected by the simulated smart meters trigger dynamic recalibration of ESS discharge rates via the MGCC, thus preventing system instability.

3.4. Decentralized Droop Control

Figure 8 illustrates the measurement and data acquisition architecture implemented within the OPAL-RT HIL simulation. Electrical quantities such as voltage, current, and power are continuously monitored using virtual sensors embedded in the Simulink-based microgrid model.
These measurements are exchanged internally via OpComm blocks and recorded using the OpWriteFile block at 100 ms intervals. The recorded data includes voltage deviations, DER power outputs, and ESS activity, providing high-resolution insight into local controller behavior.
All control decisions—such as power regulation through droop mechanisms—are executed locally, based on real-time measurements, without dependence on centralized supervision.
The logged datasets are used for post-simulation analysis, enabling the evaluation of voltage stability, control responsiveness, and coordination efficiency under decentralized operation.
The experimental microgrid setup comprises multiple distributed energy resources (DERs) and programmable loads to evaluate real-time control strategies under dynamic operating conditions. The generation units include a 3 kW photovoltaic (PV) emulator and a 3 kW wind emulator, both interfaced with power electronic converters for flexible dispatch. A lead–acid battery energy storage system (ESS) with a 2 kWh capacity and a maximum charge/discharge rate of 2 kW is integrated to support frequency regulation and energy balancing.
On the demand side, the system incorporates two types of loads:
  • 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

The HIL platform evaluates the microgrid control system under two primary scenarios,
  • 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

This section validates the hierarchical microgrid framework’s efficacy through real-time simulations, demonstrating its ability to optimize energy management, stabilize voltage, and reduce grid dependency. The results are structured to highlight the interplay between the T-Cell optimization algorithm and decentralized droop control, as well as their combined impact on microgrid resilience.
The interaction between the OPAL-RT simulator, Raspberry Pi, and control algorithms (Figure 9) validates the framework’s ability to
  • Dynamically adjust DER setpoints via MQTT/Modbus protocols.
  • Maintain stability under variable generation/load conditions.

4.1. Dynamic Energy Management Under Renewable Intermittency

Figure 10 illustrates the microgrid’s 24 h operation under variable renewable generation. During the first six hours, wind turbines fully supply the load, with surplus energy stored in batteries. At the sixth hour, wind generation peaks at 3 kW, and the T-Cell algorithm prioritizes local consumption by allocating 1.2 kW to controllable loads instead of exporting excess energy to the grid. As wind generation decreases around the seventh hour, controllable loads are shed to balance supply and demand. When solar generation commences, the algorithm incrementally activates controllable loads (1.2 kW → 3.6 kW), demonstrating adaptive load management. During peak demand, the microgrid supplements DERs with grid imports only after exhausting battery capacity (2 kW).
This dynamic coordination reduces grid dependency by 91%, achieving a 93% self-consumption rate—a significant improvement over forecast-driven baselines.
The forecast-driven baseline refers to an energy management method where the setpoints of energy resources are determined based on day-ahead forecasts of generation and consumption. No real-time updates or adaptive controls are applied during operation.

4.2. Voltage Stabilization via Droop Control

Figure 11 highlights the role of the decentralized droop control strategy in maintaining voltage stability. During the first five hours, the voltage remains within acceptable bounds without active droop control. At the fifth hour, a surge in wind generation causes voltage deviations, triggering droop control at the wind turbine to curtail output. By the seventh hour, residual voltage margins from solar generation activate PV droop control, ensuring sustained stability.
The droop mechanism autonomously regulates voltage within ±3% of the nominal value (230 V), even during communication outages. Deadband thresholds (ΔV deadband = ±3%) prevent oscillations during minor fluctuations, while ESS coordination (charging during overvoltage, discharging during under voltage) mitigates transient instabilities.

4.3. Voltage Profile Improvements

A comparative analysis of voltage profiles with and without control is shown in Figure 12 and Figure 13. In the uncontrolled system (Figure 12), voltage fluctuates between 216 V and 235 V during load/generation swings, highlighting risks of instability. In contrast, the hybrid framework (Figure 13) limits deviations to ±3 V through the combined action of the T-Cell algorithm and droop control. This represents a 70% reduction in voltage fluctuations, demonstrating the ability of the framework to improve power quality under dynamic conditions.

4.4. Grid Dependency Reduction

To further illustrate the benefits of the proposed hybrid EMS, Table 2 summarizes key performance indicators across three scenarios: without any control, with only the T-Cell optimization algorithm, and with the integrated T-Cell algorithm and droop control framework.
The results presented in Table 3 clearly demonstrate a 91% reduction in grid energy dependency, a 70% mitigation of voltage fluctuations with a margin of error of ±3.1%, and a 93% self-consumption rate when using the full framework. These findings are consistent with Figure 10, Figure 11, Figure 12, Figure 13 and Figure 14 and substantiate the quantitative claims made in the abstract.
This Figure 15 compares the energy exchanged with the main grid for three configurations—no control, T-Cell optimization algorithm only, and hybrid control (T-Cell algorithm+ droop). A significant reduction from 30.22 kWh to 2.69 kWh is observed in the hybrid case, confirming the system’s ability to reduce grid dependency by over 90% with a standard deviation of ±2.7%.

5. Conclusions and Future Perspectives

This paper describes an extensive framework that integrates advanced optimization and voltage-based droop control for better energy management in microgrids. They bring about real-time simulation on OPAL-RT HIL-based tests, by way of which the proposed system serves as the interface between theoretical modeling and practical implementation. Experimental results demonstrate the framework’s effectiveness, achieving a 91% reduction in grid dependency, a 70% reduction in voltage fluctuations, and a 93% self-consumption rate. The results of this study demonstrated the efficiency of using the T-Cell optimization algorithm along with droop control to achieve the primary objectives of microgrids. The optimization algorithm was proved to be capable of reducing the dependency on the grid as well as energy costs and improving self-consumption by coordinating dynamically distributed energy resources (DERs) and controllable loads. This, when integrated with droop control, also produced visible results in terms of voltage stability and energy quality.
Furthermore, the modular architecture of the proposed system ensures high scalability. The JADE-based MAS enables plug-and-play integration of additional DERs and loads through agent-based registration and coordination. MQTT protocol facilitates lightweight and efficient communication across a growing number of components, while droop control allows new DERs to operate autonomously. This design supports seamless expansion of the microgrid with minimal reconfiguration.
However, certain limitations remain, such as computational complexity and dependency on communication reliability, which may affect deployment in constrained environments. For very large-scale systems, future enhancements may include hierarchical agent clustering and distributed MGCC nodes to preserve performance. Work in this context would include an extension of this framework to large, complex systems and incorporation of machine learning techniques for predictive control to provide adaptiveness and the efficiency of microgrid operations. Moreover, the incorporation of machine learning techniques for predictive control represents a promising direction. For instance, reinforcement learning and deep neural networks could be employed to forecast short-term load demand and renewable energy profiles, allowing anticipatory adjustment of DER dispatch.

Author Contributions

A.B.: led the conceptualization, methodology, software development, validation, formal analysis, investigation, data curation, and original draft preparation. N.K.: contributed to conceptualization, methodology, supervision, review/editing of the manuscript, visualization, and project administration. Y.R.: assisted in methodology, investigation, supervision, and review/editing. Y.E.B.: participated in validation and review/editing. M.L.: provided software support, resources, and visualization. A.R.: provided software support, resources, and visualization. All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Data Availability Statement

All data generated or analyzed during this study are included in this published article. Additional simulation files are available from the corresponding author upon request.

Acknowledgments

The work presented in this paper was funded by the Moroccan Research Institute for Solar Energy and New Energies (IRESEN) under the HOLSYS project. The experimental tests were conducted at the Green Energy Park Laboratory, Benguerir, Morocco.

Conflicts of Interest

The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.

Abbreviations

The following abbreviations are used in this manuscript:
DERDistributed Energy Resources
EMSEnergy Management System
ESSEnergy Storage System
GAGenetic Algorithm
HILHardware-in-the-Loop
ICSInequality Constraint Status
JADEJava Agent Development Framework
MASMulti-Agent System
MGMicrogrid
MGCCMicrogrid Central Controller
MILP Mixed-Integer Linear Programming
MQTTMessage Queuing Telemetry Transport
OPAL RT OPAL Real-Time Simulator
PSOParticle Swarm Optimization
PVPhotovoltaic
RESRenewable Energy Sources
SMSmart Meter
SOCState of Charge
TCOT-Cell Optimization

References

  1. Mays, J. Generator Interconnection, Network Expansion, and Energy Transition. IEEE Trans. Energy Mark. Policy Regul. 2023, 1, 410–419. [Google Scholar] [CrossRef]
  2. 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]
  3. 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]
  4. 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]
  5. 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]
  6. 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]
  7. 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]
  8. Nair, R.P.; Ponnusamy, K. Modeling and Simulation of Autonomous DC Microgrid with Variable Droop Controller. Appl. Sci. 2025, 15, 5080. [Google Scholar] [CrossRef]
  9. 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]
  10. 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]
  11. 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]
  12. Baidya, S.; Nandi, C. A Comprehensive Review on DC Microgrid Protection Schemes. Electr. Power Syst. Res. 2022, 210, 108051. [Google Scholar] [CrossRef]
  13. 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]
  14. 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]
  15. 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]
  16. 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]
  17. 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]
  18. 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]
  19. 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]
  20. 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]
  21. 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]
  22. 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]
  23. 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]
  24. 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]
  25. 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]
  26. 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]
  27. 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]
  28. IEEE 2030.5-2018; IEEE Standard for Smart Energy Profile Application Protocol. IEEE Standards Association: Piscataway, NJ, USA, 2018.
Figure 1. Hierarchical three-layer architecture.
Figure 1. Hierarchical three-layer architecture.
Energies 18 04035 g001
Figure 2. P-V droop for the microgeneration units.
Figure 2. P-V droop for the microgeneration units.
Energies 18 04035 g002
Figure 3. Flowchart of the T-Cell optimization algorithm used for microgrid energy management.
Figure 3. Flowchart of the T-Cell optimization algorithm used for microgrid energy management.
Energies 18 04035 g003
Figure 4. Integration of the T-Cell algorithm with OPAL-RT for real-time microgrid optimization and control.
Figure 4. Integration of the T-Cell algorithm with OPAL-RT for real-time microgrid optimization and control.
Energies 18 04035 g004
Figure 5. Architecture of master and console subsystems in the RT-LAB simulation environment.
Figure 5. Architecture of master and console subsystems in the RT-LAB simulation environment.
Energies 18 04035 g005
Figure 6. Data exchange between Java optimization and OPAL-RT system via Raspberry PI.
Figure 6. Data exchange between Java optimization and OPAL-RT system via Raspberry PI.
Energies 18 04035 g006
Figure 7. Real-time communication architecture: OPAL-RT simulator, Raspberry Pi 4B, and the MGCC.
Figure 7. Real-time communication architecture: OPAL-RT simulator, Raspberry Pi 4B, and the MGCC.
Energies 18 04035 g007
Figure 8. Microgrid architecture with measurement and data acquisition.
Figure 8. Microgrid architecture with measurement and data acquisition.
Energies 18 04035 g008
Figure 9. Advanced EMS: real-time control and management of microgrids using OPAL-RT, T-Cell algorithm, multi-agent systems, and Raspberry Pi.
Figure 9. Advanced EMS: real-time control and management of microgrids using OPAL-RT, T-Cell algorithm, multi-agent systems, and Raspberry Pi.
Energies 18 04035 g009
Figure 10. Dynamic Operation of the Microgrid Under Variable Renewable Generation Over a 24-H Period.
Figure 10. Dynamic Operation of the Microgrid Under Variable Renewable Generation Over a 24-H Period.
Energies 18 04035 g010
Figure 11. Simulation Results of Raspberry Pi Based Power Microgeneration, Load Management, Droop Control, and Voltage Regulation.
Figure 11. Simulation Results of Raspberry Pi Based Power Microgeneration, Load Management, Droop Control, and Voltage Regulation.
Energies 18 04035 g011
Figure 12. Voltage profile without control.
Figure 12. Voltage profile without control.
Energies 18 04035 g012
Figure 13. Voltage profile after control with voltage-based droop control and T-Cell optimization algorithm.
Figure 13. Voltage profile after control with voltage-based droop control and T-Cell optimization algorithm.
Energies 18 04035 g013
Figure 14. Impact of different control strategies on microgrid interaction with the main grid: without control, with optimization algorithm, and with optimization and droop control.
Figure 14. Impact of different control strategies on microgrid interaction with the main grid: without control, with optimization algorithm, and with optimization and droop control.
Energies 18 04035 g014
Figure 15. Impact of control strategies on microgrid efficiency with main grid interaction.
Figure 15. Impact of control strategies on microgrid efficiency with main grid interaction.
Energies 18 04035 g015
Table 1. Comparative analysis of bio-inspired optimization techniques for microgrid energy management.
Table 1. Comparative analysis of bio-inspired optimization techniques for microgrid energy management.
MethodAdaptability to Real-Time ChangesConstraint HandlingConvergence SpeedMemory MechanismMicrogrid Suitability
Genetic AlgorithmModerateModerateSlowNoCommon, but slow in dynamic systems
Particle Swarm OptModerateWeakFastNoGood static optimization
Immune AlgorithmGood GoodMediumPartialBetter adaptation, moderate complexity
T-Cell algorithm (Proposed)HighStrong (ECV + ICS)Fast and stableYesIdeal for adaptive microgrid EMS
Table 2. JADE architecture components.
Table 2. JADE architecture components.
ComponentCore FunctionalityMicrogrid Relevance
Agent Management SystemRemote Management AgentEnsures continuous operation during DER reconfiguration
Directory FacilitatorAgent discovery and registrationEnables plug-and-play integration of new DERs/loads
Remote Management AgentHuman–machine interfaceProvides operator oversight and intervention capability
Table 3. Performance comparison of energy management strategies.
Table 3. Performance comparison of energy management strategies.
Performance MetricNo ControlT-Cell Algorithm OnlyT-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.

Share and Cite

MDPI and ACS Style

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

AMA Style

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 Style

Boukaibat, 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 Style

Boukaibat, 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

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop