Intelligent Type-2 Fuzzy Logic Controller for Hybrid Microgrid Energy Management with Different Modes of EVs Integration

: The rapid integration of renewable energy sources (RES) and the electrification of transportation have significantly transformed modern energy infrastructures, emphasizing the need for efficient and flexible energy management systems. This study presents an intelligent, variable-fed, Type-2 Fuzzy Logic Controller (IT2FLC) designed for optimal management of Hybrid Microgrid (HMG) energy systems, specifically considering different modes of Electric Vehicles (EVs) integration. The necessity of this study arises from the challenges posed by fluctuating renewable energy outputs and the uncoordinated charging practices of EVs, which can lead to grid instability and increased operational costs. The proposed IT2FLC is based on comprehensive mathematical modeling that captures complex interactions among HMG components, including Doubly Fed Induction Generator (DFIG) units, photovoltaic (PV) systems, utility AC power, and EV batteries. Utilizing a yearly dataset for simulation, this work examines the HMG’s flexibility and adaptability under dynamic conditions managed by the proposed intelligent controller. A Simulink-based model is built for this study to replicate the dynamical operation of the HMG and test the precise and real-time decision-making capability of the proposed IT2FLC. The results demonstrate the IT2FLC’s superior performance, achieving a substantial cost avoidance of nearly $3,750,000 and efficient energy balance, affirming its potential to sustain optimal energy utilization under stochastic conditions. Additionally, the results attest that the proposed IT2FLC significantly enhances the resilience and economic feasibility of hybrid microgrids, achieving a balanced energy exchange with the utility grid and efficient utilization of EV batteries, proving to be a superior solution for optimal operation of hybrid grids.


Introduction
As energy infrastructures undergo significant restructuring to accommodate the shifting dynamics of the energy landscape, marked by the incorporation of renewable energy sources (RES) and the electrification of transportation, hybrid microgrids (HMGs) are emerging as central components in the evolution towards smarter, cleaner grids [1,2].In contrast to traditional large-scale energy grids, HMGs offer a more reliable and efficient electricity supply with reduced carbon emissions.HMGs also exhibit greater flexibility than conventional power grids, possessing the capability to swiftly adapt their power output.Defined as active agents within a low-voltage network, HMGs can function in both grid-connected and islanded modes [3].Nevertheless, the variability of RES and challenges posed by the extensive integration of Electric Vehicles (EVs) often lead HMGs to rely heavily on the main AC grid for energy, potentially impacting their economic feasibility as a viable alternative in energy management strategies.
The global efforts to advance transportation electrification add complexity to the modernization of energy infrastructures.Planned transportation electrification is important for a sustainable energy future, as both power systems and transportation sectors are major contributors to global greenhouse gas (GHG) emissions [4].However, the widespread adoption of EVs introduces substantial challenges, notably uncoordinated charging practices that could lead to escalated peak loads, increased losses, voltage stability issues, and overloading distribution feeders [5].Recent research has focused on energy management and control strategies to navigate the complexities introduced by EV integration [6,7].For example, the authors in [4] explore the integration of one million EVs within a sub-region of the Southeast Electric Reliability Council (SERC), analyzing various charging and discharging scenarios.The findings highlight that typical power distribution feeders are ill-equipped to support extended EV charging sessions without severe overloads and potential service disruptions.Further [5] delineates one of the initial investigations into the grid impacts of uncoordinated EV integration, evaluating the technical, economic, and operational ramifications of assimilating 7.5 million EVs.The study posits that without strategic EV charging management-shifting from peak to off-peak periods-a significant surge in energy costs across the US interconnected network is inevitable.Moreover, [8] investigates the hourly operational impact of large-scale EV adoption on the power distribution grid, employing dynamic simulations to assess various integration scenarios.The outcomes reveal that uncoordinated charging violates voltage thresholds, overloads conditions, and increases energy costs for all connected consumers.Additionally [9], indicates that uncoordinated charging strategies contribute to peak demands at multiple nodes throughout the day, necessitating significant investments in enhancing the grid's generation and transmission infrastructure.On the contrary, proper management of EVs charging yields significant benefits for the operation of the electric grid [10,11].Therefore, smart energy management is essential to mitigate uncertainties associated with large-scale EV integration, underscoring the need for strategic approaches in the evolving energy landscape.
The emergence of hybrid AC/DC microgrids, encompassing both DC power sources-such as PV systems, wind power, and energy storages-and modern DC loads alongside major AC power infrastructures, has sparked significant interest in recent years.This interest is attributed to the unique amalgamation of AC and DC systems, offering combined benefits and positioning them as likely candidates for future distribution and transmission networks [12,13].A pivotal element in the efficacy of hybrid AC/DC microgrids lies in robust control strategies and management schemes, ensuring stable and efficient operations across both grid-connected and stand-alone modes [14,15].
Among well-known mathematical-based algorithms, Fuzzy Logic systems are considered among the best approaches for solving complex energy management problems.Selecting suitable fuzzy rules and membership functions (MFs) is a pivotal task in fuzzy systems.For energy systems characterized by a minimal set of variables, operators typically encounter minimal difficulties in formulating the appropriate fuzzy rules and MFs.Yet, achieving optimal performance in complex systems like energy systems becomes a formidable challenge due to the intricate task of establishing coherent relationships among the rules.Several works have utilized classical FLC to achieve effective management strategies within energy-related paradigms.For example, [16] develops a 25-rule Fuzzy Logic controller for an energy management system in a residential microgrid aimed at smoothing grid power fluctuations and managing battery state without predictive methods.Similarly, [17] proposes a rule-based energy management scheme (REMS) for continuous EV charging at a uniform price using a photovoltaic-grid system.Their work models PV output, EV demand, and energy storage unit (ESU), aiming for constant price charging by managing energy flows and enhancing the valley filling during off-peak hours.Validated under diverse conditions and compared to standard grid charging, the proposed method shows a 16.1% reduction in charging cost and a 93.7% decrease in grid burden, with vehicle-to-grid (V2G) technology further improving the payback of the PV-grid system.In [18], the evolution of energy management systems (EMS) in grid-connected Microgrids (CMGs) is investigated, focusing on a Rule-based EMS for a residential multi-source MG with distributed energy sources and V2G technology.The authors attest that FLCs offer promising features for achieving optimal energy management.The other literature utilizing classical FLC includes hybrid microgrids [19][20][21][22]; multi-agent control of DC microgrids [23][24][25]; economic dispatch-based control [26], among others.
Type II Fuzzy Logic Controllers are increasingly recognized as effective tools for navigating the complexities of managing systems like energy networks.These advanced controllers, with their layered structure and enhanced capability to handle uncertainties, offer significant improvements over classical FLCs, especially in uncertain and imprecise environments.Type-2 FLCs provide greater robustness and flexibility by capturing higher degrees of uncertainty, resulting in more accurate and reliable control.Unlike classical FLCs, which utilize crisp membership functions, T2FLCs employ fuzzy membership functions that better represent real-world ambiguities, enhancing their effectiveness in dynamic and stochastic environments.The essence of Type II FLCs lies in their adeptness at managing a broader range of uncertainties, making them particularly suitable for hybrid microgrids and RES integrations.Several studies have considered Type-2 FLC in energy management.For example, [27] tackles Load Frequency Control (LFC) in islanded AC microgrids, incorporating diverse microsources to manage power balance.They utilized a type-II fuzzy PID controller enhanced by an improved-salp swarm optimization (I-SSO) algorithm for effective frequency and tie-line power regulation amidst uncertainties.Comparative analyses highlight the proposed controller's improved performance over conventional controllers and optimization techniques, showcasing its efficacy in stabilizing multi-area islanded AC microgrids.In [28], a Fuzzy type 2 controller is introduced to address lowpower factor issues in microgrids, focusing on DC microgrids.By improving transient responses and aiming for near-unity power factors, this controller outperforms classical FLC and PI controllers in dynamic response, steady-state error, and power quality standards, validated through MATLAB/Simulink and dSPACE platform tests.In [29], a method combining Type 2 FLC and Artificial Neural Networks (ANN) for PV fault analysis is presented, demonstrating both techniques' efficacy in detecting specific PV faults like damaged modules and partial shading.Through experiments, it is shown that Type 2 Fuzzy and ANN have comparable detection performance, laying the foundation for the development of robust FLCs and ANNs suitable for diverse applications.The authors in [30] investigate the dynamic stability challenges posed by increased penetration of RES-based microgrids in power systems, highlighting the negative impact of reduced system inertia from renewable generation.It introduces a Type-2 fuzzy fractional order PID power system stabilizer (PSS), enhanced by a meta-heuristic hybrid algorithm, to improve oscillation damping and, thus, dynamic stability under diverse conditions.Several studies focus on utilizing Type-2 FLC in energy management, such as for AC microgrid control [31][32][33][34][35]; battery storage integration into DC microgrids [36][37][38], among other studies.
In the landscape of microgrid energy management, a notable gap exists in the literature regarding the extensive modeling of dynamics and uncertainty in microgrids.With significant research concentrating on Classical Fuzzy Logic Controller (CFLC) solutions, the intricate details characterizing microgrid operational dynamics are often overlooked.Such an oversight may lead to compromised results, marking a potential flaw in their conceptualization.This issue is compounded by the fact that most studies traditionally focus on either AC or DC microgrids in isolation, with little to no attention given to the application of classical or Type-2 fuzzy logic within the realm of hybrid microgrid configurations.This limited scope fails to capture the complex interplay between AC and DC systems and the unique challenges presented by hybrid microgrids, leaving a critical area of microgrid management and optimization relatively unexplored.
In response to the prevailing gaps in the microgrids management literature, particularly the oversight of the complex dynamics characterizing HMG systems, this work proposes a novel approach through the development of an intelligent, variable-fed Type-2 Fuzzy Logic Controller (IT2FLC).The proposed controller is distinguished by its capacity to accommodate real-time, variable inputs, enabling optimal energy management within HMG uncertain environments.The major contribution of this work is as follows:

