Model predictive control of heat pump based on a regression model fitted to data measured in accordance to EHPA regulation

. This paper presents a method for fitting a static regression model for the power consumption of a ground-sourced domestic heat pump, based on a low number of sample points extracted from a common measurement report developed in accordance to European Heat Pump Association (EHPA) regulation. Thereafter, we demonstrate how the coefficients can be updated with a Recursive Least Squares algorithm using only commonly accessible measurements. The regression model is designed to be used for control of a heat pump connected to an ON/OFF controlled floor heating system. The target of the method is especially systems where the flow in the floor heating circuits is unknown. The ability of the regression model to predict power consumption of the heat pump is evaluated using measurements obtained from a test-rig having the particular heat pump installed. The regression model is implemented as a module in a Mixed Integer Non-linear Model Predictive Control algorithm to illustrate the applicability of the model for control purposes. The promising results obtained from this investigation raise the question; should quality data be available in order to enable more advanced control of domestic heat pumps?


Introduction
The later years have seen a large increase in electric heat pumps becoming the main source of heat in singlefamily houses [1]. This electrification of the heat source creates an interesting bridge between space heating and electricity consumption. A connection, which is particularly interesting, if more energy assets (solar panels, energy storages, domestic wind turbines, etc.) are connected to the same system. Such energy assets are not independent, in the sense that the operational mode of one affect the others and vice versa.
In that light, there is a wish for harvesting the full potential of energy optimization for the combined system by coordinating these energy assets instead of letting them operate according to own objectives. Further, other external factors can be taken into account such as weather, resident behaviour, energy prices.
To optimize the operation with respect to energy savings, the controller must have knowledge about the system and environment and continuously collect measurements during operation in order to make optimal decisions regarding when, where and how much to heat.
Among other methods, such as Neural Networks (NN), Machine Learning (ML) and other Artificial Intelligence methods, Model Predictive Control (MPC) has been shown to be a solution to such a control problem. In [2] linear, linear time-varying and nonlinear MPC are applied to control an air-to-water heat pump connected to radiant floor heating. The performance of the heat pump is modelled using a time * Corresponding author: sith@es.aau.dk dependent function. The authors in [3] controlled a solar assisted heat pump using MPC with the heat pump efficiency modelled using a piece-wise linear function.
In this work we focus on the model of a domestic ground-sourced heat pump as a component in an MPC control scheme. More specifically, the model is a static regression expression with linear coefficients. The method presented here is developed with three goals in mind. The inputs to the model are restricted to be control inputs and cheap to measure state variables. Second, only readily available data can be used for fitting the coefficients. Last, it is a requirement that the model takes part as module in a functioning MPC algorithm.
The reason for the restrictions on data and measurements is that MPC, as well as the other mentioned methods, in general suffers from high commissioning costs. It easily gets very expensive to either develop a model, which MPC relies on, or collect the necessary data for methods like ML and NN. Without extensive amounts of data ML and NN cannot identify the important connections between cause and effect in the system. Until a solution is found most existing systems in single-family houses will likely either be regulated by ON/OFF-or PID-controllers.
We therefore ask whether it is possible to develop models and methods, which are cheap to obtain and perform acceptable.
To elaborate on the meaning of readily available data. It is common practice, for the manufacturer, to commission a measurement of the coefficient of performance (COP), seasonal coefficient of performance (SCOP) and other parameters according to the standards DIN EN 14511 (COP) [4], DIN EN 14825 (SCOP) [5], DIN EN 16147 (Domestic hot water heat pumps) [6]. The data generated during these tests exists for most heat pumps, which means it holds the potential of becoming the foundation for a generalized method for obtaining the model fit.
The concept of fitting regression models to such standard measurements is not new, in [7] the authors, in similar fashion, fit regression models to catalogue data, provided by the manufactures, with a high degree of accuracy. In [8] different linear, non-linear regression and artificial neural networks models are compared. However, unlike the previous works, we aim specifically at using the model in MPC schemes.
The layout of the rest of the paper is; first, we describe the fit of the regression model. Thereafter, a Recursive Least Squares (RLS) algorithm is applied to update the coefficients using the measured input power of the heat pump.
To validate the heat pump model, we investigate the accuracy of the fit when compared to data obtained from a test-rig and implement the model into a Mixed-Integer Non-linear MPC example to prove that the model can be part of a solvable optimization problem.
In the end, we elaborate on the findings and potential issues. Further, we discuss the potential value of these measurement reports, being made according to requirements established by the European Heat Pump Association (EHPA), with respect to control, and ask whether such reports should be mandatory and publicly available.

Materials and Methods
In this section the system is presented, followed by the method for fitting and recursively updating the linear coefficients for the static regression model. At last the Mixed Integer Non-linear Programming (MINLP) Model Predictive Control (MPC) example is described.

