# Field-Ready Implementation of Linear Economic Model Predictive Control for Microgrid Dispatch in Small and Medium Enterprises

^{1}

^{2}

^{*}

## Abstract

**:**

## 1. Introduction

## 2. Materials and Methods

#### 2.1. System Modelling and Implementation Specifics

#### 2.1.1. System Modelling

- Sample system state: SOC measurements, prediction of PV power and aggregated power demand
- Solve constrained optimization problem using the recently sampled state and the predictions from step 1 for the prediction horizon ${t}_{p}$;
- Apply first elements of the optimal control sequence of the decision variables ${P}_{2,c}$, ${P}_{2,d}$, ${P}_{{3}_{c}}$, and ${P}_{3,d}$ to the energy system for a specific control horizon ${t}_{c}$;
- Repeat after defined interval with a receding prediction horizon

#### 2.1.2. Hardware and Software Implementation

- commissioning: The parametrization of the MPC system parameters (storage capacities, bounds, efficiencies, ...) is done on the PLC and is available to the edge computer (EC) via Modbus, such that the commissioning engineer only requires IEC 61131 knowledge;
- reliability: Independent devices for supervisory control and underlying component control, such that fallback mechanisms in case of MPC failure can be implemented in the PLC;
- maintainability: separation of devices and modularization simplifies maintenance and further development;
- IT security: Independent devices provide different rights management, different interfacing (local and web), and media discontinuity.

#### 2.2. Predictions of Electricity Prices, Power Demand and PV Power

#### 2.2.1. Price Forecasts and Price Analysis

#### 2.2.2. Photovoltaic Power Predictions

#### 2.2.3. Power Demand Predictions

#### 2.3. HiL Simulations

#### 2.3.1. HiL System Architecture

#### 2.3.2. Simulation Acceleration and Synchronization

#### 2.3.3. Scenarios for HiL Simulation

#### Scenario 1

#### Scenario 2

#### 2.3.4. Scenario Evaluation

- (a)
- Status-quo operation strategy
- (b)
- Ex-post optimal operation

## 3. Results

#### 3.1. Electricity Price Analysis

#### 3.2. PV and Load Power Predictions

#### 3.3. Controller Model Verification

#### 3.4. Performance Evaluation of the Hardware Implementation

## 4. Discussion

## 5. Conclusions

## Author Contributions

## Funding

## Institutional Review Board Statement

## Informed Consent Statement

## Data Availability Statement

## Acknowledgments

## Conflicts of Interest

## Abbreviations

${A}_{eq}$ | Equality constraint matrix |

${A}_{ub}$ | Inequality constraint matrix |

${b}_{eq}$ | Equality constraint vector |

${b}_{ub}$ | Inuality constraint vector |

c | cost vector |

${c}_{\mathrm{feed}-\mathrm{in}}$ | Feed-in tariff of PV energy |

${c}_{\mathrm{supply}}$ | Supply price of electrical energy |

${C}_{i}$ | BESS/EV capacity |

$\Delta t$ | Step size |

d | day |

$\mathcal{D}$ | Set of days per week |

${\eta}_{i,c}$ | Charging efficiency of component i |

${\eta}_{i,d}$ | Discharging efficiency of component i |

${E}_{i}^{k}$ | Energy content of component i at timestep k |

h | Hour |

$\mathcal{H}$ | Set of hours per day |

k | Discretization step |

l | Lower bounds |

N | Number of timesteps |

${P}_{i}^{k}$ | Power of component i at timestep k |

${P}_{i,max}$ | Nameplate maximum power of component i |

${P}_{load,f}$ | Load power forecast at timestep k |

${P}_{pv,f}$ | PV power forecast at timestep k |

r | Pearson correlation coefficient |

$SO{C}_{i}$ | State of charge of component i |

${t}_{k}$ | Time at timestep k |

u | Upper bounds |

w | week |

$\mathcal{W}$ | Set of weeks per year |

x | State variables |

API | Application programming interface |

BESS | Battery electric storage system |

