Energy Management of Grid-Connected Microgrids Using an Optimal Systems Approach

Microgrids (MGs) are a growing energy industry segment and represent a paradigm shift from remote central power plants to more localized distributed generation. Controlling MGs represents a challenge mainly due to their complexity and the different properties each asset in the MG has. Various methods have been proposed to address this challenging problem of MG control. Some of these methods are considered the optimal operation of MG assets. Other works are based on a systems approach and address the scalability and simplicity of synthesizing a MG’s energy management system (EMS). <inline-formula> <tex-math notation="LaTeX">$\varepsilon $ </tex-math></inline-formula>-variables based logical control strategies, which are practical methods to model control strategies in MGs, can make the control structure more scalable. However, this method is not optimal. On the other hand, Switched Model Predictive Control (S-MPC) is an advanced method utilized to control power systems while satisfying several constraints to achieve an optimal solution based on various criteria. Nevertheless, its implementation is not straightforward. Therefore, to overcome these existing problems, this paper proposes a novel systems approach method called an extended optimal <inline-formula> <tex-math notation="LaTeX">$\varepsilon $ </tex-math></inline-formula>-variable method developed by combining the <inline-formula> <tex-math notation="LaTeX">$\varepsilon $ </tex-math></inline-formula>-variable based control method with the S-MPC method. This unique method has demonstrated a significant improvement in optimizing an MG’s energy management and enhanced the adaptation and scalability of a control structure of the MG. Our results show that the proposed extended optimal <inline-formula> <tex-math notation="LaTeX">$\varepsilon $ </tex-math></inline-formula>-variable method: (i) reduces the operational cost of MG by nearly 35%; (ii) reduces the usage of the battery energy storage system by 42%, and (iii) enhances the practicality of photovoltaic (PV) usage by 28%. Our novel extended optimal <inline-formula> <tex-math notation="LaTeX">$\varepsilon $ </tex-math></inline-formula>-variable technique also increases the adaptation and scalability of the control structure of the MG significantly by translating the results of S-MPC to the <inline-formula> <tex-math notation="LaTeX">$\varepsilon $ </tex-math></inline-formula>-variable method.

Boolean variable that determines the requirement of using converter i. ε Gen i (k) Generic condition for converter i.
The state of converter i. L Av (k) Logical operator depending on the availability. L Req (k) Logical operator depending on the requirement. P PV (k) PV data generated from the PV [kW]. P LD (k) Load demand (for the building) [kW]. P net (k) The differences between PV and load data [kW]. SOAcc BAT (k) The state of the accumulator [%].

x(k)
The system-state vector. x a (k) The system-state vector with the assume dimension m 1 . u(k) The system-input vector. y(k) The system-output vector. A and B The components of the discrete-time linear state-space system. PV GR (k), P 1 (k) Power flows from the PV to the grid [kWh]. GR LD (k), P 2 (k) Power flows from the grid to the load [kWh]. PV LD (k), P 3

(k)
Power flows from the PV to the load [kWh]. PV BAT (k), P 4 (k) Power flows from the PV to the battery [kWh]. BAT LD (k), P 5 1 Positive weight coefficients for minimization energy consumption from the grid 1.0. w 2 Positive weight coefficients for encouragement the PV usage 0.2. w 3 Positive weight coefficients for penalization the battery usage 0.8. f ch and γ ch The constraints for the charging situation of the battery. f ch and γ ch The constraints for the charging situation of the battery. f dis and γ dis The constraints for the discharging situation of the battery.

U(k)
The predictive control vector.

