Continuous Simulation of the Power Flow in AC–DC Hybrid Microgrids Using Simpliﬁed Modelling

: This paper reports the development of a model for continuous simulation of the power ﬂow into AC–DC hybrid microgrids operating for different generation–consumption scenarios. The proposed application was assembled using a multiple-input multiple-output model which was built using blocks containing simpliﬁed models of photovoltaic (PV) modules, wind turbines (WT), battery arrays (energy storage units, ESU), and power loads. The average power was used as the input/output variable of the blocks, allowing ﬂexibility for easy reconﬁguration of the microgrid and its control. By deﬁning a generation proﬁle, PV and WT were modeled considering environmental conditions and efﬁciency proﬁles of the maximum power point tracking (MPPT) algorithms. ESUs were modeled from intrinsic characteristics of the batteries, considering a constant power charge regime and using the State of Energy (SoE) approach to compute autonomy. To deﬁne a consumption proﬁle, DC and AC loads were modeled as a constant real power. As an innovative characteristic, unidirectional and bidirectional power conversion stages were modeled using efﬁciency proﬁles, which can be obtained from experiments applied to the real converters. The outputs of the models of generation, consumption, and storage units were integrated as inputs of the mathematical expressions computing the power balance of the buses of the microgrid. The proposed model is suitable to analyze efﬁciency for different conﬁgurations of the same microgrid architecture, and can be extended by integrating additional elements. The model was implemented in LabVIEW software and three examples were developed to test its correct operation. can be studied. Because of this main feature, it also serves as a ﬂexible basis for simulation of other simpler architectures of microgrids. The microgrid is composed of two DC distribution buses with different voltage levels and an AC bus. The AC bus is a standard single-phase point of common connection (PCC) interconnecting the microgrid, the grid, and AC loads. In Figure 1, the architecture of the hybrid microgrid selected as a case study is depicted.


Introduction
Electric energy consumption has shown accelerated growth in recent years. Simultaneously, there has been a constant development of technologies to ensure efficient generation and distribution. As a consequence, the conventional centralized energy system architecture has evolved to a distributed architecture involving localized generation based on microgrids [1,2]. Microgrids are structures capable of supplying energy to local loads with or without a connection to a main grid. Among their multiple applications, microgrids can solve the energy availability problem in rural or remote zones and contribute to the increased use of renewable resources in urban zones [3][4][5][6]. Microgrids use renewable resources to supply the energy demanded by the loads, and they require storage technologies to provide autonomy due to the intermittence of solar and wind energy. Considering their advantages, microgrids permanently attract the interest of researchers and industrialists around the world [7][8][9].
The nature of the voltage in the points of common connection of a microgrid named as nodes or buses allow the classification of microgrids as either DC, AC, or hybrid DC-AC, i.e., having DC or AC coupling capability. Hybrid microgrids have become popular in recent years because they provide the flexibility and modularity that AC and DC microgrids cannot provide separately [10][11][12][13][14]. Therefore, several research efforts are devoted to solving the challenges related to the development of these kinds of systems.
Microgrids have been simulated to facilitate their study in both academic and research environments. The vast majority of research on the modelling and control of microgrids, whether DC or AC, has been carried out using MATLAB/Simulink as a simulation tool. For instance, in [15], the power management system for a microgrid consisting of a wind turbine farm, a solar PV farm, and AC loads is validated for various operating conditions. Additionally, in [16], modelling and control of a hybrid microgrid is developed using simulations to validate the correct operation of the system under transient and stationary conditions. In [17], the Stateflow toolbox of Simulink is used to validate a power balance control strategy developed using the Petri Nets formalism. Moreover, there are other simulation tools that have been successfully used in the study of microgrids, such as PSCAD [18][19][20] and DigSILENT Power Factory [21,22]. It is also relevant to mention the existence of software such as HOMER, which allows the economic study of microgrids beyond technical aspects [23,24]. In general, researchers develop simulations focused on a particular case study, and only some works are devoted to study generalized or flexible architectures. Another important approach regarding microgrid simulation is the use of hardware in the loop (HIL) techniques, which advantageously utilize a dedicated platform, enabling a real-time simulation. For this, hardware systems such as Typhoon, OPAL-RT, or RTDS are necessary, unbalancing the cost-benefit ratio when the object of the simulation is validated for academic purposes [25][26][27][28][29][30]. As a particular case, in [31], a behavioral simulator modelling several types of power loads is presented, demonstrating that good results (regarding precision and time of simulation) can be obtained in simulation of operation scenarios of microgrids without the need for complex physical models of loads. Although this work is focused on a shipboard microgrid, its use can be extended to other kind of microgrids.
A potential solution to facilitate understanding of the fundamentals of microgrid operation is the use of simplified models capable of supporting the configuration of real parameters (environmental conditions), real scenarios (generation and consumption), and accurate modelling of conversion devices. In [32], authors introduce a modular simulation which can be used as testbed in the study of management strategies of hybrid microgrids regarding the formalism of the energetic macroscopic representation. One of the notable features of this development is the use of MATLAB/Simulink without the requirement of additional toolboxes, which allows accessibility to a wider community. In this work, models for PV modules, batteries, fuel cells, ultracapacitors, generators, and power converters are developed, and control loops are implemented. In [33], a simulation of a DC-coupled AC/DC hybrid microgrid is implemented in MATLAB, providing various possible configurations. In this case, the connection of three microgrids is tested based on the 14-bus bar IEEE standard. A relevant feature of this work is the simulated interconnection of multiple microgrids with AC and DC nature. This simulation allows the study of power quality indexes into the AC side, such as THD, and power factor, which is advantageous, although it adds complexity. A system-level simulation is developed in [34], proposing alternative models for different components of the microgrid. In this work, the models proposed for converters are very accurate with respect to experimental results. This is possibly due to the inclusion of accurate models of the efficiency behavior of the converters, which increased the accuracy of the simulation. In [35], a simplified modelling approach is developed to study the behavior of microgrids in islanding operations. The authors demonstrated that the complexity of the proposed models is reduced and the corresponding algorithms are easy to implement in any general-purpose software. A comparison with simulations developed in PSCAD-EMTDC is provided, confirming the validity of the approach. On the contrary, modelling presented in [36] proposes a complex representation of the microgrid using neural networks, which integrates different components treated separately as autonomous systems. Although this approach showed a good performance, it is far from simple or flexible. To summarize, an interesting comparison of microgrid simulators is performed in [37], where simulators are classified according to two groups: deterministic and probabilistic. In this work, different comparison features are evaluated, such as demand response, generator efficiency, tariffs and incomes, life-cycle costing, rulebased dispatch, separate energy manager model, economic dispatch, and the possibility to kink with MATLAB. The HOMER simulator seems to be ideal for simulations involving economic aspects, while GridLAB-D is a good option to analyze power flow between nodes at the distribution level. However, similar to the development proposed in this paper, the approach developed in [38] proposes a small-scale microgrid simulation implemented in LabVIEW software involving photovoltaic generation, wind generation, and energy storage integrated into a bus feeding power loads.
Diverging from the previously published approaches, this paper describes the development of a model for continuous simulation of a flexible architecture of hybrid microgrids integrating two DC buses and AC distribution. The main feature distinguishing the proposed simulation from those previously described is the simplicity of the used models, which are standardized to share power values as input and output variables. The programming of the block-based definition of the models allows the integration of multiple generators, energy storage units (ESU), and loads, configuring a control plant with a multiple-input multiple-output (MIMO) model able to apply different control approaches and validate its behavior. Additionally, because the model is focused on the real power flow, efficiency analysis of the microgrid can be easily derived.
The rest of the paper is organized as follows: Section 2 presents a description of the hybrid microgrid architecture selected as a case study. Section 3 details the modelling of the elements comprising the microgrid, and a detailed implementation description is presented in Section 4. Simulation results for different operation scenarios are provided, validating the correctness of the computation and the usefulness of the simulation application, in Section 5. Finally, conclusions and future work are summarized in Section 6.