Introduction to system
The system considered in this paper, seen in Figure 1, reflects a common installation found in many houses. The setup is a ground-sourced heat pump, which feeds floor heating circuits with hot water. Each floor heating circuit provides heat to its own separate room. The flow of each floor heating circuit is balanced using a pre-set manifold valve and is controlled by an ON/OFF control valve. The control valves in a floor heating manifold are often wax-motor driven, which means there is a delay between the control signal and the reaction of the valve. In this work, we assume the reaction to be instantaneous. Table 1 shows signals and measurements that are available during operation.

Data
This study is based upon two main datasets, which are presented in the following two subsections. All data is freely available for download at [10].

Standard test data
The smaller dataset consist of 18 sample points extracted from the report containing the measurements obtained according to the standards EN14500, EN14825, EN16147. This data is from henceforward referred as the standard test data.

Test-rig data
The larger dataset consist of time series data sampled each minute over a time period of 24 days. The data is obtained from a test rig where the heat pump delivers heat to a simulated house with four floor heating circuits. The simulation calculates the response of the house based on the forward temperature and water flow.
A cooling system cools the return water from each circuit to emulate the transfer of heat to the floor. This dataset is divided into two parts. The first part covers 10 days and plays the role as data measured during operation, and the second is used for validation. This is referred to as fit test-rig data and validation test-rig data. More information about the test-rig can be found at [11]. The test-rig data is freely available at [10].

Static Regression Model for estimation of power input to the heat pump
In this section, the method for obtaining the regression model for the estimated consumed electric power � of the heat pump is described. The method consists of three main steps, a) use the standard test data to initially fit coefficients, b) replace the flow with an estimate based on the valve input vector , and c) update the coefficients online using Recursive Least Squares.

Initial fit using standard test data
To obtain an estimate for the heat pumps consumed electric power � , we formulate a multivariate quadratic polynomial Which takes the forward temperature , return temperature and mass flow as inputs. Using the data described in Section 2.2.1 a system of linear equations are formulated in matrix form seen in (2).
2 ] being the ℎ row in and = [ 0 … 6] T being the coefficients of (1) to solve for. This system of linear equations are overdetermined, so no exact solution exists. Instead, the coefficients in c are found by solving the Least Squares problem having solution with † being the pseudo inverse of . The choice of variables is guided by two objectives. The first being physical relevance and the second is all but one are considered easy to measure. In this case we assume , and to be directly measured during operation leaving only the flow unmeasured.

Fitting valve input to estimated flow
Since the flow is not measured it is replaced by an estimate based on the set of valve control signals defined as ∈ {0,1} where is the number of floor heating circuits. To obtain the estimate for the flow, is isolated in Eq. (1) as seen in Eq. (5).
Solving the second order equation in Eq.
(1) provides two solutions, so a choice has to be made whether to choose � + or � − for the estimate. The main criteria is that the values of � are positive, since a negative flow does not make physical sense in this context. If 3 , 6 > 0, then the choice is always � + . This can be obtained by formulating Eq. (3) as a constrained optimization problem, with 3 , 6 ≥ 0. This is a linear programming problem, which most solvers can handle.
Since the flow largely is decided by the combination of open valves, a linear regression expression, seen in Eq. (6), is used.
This means that � can be interpreted as a sum of nominal estimates with � , = being an estimate for the flow . Again the coefficients in = [ 1 … ] T are found by minimizing the squared error between � and � using Eq. (3). The data needed to fit the coefficients in , is measured during operation. The expression for � in (6) is then inserted into Eq. (1) giving � = ( , , ) The function is now only a function of measured variables and inputs. Structural-wise the expression is in principle ready for use in a predictive control scheme applied to the system described in Section 2.1.

Recursive least squares update of linear coefficients
Since is measured during operation, it is possible to update the linear coefficients in , from Eq. (4), recursively as new data comes in. The algorithm applied here is a common Recursive Least Squares (RLS), which can be found in standard literature, for further reading [12] and [13]. The RLS algorithm is shown in (8)- (13). To initiate the RLS algorithm a set of initial coefficients � 0 and the constant must be chosen. As seen in (9), the coefficients from is used. The constant is a tweaking parameter, which if chosen low (10 −5 ) only changes the coefficients of � ( ) slightly, and if chosen larger the coefficients might wander far from the initial values. In case all circuits are closed, the heat pump is turned off and the step of updating the coefficients is skipped.