II. INTRODUCTION
Due to their renewable and eco-friendly qualities, solar photovoltaic (PV) and wind turbine (WT) power generators are being integrated into microgrids (MGs) increasingly [1]. MG integrates various energy sources along with renewable energy sources (RESs) (PV panel, wind), energy storage systems (battery, hydrogen, pumped hydro (water)), diesel generators, and load and control devices [2]. In addition, a MG can schedule the load demand with demand response (DR) programs in order to maintain generation and demand 9908 VOLUME 11, 2023 balance. DR programs have the potential to alter customer load profiles [3]. This ability develops reliability and reduces energy expenditures in the MGs. For these reasons, the MG is regarded as an advanced power network topology [4].
Nevertheless, a MG has extra difficulties in controllability due to abrupt power changes in real-time operation, intermittent energy generation, and irregular energy consumption [5], [6]. The most critical challenges among these issues are to properly manage the power flow between the main grid and MGs: (i) the scalability and (ii) the optimal operation of MG assets with increases in the complexity of control frames [7]. Hence, a practical method is needed to ensure effective energy management.
On the other hand, in [8] it was first proposed, a new method to systematically model EMSs using a concept based on evolution operators and the state of the directed graph that represents the system. This method is based on the so-called ε-variables describing the evolution and hence the control approach of a multi-vector energy system [9]. The key to this approach is that a node represents every asset in the system, and every flow of energy and/or matter is defined by an edge between the nodes.
More specifically, according to [9], a hybrid energy system can be easily described using graph theory. In other words, energy systems can be illustrated in such a way as to simplify their analysis, operation, and management with the help of graph theory enhanced by using the evolution as mentioned above operators. This methodology says that any energy system comprises three main elements: flows, accumulators, and converters. The flows represent the flow of energy and/or matter, the accumulators accumulate energy or matter, and the converters convert energy/matter to energy/matter. Finally, the control statements operating the converters are the evolution operators describing the multi-vector system's EMS [10]. The scalability issue of the MG has been solved using the ε-variables method. However, this method is not optimal.
As shown in Table 1, several optimization and control algorithms have been presented to provide an optimal operation on the MGs. Besides, stochastic dynamic programming and optimization algorithms have been used by several authors [28], [29], [30], [31]. In order to minimize the overall losses in the distribution network, the operation of renewable energy systems has been optimized using the Cuckoo Search (CS) algorithm and the GOA [24]. In [16], distributed proximal primal-dual (PD) was utilized for the smooth optimization of a distributed energy management issue for responsive loads and distributed generators with transmission losses. A PD-based distributed algorithm with dynamic weights is presented to assign the various energy sources in order to achieve optimal energy management with tolerable operational costs and gas emissions. In addition, the suggested technique has lower computational complexity than distributed optimization algorithms [17]. The teaching learningbased optimization (TLBO) algorithm was employed to solve a multi-objective optimization problem that reduces costs and improves the MG's reliability. The findings demonstrated how energy storage system (ESS) charging and discharging can lower microgrid costs while enhancing system performance and reliability [25]. In [18], the simulation findings demonstrate the effectiveness of the master-slave (MS) peer-to-peer integration micro-grid control method based on communication in achieving stable functioning of the MG in grid-connected and islanded states as well as smooth switching between these two modes. Multi-commodity flow (MCF) and single-commodity flow (SCF) were utilized to provide flexible and adaptive operations for MG generation. This study demonstrated that, regardless of the difficulty of the optimization problem, MCF-based formulations and enumeration formulations are typically less effective [11]. For the best design of a hybrid renewable energy system (HRES), including PVs, WTs, and battery units, while minimizing the system's overall cost, the Particle Swarm Optimization (PSO) method has been incorporated [21].
On the other hand, S-MPC is a cutting-edge and more effective control scheme than traditional control strategies. Also, S-MPC has a fast transient response [6] since the leading role of S-MPC is to integrate new updated data and forecasts. By doing so, the S-MPC can make better decisions for the system's future demeanor using various constraints [27], [32], [33]. Besides, S-MPC can be effectively utilized in various ways to better control the MG system compared to the other control strategies. For instance, the understanding of S-MPC is straightforward and intuitive. It works by taking into consideration several constraints and uncertainties [26]. However, it is challenging to implement and modify it if the structure of the MG has changed during the operation due to a sudden change in the MG.
As shown in Table 1, although these optimization methods are optimal, some are neither scalable nor straightforward. This paper follows an advanced approach to produce a more systematic approach to bridge between the simplicity of implementation, scalability, and the optimal operation of the MG. The approach implements the combination of the ε-variable method and S-MPC while keeping the same advantages of the ε-variable method but making it more effective and robust using the S-MPC.
A novel extended optimal ε-variable technique is produced. With the help of this method: • The operational cost of the MG is decreased. • The practicality of renewable generator usage is encouraged.
• The adaptability and scalability with the changes in the MG structure are improved.
The rest of the paper is organized as follows: Section III presents the methodology of building optimal systems-based EMS of the MG. Section IV describes the MG used in this study and explains the steps to implement the proposed optimal method. The simulation results of the proposed EMS are discussed in Section V. Finally, Section VI outlines the conclusions and addresses future work.

