**7. MPC Based HEMS—Experimental Results**

A laboratory system has been constructed to evaluate the performance of the MPC using a real HBSS in a typical operating environment. The MPC-based HEMS was tested experimentally for one day at the FlexElec Laboratory in the University of Nottingham, using the "Smart Home Rig" (SHR) shown in Figures 3 and 4.

**Figure 3.** The smart home rig at the University of Nottingham Laboratory.

**Figure 4.** The connection diagram of the smart home rig at the University of Nottingham Laboratory.

This SHR comprises:


The HEMS-based MPC was implemented experimentally. At each sample time (every two minutes): (1) the Raspberry pi measures the SOC of the HBSS (from SMA converter in the HBSS) and sends it to the HEMS; (2) a MATLAB script is used to execute the MILP optimization and calculate the optimal power setting for the HBSS; (3) the Raspberry Pi receives the HBSS optimal power setting for just the next sample and passes it to the HBSS's SMA inverter; (4) these steps are repeated every two minutes.

Figure 5 shows the performance of the MPC-based HEMS for one day. The TOU tariff scheme and a fixed export electricity tariff were used in this experiment. The methods used for forecasting demand and generation are the previous week same day load profile (L-PWSD) and the previous day generation profile (PV-PD), respectively. The mean absolute percentage error (MAPE) for the load and generation forecasts were 29.3% and 22.66%, respectively. A two-minute sample time has been used—the MPC updates the HBSS references every two minutes and it can therefore respond to relatively fast disturbances in the system.

**Figure 5.** (**a**) Actual daily, load demand, PV generation, utility power (negative value—house is exporting power to the utility, positive value—importing), and the optimal power settings sent to the HBSS (negative value—charging, positive value—discharging); (**b**) Daily actual SOC of the HBSS.

A sample time of two minutes is the shortest sample time that can be used in this experiment. When a one-minute sample time was attempted for MPC operation, it was found that the MPC takes 5.62 min to perform just the optimization process, making a sample time of less than two minutes unfeasible for this experiment.

Figure 5a shows that the HEMS/BESS matches the household demand from 16:00 to 20:00 (during peak-tariff hours) so the home did not have to import energy from the main utility during this period. The PV generation was used in the home (including charging the HBSS) instead of being exported to the utility. From 00:00 am to 07:00 am (off-peak tariff time), a greater amount of energy was drawn from the supply utility at the low tariff rate (5 pence/kWh) to cover the home energy demands and charge the HBSS. It is clear from Figure 5b that the HBSS was charged from both the surplus PV generation during daytime and the imported energy from the supply utility during the off-peak tariff time.

Unwanted export power can be seen in Figure 5a (negative values of the utility power (black) profiles). The reason for this unwanted export was the errors associated with the load and generation forecasts at certain points in the day (i.e., when there is a sudden increase or decrease of the load or generation/export at power levels higher than the BESS can manage). The unwanted export power was one of the reasons for the lost energy when using the MPC for HEMS. The HECIR and ELR were 27% and 14%, respectively.

It is clear from Figure 5b that the HBSS charged to 67% overnight (i.e., not to its maximum limit of 90%) because this overnight charging level (a) enables the HBSS to provide the expected load demand during the morning period (i.e., no energy is purchased from the supply utility from 7:00 to 10:00), and (b) leaves space for the surplus PV generation during the following day to be stored in the HBSS (i.e., no energy is exported to the main utility from 9:00 to 15:00). The battery is fully charged at 16:00hrs, ready for the peak tariff period.

### **8. Performance Analysis for the MPC-Based HEMS**

This section will analyse the performance of the MPC-based HEMS over a one-year period.

### *8.1. Sample Time Resolution*

With a sample time of 60 min for the MPC operation, the HBSS power settings received from the MPC optimization will stay fixed for 60 min. As a result, any change in generation and/or load in this period will be compensated by the supply utility to balance the total active power in the home (4) and this may affect the total energy costs. If a sample time of two-minutes is selected for the MPC, it will update the HBSS references every two minutes and therefore will respond to fast changes in load and generation to minimize the home's energy costs and reduce lost energy.

Figure 6 compares the use of a 60 min sample time and a two minute sample time for the MPC. Figure 6a shows the HBSS power settings obtained using 60 min (red settings) and two minutes (blue settings), respectively. Figure 6b shows the power drawn from the supply utility when using 60 min (red) and two minutes (blue), respectively. Figure 6c shows the load and the generation profiles for a two-minute sample time.

It can be seen from Figure 6a that when a 60 min sample time was used for the MPC, the HBSS references remained constant for 60 min and changes in load and generation were compensated by the supply utility, as can be seen in Figure 6b. Energy is purchased from the supply utility during the peak-tariff period, and there is also unwanted export to the supply utility during the late afternoon. This export could be captured in the HBSS. Figure 6a shows that when the MPC updates the HBSS power settings (blue line) every two minutes, it can respond appropriately to fast changes in load and generation (seen in Figure 6c).