•
Development of an intelligent controller capable of accommodating real-time, variable inputs.This controller is designed to achieve optimal energy management within HMG environments characterized by uncertainty.This work is organized as follows: Section 2 provides a comprehensive mathematical modeling of the dynamic operation of HMGs and proposes intelligent, variable-fed IT2FLC; Section 3 provides detailed mathematical analysis of the fuzzy system utilized in this work and details the designed Simulink model that resembles the operation of HMG given uncertainty factors and real-time data; and Section 4 concludes the work with final remarks and discussion.

Mathematical Modeling of the Dynamics of Hybrid Microgrids Considering Different Modes of Electric Vehicles Integration
Figure 1 shows a system architecture of HMGs from both circuit-based design (left), and component-based design (right).To ensure the reliability and stability of operations within a HMG system across various conditions, it is imperative to maintain a balance between energy supply and demand.This work assumes the HMG system operates under three conditions:

•
EVs Power Discharging Mode: In scenarios where the available power from RES is insufficient to meet the HMG load requirements, the system operates in this mode.
Here, the EVs battery are utilized to regulate the output voltage through battery discharge, serving as voltage sources.The goal of the controller is to enable precise energy sharing and optimal voltage regulation within an acceptable threshold to reduce dependence on upstream power received from the AC grid.

•
Idle Power Mode: This mode signifies a state of equilibrium where the HMG system operates independently in an islanded mode, with the DFIG and PV systems being adequate to meet the demands.In this mode, EV batteries are not involved in the energy management scheme.The RES undertakes the regulation of the HMG bus voltage, utilizing fuzzy tracking control to maintain stability.