III. METHODOLOGY OF BUILDING OPTIMAL SYSTEMS-BASED EMS OF A MG
The methodology of building the EMS of MG is composed of three main steps, as shown in Fig. 1. In the first step, the EMS will be built using a system approach method based on the MG specifications and the operational constraints of the MG. The system approach used in this paper is the ε-variable method [9], [34]. The output of the first step is a non-optimal EMS. In the second step, the obtained EMS will be used as input to generate the equivalent mathematical problem to meet optimally the objective(s) defined by the MG operators with considering the operational condition already included in the EMS obtained from Step 1. The optimal problem will be formulated in the form of S-MPC. After finding the optimal decisions in Step 2, these decisions will be embedded in the ε-variable based EMS in Step 3. The output of Step 3 will be hence the extended optimal ε-variablebased EMS. During the operational stage of the EMS, the MG specification and inputs from the MG operator will be checked at the beginning of each time step. If this information has been modified/changed, the operational states of the MG assets will be updated, and the three steps of the EMS building will be repeated to consider the new input. If not, the extended optimal ε-variable-based EMS can be used to control the MG for the next time step. Notably, the proposed method checks whether or not the system specifications/inputs of the MG operator change for the next time step.

IV. THE BUILDING OPTIMAL SYSTEM BASED EMS
This section will explain the three steps to build the optimal systems-based EMS using the simple MG shown in Fig. 2.
The MG system is composed of a 15 kW PV array, 21.6 kWh battery storage, a 5.4 kW diesel generator, and a utility grid [35].
A. STEP 1: BUILDING THE EMS USING ε-VARIABLE METHOD The hybrid power system where power can be considered as flow; the accumulator is the battery (BAT), and converters are the photovoltaic (PV) array, utility grid (GR), load (LD), and diesel generator (DG). The graph of that system suggests that the assets of the MG system can be divided into two sets, such as Rs Accumulator = {BAT } and Rs Converters = {PV , GR, LD, DG} [9]. The flow can be defined as the connection between two nodes: for instance, PV to BAT and BAT to LD. Hence the set of flow in this hybrid power system can be considered as: The evolution operator for the converters can be defined by three factors and symbolized by binary variables: ϵ Av i , ϵ Req i and ϵ Gen i . For our purpose, this evolution operator is the energy management approach utilised to control the microgrid and the principle of operation of the accumulator. As with dynamical systems, we need a different evolution operator for each state variable. The availability of energy relies upon the condition of the accumulators. In other words, the binary variable ϱ is 0 or 1 depending on the accumulators, as can be seen below [9]: where L Av and L Req are the logical operators 'and' or 'or,' while the general condition relies upon the condition of converters in general. The power flows are calculated by multiplying P net and (4).
The last step is to calculate the evolution operator for the accumulator: Depending on their working situation (activated or not), the converters are illustrated as:

B. STEP 2: SYSTEMATIC GENERATION OF THE EXTENDED OPTIMAL CONTROL PROBLEM USING S-MPC FORMULATION
The S-MPC method is applied after the implementation of the ε-variable method. Before the employment of the S-MPC, system-state, system-input, and system-output vectors are defined.
Let us start by defining the discrete-time linear state-space system [36]: where k = 0, 1, 2, . . . , T H -1 is the discrete-time instant, and x(k) ∈ X ⊆ R n and u(k) ∈ U ⊆ R m are the state and control vector, respectively. A ∈ R nxn is the state-system matrix and B ∈ R nxm is the input-system matrix. T H is the number of time instants. For the MG, system-control (input) vectors are energy consumption from the grid GR LD (k), (P 2 (k)); power flow from the PV to the load PV LD (k), (P 3 (k)); PV to the battery (charging) PV BAT (k), (P 4 (k)); battery to the load (discharging) BAT LD (k), (P 5 (k)). On the other hand, the system-output vectors are exported energy from PV to the grid PV GR (k), (P 1 (k)); the battery exploitation (charging and discharging situation) PV BAT (k)+BAT LD (k), (P 4 (k)+P 5 (k)); and the practical utilization of PV, PV LD (k)+ PV BAT (k), (P 3 (k) + P 4 (k)).
The system-state vector and system-control vector of the hybrid power system can be stated as follows: x a (k) = SOC(k) u(k) = [P 2 (k); P 3 (k); P 4 (k); P 5 (k)] where subscription ''a ′′ in the equations represents a matrix with assumed dimension m 1 . The dynamic process of the battery can be defined by: where b a = [0 0 η ch −η dis ]. Define the system-output vectors y a , y b , and y c : where c a = 0 and d a = [w 1 w 1 0 w 1 ]. From the definition of y a ; With respect to y b ; where c b = 0 and d b = [0 w 3 w 3 0]. To encourage the practicality of PV utilization, the definition of y b ; Regarding y c , where c c = 0 and d c = [0 0 w 2 w 2 ]. To increase the life cycle of the battery, the definition of y c ; Finally, the augmented system-state and the system output of the hybrid power system will be: The linear state-space can be defined according to the battery (22). In general, the linear state-space (11) can be represented as follows: Because of the dynamic equation of SOC in (22), the A and B in (11) will be:

1) THE INEQUALITIES CONSTRAINTS OF THE MG
The PV system is used to supply the load demand and charge the battery. It runs depending on several constraints at sampling time k, as follows: (27) Also, the sum energy for meeting the load demand and charging the battery should be equal or less to/than P PV as below: In addition, constraints related to the battery can be represented below: The utility grid is exploited to meet the load demand when the PV panel and the battery are insufficient. This is the last option because this scenario is more expensive and not environmentally friendly. The only advantage of its exploitation is to be available at any time except for blackout.
Moreover, the constraints related to the grid system and load can be written as follows:

2) OBJECTIVES FUNCTIONS OF THE MG
The cost functions of the MG are composed of three items which are: • To minimize the energy consumption from non-RES: • To increase the life cycle of the battery: • To maximize the practicality of the renewable energy usage:

C. STEP 3: TRANSLATING THE OPTIMAL CONTROL DECISIONS OF S-MPC TO ε-VARIABLES
The power flows are calculated by multiplying (13) and (4), and (21) and (4).
Then, another step is to estimate the evolution operator for the accumulator:

D. SUMMARY OF THE BUILDING THE EXTENDED OPTIMAL ε-VARIABLE METHOD
As illustrated in Fig. 3, the 'control decisions from the ε-variable method' exploited by the S-MPC technique as input data are initially obtained using the ε-variable method. The ''control decisions'' are PV GR , GR LD , PV LD , PV BAT , and BAT LD in Fig. 3. Then, the input (control), output, and state variables of the hybrid power system are re-calculated and optimized employing ''quadratic programming'' in S-MPC. It is vitally significant to note that charging and discharging are not permitted simultaneously. Therefore, the persistence of excitation is applied to the battery. Finally, the SOC of the battery and ''optimal control decisions'' are found and compared with the ''control decisions'' obtained by the ε-variable method. More specifically: To summarise, as shown in Fig. 3, the extended optimal ε-variable technique is composed of several steps: • The system specifications and operational conditions from the MG operator are read.
• Net energy (differences between the PV and the load data for 96 hours and 8760 hours) is calculated.
• The evolution operators and power flows for the PV, battery, load, and utility grid are calculated.
• The last step in the ε-variable method is the estimation of the SOAcc BAT .
• The first step in the extended optimal ε-variable technique is to assess the ''control decisions'' obtained using the ε-variable method.
• The A, B, u, x, and y matrices rely on the ''control decisions.'' • Then, the persistence of excitation is applied in order not to permit simultaneously the charging and discharging situations for the battery.
• The MG operation is optimized/simulated with the help of quadratic programming on MATLAB/Simulink on a Core TM i7 4500U (2.40GHz) computer, 8GB of RAM with Windows 10 Professional.
• All ''optimal control decisions'' are updated and compared with former ''control variables.'' • Regarding the section translating S-MPC results to ε-variables, the utility grid is removed, and the diesel generator is added. Then, the ''optimal control variables'' are updated for the ε-variable method as input data.
• Evolution operators and power flows are re-updated depending on the ''optimal control variables'' obtained from the S-MPC.
• The final step is to estimate and update the SOAcc BAT and power results and make the feedback control.

