Introduction

Electric microgrids are seen as a crucial global need to tackle the energy and environmental issues that our planet faces. The main reasons for this shift include the rapid increase in global energy demand, a growing focus on electric mobility, the declining condition of existing infrastructure, and the empowerment of consumers [1, 2].

Table 1 Characteristics of the five microgrids developed in the research program

A microgrid is an independent power system that consists of distributed energy resources (DERs) such as distributed generators (DG), energy storage systems (ESS) and loads (some controllable) [3]. While integrating power electronics (PE) and renewable energy sources (RES) through microgrids has many benefits, it also presents challenges. For example, careful planning is required to transition medium and low voltage networks from passive to active during the initial stage of a microgrid project. The widespread use of power electronics converters and their voltage and frequency regulation issues must also be considered [3, 4]. Adequate control architectures and optimal power dispatch of DERs are needed to ensure that the microgrid operates as expected and provides economic access to electricity [5, 6].

Power dispatch in microgrids refers to the process of managing and distributing power generated by DERs within a microgrid. This can be a challenging task due to factors such as the intermittent nature of renewable energy sources and the need for coordination among multiple resources. Different control strategies can be used to efficiently allocate resources and optimize power dispatch within a microgrid [7, 8]. Economic dispatch of active power can also help minimize generation costs by taking advantage of cheaper renewable generators such as photovoltaic and wind turbines [8].

One approach to power dispatch in microgrids is through optimal power dispatching strategies that aim to minimize global energy costs, while considering forecasts for consumption and production as well as possible constraints imposed by the main grid operator [9]. Distributed control strategies can also be used to efficiently allocate resources and optimize power dispatch within a microgrid [10].

Nowadays, different approaches involve implementing optimal energy management and power sharing control using modern and classical strategies such as game theory [11], hyperfine optimization [12], mixed-integer linear programming (MILP) [9, 13], gravitational-search algorithm and random forest regression [14], quadratic programming (QP)[15, 16], model predictive control (MPC) [17], particle swarm optimization (PSO) [18], among others. Also, complementary works consider additional or secondary functionalities to the energy management as reactive power dispatch for voltage regulation in islanded microgrids [8], optimal battery charging and discharging plan defined by time-based electricity price mechanism [19], pollutant emissions minimization for traditional generators management under an environmental cost function [10], combined heating, cooling and electricity dispatch for large buildings and microgrids [14, 20]. New optimization principles can help improve the efficiency of the overall system, reduce operating costs, and enable fast return on investment.

On the other hand, most of the current developments for optimal dispatch and power management in microgrids only consider simulation testing of the proposed control systems, as in [6, 21, 22]. Only few works are experimentally implemented on physical microgrids, as current proposals are mainly focused on laboratory-scale grids with simulated devices [23, 24], with some works emphasizing on the energy management and generation/load forecast of real-time simulated isolated grids [25], and even recent mobile-clustered hybrid energy system developments with an integrated power control as in [26]. However, minor contributions with medium-scale real microgrid systems can be found as in [17].

Medium-scale experimental microgrids face significant challenges in developing tailored control systems and power management strategies. This is due to limitations in the flexibility and controllability of commercial devices such as power converters that make up the microgrid resources. These devices are often industrial-made mechanisms with limited parameter setting and internal tuning capabilities, making it difficult to achieve primary control characteristics. As a result, secondary and tertiary levels of control must be implemented. Additionally, medium-scale experimental microgrids must contend with uncertainties, disturbances, communication issues, and other typical restrictions such us the inability to operate in complete isolation and the need for a high-level aggregator to manage economic, energy, and electrical functioning further complicate matters.

This way, five microgrids were created in Colombia by the research program “Strategies for the transformation of the Colombian energy sector in the 2030 horizon - Energética 2030” to test power dispatch and control strategies. The microgrids include one located at the national electric grid operator ISA, in Medellin city, and four located at university campuses across the nation, including the Universidad Pontificia Bolivariana (UPB) campus. These medium-sized experimental microgrids can generate up to 400 kWp of renewable energy individually. Table 1 provides a general description of their characteristics.

The research project involves adding new DERs to the microgrids following [27] and developing a multi-level Energy Management System (EMS). The EMS serves as the energy, economic, and electrical manager of the microgrid and includes a high-level aggregator agent that collects performance data from the five microgrids. The EMS is responsible for various tasks that are categorized based on control techniques. A centralized hierarchical EMS was built for the campus microgrids, which consists of primary (local voltage and current management of DERs), secondary (voltage, frequency, power regulation, and optimal energy dispatch), and tertiary (mode transition and external grid relation) control levels, guided by [28]. The main control and management functions of the developed EMS are a model predictive voltage control strategy based on reactive power regulation described in [29] and implemented in [30], and the optimal active power dispatch architecture described in the present work.

To face and solve the aforementioned challenges of optimal power dispatch and secondary control of microgrids, in the present work a flexible hourly day-ahead power dispatch architecture for distributed energy resources is proposed based on linear-programming optimization considering forecasts for consumption and generation. The power management scheme is experimentally tested in a university campus microgrid in Colombia with previous tuning and testing on a real-time simulated grid, through a remote RTDS digital simulator owned by the national energy market operator XM and accessed through a P2P VPN connection from the university campus. The designed architecture is built up in a multi-class Python environment with SQLExpress and InfluxDB databases storing the dispatcher and microgrid data, and Modbus communication with physical devices.