•
EVs Power Charging Mode: During times of abundance of power from RES, the supply from the DFIG and PV surpasses the connected demands, leading to an increase in energy levels.In such instances, the surplus energy is directed towards charging the EV batteries for later use, which in turn manages the HMG voltage through their charging mechanisms.
Given the three modes of operation detailed above, the following equations set the conditions for the HMG operation in this study: The dynamic behavior of the PV system is modeled through the following set of equations that govern the inductor current, the capacitor voltage, and the output voltage, as highlighted in the left part of Figure 1: Equation ( 4) delineates the interplay between the generated current, the system's inherent resistances, and the impact of these factors on the current through the inductor,  , , a key component for energy transfer in the PV system, and the rate of change in the inductor current. , ,  , , are resistances on both the conductance and inductance sides, while  , ,  , represents the dynamics introduced by the diode and capacitor of the grid.Equation (5) focuses on the voltage dynamics across the PV capacitor ( ), illustrating how the capacitor moderates the fluctuation in the system's voltage, which is crucial for maintaining the stability of the voltage supplied by the PV system to ensure it meets the demand without introducing volatility into the HMG energy supply.On the other hand, Equation (6) models the output voltage ( , ) dynamics of the PV system, which shows how variations in demand and supply currents affect the output voltage, ensuring the PV system's output is stable and reliable in a hybrid microgrid.
The dynamic modeling of the DFIG machine within the HMG system, shown in Figure 1, can be described succinctly as follows, considering the generator's power and voltage dynamics under varying operational conditions.
Here, Equations ( 7) and ( 8) highlight the rotor and stator's roles in managing active and reactive power while maintaining voltage stability and power quality within the HMG.Where  represents the rate of change in rotor power considering slip frequency ( ), rotor currents ( , ), and DC link voltage ( ), with  as the reactive power dynamics of the stator, incorporating synchronous speed ( ), stator currents ( , ), and their interaction with the grid voltage.On the other hand, Equation ( 9) demonstrates the voltage behavior in response to frequency variations, which is critical for adapting to changing load demands and operational conditions.Equation ( 10) models the DFIG response to external voltage variations, ensuring efficient power conversion and stability of the HMG energy supply.The dynamic behavior of EVs' batteries could further be encapsulated by the following equations that delineate aspects of battery operation and thermal management: where  , outlines the current dynamics of the EVs battery, relating the change in current to the difference between the main and auxiliary currents through resistive and capacitive components;  , represents the rate of change in extracted charge, which is directly proportional to the main current and is a needed parameter for monitoring the state of charge (SoC) and energy usage efficiency of the EV battery.Equation ( 14) presents thermal modeling crucial for preventing overheating and ensuring the safety and durability of the battery, where  models the temperature dynamics of the battery, factoring in the specific heat capacity ( , ), power dissipation ( , ), ambient temperature ( ), and thermal resistance ( , ).On the other hand, Equation (15) defines the thermal power generated within the battery, which is a function of the battery's power coefficient (  , ) and nominal voltage.Finally, Equation ( 16) underscores the significance of thermal effects on battery performance and efficiency.
The HMG system's operational efficacy relies heavily on the accurate modeling of EVs as integral energy storage components.Hence, the interplay between the charging/discharging processes of EV batteries and their impact on the grid's stability and voltage regulation could be formulated, as follows: Equation (17) shows the influence of the inductance, duty cycle, and the DC bus voltage as well as the EV voltage on the charging and discharging process, while Equation (18) details the dynamics of the DC bus voltage in such processes, where the capacitance of the EVs battery plays a central role in managing voltage fluctuations.Hence, the charging and discharging formula could be formulated as follows: where the SoC value is calculated using the Coulomb counting method and corrected according to the actual battery capacity.The SoC is calculated as follows: Considering the first operational mode, EVs Power Discharging Mode; cooperative functionality of the EVs battery, DFIG and PV units within the HMG are carefully integrated for proper system modeling, as follows: Here, Equation ( 22) models the dynamics of the EV battery's main current influenced by the boost converter's operation, including efficiency losses ( , ) and the variation of charges ( , ).Equations ( 23) and ( 24) describe the adjustment in output current and voltage based on recorded current flows in the system, which is essential for maintaining optimal battery operation and preventing any unnecessary overdischarging.Simultaneously, Equations ( 25) to (29) model the DFIG system's performance, capturing slip-based power generation and reactive power dynamics with respect to the rotor and stator interactions.These equations highlight the DFIG's capability to adapt its output based on the grid's demand, including the adjustment of rotor current ( , ) and grid voltage ( , ) to ensure stability and efficient energy conversion.The PV system's contribution is elucidated through Equations ( 30) to (32), which details the current and voltage dynamics in the presence of a buck converter, which emphasize the PVs role in sustaining the microgrid's energy supply, particularly by adjusting the output voltage and managing the load current to align with the system's energy requirements.Hence, the voltage level that could be supported by the HMG during discharging mode could be reformulated as follows: where the  ,  ,  ,  are the circuit resistances of the EVs battery, DFIG system, PV system, and load demand.Now, focusing on optimizing the PV performance, the Maximum Power Point Tracking (MPPT) of the PV shown in Figure 1 could be given as: While the dynamics of the wind turbines in the DFIG could be given from: Here, Equation (36) highlights the MPPT mechanism for the PV systems, employing an exponential function to dynamically adjust to changing solar irradiance levels, thereby ensuring the PV system operates at its optimum power output.For wind energy conversion, Equations (37) through (38) provide a comprehensive model.Equation (37) outlines the maximum extractable power from wind as a function of air density (ρ ), turbine blade area (A), and wind velocity ( ), modulated by the power coefficient (p), which is further detailed in Equation (38).This coefficient, dependent on the tip speed ratio (λ) and blade pitch angle (β), indicates the efficiency with which a wind turbine converts kinetic wind energy into electrical power.The piecewise function in Equation (39) delineates the average power output across different wind speed ranges.
To carefully underscore the roles of the EVs battery, DFIG, and PV systems within the broader framework, further refinement is needed towards optimizing the operational efficiency of the discharging process.Hence, to further optimize the EVs battery discharge characteristics and its impact on the HMGs stability, particularly in the face of fluctuating load demands, Equations ( 22)-( 24) can be reformulated as follows: Additionally, to account for the complexities of wind energy conversion and its integration into the HMG, ensuring that the system's energy supply remains responsive to varying wind speeds while maintaining voltage stability, Equations ( 25)~( 29) can be reformulated as follows: , =  , −  (47) Similarly, the PV system's contribution, initially outlined in Equations ( 30)~ (32), is revisited to offer a more detailed perspective on the solar irradiance's impact on power output, as follows: Now, considering the Idle Power Mode highlighted by Equation ( 2), where power is only supplied from PV and DFIG, as follows: Hence, the dynamic operation of the HMG with the absence of EVs battery discharging is given as follows: Here, Equation (56) models the dynamics of grid voltage, emphasizing the regulation based solely on the contributions from the DFIG and PV systems.Unlike in the discharging mode, where the EV battery's involvement is prominent, this equation adapts to the absence of battery support, focusing on mitigating voltage fluctuations through the real-time outputs from RES.Similarly, Equations ( 57) and (58) provide the PV system's operational nuances, with (57) detailing the voltage dynamics across the PV array and (58) describing the current flow dynamics within the PV circuit.On the other hand, Equation (59) provides insight into the overall voltage management at the PV output, aiming for seamless integration into the grid.This equation, alongside (57) and (58), underscores the critical role of the PV system in maintaining energy supply and grid stability during the floating power mode, highlighting the strategic shift from energy storage reliance to maximizing renewable generation capabilities in this mode.
Moving to the third operational mode, the EVs battery charging mode, the energy management strategy of the HMG undergoes a significant transition through prioritizing the charging of batteries.This mode distinguishes itself from the earlier modes-discharging and idle power modes-by its focus on utilizing excess power for battery charging, thereby ensuring energy storage for future use or grid support.The EVs battery model is then reformulated as follows: Equations ( 60) and (61) detail the charging dynamics, capturing the interplay between the charging current's inflow and outflow through the resistive and capacitive elements of the EV's battery circuit.Unlike the discharging mode, these equations emphasize reversing the current flow to replenish the battery's stored energy.Additionally, Equation (62) further refines the battery charging model by accounting for the complex interactions within the EV charging circuit, including the effects of inductance, resistance, and the induced voltage from RES.This equation ensures optimal charging efficiency by modulating the charging current in response to RES dynamics, given as follows: Equations ( 63) through (67) provide a mathematical description of the contributions of the DFIG, and PV systems during the charging phase.These equations, while mirroring the operational dynamics of previous modes, are now reoriented towards maximizing energy capture and storage.Particularly, Equation (66) highlights the grid voltage regulation facilitated by the DFIG and PV outputs, ensuring stable and efficient charging of the EV batteries.
This study introduces, in the next section, the design and deployment of an intelligent, variable-fed, Type-2 Fuzzy-Logic Controller (FLC) based on the Mamdani fuzzy inference system to optimize the operation of HMGs considering the abovementioned three modes of operation.The control strategy intricately links the uncertainty of the PV outputs, the performance of the DFIG, and the SoC of the EVs battery, as follows: Equations ( 68) through (73) establish the foundational objectives of the proposed controller, setting the desired operational states for the PV system, active power and reactive power, voltage levels across the grid, as well as the EVs battery and PV system, all in accordance with their respective reference values ( ).These targets underscore the critical balance the controller aims to achieve, ensuring that each component of the HMG operates at its optimum level for efficiency and stability.To accurately monitor and adjust the system's dynamics, the controller utilizes a set of error variables, highlighted in Equations (74)~(79).These variables represent the deviation of the current state from the desired reference points.By quantifying these discrepancies, the proposed IT2FLC can apply corrective measures to minimize these errors, thereby aligning the HMG's operation with the set objectives.Lastly, Equations (74)~(80) not only facilitate precise control over the microgrid's components but also illustrate the comprehensive scope of the controller's regulatory capacity.Through the adaptive adjustment of the PV system's voltage, the active and reactive power outputs, and the voltage levels across the grid and EVs battery, the controller ensures that the HMG maintains a stable and efficient energy supply.Additionally, by addressing the specific needs of the DFIG, the controller enhances the integration of wind energy into the HMG, further contributing to sustainable operation.