**Figure 6.** Comparison of a two-minute sample time and a 60 min sample time for the MPC. (**a**) The HBSS optimal power settings when using a two-minute sample time (blue settings) and when using a 60 min sample time(red), (**b**) the power drawn from the supply utility when using a two-minute sample time (blue) and a 60 min sample time (red), (**c**) PV generation and load demand profiles for a two-minute sampling time.

Table 3 shows the effect on the operation of the MPC using different sample times. An ideal forecast of load and generation was used for these tests so that the effect of sample time only was studied. The best case is where a two-minute sample time was used.


**Table 3.** Effect of sample time on the MPC computational time, the annual HECIR, and the annual energy lost ratio (ELR).

\* This case cannot be applied in a real system. The optimization process was only performed to show the required computation time.

It can be seen that the computational time of the optimization process can pose a problem if too short a sample time is used. For example, it is seen that if a one min sample time is used, the MPC takes 5.62 min to perform just the optimization process (a much larger time for computation than the rolling step size itself). This makes the use of this sampling time resolution unfeasible. In addition, if a very short sample time is used, this will force the controller to respond to each and every change in the load or generation. The controller action then has a high frequency content which can affect the lifetime of the HBSS: the battery will be exposed to high operational stresses if it changes between charging and discharging too quickly.

Usually, it is desirable to use a short sample time for the MPC. It can be seen from Table 3 that when a small sample time is used, this results in a lower energy cost increment ratio and a lower lost energy ratio. For a 60 min sample time for the MPC, the HECIR increases by 35.19% and the lost energy ratio increases by 29.86% compared with the smaller sample time. If a short scanning and response time is used, the MPC controller can respond to rapid changes in load and generation, and this therefore guarantees better performance and a greater reduction in costs for the householders. The compromise is that a longer computation time is required for the MPC optimization process.

### *8.2. The E*ff*ect of Forecasting Errors*

To measure the accuracy of the forecasting methods for load and generation for the following day, the mean absolute percentage error (MAPE) is calculated (19).

$$\text{M.A.P.E} = \frac{1}{\text{N}} \sum\_{\text{to}}^{\text{T}} \left| \frac{\text{A}\_{\text{t}} - \text{F}\_{\text{t}}}{\text{A}\_{\text{t}}} \right| \times 100 \tag{19}$$

where At is the actual point, Ft is the forecast and N is the number of forecasts considered.

Table 4 shows the MAPE values for the forecasted load and generation for the next day using the forecasting methods listed in Section 3.2. The forecasted load and generation profiles using the methods (i.e., L-PD, L-PWSD, L-AV, PV-PD, and PV-AV) were found using the historical dataset available.

**Table 4.** The mean absolute percentage error (MAPE) values for the load demand and the PV generation forecasting methods listed in this research.


When using the PV-FP forecasting method, as historical data has been used, the forecasted PV generation profile was created by adding Gaussian noise to the actual PV generation profile of the current day. The Gaussian noise represents the MAPE for the forecasted profile. The value of the MAPE (14% in this case) is obtained from the results available from the Sheffield solar website for PV generation forecasting for the following day [46].

For the next day household demand forecasting using the L-FP case, an adaptive neuro-fuzzy inference system (ANFIS) forecasting method, developed in [51], was used. Other load demand forecasting techniques could be used to potentially obtain better results.

Figure 7 shows the effect of forecasting uncertainty for both the load and generation on the annual HECIR and the annual lost energy ratio using the TOU purchasing tariff scheme. The sample time used in these calculations is two minutes and is fixed in all the cases to investigate the effect of the forecasting uncertainty only. It can be seen from the results that the forecasting uncertainty for the load demand and PV generation for the following day greatly affect the household energy costs and the lost energy ratio. The HECIR approaches 67.98% when using the L-AV and PV-AV forecasting methods (i.e., more than half of the cost that would be achieved when using ideal forecasting). Ideal forecasting is the perfect forecasting (100% accurate) of generation and load profiles for the next 24-h period, which can be created as we are using historical data profiles. The ELR also approaches 32.33% for the same case. This lost energy should be saved in the HBSS and used at the appropriate time period rather than being lost to the utility with little reward. From Figure 7 it can be seen that using a forecasting method such as L-FP and PV-FP achieves lower HECIR and ELR. It is worth noting that the actual HECIR and ELR will be higher than the values shown in Figure 7 if a longer sample time is used for the MPC.

**Figure 7.** The effect of forecasting uncertainty for both the load demand and PV generation on (**a**) the annual HECIR and (**b**) the annual ELR, using the time of use (TOU) purchasing tariff scheme and two-minute sample time.

### *8.3. The E*ff*ect of Changing Tari*ff

Table 5 shows the annual household energy costs calculated using the three purchasing tariff schemes shown in Figure 1. The sample time used in this section is two minutes and perfect forecasting was used for both the load demand and PV generation as we are using historical data.

**Table 5.** The annual household energy costs for the three purchasing tariff schemes.