The control system considers mathematical power model of photovoltaic sources (PV), battery energy storage systems (BESS), diesel generators, biogas generators, external grid and electric loads. Also, the scheme makes use of solar irradiance and power demand forecasts to consider day-ahead renewable generation availability and expected load. A workstation computer with Intel Xeon E-2224G processor and 64 GB of RAM, with wired access to the communications network of the campus and Python 3.9 running on Spyder IDE, is used to experimentally test the dispatch strategy in the UPB campus microgrid. The real-time power management architecture includes data-gathering, database communication, meteorological and demand forecasting, and power control setpoint writing.

The objective of this study is then to present a flexible day-ahead power dispatch architecture to be implemented in experimental real-scale microgrids. The control scheme relies on power models of DERs, so the optimal active power setpoint is calculated based on meteorological and power demand forecasts, testing the architecture in a real-time simulated grid and a physical campus microgrid. This way, the paper is organized as follows: In “Energy Management Methodology” the experimental power dispatch architecture is described, integrated DERs models are detailed and the general operation classes and functionalities of the control scheme are presented. Next, in “Optimal Dispatch Architecture Implementation” the test cases of the dispatch strategy are described and the operation results are presented, including a medium-scale real-time simulated microgrid and the experimental implementation in the UPB campus microgrid as the main result of this work. Finally, in “Conclusions and Future Work” conclusions and future work are carried out.

Energy Management Methodology

Control Architecture

The economic dispatch system is responsible for the optimal calculation and active power setpoint commanding to controllable energy resources for each of the twenty-four hours of the following day’s dispatch (day-ahead dispatch). The complete architecture is developed through code in a Python multi-class environment.

The capture of initial system operational electrical measurements, the reading of necessary weather forecast conditions to calculate future states, and the dispatching of resulting control commands to manipulated resources within the corresponding period are integrated through code in the communication and operation logic of the program. The optimal power dispatch architecture for experimental implementation in microgrids and active distribution networks is presented in Fig. 1.

Fig. 1
figure 1

Proposed experimental control architecture

As depicted in the diagram, the operational logic begins with the construction of device tables for the microgrid components that are to be integrated into the dispatch scheme. These device tables have a fixed structure where the model parameters for each resource are defined, as detailed in “Distributed Energy Resources Modeling”. They also include hourly energy costs for each device and the fuel supply schedule for biogas and diesel plants, all of which are necessary to optimize the active power dispatch for the following day. Additionally, the power variables, state of charge, fuel volume, and demand variables from the microgrid database are linked in this table. This table can be easily constructed using a tool like Microsoft Excel and updated in the SQL Server database of the microgrid through a simple query.

Once the table of controllable resources is defined, the operating mode of the dispatcher is selected, either based on cost or based on demand. Cost-based dispatch optimization aims to minimize the levelized hourly cost of grid energy in USD/kWh by considering the generation costs of each resource, their power capacities, and operational constraints. Demand-based optimization aims to reduce peak loads in the microgrid and flatten the demand curve under a peak-shaving logic, minimizing the energy import from the external grid through optimal management of charging and discharging cycles of BESS devices. The optimization strategies of the architecture are detailed in “Power Dispatch Optimization”.

Continuing with the controller flow, the initial connection is made to the InfluxDB database (measurements and forecasts) and SQL database (device parameters and energy costs), bringing into the execution environment the model data, constraints, energy costs, and fuel supply for optimizer operation. Next, the initial values of energy variables such as generation and demand powers, states of charge, and fuel volumes, are acquired from the 23:15 data available in the InfluxDB database, which is populated by the Collector Agent of the EMS. Additionally, forecast values of weather variables (solar irradiance G and ambient temperature T) and electrical demand for each hour of the dispatched day are acquired from the InfluxDB database of the Microgrid Aggregator Agent, which is populated by various additional functionalities of the complete EMS.

Now that the program environment has integrated the information of models, constraints, initial states, and forecast variables, the hourly optimization is executed to calculate the power setpoints for every DER of the microgrid, either based on cost or demand. The dispatch results for each device are written to the InfluxDB database for storage and further analysis. These commands are written to the database with the corresponding future timestamp for each of the twenty-four periods of the day.

In the next step, the optimal active power setpoints for generation resources and charging/discharging of storage devices are sent to the physical equipment in the microgrid via Modbus TCP/IP protocol during the corresponding period, aiming to generate the required power to fulfill the economic operational plan of the system for each hour. Similar to the database writing, the Modbus transmission of these setpoints is executed at the appropriate instant for each of the twenty-four dispatch periods.

Finally, after the twenty-four operating periods of the system have been dispatched, at 23:15, the control program restarts the connection with databases and automatically begins a new execution of the optimal dispatch architecture for the next day. Additionally, the code has been prepared to continue operating during most communication problems with devices and databases, so that execution continues for the available resources that can be controlled.

Having defined the integrated architecture for optimal power dispatch in the microgrid, the following section details the mathematical models and constraints for the diverse types of energy resources considered in the energy management system.

Distributed Energy Resources Modeling

In this section, the mathematical models used to calculate the power generation and energy storage of DERs integrated to the optimal dispatch architecture are presented, including photovoltaic, biogas, and diesel generation models, and battery storage systems. These models are used to predict the behavior of different resources within the controlled microgrid and feed into the proposed dispatch algorithm.

Photovoltaic System

The power generated by a photovoltaic module depends mainly on the solar irradiance received by the panel and the ambient temperature. Equation 1 is used as a general photovoltaic module power model, taking into account the available solar irradiance of the location, temperature corrections for the generated power, and lifetime degradation [31,32,33,34]. This classical model is adapted to depend on the solar radiation G(h) and ambient temperature \(T_M(h)\) for each time-period h of the next dispatched day.