BSD | Berkeley Software Distribution |

CPU | Central processing unit |

DER | Distributed renewable energy resources |

DSM | Demand side management |

DWD | Deutscher Wetterdienst (German weather service) |

EV | Electric vehicle |

HiL | Hardware-in-the-loop |

ICT | Information and communications technology |

IO | Input/Output |

LP | Linear programming |

MAD | Mean absolute deviation |

MILP | Mixed integer linear programming |

MPC | Model predictive control |

NTP | Network time protocol |

NWP | Numerical weather prediction |

PID | Proportional–integral–derivative |

PLC | Programmable logic controller |

PV | Photovoltaic |

SCADA | Supervisory control and data acquisition |

SME | Small and medium enterprises |

SOC | State of charge |

## Appendix A. Simulation Results

#### Appendix A.1. Simulation Results of Scenario 1

#### Appendix A.2. Simulation Results of Scenario 2

## References

- Lund, P.D.; Lindgren, J.; Mikkola, J.; Salpakari, J. Review of energy system flexibility measures to enable high levels of variable renewable electricity. Renew. Sustain. Energy Rev.
**2015**, 45, 785–807. [Google Scholar] [CrossRef] [Green Version] - Auer, H.; Haas, R. On integrating large shares of variable renewables into the electricity system. Energy
**2016**, 115, 1592–1601. [Google Scholar] [CrossRef] - Corinaldesi, C.; Fleischhacker, A.; Lang, L.; Radl, J.; Schwabeneder, D.; Lettner, G. European Case Studies for Impact of Market-driven Flexibility Management in Distribution Systems. In Proceedings of the 2019 IEEE International Conference on Communications, Control, and Computing Technologies for Smart Grids (SmartGridComm), Beijing, China, 21–24 October 2019; pp. 1–6. [Google Scholar] [CrossRef]
- Directive (EU) 2019/944 of the European Parliament and of the Council of 5 June 2019 on Common Rules for the Internal Market for Electricity and Amending Directive 2012/27/EU. Official Journal of the European Union, 5 June 2019.
- aWATTar Deutschland GmbH. aWATTar Service API. Available online: https://www.awattar.de/services/api (accessed on 11 March 2021).
- Tibber Deutschland GmbH. Homepage. Available online: https://tibber.com/ (accessed on 13 April 2021).
- Next Kraftwerke GmbH. Homepage. Available online: https://www.next-kraftwerke.de/ (accessed on 13 April 2021).
- Alphonsus, E.R.; Abdullah, M.O. A review on the applications of programmable logic controllers (PLCs). Renew. Sustain. Energy Rev.
**2016**, 60, 1185–1205. [Google Scholar] [CrossRef] - Parisio, A.; Rikos, E.; Glielmo, L. A Model Predictive Control Approach to Microgrid Operation Optimization. IEEE Trans. Control. Syst. Technol.
**2014**, 22, 1813–1827. [Google Scholar] [CrossRef] - Halvgaard, R.; Poulsen, N.K.; Madsen, H.; Jorgensen, J.B.; Marra, F.; Bondy, D.E.M. Electric vehicle charge planning using Economic Model Predictive Control. In Proceedings of the 2012 IEEE International Electric Vehicle Conference, Greenville, SC, USA, 4–8 March 2012; pp. 1–6. [Google Scholar] [CrossRef]
- Freire, V.A.; de Arruda, L.V.R.; Bordons, C.; Marquez, J.J. Optimal Demand Response Management of a Residential Microgrid Using Model Predictive Control. IEEE Access
**2020**, 8, 228264–228276. [Google Scholar] [CrossRef] - Hu, J.; Shan, Y.; Guerrero, J.M.; Ioinovici, A.; Chan, K.W.; Rodriguez, J. Model predictive control of microgrids—An overview. Renew. Sustain. Energy Rev.
**2021**, 136, 110422. [Google Scholar] [CrossRef] - Elmouatamid, A.; Ouladsine, R.; Bakhouya, M.; El Kamoun, N.; Khaidar, M.; Zine-Dine, K. Review of Control and Energy Management Approaches in Micro-Grid Systems. Energies
**2021**, 14, 168. [Google Scholar] [CrossRef] - Garcia-Torres, F.; Zafra-Cabeza, A.; Silva, C.; Grieu, S.; Darure, T.; Estanqueiro, A. Model Predictive Control for Microgrid Functionalities: Review and Future Challenges. Energies
**2021**, 14, 1296. [Google Scholar] [CrossRef] - Xing, X.; Xie, L.; Meng, H. Cooperative energy management optimization based on distributed MPC in grid-connected microgrids community. Int. J. Electr. Power Energy Syst.
**2019**, 107, 186–199. [Google Scholar] [CrossRef] - Dongol, D.; Feldmann, T.; Schmidt, M.; Bollin, E. A model predictive control based peak shaving application of battery for a household with photovoltaic system in a rural distribution grid. Sustain. Energy Grids Netw.
**2018**, 16, 1–13. [Google Scholar] [CrossRef] - Doroudchi, E.; Feng, X.; Strank, S.; Hebner, R.E.; Kyyrä, J. Hardware–in–the–loop test for real–time economic control of a DC microgrid. J. Eng.
**2019**, 17, 4298–4303. [Google Scholar] [CrossRef] - Sangi, R.; Kümpel, A.; Müller, D. Real-life implementation of a linear model predictive control in a building energy system. J. Build. Eng.
**2019**, 22, 451–463. [Google Scholar] [CrossRef] - De Lorenzi, A.; Gambarotta, A.; Morini, M.; Rossi, M.; Saletti, C. Setup and testing of smart controllers for small-scale district heating networks: An integrated framework. Energy
**2020**, 205, 118054. [Google Scholar] [CrossRef] - Huyck, B.; de Brabanter, J.; de Moor, B.; van Impe, J.F.; Logist, F. Online model predictive control of industrial processes using low level control hardware: A pilot-scale distillation column case study. Control. Eng. Pract.
**2014**, 28, 34–48. [Google Scholar] [CrossRef] [Green Version] - Krupa, P.; Limon, D.; Alamo, T. Implementation of Model Predictive Control in Programmable Logic Controllers. IEEE Trans. Control. Syst. Technol.
**2020**, 29, 1–14. [Google Scholar] [CrossRef] - Johansen, T.A. Toward Dependable Embedded Model Predictive Control. IEEE Syst. J.
**2017**, 11, 1208–1219. [Google Scholar] [CrossRef] [Green Version] - IEC 60050-192—International Electrotechnical Vocabulary—Part 192: Dependability, 1st ed.; International Electrotechnical Commission: Geneva, Switzerland, 2015.
- Kull, T.; Zeilmann, B.; Fischerauer, G. PLC implementation of economic model predictive control for scheduling and dispatch in energy systems. In Proceedings of the ETG-Fb. 163: ETG-Kongress 2021 Das Gesamtsystem im Fokus der Energiewende, Wuppertal, Germany, 18–19 May 2021. [Google Scholar]
- Rawlings, J.B.; Angeli, D.; Bates, C.N. Fundamentals of economic model predictive control. In Proceedings of the 2012 IEEE 51st IEEE Conference on Decision and Control (CDC), Maui, HI, USA, 10–13 December 2012; pp. 3851–3861. [Google Scholar] [CrossRef]
- Afram, A.; Janabi-Sharifi, F.; Fung, A.S.; Raahemifar, K. Artificial neural network (ANN) based model predictive control (MPC) and optimization of HVAC systems: A state of the art review and case study of a residential HVAC system. Energy Build.
**2017**, 141, 96–113. [Google Scholar] [CrossRef] - Moncecchi, M.; Brivio, C.; Mandelli, S.; Merlo, M. Battery Energy Storage Systems in Microgrids: Modeling and Design Criteria. Energy
**2020**, 13, 2006. [Google Scholar] [CrossRef] [Green Version] - Bemporad, A.; Morari, M. Control of systems integrating logic, dynamics, and constraints. Automatica
**1999**, 35, 407–427. [Google Scholar] [CrossRef] - Kull, T.; Fischerauer, G. Online-Leistungsprognosen für Photovoltaikanlagen basierend auf physikalischen Anlagenmodellen und numerischen Wetterprognosen. In Berichte aus der Umweltinformatik; Wittmann, J., Ed.; Shaker: Düren, Germany, 2020. [Google Scholar]
- German Weather Service. Open Data Server. Available online: https://opendata.dwd.de/ (accessed on 13 April 2021).
- Fucile, E.; Kertész, S.; Lamy-Thépaut, S.; Najm, S. ECMWF’s new data decoding software ecCodes. Comput. Sect. Ecmwf Newsl.
**2015**, 35–39. [Google Scholar] [CrossRef] - Holmgren, W.F.; Hansen, C.W.; Mikofski, M.A. pvlib python: A python package for modeling solar energy systems. J. Open Source Softw.
**2018**, 3, 884. [Google Scholar] [CrossRef] [Green Version] - Dobos, A. PVWatts Version 5 Manual. Available online: https://www.osti.gov/biblio/1158421 (accessed on 30 June 2021).
- Stüber, M.; Scherhag, F.; Deru, M.; Ndiaye, A.; Sakha, M.M.; Brandherm, B.; Baus, J.; Frey, G. Forecast Quality of Physics-Based and Data-Driven PV Performance Models for a Small-Scale PV System. Front. Energy Res.
**2021**, 9. [Google Scholar] [CrossRef] - Kull, T.; Fischerauer, G.; Zeilmann, B. Hardware-in-the-loop test concept for an energy-optimized process control. In Proceedings of the 20. GMA/ITG-Fachtagung Sensoren und Messsysteme 2019, Nürnberg, Germany, 25–26 June 2019; AMA: Wunstorf, Germany, 2019; pp. 789–793. [Google Scholar] [CrossRef]
- German Federal Network Agency. SMARD|Download Market Data. Available online: https://www.smard.de/en/downloadcenter/download-market-data (accessed on 13 April 2021).
- Mitchell, S.; Peschiera, F.; Christophe-Marie Duquesne; O’Neil, R.J.; Usher, W.; Hsueh, F.Y.; Prypin, O.; Detha, U.; Feng, J.; Marvin, A.; et al. coin-or/pulp: 2.4. 2020. Available online: https://zenodo.org/record/3930501 (accessed on 30 June 2021).
- Hilbers, A.P.; Brayshaw, D.J.; Gandy, A. coin-or/cbc: Version 2.10.5. 2020. Available online: https://arxiv.org/pdf/2008.10300.pdf (accessed on 30 June 2021).
- Kull, T.; Zeilmann, B.; Fischerauer, G. Scenario Data for a fIeld-Ready Implementation of Linear Economic Model Predictive Control for Microgrid Dispatch in Small and Medium Enterprises. 2021; Unpublished work. [Google Scholar]