Validation
In this section, we present the MPC control problem, which has been implemented and simulated to prove that the derived expression can take part in a solvable Mixed-Integer Non-linear Programming (MINLP) optimization problem.
� (14) subject to (15) ∈ {1, … , }, ∈ {0 … ℎ − 1} (16) ∈ ℝ ℎ , , ∈ ℝ + (17) with vectors and matrices being Superscript indicates the time period with ∈ {0, … , ℎ } being the prediction window. In this example, the control and prediction horizon have the same length. The room number is indicated in subscript using , with being the number of rooms. The cost function is quadratic and punishes energy consumption by the heat pump and divergence from the reference temperature. The vectors , and , contain the room temperature reference and estimated room temperatures for room over the prediction window, respectively. The vector contains the cost weights for each sample and have the unit euro per watt-hour [€/ ℎ]. The discomfort penalty for room is , with unit euro per kelvin squared hour [€/( 2 ℎ)]. The sample time ∆ has unit hours [ℎ]. The cost on temperature deviation is quadratic to punish both under and overheating of a room.
The control signals in are constrained according to (20), with the valve control signals being binary.
The model, seen in (21), reflects an RC-equivalent model, with two bilinear terms. The bi-linearity arises from the fact that both forward temperature and valve states are control inputs. The parameters represent heat conductance [ / ], is heat capacity [ / ] and is specific heat capacity for water. The estimated power consumption of the heat pump is � , which is derived in Sec. 2.3.
The return temperature is calculated using the output function ( , ). The output function is derived based on the energy balance in a mixing circuit seen in Eq. (33).
Since we do not have a measure of or we replace it with the estimate � seen in (6) and the nominal estimates for each circuit � , . For Eq. (34) to make sense � , has to be non-zero and positive.
which gives the result A small constant is added to avoid divison by zero.

Regression results
The overall result regarding the regression is that the initial regression fit performs acceptable without further update of the parameters. This said, we show that an improvement is obtained by updating the coefficients recursively.

Regression from standard test data
The result of for the initial regression expression fitted to the standard test data is presented in Figure 2. As seen in the left sub-figure the 2 value is close to one, indicating that no more information can be extracted from the 18 samples. The picture changes when the model is compared to the validation data where the inaccuracies get clearer with 2 ≈ 70%.
The  Notice that mass flow and forward temperature increase the cost and return temperature decreases it. This makes good sense, since a high return temperature means that less energy has to be induced to reach the requested forward temperature.

Results for linear regression of the flow
This section contains the results for the linear regression model of the flow seen in Eq. (6) and the isolated flow estimate � + seen in (5). To obtain a series of data points for � + measurements of , and from the first 10 days of the test-rig data is used. As can be seen in Figure 3 the estimate � + is catching the trend, but it does overestimate at large values when compared to the flow measurements obtained from the test-rig. Interesting enough, the results improve when the linear regression model for � , based on the control valve input signals, is used. This indicates that the initial assumption that the flow is a sum of nominal flows from each circuit is correct. Since � + is calculated by solving a second order equation complex roots can appear. This was experienced in this particular investigation. The complex roots were few and handled by using the real part only.

Results for recursive least squares update of the coefficients
The results from the RLS update of the coefficients in the regression model (7) show that it is possible to improve the estimate of the power input by use of online measurements. The graphs in Figure 4 compare the performance between RLC, for the cases = 10 −5 and δ = 10 6 , and the original fit from (7). The RMSE reduces from the original value of 506[W], obtained using the regression model from (7), to approx. 400[W] for = 10 −5 and 360[W] for = 10 6 when compared to the validation data. To provide an overview on how such an improvement looks the time series results are presented in Figure 5.
The results showed a high value ( = 10 6 ) caused a significant improvement to the estimation as seen on the absolute cumulative error in Figure 5. The total energy consumption of the heat pump over the validation period, seen in Figure 5, is approx. 70 kWh, which gives the following relative accuracy errors seen in Table 5 with relative accuracy error defined in Eq. (40).
Where � is the estimate and the measured value. The cost of choosing large is a very poor estimate in the initial period, seen in Figure 4. It took 2 days before the estimates improved compared to the initial fit. Further, the values of the coefficients were highly volatile before converging as seen in Figure 6. In contrast with = 10 −5 the coefficients were more steady, but the improvement in estimate was insignificant when compare to the validation data.
The curves in the upper row of Figure 6 and Figure  7 show the individual contribution from each measurement to the full expression. The curves are generated by setting every measurement except one to zero, then making a sweep over the remaining. One curve is made for each set of coefficients as they develop over time. The lighter lines are early solutions while the darker are later solutions. The red line is the final, curve. This is done to give an idea of how the components of the function develops as the RLS algorithm progresses. The main conclusion is that both choices of have advantages and disadvantages. If faster settling time and low coefficient volatility is priority then should be chosen low. If the accuracy of the estimate is of highest priority, then a high value could be chosen.