Design of Intelligent, Variable-Fed, Type-2 FLC for HMG Energy Management
In fuzzy logic systems, the challenge of addressing numerical and linguistic uncertainties that lead to rule ambiguities is pivotal.Hence, Type-2 FLC provides an advanced solution for managing these uncertainties.Unlike Type-1 systems, Type-2 FLC distinguishes itself through its unique handling of membership functions (MFs) and output processing mechanisms.Illustrated in Figure 2, the architecture of the proposed IT2FLC includes the following essential components: a fuzzifier, an inference engine, a fuzzy rule base, and an output processor that integrates both a type-reducer and a defuzzifier.Leveraging the extensive mathematical modeling outlined in Section 2.1, the proposed IT2FLC is particularly effective in this kind of problem, as it introduces a higher degree of flexibility in handling uncertain inputs and rules, crucial for the adaptive energy management of HMGs.The fuzzifier component of IT2FLC transforms crisp inputs into interval Type-2 fuzzy sets with fuzzy boundaries for MFs, enabling a better representation of input uncertainties.This is critical in scenarios where precise mapping of MFs is hindered by incomplete information or system anomalies.Below is a description of each of the components shown in Figure 2: (a) Fuzzifier: the fuzzifier in the IT2FLC transforms crisp input vectors, ( ,  , . . .,  ) , into interval type-2 fuzzy sets, fundamentally differing from Type-1 fuzzy logic systems, which employ membership functions defined by precise numbers.In T2FLC, membership functions are characterized by a range of values within [0, 1], reflecting the inherent fuzziness and allowing for the representation of uncertainty directly within the function itself.This characteristic is particularly advantageous in scenarios where system faults or incomplete data compromise the accuracy of membership function mapping.By accommodating uncertainties in input variables, IT2FLC enhances the model's robustness, making it an effective tool for managing complex systems such as HMGs.(b) Fuzzy-rule Base: the fuzzy rules within IT2FLC are formulated as linguistic If-Then, statements, comprising multiple antecedents linked to a singular consequent.These rules establish a Type-2 fuzzy relationship among n inputs within the input space and a single output, serving as the foundation for decision-making within the system.The k th rules of Type-2 FLC can be formulated as follows [39]: Then, for  = 1,2, . ., ; Here,  represents the IT2FLC of input state  of the kth rules, while xs resemble the inputs,  as outputs of the IT2FLC of the N rules.
(c) Fuzzy-inference Engine: The fuzzy inference engine serves the crucial function of amalgamating fuzzy rules to transform fuzzy inputs into corresponding fuzzy outputs.This input-to-output conversion lays the groundwork for discerning patterns or making informed decisions.Within the engine, a comprehensive database of MFs, along with the defined fuzzy If-Then rules and logical operations, facilitates the systematic evaluation of inputs.The engine executes calculations that include the intersection of antecedents, the aggregation of rule consequents through union operations, and the execution of the extended sup-star composition.In the framework of IT2FLC, each activated (or triggered) rule, denoted as the k th rule, delineates an interval bound by two extremities [40,41].This range is critical for encapsulating the inherent uncertainties and facilitating a more adaptable output generation.This interval-based approach enriches the system's capability to navigate through the dynamic and uncertain nature of inputs, as follows: ( ,  , . . .,  ) =  ( ,  . . .,  ),  ̅ ( ,  . . .,  ) =  ,  ̅ where  and  ̅ are found as follows: (d) Type-reducer: Type reduction is tasked with transitioning the Type-2 fuzzy set output into a Type-1 fuzzy one.This step is critical, as it bridges the computational gap between high-dimensional fuzzy logic and the actionable, crisp outputs necessary for real-time energy management decisions for the HMG.Following type reduction, the defuzzification phase further processes the Type-1 fuzzy set, distilling it into a precise, crisp value conducive to practical application.In the context of this study, centroid-type reduction is employed for its efficacy in negotiating the intricate balance between the detailed representation of uncertainty in Type-2 sets and the requisite clarity of Type-1 sets.The centroid,  ̅ , calculation for a Type-2 fuzzy system embodies a meticulous aggregation of the system's outputs, thereby providing a comprehensive yet concise representation of the fuzzy logic's inference outcome, as follows: Here,  ̅ represents the Type-1 reduced set, with n as total number of discrete points of  ̅ ,  ∈  and  ∈ [0, 1], while  ( ) and  ( ) are membership functions of  and  , with T is defined as a t-norm.Similarly, Equation ( 86) can be expressed as the centroid for the proposed IT2FLC as follows: (e) Defuzzifer: The predominant method employed for defuzzification involves calculating the centroid of the type-reduced set, a process that ensures the final decision or output retains a balance between the understanding captured by the fuzzy logic and the actionable clarity required for effective control.To achieve this balance, the following expression calculates the centroid of an n-point discretized type-reduced set: With the iterative Karnik-Mendel technique is utilized to compute the output.Therefore, the defuzzified output of the IT2FLC is: With where  represents the points in the discretized set, and  denotes their associated membership values.This formula encapsulates the essence of defuzzification within the proposed IT2FLC, highlighting its capability to facilitate the transition from fuzzy to crisp logic.Through this precise mathematical operation, the IT2FLC efficiently converges on a single output value that is both reflective of the complex inputs and suitable for direct application within the HMG management context.