Description of the Selected Microgrid Architecture
The model was developed considering a flexible architecture in which the majority of the concepts applied in microgrids can be studied. Because of this main feature, it also serves as a flexible basis for simulation of other simpler architectures of microgrids. The microgrid is composed of two DC distribution buses with different voltage levels and an AC bus. The AC bus is a standard single-phase point of common connection (PCC) interconnecting the microgrid, the grid, and AC loads. In Figure 1, the architecture of the hybrid microgrid selected as a case study is depicted. treated separately as autonomous systems. Although this approach showed a good performance, it is far from simple or flexible. To summarize, an interesting comparison of microgrid simulators is performed in [37], where simulators are classified according to two groups: deterministic and probabilistic. In this work, different comparison features are evaluated, such as demand response, generator efficiency, tariffs and incomes, lifecycle costing, rule-based dispatch, separate energy manager model, economic dispatch and the possibility to kink with MATLAB. The HOMER simulator seems to be ideal for simulations involving economic aspects, while GridLAB-D is a good option to analyze power flow between nodes at the distribution level. However, similar to the development proposed in this paper, the approach developed in [38] proposes a small-scale microgrid simulation implemented in LabVIEW software involving photovoltaic generation, wind generation, and energy storage integrated into a bus feeding power loads.
Diverging from the previously published approaches, this paper describes the development of a model for continuous simulation of a flexible architecture of hybrid microgrids integrating two DC buses and AC distribution. The main feature distinguishing the proposed simulation from those previously described is the simplicity of the used models, which are standardized to share power values as input and output variables. The programming of the block-based definition of the models allows the integration of multiple generators, energy storage units (ESU), and loads, configuring a control plant with a multiple-input multiple-output (MIMO) model able to apply different control approaches and validate its behavior. Additionally, because the model is focused on the real power flow, efficiency analysis of the microgrid can be easily derived.
The rest of the paper is organized as follows: Section 2 presents a description of the hybrid microgrid architecture selected as a case study. Section 3 details the modelling of the elements comprising the microgrid, and a detailed implementation description is presented in Section 4. Simulation results for different operation scenarios are provided, validating the correctness of the computation and the usefulness of the simulation application, in Section 5. Finally, conclusions and future work are summarized in Section 6.