$$\begin{aligned} P_m(h)=f_{pv}\cdot \frac{G(h)}{G_0}\cdot {P_m^M}[1+\mu _{Pm}\cdot (T_M(h)+G(h)\cdot \frac{T_N-20}{800}-T_{M0})] \end{aligned}$$
(1)

Where:

\(P_m(h)\): Active power of the photovoltaic module for each dispatch period h, [W]

\(f_{pv}\): Reduction factor of the module power according to the years of operation

G(h): Solar irradiance at the location of the photovoltaic system for each dispatch period h, [\(W/m^2\)]

\(G_0\): Solar irradiance under standard operating conditions of the modules, typically 1000 \(W/m^2\), [\(W/m^2\)]

\(P_m^M\): Nominal power of each photovoltaic module in the system, [W]

\(\mu _{Pm}\): Coefficient of power variation with temperature at the maximum power point, [%/\(^{\circ }\) \(C\)]

\(T_M(h)\): Ambient temperature at the location of the photovoltaic system for each dispatch period h, [\(^{\circ }\) \(C\)]

\(T_N\): Normal ambient operating temperature of the modules, typically 20 \(^{\circ }\)C, [\(^{\circ }\) \(C\)]

\(T_{M0}\): Ambient temperature under standard operating conditions of the modules, typically 25 \(^{\circ }\)C, [\(^{\circ }\) \(C\)]

The power of the entire photovoltaic system, in kW, will be the power of each module multiplied by the total number of panels, as shown in Eq. 2.

$$\begin{aligned} P_{pv}(h)=\frac{N_{pv}\cdot {P_m(h)}}{1000} \end{aligned}$$
(2)

Where:

\(P_{pv}(h)\): Power of the photovoltaic generator for each dispatch period h, [kW]

\(N_{pv}\): Number of photovoltaic modules

The constraints of the photovoltaic system model are based on the peak power limits and the minimum generation power (typically zero) of the entire resource. Thus, the dispatch constraint is determined by Eq. 3.

$$\begin{aligned} P_{pv_{\text {min}}} \le P_{pv}(h) \le P_{pv_{\text {max}}} \end{aligned}$$
(3)

Where:

\(P_{pv_{\text {min}}}\): Minimum generation power of the system, [kW]

\(P_{pv_{\text {max}}}\): Maximum generation power of the system, [kW]

The SQL database where DERs are configured to integrate into the dispatch system of the microgrid, allows for the definition of the aforementioned parameters for the photovoltaic source to accurately specify its capacities and characteristics. Additionally, the solar irradiance and temperature values for the next-day dispatch are provided by the forecasting module of the EMS through the InfluxDB database of the Microgrid Aggregator.

Biogas Generator

The power of the biogas generator is related to the low heating value (LHV) of the biogas, the fuel flow rate per unit of time, and the equivalent efficiency of the generator. Equation 4 describes this behavior. The model is based on the diesel generator from [31, 35, 36] and the recommendations of fellow researchers experienced in bioenergy systems (see [37] for reference).

$$\begin{aligned} P_{bg}(h)=\eta _{bg} \cdot LHV_{bg} \cdot Q_{bg}(h) \end{aligned}$$
(4)

Where:

\(P_{bg}(h)\): Power of the biogas generator for each dispatch period h, [kW]

\(\mu _{bg}\): Equivalent efficiency of the biogas generator

\(LHV_{bg}\): Lower heating value of the biogas, [kWh/L]

\(Q_{bg}(h)\): Biogas flow rate injected into the generator for each dispatch period h, [L/h]

The volume of biogas in the storage tank is an important constraint variable that must be considered by the optimal dispatch controller, as it determines the availability of generation for future time periods. Thus, the standard volume of biogas available in the next dispatch period is defined as:

$$\begin{aligned} V_{bg}(h+1)=V_{bg}(h)+V_{{bg}_{supply}}(h)-Q_{bg}(h) \cdot h \end{aligned}$$
(5)

Where:

\(V_{bg}(h)\): Standard volume of biogas available for each dispatch period h, [L]

\(V_{{bg}_{supply}}(h)\): Standard volume externally supplied to the biogas storage tank for each dispatch period h, [L]

It is important to clarify that the calculations for biogas storage are performed in standard volume units, considering normalized conditions of temperature at 25 \(^{\circ }\)C and pressure at 100 kPa.

The dispatch system has been designed with a logic such that if the biogas storage reaches the maximum capacity of the tank in a given period, the dispatcher will perform generation of the resource in the immediately following period, in order to ensure storage availability for new biogas production from biomass.

The constraints of the biogas generator model are based on the power limits of the coupled generator and the minimum and maximum capacities of the storage tank. Therefore, the dispatch constraints are determined by the following equations:

$$\begin{aligned} P_{{bg}_{\text {min}}} \le P_{bg}(h) \le P_{{bg}_{\text {max}}} \end{aligned}$$
(6)
$$\begin{aligned} V_{{bg}_{\text {min}}} \le V_{bg}(h) \le V_{{bg}_{\text {max}}} \end{aligned}$$
(7)

Where:

\(P_{{bg}_{\text {min}}}\): Minimum power of the coupled generator, [kW]

\(P_{{bg}_{\text {max}}}\): Maximum power of the coupled generator, [kW]

\(V_{{bg}_{\text {min}}}\): Minimum volume of the stored biogas, [L]

\(V_{{bg}_{\text {max}}}\): Maximum volume of the stored biogas, [L]

Equation 6 integrates the power constraints of the coupled generator, and Eq. 7 integrates the volume constraint of the biogas tank.

Similarly to the photovoltaic systems, the SQL database where the energy resources are configured to integrate into the dispatch system, allows for specifying each of the aforementioned parameters of the biogas generators to accurately define their capacities and characteristics. Additionally, the values of biogas supply to the storage tank are defined by the user for all dispatch periods, according to their planned biomass filling and biogas production.

