You are on page 1of 63

Institutionen fr systemteknik

Department of Electrical Engineering


Examensarbete
Control of a Ground Source Heat Pump using
Hybrid Model Predictive Control
Examensarbete utfrt i Reglerteknik
vid Tekniska hgskolan vid Linkpings universitet
av
Markus Sundbrandt
LiTH-ISY-EX--11/4514--SE
Linkping 2011
Department of Electrical Engineering Linkpings tekniska hgskola
Linkpings universitet Linkpings universitet
SE-581 83 Linkping, Sweden 581 83 Linkping
Control of a Ground Source Heat Pump using
Hybrid Model Predictive Control
Examensarbete utfrt i Reglerteknik
vid Tekniska hgskolan i Linkping
av
Markus Sundbrandt
LiTH-ISY-EX--11/4514--SE
Handledare: Sina Khoshfetrat Pakazad
isy, Linkpings Universitet
Jim Fredin
Bosch Thermoteknik AB
Examinator: Daniel Axehill
isy, Linkpings Universitet
Linkping, 13 October, 2011
Avdelning, Institution
Division, Department
Division of Automatic Control
Department of Electrical Engineering
Linkpings universitet
SE-581 83 Linkping, Sweden
Datum
Date
2011-10-13
Sprk
Language
Svenska/Swedish
Engelska/English

Rapporttyp
Report category
Licentiatavhandling
Examensarbete
C-uppsats
D-uppsats
vrig rapport

URL fr elektronisk version


http://www.control.isy.liu.se
http://www.ep.liu.se
ISBN

ISRN
LiTH-ISY-EX--11/4514--SE
Serietitel och serienummer
Title of series, numbering
ISSN

Titel
Title
Reglering av en bergvrmepump med hjlp av hybrid modellprediktiv reglering
Control of a Ground Source Heat Pump using Hybrid Model Predictive Control
Frfattare
Author
Markus Sundbrandt
Sammanfattning
Abstract
The thesis has been conducted at Bosch Thermoteknik AB and its aim is to de-
velop a Model Predictive Control (MPC) controller for a ground source heat pump
which minimizes the power consumption while being able to keep the inside air
temperature and Domestic Hot Water (DHW) temperature within certain comfort
intervals.
First a model of the system is derived, since the system consists of both con-
tinuous and binary states a hybrid model is used. The MPC controller utilizes the
model to predict the future states of the system, and by formulating an optimiza-
tion problem an optimal control is achieved.
The MPC controller is evaluated and compared to a conventional controller us-
ing simulations. After some tuning the MPC controller is capable of maintaining
the inside air and DHW temperature at their reference levels without oscillat-
ing too much. The MPC controllers general performance is quite similar to the
conventional controller, but with a power consumption which is 1-3 % lower. A
simulation using an inside air temperature reference which is lowered during the
night is also conducted, it achieved a power consumption which was 7.5 % lower
compared to a conventional controller.
Nyckelord
Keywords Model Predictive Control, MPC, Hybrid Model Predictive Control, Hybrid Sys-
tems, Modelling, Heat Pump
Abstract
The thesis has been conducted at Bosch Thermoteknik AB and its aim is to de-
velop a Model Predictive Control (MPC) controller for a ground source heat pump
which minimizes the power consumption while being able to keep the inside air
temperature and Domestic Hot Water (DHW) temperature within certain comfort
intervals.
First a model of the system is derived, since the system consists of both con-
tinuous and binary states a hybrid model is used. The MPC controller utilizes the
model to predict the future states of the system, and by formulating an optimiza-
tion problem an optimal control is achieved.
The MPC controller is evaluated and compared to a conventional controller us-
ing simulations. After some tuning the MPC controller is capable of maintaining
the inside air and DHW temperature at their reference levels without oscillat-
ing too much. The MPC controllers general performance is quite similar to the
conventional controller, but with a power consumption which is 1-3 % lower. A
simulation using an inside air temperature reference which is lowered during the
night is also conducted, it achieved a power consumption which was 7.5 % lower
compared to a conventional controller.
Sammanfattning
Denna uppsats har utfrts hos Bosch Thermoteknik och dess ml r att utveckla
en MPC regulator fr en bergvrmepump som minimerar eektfrbrukningen och
samtidigt klarar av att hlla inomhus- och varmvattentemperaturen inom en viss
komfortzon.
Frst har en modell fr systemet tagits fram, eftersom systemet innehller bde
diskreta och kontinuerliga tillstnd har en hybridmodell anvnts. MPC regulatorn
utnytjar modellen fr att prediktera systemets framtida tillstnd och genom att
formulera ett optimeringsproblem erhlls en optimal styrning.
MPC regulatorn utvrderas och jmfrs med en konventionell regulator ge-
nom simuleringar. Efter intrimmning klarar MPC regulatorn att hlla inomhus-
och varmvattentemperaturen vid sina referensniver utan att oscillera fr mycket.
MPC regulatorns generella prestanda r ganska lik den konventionella regulatorns,
men eektfrbrukningen r 1-3 % lgre. En simulering med en referensinomhus-
temperatur som snks under natten utfrs ocks, den uppndde en energifrbruk-
ning som var 7.5 % lgre jmfrt med en konventionell regulator.
v
Acknowledgments
I would like to thank Magnus Erixon for giving me the opportunity to conduct this
thesis at Bosch Themoteknik. My supervisor at Bosch Thermoteknik, Jim Fredin,
has been very helpful whenever I have had questions regarding heat pumps. I would
also like to thank all the people in the control group at Bosch Thermoteknik who
have provided help when needed.
My supervisor at LiU, Sina Khoshfetrat Pakazad, has always supported me
whenever I needed to discuss or ask questions about dierent problems I encoun-
tered. My examiner, Daniel Axehill, have guided me throughout the thesis and
helped when needed.
Finally, I would like to thank my family and especially my girlfriend for always
supporting me throughout my studies at Linkping University.
Linkping, October 2011
Markus Sundbrandt
vii
Contents
1 Introduction 1
1.1 Heat Pumps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.3 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.4 Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.5 Related Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.6 Bosch Thermoteknik . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.7 Thesis Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2 Preliminaries 5
2.1 Model Predictive Control - MPC . . . . . . . . . . . . . . . . . . . 5
2.1.1 Prediction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.1.2 Cost Function . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.1.3 Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1.4 Tuning Parameters . . . . . . . . . . . . . . . . . . . . . . . 7
2.2 Hybrid Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.3 Hybrid MPC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3 Modelling 11
3.1 Thermal Behavior of the Building . . . . . . . . . . . . . . . . . . . 11
3.2 The Heat Pump . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.3 Combining the Models . . . . . . . . . . . . . . . . . . . . . . . . . 25
4 Implementation 27
4.1 Cost Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.2 Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.3 Optimization Problem . . . . . . . . . . . . . . . . . . . . . . . . . 28
5 Simulations 31
5.1 Simulation Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
5.2 Tuning of the MPC . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
5.3 Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
5.3.1 Scenario 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
5.3.2 Scenario 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
5.3.3 Scenario 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
ix
x Contents
5.3.4 Scenario 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
6 Discussion and Conclusion 43
7 Future work 47
Bibliography 49
Chapter 1
Introduction
The purpose of a ground source heat pump (henceforth referred to only as a heat
pump) is to utilize the energy stored in the ground to get a lower heating cost.
When controlling a heat pump a trade-o between power consumption and user
comfort will have to be made. Running the heat pump often will make it possible to
ensure the comfort of the user however the cost of the electric energy will be large.
It would therefore be desirable to have a controller which minimizes the heating
cost while still maintaining a comfortable inside air temperature and Domestic
Hot Water (DHW) temperature.
1.1 Heat Pumps
A heat pump consists of four main components: a condenser, an evaporator, a
compressor and an expansion valve. By adding electric energy to the compressor
heat is transfered from a cold environment to a warm heated space see Figure 1.1.
In the case of a ground source heat pump, heat is extracted from a bore hole and
transfered to the refrigeration medium by a heat exchanger called the evapora-
tor. The pressure of the refrigeration medium is then increased by the compressor
and hence the temperature of the refrigeration medium is also increased. Heat is
then transfered from the refrigeration medium to the heating system by a heat
exchanger called the condenser. The pressure and the temperature of the refrig-
eration medium is then lowered when passing trough the expansion valve. The
situation is illustrated in Figure 1.1
1.2 Background
The heat pump is controlled by an on/o signal and a signal to a three-way
valve which decides whether to produce DHW or radiator water. To minimize
the power consumption of the heat pump while still having a comfortable inside
air temperature and DHW temperature, one will have to decide on how long the
heat pump should run and whether to produce DHW or radiator water. The heat
1
2 Introduction
W
Cold Environment
Q
L
Warm Heated Space
Q
H
Evaporator
Condenser
Compressor
Expansion
Valve
Heat Pump
T
1
> T
4
P
1
T
2
> T
1
P
2
> P
1
T
3
< T
2
P
2
T
4
< T
3
P
1
< P
2
Figure 1.1. Overview of a heat pump.
1.3 Objectives 3
pumps consumed electrical power is also increased with increased temperature of
the water delivered out from the heat pump or the so called ow temperature. Also
to get a good life expectancy of the compressor, a maximum number of starts and
stops per hour should not be violated. When the heat pump is stopped it is not
allowed to start again for 10-15 minutes because it could damage the compressor.
To get a comfortable indoor climate the indoor temperature should not oscillate
by more than approximately 1.5

