Hardware-in-the-loop test for real-time economic control of a DC microgrid

: Microgrids (MGs) utilising both renewables and energy storage to optimise onsite energy consumption rather than importing power form the utility grid, require a tertiary-level energy management system (EMS). The EMS must monitor and control the energy exchange within the nodes of MG to maximise any solar energy generation and benefit from installed storage. This paper considers a single-family house as the MG that has DC distribution circuit model. The look-ahead EMS is formulated as a linear programming problem, which has been tested in both offline simulation and hardware-in-the-loop (HIL) simulation environment. The simulation results indicate that the proposed look-ahead EMS can effectively reduce the DC MG operation cost without any operational constraint violation. In addition, the proposed look ahead energy optimisation approach has the potential to be used in a large-scale system such as a community MG with multiple buildings.


Introduction
In Europe, the energy consumed by the residential sector is still a significant proportion of all energy use.Almost 25% of the energy consumption in 2014 belongs to the households sector, which is the third highest after transportation (32.2%) and industry (25.9%) [1].Therefore, household energy consumption needs to be mitigated by efficient use of renewables and energy storage on generation and distribution systems.By studying the challenges and practicalities of utilising new sources of energy in buildings, it may be possible to decrease the dependency of residential sectors on utility power.When each household can partially contribute in power generation, the burden during peak hours on the larger utility can be moderated.This is the function of microgrids (MG), with capability to operate in either islanded or grid-connected mode, to increase the overall efficiency and resiliency of energy systems.A MG requires a control system to observe all generation and demand, and manage the economic operation of the energy system, which can be classified as primary control, secondary control, and tertiary control.Therefore, a tertiary control is designed to manage the power exchange and makes decisions regarding the best use of the electric power-generation resources and storage devices within the MG.Effective energy management can enable optimal and sustainable energy supply, with maximum capabilities.In addition, given the intermittent nature of renewable energy resources, an energy management system (EMS) must be able to determine the optimal control solution to provide power to system loads reliably.
While research exists, with a focus on MGs energy management, only a few studies have considered DC MG energy management e.g.[2][3][4].This paper considers a DC MG, consisting of a single-family house, and models the detailed dynamic behaviours of a typical DC residential building.The look-ahead energy optimisation problem is formulated as a linear programming problem that could be solved efficiently using a standard optimisation solver.In addition, this paper has focused on real-time implementation of EMS with additional constraints for battery operation and heating, ventilation, and air conditioning (HVAC) system.Real-time operation has been investigated in literature [5,6] but these algorithms have not been tested in real experimental MGs.
In this work, the look-ahead optimisation approach is used to optimise the energy utilisation of a DC residential building with battery energy storage, PV unit, HVAC load along with other uncontrollable loads in the grid-connected mode.A dynamic electricity price signal is also used to guide the utilisation of battery energy storage as well as the energy consumption of HVAC system to minimise the electricity cost of the system.The look-ahead multi-interval optimisation mechanism plays a key role in the economic control.This mechanism allows the energy storage to be charged during low electricity price periods and discharged over high electricity price intervals.In addition, the precooling or preheating mechanism [7,8] is automatically integrated in this optimisation framework to reduce the building energy consumption during peak hours.The developed optimisation algorithm has been first tested in offline simulation to validate the feasibility of the proposed approach.In order to validate the real-time behaviours of the developed EMS system, the Opal-RT HIL simulator is used to further test the developed algorithm.
The control-HIL simulation is an efficient way to test the prototype in a real-time simulation environment.The economic control algorithm is prototyped on a dedicated controller that is interfaced with the Opal-RT simulator.The DC distribution circuit model of the residential building is simulated on the Opal-RT simulator in real-time to emulate the real behaviour of the physical system.With this capability, reliability and time-to-market requirements in a cost-effective manner could be maintained even as the system that is testing becomes more complex.As reported in literature, some MG test systems working in real time have been implemented [9][10][11].However, the HIL simulation test is not considered in these models.
The outline of this paper is as follows.Section 2 discusses the DC MG model and the problem formulation for the look-ahead EMS.Section 3 presents the offline simulation results for the developed EMS algorithm.The HIL simulation test results are presented in Section 4. Finally, the conclusion is given in Section 5.

Problem formulation
The operation of DC MGs can be classified as primary control, secondary control, and tertiary control, as shown in Fig. 1.The primary controller has a small decision time step to regulate bus voltage locally.On the other hand, tertiary controller collects system state information using the communication infrastructure and makes decisions to improve the overall performance of MGs [12].The proposed DC MG EMS system is on the tertiary control level.The decision time interval of the proposed look-ahead EMS system is on the order of minutes.