Description of the Selected Microgrid Architecture
The model was developed considering a flexible architecture in which the majority of the concepts applied in microgrids can be studied. Because of this main feature, it also serves as a flexible basis for simulation of other simpler architectures of microgrids. The microgrid is composed of two DC distribution buses with different voltage levels and an AC bus. The AC bus is a standard single-phase point of common connection (PCC) interconnecting the microgrid, the grid, and AC loads. In Figure 1, the architecture of the hybrid microgrid selected as a case study is depicted.  Both DC buses of the microgrid are nodes integrating renewable generators, energy storage, and local loads. Photovoltaic modules (PV) and Wind Turbines (WT) are considered among the existing renewable energies. Each bus can integrate several generators, allowing the study of multiple control and energy management strategies. The microgrid uses energy storage units (ESU) connected to one of the DC buses; each DC bus can integrate multiple ESU. The loads connected to the buses are represented with a constant power behavior. The loads connected to the AC side can be fed by either the grid or the microgrid. They can be fed by the microgrid by using power converters taking the required energy from one or both DC buses. The exchange of energy between DC buses is enabled using one or two paralleled bidirectional DC-DC converters, named interlinking converters (ILC). The interaction between the DC buses and the AC bus is enabled by using bidirectional DC-AC converters, named as interfacing converters (IFC). Fundamentals considered in the architecture selection take the basis of the overview of power and control architectures presented in [10]. From a generalized perspective, the selected architecture allows the study of multiple alternatives for power flow into the microgrid, which are defined by the user through the rules programmed into the external decision algorithm as control. In this paper, we focus on the mathematical modelling of a hybrid microgrid as a plant with the aim to provide flexibility to the study's multiple control strategies.

Modelling
The proposed model was built considering each component of the microgrid as a module with a mathematic model representing a power source or a power load. These modules were integrated through a generalized mathematic model of the microgrid buses and the control algorithms. For example, a battery module has a source behavior during the discharge process and a load behavior during the charging process, requiring that their model can consider bidirectional flow and different modes of operations. Similarly, although generators have a unidirectional power flow, they are composed of a chain of modules involving power production, efficiency profiles of the power converters, and the maximum power point tracking algorithms.
Mathematical expressions modelling different modules use numerical variables N pqxn−z (taking values 0 and 1), allowing the configuration of different modes of operation. The sub-indexes p and q define the type of unit (PV: photovoltaic, WT: Wind, ES: Energy Storage), while x denotes the bus in which a unit is connected (1, 2 or 3), n defines the index if more than one unit of the same nature is connected to the same bus (1, 2, . . . ), and z allows the differentiation of functions for each unit (a, b, and c, if required). Using these signals, an external decision algorithm can control the power given or absorbed by each module. Similarly, the power variables are defined using the same convention with an added sub-index to identify the power in a conversion chain (1, 2 and 3).
The block diagrams used within the paper consider the results of computations at the right side of the blocks from the values available at the left side and the parameters selecting the operation modes. If computations consider the output value also as an input, the value corresponding to the previous sampling period is used as an input. The modelling for all modules used in the simulation is presented below.

Modelling of the PVG
The power delivered by a PV generator depends on a chain composed by three modules: the solar panel, the maximum power point tracking (MPPT) algorithm, and one unidirectional DC-DC power converter. Integrated to a DC bus in the microgrid, each generator can operate in the three modes listed in Table 1. In the modes 0 and 3, the generator is deactivated and its power contribution is zero. Operating in the mode 1, the PV module delivers the maximum available power, which is affected by the MPPT efficiency and the DC-DC converter efficiency. Contrarily, operating in the mode 2, the solar panel delivers a fraction of the available power, tracking an external power reference given by a superior level of the control hierarchy of the microgrid. In mode 2, the power delivered by the solar panels is affected only by the efficiency of the DC-DC converter, as the MPPT algorithm does not operate (in this mode the MPPT efficiency is settled to 100%). Table 1. Operation modes of PV generators.

Mode Mode Convention
Parameters Module OFF OFF 1 1

Solar Panel Model
A general but simple model of a photovoltaic panel calculating the maximum output power for specific irradiance and temperature values is given by the following expression: where P pvxn−max is the rated power of the PV module, S pv is the instantaneous irradiance, S re f is the irradiance reference (1000 W/m 2 ), T pv is the instantaneous temperature, T re f is the temperature reference (25 • C), and γ is the maximum power correction factor for temperature, which takes values around −0.005, depending on the material employed to build the panel [39]. P pvxn−nom is the nominal power of the generator applied for both the PV module and power converter. Then, for a set of environmental conditions, this model provides the value of the maximum allowable power which can be extracted either totally or partially.

MPPT Algorithm
Conventionally, the efficiency of the MPPT algorithms used in PV applications depends on the irradiance level or consequently on the extracted power. This efficiency value can range from 80% to 99.9% in the more active MPPT algorithms [40,41]. Then, the efficiency of the MPPT is represented as a function of the maximum allowable power provided by the model of the PV module. As mentioned previously, the efficiency of the MPPT is settled to 100% when operating in the limited power mode. The MPPT efficiency profile of the PV generators can be loaded separately for each generator or unified for all generators integrated to a DC bus. The efficiency profile is defined by means of the coefficients A pvxn−1 and A pvxn−0 of the first order polynomial in (2), which depends on the relationship between the available power P pvxn−1 and the nominal power P pvxn−nom .