C and the DHW temperature should not become
too low. If it is possible to lower the power consumption of the heat pump while
still having a comfortable indoor- and DHW temperature, it will be benecial
for both the environment and the users heating costs. One type of controller
which is becoming more common is model predictive control (MPC), thanks to the
development of computers and their ability to solve more complicated problems.
An MPC controller utilizes the knowledge of the systems dynamics by the use
of an internal model of the system to predict the future behavior of the system
and benet from it. One advantage of the MPC is its ability to easily incorporate
limitations and constraints on control signals and states and it can also handle
multiple inputs and outputs in a simple way. Since the heat pump consists of both
continuous and discrete states and inputs, a hybrid MPC will have to be used.
1.3 Objectives
The goal of this thesis is to develop an MPC controller for a heat pump which
minimizes the power consumption while controlling the inside temperature of the
house and the DHW temperature. To do this a model which can capture the
dynamics of the system will have to be derived. The performance of the MPC
controller will be evaluated and compared to a conventional controller using sim-
ulations.
Goals
Derive a model of the thermal behavior of the house and the DHW.
Develop an MPC controller which:
minimizes the consumed power,
is capable of maintaining a reference inside air temperature and not
oscillate by more than 1.5

C,
is capable of keeping the DHW temperature above 44

C for most of the
time, lower temperatures can be accepted when DHW tapping occurs
but the DHW temperature should never be lower than 42