Diesel Generator

Equivalent to the biogas case, since we are dealing with thermal machines, the power of the diesel generator is related to the LHV of the diesel fuel, the fuel flow rate per unit time, and the equivalent efficiency of the generator. Equation 8 describes this behavior. The model is based on the information presented in [31, 35, 36] and recommendations from project researchers with expertise in the field of thermal generators.

$$\begin{aligned} P_{di}(h)=\eta _{di} \cdot LHV_{di} \cdot Q_{di}(h) \end{aligned}$$
(8)

Where:

\(P_{di}(h)\): Power of the diesel generator for each dispatch period h, [kW]

\(\mu _{di}\): Equivalent efficiency of the diesel generator

\(LHV_{di}\): Lower heating value of the diesel fuel, [kWh/L]

\(Q_{di} (h)\): Diesel flow rate injected into the generator for each dispatch period h, [L/h]

On the other hand, the volume of diesel in the storage tank is a constraint variable considered by the economic dispatcher, determining the availability of generation for future instances. Thus, the available volume of diesel fuel in the next dispatch period is defined as:

$$\begin{aligned} V_{di}(h+1)=V_{di}(h)+V_{{di}_{supply}}(h)-Q_{di}(h) \cdot h \end{aligned}$$
(9)

Where:

\(V_{di}(h)\): Available volume of diesel for each dispatch period h, [L]

\(V_{{di}_{supply}}(h)\): Externally supplied volume to the diesel storage tank for each dispatch period h, [L]

The constraints of the diesel plant model are based on the power limits of the generator and the minimum and maximum storage capacities allowed for the storage tank. Thus, the dispatch constraints are determined by the following equations:

$$\begin{aligned} P_{{di}_{\text {min}}} \le P_{di}(h) \le P_{{di}_{\text {max}}} \end{aligned}$$
(10)
$$\begin{aligned} V_{{di}_{\text {min}}} \le V_{di}(h) \le V_{{di}_{\text {max}}} \end{aligned}$$
(11)

Where:

\(P_{{di}_{\text {min}}}\): Minimum power of the coupled generator, [kW]

\(P_{{di}_{\text {max}}}\): Maximum power of the coupled generator, [kW]

\(V_{{di}_{\text {min}}}\): Minimum volume of the diesel tank, [L]

\(V_{{di}_{\text {max}}}\): Maximum volume of the diesel tank, [L]

Equation 10 integrates the power constraints of the coupled generator, and Eq. 11 integrates the volume constraint of the diesel fuel tank.

Similar to the previous systems, the SQL database where energy resources are configured to integrate into the dispatch system, allows for the definition of the aforementioned parameters for the diesel generator to accurately specify its capacities and characteristics. Additionally, the fuel supply values to the storage tank are defined by the user for all dispatch periods, according to their planned refilling schedule.

Battery Energy Storage System

For the economic dispatch of microgrids, Battery Energy Storage Systems (BESS) are considered. These systems can be integrated by different storage banks and inverters, where each battery-inverter set is optimized and dispatched separately. Furthermore, the charging and discharging powers are represented by separate variables, \(P_{bc}\) and \(P_{bd}\) respectively. The charging power is considered negative, while the discharging power is positive. Equation 12, based on [35, 36], describes the available energy stored in the battery for future dispatch periods, taking into account the previous state of charge, dispatched powers, and efficiencies.

$$\begin{aligned} E_b(h+1)=E_b(h)\cdot (1-\gamma _{sd} )+[\eta _{bc}\cdot P_{bc}(h)-\frac{1}{\eta _{bd}} \cdot P_{bd}(h)] \end{aligned}$$
(12)

Where:

\(E_b(h)\): Energy stored in the batteries for each dispatch period h, [kWh]

\(\gamma _{sd}\): Self-discharge coefficient of the batteries

\(\eta _{bc}\): Charging efficiency of the BESS

\(\eta _{bd}\): Discharging efficiency of the BESS

\(P_{bc}(h)\): Charging power of the BESS for each dispatch period h, with negative values, [kW]

\(P_{bd}(h)\): Discharging power of the BESS for each dispatch period h, with positive values, [kW]

As stated before in “Control Architecture”, the dispatch architecture manages the charging and discharging of batteries based on two different logics: energy price and peak demand shaving. Guided by price, the BESS will be charged during periods of lower energy cost considering a microgrid without storage (ideal dispatch), and will be discharged during periods of higher prices. Guided by demand, the system will be charged during periods of lower energy consumption in the microgrid, and will be discharged during periods of higher demand. Furthermore, complete charge and discharge cycles are always ensured to preserve the health of the batteries, and it is intended to fulfill at least one charge/discharge cycle per day, depending on the availability of energy resulting from the previous dispatched day.

The constraints of the BESS model are based on the limits for the charging and discharging power, and the minimum and maximum storage capacities. Thus, the dispatch constraints are determined by the following equations:

$$\begin{aligned}P_{{bc}_{\text {min}}} \le P_{bc}(h) \le P_{{bc}_{\text {max}}}\\ P_{{bd}_{\text {min}}} \le P_{bd}(h) \le P_{{bd}_{\text {max}}}\end{aligned}$$
(13)
$$\begin{aligned} \begin{gathered} -\eta _{bc} \cdot P_{bc}(h+1)-\frac{1}{\eta _{bd}} \cdot P_{bd}(h+1) \ge \\ E_{\text {min}}-(1-\gamma _{sd})\cdot [E_b(h)\cdot (1-\gamma _{sd})-\eta _{bc}\cdot P_{bc}(h)-\frac{1}{\eta _{bd}} \cdot P_{bd}(h)] \end{gathered} \end{aligned}$$
(14)
$$\begin{aligned} \begin{gathered} -\eta _{bc} \cdot P_{bc}(h+1)-\frac{1}{\eta _{bd}} \cdot P_{bd}(h+1) \le \\ E_{\text {max}}-(1-\gamma _{sd})\cdot [E_b(h)\cdot (1-\gamma _{sd})-\eta _{bc}\cdot P_{bc}(h)-\frac{1}{\eta _{bd}} \cdot P_{bd}(h)] \end{gathered} \end{aligned}$$
(15)

Where:

\(P_{{bc}_{\text {min}}}\): Minimum charging power, [kW]

\(P_{{bc}_{\text {max}}}\): Maximum charging power, [kW]

\(P_{{bd}_{\text {min}}}\): Minimum discharging power, [kW]

\(P_{{bd}_{\text {max}}}\): Maximum discharging power, [kW]

\(E_{\text {min}}\): Minimum energy storage of the batteries, [kWh]

\(E_{\text {max}}\): Maximum energy storage of the batteries, [kWh]

Equation 13 integrates the constraints on charging and discharging power. Equations 14 and 15 integrate the constraints on minimum and maximum energy storage for the next dispatch period.

Similar to the previous DER models, the SQL database where energy resources are configured to integrate into the dispatch system, allows for the definition of each parameter and constraint of the BESS devices, ensuring accurate specification of their capacities and characteristics.

This way, the optimal dispatch controller system is fed with the energy resource models based on the parameters and operational variables stored in the databases. Next section details the connection, architecture, and integration of the variables and devices databases within the proposed comprehensive energy management scheme.

Database Management

The proposed architecture for the development of the EMS for microgrids includes two databases to support each of the four operational modules: electrical, forecasting, monitoring, and optimal dispatch. The first database is a relational database (SQL) instantiated in the Microsoft SQL Server engine. The second one is a non-relational database (NoSQL) oriented towards time-series data, instantiated in the InfluxDB engine. The following is a description of these databases and their functionalities related to the optimal dispatch architecture.

A relational database consists of a collection of data organized into tables that are related to each other. Its main purpose is to provide users with a perception or view of the database as a logical structure consisting of a set of relationships, rather than as a physical implementation structure. This helps achieve a high degree of data independence [38].

These characteristics make SQL databases an appropriate tool for designing a mapping database allowing the dispatch architecture to store the technical information of each microgrid DER, as well as the communication information to access different system variables [39, 40].

NoSQL (acronym for Not only Structured Query Language) refers to a set of database technologies that seek alternatives to the relational database system, emphasizing speed, handling large volumes of data, and the ability to have a distributed system [38, 41, 42]. They are an agile type of database that allows for structural changes as applications evolve, always providing the functionality that developers expect from traditional databases, such as secondary indexes, a complete search language, and strict consistency [42, 43].

For the development proposed in this work, InfluxDB was selected as the time series database solution. InfluxDB is an open-source time series database (TSDB) implemented to optimize query times for time series data. It has been developed for fields such as operational monitoring, information metrics, IoT, and real-time analytics. It is an open-source project that is easy to install and deploy in various development environments [42,43,44,45].

In the case of power dispatch, the database stores the dispatch values for each controllable DER in the microgrid for the 24 periods of the next day. This dispatch is obtained at 23:15, and the stored dispatch values are queried hour by hour on the following day and commanded to the power conversion devices via Modbus.

The next section describes the control problem to be solved through linear optimization in each iteration of the dispatch controller, as well as the considerations for operational constraints of the energy resources considered in the microgrid management.

Power Dispatch Optimization

The economic dispatch problem for the microgrid resources is a case of linear optimization, where the objective function and constraints depend on the prediction horizon, denoted as \(N_p\). Thus, the operational constraints of the problem, for each resource in the system and for power balance, must be evaluated for the \(N_p\) prediction periods.

The objective function depends on the generation and charge/discharge powers of each dispatchable DER in the microgrid, according to their hourly energy costs. Therefore, the control problem can be simplified and written as follows:

$$\begin{aligned} \begin{array}{l} \begin{array}{c} \min \{z=c^{T} \cdot u\} \end{array} \\ \begin{array}{cl} s.t. &{} A \cdot u \le b\\ \end{array} \end{array} \end{aligned}$$
(16)

Where c contains the weights (energy costs) of the optimization variables, u represents the manipulated variables (resource powers), matrix A and vector b contain the constraint information (models and operational limits). As presented, the manipulated variables are subject to linear models and limits, making the optimization problem a linear programming problem.

For the objective function and optimization, [46] was used as a basis. The objective function of the controller is the total hourly energy cost of the microgrid, considering the costs of each of its DERs and the external grid. Additionally, hourly operation and maintenance costs of the resource can be included. Thus, the objective function that determines the energy cost of the microgrid is given by:

$$\begin{aligned}C_{MG} (h)=\sum _{i=1}^{N}(P_i (h)\cdot C_i (h))\end{aligned}$$
(17)

Where:

\(C_{MG}(h)\): Cost of energy for the entire microgrid for each dispatch period h, [\(\$ \)]

\(P_{i}(h)\): Power delivered by the i-th resource that has an associated energy cost, for each dispatch period h, [kW]

\(C_{i}(h)\): Generation cost of the i-th resource for each dispatch period h, [USD/kWh]