DC-DC Converter
To integrate PV generators into a DC bus of the microgrid, at least one DC-DC conversion stage is required. Regardless of the studied bus, the efficiency profiles of the converters are represented using static gains defined by first-order polynomials depending on the converted power. These profiles can be obtained from the results of laboratory tests measuring the efficiency of the converter for different output power values. The efficiency profile is defined by means of the coefficients B pvxn−1 and B pvxn−0 of the expression in (3), which depends on the relationship between the extracted power P pvxn−2 and the nominal power P pvxn−nom .
Computation 2022, 10, 52 6 of 20 At this point, it is also possible to compute the maximum power that can be provided by a PV generator in the mode 2 which corresponds to the maximum power at a defined operation point directly affected by the efficiency of the converter η pv12−dc1 . It is important to mention that the generator may be unable to provide the power defined by the external reference, in which case it will provide a power near to the maximum allowable.
The complete modelling of the PV generators is synthesized in Expressions (6)-(8) computing the output of each block. P pvxn−re f is a power reference given by an outer loop regulating the bus voltage or by a superior layer in the hierarchical architecture of the microgrid control.
The resulting assembly of blocks conforming PV generators is depicted in Figure 2, showing the causal flow of the required computations. At this point, it is also possible to compute the maximum power that can be provided by a PV generator in the mode 2 which corresponds to the maximum power at a defined operation point directly affected by the efficiency of the converter . It is important to mention that the generator may be unable to provide the power defined by the external reference, in which case it will provide a power near to the maximum allowable.
The complete modelling of the PV generators is synthesized in expressions (6)-(8) computing the output of each block.
is a power reference given by an outer loop regulating the bus voltage or by a superior layer in the hierarchical architecture of the microgrid control.
The resulting assembly of blocks conforming PV generators is depicted in Figure 2, showing the causal flow of the required computations.

Modelling of the WTG
The power delivered by a wind generator depends on the chain composed of the following three modules: the wind turbine, the MPPT algorithm, and the power converter which is composed of an AC-DC stage and a DC-DC stage. The wind generator can operate in the modes listed in Table 2. In the modes 0 and 3, the generator is deactivated and its power contribution is zero. In the MPPT mode (namely mode 1), the generator delivers the maximum available power, which is affected by the MPPT efficiency and the AC-DC-DC converter efficiency. Operating in the mode 2, the wind generator delivers a fraction of the available power, tracking an external power reference. In this mode, the power delivered is affected only by the efficiency of the AC-DC-DC converter. The wind turbine static behavior can be modelled by the piece-wise function in ex-

Modelling of the WTG
The power delivered by a wind generator depends on the chain composed of the following three modules: the wind turbine, the MPPT algorithm, and the power converter which is composed of an AC-DC stage and a DC-DC stage. The wind generator can operate in the modes listed in Table 2. In the modes 0 and 3, the generator is deactivated and its power contribution is zero. In the MPPT mode (namely mode 1), the generator delivers the maximum available power, which is affected by the MPPT efficiency and the AC-DC-DC converter efficiency. Operating in the mode 2, the wind generator delivers a fraction of the available power, tracking an external power reference. In this mode, the power delivered is affected only by the efficiency of the AC-DC-DC converter. The wind turbine static behavior can be modelled by the piece-wise function in Expression (9) defining the produced power as a function of the wind speed besides some parameters from the geometry and size of the turbine. The conventional model defining this curve requires the cut-in speed (v cin ), the nominal speed (v rat ), and the cut-out speed (v cout ) of the turbine as follows: where v is the wind speed, ρ the air density, A the area swept by the rotor blades, C p the power coefficient of the turbine, and P rat the nominal power [42]. A simplified version of this model is obtained following the shape of the saturation function as follows: where the resulting piecewise model is defined by the coordinates (V min , 0) and (V max , P max ).

MPPT Algorithm
The efficiency of the MPPT algorithms for wind generators depends on the wind speed or consequently depends on the extracted power. In a practical sense, the same algorithms used for PV generators can be used for wind turbines. The first order expression in (11) models the efficiency of that algorithm as a function of the rated power.