C.
1.4 Scope
The arguments presented in this thesis will only be based on simulations and no
real data will be used. A verication of the results would require real data which
4 Introduction
is not provided for this thesis. However the model used for simulations is quite
sophisticated and have been veried. The model of the heat pump is simplied
and is based on a steady state model, therefore it can not capture the transient
behavior of the heat pump during starts and stops. The identication of the
parameters of the internal model is not described in the thesis since the focus is
not on system identication.
1.5 Related Work
Methods for modeling the thermal behavior of buildings have been studied in
several articles and papers. In [14] a simplied physical model of a multi-zone
heating system is proposed and a similar modeling technique is presented in [6].
Modelling of hybrid systems is described in [4]. General theory on MPC is treated
in [16, 7] and hybrid MPC is discussed in [2]. The use of MPC for heat pumps
has been done in [5] where the required heating power of the building is predicted
and the controller delivers this predicted heating power by using a pulse width
modulation concept.
1.6 Bosch Thermoteknik
The work done in this thesis was conducted at Bosch Thermoteknik AB, Trans,
Sweden. Bosch Thermoteknik produces and develops energy ecient products
with a focus on renewable energy. The main product which is developed is heat
pumps where Bosch Thermoteknik are the market leader in Europe.
1.7 Thesis Outline
Chapter 1 gave an introduction to the topic, goals and presented a summary of the
related research. In chapter 2 a description of the theory of hybrid systems and
MPC is given. An overview of the heating system is provided in chapter 3 and the
mathematical model of the heating system is also introduced. The implementation
of the controller is given in chapter 4. In chapter 5 a description of the simulation
environment and the simulation results are given. Discussion of the results and
conclusions are given in chapter 6. Finally, future work is treated in chapter 7.
Chapter 2
Preliminaries
This chapter gives an introduction to the theory behind the ideas and results of
this thesis.
2.1 Model Predictive Control - MPC
During the last years Model Predictive Control (MPC) have become a more com-
monly used control strategy. This has become possible as computers have become
more powerful and are able to make large computations in real-time. A great
advantage of MPC is that it can deal with constraints in a simple and intuitive
way. The idea is to utilize the knowledge about the system, using a process model,
to calculate an optimal control sequence at every time step. A simple algorithm
which illustrates the procedure is taken from [7] and looks as follows:
1. At time t compute or predict a number of future output signals y(t + k[t),
k = 1, . . . , M. These will depend on future control signals u(t + j), j =
0, 1, . . . , N and on the the known measurements at time t.
2. Formulate a criteria based on these variables and optimize with respect to
u(t +j), j = 0, 1, . . . , N.
3. Apply u(t).
4. Await the next time t + 1 and go to 1.
Since the MPC is solving the optimization problem for a nite time horizon
which moves forward in time at each sample, this control strategy is also known
as receding horizon control.
2.1.1 Prediction
A linear system without noise can be written in state space form [9] as:
x(t) = Ax(t) +Bu(t), (2.1a)
y(t) = Cx(t) +Du(t), (2.1b)
5
6 Preliminaries
where x(t) is a vector of n states, A is a nn matrix, u(t) is a vector of m inputs,
B is a n m matrix, y(t) is a vector of p outputs, C is a p n matrix and D is a
p m matrix.
The state space model can be discretized using for example Eulers forward
method:
x(t)
x(t +T
s
) x(t)
T
s
, (2.2)
where T
s
is the sample time.
The discrete version of model 2.1b can therefore be written as
x(k + 1) = A
d
x(k) +B
d
u(k), (2.3)
By using Equation 2.3 recursively, as in [17] a prediction of future states can
be made, one gets
x(k +2) = A
d
x(k +1) +B
d
u(k +1) = A
2
d
x(k) +A
d
B
d
u(k) +B
d
u(k +1). (2.4)
By repeating the recursion, it can be shown that
X =

Ax(k) +

BU, (2.5)
where
X =
_
_
_
_
_
x(k)
x(k + 1)
.
.
.
x(k +N 1)
_
_
_
_
_
, U =
_
_
_
_
_
u(k)
u(k + 1)
.
.
.
u(k +N 1)
_
_
_
_
_
,

A =
_
_
_
_
_
I
A
d
.
.
.
A
N1
d
_
_
_
_
_
,

B =
_
_
_
_
_
_
_
0 0 0 0
B
d
0 0 0
A
d
B
d
B
d
0 0
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
A
N2
d
B
d
A
d
B
d
B
d
0
_
_
_
_
_
_
_
,
where N is the prediction horizon. This prediction can be used in the cost function
to formulate an optimization problem which gives an optimal control sequence.
2.1.2 Cost Function
The cost function can be formulated in dierent ways but often the rate of change
of inputs, u

(k) = u(k)u(k1), and predicted control error, e(k) = r(k) y(k)


where r(k) is the reference signal and y(k) is the predicted outputs at sample k,
is penalized. The cost function is then written as
J(u

) =
N

k=1
e
T
(k)P
e
e(k) +u
T

(k)P
u
u

(k), (2.6)
where P
e
and P
u
are weight matrices.
2.2 Hybrid Systems 7
2.1.3 Constraints
One of the reasons MPC has become popular is its ability to handle constraints
on control signals and outputs. The constraints are often written as inequities
a u(k) b, k = 1, 2, . . . , N (2.7)
c x(k) d, k = 1, 2, . . . , N. (2.8)
However the constraints on the inputs and outputs can sometimes cause the opti-
mization problem to become infeasible. It happens if there exists no control signals
which can hold the system within the bounds dened by constraint 2.8. For ex-
ample it can be caused by large disturbances or if the model used for prediction is
not good enough. Often this problem is solved by introducing non-negative slack
variables, , into the constraints,
c

(k) x(k) d +
+
(k), k = 1, 2, . . . , N, (2.9)

(k),
+
(k) 0, k = 1, 2, . . . , N. (2.10)
The slack variables E = [

(1),
+
(1), . . . ,

(N),
+
(N)] are included in the cost
function and weighted by the matrix P
s
J(u

) =
N

k=1
e
T
(k)P
e
e(k) +u
T

(k)P
u
u

(k) +E
T
P
s
E. (2.11)
By having a large penalty for the slack variables it is possible to keep them close
to zero as long as the states lie within the original bounds.
2.1.4 Tuning Parameters
The parameters used for tuning the MPC controller are the prediction horizon,
N, and the penalty matrices, P
e
, P
u
, P
s
. Often the states and control signals
used in the cost function are normalized to simplify the tuning of the controller.
Since the MPC is discrete the sample time T
s
can also be considered as a tuning
parameter.
2.2 Hybrid Systems
Systems which have both logic, discrete and continuous dynamics are known as
hybrid systems. Systems which include switches and valves such as a heat pump
are examples of hybrid systems. There are several ways to model a hybrid system,
for example mixed logical dynamical (MLD) systems, [4] or piecewise ane (PWA)
systems [3], their equivalence has been shown in [11]. In this thesis the MLD
framework will be used.
A hybrid system can be written on MLD form as
x(k + 1) = A
k
x(k) +B
1k
u(k) +B
2k
(k) +B
3k
z(k) (2.12a)
y(k) = C
k
x(k) +D
1k
u(k) +D
2k
(t) +D
3k
z(k) (2.12b)
E
2k
(k) +E
3k
z(k) E
1k
u(k) +E
4k
x(k) +E
5k
, (2.12c)
8 Preliminaries
where k Z, x is the state of the system, y is the output vector, u is the input
vector, and z are vectors of auxiliary logical and continuous variables.
Products of logical variables and of continuous and logical variables can be
expressed in the same way as in [4]. The product of two logical variables,
1

2
,
can be replaced using an auxiliary variable

3
=
1

2

_

1
+
3
0,

2
+
3
0,

1
+
2

3
1.
(2.13)
A product of a logical variable, , and a function of the states, f(x), can be
replaced by an auxiliary variable z f(x).
z f(x)
_

_
z M,
z m,
z f(x) m(1 ),
z f(x) M(1 ),
(2.14)
where
M max f(x) (2.15)
and
m min f(x). (2.16)
By converting a general hybrid model using equations 2.13 - 2.16 it is possible
to formulate a MLD model on the form of equations 2.12a - 2.12c
2.3 Hybrid MPC
Using MPC with a hybrid model and constraints is possible by adding the MLD
equations 2.12a - 2.12c as constraints. With the notation e

(k) =
r
(k) (k),
e
z
(k) = z
r
(k) z(k), where index r indicates reference signal, the control problem
can then be formulated as
min J(u

, ) =
N

k=1
e
T
(k)P
e
e(k) +u
T

(k)P
u
u

(k) +e
T

(k)P

(k) +
e
T
z
(k)P
z
e
z
(k) (2.17a)
subject to
x(k + 1) = A
k
x(k) +B
1k
u(k) +B
2k
(k) +B
3k
z(k) (2.17b)
y(k) = C
k
x(k) +D
1k
u(k) +D
2k
(k) +D
3k
z(k) (2.17c)
E
2k
(k) +E
3k
z(k) E
1k
u(k) +E
4k
x(k) +E
5k
. (2.17d)
2.3 Hybrid MPC 9
The optimization problem formed by equation 2.17a - 2.17d is in the form
of a Mixed Integer Quadratic Programming (MIQP), for which there exists well-
developed optimization packages [1, 10, 12].
Chapter 3
Modelling
The modelling have been divided into two main parts, a model of the thermal
behavior of the house and a model of the heat pump. The models have then been
combined to get a complete model of the heating system.
3.1 Thermal Behavior of the Building
The building will be modeled as a single room with a radiator and a DHW tank,
the heat pump delivers heat to the radiator or DHW tank depending on how
the three-way valve is set. The outside air temperature and solar radiation is
considered as measured disturbances. The users DHW tapping will aect the
DHW temperature and is also modeled as disturbance. An overview of the system
can be seen in Figure 3.1.
The building is modeled in the same way as in [14] by using the following
equations:
C
in,air
dT
in,air
(t)
dt
= Q
emit
(t) +Q
solar
(t) K
2
(T
in,air
(t) T
in,wall
(t))
K
3
(T
in,air
(t) T
out,air
(t)) +K
1c
(T
DHW
(t) T
in,air
(t)), (3.1)
C
in,wall
dT
in,wall
(t)
dt
= (1 )Q
emit
(t) +K
2
(T
in,air
(t) T
in,wall
(t))
K
4
(T
in,wall
(t) T
out,wall
(t)) +K
1r
(T
DHW
(t) T
in,wall
(t)), (3.2)
C
out,wall
dT
out,wall
(t)
dt
= (1 )Q
solar
(t) +K
4
(T
in,wall
(t) T
out,wall
(t))
K
5
(T
out,wall
(t) T
out,air
(t)), (3.3)
11
12 Modelling
PP

eeee
WPW
kkk
Prrre rrrrrr
k
rkrrr
k
rkree
Q
rrer
k
rrrree
Q
rr
Q
WPW
Q
PP
k
rrrrrr
k
WPW
Figure 3.1. System overview.
C
DHW
dT
DHW
(t)
dt
= Q
DHW
(t) K
1r
(T
DHW
(t) T
in,wall
(t))
K
1c
(T
DHW
(t) T
in,air
(t)). (3.4)
Due to the inertia of the water system one gets

1
dQ
emit
(t)
dt
= Q
emit
(t) +Q
HP
(t) u
HP
(t) u
3wv
(t) (3.5)
and

2
dQ
DHW
(t)
dt
= Q
DHW
(t) +Q
HP
(t) u
HP
(t) u
3wv
(t), (3.6)
where
T
in,air
= average inside air temperature [K].
T
in,wall
= average temperature of the inner walls [K].
T
out,wall
= average temperature of the outer walls [K].
T
DHW
= average temperature in the DHW tank [K].
3.1 Thermal Behavior of the Building 13
T
out,air
= outside air temperature [K].
C
in,air
=thermal capacity of the inside air [J/K].
C
in,wall
=thermal capacity of the inner wall [J/K].
C
out,wall
=thermal capacity of the outer wall [J/K].
C
DHW
= thermal capacity of the DHW tank [J/K].
K
1c
= heat transfer coecient between the DHW tank and the inside air
[W/K].
K
1r
= heat transfer coecient between the DHW tank and the inner wall
[W/K].
K
2
= heat transfer coecient between the inside air and the inner wall
[W/K].
K
3
= heat transfer coecient between inside and outside air [W/K].
K
4
= heat transfer coecient between inner and outer wall [W/K].
K
5
= heat transfer coecient between the outer wall and the outside air
[W/K].

1
= thermal inertia of the radiator water system [s].

2
= thermal inertia of the DHW system [s].
Q
HP
= the power which the heat pump is capable of delivering [W].
Q
emit
= power emitted from the radiators [W].
Q
DHW
= power delivered to the DHW tank [W].
Q
solar
= power from solar radiation [W].
= the percentage of solar radiation penetrating into the building [].
= the percentage of emitted heat from radiator by convection [].
u
HP
= control signal to the heat pump.
u
3wv
= control signal to the three way valve.
Since the surface area of the DHW tank and the radiator is very small compared
to the surface area of the walls, the radiation between DHW tank and radiator
has been neglected. Using the equations above it is possible to make a state space
representation of the house. Let the state vector be x(t) = [T
in,air
(t), T
in,wall
(t),
T
out,wall
(t), T
DHW
(t), Q
emit
(t), Q
DHW
(t)]
T
. The outputs that we are interested
in are the states T
in,air
(t) and T
DHW
(t) and therefore we get an output vector
y(t) = [y
1
(t), y
2
(t)]
T
[T
in,air
(t), T
DHW
(t)]
T
. Since the control signals u
HP
(t)
and u
3wv
(t) are on/o signals they can be represented by the binary inputs u
b,1
(t)
14 Modelling
and u
b,2
(t). By using Equation 2.13 the product terms u
HP
(t)u
3wv
(t) and u
HP
(t)
u
3wv
(t) can be replaced by auxiliary variables
1
(t) u
b,1
(t)u
b,2
(t) and
2
(t)
u
b,1
(t)u
b,2
(t), where

1
= u
b,1
u
b,2

_

_
u
b,1
+
1
0,
u
b,2
+
1
0,
u
b,1
+u
b,2

1
1,
(3.7)
and

2
= u
b,1
u
b,2

_

_
u
b,1
+
2
0,
u
b,2
+
2
1,
u
b,1
u
b,2

2
0.
(3.8)
The auxilliary binary variables can then be represented by the vector (t) =
[
1
(t),
2
(t)]
T
and the binary inputs by the vector u(t) = [u
b,1
(t), u
b,2
(t)]
T
. Since
the outside temperature and the solar radiation can not be aected they are treated
as a measured disturbance in a separate vector n(t) = [T
out,air
(t), Q
solar
(t)]
T
.
A state space model of the thermal behavior of the building can be written as
x(t) =
_
_
_
_
_
_
_
_
_
K
2
K
3
K
1c
C
in,air
K
2
C
in,air
0
K
2
C
in,wall
K
2
K
4
K
1r
C
in,wall
K
4
C
in,wall
0
K
4
C
out,wall
K
4
K
5
C
out,wall
K
1c
C
DHW
K
1r
C
DHW
0
0 0 0
0 0 0


K
1c
C
in,air

C
in,air
0
K
1r
C
in,wall
(1)
C
in,wall
0
0 0 0
K
1r
K
1c
C
DHW
0
1
C
DHW
0
1

1
0
0 0
1

2
_
_
_
_
_
_
_
_
_
x(t)
+
_
_
_
_
_
_
_
_
0 0
0 0
0 0
0 0
0
Q
HP

1
Q
HP

2
0
_
_
_
_
_
_
_
_
(t) +
_
_
_
_
_
_
_
_
_
K
3
C
in,air

C
in,air
0 0
K
5
C
out,wall
(1)
C
out,wall
0 0
0 0
0 0
_
_
_
_
_
_
_
_
_
n(t) (3.9a)
y(t) =
_
1 0 0 0 0 0
0 0 0 1 0 0
_
x(t) (3.9b)
3.1 Thermal Behavior of the Building 15
_
_
_
_
_
_
_
_
1 0
1 0
1 0
0 1
0 1
0 1
_
_
_
_
_
_
_
_
(t)
_
_
_
_
_
_
_
_
1 0
0 1
1 1
1 0
0 1
1 1
_
_
_
_
_
_
_
_
u(t) +
_
_
_
_
_
_
_
_
0
0
1
0
1
0
_
_
_
_
_
_
_
_
(3.9c)
To be able to use this model 14 parameters have to be identied; C
in,air
,
C
in,wall
, C
out,wall
, C
DHW
, K
1c
, K
1r
, K
2
, K
3
, K
4
, K
5
, , ,
1
and
2
. Some of
these parameters can be determined by the buildings design whereas the others
have to be determined by using parameter identication. In this thesis the param-
eters have been identied using gray box modelling and the system identication
toolbox for Matlab. Due to time constraints, the identication part will not be
treated in this thesis but can be studied in for example [15, 8].
In order to discretize the model, the derivatives has been discretized using the
Euler forward method
x(t)
x(t +T
s
) x(t)
T
s
(3.10)
where T
s
is the sample time.
By using the notation
A
B
=
_
_
_
_
_
_
_
_
_
_
(K
2
K
3
K
1c
)T
s
C
in,air
+ 1
K
2
T
s
C
in,air
0
K
2
T
s
C
in,wall
(K
2
K
4
K
1r
)T
s
C
in,wall
+ 1
K
4
T
s
C
in,wall
0
K
4
T
s
C
out,wall
(K
4
K
5
)T
s
C
out,wall
+ 1
K
1c
T
s
C
DHW
K
1r
T
s
C
DHW
0
0 0 0
0 0 0


K
1c
T
s
C
in,air
T
s
C
in,air
0
K
1r
T
s
C
in,wall
(1)T
s
C
in,wall
0
0 0 0
(K
1r
K
1c
)T
s
C
DHW
+ 1 0
T
s
C
DHW
0
T
s

1
+ 1 0
0 0
T
s

2
+ 1
_
_
_
_
_
_
_
_
_
_
, (3.11)
B
2,B
= T
s
_
_
_
_
_
_
_
_
0 0
0 0
0 0
0 0
0
Q
HP

1
Q
HP

2
0
_
_
_
_
_
_
_
_
, (3.12)
16 Modelling
N
B
= T
s
_
_
_
_
_
_
_
_
_
K
3
C
in,air

C
in,air
0 0
K
5
C
out,wall
(1)
C
out,wall
0 0
0 0
0 0
_
_
_
_
_
_
_
_
_
, (3.13)
C
B
=
_
1 0 0 0 0 0
0 0 0 1 0 0
_
, (3.14)
E
1,B
=
_
_
_
_
_
_
_
_
1 0
0 1
1 1
1 0
0 1
1 1
_
_
_
_
_
_
_
_
, (3.15)
E
2,B
=
_
_
_
_
_
_
_
_
1 0
1 0
1 0
0 1
0 1
0 1
_
_
_
_
_
_
_
_
, (3.16)
E
5,B
=
_
_
_
_
_
_
_
_
0
0
1
0
1
0
_
_
_
_
_
_
_
_
, (3.17)
the discrete state space model can be written as
x(k + 1) = A
B
x(k) +B
2,B
(k) +N
B
n(k) (3.18a)
y(k) = C
B
x(k) (3.18b)
E
2,B
(k) E
1,B
u(k) +E
5,B
. (3.18c)
3.2 The Heat Pump 17
3.2 The Heat Pump
The heat pump will be modeled using characteristic curves which are a steady state
description of the heat pump. These curves have been obtained using experimental
data. The curves are on the form
W
HP
(t) = (FT
brine,in
(t)+GT
water,out
(t)+H)u
b,1
(t) = Fz
1
(t)+Gz
2
(t)+Hu
b,1
(t)
(3.19)
and
Q
HP
(t) = (B T
brine,in
(t) +C T
water,out
(t) +D)u
b,1
(t) =
= Bz
1
(t) +Cz
2
(t) +Du
b,1
(t), (3.20)
where T
brine,in
is the temperature of the brine delivered from the bore hole to
the heat pump, T
water,out
is the temperature of the water delivered from the heat
pump to the heating system, Q
HP
is the heat produced by the heat pump, W
HP
is the required input power to the heat pump and B, C, D, F, G, H are constants.
The auxiliary variables z
1
(t) and z
2
(t) are dened using Equation 2.14
z
1
T
brine,in
u
b,1

_

_
z
1
M
1
u
b,1
,
z
1
m
1
u
b,1
,
z
1
T
brine,in
m
1
(1 u
b,1
),
z
1
T
brine,in
M
1
(1 u
b,1
),
(3.21)
z
2
T
water,out
u
b,1

_

_
z
2
M
2
u
b,1
,
z
2
m
2
u
b,1
,
z
2
T
water,out
m
2
(1 u
b,1
),
z
2
T
water,out
M
2
(1 u
b,1
),
(3.22)
which can be written using the matrices
E
1,1
=
_
_
_
_
_
_
_
_
_
_
_
_
M
1
m
1
m
1
M
1
M
2
m
2
m
2
M
2
_
_
_
_
_
_
_
_
_
_
_
_
, (3.23)
18 Modelling
E
3,1
=
_
_
_
_
_
_
_
_
_
_
_
_
1 0
1 0
1 0
1 0
0 1
0 1
0 1
0 1
_
_
_
_
_
_
_
_
_
_
_
_
, (3.24)
E
4,1
=
_
_
_
_
_
_
_
_
_
_
_
_
0 0 0
0 0 0
0 0 1
0 0 1
0 0 0
0 0 0
1 0 0
1 0 0
_
_
_
_
_
_
_
_
_
_
_
_
, (3.25)
E
5,1
=
_
_
_
_
_
_
_
_
_
_
_
_
0
0
m
1
M
1
0
0
m
2
M
2
_
_
_
_
_
_
_
_
_
_
_
_
, (3.26)
as
E
3,1
[z
1
z
2
]
T
E
1,1
u
b,1
+E
4,1
[T
water,out
T
water,in
T
brine,in
]
T
+E
5,1
. (3.27)
By combining Equation 3.19 - 3.20, Q
HP
can be written as
Q
HP
= Bz
1
(t) +
C
G
(W
HP
Fz
1
Hu
b,1
) +Du
b,1
. (3.28)
By using Equation 3.20 in Equations 3.5 and 3.6 we get

1
dQ
emit
(t)
dt
= Q
emit
(t) +Q
HP
(t)
2
(t) = Q
emit
(t) +
Bz
3
(t) +Cz
4
(t) +D
2
(t) (3.29)
and

2
dQ
DHW
(t)
dt
= Q
DHW
(t) +Q
HP
(t)
1
(t) = Q
DHW
(t) +
Bz
5
(t) +Cz
6
(t) +D
1
(t), (3.30)
3.2 The Heat Pump 19
where the auxiliary variables z
3
, . . . , z
6
are dened as
z
3
T
brine,in

2

_

_
z
3
M
1

2
,
z
3
m
1

2
,
z
3
T
brine,in
m
1
(1
2
),
z
3
T
brine,in
M
1
(1
2
).
(3.31)
z
4
T
water,out

2

_

_
z
4
M
2

2
,
z
4
m
2

2
,
z
4
T
water,out
m
2
(1
2
),
z
4
T
water,out
M
2
(1
2
).
(3.32)
z
5
T
brine,in

1

_

_
z
5
M
1

1
,
z
5
m
1

1
,
z
5
T
brine,in
m
1
(1
1
),
z
5
T
brine,in
M
1
(1
1
).
(3.33)
z
6
T
water,out

1

_

_
z
6
M
2

1
,
z
6
m
2

1
,
z
6
T
water,out
m
2
(1
1
),
z
6
T
water,out
M
2
(1
1
),
(3.34)
which can be written using the matrices
E
2,2
=
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
0 M
1
0 m
1
0 m
1
0 M
1
0 M
2
0 m
2
0 m
2
0 M
2
M
1
0
m
1
0
m
1
0
M
1
0
M
2
0
m
2
0
m
2
0
M
2
0
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
, (3.35)
20 Modelling
E
3,2
=
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
1 0 0 0
1 0 0 0
1 0 0 0
1 0 0 0
0 1 0 0
0 1 0 0
0 1 0 0
0 1 0 0
0 0 1 0
0 0 1 0
0 0 1 0
0 0 1 0
0 0 0 1
0 0 0 1
0 0 0 1
0 0 0 1
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
, (3.36)
E
4,2
=
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
0 0 0
0 0 0
0 0 1
0 0 1
0 0 0
0 0 0
1 0 0
1 0 0
0 0 0
0 0 0
0 0 1
0 0 1
0 0 0
0 0 0
1 0 0
1 0 0
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
, (3.37)
3.2 The Heat Pump 21
E
5,2
=
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
0
0
m
1
M
1
0
0
m
2
M
2
0
0
m
1
M
1
0
0
m
2
M
2
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
, (3.38)
as
E
2,2
[
1

2
]
T
+E
3,2
[z
3
z
4
z
5
z
6
]
T
E
4,2
[T
water,out
T
water,in
T
brine,in
]
T
+E
5,2
.
(3.39)
The dynamics of the temperature of the water delivered from the heat pump
to the heating system, T
water,out
, and the temperature of the water returned to
the heat pump from the heating system, T
water,in
, is given by
C
w,out
dT
water,out
(t)
dt
= Q
HP
(t) K
6
(T
water,out
(t) T
water,in
(t)) =
Bz
1
(t) +Cz
2
(t) +Du
b,1
(t) K
6
(T
water,out
(t) T
water,in
(t)) (3.40)
and
C
w,in
dT
water,in
(t)
dt
= (Q
emit
(t) +K
7
(T
water,out
(t) T
water,in
(t)))
2
+(Q
DHW
(t) +K
8
(T
water,out
(t) T
water,in
(t)))
1
=
z
7
(t) +K
7
z
8
(t) z
9
(t) +K
8
z
10
(t), (3.41)
where the auxiliary variables z
7
, . . . , z
10
are dened as
z
7
Q
emit

2

_

_
z
7
M
3

2
,
z
7
m
3

2
,
z
7
Q
emit
m
3
(1
2
),
z
7
Q
emit
M
3
(1
2
).
(3.42)
z
8
(T
water,out
T
water,in
)
2

_

_
z
8
M
4

2
,
z
8
m
4

2
,
z
8
T
water,out
T
water,in
m
4
(1
2
),
z
8
T
water,out
T
water,in
M
4
(1
2
).
(3.43)
22 Modelling
z
9
Q
DHW

1

_

_
z
9
M
5

1
,
z
9
m
5

1
,
z
9
Q
DHW
m
5
(1
1
),
z
9
Q
DHW
M
5
(1
1
).
(3.44)
z
10
(T
water,out
T
water,in
)
1

_

_
z
10
M
4

1
,
z
10
m
4

1
,
z
10
T
water,out
T
water,in
m
4
(1
1
),
z
10
T
water,out
T
water,in
M
4
(1
1
),
(3.45)
which can be written using the matrices
E
2,3
=
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
0 M
3
0 m
3
0 m
3
0 M
3
0 M
4
0 m
4
0 m
4
0 M
4
M
5
0
m
5
0
m
5
0
M
5
0
M
4
0
m
4
0
m
4
0
M
4
0
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
, (3.46)
3.2 The Heat Pump 23
E
3,3
=
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
1 0 0 0
1 0 0 0
1 0 0 0
1 0 0 0
0 1 0 0
0 1 0 0
0 1 0 0
0 1 0 0
0 0 1 0
0 0 1 0
0 0 1 0
0 0 1 0
0 0 0 1
0 0 0 1
0 0 0 1
0 0 0 1
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
, (3.47)
E
4,3
=
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
0 0 0 0
0 0 0 0
1 0 0 0
1 0 0 0
0 0 0 0
0 0 0 0
0 0 1 1
0 0 1 1
0 0 0 0
0 0 0 0
0 1 0 0
0 1 0 0
0 0 0 0
0 0 0 0
0 0 1 1
0 0 1 1
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
, (3.48)
24 Modelling
E
5,3
=
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
0
0
m
3
M
3
0
0
m
4
M
4
0
0
m
5
M
5
0
0
m
4
M
4
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
, (3.49)
as
E
2,3
[
1

2
]
T
+E
3,3
[z
7
z
8
z
9
z
10
]
T
E
4,3
[Q
emit
Q
DHW
T
water,out
T
water,in
]
T
+E
5,3
.
(3.50)
Since the heat pump will be running for relatively small time intervals T
brine,in
(t)
will be regarded as constant i.e.
dT
brine,in
(t)
dt
= 0. (3.51)
The heat pump model can be described in state space form, using x(t) =
[T
water,out
(t), T
water,in
(t) and T
brine,in
(t)]
T
as states.
By using the notation
A
HP
=
_
_
C
w,out
K
6
T
s
C
w,out
K
6
T
s
C
w,out
0
0 1 0
0 0 1
_
_
, (3.52)
B
2,HP
= T
s
_
_
D
C
w,out
0
0
_
_
, (3.53)
B
3,HP1
= T
s
_
_
B
C
w,out
C
C
w,out
0 0
0 0
_
_
, (3.54)
3.3 Combining the Models 25
B
3,HP2
= T
s
_
_
0 0 0 0
1
C
w,in
K
7
C
w,in
1
C
w,in
K
8
C
w,in
0 0 0 0
_
_
, (3.55)
the discrete hybrid state space model can be written on MLD form as
x(k + 1) = A
HP
x(k) +B
2,HP
u
b,1
(k) + [B
3,HP1
B
3,HP2
]z(k), (3.56a)
_
_
E
2,B
0
82
E
2,3
_
_
(k) +
_
_
0
66
E
3,1
0
84
0
162
E
3,3
_
_
z(k)
_
_
E
1,B
E
1,1
0
162
_
_
u(k) +
_
_
0
63
E
4,1
E
4,3
_
_
x(k) +
_
_
E
5,B
E
5,1
E
5,3
_
_
(3.56b)
where z = [z
1
, z
2
, z
7
, z
8
, z
9
, z
10
]
T
3.3 Combining the Models
To get a complete description of the system, Equations 3.18a - 3.18c, 3.29 -
3.30, 3.39 and 3.56a - 3.56b will have to be combined. Using the notation x =
[T
in,air
, T
in,wall
, T
out,wall
, T
DHW
, Q
emit
, Q
DHW
, T
water,out
, T
water,in
, T
brine,in
]
T
,
= [
1
,
2
]
T
, u = [u
b,1
, u
b,2
]
T
and z = [z
1
, . . . , z
10
]
T
the complete state space
system can be written as
x(k + 1) =
_
A
B
0
63
0
36
A
HP
_
x(k) +
_
0
62
B
2,HP
0
31
_
u(k) +
_
_
_
_
0
42
_
0
D

1
D

2
0
_
0
32
_
_
_
_
(k) +
_
_
_
_
0
410
0
22
_
B C 0 0
0 0 B C
_
0
24
B
3,HP1
0
34
B
3,HP2
_
_
_
_
z(k) +
_
N
B
0
32
_
n(k) (3.57a)
y(k) =
_
C
B
0
23
_
x(k) (3.57b)
26 Modelling
_
_
_
_
E
2,B
0
82
E
2,2
E
2,3
_
_
_
_
(k) +
_
_
_
_
0
610
E
3,1
0
88
0
162
E
3,2
0
164
0
166
E
3,3
_
_
_
_
z(k)
_
_
_
_
E
1,B
E
1,1
0
162
0
162
_
_
_
_
u(k) +
_
_
_
_
0
69
0
86
E
4,1
0
166
E
4,2
0
164
E
4,3
0
161
_
_
_
_
x(k) +
_
_
_
_
E
5,B
E
5,1
E
5,2
E
5,3
_
_
_
_
(3.57c)
which can be written as
x(k + 1) = A
k
x(k) +B
1k
u(k) +B
2k
(k) +B
3k
z(k) +N
k
n(k) (3.58a)
y(k) = C
k
x(k) (3.58b)
E
1k
(k) +E
2k
z(k) E
3k
u(k) +E
4k
x(k) +E
5k
(3.58c)
Chapter 4
Implementation
To get a controller which gives as low power consumption as possible and holds
T
in,air
and T
DHW
within certain limits a mathematical optimization problem have
to be formulated. The mathematical formulation will include a cost function J,
which should be minimized with respect to certain constraints.
4.1 Cost Function
The power consumption of the heat pump at time k is given by
W(k) = W
HP
(k) +W
pumps
u
b,1
(k) +W
control
+W
circ.pump
, (4.1)
where W
HP
is the power consumed by the heat pumps compressor, W
pumps
is
the power consumed by the pumps for the uids of the heat pump, W
control
and
W
circ.pump
are known constants related to the power consumption of the heat
pumps controller and circulation pump for the radiator system. By using Equa-
tion 3.19 Equation 4.1 can be written as
W(k) = Fz
1
(k) +Gz
2
(k) +Hu
b,1
(k) +W
pumps
u
b,1
(k) +
W
control
+W
circ.pump
. (4.2)
To minimize the consumed power is therefore equivalent to minimizing Equa-
tion 4.2, since W
control
and W
circ.pump
are constants it is not necessary to include
them in the cost function. A cost function related to the minimization of the
power consumption can therefore be expressed as
J
power
=
H
p

k=1
Fz
1
(k) +Gz
2
(k) +Hu
b,1
(k) +W
pumps
u
b,1
(k), (4.3)
where H
p
is the prediction horizon.
The problem of holding T
in,air
and T
DHW
within certain limits can be solved
in dierent ways. One way is to incorporate the dierence between measured and
27
28 Implementation
reference temperature directly in the cost function, another way is to introduce
a constraint on the dierence between measured and reference temperature. In
this thesis the rst approach has been used. A cost function which minimizes the
deviation of T
in,air
and T
DHW
from the reference values can be expressed as
J
temperature
=
H
p

k=1
|T
in,air
(k) T
in,air,ref
|
2
2
+|T
DHW
(k) T
DHW,ref
|
2
2
. (4.4)
To get a high life expectancy of the compressor the average number of on and
o switchings per hour should not be more than one. This can be achieved by
using the following cost function
J
switch
=
H
p

k=1
|u
b,1
(k) u
b,1
(k + 1)|
2
2
. (4.5)
4.2 Constraints
The constraints of the optimization problem will have to include the state space
description of the system to be able to predict the future states. This can be done
by including Equations 3.58a - 3.58c as constraints. Also to prevent damage to the
compressor it should wait at least 10 minutes to start again once it has stopped,
this can be achieved by including constraints on the form
u
b,1
(k) u
b,1
(k + 1) +u
b,1
(k + 2) 1 (4.6)
and
u
b,1
(k) u
b,1
(k + 1) +u
b,1
(k + 3) 1. (4.7)
Since u
b,1
(k) u
b,1
(k + 1) will be 1 when the heat pump stops u
b,1
(k + 2) and
u
b,1
(k + 3) will have to be 0 to be able to fulll the constraints. Depending on
which sample time the controller uses it may be necessary to include more or less
constraints on the form 4.6.
4.3 Optimization Problem
The optimization problem will include the cost functions given by Equations 4.3 -
4.5 and a cost for the slack variable . These parts will be weighted by the penalties
P
1
, P
2
, P
3
, P
4
and P

to be able to tune the controller. P

is a row vector with


the same number of columns as the number of constraints in equation 3.57c. The
constraints of the optimization problem will be given by Equations 3.58a - 3.58c
and 4.6 - 4.7. The optimization problem will therefore be written as
4.3 Optimization Problem 29
min J =
H
p

k=1
P
1
(Fz
1
(k) +Gz
2
(k) +Hu
b,1
(k) +W
pumps
u
b,1
(k)) +
P
2
|y
1
(k) T
in,air,ref
(k)|
2
2
+P
3
|y
2
(k) T
DHW,ref
(k)|
2
2
+
P
4
|u
b,1
(k) u
b,1
(k 1)|
2
2
+P

(k) (4.8a)
subject to
x(k + 1) = A
k
x(k) +B
1k
u(k) +B
2k
(k) +B
3k
z(k) +N
k
n(k) (4.8b)
y(k) = C
k
x(k) (4.8c)
E
1k
(k) +E
2k
z(k) E
3k
u(k) +E
4k
x(k) +E
5k
+E

(k) (4.8d)
u
b,1
(k) u
b,1
(k + 1) +u
b,1
(k + 2) 1 (4.8e)
u
b,1
(k) u
b,1
(k + 1) +u
b,1
(k + 3) 1 (4.8f)
0 (4.8g)
x '
9
(4.8h)
y '
2
(4.8i)
z '
10
(4.8j)

i
0, 1 , i = 1, 2 (4.8k)
u
b,i
0, 1 , i = 1, 2 (4.8l)
where E

is a matrix that is used to select which constraints in equation 4.8d that


should be soft rather than hard constraints.
Chapter 5
Simulations
The MPC controller derived in chapter 4 has been tested and compared to a con-
ventional heat pump controller using simulations. Dierent simulation scenarios
has been run to ensure that the MPC controller is able to function as intended
all year round. The winter months is the most challenging months for the heat
pump since it has to ensure that both inside air temperature and DHW tempera-
ture are satisfactory. During the summer there is no need for heating so the heat
pump should only produce DHW. A scenario where the MPC controllers reference
tracking is tested is also conducted.
5.1 Simulation Setup
All of the simulations have been made using a Simulink model, the main parts of
the model are:
House: A house dened by its layout and insulation.
Weather: A weather database containing temperatures, solar radiation
and wind conditions for dierent locations around the world.
User: The user determines how much DHW which is consumed and when.
Heating System: The heating system consists of the heat pump and a
DHW tank and radiators for heating.
Controller: Determines which of the controllers that should be used.
A schematic overview of the simulation setup can be seen in Figure 5.1. The
MPC controller has been implemented in Matlab using the software Yalmip [13]
together with an MIQP-solver. A coupling between the Simulink model and an
emulator of a conventional controller has been made to be able to compare the
dierent control strategies.
31
32 Simulations
Weather Controller
Heating
System
House
User
Figure 5.1. Schematic overview of the simulation setup.
Parameter Value
T
s
5 minutes
H
p
5
P
1
Medium
P
2
High
P
3
Medium
P
4
Low
P

Very High
Table 5.1. Settings for the tuning parameters.
5.2 Tuning of the MPC
To get a good performance of the controller several tuning iterations are performed.
To simplify the tuning the dierent parts of the cost function is normalized and
tuning is made by changing the ratios between the dierent penalties in the cost
function. Tuning is also performed by changing the sample time T
s
and the pre-
diction horizon H
p
. The control of the DHW temperature is tuned so that it never
goes below 42

C and stops when it reaches about the same temperature as the
conventional controller. The inside air temperature is tuned to have an oscillation
of approximately 1

C. When a satisfactory performance is achieved the tuning
is complete, the parameters used can be seen in Table 5.1.
5.3 Scenarios
All scenarios use the same building, heating system and user options, this way it
is easy to compare the dierent controllers. The building is a modern building
5.3 Scenarios 33
with good insulation adapted to Swedish conditions, the location chosen for all
simulations is Landvetter, Sweden. The user preferences is setup as a standard
user, the user consumes DHW at certain points in time when for example taking a
shower in the morning or in the evening. The parameter values used for the MPC
are the same as the values received from the tuning (see Table 5.1). The same
parameter values are used in all of the scenarios below.
5.3.1 Scenario 1
This scenario studies the operation during winter conditions and covers the 21:th -
25:th of January which has cold outside temperatures, the outside air temperature
for this interval is shown in Figure 5.2. The reference inside air temperature of
the MPC controller is set to be 21

C. Plots from the simulation are shown in
Figure 5.3 and a comparison of the performance of the dierent controllers can be
seen in Table 5.2. It can be seen that the controllers are quite similar, the biggest
dierence is in the mean and standard deviation of the DHW. The MPC controller
is capable of keeping both the inside air temperature and DHW temperature at
acceptable levels without oscillating too much or turning the compressor on and
o too often.
0 10 20 30 40 50 60 70 80 90 100
16
15
14
13
12
11
10
9
8
7
6
Outside Air Temperature
Time [h]
T
e
m
p
e
r
a
t
u
r
e

[

C
]
Figure 5.2. The outside air temperature for scenario 1.
34 Simulations
0 10 20 30 40 50 60 70 80 90 100
20
20.5
21
21.5
22
22.5
Inside Air Temperature
Time [h]
T
e
m
p
e
r
a
t
u
r
e

[

C
]


0 10 20 30 40 50 60 70 80 90 100
42
44
46
48
50
52
DHW Temperature
Time [h]
T
e
m
p
e
r
a
t
u
r
e

[

C
]


0 10 20 30 40 50 60 70 80 90 100
off
on
off
on
Time [h]
C
o
n
t
r
o
l

s
i
g
n
a
l
s
Control Signals MPC Controller


0 10 20 30 40 50 60 70 80 90 100
off
on
off
on
Time [h]
C
o
n
t
r
o
l

s
i
g
n
a
l
s
Control Signals Conventional Controller


MPC Controller
Conventional Controller
MPC Controller
Conventional Controller
Heat Pump
3Way Valve
Heat Pump
3Way Valve
Figure 5.3. The control performance for scenario 1.
5.3 Scenarios 35
Controller MPC Conventional
Mean of Inside Air Temperature [

C] 21.26 21.38
Standard Deviation of Inside Air Temperature [

C] 0.25 0.28
Mean of DHW Temperature [

C] 45.92 47.03
Standard Deviation of DHW Temperature [

C] 2.48 1.85
On/O Switchings 78 84
Run Time Ratio MPC/Conventional 0.9838
Energy Ratio MPC/Conventional 0.9801
Table 5.2. A comparison between the MPC controller and the conventional controller
for scenario 1.
5.3.2 Scenario 2
This scenario studies the operation during autumn/spring conditions and covers
the 19:th - 23:th of October which has the outside temperature seen in Figure 5.4.
The reference inside air temperature of the MPC controller is set to be 21

C.
Plots from the simulation are shown in Figure 5.5 and a comparison of the per-
formance of the dierent controllers can be seen in Table 5.3. It can be seen that
the performance of the controllers are very similar, however the MPC controller
produces DHW less often.
0 10 20 30 40 50 60 70 80 90 100
1
2
3
4
5
6
7
8
9
Outside Air Temperature
Time [h]
T
e
m
p
e
r
a
t
u
r
e

[

C
]
Figure 5.4. The outside air temperature for scenario 2.
36 Simulations
0 10 20 30 40 50 60 70 80 90 100
20
20.5
21
21.5
22
22.5
Inside Air Temperature
Time [h]
T
e
m
p
e
r
a
t
u
r
e

[

C
]


0 10 20 30 40 50 60 70 80 90 100
42
44
46
48
50
52
DHW Temperature
Time [h]
T
e
m
p
e
r
a
t
u
r
e

[

C
]


0 10 20 30 40 50 60 70 80 90 100
off
on
off
on
Time [h]
C
o
n
t
r
o
l

s
i
g
n
a
l
s
Control Signals MPC Controller


0 10 20 30 40 50 60 70 80 90 100
off
on
off
on
Time [h]
C
o
n
t
r
o
l

s
i
g
n
a
l
s
Control Signals Conventional Controller


MPC Controller
Conventional Controller
MPC Controller
Conventional Controller
Heat Pump
3Way Valve
Heat Pump
3Way Valve
Figure 5.5. The control performance for scenario 2.
5.3 Scenarios 37
Controller MPC Conventional
Mean of Inside Air Temperature [

C] 20.86 21.17
Standard Deviation of Inside Air Temperature [

C] 0.2983 0.2557
Mean of DHW Temperature [

C] 46.09 46.77
Standard Deviation of DHW Temperature [

C] 2.50 1.96
On/O Switchings 50 46
Run Time Ratio MPC/Conventional 0.9752
Energy Ratio MPC/Conventional 0.9711
Table 5.3. A comparison between the MPC controller and the conventional controller
for scenario 2.
5.3.3 Scenario 3
This scenario studies the operation during summer conditions and covers the 19:th
- 21:th of July which has warm outside temperatures, the outside air temperature
for this interval is shown in Figure 5.6. Only two days of simulation is run because
there is no need for heating during summer. This scenario will therefore only be
used to check that the heat pump only produces DHW. The reference inside air
temperature of the MPC controller is set to be 21

C. Plots from the simulation
are shown in Figure 5.7 and a comparison of the performance of the dierent
controllers can be seen in Table 5.4. It can be seen that the controllers can not
keep the inside air at the reference temperature, however this behavior is expected
since the heat pumps have no cooling capability.
0 5 10 15 20 25 30 35 40 45 50
12
13
14
15
16
17
18
19
Outside Air Temperature
Time [h]
T
e
m
p
e
r
a
t
u
r
e

[

C
]
Figure 5.6. The outside air temperature for scenario 3.
38 Simulations
0 5 10 15 20 25 30 35 40 45 50
22
22.5
23
23.5
24
24.5
Inside Air Temperature
Time [h]
T
e
m
p
e
r
a
t
u
r
e

[

C
]


0 5 10 15 20 25 30 35 40 45 50
42
44
46
48
50
52
DHW Temperature
Time [h]
T
e
m
p
e
r
a
t
u
r
e

[

C
]


0 5 10 15 20 25 30 35 40 45 50
off
on
off
on
Time [h]
C
o
n
t
r
o
l

s
i
g
n
a
l
s
Control Signals MPC Controller


0 5 10 15 20 25 30 35 40 45 50
off
on
off
on
Time [h]
C
o
n
t
r
o
l

s
i
g
n
a
l
s
Control Signals Conventional Controller


MPC Controller
Conventional Controller
MPC Controller
Conventional Controller
Heat Pump
3Way Valve
Heat Pump
3Way Valve
Figure 5.7. The control performance for scenario 3.
5.3 Scenarios 39
Controller MPC Conventional
Mean of Inside Air Temperature [

C] 23.09 23.09
Standard Deviation of Inside Air Temperature [

C] 0.3936 0.3849
Mean of DHW Temperature [

C] 45.94 45.99
Standard Deviation of DHW Temperature [

C] 2.200 1.952
On/O Switchings 8 10
Run Time Ratio MPC/Conventional 0.9902
Energy Ratio MPC/Conventional 1.005
Table 5.4. A comparison between the MPC controller and the conventional controller
for scenario 3.
5.3.4 Scenario 4
This scenario studies the MPC controllers reference tracking ability, a simulation
has been run for three days during the 24:th - 27:th of October. The outside
air temperature for this scenario is shown in Figure 5.8. The reference inside air
temperature is given a setback during the night so that it is 21

C from 06:00
- 22:00 and 19.5

C from 22:00 - 6:00. Plots from the simulation are shown in
Figure 5.9 and a comparison of the performance of the dierent controllers can be
seen in Table 5.5. It can be seen that the mean and standard deviation of the inside
air temperature are not as similar as for the previous scenarios when comparing
the two controllers. It is quite natural since the purpose of the MPC controller
is to let the inside air temperature be lower during nights for this simulation. It
can be seen that the MPC controlled heat pump does not produce heat during the
night and therefore consumes 7.5 % less energy than a conventional controller.
0 10 20 30 40 50 60 70 80
2
3
4
5
6
7
8
Outside Air Temperature
Time [h]
T
e
m
p
e
r
a
t
u
r
e

[

C
]
Figure 5.8. The outside air temperature for scenario 4.
40 Simulations
0 10 20 30 40 50 60 70 80
19
20
21
22
Inside Air Temperature
Time [h]
T
e
m
p
e
r
a
t
u
r
e

[

C
]


0 10 20 30 40 50 60 70 80
44
46
48
50
52
DHW Temperature
Time [h]
T
e
m
p
e
r
a
t
u
r
e

[

C
]


0 10 20 30 40 50 60 70 80
off
on
off
on
Time [h]
C
o
n
t
r
o
l

s
i
g
n
a
l
s
Control Signals MPC Controller


0 10 20 30 40 50 60 70 80
off
on
off
on
Time [h]
C
o
n
t
r
o
l

s
i
g
n
a
l
s
Control Signals Conventional Controller


MPC Controller
Conventional Controller
MPC Reference
MPC Controller
Conventional Controller
Heat Pump
3Way Valve
Heat Pump
3Way Valve
Figure 5.9. The control performance for scenario 4.
5.3 Scenarios 41
Controller MPC Conventional
Mean of Inside Air Temperature [

C] 20.50 20.98
Standard Deviation of Inside Air Temperature [

C] 0.4945 0.2486
Mean of DHW Temperature [

C] 45.94 46.89
Standard Deviation of DHW Temperature [

C] 2.356 1.727
On/O Switchings 32 39
Run Time Ratio MPC/Conventional 0.8985
Energy Ratio MPC/Conventional 0.9243
Table 5.5. A comparison between the MPC controller and the conventional controller
for scenario 4.
Chapter 6
Discussion and Conclusion
The goal of this thesis was to develop an MPC controller which is capable of
maintaining the inside air temperature and the DHW temperature within a certain
comfort zone while minimizing the power consumption.
One of the specied goals was that the inside air temperature should not oscil-
late by more than 1.5

C. In Figure 6.1 the inside air temperature for simulation
scenario 1 and 2 is shown together with the reference temperature at 21

C and
boundaries of 21 0.75

C. It can be seen that the goal on the amplitude of the
oscillations is achieved.
The goal that the DHW temperature should not be lower than 42

C is also
achieved. It is illustrated in Figure 6.2, where the DHW temperature for the MPC
controller for scenario 1,2 and 3 is shown.
The MPC controller is designed to minimize the consumed energy with respect
to several constraints. In Tables 5.2 - 5.4 it can be seen that the consumed energy is
about 1-3% lower for the MPC controller compared to the conventional controller.
The most probable reason for this is that the MPC controller does not produce
DHW as often as the conventional controller and hence the standard deviation of
the DHW is higher and the mean DHW temperature lower for the MPC controller.
As shown in simulation scenario 4 the power consumption can be reduced
by introducing a nightly setback in the reference temperature, by reducing the
temperature by 1.5

C during the night the consumed power was reduced by 7.5%
compared to the conventional controller.
One big advantage of the MPC controller is that it is easier for the user to set
a reference temperature. In the conventional controller the inside air temperature
is not set explicitly, instead the user species which temperature the water out of
the heat pump (ow temperature) should have at a certain outside air tempera-
ture. This requires knowledge about the specic house and is usually done by an
installer, also it is generally not a linear coupling between ow temperature and
outside temperature.
43
44 Discussion and Conclusion
0 10 20 30 40 50 60 70 80 90 100
20
20.5
21
21.5
22
Inside Air Temperature Scenario 2
Time [h]
T
e
m
p
e
r
a
t
u
r
e

[

C
]


0 10 20 30 40 50 60 70 80 90 100
20
20.5
21
21.5
22
Inside Air Temperature Scenario 1
Time [h]
T
e
m
p
e
r
a
t
u
r
e

[

C
]


Boundaries
Reference
Boundaries
Reference
Figure 6.1. The inside air temperature for scenario 1 and 2 and upper and lower
boundaries on its oscillations.
45
0 10 20 30 40 50 60 70 80 90 100
40
45
50
55
DHW Temperature Scenario 1
Time [h]
T
e
m
p
e
r
a
t
u
r
e

[

C
]


0 10 20 30 40 50 60 70 80 90 100
40
45
50
55
DHW Temperature Scenario 2
Time [h]
T
e
m
p
e
r
a
t
u
r
e

[

C
]


0 5 10 15 20 25 30 35 40 45 50
40
45
50
55
DHW Temperature Scenario 3
Time [h]
T
e
m
p
e
r
a
t
u
r
e

[

C
]


DHW Temperature
Lower Boundary
DHW Temperature
Lower Boundary
DHW Temperature
Lower Boundary
Figure 6.2. The DHW temperature for scenario 1,2 and 3 and its lower boundary.
Chapter 7
Future work
Future work could include the following:
Development of an MPC controller for an air source heat pump:
By using a model of an air source heat pump instead of a ground source heat
pump the MPC could be adapted to work for air source heat pumps as well.
Further development of the MPC controller:
By including a description of the future outside temperatures from a weather
forecast the controller would be able to take into account changes in the
outside conditions and possibly be able to control the heat pump more eec-
tively. Including a nightly setback in the reference signal for inside air has
shown some promising results, therefore it would be good to conduct further
simulations in this area. A setback in the DHW temperature reference could
also lower the heating costs. If for example the user only consumes DHW
in mornings and evenings during workdays it could be benecial to let the
DHW temperature be lower during the day.
On-line parameter estimation:
To be able to implement the controller in a real installation it would be
good to have some kind of on-line parameter estimation which identies the
parameters of the heating system since they can dier a lot for dierent
buildings.
Explicit MPC:
It would also be useful to investigate the possibility of developing an explicit
MPC since the computing capacity of a heat pump is fairly limited.
47
Bibliography
[1] Daniel Axehill. Integer Quadratic Programming for Control and Communi-
cation. Linkping Studies in Science and Technology. Dissertations. No. 1158,
February 2008.
[2] A. Bemporad, F. Borrelli, and M. Morari. Optimal controllers for hybrid
systems: Stability and piecewise linear explicit form. In Proceedings of the
39th IEEE Conference on Decision and Control, pages 18101815. IEEE, 2000.
[3] A. Bemporad, G. Ferrari-Trecate, and M. Morari. Observability and Con-
trollability of Piecewise Ane and Hybrid Systems. IEEE Transactions on
Automatic Control, 45:18641876, 2000.
[4] Alberto Bemproad and Manfred Morari. Control of systems integrating logic,
dynamics, and constraints. Automatica, 35:407427, 1999.
[5] M. Bianchi, E. Shafai, and H. P. Geering. Comparing new control concepts for
heat pump heating systems on a test bench with the capability of house and
earth probe emulation. In Proceedings of the 8th IEA Heat Pump Conference:
Global Advances in Heat Pump Technology, Applications and Markets, 2005.
[6] M. Garca-Sanz. A reduced model of central heating systems as a realistic
scenario for analyzing control strategies. Applied Mathematical Modelling,
21:535 545, 1997.
[7] Torkel Glad and Lennart Ljung. Reglerteori - Flervariabla och olilnjra
metoder. Studentlitteratur, 2003.
[8] Torkel Glad and Lennart Ljung. Modellbygge och simulering. Studentlitter-
atur, 2004.
[9] Torkel Glad and Lennart Ljung. Reglerteknik - Grundlaggande teori. Stu-
dentlitteratur, 2006.
[10] Gurobi Optimization, Inc. Gurobi optimizer 4.5, 2011.
http://www.gurobi.com/ (accessed 16 May 2011).
[11] W.P.M.H. Heemels, B. De Schutter, and A. Bemporad. Equivalence of hybrid
dynamical models. Automatica, 37:10851091, 2001.
49
50 Bibliography
[12] IBM, Inc. CPLEX Optimizer, 2011. http://www-
01.ibm.com/software/integration/optimization/cplex-optimizer/ (accessed
19 May 2011).
[13] J. Lfberg. Yalmip : A toolbox for modeling and optimization in MATLAB.
In Proceedings of the CACSD Conference, Taipei, Taiwan, 2004.
[14] Z. Liao and A.L. Dexter. A simplied physical model for estimating the
average air temperature in multi-zone heating systems. Building and Envi-
ronment, 39:10131022, 2004.
[15] Lennart Ljung. System identication (2nd ed.): theory for the user. Prentice
Hall PTR, 1999.
[16] Jan Marian Maciejowski. Predictive Control with Constraints. Prentice Hall,
2000.
[17] N/A. Industriell reglerteknik - Kurskompendium. Reglerteknik, Instutitionen
fr systemteknik, Linkpings universitet, 2009.
Upphovsrtt
Detta dokument hlls tillgngligt p Internet eller dess framtida ersttare
under 25 r frn publiceringsdatum under frutsttning att inga extraordinra
omstndigheter uppstr.
Tillgng till dokumentet innebr tillstnd fr var och en att lsa, ladda ner,
skriva ut enstaka kopior fr enskilt bruk och att anvnda det ofrndrat fr icke-
kommersiell forskning och fr undervisning. verfring av upphovsrtten vid en
senare tidpunkt kan inte upphva detta tillstnd. All annan anvndning av doku-
mentet krver upphovsmannens medgivande. Fr att garantera ktheten, skerhe-
ten och tillgngligheten nns det lsningar av teknisk och administrativ art.
Upphovsmannens ideella rtt innefattar rtt att bli nmnd som upphovsman
i den omfattning som god sed krver vid anvndning av dokumentet p ovan be-
skrivna stt samt skydd mot att dokumentet ndras eller presenteras i sdan form
eller i sdant sammanhang som r krnkande fr upphovsmannens litterra eller
konstnrliga anseende eller egenart.
Fr ytterligare information om Linkping University Electronic Press se frla-
gets hemsida http://www.ep.liu.se/
Copyright
The publishers will keep this document online on the Internet or its possi-
ble replacement for a period of 25 years from the date of publication barring
exceptional circumstances.
The online availability of the document implies a permanent permission for
anyone to read, to download, to print out single copies for his/her own use and
to use it unchanged for any non-commercial research and educational purpose.
Subsequent transfers of copyright cannot revoke this permission. All other uses of
the document are conditional on the consent of the copyright owner. The publisher
has taken technical and administrative measures to assure authenticity, security
and accessibility.
According to intellectual property law the author has the right to be mentioned
when his/her work is accessed as described above and to be protected against
infringement.
For additional information about the Linkping University Electronic Press
and its procedures for publication and for assurance of document integrity, please
refer to its www home page: http://www.ep.liu.se/
c _ Markus Sundbrandt

You might also like