The objective function is constrained to achieve energy balance in the microgrid, ensuring that the generated power is equal to the consumed and stored power at all dispatch instants. Thus, the power output from the photovoltaic, biogas, and diesel generators, and battery discharge power (positive values) must be equal to the battery charging power and energy demand (negative values), with the external grid power as an additional flexible resource that can take positive values (microgrid imports energy) or negative values (microgrid exports energy) as required. This balance constraint can be expressed as:

$$\begin{aligned} P_{pv} (h)+P_{bg} (h)+P_{di} (h)+P_{bd} (h)+P_{bc} (h)+P_{d} (h)+P_{gr} (h)=0 \end{aligned}$$
(18)

Where:

\(P_{pv}(h)\): Power of the photovoltaic generators for each dispatch period h, positive values, [kW]

\(P_{bg}(h)\): Power of the biomass generators for each dispatch period h, positive values, [kW]

\(P_{di}(h)\): Power of the diesel generators for each dispatch period h, positive values, [kW]

\(P_{bd}(h)\): Battery discharge power for each dispatch period h, positive values, [kW]

\(P_{bc}(h)\): Battery charge power for each dispatch period h, negative values, [kW]

\(P_{d}(h)\): Demand power for each dispatch period h, negative values, [kW]

\(P_{gr}(h)\): Power from the external grid for each dispatch period h, positive or negative values, [kW]

On the other side, although generation losses are considered through the modeled environmental effects on the generation devices, such as the temperature effect on the photovoltaic source, and operational/conversion efficiencies are defined for each generation and storage system, the network losses due to medium voltage distribution lines, transformers, and low voltage lines impedance are not integrated into the control problem.

Considering network power losses would result in a more accurate representation of the actual power flow within the grid, requiring higher generated powers from sources and higher energy cost to account for the energy lost in the network, acknowledging that line losses could be 5-6% and transformer losses are about 2%. However, the model would need to include additional parameters to account for these losses, such as line characteristics, making it more intricate and potentially affecting computational efficiency, an important constraint for the proposed architecture aimed to operate in real microgrids where data gathering and communications delays are important.

As this proposal is an initial approach to power management in real microgrids, integration of grid power losses will be considered for future evolution of the system.

In the next section, the methodology for sending active power setpoints to each dispatchable resource of the physical microgrid is detailed through the communication system of the control architecture.

Control Setpoint Writing

The results of the optimal calculation of active power dispatch for generation resources and charging/discharging setpoints for storage systems need to be sent to the corresponding DERs at the precise time interval for each dispatched hour of the day.

The communication function is performed through the Modbus TCP/IP protocol, which is integrated into the complete management scheme using Python code through the PyModbus library. Thus, the dispatch results for each DER in each time interval are sent via Modbus to the corresponding writable register that controls the power output or the charging/discharging conditions of the device, typically managed by the power converter of the system.

The next section presents two evaluation cases of the proposed optimal dispatch scheme through its implementation in a real-time simulated microgrid and a physical campus-type microgrid. The electrical grids and DERs characteristics are described, and the operational results of the power dispatch system during a day of operation is detailed.

Optimal Dispatch Architecture Implementation

In order to adjust and evaluate the performance of the proposed optimal dispatch architecture described in the previous section, its implementation is carried out in a computational simulation environment and a real microgrid system.

For the simulation implementation, a real-time simulator owned by a project partner organization is used. It operates a microgrid consisting of generation, storage, and power demand elements. For the real experimental implementation, the developed dispatch system is integrated into the monitoring and management scheme of the UPB campus microgrid (see Table 1) to optimally control the generation of dispatchable sources and the charging/discharging behavior of the BESS. The following section describes the two test scenarios.

Real-Time Digital Simulated Microgrid

System Description

To test the real-time operation of the optimal dispatch architecture, the cyber-physical microgrid implemented by the ISA group (administrator of the National Interconnected System) is used on their OPAL RT equipment. The microgrid shown in Fig. 2 is a 220 VAC system composed by a commercial load and a group of DERs (photovoltaic generator, diesel generator, and BESS) to meet the demand and reduce operating costs based on hourly prices.

Fig. 2
figure 2

Real-time simulated microgrid for optimal dispatch architecture testing

Table 2 summarizes the main electrical characteristics of the resources that make up the real-time simulated grid. Also, the capital cost (CAPEX), operating and maintenance cost (OPEX), and the lifetime of each system are presented to consider the cost-benefit relation for different DER technologies; these data were scaled from actual values of the devices of the real microgrid presented in the next section. The objective of the dispatch system will be the management of the generated and stored energy in the microgrid, ensuring that the power demand is met and optimal operation is guaranteed in terms of energy costs.

Table 2 Real-time simulated microgrid DER characteristics
Fig. 3
figure 3

Power demand profile for the real-time simulated microgrid

The demand behaviour of the real-time simulated microgrid is shown in Fig. 3, identified by a commercial load profile corresponding to the buildings of the ISA group headquarters. It is characterized by a flat behavior during the day, with a maximum active power demand close to 800 kW, and it reduces to around 300 kW during the night.

In terms of energy costs, a value of zero is assumed for photovoltaic generation and the charging/discharging operation of battery storage systems. Figure 4 presents the costs of diesel generation, assumed to be constant throughout the 24-hour periods, along with the costs of the energy supplied by the grid. Variable prices are implemented in accordance with the demand behavior in Colombia.

Simulation Results

When performing the real-time simulation of the microgrid dispatch, in accordance with the proposed architecture of Fig. 1, the contribution of each distributed generator in the system, as well as the external grid, is obtained according to the power demand in each time period of the day, optimizing the costs of the energy supplied to the system loads.