Description of the Developed Hybrid Microgrid Simulink Model
To validate the mathematical concept described in this work, a Simulink-based model of a hybrid microgrid energy system is developed, as seen in Figure 3.The model is segmented into distinct modules, each modeling a component of the microgrid.The RES block simulates energy generation from a 5 kW PV and a 3 kW DFIG, utilizing environmental data inputs such as irradiance and wind speed.An EV battery model is integrated to simulate the interactive influence of the battery's SoC on the energy management of the HMG.To ensure a feedback-oriented approach, the measurements block captures real-time data on system variables, including power outputs and SOC, providing critical feedback to the IT2FLC block for continuous optimization.The utility grid and load profile blocks represent the HMG's interaction with the main AC power grid and demand side, respectively, showcasing the system's response to fluctuating consumption patterns.The Simulink model closely mirrors the actual HMG environment by incorporating PV systems, DFIG, and EVs, and utilizing real-world data for wind, solar irradiance, and load demands.However, it simplifies environmental complexities, sensor inaccuracies, and communication delays that are inherent in real-world scenarios, which may be overcome by integrating Hardware-in-the-Loop (HIL) to conduct similar studies.

Input Parameters
In this study, the simulation is supported by a detailed representation of realistic input data for PV cells, characteristics of EV batteries, and wind energy components.For the PV cell simulation, key parameters include a maximum power output of 5000 Watts, achieved at a maximum power point voltage of 42.48 Volts, and a current of 5.88 Amperes.The cells demonstrate an open-circuit voltage of 51 Volts and a short-circuit current of 6.3 Amperes, structured in an array comprising 72 cells in series and a single cell in parallel configuration.The standard reference conditions for these simulations are set at a temperature of 25 degrees Celsius and solar irradiance of 1000 Watts per square meter, with an ideality factor adjusted to 0.945.On the other hand, the EVs battery model is tailored to reflect the dynamics of Lithium-Ion batteries, with the discharge and charge phases both designed around a maximum capacity of 100 Ampere-hours and a steadfast open-circuit voltage of 12 Volts.The internal resistance remains constant at 0.0012 Ohms for both phases.The charge and discharge characteristics are further defined by specific parameters: during discharge, 'K' is set at 0.00040 Volts, 'A' at 1.9896 Ohms, and 'B' at −9 Ah −1 , while the charging phase sees 'K' adjusted to −0.074739 Volts, 'A' to 0.0015 Ohms, and 'B' to 6 Ah −1 , reflecting the intricate behaviors of battery operations under varying conditions.Finally, wind energy input parameters encompass a maximum power output of 3000 Watts, with a lambda (tip speed ratio) of 8.1 and a beta (blade pitch angle) of 0, ensuring optimal aerodynamic efficiency.The turbine's blade spans an area of 8 square meters, operating within an air density (Pa) of 1.2 kg per cubic meter.The system is designed to initiate generation at a cut-in speed of 5 m per second, reach its rated performance at 12 m per second, and cease operation at a cut-off speed of 20 m per second, encapsulating the variable nature of wind availability.
Moreover, this study utilizes real-world input data spanning over a year of solar irradiance [42], wind speed [43], and residential demand patterns [44].This approach ensures that the analysis and outcomes are grounded in the practical, operational conditions of HMG systems.