**Figure 1.**System architecture of the energy system under investigation and system components (${P}_{i}^{k}$ denoting power exchange and ${E}_{i}^{k}$ denoting energy content of component i at timestep k).

**Figure 2.**Hardware setup: (

**a**) Human–machine interface, (

**b**) power supply, (

**c**) PLC, (

**d**) edge computer, (

**e**,

**f**) fieldbus-coupled input and output modules of the PLC.

**Figure 5.**Heatmap of hourly electricity prices in ct/kWh during the year 2020. Extreme values outside the interval 15 ct/kWh ≤ c ≤30 ct/kWh are not shown (outliers see Figure 7).

**Figure 6.**Relative frequency density of hourly electricity prices (

**a**), outliers not shown, see Figure 7), of intraday price spreads (

**b**), and of MAD from daily mean prices (

**c**) in the year 2020.

**Figure 7.**Hourly share of renewable energy versus hourly corresponding energy prices with a Pearson correlation coefficient of $r=-0.73$ (Germany, 2020). The red line marks the basic fee per kWh of the chosen electricity tariff, prices below the red line correspond to negative prices at the stock market.

**Figure 9.**Relative frequency density of the prediction errors for the PV power forecast and the power demand forecast compared to simulation data (retrieved from historic measurement data) in the production facility in Scenario 1.