Results for MPC validation example
The results from the simulation of the model predictive control (MPC) algorithm containing the heat pump model, described in Section 2.4, is presented here. Since the focus is on solvability, several simplifications have been made. First, the model used for simulation is the same as the model described in the optimization Figure 6. Comparison between measured data, initial fit and recursive fit evaluated on the validation data. problem leaving out any model uncertainties. Additionally, it is assumed that future values, such as ambient temperature are known, fundamentally making it deterministic MPC. This said the optimization problem is solvable on a standard laptop (Lenovo T490s) as seen in Figure 8, which shows the progress of the states over the simulation window for each of the four rooms. The optimization problem is implemented in MATLAB using CasADi [16] for formulation and BONMIN as solver. The constraints in the optimization problem are relaxed using slack variables, when necessary, to maintain feasibility during simulation. The code is available in the public repository [10].
This particular example presented in Figure 8 and Figure 9 is solved using a sample time of 15 minutes and a prediction horizon of 8 samples corresponding to a length of 2 hours. This is relatively short, considering the time constants of a building. The deciding factor for the length of the prediction horizon is the complexity of the problem. The complexity of a Mixed-Integer Programming problem increases very fast with the length of the window. In this case, a prediction horizon of 10 samples occasionally took 30 min. to solve, which is problematic when the sample time is 15 min. Further, this issue only increases when more rooms are added to the problem, calling for another approach. A workaround is to use continuous variables in the range [0,1] and round to the closest integer. In this case solving time is seconds for windows of approx. 6 hours. The main conclusion from Figure 8 is that the controller is able to bring the room temperature to the reference using the discrete control inputs, which proves that the heat pump model can take part in a larger control problem. Figure 9 presents the results, which are directly related to the regression model of the heat pump. The three plots in Figure 9 show the estimate for the consumption � and the three inputs forward temperature , return temperature and combined flow in the floor heating circuit. Using common sense, the following situations led to high power consumptions. A large flow, means a larger mass needs to be heated, a large difference between return and forward temperature also naturally demands more energy. Further, a high forward temperature lowers the Carnot Coefficient of Performance (COPCarnot) due to the increased difference between cold (brine temperature) and warm (forward temperature) reservoir. Some of these patterns are visible in the results. In the first six hours the difference − is large combined with a high forward temperature which result in a high energy consumption, even though the flow is low. In the hours between 7 and 13, the consumption is lower, mainly due to the small difference between forward and return temperature. In the last period from hour 13 and onwards, the power consumption increases again due the combination of flow combined with rising forward temperature. It is an important conclusion that the power consumption increases with the forward temperature, since this effect reflects the drop in COPCarnot. Note that the return temperature is estimated, and the expression seen in (38) is directly dependent on forward temperature. This might cause the value to be volatile, and highly affect the estimate for the power consumption, therefor and improvement in this estimate should lead to better estimates for the power consumption.

Conclusion
In this paper, a quadratic regression model estimating the power consumption of a heat pump connected to ON/OFF controlled floor heating is presented. The data and measurements, used for fitting the coefficients, are chosen based on degree of availability in such an installation.
The data is extracted from a report containing common manufacture-commissioned tests intended to measure the COP under controlled conditions. The validation and recursive update is performed using the data obtained from the test-rig. Both data sets are made available for the purpose of scrutiny and further work.
The regression model is integrated into a Mixed -Integer Non-linear MPC problem which is proven solvable by example. In the spirit of this text, one has to emphasise that the MPC only could be solved with a window length up till 2 hours, on a standard laptop, and calculation time for an iteration could take as long as 30 minutes. This is troubling, since the model consists of only four rooms and with the type of time constants in play a window length of minimum 6 hours is much more beneficial.
The results indicate that there is enough information contained in the few data points from the standard test data to establish a cost relation between control inputs to the heat pump and the power consumption. This relation is important since an actual price can be attached to the power consumption enabling the use of Economic MPC (EMPC).
Since the data from the standard test seems to hold value in other contexts than for calculating COP and SCOP, the authors propose these test become mandatory and publicly available. One could imagine an online database containing operational data for all commercial models.
Because both the Recursive Least Squares (RLS) method and MPC are repetitive algorithms, it does not take much imagination to consider running the recursive algorithm parallel with the MPC algorithm. This approach might cause the optimization problem to become infeasible, due unexpected changes in the estimate of the heat pump power. Since this claim stays untested, we will not comment on it further.
The next logical step is to test the method against a heat pump, which is installed in a real house. Further, it is interesting to investigate whether a similar expression, using outside temperature, can be obtained for an air-towater heat pump. At last, an investigation of a more meaningful formulation of a model predictive controller, using the heat pump model is in its place.