Figure 5 presents the results obtained for a day (24 periods) of operation, highlighting the contribution of photovoltaic generation during the peak solar radiation hours of the day. Diesel generation is dispatched only during periods of the day where its cost is lower than the grid energy costs, as for hours 9, 11, 20, 21 and 22. For efficiency purposes, the diesel plant is usually dispatched at nominal capacity as these thermal generators operate with the highest efficiency in this condition.

Fig. 4
figure 4

Energy costs for the real-time simulated microgrid

Fig. 5
figure 5

Dispatch architecture operation results for the real-time simulated microgrid

Additionally, the discharge of the BESS device is developed during the periods of higher grid energy prices and when the load demand is near its peak value, so the BESS is used by the power management system to develop peak shaving on the demand and reduce the levelized energy cost.

On the other side, at hour 22 the diesel plant generation cost is again slightly lower than the external grid cost, so the diesel plant is dispatched at nominal power according to the logic explained before. Also, at the same hour the load demand is near its minimum. This way, to take advantage on the high diesel plant generation (cheaper than grid at that period) and a very low demand in the system, the BESS is ordered to charge to full SOC, ensuring complete charge cycles and maintaining the battery health.

Finally, it is noteworthy that during the periods when the diesel generator is dispatched at full power due to its high contribution, energy is exported and sold to the external grid.

The power dispatch system is configured to maintain the BESS SOC level between 20% and 100% to preserve its health and extend its lifespan, noting that the SOC is calculated based on the battery remaining energy from Eq. 12 and the total capacity.

For reference and validation purposes, the exact same microgrid system is simulated using the System Advisor Model (SAM) software, a tool for techno-economic analysis of energy technologies from the National Renewable Energy Laboratory (NREL) [47]. The classical (non real-time) simulation results for 24 hourly periods of power dispatch is presented in Fig. 6, integrating PV, BESS, diesel, load and grid elements.

Comparing the results of SAM simulation with those obtained in the real-time simulation, can be appreciated that there is great similarity in the contributions of the grid and the solar and diesel systems, in contrast, the battery system shows that the charging and discharging periods are carried out more efficiently by the developed controller, since it allows the batteries to be discharged almost completely and charges them up to 100%, thus reducing the number of charging and discharging cycles in a day of operation.

Finally, Fig. 7 presents the dispatch results for the simulated microgrid operating in islanded or isolated mode, aiming to test the developed architecture for the diverse operation scenarios of microgrids. The microgrid is considered with the same devices of Table 2, demand variation of Fig. 3 and diesel operation cost of Fig. 4.

As the results indicate, without the external grid, the diesel generator must supply the required power demanded by the microgrid load, prioritizing first the photovoltaic generation as a cheaper energy source. Also, in this scenario, as the greatest power source of the grid, the diesel plant would act as the voltage and frequency controller, and the BESS device is managed by the dispatch architecture to reduce the energetic operation costs.

Fig. 6
figure 6

Dispatch results for the simulated microgrid using SAM tool

This way, the BESS is set to discharge at hours 14 and 15, as the demand presents its highest values of the day supporting the diesel source operation and reducing the levelized energy cost. Later, at hours 21, 22, and 23 the device is charged as the lowest power is demanded and the diesel plant generation is relatively low.

Fig. 7
figure 7

Dispatch architecture operation results for the simulated microgrid in isolated mode

Fig. 8
figure 8

Some of the UPB campus microgrid resources and locations. Medellin, Colombia

Fig. 9
figure 9

UPB campus microgrid diagram

Experimental Campus Microgrid

System Description

Established in 2013, the UPB microgrid is a research project aimed at integrating RES and cutting-edge technologies into contemporary power grids. The project is located at the main campus of the university in Medellin, Colombia and is spearheaded by the Research Group on Transmission and Distribution of Electric Power (T &D). Figure 8 provides an overview of the university campus, highlighting some of the microgrid resources currently in use: 1 represents a 1 kWh/day biodigester; 2 represents the Ecovilla Smart Living Laboratory; 3 represents a 52 kW photovoltaic system; and 4 represents a 21 kVA - 55 kWh BESS device.

Table 3 UPB microgrid distributed energy resources capacities
Fig. 10
figure 10

Composition of the main BESS device of the UPB microgrid

The microgrid is powered by a 13.2 kV distribution network that splits into four branches within the campus. It is supported by 18 transformers, located in 15 substations that integrate 8 backup power plants (for use during blackouts), 2 biodigesters, 2 BESS, and 5 PV generators of various capacities. Figure 9 provides a detailed illustration of the electrical topology of the microgrid, including the devices integrated into each system busbar.

Fig. 11
figure 11

Energy costs for the UPB microgrid

Fig. 12
figure 12

Dispatch architecture results for the UPB microgrid

To meet the power requirements of the microgrid, external grid supply, 133.5 kWp worth of PV generators that are detailed and analyzed in [48], and 24 kW / 73 kWh worth of BESS systems are utilized. In addition, diesel backup generators are incorporated to provide power during periods when the distribution grid supply is unavailable. Table 3 outlines the generation powers and storage capacities of the DERs integrated into the UPB microgrid.

Fig. 13
figure 13

Dispatch architecture operation results for BESS in the UPB microgrid

The largest BESS device of the grid, located at the B15_BIB busbar, is one of the main systems to be optimally dispatched by the power management architecture presented in this work, due to its high energy flexibility and various operating modes. In Fig. 10, an image of the device is shown with its components identified as: 1 Fortress eVault battery banks (3 x 18.5 kWh each); 1 DC connection panel and Schneider Electric Battery Monitor; 1 Schneider Electric Conext XW single-phase inverters (3 x 6.8 kVA each); 1 AC transfer and connection panel; 1 backed load panel for the second floor of the 15th Block of the campus.