AC-DC-DC Converter
Low-power wind generators are commonly built integrating a Permanent Magnet Synchronous Generator (PMSG) to provide the conversion of mechanical energy into electrical energy. These generators have a three-phase AC output whose voltage and power depend on the wind speed and the connected load. Therefore, to integrate a wind generator into a DC bus of the microgrid, an AC-DC converter is required. The simpler topology is a two-stage power conversion chain composed by a three-phase diode bridge rectifier and a boost-type DC-DC converter, the second allowing the control of the extracted power. The efficiency profile is defined by means of the coefficients B wtxn−1 and B wtxn−0 of the first order polynomial in (12), which depends on the relationship between the extracted power P pvxn−2 and the nominal power P wtxn−nom .
At this point, it is possible also to compute the maximum power that can be provided by the WT generator in the mode 2, which corresponds to the maximum power at a defined operation point directly affected by the efficiency of the converter η wtxn−dc1 . It is important to mention that the generator may be unable to provide the power defined by the external reference, in which case it will provide a power near to the maximum allowable.
P wtxn−aux = max P wtxn−max η pvxn−1 (P wtxn−max ), P wtxn−re f Computation 2022, 10, 52 8 of 20 The complete modelling of the WT generators can be synthesized in Expressions (15)- (17), computing the output of each block. P wtxn−R is a power reference given by an outer control loop.
By assembling the three described modules, the wind generators (WTG) are modelled as depicted in the block diagram presented in Figure 3. Equivalent to the PV generators, the x sub-index defines the bus in which the generator is connected, and the n sub-index differentiates the generators connected to the same bus. By assembling the three described modules, the wind generators (WTG) are modelled as depicted in the block diagram presented in Figure 3. Equivalent to the PV generators, the x sub-index defines the bus in which the generator is connected, and the n subindex differentiates the generators connected to the same bus.

Modelling of the ESU
An Energy Storage Unit (ESU) is composed of a battery array and a bidirectional DC-DC converter which controls its charge/discharge regimes. An ESU can operate in the modes listed in Table 3. In the modes 0 and 3, ESU is deactivated. In the mode 1, batteries are charging according to the external power reference given by control. The maximum power injected is normally defined as a percentage of the nominal capacity given in Amperes multiplied by the charging voltage. This mode can remain active until the battery is charged to a desired level. In the mode 2, batteries are discharged, injecting power into the bus in which the ESU is connected. In this mode, the amount of power delivered by the ESU is defined by an outer reference which can be used to establish the power balance on the bus. To model the ESU, the State of Energy (SoE) indicator is selected [43]. As it can be shown in (18), the battery power is affected by the efficiency factor into the integral term, which allows the establishment of the similitude with the previously defined models of the simulation. The SoE can be defined as:

Bidirectional DC-DC Converter
The bidirectional DC-DC converter used in the ESU can transfer power from the bus to the battery and from the battery to the bus. Normally, the charging process requires a predefined amount of power established by the charge regime (constant current or constant power), but it can also be made using a different amount of power if the ESU regu-

Modelling of the ESU
An Energy Storage Unit (ESU) is composed of a battery array and a bidirectional DC-DC converter which controls its charge/discharge regimes. An ESU can operate in the modes listed in Table 3. In the modes 0 and 3, ESU is deactivated. In the mode 1, batteries are charging according to the external power reference given by control. The maximum power injected is normally defined as a percentage of the nominal capacity given in Amperes multiplied by the charging voltage. This mode can remain active until the battery is charged to a desired level. In the mode 2, batteries are discharged, injecting power into the bus in which the ESU is connected. In this mode, the amount of power delivered by the ESU is defined by an outer reference which can be used to establish the power balance on the bus.

Batteries
To model the ESU, the State of Energy (SoE) indicator is selected [43]. As it can be shown in (18), the battery power is affected by the efficiency factor η e into the integral term, which allows the establishment of the similitude with the previously defined models of the simulation. The SoE can be defined as: Computation 2022, 10, 52 9 of 20

Bidirectional DC-DC Converter
The bidirectional DC-DC converter used in the ESU can transfer power from the bus to the battery and from the battery to the bus. Normally, the charging process requires a predefined amount of power established by the charge regime (constant current or constant power), but it can also be made using a different amount of power if the ESU regulates the voltage of the bus. The efficiency profile of the converter is separately defined for each power flow direction, as normally the voltage level of the buses differs from the voltage level of the battery array. Then, simulation differentiates the efficiency profiles η dcdc2 (P btxn−1 ) and η dcdc1 (P btxn−2 ) for charging and discharging modes, respectively, using expressions with the form of (3). The complete modelling of the ESU can be synthesized in Expressions (19) and (20) computing the output of each block. P btxn−R is a power reference given by an outer loop regulating charge and discharge processes.
By assembling the two described modules, an ESU is modelled as it is depicted in the block diagram presented in Figure 4.  (19) and (20) computing the output of each block. reference given by an outer loop regulating charge and discharge process By assembling the two described modules, an ESU is modelled as it i block diagram presented in Figure 4.

Modelling of the Power Consumption
The DC loads can be classified into three types: constant resistive constant current load (CCL [45]), and constant power load (CPL [46]). T classified into resistive, inductive, capacitive, or nonlinear groups [47]. considers the real power consumption of the loads in both DC and AC bu value that can suffer changes representing connection or disconnection of vention used by the model is .

Modelling of the ILCs
The DC buses 1 and 2 can exchange power through the ILCs. There verters are able to operate with bidirectional power flow. Considering v the DC buses are regulated, the efficiency profile of these converters are curves with the form defined by (3). The possible modes of operation of th listed in Table 4. When the IFC is operating in mode 0, the DC buses of th disconnected, which in fact decouples their operation. In the modes 1 and transfers power from one DC bus to the other.