Fuzzification of the Input
In the design of the proposed variable-fed IT2FLC for HMG energy management, the fuzzification process is central as it transforms quantifiable inputs, specifically the net power from RESs versus the load demand and the SOC of the EVs, into fuzzy sets.As illustrated in Figure 4, this study employs an array of both triangular and trapezoidal membership functions.These functions are strategically chosen to span the complete spectrum of input power variances, thereby providing the proposed controller with a wide dataset for robust decision-making.This process ensures that the controller accurately gauges the degree of consistency of the input power differential within each function's scope, subsequently leveraging this information to initiate appropriate control actions.The fuzzification of the SOC variable transforms discrete SOC values into a continuum of fuzzy values.MFs are designed to capture the extent of alignment between the SOC's numerical value and corresponding linguistic terms.In this framework, a combination of triangular and trapezoidal MFs is adopted to accurately represent the SOC input, which is particularly important for the variable's nonlinear characteristics.These functions are devised to cover the entire operational range of SOC, from 20% to 90%.Each function is calibrated to reflect a specific operational state-'Low,' 'Medium,' or 'High'-thus encapsulating the entire spectrum of charging states.This ensures that each linguistic label is backed by a quantitative model that mirrors the real-world behavior of the SOC, providing a robust basis for the subsequent inferential processes within the HMG framework.Figure 5 shows the fuzzification membership plots for, from top-to-bottom: SoC of EVs, output power of the EVs battery, and output power of the HMG level.

Fuzzy Rule Base
The fuzzy rule base serves as the cornerstone of the Fuzzy controller, encapsulating expert knowledge through a collection of conditional statements.Each "if-then" rule elucidates the intricate relationship between input variables-such as power discrepancies, state of charge, and demand fluctuations-and the controller's outputs, which are instrumental in dictating the HMGs behavior for each operational mode.In this study, a comprehensively unique set of 33 fuzzy rules, shown in Table 1, has been developed to encapsulate the full spectrum of potential operational dynamics.This extensive rule base is determined through rigorous simulation testing, encompassing a multitude of scenarios reflective of the HMG's operational environment.