**Figure 10.**Relative frequency density of the prediction errors for the PV power forecast and the power demand forecast compared to simulation data (retrieved from historic measurement data) in the production facility in Scenario 2.

**Table 1.**Yearly average of: Intraday mean price depending, intraday price spread, and intraday MAD depending on the type of day, calculated from historic price data of the year 2020 in ct/kWh.

Mon | Tue | Wed | Thu | Fri | Sat | Sun | |
---|---|---|---|---|---|---|---|

Mean price | 23.94 | 23.10 | 23.25 | 23.23 | 23.07 | 22.29 | 21.54 |

Mean price spread | 3.14 | 2.70 | 2.26 | 2.39 | 1.96 | 1.53 | 2.69 |

MAD | 0.71 | 0.60 | 0.58 | 0.56 | 0.49 | 0.32 | 0.61 |

Scenario 1 | Scenario 2 | |||||
---|---|---|---|---|---|---|

Cost | Total | Supply | Feed-in | Total | Supply | Feed-in |

Status quo | 401.03 € | 408.59 € | −7.56 € | 440.75 € | 448.85 € | −8.10 € |

Ex-post optimal | 385.70 € | 386.54 € | −0.84 € | 415.49 € | 416.35 € | −0.86 € |

MPC, HiL | 387.92 € | 388.93 € | −1.01 € | 422.52 € | 424.13 € | −1.61 € |