J. Eng.
This is an open access article published by the IET under the Creative Commons Attribution License (http://creativecommons.org/licenses/by/3.0/) 1

DC microgrid model
The DC distribution circuit diagram of a residential building is shown in Fig. 2. The voltage level is 380 VDC for high power devices and 48 VDC for low power devices [13].A DC/AC inverter is used to supply appliances utilising AC power.The efficiency curves for the modelled converters were obtained from similar converters in the market [14,15].Similarly, the nominal efficiency of the grid rectifier was obtained from a Vicor commercialised rectifier [16].This system also includes a solar photovoltaic (PV) unit and a battery energy storage.The PV capacity is 4 kW with the efficiency of 15.4% for solar cells [17].The electrical storage is a lithium-ion battery with 3.3 kW/6 kWh capacity [18].The converters, solar PVs, storage, and HVAC system specified ratings and constraints are considered when modelling the system in Matlab/Simulink environment.

Problem mathematical representation
In the designed model, the objective is to minimise the imported/ exported power amount to increase the use of onsite-generated power.At the same time, the battery energy storage charging/ discharging frequency is controlled to be minimised to extend the life time of the battery.The look-ahead energy optimisation problem is formulated as a linear programming problem.In each optimisation routine, the energy utilisation of the DC building is optimised over the next 12-24 h.Once new load, renewable energy, and electricity price forecasts are available, the optimisation is executed again to update the economic control solution.In this way, the most recent forecast information could be used to improve the accuracy of the economic control.The objective function is shown in (1).
where I is the index of decision intervals, P IMP is the imported power, P EXP is the exported power, P STO is the storage charging/ discharging power, α is a penalty factor to limit the storage charging/discharging frequency, N is the planning intervals, w IMP is the electricity price for import power, and w EXP is the electricity price for export power.The reason to define export power and import power separately is that the electricity price of import and export power may be different.The power balance constraint is shown in ( 2) and (3) represents the role of import/export power in the balance equation.P grid (i) + P STO (i) + P load (i) + P HVAC (i) = 0, 1 ≤ i ≤ N (2) where P grid is the grid power, P load is the load demand of electrical appliances, P HVAC is the HVAC load demand, and P STO is the battery power.
The battery state-of-charge (SOC) constraint is shown in (4).The lower limit of battery SOC is set as 20% and higher limit is set as 100% [19].
A two-capacity building thermal model [20] is adopted in ( 5) and ( 6) to estimate the room temperature of the DC building.The coefficient values of the building model are also obtained from [20].
where Δt is the decision time interval, H e is the virtual thermal conductance between room temperature and external temperature T e , H g is the thermal conductance between ground temperature, T g , node point and room temperature T amb .H s is the thermal capacitance controlling the ventilation air heat capacity flow having temperature T s , H m and H M are the heat conductance of the solid wall material and convection on the surfaces.The initial room temperature is assumed 21°C.The thermal comfort constraint is given in (7).
where T* is the desired room temperature and β is the temperature dead-band which is set as 2°C in this study.

Offline simulation test results
In this section, the developed optimisation algorithm is implemented and tested on a Windows machine.The building EMS problem is formulated as a linear programming problem and is solved using general algebraic modelling system (GAMS) software.In this section, two offline simulation cases are used to test the performance of the developed algorithm.

Case 1, time of use pricing
In this case, a two-step price signal is used to test the performance of the developed EMS algorithm.The electricity price is relatively high from hour 9 to 20, and the price is relatively low during the rest time of day as shown in Fig. 3a.Fig. 3c represents that the storage charges during hours when the electricity price is low and then discharges when the price is high.This method ensures that the imported power is shifted to low electricity price hours, which moderates the burden for the utility grid as shown in Fig. 3b.The battery storage is charged for two intervals before the electricity price is increased.Fig. 3d indicates that the HVAC load has a reduction at 9am when the electricity price rises.This is because that the thermal capacity of the building is used to shift energy consumption from high price intervals to low price intervals, which is also known as pre-heating strategy.Fig. 3f shows that the room temperature decreases to the minimum allowable limit at 9am and remains at that temperature for the rest of the day.Through limiting the room temperature within a specified range, instead of a fixed value, the household electricity cost could be significantly reduced without affecting consumer's comfort level.

Case 2, dynamic pricing
In this case, the energy price is varying hour-by-hour and the energy storage charging occurs during lowest price hours and discharges over evening when the electricity price is higher.The results of the simulation in Fig. 4 represent less imported power during nighttime.At the same time, the ambient temperature is almost constant throughout the day while satisfying the consumers comfort.Fig. 4a indicates that the electricity price is relatively high between hours 17 and 20.As shown in Fig. 4c, the storage is charged in the low price hours and discharged at hours 18 and 19.
Due to the price difference between hours 21 and 22, there is a charge and then a discharge to reduce the electricity cost.The other term affecting the reduction of imported power is that the preheating strategy is implemented at hours 15 to 16 as shown in Figs.4d and f.At hours 15 and 16, the electricity price is still low and solar power is available.Thus, the pre-heating strategy helps to keep the temperature within the allowable range as well as reducing the electricity cost.
The two case studies indicate that the developed EMS algorithm can effectively reduce the electricity cost and fully utilise the battery storage as well as integrating the preheating strategy to further reduce the amount of the imported energy from the grid utilities.

Real-time HIL simulation test results
In this section, the developed EMS algorithm is tested in a realtime HIL simulation environment.The building EMS is implemented on a Windows machine with 3.16 GHz CPU and 4.00 GB RAM.The optimisation algorithm is executed in operational real-time to regulate the controllable resources in a DC building to achieve the operational objective.The control signals

Case 1, time of use pricing
In this case study, the decision time interval is chosen as 20 s.A two-step electricity price signal is used to test the behaviour of the battery energy storage.It is assumed that the optimisation time horizon is 24 time intervals.The initial battery SOC is assumed 20%, which is equal to the lower limit of SOC.The look-ahead optimisation solver optimises the system operation over the next 24 intervals to fully utilise the dispatchable resources to reduce the system operation cost.When the utility electricity price is low from interval 1 to 8, the battery is charged with the maximum rate.The import power from utility grid is high to fully utilise the low cost electricity from the grid as shown in Fig. 6b.During the high electricity price period, the battery is discharged to reduce the import power from the grid as shown in Fig. 6c.The solar power is fully utilised to reduce the import power from the grid as shown in Fig. 6e.
The decision time interval is 20 s in order to accelerate the operation of the system in real-time and provide enough time for the optimisation model to prepare the results.Since proper timestep duration must be determined to accurately represent system frequency response up to the fastest transient of interest [21].The battery power and energy capacities are 3.3 kW and 6 kWh, respectively.The battery SOC only increases around 0.2% after charging for 8 time intervals, so the SOC is well below the higher limit.Increasing the decision time interval to few minutes is required to further validate the developed algorithm in real time.

Case 2, dynamic pricing
In this case study, the decision time interval is chosen 20 s as in previous case.A real dynamic price signal is used to test the behaviour of the optimisation algorithm assuming the optimisation time horizon 24 time intervals.
Again, the initial battery SOC is assumed 20%.The look-ahead optimisation solver optimises the system operation over the next 24 intervals to utilise the dispatchable resources fully to reduce the system operation cost.The high electricity price occurs from When the utility electricity price is low from interval 1 to 8, the battery is charged at the maximum rate.The import power from utility grid is high to fully utilise the low-cost electricity from the grid as shown in Fig. 7b.During the high electricity price period, the battery is discharged to reduce the import power from the grid as shown in Fig. 7c.The solar power is fully utilised to reduce the import power from the grid as shown in Fig. 7e.
The HIL test results suggest that the developed EMS algorithm could also achieve desired performance in operational real time.Each EMS optimisation could be finished in a few seconds, which is acceptable for real-time applications.In addition, the prototyped communication and software architecture of the EMS system is also tested in the HIL simulation environment and the test result suggests that the developed method is very promising for real applications for building economic control.

Offline and HIL simulation test results comparison
As explained, in HIL test, the designed control model can be examined in real time comparing to the offline simulation model.Thus, for each time-step, the simulator executes the same series of tasks: (1) read inputs and generate outputs; (2) solve model equations; (3) exchange results with other simulation nodes; and (4) wait for the start of the next step.
The results comparison in case 1 for the offline and HIL simulations represent more accurate data sharing for the HVAC system and the room temperature in the HIL system.This highlights the effectiveness of the real-time simulation model provides data that are more realistic.
The same comparison for case 2 illustrates that the energy required for the HVAC system in HIL is slightly higher than in the offline simulation, while the room temperature is almost constant.Thus, the overall imported power in HIL is higher compared to the offline model and this discrepancy highlights the effectiveness of the HIL simulation.

Conclusion
Here, a look-ahead EMS algorithm was developed for a DC residential building to minimise the system operation cost in operational real time.The proposed method integrated battery energy storage, PV unit, controllable loads, and dynamic electricity price into the look-ahead optimisation framework.The battery storage system was efficiently utilised to enable the energy shift and the pre-cooling/heating mechanism was integrated in the energy optimisation framework.The proposed algorithm was tested for two different pricing cases, time of use, and dynamic pricing models.In addition, the proposed algorithm is tested in a control-HIL simulation environment to validate the real-time behaviour of the developed EMS system.The simulation results represent that higher power is imported from the grid in HIL tests as the model is updating simultaneously and more accurate model of the system under study is applied.
Future work will focus on the EMS framework development for community-level MG with multiple residential and commercial buildings as well as its validation in HIL simulation environment.

Fig. 1 Fig. 2
Fig.1Diagram of microgrid control operations based on the concept proposed in[12]

Fig. 3 Fig. 4
Fig. 3 Offline simulation test results for case 1 (a) Electricity price signals, (b) Grid power demand, (c) Battery energy storage power output, (d) Load demand, (e) Solar power, (f) Room and environment temperatures

Fig. 5
Fig. 5 High-level diagram of the real-time HIL simulation test platform

Fig. 7
Fig. 7 HIL test results for case 2 (a) Electricity price signals, (b) Grid power demand, (c) Battery energy storage power output, (d) Load demand, (e) Solar power, (f) Room and environment temperatures