Case Study Incorporating Dynamic HMG Operation
The comprehensive simulations that cover a span of a year of HMG operation offer an empirical basis for evaluating its operational dynamics under varying conditions and the efficacy of the proposed intelligent Type-2 Fuzzy Logic Controller (IT2FLC).Data comprising hourly variations in wind, solar irradiance, and load demands form the core inputs, facilitating a robust analysis that reflects real-world scenarios.Figure 6 provides a graphical representation of the PV power output, which distinctly fluctuates with seasonal changes in solar irradiance.This variation is critical for assessing the proposed IT2FLC's capability in managing the energy balance within the HMG.Particularly noteworthy is the adaptability of the system during the solar peak times and the diminished outputs during the winter months, illustrating the control enabled by the proposed controller.A more detailed view, presented in a zoomed-in section of Figure 6, reveals the PV output for a select four-day period, highlighting the proposed controller precision in short-term energy prediction and allocation.On the other hand, Figure 7 shows the output power from the DFIG for a one-year simulation, showing the clear variations across different seasons.
Figure 8 showcases the load profile pertinent to the study, with a maximum and minimum load of 2295 W and 1196 W, respectively.This profile, illustrating the consumption behavior typical of a residential entity over an annual period, is instrumental for the HMGs energy management concept.The methodological approach to deriving this profile involved comprehensive monitoring of residential energy use, aggregating, and averaging the data to establish an hourly representation of load across the year.This pattern, which is inherently cyclical, mirrors the variability inherent in residential energy consumptions.Crucially, this load profile serves as a foundational parameter within the HMG control framework, as it influences the strategic decisions concerning energy allocation and distribution across the microgrid's components, aiming to maintain an optimal balance between supply and demand.Through precise control and management based on the detailed load profile, the proposed IT2FLC's ensure the HMG operates with heightened efficiency and stability, effectively balancing the dynamic energy demands of the residential load with the available supply from various energy sources within the microgrid.To evaluate the performance of the proposed IT2FLC, a comprehensive series of simulations was conducted.These simulations were carefully designed to assess the HMG's operational efficiency over a yearly cycle, with each simulation step precisely calibrated to a one-hour interval.At each of these intervals, the HMG engaged in a systematic process of data intake, analysis, and computation of control strategies, culminating in the calculation of operational setpoints for both the EV battery and the utility grid.Figures 9 and 10 clearly show the efficacy of the proposed controller in achieving optimal energy management considering the dynamic nature and uncertainty evolving in the operation of the HMG, where they show the powerset points for the utility grid and EVs battery as modulated by the controller.These results underscore the system's adeptness at managing energy flows within the HMG, aligning energy utilization with the operational requirements of EVs across the three considered modes.
Throughout the year, all three modes of operation are actively engaged by the controller to optimize energy flow within the HMG, as shown in Figure 9 and 10.The experimental results highlight several advantages of the proposed IT2FLC.Its ability to adaptively manage energy flows ensures that the system can respond to dynamic and uncertain conditions effectively.For instance, the controller's performance during peak demand hours (as seen from the extensive utilization of EVs discharging power mode) demonstrates its capability to enhance grid support and energy reliability.Additionally, the seamless transition between different modes of operation (discharging, idle, and charging) further underscores the controller's flexibility in maintaining optimal energy balance within the HMG components.However, it is particularly noteworthy that the EVs discharging power mode (Mode 1) is extensively utilized during the hot months (from the first week of May until the third week of September, as highlighted in Figure 9) to address peak demand hours, as vividly illustrated in the 24-hour zoom snapshot.This period is characterized by significant energy being provided to the grid, demonstrating the proposed controller's strategic deployment of EV battery resources to enhance grid support and energy reliability during times of high demand.Conversely, during the colder months, a more equitable balance is observed between the EVs discharging power Mode (Mode 1) and the charging mode (Mode 3).This allows for the EVs to be charged during mid-day hours when energy is abundant and to discharge during the second peak to off-peak hours in a cooperative and balanced manner.This shift in operational dynamics ensures an efficient use of stored energy, optimizing the HMG's performance, and contributing to a more sustainable and economic operation.Through the adept management of EV battery interactions-leveraging discharging capacities during times of surplus and modulating charging activities in response to the inherent balance between energy availability and demand-the proposed intelligent IT2FLC demonstrates a sophisticated approach to optimizing energy flows considering the stochastic nature of the input variables.This ensures not only the maintenance of energy supply during critical demand peaks but also the effective utilization of EVs as dynamic components within the HMG, fostering an enhanced balance between energy supply, demand, and storage efficiency across varying seasonal demands.However, the implementation of IT2FLC also presents certain limitations.One potential challenge is the computational complexity associated with real-time processing of fuzzy logic rules, especially when handling large datasets and multiple variables.This could impact the system's response time in rapidly changing conditions.Furthermore, the reliability of the controller depends on the accuracy of the input data (e.g., solar irradiance, wind speeds, and load demands).Inaccurate or delayed data could lead to suboptimal decision-making, affecting the overall efficiency of the HMG.Moreover, the zoomed-in snapshot shows the SoC changes during peak hours of a specific day in June.The larger fluctuations in SoC within this inset is due periods of significant discharging (when energy is taken from the EVs battery, which would show as a decrease in SoC) and charging (when energy is put into the battery, increasing the SoC).
The voltage profile of the HMG across the year is presented Figure 12.In the warmer months, the plot exhibits noticeable variances indicative of the EVs discharging mode during peak hours to support the HMGs operation.This is observable as voltage sags followed by recoveries, marking periods where EVs discharge, contributing positively to the grid during peak demand.The zoomed-in snapshot offers a view of this activity, underscoring the strategic timing of discharging during high-demand intervals to stabilize the grid.As the seasons transition towards colder months, the results suggest a harmonious oscillation between the discharging and charging of EVs-Modes 1 and 3, respectively.During these times, a surplus of energy during mid-day prompts the charging of EVs, while the descent into evening peak and off-peak hours triggers a discharge from the EVs.This cyclic pattern is indicative of a well-balanced and cooperative energy management approach, moderating the voltage within a tighter band, thereby implying a consistent and stable grid operation under the supervision of the proposed controller.Table 2 provides a comprehensive overview of the energy exchange dynamics between the HMG and the utility grid over the monitoring period.As seen in Table 2, the study reveals that the HMG was a net recipient of energy from the utility grid for a duration of 4611 h.During this interval, the HMG consumed an average power of 8009.5 kW, aggregating to a total energy import of 18,759 MWh.Conversely, the microgrid supplied energy back to the utility grid for a lesser span of 3647 h at an average export power of 5408.4 kW, culminating in a substantial energy export totality of 31,178 MWh.The net energy balance underscores that the HMG imported 12,467 MWh from the utility grid.From an economic perspective, with the assumed utility cost of $0.27 per kWh, the microgrid's net energy transactions resulted in a significant cost avoidance of $3,748,900, money that would have otherwise been an expenditure for energy procured from the grid.In comparison, the classical FLCs yielded cumulative financial savings of −3,030,638.64USD.This demonstrates that the proposed IT2FLC offers a 23.7% improvement in cost savings, further validating its superior performance.The table also details the energy management within the HMG, considering the integrated EVs' batteries.The EVs were engaged in charging operations for 365 h, absorbing power at an average rate of 152.22 kW and totaling an energy intake of 53.53 MWh.Battery discharging occurred over 339 h, delivering power at an average rate of 142.22 kW and contributing an energy output of 46.79 MWh to the microgrid.These figures represent the critical role of the EV battery in the HMG energy schema, balancing charge and discharge cycles to optimize grid interactions and economic benefits.Overall, the proposed IT2FLC demonstrates significant potential for enhancing the resilience and economic feasibility of hybrid microgrids.Its advanced handling of uncertainties and ability to efficiently manage diverse energy sources and loads make it a promising solution for modern energy systems.While the controller's complexity and dependency on accurate data present certain challenges, the benefits it offers in terms of flexibility, adaptability, and optimized energy management are substantial.Future work could focus on streamlining the computational aspects and enhancing data integration methods to further improve the controller's practical applicability.