A. SIMULATION RESULTS OF THE EXTENDED OPTIMAL E -VARIABLE METHOD
Before the simulation, some parameters were defined, as shown in Table 2 [37], [38]. The PV array and load data for the simulation were obtained from the building in the UK for four days (96 hours) and one year (8760 hours) [39].
To see explicitly how to perform our method, the εvariables method is applied, and obtained the results as shown in Fig. 4. Then, ε-variable-S-MPC is applied and gets the results as shown in Fig. 5. From the results, (i) the energy consumption from the grid GR LD significantly decreased when compared to Fig. 4(a) and Fig. 5(a), (ii) the practicality of PV usage (PV GR and PV BAT ) is encouraged, (iii) the battery usage BAT LD is penalized. On the other hand, the state of charge of the battery is working at the desired conditions in Fig. 5(b) using the extended optimal ε-variable technique. After translating the results of S-MPC to ε-variable methods, the same results were obtained with the extended optimal εvariable technique.
Regarding the simulation for 8760 hours, as shown in Fig. 6, and Table 3, the overall energy consumption from the grid decreased from 2055 kWh to 1529 kWh. Besides, the energy usage from the PV (PV GR + PV BAT ) is encouraged from 2747.78 kWh to 3512.12 kWh. Lastly, the usage of the battery accounting for 2137.4 kWh and 1234.6 kWh for the ε-variable method and extended optimal ε-variable technique, respectively, is penalized in order to increase the battery life. All these results are expected and desired since the extended optimal ε-variable technique has optimization techniques.

B. THE ILLUSTRATING THE ADAPTABILITY AND SCALABILITY OF THE EXTENDED OPTIMAL ε-VARIABLE METHOD
To show how our structure gets more adaptable and scalable using our proposed method, some processes have been fulfilled (i) changing evolution operators and (ii) adding a diesel generator by standalone.

1) CHANGING EVOLUTION OPERATORS ON THE EXTENDED OPTIMAL ε-VARIABLE METHOD
In order to illustrate how our structure gets more adaptable and scalable, the evolution operator for the utility grid ε GR was changed by altering the logical operator from ''OR'' to ''AND.'' When the SOC gets below 50%, the S-MPC will import energy from the grid, as illustrated in Fig. 5(a).   However, there are cases where this may happen close to a point where the PV will produce enough power to compensate for the slight drop of SOC below 40%, increasing the system's autonomy from the main grid. So, in this case, and without changing the S-MPC structure, the evolution operator of the converter ''Grid'' will contain another term that will be logical 0 when it is anticipated that the PV will produce sufficient power in 1 or 2 samples. Since, in this work, this evolution operator uses the AND logical gate, when this new binary variable is 0, the evolution operator, ε GR will also be 0. Hence, the system will not import energy from the main grid, Fig. 7(a). Regarding the ε BAT , its binary variables (black line in Fig. 7(a)) are turned to 0 from 1 when the utility grid works for charging the battery (red line). In other words, in the case of lacking energy in the battery, the evolution operator of grid ε GR will turn 1 from 0. Therefore, ε GR→BAT runs, and the connection of GR BAT is active.

2) ADDING A DIESEL GENERATOR BY STANDALONE
During the second step (S-MPC section) in the extended optimal ε-variable technique, as shown in Fig. 3, a diesel  generator is added, the utility grid is removed, and updated the algorithm. PV GR and GR LD are excluded in this case, and DG LD is included. The ε-variables easily are adopted into the system and utilized for the hybrid power system in the case of an emergency case such as a blackout or imbalance load demand. The extended optimal ε-variable technique results illustrate that the load demand is met by the PV, battery, and diesel generator, respectively, as shown in Fig. 8. During the morning and afternoon, the PV meets the load demand (blue line). If there is excess energy from the PV, the battery is charged from the PV (pink line). The imbalance load is covered by the battery (black line) and diesel generator (red line). It is worth noting that the battery has not been charged (pink line) at all during the operation of the diesel generator (red line). The battery works at desired conditions, and the SOC of the battery values does not exceed the critical values. Our results illustrate that the adaptability/flexibility and scalability of the S-MPC have been increased with the help of the extended optimal ε-variable technique.