Mode
Name Convention 0 Converter OFF OFF 0

Modelling of the Power Consumption
The DC loads can be classified into three types: constant resistive load (CRL [44]), constant current load (CCL [45]), and constant power load (CPL [46]). The AC loads are classified into resistive, inductive, capacitive, or nonlinear groups [47]. The simulation considers the real power consumption of the loads in both DC and AC buses as a constant value that can suffer changes representing connection or disconnection of loads. The convention used by the model is P Lx .

Modelling of the ILCs
The DC buses 1 and 2 can exchange power through the ILCs. Therefore, these converters are able to operate with bidirectional power flow. Considering voltage levels of the DC buses are regulated, the efficiency profile of these converters are defined by two curves with the form defined by (3). The possible modes of operation of this converter are listed in Table 4. When the IFC is operating in mode 0, the DC buses of the microgrid are disconnected, which in fact decouples their operation. In the modes 1 and 2, the converter transfers power from one DC bus to the other. The simulation differentiates the efficiency profiles η dcdc1 (P iLm−1 ) and η dcdc2 (P iLm−2 ) for different modes, respectively. The following set of expressions allows the computation of the power at both ports of one ILC.
where P iLm−R1 and P iL−R2 are the power references given by an outer control loop to define the amount of power transferred by one ILC. Parameters N iLm−a and N iLm−b define the priority of the ILCs, indicating which of the two ports fixes the required or demanded power and allowing the computation of the power in the other port. A block diagram of the model of the ILCs is depicted in Figure 5.
Computation 2022, 10, x FOR PEER REVIEW priority of the ILCs, indicating which of the two ports fixes the required or de power and allowing the computation of the power in the other port. A block dia the model of the ILCs is depicted in Figure 5.

Modelling of the IFCs
The DC buses are connected to the AC side of the microgrid through the IFC converters are able to operate with bidirectional power flow. However, when they connected to the auxiliary generator, the flow is limited to transfer power from th ator to the microgrid. As shown in Table 5, these converters have four operation When the converter is OFF, the AC loads can only be fed directly from the gri generator. When the IFCs are operating in stand-alone mode (mode 1), they feed loads. In modes 2 and 3, the IFCs are connected to the auxiliary generator or to t and they establish the power balance of the DC buses.  where is the power reference given by the control to define the amount o transferred by the IFCs to or from a DC port and is the power load fed a side (see expressions (25) and (26)). Parameter indicates if one IFC is oper SAC mode while parameters and define the priority of the ILCs, in which of the two ports fixes the demanded or delivered power. A block diagram

Modelling of the IFCs
The DC buses are connected to the AC side of the microgrid through the IFCs. These converters are able to operate with bidirectional power flow. However, when they operate connected to the auxiliary generator, the flow is limited to transfer power from the generator to the microgrid. As shown in Table 5, these converters have four operation modes. When the converter is OFF, the AC loads can only be fed directly from the grid or the generator. When the IFCs are operating in stand-alone mode (mode 1), they feed the AC loads. In modes 2 and 3, the IFCs are connected to the auxiliary generator or to the grid, and they establish the power balance of the DC buses. A conditional logic was designed to avoid other possible modes resulting from undesired combinations of the N i f cx−a values. The efficiency profiles of the IFCs are defined separately for operation in the two possible power directions. The efficiency profiles η dcacx (P iFx−1 ) and η acdcx (P iFx−2 ) have the form defined by Expression (3). The following set of expressions allows for the computation of the power at both ports of the IFCs.
where P i f cx−1R is the power reference given by the control to define the amount of power transferred by the IFCs to or from a DC port and P iFx−2L is the power load fed at the AC side (see Expressions (25) and (26)). Parameter N iFx−a indicates if one IFC is operating in SAC mode while parameters N iFx−b and N iFx−c define the priority of the ILCs, indicating which of the two ports fixes the demanded or delivered power. A block diagram of the model of the IFCs is depicted in Figure 6.
where is the power reference given by the control to define the amount of power transferred by the IFCs to or from a DC port and is the power load fed at the AC side (see expressions (25) and (26)). Parameter indicates if one IFC is operating in SAC mode while parameters and define the priority of the ILCs, indicating which of the two ports fixes the demanded or delivered power. A block diagram of the model of the IFCs is depicted in Figure 6.

Modelling of the DC Buses
The DC buses allow the interconnection of the generation, storage, and consumption units. Each DC bus also integrates the power injected or extracted by one IFC and two

Modelling of the DC Buses
The DC buses allow the interconnection of the generation, storage, and consumption units. Each DC bus also integrates the power injected or extracted by one IFC and two ILCs. The model of each bus computes the instantaneous power balance defined by the variable ∆ P1 providing information to define the references of the control. A block diagram of the model corresponding to the DC bus 1 is depicted in Figure 7.