For the experimental implementation, the dispatch system considers hourly energy prices for each resource in the microgrid, including the external grid, in order to find the optimal combination of power and operational cost of the device, minimizing the energy expenses for each time period of the day. Figure 11 presents the generation prices for biogas and diesel, as well as the grid energy cost profile considered for the dispatch of the UPB microgrid. Photovoltaic generation and BESS charging/discharging are considered with a price of zero. Biogas energy cost was estimated according to the costs incurred for substrate collection. Diesel energy cost was estimated according to the price of fuel in Colombia at study development year. The grid energy cost was consider as a variable price in accordance with the demand behavior, in order to test the operation of the controller to hourly changes cost, as intended to be implemented by the regulatory agency in Colombia in the near future.

Operation Results

The optimal dispatch of the UPB microgrid is considered through the architecture detailed in “Control Architecture”, with a focus on the 21 kVA/55 kWh BESS system based on the energy costs shown in Fig. 11. The goal is to shift demand from high-priced hours to low-priced hours and reduce the total operational cost of the system.

Figure 12 presents the results of one day optimal dispatch of the UPB microgrid. Figure 12a shows the behavior of the demand for each period and Fig. 12b shows the optimal dispatch for each period of the different DER of the microgrid. Figure 13 presents the real operation results based on the optimal dispatch of the storage DER during one operation day. Figure 13a shows the actual delivered/consumed active power of the BESS, Fig. 13b and c indicate the behavior of the SOC and temperature conditions in the device, respectively.

Regarding the power dispatch setpoints, a negative value indicates BESS charging, and a positive power indicates discharging. However, in the actual measurement logic and variable communication of the device, these signs are reversed, where a positive power represents charging, and a negative power represents discharging. It is evident that the orders of the dispatch architecture are followed during the corresponding time periods for each operating mode. During the hours when the grid energy price is low (5 a.m. - 9 a.m.), charging setpoints for the BESS are executed. Conversely, during the periods when the energy price is high (7 p.m. - 11 p.m.), discharging setpoints are executed, reducing operational costs by avoiding energy import from the external grid during high-price hours.

Furthermore, the power dispatch system is configured to maintain the BESS SOC level between 20% and 100% to preserve its health and extend its lifespan, noting that the SOC is calculated based on the battery remaining energy from Eq. 12 and the total capacity. This way, the SOC variation is carefully considered for each dispatch period, also aiming to avoid significant temperature variations in the battery cells, as observed in the lower graph of Fig. 13.

On the other hand, is known that grid integrated microgrids are able to operate in two modes: grid connected and islanded. The real campus microgrid where the control system was tested mainly operates as a grid-tied network. Also, the real-time simulated grid is considered to be grid-tied as it was a prior test trying to represent conditions similar to those of the physical system. However, off-grid operation is also possible for the dispatch architecture but was not presented for abbreviation.

When the electrical or economic conditions require the microgrid to operate islanded, the day-ahead dispatch is optimized for this condition. For this scenario the storage device acquires the additional task to ensure the power balance in the network, as the external grid does in grid connected mode.

Conclusions and Future Work

An optimal power dispatch architecture for microgrids with high penetration of renewable sources and storage devices was designed and developed as part of a multi-module Energy Management System. The system was built adapted to the common conditions of real microgrids.

The architecture considers and is prepared for microgrid conditions such as the impossibility of operating in complete isolation, the use of commercial devices that hinder the development of primary controls, uncertainties, disturbances, communication, and typical limitations of a medium-scale experimental implementation. The proposed control system performance in these conditions is tested in a physical campus microgrid with commercial devices, integrating real meteorological forecast. The architecture shows a proper operation for near-to-real and real medium-scale microgrids with a complex scheme of data gathering, processing, optimization, and device control.

The control architecture is conceived from its structure as part of a wider multi-microgrid management system. The data gathering and storage procedure of the power dispatch system are intricately connected to the wider functions of the complete high-level in-development microgrid aggregator, allowing to operate multiple microgrids as a whole.

The generation power and battery storage management function of the dispatch architecture was tested in a real-time simulation environment for grid-connected and isolated systems, prior to the physical implementation in the UPB campus microgrid in Colombia. The control architecture performance has a strong dependence on the quality of the meteorological forecast, as the day-ahead dispatch relies on the expected future generation of renewable resources to develop the cost minimization.

Low-order linear models of distributed energy resources were used to represent the active power generation and battery storage behaviour to be managed by the proposed optimal dispatch architecture. The renewable and conventional energy source models allow to consider future meteorological forecast and fuel supply schedule to develop the day-ahead dispatch calculation.

The power dispatch architecture is presented as a flexible and customizable management tool, tailored to the microgrid requirements and operation. The control system, tested in digital and physical environments for different operation scenarios of the microgrids, shows to be prepared for the current and future challenges of electrical systems and distributed generation, integrating the disturbances of meteorological conditions, renewable sources, and power demand into the control problem.

This proposal is an initial approach to power management in real microgrids, considering different conditions of the generation and storage devices, and integrating meteorological and demand forecast to the control problem. This way, as an initial approach, network power losses such as distribution lines, transformers, and low voltage grid losses are not considered in the dispatch optimization and will be contemplated in future developments of the system.

As future and in-development work of the optimal dispatch controller proposed and experimentally tested in this work, it is planned to tune and implement the architecture on the other four real microgrids developed in the research program framing this work. These additional implementations integrate different resources, capabilities, and requirements, as well as diverse weather characteristics and thermal floors, in order to experimentally test the real flexibility and adaptability of the proposed energy management and dispatch system.