Conclusions
In conclusion, this research presents a comprehensive mathematical modeling framework for hybrid microgrids (HMGs) that accounts for detailed parameters influencing the grid's operation while considering various operational modes of EV integration.The transitions between these modes are based on real-time measurements of power supply and demand within the HMG, ensuring responsive and adaptive energy management.The proposed intelligent Type-2 Fuzzy Logic Controller (IT2FLC) continuously monitors these parameters and optimally switches between modes to maintain energy management and system stability.The models, derived and elucidated through rigorous mathematical formulations, robustly capture the dynamic behavior and un-certainty of HMGs, including PV systems, DFIG units, and the critical operational characteristics of EV batteries, particularly in their dual role as energy consumers and storage devices.
The implementation of the proposed variable-fed IT2FLC, based on Mamdani fuzzy inference, advances the management of the complex interplay of HMG components under fluctuating energy conditions.Extensive simulations validate the efficacy of the proposed IT2FLC, capturing seasonal variabilities and day-to-day energy exchange intricacies.Results indicate that the HMG, under the supervision of the intelligent controller, adeptly navigates across various modes of EV integration with the grid.This adaptability ensures efficient energy flow, harnessing renewable generation while maintaining grid stability and energy availability during peak demand periods.
The main findings from the results demonstrate the superior performance of the IT2FLC in managing energy flows within the HMG.The controller effectively mitigates the volatility of renewable energy sources by dynamically adjusting the operation of EV batteries.During high demand periods, the EVs discharge to support the grid, significantly reducing the reliance on external power sources and improving grid stability.Conversely, in periods of surplus energy, the controller efficiently directs excess power to charge the EV batteries, preparing them for future use.The simulation results highlight a well-balanced energy distribution, optimal voltage stability, and significant cost savings, emphasizing the economic and operational benefits of the IT2FLC.
Alongside the energy transaction summaries provided in Table 2, the results also reflect the strategic effectiveness of the proposed IT2FLC in managing energy surplus and deficit scenarios.By effectively utilizing the discharging capacity of EVs during high energy demand periods and leveraging their charging potential during excess power availability, the HMG sustains an optimal energy balance.This not only reinforces the grid's reliability but also underscores a sustainable and economically viable energy ecosystem, as evidenced by the substantial cost savings highlighted.The controller's effectiveness in maintaining voltage stability and managing the SoC of EVs, particularly under varying load conditions, is commendable.Overall, by harnessing the potential of RES, optimizing energy storage via EV batteries, and ensuring seamless integration with existing grid frameworks, the proposed controller proves to be an effective tool for providing optimal energy management solutions.
For future studies, the potential of intelligent FLCs in cybersecurity applications for energy systems is a promising avenue.As cyberattacks against energy infrastructures have significantly increased in recent years to advance political, social, or financial agendas, the cybersecurity of energy systems has become a central topic in research recently [45,46].Intelligent FLCs can be leveraged to enhance the security of energy infrastructures against cyber threats such as Distributed Denial of Service (DDoS) attacks, a form of cyber threat that can successfully paralyze charging stations [47].For instance, intelligent FLCs can monitor and respond to abnormal traffic patterns indicative of a DDoS attack targeting EV charging stations, thereby protecting the grid from disruptions.This integration of cybersecurity measures within an intelligent FLC framework could ensure that energy systems remain resilient to both physical and cyber threats, providing a robust defense mechanism in increasingly interconnected energy networks.Other recommendations for future studies include exploring the integration of artificial intelligence and machine learning techniques to further enhance the predictive capabilities and decision-making processes of intelligent FLCs [48,49].Additionally, investigating the scalability of the proposed controller for larger and more complex energy systems, including smart cities, can provide insights into its broader applicability.Further studies can also focus on real-world implementations and field tests to validate the simulated results and assess the practical challenges and benefits of deploying IT2FLCs in actual HMG environments.

Figure 2 .
Figure 2. The main components of Type 2 controllers.

Figure 3 .
Figure 3.A system architecture of the developed Simulink model in this work.

Figure 4 .
Figure 4. Fuzzification of first input (difference of RES power and load demand).

Figure 5 .
Figure 5. Membership of SoC of EVs (upper), output power of the EVs battery (middle) and grid level (lower).

Figure 6 .
Figure 6.PV output simulation for one-year period.

Figure 7 .
Figure 7. Output simulation of the DFIG unit for one-year period.

Figure 8 .
Figure 8. Load profile of the HMG system for a span of one year.

Figure 9 .EVFigure 10 .
Figure 9. Integration of EV batteries for 364-days into the HMG considering the discussed three modes of operation.

Figure 11
Figure11shows the SoC through the year for the EVs battery.The red bars indicate the charging and discharging cycles of the EVs batteries over time.A positive red bar indicates EV in charging cycle, leading up to a higher SoC, while a negative in the red bar indicates a discharging cycle where the EV is being used or is providing power back to the grid or home.As shown in the figure, the SoC fluctuates significantly, primarily due to its daily usage patterns or controlled charging/discharging by the proposed IT2FLC.Moreover, the zoomed-in snapshot shows the SoC changes during peak hours of a specific day in June.The larger fluctuations in SoC within this inset is due periods of significant discharging (when energy is taken from the EVs battery, which would show as a decrease in SoC) and charging (when energy is put into the battery, increasing the SoC).The voltage profile of the HMG across the year is presented Figure12.In the warmer months, the plot exhibits noticeable variances indicative of the EVs discharging mode during peak hours to support the HMGs operation.This is observable as voltage sags followed by recoveries, marking periods where EVs discharge, contributing positively to the grid during peak demand.The zoomed-in snapshot offers a view of this activity, underscoring the strategic timing of discharging during high-demand intervals to stabilize the grid.As the seasons transition towards colder months, the results suggest a harmonious oscillation between the discharging and charging of EVs-Modes 1 and 3, respectively.During these times, a surplus of energy during mid-day prompts the charging of EVs, while the descent into evening peak and off-peak hours triggers a discharge from the EVs.This cyclic pattern is indicative of a well-balanced and cooperative energy management approach, moderating the voltage within a tighter band, thereby implying a consistent and stable grid operation under the supervision of the proposed controller.

Figure 11 .
Figure 11.SoC level of the EVs batteries connected to the HMG.

Figure 12 .
Figure 12.Voltage level at the HMG during simulation, considering the discussed three modes of operation.

Table 1 .
The 33 fuzzy rules in this work.

Table 2 .
Summary of simulation results.