Modelling of the AC Side Interconnection
In the studied microgrid architecture, it is possible to feed the AC pow tion from three sources: the AC grid, an auxiliary fuel generator, and through the IFCs operating in SAC mode. The presence of the AC grid and generator will determine if the AC load consumption will be covered them or indirectly through one or both of the IFCs. The following expressio elling of the AC side of the microgrid: The parameter is defined as the sharing index taking values between and defines the percentage of contribution of the IFCs operating as SAC feed is an integer variable taking values into the set 0, 1 and defining th the IFC in SAC mode. The power of the AC sources is defined by: Parameter defines which AC source fed the loads. Table 6 summa nection/disconnection logic of the AC side.

Modelling of the AC Side Interconnection
In the studied microgrid architecture, it is possible to feed the AC power consumption from three sources: the AC grid, an auxiliary fuel generator, and the DC buses through the IFCs operating in SAC mode. The presence of the AC grid and the auxiliary generator will determine if the AC load consumption P L3 will be covered directly from them or indirectly through one or both of the IFCs. The following expressions allow modelling of the AC side of the microgrid: P iF1−2L (k) = P L3 N ac2 K L (25) The parameter K L is defined as the sharing index taking values between zero and one and defines the percentage of contribution of the IFCs operating as SAC feeding the loads. N ac3 is an integer variable taking values into the set {0, 1} and defining the operation of the IFC in SAC mode. The power of the AC sources is defined by: Parameter N acx defines which AC source fed the loads. Table 6 summarizes the connection/disconnection logic of the AC side. A block diagram of the model of the AC side is depicted in Figure 8.

Modes of Operation and Special Features of the Sim
By considering the multiple modes of opera crogrid, the whole operation can be configured, but ing modes:

Modes of Operation and Special Features of the Simulated Microgrid
By considering the multiple modes of operation of the different units of the microgrid, the whole operation can be configured, but is not limited to operate in the following modes: There is no AC source and the microgrid cannot produce enough energy to feed the AC loads, feeding the DC loads as priority.

•
Islanded/SAC (ISL-SAC): There is no AC source but the local generation is enough to feed both the DC and AC loads. • Grid/Grid (GRD/GRD): In this case, the grid has good quality and shares power consumption with the microgrid, which transfers power through the IFC.
A list of the suggested modes of operation is presented in Table 7 (Tables 1-6 define the conventions of the modes and the corresponding values of N xxx for each of them).

Simulation Implementation
The simplified model developed in this work was implemented in a virtual instrument in the LabVIEW platform to obtain the continuous property. The main specifications for the software development were:

•
The user configures the parameters of the models of solar panels, wind turbines and batteries.

•
The user provides the coefficients of efficiency profiles of power converters and MPPT algorithms.

•
The user can change online environmental variables and power consumptions.

•
The simulation can interact with other algorithms through global variables.
The microgrid architecture depicted in Figure 9 was selected to provide details of the model programming. As it can be observed, the example has one PVG and one WTG integrated in the DC bus 1, one ESU integrated in the DC bus 1, one PVG integrated in the DC bus 2, one ILC interconnecting the DC bus 1 and the DC bus 2, and one IFC interconnecting the DC bus 2 with the AC bus. The programed functions developed for each of these units are shown in Figures 10-14. Please consider that unlike the other units, programming of the ESU requires the creation of a shift register to obtain the delayed sample required to implement the integral function of the SoE (ESS = SoE(k) and EES1 = SoE(k − 1)). tegrated in the DC bus 1, one ESU integrated in the DC bus 1, one PVG integrated in the DC bus 2, one ILC interconnecting the DC bus 1 and the DC bus 2, and one IFC interconnecting the DC bus 2 with the AC bus. The programed functions developed for each of these units are shown in Figures 10-14. Please consider that unlike the other units, programming of the ESU requires the creation of a shift register to obtain the delayed sample required to implement the integral function of the SoE ( = ( ) and 1 = ( − 1)).  . Figure 11. LabVIEW programming for WT generators.  . Figure 11. LabVIEW programming for WT generators.  . Figure 11. LabVIEW programming for WT generators.     As the different modules were programmed as subVis (in the context of LabVIEW programming), they could be inserted into the model of the whole microgrid, which was developed using three whole loops running separately (one loop per bus as shown in Figures 15-17). The variables shared between buses through the ILC and IFC units were programmed as local variables. The loads connected to the buses were implemented as input variables. Controls and indicators used in the simulation were placed into a user interface, which is depicted in Figure 18.  As the different modules were programmed as subVis (in the context of LabVIEW programming), they could be inserted into the model of the whole microgrid, which was developed using three whole loops running separately (one loop per bus as shown in Figures 15-17). The variables shared between buses through the ILC and IFC units were programmed as local variables. The loads connected to the buses were implemented as input variables. Controls and indicators used in the simulation were placed into a user interface, which is depicted in Figure 18. As the different modules were programmed as subVis (in the context of LabVIEW programming), they could be inserted into the model of the whole microgrid, which was developed using three whole loops running separately (one loop per bus as shown in Figures 15-17). The variables shared between buses through the ILC and IFC units were programmed as local variables. The loads connected to the buses were implemented as input variables. Controls and indicators used in the simulation were placed into a user interface, which is depicted in Figure 18.