**Table 3.**Energy from utility grid: Renewable energy (ren.), renewable energy share from grid, conventional energy (conv.), conventional share from grid, total energy from grid and reduction of utility-grid energy due to increased DER own consumption in ex-post optimal case and MPC controlled case (HiL-experiment) for both scenarios.

Ren. Energy | ren. Share | conv. Energy | conv. Share | Total | Reduction | |
---|---|---|---|---|---|---|

Status quo S1 | 712.5 kWh | 40.7% | 1037.2 kWh | 59.3% | 1749.7 kWh | |

Ex-post opt. S1 | 733.9 kWh | 43.8% | 0941.4 kWh | 56.2% | 1675.3 kWh | 4.2% |

MPC, HiL S1 | 736.1 kWh | 43.8% | 0943.7 kWh | 56.2% | 1679.8 kWh | 4.0% |

Status quo S2 | 750.0 kWh | 41.3% | 1068.0 kWh | 58.7% | 1818.0 kWh | |

Ex-post opt. S2 | 768.9 kWh | 44.2% | 0970.7 kWh | 55.8% | 1739.6 kWh | 4.3% |

MPC, HiL S2 | 780.2 kWh | 44.1% | 0989.5 kWh | 55.9% | 1769.7 kWh | 2.7% |

Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations. |

© 2021 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 (https://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Kull, T.; Zeilmann, B.; Fischerauer, G.
Field-Ready Implementation of Linear Economic Model Predictive Control for Microgrid Dispatch in Small and Medium Enterprises. *Energies* **2021**, *14*, 3921.
https://doi.org/10.3390/en14133921

**AMA Style**

Kull T, Zeilmann B, Fischerauer G.
Field-Ready Implementation of Linear Economic Model Predictive Control for Microgrid Dispatch in Small and Medium Enterprises. *Energies*. 2021; 14(13):3921.
https://doi.org/10.3390/en14133921

**Chicago/Turabian Style**

Kull, Tobias, Bernd Zeilmann, and Gerhard Fischerauer.
2021. "Field-Ready Implementation of Linear Economic Model Predictive Control for Microgrid Dispatch in Small and Medium Enterprises" *Energies* 14, no. 13: 3921.
https://doi.org/10.3390/en14133921