VI. CONCLUSION
There are several reasons to utilize the variable method to manage the MG power system; however, this method is not optimal. On the other hand, S-MPC has various optimization techniques and can predict power generation and consumption by employing cost functions and constraints. However, S-MPC implementation is not straightforward, especially in complex MG systems. To overcome the existing issues of e-variable and S-MPC methods, we developed an extended optimal ε-variable technique that effectively: (i) reduces the operational cost of MG by nearly 35%, (ii) reduces the usage of the battery energy storage system by 42%, and (iii) enhances the practicality of PV usage by 28%. The computation power of the new method is more or less similar (+2%) to that of the S-MPC. This extended optimal ε-variable, (i) optimized the existing ε-variable method, (ii) mitigated the complexity of the existing S-MPC implementation, and (iii) improved the scalability and adaptability of the S-MPC implementation significantly. The adaptability and scalability properties of the extended optimal ε-variable technique were enhanced by changing some evolution operators and adding a diesel generator. Therefore, the system's control is made more straightforward and optimal using the proposed extended technique. In future work, the scalability of the proposed method will be fully demonstrated on a real system built in Xanthi, Greece. It will employ fuel cells and electrolysers in order to have complete autonomy from the main grid. In this case, hydrogen and water tank can be considered accumulators, whereas fuel cells, electrolyzers, PVs, and so on can be conceived as converters. KABITA ADHIKARI received the B.Eng. degree in electronics and communication engineering from the Institute of Engineering, Pulchowk Campus, Tribhuvan University, Nepal, in 2004, the M.Sc. degree from Northumbria University, Newcastle upon Tyne, U.K., in 2007, and the Ph.D. degree from Newcastle University, Newcastle upon Tyne, in 2019. She is currently a Lecturer in signal processing and machine learning at the Electrical and Electronic Engineering Department, School of Engineering, Newcastle University. Her research interests include intelligent signal processing, machine learning, preventive and predictive modeling for biomedical applications, AI-enabled assistive health-care technologies, and robotics.
MANSOUREH ZANGIABADI received the Ph.D. degree in electrical power engineering from the School of Electrical and Electronic Engineering, University of Tehran, Iran, in 2012. She has more than 15 years of teaching, research, and industrial experience working in universities and companies in Iran, France, Norway, and the U.K. She is currently with the School of Engineering, Newcastle University, U.K., and a Lead Researcher at the Smart Energy Laboratory, Centre of Energy, Newcastle University. She designed and conducted the laboratory tests of E-Lobster Project, the EU Horizon 2020 Project, Smart Hub Project, and the Innovate U.K. Project. Her research interests include smarter solutions of future electricity gird (electrical battery storage, renewable energy resources, microgrids, demand side management), whole energy system roadmap of future (energy hub management), and smart mobility solutions (electrification of transport).
DAMIAN GIAOURIS received the B.Eng. degree in automation engineering from the Technological Educational Institute of Thessaloniki, Greece, in 2000, the M.Sc. and Ph.D. degrees in control of electrical systems from Newcastle University, U.K., in 2001 and 2004, respectively, and the B.Sc. and P.G.Cert. degrees in mathematics from the Open University, U.K., in 2009 and 2011, respectively. He is currently a Professor of control of electrical systems at Newcastle University. He has more than 150 publications (with more than 3500 citations). His research interests include control of power converters, multi-vector energy systems, smart grids, electric vehicles, and nonlinear dynamics of electrical systems. He has served as an Associate Editor for IET Power Electronics and the IEEE TRANSACTIONS ON CIRCUITS AND SYSTEMS-II: EXPRESS BRIEFS. He has also been a Guest Associate Editor of the IEEE JOURNAL ON EMERGING AND SELECTED TOPICS ON CIRCUITS AND SYSTEMS, among other journals. VOLUME 11, 2023