Parameters of the Simulation
Simulations considered 250 W commercial solar panels [48], 300 W Permanent Magnet Generator Wind Turbines [49], and 12 V batteries with capacities of 100 Ah [50]. The main parameters are summarized in Table 8. To facilitate correctness of the computations in the simulation, the efficiency of the MPPT and the efficiency profiles of all converters were defined by the following expressions using only the first order and constant terms: where P nom is the nominal power of the converter, which is defined as 3 kW.

Test Using Predefined Scenarios
Three scenarios were chosen for tests providing simulated results: Grid-connected GRD-GRD (night), Grid-connected GRD-GRD (day), and Islanded mode (ISL-SAC). The possible configurations of the microgrid to face each scenario are uncountable. A definition of the modes in which the units must operate to face each one of the selected scenarios is given in Table 9 (take this configuration only as example). GRD-GRD (day): Similar to the previous scenario, the complete operation of the microgrid is required to feed the connected loads. The IFCs operate in grid-connected mode either as inverters or rectifiers. The ESU is settled to charging mode. 3.
ISL-SAC: In this scenario, the microgrid operates without AC power supplied from the grid but the AC loads are fed by the IFC, which operates as SAC. The IFC cannot regulate the voltage of the DC bus 2, forcing the ILC to perform this task. As a consequence, the voltage of the DC bus 1 is regulated by the ESU, which can pass from a charging mode to a discharging mode depending on the renewable energy production which operates at MPPT.

Results for Scenario 1: Operation in GRD-GRD (Night)
In this scenario, the PVGs were off and the WTG contributed to the DC bus 1 with powers between 1500 and 2500 W. The total consumption of the loads into the microgrid varied between 2000 and 5000 W. The resulting power values establishing the stable operation of the microgrid in the example are presented in Table 10. In this scenario, voltage regulation of the DC bus 1 was performed by the ILC while the voltage regulation of the DC bus 2 was performed by the IFC. In the three cases, the deficit of power was covered from the grid. In the first case, the efficiency was computed as 91.7%. In the second case, the efficiency was computed as 87.5%. In the third case, the efficiency was computed as 80%. As expected, these are the results obtained using the control rules manually provided to the simulation, which do not use the ESU to cover consumption. Then, for the other set of control rules, for example, the consumption of the DC bus 1 can be covered from the ESU while the consumption of the DC bus 2 is covered from the grid.

Results for Scenario 2: Operation in GRD-GRD (Day)
In this scenario, the microgrid fed the same power loads as in the cases of the previous scenario. The PVGs contributed with powers between 500 and 1500 W and the WTG contributed to the DC bus 1 with three different powers between 1300 and 2500 W. The total consumption of the loads into the microgrid varied between 2000 and 5500 W. The resulting power values establishing the stable operation of the microgrid in the example are presented in Table 11. In this scenario, regulation of the buses was performed in the same way as it was performed for the scenario 1. In the three cases, the deficit of power was covered from the grid. In the first case, the efficiency was computed as 85.2%. In the second case, the efficiency was computed as 88%. In the third case, the efficiency was computed as 83.8%. As expected, these are the results obtained using the control rules manually provided to the simulation, which do not use the ESU to cover consumption. Then, for the other set of control rules, for example, the consumption of the DC bus 1 can be covered from the ESU while the consumption of the DC bus 2 is covered from the grid.

Results for Scenario 3: Operation in ISL-SAC Mode
In this scenario, the microgrid fed the same power load as in the previous scenarios. The PVGs contributed with powers between 1000 and 1500 W while the WTG contributed with powers between 1000 and 2500 W. The resulting power values establishing the stable operation of the microgrid in the control example are presented in Table 12. In this scenario, voltage regulation of the DC bus 1 was performed by the ESU1 while the voltage regulation of the DC bus 2 was performed by the ILC1. The IFC1 was deactivated while the IFC2 operated as SAC, feeding the AC load. In the three cases, the power consumption was entirely covered by the microgrid. The efficiency was computed as 86%, 80.5%, and 84.4% for each case, respectively.

Conclusions
A flexible and simple model was proposed in this paper, allowing for the easy simulation of the power flow behavior for hybrid microgrids. The use of simplified models of solar panels, wind turbines, batteries, and loads and a binary logic to configure the operation of the microgrid allowed us to considerably reduce the computational cost of the simulation. Complementarily, the use of efficiency profiles to accurately model power-processing stages and MPPT algorithms increased the accuracy of the simulation without increasing its complexity, and allowed us to evaluate the efficiency of the entire microgrid for the studied scenarios and cases, providing elements to analyze how to improve the whole performance of the system. Simulated models were implemented in LabVIEW software.
Simple control rules ensuring power balances in DC and AC buses were used to test the functionality of the model in examples for three different scenarios (night and day operation having grid connection and islanding mode feeding AC loads) and three different cases in each of them, in which differences were introduced for power production and consumption. The power flow of the microgrid was analyzed from the power transferred by the IFC and ILC bidirectional converters.
As a relevant contribution to the study of microgrids, this simulation can operate as a model with input parameters and variables and output variables able to interact with other algorithms performing control functions. Moreover, the results showed the potentiality of the proposed model to serve as a plant to study the application of control algorithms in both educational and research environments.

Conflicts of Interest:
The authors declare no conflict of interest.