It can be seen from the results in Table 5 that lower home energy costs can be achieved using the TOU tariff compared to using the Economy 7 or the real-time tariff schemes. The TOU tariff offers lower energy prices during off-peak periods (i.e., 4.99 pence/kWh as shown in Figure 1), compared to the Economy 7 tariff (8.4 pence/kWh for the same off-peak period). Lower energy prices during off-peak periods give the HBSS a chance to store as much energy as needed at low cost to cover the home demands through the day. The TOU tariff also offers lower prices during the off-peak periods compared to the real-time (half-hourly) pricing scheme which can offer high prices at night (as can be seen in Figure 1). This is an area of ongoing research.

### *8.4. Variation of HBSS Capacity*

Table 6 shows the impact of changing the capacity of the HBSS on the annual household energy cost and the PV self-consumption ratio using the TOU tariff scheme and 1.4 kW peak PV system. It can be observed that as the battery capacity increases, the household energy costs decreases and the PVSCR increases. The PVSCR also increases at a high rate when the battery capacity changes from 0 kWh to 4.8 kWh. However, the increment rate in the PVSCR is low when the battery capacity increases from 6.4 to 13.5 kWh. This is related to the rated size of the PV system (1.4 kWp); when the battery capacity increases beyond a certain size, this additional storage capability cannot increase the capture of PV generation (the remaining excess PV generation is at a power level above the power rating of the HBSS), and it therefore cannot improve the PVSCR.

**Table 6.** Effect of changing battery storage's capacity on the annual household energy cost and the PV self-consumption ratio using TOU purchasing tariff scheme and 1.4 kW (peak) PV system.


It is worth noting that as the battery capacity increases, the initial investment cost of the battery system increases as well. An optimization technique is required to select the best battery size which minimizes both battery investment cost and the annual household energy costs, as discussed in Section 4 and [42].

### *8.5. Varying PV System Size*

Table 7 shows the effect of changing the size of the PV system on the annual household energy cost and PV self-consumption ratio using the TOU purchasing tariff scheme and a 6.4 kWh battery. Different PV system sizes, from 1 kW to 5 kW, were used by scaling the PV data accordingly. It is clear from Table 7 that as the PV system size increases, the household energy costs decreases. Furthermore, it is observed that the PVSCR decreases instead of moving to 100% as the PV system size increases. The reason for this is due to the battery power limit (2.5 kW in this case); the additional PV generation is at a power level higher than the battery system's converter and therefore much of the surplus PV energy is exported to the main electricity grid.

The appropriate PV system size for the house should be selected according to the household needs and in coordination with the power limits of the HBSS to improve the PVSCR and minimize the overall household energy costs.


**Table 7.** Effect of changing PV system size on the annual household energy cost and the PV self-consumption ratio using TOU purchasing tariff scheme and 6.4 kWh battery.

### **9. Conclusions**

This paper has assessed the performance of two home energy management systems based on (a) a real-time controller and (b) a model predictive controller over a one-year period. Using the real-time controller, the effect of adjusting the overnight charging level on the overall performance has been studied. The results showed that the lowest value for household energy cost increment ratio and the highest value for PV self-consumption ratio (i.e., 8.1% and 89.70%, respectively) could be achieved using a weather prediction for the next day to adjust the overnight charging level, but this would incur additional operational costs.

Load demand and PV generation forecasts can be made relatively easily using methods such as L-PWSD, L-PD, L-AV, PV-PD, and PV-AV, i.e., methods which use historical data only and do not require any complex forecasting model or meteorological data (i.e., temperature, irradiation, humidity, etc.), compared to using accurate prediction methods such as L-FP and PV-FP which require up-to-date weather prediction and complex modelling. L-FP and PV-FP forecasting packages achieve greater reductions in household energy costs and lower lost energy compared to simple prediction packages. However, these forecasting packages require a good communication infrastructure and also additional costs for complex modelling.

The performance of the MPC has been studied considering the effect of forecasting errors (this technique requires forecasting for its fundamental operation), the sample time, and different purchasing tariffs. The results show that with appropriate selection of the forecasting method for load demand and PV generation, a significant reduction in household peak energy demand from the supply utility and also the cost of home utility bills can be achieved. Using a 60 min sample time for MPC operation increases the household energy cost increment ratio by 35.2% and the lost energy ratio by 29.8% compared to using a two-minute sample time. Using a short scanning and response time of two minutes, the MPC controller can respond to changes in load and generation that occur over a short time, and therefore guarantees better performance and a higher reduction in costs for the householders. Using the time of use tariff scheme with a PV-battery system reduces the household energy costs even further compared to the other tariff schemes considered.

**Author Contributions:** Writing—original draft preparation, investigation and analysis, M.E.; methodology, M.S.; conceptualization, M.S. and D.T.; simulation, M.E.; experimental validation, M.E.; writing—review and editing, M.S. and D.T.; Visualization and Investigation, S.P.; validation and Software, R.D. All authors have read and agreed to the published version of the manuscript.

**Funding:** This work is supported by the University of Nottingham, the Egyptian Government—ministry of higher education (cultural affairs and missions sector) and the British Council through Newton-Mosharafa fund.

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

### **Appendix A**

**Figure A1.** The annual household energy costs and the annual PV self-consumption ratio using different overnight charging levels for the yearly optimized case (case 2).

### **References**


© 2020 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).

*Article*
