60
eeh power systems laboratory

Investigation of the Dynamic Behavior of Heat Pumps for ... · eeh power system s laboratory Chakrit Bhamornsiri Investigation of the Dynamic Behavior of Heat Pumps for the Future

  • Upload
    ngoanh

  • View
    212

  • Download
    0

Embed Size (px)

Citation preview

eeh power systemslaboratory

Chakrit Bhamornsiri

Investigation of the Dynamic Behavior ofHeat Pumps for the Future Integration in

Load Management Strategies

Semester Thesis

EEH � Power Systems LaboratorySwiss Federal Institute of Technology (ETH) Zurich

Expert: Prof. Dr. Göran AnderssonSupervisor: Dipl.-Ing. Stephan Koch

Zurich, March 21, 2011

Abstract

In this semester thesis, the dynamic behavior of heat pumps is investigated withrespect to the suitability for inclusion in load management strategies. First,literature research about the di�erent types of heat pumps, their general char-acteristics and di�erent modeling strategies is done. One building/heat pumpmodel from literature is then selected for further study. With this model, asimulation study of the normal operation of a heat pump (without load man-agement) during the day depending on the season and weather conditions isconducted. Apart from the individual unit behavior, larger groups of heat pumps(several hundred) are simulated in parallel and their aggregated load characteris-tics are elaborated. Based on the results, recommendations are made regardingthe suitability of load management strategies for heat pumps.

i

Kurzfassung

In dieser Semesterarbeit wird das dynamische Verhalten von Wärmepumpen inBezug auf Eignung für Lastmanagement-Strategien untersucht. Zuerst werdenmittels Literaturrecherche die verschiedenen Typen von Wärmepumpen, ihre ge-nerellen Charakteristiken und verschiedene Modellierungsstrategien aufgezeigt.Ein aus der Literatur ausgewähltes Gebäude/Wärmepumpenmodell wird dann fürdie weiteren Untersuchungen verwendet. Mit diesem Modell wird zuerst mittelsSimulationsstudie die Abhängigkeit des normalen Betriebs einer Wärmepumpe(ohne Lastmanagement) während eines Tages von der Jahreszeit und den Wet-terbedingungen analysiert. Danach werden grössere Gruppen von Wärmepumpen(mehrere Hundert) parallel simuliert und ihre aggregierte Lastcharakteristik be-trachtet. Gestützt auf diesen Resultaten wird die Tauglichkeit von Wärmepumpenin Lastmanagement-Strategien bewertet und Vorschläge zu deren Verwendunggegeben.

ii

Contents

List of Acronyms v

List of Symbols vi

List of Figures viii

List of Tables ix

1 Introduction 1

1.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Structure and Approaches . . . . . . . . . . . . . . . . . . . . . 11.3 Principle of Operation . . . . . . . . . . . . . . . . . . . . . . . 21.4 Heat Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

1.4.1 Heat Source: Air . . . . . . . . . . . . . . . . . . . . . 31.4.2 Heat Source: Water . . . . . . . . . . . . . . . . . . . . 41.4.3 Heat Source: Ground . . . . . . . . . . . . . . . . . . . 4

1.5 Control Strategies . . . . . . . . . . . . . . . . . . . . . . . . . 51.5.1 On-O� Control . . . . . . . . . . . . . . . . . . . . . . 51.5.2 Proportional-Integral (PI) Control . . . . . . . . . . . . . 51.5.3 Model Predictive Control (MPC) . . . . . . . . . . . . . 5

2 Models 7

2.1 Building . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.1.1 Supply Water Temperature Tws . . . . . . . . . . . . . . 82.1.2 Return Water Temperature Twr . . . . . . . . . . . . . . 82.1.3 Floor Temperature Tf . . . . . . . . . . . . . . . . . . . 92.1.4 Room Temperature Tr . . . . . . . . . . . . . . . . . . . 92.1.5 State Space Representation . . . . . . . . . . . . . . . . 102.1.6 Parameters . . . . . . . . . . . . . . . . . . . . . . . . . 11

2.2 Ground . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112.2.1 State Space Representation . . . . . . . . . . . . . . . . 12

2.3 Heat Pump . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

iii

CONTENTS iv

3 Single Heat Pump Simulation 14

3.1 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . 143.2 Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163.3 Findings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

4 Heat Pump Aggregation 21

4.1 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . 214.2 Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214.3 Findings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

5 Discussion and Conclusion 24

5.1 Outlook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

A Appendix 26

A.1 Matlab/Simulink Implementation for a Single System . . . . . . 26A.1.1 Model Initialization . . . . . . . . . . . . . . . . . . . . 26A.1.2 Get Heat Demand . . . . . . . . . . . . . . . . . . . . . 33A.1.3 Calculate Heat Pump/Auxiliary Power . . . . . . . . . . 33A.1.4 Simulate Building Dynamics . . . . . . . . . . . . . . . . 36A.1.5 Simulate Ground Dynamics . . . . . . . . . . . . . . . . 37A.1.6 Plot Outputs . . . . . . . . . . . . . . . . . . . . . . . . 37

A.2 Matlab Implementation for System Aggregation . . . . . . . . . 39A.2.1 Create Random Parameter Sets . . . . . . . . . . . . . . 39A.2.2 Main File . . . . . . . . . . . . . . . . . . . . . . . . . . 39A.2.3 Create Systems, Initialization . . . . . . . . . . . . . . . 42A.2.4 Heat Demand . . . . . . . . . . . . . . . . . . . . . . . 45A.2.5 Heat Pump/Auxiliary Power . . . . . . . . . . . . . . . . 45A.2.6 Plot Outputs . . . . . . . . . . . . . . . . . . . . . . . . 46

Bibliography 49

List of Acronyms

COP Coe�cient of performanceJAZ JahresarbeitszahlMPC Model predictive controlPI(D) Proportional-integral(-derivative)

v

List of Symbols

Variable Names

c Speci�c heat capacity [J/kg·K]C Heat capacity [J/K]κ Thermal conductivity [W/K·m]K Thermal conductance [W/K]m Mass [kg]ρ Density [kg/m3]T Temperature [K]V Volume [m3]

Indices

a Ambient airaux Auxiliaryb Buildingc Compressord Disturbancedem Demandf Floorg Groundhp Heat pumpr Room airss Steady statew Heat waterwr Return heat waterws Supply heat water

vi

List of Figures

1.1 Principle of operation of heat pumps [4] . . . . . . . . . . . . . 21.2 Air source [2] . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.3 Water source [2] . . . . . . . . . . . . . . . . . . . . . . . . . . 41.4 Ground source [2] . . . . . . . . . . . . . . . . . . . . . . . . . 41.5 On-o� control . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

2.1 Building model consisting of heat water, �oor and one singleroom (according to [13]) . . . . . . . . . . . . . . . . . . . . . 7

2.2 Ground model (according to [11]) . . . . . . . . . . . . . . . . . 112.3 Heat pump input power . . . . . . . . . . . . . . . . . . . . . . 132.4 Heat pump ouput power . . . . . . . . . . . . . . . . . . . . . . 132.5 Coe�cient of performance . . . . . . . . . . . . . . . . . . . . . 13

3.1 Block diagram of heat pump system implementation . . . . . . . 143.2 Single heat pump simulated for three days, on-o� control, con-

stant room temperature setpoint, building 1 . . . . . . . . . . . 173.3 Single heat pump simulated for three days, on-o� control, night

setback of room temperature, building 1 . . . . . . . . . . . . . 173.4 Single heat pump simulated for one year, on-o� controlled, con-

stant room temperature setpoint, building 1 . . . . . . . . . . . 183.5 Single heat pump simulated for one year, modulated power, con-

stant room temperature setpoint, building 1 . . . . . . . . . . . 183.6 Single heat pump simulated for one year, on-o� controlled, con-

stant room temperature setpoint, building 2 . . . . . . . . . . . 193.7 Single heat pump simulated for one year, modulated power, con-

stant room temperature setpoint, building 2 . . . . . . . . . . . 19

4.1 Aggregation of 1000 heat pump systems, σ = 3.33% . . . . . . 224.2 Aggregation of 1000 heat pump systems, σ = 20% . . . . . . . 224.3 Aggregated input power of 1000 heat pump systems, three days

simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224.4 Aggregated input power of 1000 heat pump systems, one year

simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

vii

LIST OF FIGURES viii

A.1 Single heat pump system implemented in Matlab/Simulink . . . 26A.2 Subsystem get heat demand . . . . . . . . . . . . . . . . . . . 33A.3 Subsystem calculate heat pump / auxiliary power . . . . . . . . 34A.4 Subsystem simulate building dynamics . . . . . . . . . . . . . . 36A.5 Subsystem simulate ground dynamics . . . . . . . . . . . . . . . 37

List of Tables

2.1 Building parameters [1] . . . . . . . . . . . . . . . . . . . . . . 11

3.1 User inputs for the Matlab/Simulink model . . . . . . . . . . . . 153.2 Switches for the Matlab/Simulink model . . . . . . . . . . . . . 153.3 Plots of the Matlab/Simulink model outputs . . . . . . . . . . . 163.4 Simulated cases with the single heat pump system . . . . . . . . 17

Chapter 1

Introduction

The introduction is composed of the motivation of this thesis, its structure andapproaches. Further the operating principle of heat pumps is explained, includingtheir di�erent heat sources and control strategies.

1.1 Motivation

The application of heat pumps for building heating provides an e�cient alter-native to fossil-fuel-based heating systems and electric resistance heating. InSwitzerland, the number of installed heat pump systems is expected to rise con-tinuously in the future.

As the temperature dynamics of the building/heat pump system is relativelyslow, certain �exibility exists in the power consumption of heat pumps. Thismakes it suitable for the inclusion in load management strategies such as theone being developed at the power systems laboratory of the ETH Zurich byKoch et al. [5, 6]. They are aimed at supporting the operation of the electricitysystem from the load side. Such load management methods are often based ona variable energy price together with a local optimization strategy as done byRink et al. [7]. Another possible approach is the aggregation of a high numberof individual units with a direct in�uence of the group by control commands. Inthe latter case, local requirements, e.g. on user comfort, have to be taken intoaccount by the aggregator.

1.2 Structure and Approaches

This thesis is divided into the following �ve chapters.First, the next sections in this chapter explain how heat pumps work, where

they can get their energy from and three possibilities to control their operation.The second chapter presents the models used to simulate the system which

consists of a building, the ground and of course the heat pump. A ground model

1

CHAPTER 1. INTRODUCTION 2

is included because the simulations are performed with a ground source heatpumps.

Chapter 3 deals with a single heat pump system whereas Chapter 4 coversan aggregation of several heat pump systems. A single system is �rst analyzedto study the characteristics of the system. With these �ndings is the aggregatedsystem implemented and simulated for useful cases. Both chapters are structuredinto three sections: �rst is the implementation explained, then are the simulationspresented which are followed by their �ndings.

The concluding chapter discusses the obtained results and suggests furthersteps.

1.3 Principle of Operation

Heat pumps extract low-temperature heat from the ambiance (air, ground, wa-ter) and convert it to a higher temperature e.g. suitable for space heating. Mostheat pumps achieve this by the principle of the vapour compression cycle shown inFigure 1.1. The so called working �uid circulates through the four main compo-nents evaporator, compressor, condenser and expansion valve: In the evaporator,the cold �uid is warmed-up by the heat source and evaporates. Then it is com-pressed and arrives at a higher temperature, this step requires some drive energy,e.g. electricity. The hot vapour enters the condenser where heat is transferredthrough a chiller to e.g. water for �oor heating. Now the �uid passes the ex-pansion valve where the pressure and temperature is lowered before it enters theevaporator again. [4]

Figure 1.1: Principle of operation of heat pumps [4]

There are also heat pumps where the compressor is driven by a combustionengine. Since this type does not need electricity, they are of no interest here inthe focus of load management.

The coe�cient of performance

COP =|∆Q|∆P

(1.1)

expresses the ratio of the change in heat output to work input. It is usually in

CHAPTER 1. INTRODUCTION 3

the range of 4�6, which means the primary energy usage for serving the buildingheat demand is signi�cantly reduced (e.g. resistive heat has a COP = 1).

The maximum theoretical e�ciency for heat pumps

COPmax =Tsupply

Tsubbly − Tsource(1.2)

depends on the temperature di�erence between the heat source and the desiredsupply temperature.

Because temperatures change during the year, the heat pump works at dif-ferent operating points and so at di�erent COPs. The Jahresarbeitszahl

JAZ =

∫ t2t1Q dt∫ t2

t1P dt

(1.3)

takes these changes into account and gives a better picture of the e�ciency ofa heat pump system.

1.4 Heat Sources

The e�ciency of heat pumps depends on the choice of the heat source. For apreferably steady and high COP the source temperature should be stable andclose to the desired setpoint temperature.

One distinguishes between three main types of heat sources: air, water andground. The following subsections show some advantages and disadvantages ofthese.

1.4.1 Heat Source: Air

Figure 1.2: Air source [2]

Ambient air is freely available everywhere.But the heat source temperature changes sig-ni�cantly during the year which requires theheat pump to run at a wide range of operatingpoints. Especially in winter, when the heatingis most needed, the largest temperature di�er-ences between heat source and desired roomtemperature arise. This makes air source heatpumps least e�cient during the year. In ad-dition, frost protection is needed with fallingtemperatures.

CHAPTER 1. INTRODUCTION 4

1.4.2 Heat Source: Water

Figure 1.3: Water source [2]

Water is in principle a good heat source,but care has to be taken to avoid corrosionand fouling. Water source systems can beopen, where the source water itself is pumpedthrough the system, or closed with heat ex-changers and a working �uid.

Water source heat pumps are further sub-divided into the following three types of watersources:

Ground water has a constant temperature of 4�10� [4] but it requires o�cialapproval to draw energy from it.

Sea Water has at a depth of about 25�50m a constant temperature, so it issimilar to ground water [4].

River and lake water temperature is low during winter, naturally because ofbeing at the surface and its �ow. Furthermore, antifreezing measures haveto be taken [4].

1.4.3 Heat Source: Ground

Figure 1.4: Ground source [2]

The ground temperature is from a certaindepth on constant (12� at 100m below thesurface) and then rising with depth (+3� per100m) [2]. A mixture of water and antifreeze�uid, the brine, �ows through vertical or hor-izontal pipes layed in the ground and extractsheat from the soil. Vertical boreholes rangeup to a depth of 300m [2] where the tem-perature is stable at 18�. The major disad-vantage of this construction is the expensivedrilling which requires o�cial approval.

For the further studies is the ground source heat pump chosen, althoughair source heat pumps have a higher share of sales in Switzerland over the lastyears (41.6% versus 54.7% respectively in 2004 [3]). This is most probablydue to the high expenses for installing a ground source heat pump, but thesecosts have decreased by 50% in 24 years (1980�2004) according to the FWS[3]. And ground source heat pumps are much more used than the in fact moree�cient water source heat pump (share of sales 3.2% in 2004). Additionally,the behaviour of the ground temperatures can be observed as a side e�ect ofthe implementation of a ground source heat pump.

CHAPTER 1. INTRODUCTION 5

1.5 Control Strategies

There are di�erent control strategies to operate the heat pump to manage theroom temperature. The next subsections explain shortly three strategies.

1.5.1 On-O� Control

On-o� control is mostly used for thermal household appliances. There are lowerand upper limits for the temperature, i.e. a deadband around the desired tem-perature. If the measured temperature falls below the lower limit the heatingunit switches on and it switches o� again as soon as the upper limit is reached.

Figure 1.5: On-o� control

The room temperature itself isn not measured in most cases for room heatingwith a heat pump. Instead the water return temperature is chosen as variableto control. Also, the inertia of a room temperature is much larger than e.g. ofa fridge.

Most units have only one �on-state� and one �o�-state�. Heat pumps canoperate also at lower power than 100%, i.e. at lower compressor frequencies. Ifthis is taken into account, it is called modulated control.

1.5.2 Proportional-Integral (PI) Control

This control strategy is similar to the on-o� control. Instead of an upper andlower limit, a proportional-integral controller is used to operate the heat pumpin order to keep the setpoint temperature. But the nature of heat pumps posesdi�culties for a conventional PI(D) controller because their operation is notlinear. Seon-Woo et al. [9] tackled this with a fuzzy precompensator.

1.5.3 Model Predictive Control (MPC)

(From [13]): In MPC, the system behaviour is simulated in every time step for acertain time horizon. Based on a su�ciently exact model and the known systemstate, the future control inputs are optimized. The most used optimizationcriterion is to minimize the error between the calculated output signal and thedesired setpoint. Another interesting criterion in the case of space heating is theminimization of energy costs.

CHAPTER 1. INTRODUCTION 6

The �rst calculated input is executed with the system and all further predictedinputs are discarded.

With the new system state, the optimization runs again to �nd the nextinput for the system.

It is obvious that the model is very important in this control strategy. Becauseeach system of heat pump and building is di�erent, it is di�cult to implementsuch a concept in real series production. The identi�cation of individual settingsfor each installation is quite complicated in comparison to other strategies.

Chapter 2

Models

In this chapter, the simulated system is described, which, besides the heat pumpmodel, consists of a building and a ground model to reproduce the dynamics ofa ground source heat pump.

2.1 Building

The Building model is based on the third order model developed by Wimmer[13] and extended by Verhelst et al. [10] with the supply water temperaturestate to determine the COP. It consists of the heat water, the �oor and onesingle room. A more complex model with multiple rooms is not necessary sincethe temperature is controlled at one point only by the heat pump, and �ow ratesare not individually regulated for the seperate rooms.

Figure 2.1: Building model consisting of heat water, �oor and one single room (according to[13])

7

CHAPTER 2. MODELS 8

2.1.1 Supply Water Temperature Tws

It takes some time to reach the static heat power Qhp,s while starting the heatpump from standstill, modeled by a �rst order low pass �lter. The di�erentialequation for the supply water temperature

cw · ρw · Vws︸ ︷︷ ︸Cws

· ddtTws(t) = cw · ρw · Vw︸ ︷︷ ︸

Cw

· [Twr(t)− Tws(t)] + Qhp,s(t) (2.1)

is calculated from the speci�c heat capacity cw and density ρw of the heat water,its volume Vw and return temperature Twr. Vws is the volume of the supply waterwhich is mainly the volume of the compressor.

2.1.2 Return Water Temperature Twr

The energy stored in the returning heat water

Qwr(t) = cw · ρw · Vwr︸ ︷︷ ︸Cwr

·Twr(t) (2.2)

is the product of the heat water parameters and return temperature. The suppliedheat �ow of the heat pump

Qhp(t) = cw · ρw · Vw(t) · [Tws(t)− Twr(t)] (2.3)

minus the heat �ow between the heat water and the �oor

Qwf(t) = κwf ·Aw︸ ︷︷ ︸Kwf

· [Twr(t)− Tf(t)] (2.4)

determine the change of energy stored in the heat water

d

dtQwr(t) = Qhp(t)− Qwf(t) . (2.5)

Above equations (2.2) to (2.4) inserted in (2.5) result in the di�erentialequation for the return water temperature

cw · ρw · Vwr ·d

dtTwr(t) =−

[cw · ρw · Vw(t) + κwf ·Aw

]· Twr(t)

+ κwf ·Aw · Tf(t)+ cw · ρw · Vw(t) · Tws(t) .

(2.6)

CHAPTER 2. MODELS 9

2.1.3 Floor Temperature Tf

The mass of the �oor mf multiplied by its speci�c heat capacity cf and temper-ature Tf result in the energy stored in the �oor

Qf(t) = mf · cf︸ ︷︷ ︸Cf

·Tf(t) . (2.7)

The change of this energy

d

dtQf(t) = Qwf(t) + Qd,f(t)− Qfr(t) (2.8)

is given by the heat �ow Qwf (2.4), auxiliary heat through irradiation Qd,f anddelivered heat �ow to the room

Qfr(t) = κfr ·Af︸ ︷︷ ︸Kfr

· [Tf(t)− Tr(t)] (2.9)

where κfr is the thermal conductivity between �oor and room, Af the �oor'ssurface area and Tr the room temperature.

The di�erential equation for the �oor temperature

mf · cf ·d

dtTf(t) =− [κwf ·Aw + κfr ·Af] · Tf(t)

+ κwf ·Aw · Twr(t)+ κfr ·Af · Tr(t) + Qd,f(t)

(2.10)

is obtained by inserting equations (2.4), (2.7) and (2.9) in (2.8).

2.1.4 Room Temperature Tr

The Room air with temperature Tr is the last heat storage. Its energy

Qr(t) = cr · ρr · Vr︸ ︷︷ ︸Cr

·Tr(t) (2.11)

is obtained from the room parameters cr and ρr, the room's volume Vr andtemperature. The former two parameters are a mean value of the capacity anddensity of the room air and the walls of the building, which are not modelledseparately to keep the system's order low. As a consequence of this, the roomair does not react as fast as in reality, but the mean room air temperature su�ceas a system state for the purpose of this thesis. The change of energy

d

dtQr(t) = Qfr(t) + Qd,r(t)− Qra (2.12)

CHAPTER 2. MODELS 10

originates from the heat delivered from the �oor Qfr, solar irradiation and userbehaviour Qd,r and the loss through the building envelope

Qra = κra ·Ar︸ ︷︷ ︸Kra

· [Tr(t)− Ta(t)] . (2.13)

The latter one is calculated from the thermal conductivity between �oor andambient air κra, the building surface Ar and the temperature di�erence.

Equations (2.9) and (2.11)�(2.13) give the di�erential equation for the roomtemperature

cr · ρr · Vr ·d

dtTr(t) =− [κfr ·Af + κra ·Ar] · Tr(t)

+ κfr ·Af · Tf(t)+ κra ·Ar · Ta(t) + Qd,r(t) .

(2.14)

2.1.5 State Space Representation

The fourth order building model derived in previous subsections is expressed instate space representation

xb(t) = Ab · xb(t) +Bb · ub(t)yb(t) = Cb · xb(t) +Db · ub(t)

(2.15)

with the state vector (building temperatures)

xb(t) = Tb(t) =

Tws(t)Twr(t)Tf(t)Tr(t)

, (2.16)

input vector

ub(t) =

Ta(t)Qhp(t)Qaux(t)

, (2.17)

state matrix

Ab =

− Cw

Cws

Cw

Cws0 0

Cw

Cwr−Cw+Kwf

Cwr

Kwf

Cwr0

0 Kwf

Cf−Kwf+Kfr

Cf

Kfr

Cf

0 0 Kfr

Cr−Kfr+Kra

Cr

(2.18)

and input matrix

Bb =

0 1

Cws0

0 0 1Cwr

0 0 0Kra

Cr0 0

. (2.19)

CHAPTER 2. MODELS 11

2.1.6 Parameters

The Parameters for the building model are listed in Table 2.1. The parameterset �Building 1� is identi�ed with a real reference system by [1] and �Building 2�models a slower �oor heating as proposed by the University of Applied SciencesBasel (FHBB) [1].

Parameter Building 1 Building 2

Kfr 6155 W/K 560 W/KKra 260 W/K 125 W/KKwf 1160 W/K 3060 W/KCf 45500 kJ/K 42000 kJ/KCr 224640 kJ/K 126000 kJ/KCw 5356.8 kJ/K 6277.5 kJ/KCwr 5156.229 kJ/K 6181.071 kJ/KCws 200.571 kJ/K 96.429 kJ/K

Table 2.1: Building parameters [1]: �Building 1� identi�ed with a real reference system, �Build-ing 2� by the University of Applied Sciences Basel (FHBB)

2.2 Ground

Figure 2.2: Ground model (according to [11])

As the heat pump draws energy from the ground, the temperature aroundthe borehole will fall. If not enough heat from the surrounding ground can �owto the borehole, it could cool down. The ground model is adopted from [12].

Around the borehole are 12 concentric circles at which the ground temper-atures are modeled. At the most outer circle, the ground temperature is keptconstant.

CHAPTER 2. MODELS 12

2.2.1 State Space Representation

This results in a system of linear equations, which is like the building equationsexpressed in state space representation

xg(t) = Ag · xg(t) +Bg · ug(t)yg(t) = Cg · xg(t) +Dg · ug(t) .

(2.20)

The form of the state matrix

Ag =

∗ ∗ 0 0 0 0 0 0 0 0 0 0∗ ∗ ∗ 0 0 0 0 0 0 0 0 00 ∗ ∗ ∗ 0 0 0 0 0 0 0 0

. . .

0 0 0 0 0 0 0 0 ∗ ∗ ∗ 00 0 0 0 0 0 0 0 0 ∗ ∗ ∗0 0 0 0 0 0 0 0 0 0 ∗ ∗

[12×12]

(2.21)

arises because every state depends only on its neighbouring states. The inputsa�ect only the �rst state, through the energy drawn from the heat pump, andthe last one, at the constant ground temperature. This results in an input matrix

Bg =

∗ 00 0...

...0 00 ∗

[12×2]

(2.22)

with non-zero elements only in the upper left and the lower right corner.

2.3 Heat Pump

Exact internal processes in the heat pumps are not of interest in this thesis, thatis why the heat pump itself is modeled by two lookup tables [10] only, one for thepower input Php and the second one for the respective power output Qhp. Bothtables are three dimensional: (1) the return water temperature, (2) the supplywater temperature and (3) the frequency of the compressor. Values between thebase points are interpolated linearily.

Figure 2.3 shows the implemented lookup table for the input power. On thex-axes is the evaporator (ground) water temperature, the y-axes is the con-denser (supply) water temperature and the z-axes shows the required inputpower. These points are saved for di�erent compressor frequencies, here be-tween 30Hz (Figure 2.3(a)) and 75Hz (Figure 2.3(b)). The same is done forthe ouput power in Figure 2.4. In Figure 2.5 is the resulting COP for the di�erentoperating points drawn.

CHAPTER 2. MODELS 13

(a) operated at 30Hz (b) operated at 75Hz

Figure 2.3: Heat pump input power

(a) operated at 30Hz (b) operated at 75Hz

Figure 2.4: Heat pump ouput power

(a) operated at 30Hz (b) operated at 75Hz

Figure 2.5: Coe�cient of performance

Chapter 3

Single Heat Pump

Simulation

To study the characteristics of the system, simulations with one single heatpump and building are made. Parameters such as ambient temperature, roomtemperature setpoint and the building are varied to observe their e�ects on thesystem behaviour.

3.1 Implementation

The �rst implementation is for a single heat pump system and realized in Mat-lab/Simulink because it is easily seen through the graphical interface how theindividual models are connected. The block diagram representation is shown inFigure 3.1.

Figure 3.1: Block diagram of heat pump system implementation

In the �rst block is the heat demand of the building calculated based onthe ambient temperature and the room temperature setpoint. This is done by asteady state calculation of the building equations (2.15):

0!

= Ab · xss +Bb · uss = Ab ·

Tws,ssTwr,ssTf,ssTr,setp

+Bb ·

Ta(t)Qdem

0

. (3.1)

14

CHAPTER 3. SINGLE HEAT PUMP SIMULATION 15

The element Qaux in uss is chosen zero for the steady state calculation. Qhp inuss stands for the heat demand of the building, called Qdem, since there are nolimits for it considered yet.

The second block of the diagram in Figure 3.1 represents the heat pump.The steady state temperatures for the supply and return heat water determinethe heat pump operation point out of the lookup table as explained in Section2.3. If the resulting heat pump output power Qhp is not su�cient to cover thesteady state heat demand of the building Qdem, the remaining power is coveredthrough auxiliary power Qaux.

The energy delivered to the building, heat pump and auxiliary power, togetherwith recorded real hourly weather information are used to simulate the buildingdynamics.

The di�erence between heat pump output and input power (Qhp − Php),i.e. the drawn energy from the ground, determine the ground dynamics aroundthe borehole.

The resulting states of the last two blocks in Figure 3.1 are then looped backto the heat pump block, where their values are used within the next time step.

Several user inputs (Table 3.1) and switches (Table 3.2) allow comfortablesimulation of di�erent scenarios to show the e�ects of the parameters, as donein Section 3.2.

User input

Constant ambient temperatureConstant room temperature setpointDay's room temperature setpointNight's room temperature setpointConstant ground temperature (at the most outer ground state)Deadband on return water temperature

Table 3.1: User inputs for the Matlab/Simulink model

Switch Value 1 Value 2

Building Building 1 Building 2Controller On-o� ModulatedAmbient temperature Constant Real hourly curveRoom setpoint Constant Night setback

Table 3.2: Switches for the Matlab/Simulink model

The outputs of the simulation are sent to Matlab which plots them in threeseparate graphs as listed in Table 3.3.

The detailed Matlab/Simulink model is enclosed in the appendix, SectionA.1.

CHAPTER 3. SINGLE HEAT PUMP SIMULATION 16

Graph name Plotted variables

Building and ambient temperatures The four building states (Tws, Twr, Tf,Tr), the room temperature setpoint(Tr,setp) and the ambient temperature(Ta)

Ground temperatures The twelve temperatures of the groundmodel

Power consumption The output (Qhp) and input (Php)power of the heat pump, the auxiliarypower (Qaux) and the heat demand ofthe building (Qdem)

Table 3.3: Plots of the Matlab/Simulink model outputs

3.2 Simulation

The Matlab/Simulink model developed in the previous section is used to studythe behaviour of one heat pump/building system.

To get a �rst impression of the heat pump operation, the system is simulatedfor three days in early January, i.e. ambient temperature around 0�. The non-modulated on-o� controller manages to keep the room temperature at the desired20�, constant during day and night. The output is shown in Figure 3.2.

Previous settings proposed no problems for the controller. The room temper-ature setpoint is now varied between 20� during the day and 18� at night asseen in Figure 3.3. All other settings are the same as in the previous simulation,Figure 3.2.

Seasonality e�ects of the ambient temperature are seen in Figure 3.4, wherethe system is simulated for one year with real weather information and non-modulated on-o� control. The desired room temperature is set to 20�, constantat day and night.

Figure 3.5 shows the in�uence of a di�erent control strategy, the modulatedcontrol. The other parameters are the same as in Figure 3.4.

Both yearly scenarios are also simulated with the second building parameterset, the one with the slower �oor heating. On-o� control produces Figure 3.6and modulated control Figure 3.7.

Table 3.4 gives an overview about the just described simulated cases.

CHAPTER 3. SINGLE HEAT PUMP SIMULATION 17

Figure Building Controller Room temp. setpoint Simulation period

3.2 1 On-o� Constant at 20� 3 days3.3 1 On-o� Night setback 20/18� 3 days3.4 1 On-o� Constant at 20� 1 year3.5 1 Modulated Constant at 20� 1 year3.6 2 On-o� Constant at 20� 1 year3.7 2 Modulated Constant at 20� 1 year

Table 3.4: Simulated cases with the single heat pump system

Figure 3.2: Single heat pump simulated for three days, on-o� control, constant room temper-ature setpoint, building 1

Figure 3.3: Single heat pump simulated for three days, on-o� control, night setback of roomtemperature, building 1

CHAPTER 3. SINGLE HEAT PUMP SIMULATION 18

Figure 3.4: Single heat pump simulated for one year, on-o� controlled, constant room tem-perature setpoint, building 1

Figure 3.5: Single heat pump simulated for one year, modulated power, constant room tem-perature setpoint, building 1

CHAPTER 3. SINGLE HEAT PUMP SIMULATION 19

Figure 3.6: Single heat pump simulated for one year, on-o� controlled, constant room tem-perature setpoint, building 2

Figure 3.7: Single heat pump simulated for one year, modulated power, constant room tem-perature setpoint, building 2

CHAPTER 3. SINGLE HEAT PUMP SIMULATION 20

3.3 Findings

Figure 3.2: In the building and ambient temperature graph is seen that the goal,to keep the room temperature at its setpoint value, is ful�lled. All graphs showthe typical behaviour of the on-o� control strategy with cycling times of about2.5 hours in this case.

Figure 3.3: The on-o� control strategy does not manage to follow a nightsetback of the room temperature setpoint. It results in long on-times at thebeginning of each day.

Figure 3.4: The heat demand curve in the power consumption graph is inits shape practically the opposite of the ambient temperature curve, as moreheat is needed during cold days and vice versa. For the same reason, the groundtemperatures follow the ambient temperature curve. This shows also that theground model cannot be neglected when the examined timeframe exceeds somedays. The heat pump has to operate at di�erent operating points as the tem-perature di�erence changes between winter and summer, in this case for about8�.

Figure 3.5: With this controller the room temperature is kept constant butjust below the setpoint. Because only the needed energy is supplied and thereis no overheating at all, the heat pump is constantly turned on during winter.

Figure 3.6 and 3.7: The building and ambient temperature graph shows thatthe �oor temperature reacts much faster than in building 1, but the room is notheaten up as fast. The system is not able to keep the room temperature at 20�with modulated control in Figure 3.7.

The best results are achieved with the non-modulated on-o� control. Thesystem is able to act against varying ambient temperatures and keeps the roomtemperature at the desired value.

Chapter 4

Heat Pump Aggregation

In this chapter is the aggregation of several heat pump systems examined tostudy their e�ect in the network.

4.1 Implementation

The simulation of several hundred heat pumps in parallel is written in plainMatlab because it is much faster than Matlab/Simulink.

Normally distributed building and heat pump parameter variation is used toget the di�erent systems. The initial conditions of each system are also randomwith a normal distribution around their steady state values.

The systems are simulated in parallel at each time step. This allows aninteraction with a superior load management controller, but none is implementedyet for this thesis. An interaction between the boreholes in the ground is notconsidered either.

Complete insight is given by the source code in Section A.2 within the ap-pendix.

4.2 Simulation

All aggregated simulations are done with the building 1 parameter set as basis.The non-modulated on-o� control strategy is chosen with a constant room tem-perature setpoint at 20�. Ambient temperatures follow the recorded real hourlyinformation and the temperature of the most outer ground state is kept at 10�.

The �rst simulation, displayed in Figure 4.1, is done with a standard deviationof 3.33% of the mean value for the system parameters. This distribution resultsin system parameter variations within±10% of the ones used in the single systemsimulations with a 99.7% certainty.

For a more realistic diversity of the systems, further simulations are donewith a standard deviation of 20% of the mean value for the system parameters.This means that the parameters vary with 99.7% certainty within ±60% of the

21

CHAPTER 4. HEAT PUMP AGGREGATION 22

base parameter set. This gives the power consumption pro�le shown in Figure4.2.

The wheather's in�uence on the power demand of the heat pump cluster isshown by a three day simulation displayed in Figure 4.3.

Figure 4.4 visualizes the power consumption of the 1000 heat pump systemsover one whole year.

Figure 4.1: Aggregation of 1000 heat pump systems, σ = 3.33%

Figure 4.2: Aggregation of 1000 heat pump systems, σ = 20%

Figure 4.3: Aggregated input power of 1000 heat pump systems, three days simulation

CHAPTER 4. HEAT PUMP AGGREGATION 23

Figure 4.4: Aggregated input power of 1000 heat pump systems, one year simulation

4.3 Findings

In the simulation outputs in Figures 4.1 and 4.2, only the power consumptiongraph is shown. An additional line is added to the graph, drawing the aggregatedheat pump input power. The individual building and ground temperatures donot reveal any more information than in Chapter 3 about the simulations withsingle heat pump systems.

Figure 4.1 shows negative synchronizing e�ects. The aggregated input powerbegins to oscillate after relatively small heat demand changes. This happensbecause the systems are too similar and they switch all at nearly the same time.

This e�ect is eliminated with the wider distribution in Figure 4.2. The variatyis also clearly seen by the expanded band of heat demand curves.

Figure 4.3 depicts the importance of an accurate temperature forecast. Thedrop of 6� leads to an increased power demand of 600 kW within 8 hours,consumed only by the heat pumps beside other demand changes.

Chapter 5

Discussion and Conclusion

The single system simulations in Chapter 3 showed that the ground model cannotbe left aside, the ground temperature changes signi�cantly due to the heat pumpoperation. For the heat pump itself, it is su�cient to model it through a lookuptable with some base points and interpolate the operating points in between. Butmost important is an accurate building model to produce meaningful simulationresults. With the models and controller implemented in this thesis, analyses witha constant room temperature setpoint are possible. Changes in this setpointduring the simulation, e.g. night setback of the room temperature, were notmeaningful with the implemented system. But still, this showed how big theinertia of the system is, which allows the heat pump to act �exible and reacte.g. on control commands from outside without a�ecting the user comfort.

Chapter 4 demonstrated that an aggregation of heat pumps can have in�u-ence on the network. Their power demand is not negligible and can change a lotdepending on weather. In addition, if the heat pump cluster is too homogenous,negative synchronizing e�ects appear and the demand oscillates.

These �ndings makes it reasonable to consider an integration of heat pumpsinto load management strategies.

5.1 Outlook

The system implemented in this thesis is a good basis for further research. Butthere are a lot of extensions conceivable:

� Program other control strategies.

� Improve the building model (with separate wall modelling).

� With the two previous items, studies with night setback of the room tem-perature to optimize the heating with heat pumps and their energy de-mand.

24

CHAPTER 5. DISCUSSION AND CONCLUSION 25

� Include energy prices and subsequently price based control for an econom-ically optimal operation.

� Overlay a superior controller to the cluster for actual load managementactivities such as load curve shaping and price incentive operation.

� Use the heat pumps also for cooling.

� Provide more building and heat pump parameter sets for a higher and realdiversity in the aggregation.

� Consider ground interaction between the single systems (requiring to placethem on a coordinate system).

� Include disturbances in the building model, e.g. solar/light radiation, ran-dom window and door openings.

Appendix A

Appendix

A.1 Matlab/Simulink Implementation for a SingleSystem

Figure A.1: Single heat pump system implemented in Matlab/Simulink

A.1.1 Model Initialization

1 % Returns a s t r u c t c o n t a i n i n g s t a t e space mat r i c e s , pa ramete r s and ←↩i n i t i a l v a l u e s

f u n c t i o n s = heat_pump_init ( )

4 % s t r u c t h o l d i n g v a r i a b l e s used i n s imu l i n k models = struct ;

26

APPENDIX A. APPENDIX 27

7 % step s i z e ( use f i x e d s t ep s i z e s on l y ) = 1 means hou r l y s imu l a t i o nstep = str2double ( get_param ( ' heat_pump ' , ' F ixedStep ' ) ) ;

10 % bu i l d i n gi f ( str2double ( get_param ( ' heat_pump/ b u i l d i n g sw i t c h ' , ' sw ' ) ) )

building = 'Wimmer1 ' ;13 e l s e

building = 'Wimmer2 ' ;end

16 % number o f s t a t e s i n b u i l d i n gnxb = 4 ;% con t i nuou s b u i l d i n g model

19 [ s . Abc , s . Bbc , s . Qaux_max , s . facHP , nb ] = get_sys_building ( building , 'h ' )←↩;

s . Abc = s . Abc .* step ;s . Bbc = s . Bbc .* step ;

22 sysbc = ss ( s . Abc , s . Bbc , eye ( nxb ) , z e r o s ( nxb , s i z e ( s . Bbc , 2 ) ) ) ;% d i s c r e t e b u i l d i n g modelsysbd = c2d ( sysbc , 1 ) ;

25 [ s . Abd , s . Bbd ] = ssdata ( sysbd ) ;

% ground28 % number o f s t a t e s i n the ground

nxg = 12 ;% con t i nuou s ground model

31 [ s . Agc , s . Bgc ] = get_sys_ground ( nxg , 'h ' , 'W' ) ;s . Agc = s . Agc .* step ;s . Bgc = s . Bgc .* step ;

34 s . Bgc ( 1 , 1 ) = s . Bgc ( 1 , 1 ) /nb ; % Qground = u4sysgc = ss ( s . Agc , s . Bgc , eye ( nxg ) , z e r o s ( nxg , s i z e ( s . Bgc , 2 ) ) ) ;% d i s c r e t e ground model

37 sysgd = c2d ( sysgc , 1 ) ;[ s . Agd , s . Bgd ] = ssdata ( sysgd ) ;

40 % load ambient t empe ra tu r e p r o f i l e ( h ou r l y data )s . Ta = load ( 'Ukkel_Tamb . t x t ' ) ;i f ( str2double ( get_param ( ' heat_pump/Ta sw i t ch ' , ' sw ' ) ) )

43 % cons t an t ambient t empe ra tu r eTa_init = str2double ( get_param ( ' heat_pump/ con s t an t ambient ←↩

t empe ra tu r e ' , ' Value ' ) ) ;e l s e

46 % ambient t empe ra tu r e p r o f i l eTa_init = s . Ta ( 1 , 2 ) ;

end49

% room s e t p o i n t t empe ra tu r e p r o f i l es . Tr_setp = struct ( ' t ime ' , [ ] , ' s i g n a l s ' , struct ( ' v a l u e s ' , [ 18* ones ( 7 , 1 )←↩

; 20* ones (16 ,1 ) ;18* ones ( 2 , 1 ) ] ) ) ;52 i f ( str2double ( get_param ( ' heat_pump/Tr_setp sw i t c h ' , ' sw ' ) ) )

% con s t an t room tempe ra tu r eTr_setp = str2double ( get_param ( ' heat_pump/ con s t an t room ←↩

t empe ra tu r e ' , ' Value ' ) ) ;55 e l s e

% v a r i a b l e room tempe ra tu r eTr_setp = s . Tr_setp . signals . values (1 ) ;

58 end

% con s t a n t s :61 % und i s t u r b e d ground tempe ra tu r e

s . Tsoil = str2double ( get_param ( ' heat_pump/ground tempe ra tu r e ' , ' Value←↩' ) ) ;

APPENDIX A. APPENDIX 28

64 % i n i t i a l c o n d i t i o ns . Tbinit = get_init_state_building ( Tr_setp , Ta_init , building ) ;s . HP_status = 0 ;

67 s . LP_status = 0 ;

% Ca l c u l a t e s the s t e ady s t a t e o f a b u i l d i n g wi th i ndoo r t empe ra tu r e ←↩Tr and outdoor t empe ra tu r e Ta . Ac co r d i n g l y the s t e ady s t a t e heat←↩i n pu t and powers a r e c a l c u l a t e d .

2 f u n c t i o n [ TSS , USS ] = get_init_state_building ( Tr , Ta , building )

[ A , B ] = get_sys_building ( building , ' s ' ) ;5

% Steady s t a t e c o n d i t i o n : dot_T = 0% or : ATss + BUss = 0

8 % known : Tr , Ta% 5 unknowns : Ts1 , Ts2 , Tf , Qhp , Qaux% 4 equa t i o n s −−> 1 DOF: Qhp + Qaux !

11 % (That i s why o p t im i z a t i o n p o t e n t i a l )

% Choose Qaux = 014 % Co e f f i c i e n t s o f unknowns :

Amat = ze r o s (4 , 4 ) ;17 Bmat = ze r o s (4 , 1 ) ;

Amat ( : , 1 : 3 ) = A ( : , 1 : 3 ) ;20 Amat ( : , 4 ) = B ( : , 2 ) ;

Bmat ( : ) = −A ( : , 4 ) *Tr−B ( : , 1 ) *Ta ;

23 SS = Amat\Bmat ;TSS = [ SS ( 1 : 3 , 1 ) ; Tr ] ;USS = [ Ta ; SS ( 4 , 1 ) ; 0 ] ;

% Retu rns the s t a t e space r e p r e s e n t a t i o n o f the b u i l d i n g2 f u n c t i o n [ A , B , QDOT , facHP , nb ] = get_sys_building ( building , time_unit )

[ CWs , CWr , mBcB , CG , mWcW , kWB , kB , kG , QDOT , facHP , nb ] = get_param_building (←↩building ) ;

5

% System equa t i o n sA = ze r o s (4 , 4 ) ;

8 B = ze r o s (4 , 3 ) ;

% Tws11 A ( 1 , 1 ) = −mWcW / CWs ; % 1/ s

A ( 1 , 2 ) = mWcW / CWs ; % 1/ s

14 % TwrA ( 2 , 1 ) = mWcW/ CWr ; % 1/ sA ( 2 , 2 ) = (−mWcW − kWB ) / CWr ; % 1/ s

17 A ( 2 , 3 ) = kWB / CWr ; % 1/ s

% Tf20 A ( 3 , 1 ) = 0 ; % 1/ s

A ( 3 , 2 ) = kWB / mBcB ; % 1/ sA ( 3 , 3 ) = − ( kWB + kB ) / mBcB ; % 1/ s

23 A ( 3 , 4 ) = kB / mBcB ; % 1/ s

% Tr

APPENDIX A. APPENDIX 29

26 A ( 4 , 3 ) = kB / CG ; % 1/ sA ( 4 , 4 ) = − ( kB + kG ) / CG ; % 1/ s

29 B ( 1 , 2 ) = 1/CWs ; % K/J < QhpB ( 2 , 3 ) = 1/CWr ; % K/J < QauxB ( 4 , 1 ) = kG/CG ; % 1/ s < Tamb

32

i f s t rcmp ( time_unit , 'h ' )A = A .*3600 ;

35 B = B .*3600 ;end

% Retu rns the pa ramete r s o f the s e l e c t e d b u i l d i n gf u n c t i o n [ CWs , CWr , mBcB , CG , mWcW , kWB , kB , kG , QDOT , facHP , nb ] = ←↩

get_param_building ( building )3

switch building

case 'Wimmer1 '

6 rhoW = 1000 ; % m³/kgcpW = 4185 ; % J/kgKVH = 1 . 2 8 ; % m³

9 CW = rhoW*cpW*VH ; % J/KkWB = 1160 ; % W/KmBcB = 455e5 ; % J/K

12 kB = 6155 ; % W/KkG = 260 ; % W/KtauG = 240*3600; % s

15 CG = tauG*kG ; % J/K

case 'Wimmer2 '

18 rhoW = 1000 ; % m³/kgcpW = 4185 ; % J/kgKVH = 1 . 5 0 ; % m³

21 CW = rhoW*cpW*VH ; % J/KkWB = 3060 ; % W/KmBcB = 420e5 ; % J/K

24 kB = 560 ; % W/KkG = 125 ; % W/KtauG = 280*3600; % s

27 CG = tauG*kG ; % J/Kend

30 % Des ign hyd r on i c system , r u l e s Karlsson_et_Fahlen_2008DOT = −10; % K de s i g n outdoor t empe ra tu r eTsDOT = 35 ; % K de s i g n supp l y t empe ra tu r e

33 TrDOT = 28 ; % K de s i g n r e t u r n t empe ra tu r eQDOT = kG * ( 20 . 0 − DOT ) ; % W de s i g n heat demandmWcW = QDOT /( TsDOT − TrDOT ) ; % W/K the rma l c a p a c i t y f l ow

36 tauHP = 3*60 ; % s t ime con s t an t heat pumpCWs = tauHP*mWcW ; % J/K the rma l c a p a c i t y s upp l y waterCWr = CW − CWs ; % J/K the rma l c a p a c i t y r e t u r n water

39

% S i z e heat pump systembetaHP = 0 . 8 ;

42 QDaikin = Q_range_HP ( TsDOT , 5 ) ;facHP = ( betaHP * QDOT ) /QDaikin ( end ) ;nb = betaHP*QDOT /5000 ;

1 % Returns the the rma l power range o f a modu la t ing b r i n e−to−water ←↩heat pump at g i v en sou r c e and supp l y t empe ra tu r e

APPENDIX A. APPENDIX 30

f u n c t i o n Qvec = Q_range_HP ( TLWC , TLWE )

4 TLWC_vec = get_HP_data_ext ( 'TLWC_range ' ) ;TLWE_vec = get_HP_data_ext ( 'TLWE_range ' ) ;Freq_vec = get_HP_data_ext ( ' Freq_range ' ) ;

7 Q3D = get_HP_data_ext ( 'Q3D ' ) ;

TLWE = min ( TLWE , TLWE_vec ( end ) ) ; % i f TLWE > TLWE,max : COP = COPmax10 TLWC = max( TLWC , TLWC_vec (1 ) ) ; % i f TLWC < TLWC, min : COP = COPmax

Qvec = ze r o s ( l e n g t h ( Freq_vec ) , 1 ) ;

13 i f and ( TLWE>=TLWE_vec (1 ) , TLWC<=TLWC_vec ( end ) ) % TLWE,TWLC i n rangeQvec ( : , 1 ) = interp3 ( TLWE_vec , TLWC_vec , Freq_vec , Q3D , TLWE , TLWC ,←↩

Freq_vec ( 1 : end ) ) ;e l s e % TLWE,TWLC out o f range

16 Qvec = [ ] ;end

1 % Returns the pa ramete r s o f a modu la t ing b r i n e−to−water heat pump% TLWC : Temperature l e a v i n g water condense r [C ]% TLWE : Temperature l e a v i n g water e v apo r a t o r [C ]

4 % Freq_vec : Compressor f r e qu en c y [ Hz ]% Q3D : Thermal power at condense r s i d e [W]% P3D : E l e c t r i c power Compressor [W]

7 f u n c t i o n [ HP_data ] = get_HP_data_ext ( var )

switch var

10 case 'TLWE_range '

HP_data = [−10 −5 0 5 7 12 15 18 21 2 5 ] ;case 'TLWC_range '

13 HP_data = [30 35 40 45 50 55 60 65 7 0 ] ;case ' Freq_range '

HP_data = [30 45 58 7 5 ] ;16 case 'Q3D '

% f = 30 HzHP_data ( : , : , 1 ) = 1 .0 e+03 * [ 1 . 0 565 1 .4443 1 .7706 2 .0700 ←↩

2 .1900 2 .5100 2 .7200 2 .9300 3 .1600 3 .470019 0 .9760 1 .3691 1 .7045 2 .0100 2 .1300 2 .4400 2 .6400 2 .8500←↩

3 .0700 3 .37000 .3522 1 .0899 1 .5885 1 .9400 2 .0600 2 .3600 2 .5600 2 .7600←↩

2 .9700 3 .27001 .4697 1 .4939 1 .6382 1 .8700 1 .9800 2 .2800 2 .4700 2 .6700←↩

2 .8700 3 .160022 1 .3446 1 .3897 1 .5502 1 .7900 1 .9000 2 .1900 2 .3700 2 .5700←↩

2 .7700 3 .05001 .4248 1 .4024 1 .5084 1 .7100 1 .8100 2 .0900 2 .2700 2 .4600←↩

2 .6600 2 .93000 .7811 1 .1033 1 .3724 1 .6200 1 .7200 1 .9900 2 .1700 2 .3500←↩

2 .5400 2 .810025 1 .3867 1 .3006 1 .3607 1 .5300 1 .6200 1 .8800 2 .0500 2 .2300←↩

2 .4200 2 .68000 .7329 0 .9914 1 .2147 1 .4300 1 .5200 1 .7700 1 .9400 2 .1100←↩

2 .2900 2 . 5 5 0 0 ] ;

28 % f = 45 HzHP_data ( : , : , 2 ) = 1 .0 e+03 * [ 1 . 2 644 2 .0185 2 .5997 3 .0800 ←↩

3 .2600 3 .7200 4 .0200 4 .3300 4 .6500 5 .10001 .7590 2 .1755 2 .5797 2 .9900 3 .1600 3 .6100 3 .9000 4 .2000←↩

4 .5200 4 .960031 1 .0701 1 .8521 2 .4357 2 .9000 3 .0700 3 .5000 3 .7800 4 .0700←↩

4 .3800 4 .8100

APPENDIX A. APPENDIX 31

1 .7248 2 .0673 2 .4277 2 .8100 2 .9700 3 .3900 3 .6600 3 .9500←↩4 .2400 4 .6600

2 .2173 2 .2236 2 .4075 2 .7200 2 .8700 3 .2800 3 .5400 3 .8200←↩4 .1100 4 .5100

34 1 .8448 2 .0575 2 .3180 2 .6300 2 .7700 3 .1600 3 .4200 3 .6900←↩3 .9700 4 .3600

1 .4777 1 .8525 2 .1935 2 .5300 2 .6700 3 .0500 3 .3000 3 .5500←↩3 .8300 4 .2100

1 .3241 1 .7238 2 .0896 2 .4400 2 .5800 2 .9400 3 .1700 3 .4200←↩3 .6900 4 .0600

37 0 .9516 1 .5577 2 .0001 2 .3500 2 .4800 2 .8200 3 .0500 3 .2900←↩3 .5500 3 . 9 1 0 0 ] ;

% f = 58 Hz40 HP_data ( : , : , 3 ) = 1 .0 e+03 * [ 3 . 7 533 3 .4648 3 .5869 4 .0000 ←↩

4 .2200 4 .8400 5 .2300 5 .6400 6 .0700 6 .68002 .5605 2 .9441 3 .3914 3 .9000 4 .1200 4 .7100 5 .0900 5 .4900←↩

5 .9200 6 .51003 .0863 3 .0997 3 .3552 3 .7900 4 .0000 4 .5800 4 .9500 5 .3400←↩

5 .7500 6 .340043 3 .0914 3 .0582 3 .2755 3 .6800 3 .8800 4 .4400 4 .8000 5 .1800←↩

5 .5900 6 .16003 .2488 3 .0657 3 .1979 3 .5600 3 .7500 4 .2900 4 .6400 5 .0200←↩

5 .4100 5 .97002 .3823 2 .6523 3 .0037 3 .4300 3 .6200 4 .1400 4 .4800 4 .8400←↩

5 .2300 5 .770046 2 .3941 2 .6005 2 .9060 3 .3000 3 .4800 3 .9800 4 .3100 4 .6600←↩

5 .0400 5 .57002 .3959 2 .5386 2 .7982 3 .1600 3 .3300 3 .8100 4 .1300 4 .4700←↩

4 .8400 5 .36001 .6471 2 .1553 2 .5943 3 .0100 3 .1800 3 .6400 3 .9500 4 .2800←↩

4 .6400 5 . 1 5 0 0 ] ;49

% f = 75 HzHP_data ( : , : , 4 ) = 1 .0 e+03 * [ 2 . 6 137 3 .7535 4 .6498 5 .4100 ←↩

5 .7000 6 .4500 6 .9400 7 .4400 7 .9600 8 .690052 3 .8535 4 .2110 4 .6979 5 .3000 5 .5700 6 .3100 6 .7900 7 .2800←↩

7 .7900 8 .51003 .5223 3 .9923 4 .5437 5 .1700 5 .4400 6 .1600 6 .6200 7 .1000←↩

7 .6100 8 .31003 .5587 3 .9494 4 .4478 5 .0400 5 .3000 6 .0000 6 .4500 6 .9200←↩

7 .4100 8 .100055 3 .5238 3 .8679 4 .3281 4 .8900 5 .1400 5 .8200 6 .2600 6 .7200←↩

7 .2100 7 .88002 .2976 3 .2968 4 .0746 4 .7300 4 .9800 5 .6300 6 .0600 6 .5100←↩

6 .9900 7 .65002 .2694 3 .2050 3 .9369 4 .5600 4 .8000 5 .4300 5 .8500 6 .2900←↩

6 .7600 7 .410058 2 .2558 3 .1121 3 .7910 4 .3800 4 .6100 5 .2200 5 .6300 6 .0600←↩

6 .5100 7 .15003 .0647 3 .3134 3 .6928 4 .1800 4 .4000 5 .0000 5 .3900 5 .8100←↩

6 .2600 6 . 8 9 0 0 ] ;

61 case 'P3D '

% f = 30 HzHP_data ( : , : , 1 ) = [ 408.1947 394.7201 382.7953 371.0000 ←↩

366.0000 352.0000 342.0000 330.0000 316.0000 295.000064 463.0168 436.6944 422.3488 414.0000 411.0000 401.0000 ←↩

392.0000 382.0000 371.0000 353.0000392.4909 434.8538 455.7640 461.0000 460.0000 453.0000 ←↩

447.0000 439.0000 430.0000 414.0000

APPENDIX A. APPENDIX 32

415.3379 470.2917 500.3248 512.0000 513.0000 510.0000 ←↩506.0000 500.0000 493.0000 480.0000

67 517.4614 541.9600 558.5212 568.0000 570.0000 571.0000 ←↩569.0000 565.0000 560.0000 551.0000

634.2626 621.5111 621.5170 628.0000 631.0000 636.0000 ←↩636.0000 635.0000 632.0000 625.0000

623.3773 652.1762 675.1245 692.0000 697.0000 705.0000 ←↩707.0000 708.0000 707.0000 703.0000

70 694.8603 720.3388 742.1286 760.0000 766.0000 778.0000 ←↩783.0000 786.0000 787.0000 786.0000

738.7073 776.7767 807.6893 832.0000 840.0000 856.0000 ←↩863.0000 868.0000 871.0000 8 73 . 0 0 0 0 ] ;

73 % f = 45 HzHP_data ( : , : , 2 ) = 1 .0 e+03 * [ 0 .5918 0 .5726 0 .5594 0 .5480 ←↩

0 .5430 0 .5270 0 .5140 0 .4990 0 .4820 0 .45500 .5246 0 .5801 0 .6066 0 .6120 0 .6100 0 .5990 0 .5900 0 .5780←↩

0 .5640 0 .542076 0 .6366 0 .6610 0 .6754 0 .6810 0 .6810 0 .6760 0 .6700 0 .6620←↩

0 .6510 0 .63400 .6962 0 .7253 0 .7440 0 .7540 0 .7560 0 .7570 0 .7550 0 .7500←↩

0 .7430 0 .72900 .7311 0 .7790 0 .8113 0 .8310 0 .8360 0 .8430 0 .8440 0 .8420←↩

0 .8380 0 .829079 0 .6919 0 .8076 0 .8764 0 .9120 0 .9200 0 .9320 0 .9370 0 .9390←↩

0 .9380 0 .93400 .9074 0 .9377 0 .9691 0 .9980 1 .0080 1 .0270 1 .0340 1 .0400←↩

1 .0430 1 .04300 .9843 1 .0191 1 .0547 1 .0880 1 .1000 1 .1250 1 .1360 1 .1450←↩

1 .1520 1 .156082 0 .9937 1 .0744 1 .1359 1 .1820 1 .1970 1 .2280 1 .2430 1 .2550←↩

1 .2650 1 . 2 7 4 0 ] ;

% f = 58 Hz85 HP_data ( : , : , 3 ) = 1 .0 e+03 * [ 0 .6950 0 .7292 0 .7450 0 .7460 ←↩

0 .7430 0 .7290 0 .7170 0 .7020 0 .6840 0 .65600 .7056 0 .7780 0 .8157 0 .8280 0 .8280 0 .8210 0 .8140 0 .8030←↩

0 .7890 0 .76700 .7745 0 .8512 0 .8953 0 .9150 0 .9180 0 .9180 0 .9150 0 .9090←↩

0 .8990 0 .882088 0 .8808 0 .9414 0 .9818 1 .0060 1 .0120 1 .0200 1 .0210 1 .0190←↩

1 .0140 1 .00300 .9511 1 .0210 1 .0694 1 .1010 1 .1100 1 .1260 1 .1320 1 .1340←↩

1 .1330 1 .12801 .0771 1 .1240 1 .1657 1 .2010 1 .2130 1 .2370 1 .2470 1 .2540←↩

1 .2580 1 .257091 1 .2001 1 .2291 1 .2665 1 .3060 1 .3210 1 .3530 1 .3670 1 .3780←↩

1 .3860 1 .39201 .2953 1 .3267 1 .3689 1 .4150 1 .4330 1 .4730 1 .4920 1 .5080←↩

1 .5200 1 .53101 .4382 1 .4447 1 .4794 1 .5290 1 .5500 1 .5980 1 .6210 1 .6420←↩

1 .6580 1 . 6 7 5 0 ] ;94

% f = 75 HzHP_data ( : , : , 4 ) = 1 .0 e+03 * [ 1 .0661 1 .0654 1 .0716 1 .0800 ←↩

1 .0830 1 .0870 1 .0860 1 .0830 1 .0770 1 .065097 1 .1907 1 .1719 1 .1729 1 .1850 1 .1910 1 .2040 1 .2080 1 .2090←↩

1 .2080 1 .20201 .1367 1 .2074 1 .2589 1 .2950 1 .3060 1 .3270 1 .3360 1 .3420←↩

1 .3460 1 .34701 .2525 1 .3181 1 .3711 1 .4130 1 .4270 1 .4560 1 .4700 1 .4820←↩

1 .4900 1 .4980

APPENDIX A. APPENDIX 33

100 1 .3193 1 .4115 1 .4826 1 .5370 1 .5550 1 .5930 1 .6120 1 .6280←↩1 .6420 1 .6550

1 .4813 1 .5481 1 .6108 1 .6680 1 .6890 1 .7360 1 .7600 1 .7810←↩1 .8000 1 .8200

1 .5751 1 .6595 1 .7364 1 .8050 1 .8300 1 .8860 1 .9150 1 .9410←↩1 .9650 1 .9920

103 1 .5866 1 .7447 1 .8618 1 .9490 1 .9780 2 .0420 2 .0770 2 .1080←↩2 .1370 2 .1700

1 .8150 1 .9190 2 .0139 2 .1000 2 .1320 2 .2060 2 .2460 2 .2820←↩2 .3160 2 . 3 5 5 0 ] ;

end

A.1.2 Get Heat Demand

Figure A.2: Subsystem get heat demand

% Ca l c u l a t e s the s t e ady s t a t e o f a b u i l d i n g wi th i ndoo r t empe ra tu r e ←↩Tr and outdoor t empe ra tu r e Ta . Ac co r d i n g l y the s t e ady s t a t e heat←↩i n pu t and powers a r e c a l c u l a t e d .

f u n c t i o n [ TSS , Qdem ] = steady_state_sys_build ( Tr_setp , Abc , Bbc ,←↩Ta_av_ext )

3 % Steady s t a t e c o n d i t i o n : dot_T = 0% or : ATss + BUss = 0% known : Tr , Ta

6 % 5 unknowns : Ts1 , Ts2 , Tf , Qhp , Qaux% 4 equa t i o n s −−> 1 DOF: Qhp + Qaux !% (That i s why o p t im i z a t i o n p o t e n t i a l )

9

% Choose Qaux = 0% C o e f f i c i e n t s o f unknowns :

12

Amat = ze r o s (4 , 4 ) ;Bmat = ze r o s (4 , 1 ) ;

15

Amat ( : , 1 : 3 ) = Abc ( : , 1 : 3 ) ;Amat ( : , 4 ) = Bbc ( : , 2 ) ;

18 Bmat ( : ) = −Abc ( : , 4 ) *Tr_setp−Bbc ( : , 1 ) *Ta_av_ext ;

SS = Amat\Bmat ;21 TSS = [ SS ( 1 : 3 , 1 ) ; Tr_setp ] ;

%USS = [ Ta_av_ext ; SS (4 , 1 ) ; 0 ] ;Qdem = SS (4 ) ;

A.1.3 Calculate Heat Pump/Auxiliary Power

APPENDIX A. APPENDIX 34

Figure A.3: Subsystem calculate heat pump / auxiliary power

% Ca l c u l a t e s the heat pump power and a u x i l i a r y power based on a ←↩weather dependent h e a t i n g cu r ve s t r a t e g y .

% 1 . The s e t p o i n t t empe r a tu r e s and s e t p o i n t heat demand a r e ←↩c a l c u l a t e d . These depend on

3 % (* ) i n pu t 1 : the h e a t i n g system and b u i l d i n g pa ramete r s% (* ) i n pu t 2 : the s e t p o i n t t empe ra tu r e f o r the room% (* ) i n pu t 3 : the d a i l y ave r age outdoor t empe ra tu r e

6 % (* ) i n pu t 4 : the c u r r e n t s t a t e o f the system% 2 . I t i s i n v e s t i g a t e d i f the h e a t i n g demand can be e n t i r e l y ←↩

d e l i v e r e d by the heat pump .% 3 . I f the heat pump can not produce a l l the heat r e qu i r e d , the ←↩

backup may9 % be s t a r t e d IF the r e t u r n water t empe ra tu r e f a l l s under a g i v en ←↩

t r e s h o l d .f u n c t i o n y = get_hp_power ( u )

12 % decompose i n pu t v e c t o rTb = u ( 1 : 2 ) ;Twrss = u (4 ) ;

15 Qdem = u (7 ) ;Tg = u ( 8 : 1 9 ) ;DB = u (20) ; % dead band on r e t u r n water t empe ra tu r e

18 Qaux_max = u (21) ;facHP = u (22) ;HP_status = u (23) ;

21 LP_status = u (24) ;

Tr_setp = Twrss ; % s e t p o i n t r e t u r n t empe ra tu r e24 Qaux = 0 ; % d e f a u l t no a u x i l i a r y h e a t i n g

% on−o f f ( 1 ) or modulated (0 ) c o n t r o l27 controller = str2double ( get_param ( ' heat_pump/ c o n t r o l l e r sw i t c h ' , ' sw '←↩

) ) ;

i f LP_status == 0 % low p r e s s u r e a larm : heat pump unab led30 i f Tg (1 ) >= 0 ;

LP_status = 1 ; % re−enab l e heat pumpend

33 Qhp = 0 ;Php = 0 ;

e l s e36 i f Tg (1 ) <= −3; % low p r e s s u r e a larm : unab l e heat pump

LP_status = 0 ;

APPENDIX A. APPENDIX 35

Qhp = 0 ;39 Php = 0 ;

e l s ei f HP_status % Heat pump on at p r e v i o u s t ime s t ep

42 i f Tb (2 ) < ( Tr_setp + DB ) % Twr s t i l l be low upper bandi f ( controller )

Qvec = Q_range_HP ( Tb (1 ) , Tg (1 ) ) ;45 e l s e

Qvec = Qdem ;end

48 [ Qhp , Php ] = HP_lookup_TLWC_TLWE_Qdem_ext ( Tb (1 ) , Tg (1 ) , Qvec ,←↩facHP ) ;

Qaux = max (0 , min ( Qaux_max , Qdem−Qhp ) ) ;e l s e % Twr above upper band

51 Qhp = 0 ;Php = 0 ;HP_status = 0 ; % sw i t ch o f f heat pump

54 ende l s e % HP was i n o f f−mode

i f Tb (2 ) < ( Tr_setp − DB ) % T exceeded l owe r deadband57 i f ( controller )

Qvec = Q_range_HP ( Tb (1 ) , Tg (1 ) ) ;e l s e

60 Qvec = Qdem ;end[ Qhp , Php ] = HP_lookup_TLWC_TLWE_Qdem_ext ( Tb (1 ) , Tg (1 ) , Qvec ,←↩

facHP ) ;63 HP_status = 1 ;

e l s eQhp = 0 ;

66 Php = 0 ;HP_status = 0 ; % sw i t ch o f f heat pump

end69 end

endend

72

y = [ Qaux ; Qhp ; Php ; HP_status ; LP_status ] ;

% I n t e r p o l a t e s the heat pump i npu t and output power2 f u n c t i o n [ Qeff , Peff ] = HP_lookup_TLWC_TLWE_Qdem_ext ( TLWC , TLWE , Qvec ,←↩

fac_HP )

i f n a r g i n < 45 fac_HP = 1 ;

end

8 TLWC_vec = get_HP_data_ext ( 'TLWC_range ' ) ;TLWE_vec = get_HP_data_ext ( 'TLWE_range ' ) ;Freq_vec = get_HP_data_ext ( ' Freq_range ' ) ;

11 Q3D = get_HP_data_ext ( 'Q3D ' ) ;P3D = get_HP_data_ext ( 'P3D ' ) ;

14 HC = Qvec ( end ) ;

% Heat power as a f u n c t i o n o f f f o r the g i v en t empe r a tu r e s TLWE, ←↩TLWE

17 TLWE = min ( TLWE , TLWE_vec ( end ) ) ; % i f TLWE > TLWE,max : COP = COPmaxTLWC = max( TLWC , TLWC_vec (1 ) ) ; % i f TLWC < TLWC, min : COP = COPmax

20 i f HC > 0 % Heat demand

APPENDIX A. APPENDIX 36

i f and ( TLWE >= TLWE_vec (1 ) , TLWC <= TLWC_vec ( end ) ) % TLWE,TWLC i n ←↩range

Qeff_1D = ze r o s ( l e n g t h ( Freq_vec ) , 1 ) ;23 Qeff_1D ( : , 1 ) = interp3 ( TLWE_vec , TLWC_vec , Freq_vec , Q3D , TLWE , TLWC ,←↩

Freq_vec ) ;i f HC < Qeff_1D (1 ) ; % HC < Qhp , min

f = Freq_vec (1 ) ;26 e l s e i f HC > Qeff_1D ( end ) ; % HC > Qhp ,max

f = Freq_vec ( end ) ;e l s e % Qhp , min < HC < Qhp ,max

29 f = i n t e r p 1 ( Qeff_1D , Freq_vec , HC ) ; % HC between boundsend

end32 Qeff = interp3 ( TLWE_vec , TLWC_vec , Freq_vec , Q3D , TLWE , TLWC , f ) ;

Peff = interp3 ( TLWE_vec , TLWC_vec , Freq_vec , P3D , TLWE , TLWC , f ) ;freq = f ;

35 COP = Qeff/Peff ;e l s e % TLWE,TWLC out o f range

Qeff = 0 ;38 Peff = 0 ;

freq = 0 ;COP = NaN;

41 ende l s e % No heat demand

Qeff = 0 ;44 Peff = 0 ;

freq = 0 ;COP = NaN;

47 end

% Sc a l i n g heat pump ac co r d i n g to demand at d e s i g n t empe ra tu r e ←↩c o n d i t i o n s

50 Qeff = Qeff*fac_HP ;Peff = Peff*fac_HP ;

A.1.4 Simulate Building Dynamics

Figure A.4: Subsystem simulate building dynamics

APPENDIX A. APPENDIX 37

% S imu l t e s the b u i l d i n g dynamicsf u n c t i o n Tb_out = simulate_building ( Tb_in , Ta , Qaux , Qhp , Abd , Bbd )

3 Tb_out = Abd * Tb_in + Bbd * [ Ta ; Qhp ; Qaux ] ;

A.1.5 Simulate Ground Dynamics

Figure A.5: Subsystem simulate ground dynamics

% Simu l a t e s the ground dynamicsf u n c t i o n Tg_out = simulate_ground ( Tg_in , Qhp , Php , Tsoil , Agd , Bgd )

3 Tg_out = Agd * Tg_in + Bgd * [ ( Qhp−Php ) ; Tsoil ] ;

A.1.6 Plot Outputs

% Plo t s the output o f the heat_pump s imu l i n k modelf u n c t i o n heat_pump_plot ( s )

3

% con t en t s o f s imu l a t i o n output s t r u c tv = s . signals . values ;

6 t = s . time ;Ta = v ( : , 1 ) ;Tb = v ( : , 2 : 5 ) ;

9 Qaux = v ( : , 6 ) ;Qhp = v ( : , 7 ) ;Php = v ( : , 8 ) ;

12 Tg = v ( : , 9 : 2 0 ) ;Tr_setp = v ( : , 2 1 ) ;Qdem = v ( : , 2 2 ) ;

15

% p l o t b u i l d i n g and ambient t empe r a tu r e sf i g u r e ;

18 s u bp l o t ( 3 , 1 , 1 ) ;p l o t (t , Tb ) ;ho ld a l l ;

21 s t a i r s (t , Tr_setp ) ;p l o t (t , Ta ) ;ho ld off ;

24 a x i s tight ;t i t l e ( ' Bu i l d i n g and ambient t empe r a tu r e s ' ) ;%x l a b e l ( ' t ime [ h ] ' ) ;

27 y l a b e l ( ' Temperature [ °C ] ' ) ;

APPENDIX A. APPENDIX 38

l e g end ( 'T_{ws} ' , 'T_{wr} ' , 'T_{ f } ' , 'T_{ r } ' , 'T_{r , s e t p } ' , 'T_{a} ' , '←↩Loca t i on ' , ' South ' , ' Or i e n t a t i o n ' , ' h o r i z o n t a l ' ) ;

30 % p l o t ground t empe ra tu r e ss u bp l o t ( 3 , 1 , 2 ) ;p l o t (t , Tg ) ;

33 a x i s tight ;t i t l e ( 'Ground t empe ra tu r e s ' ) ;%x l a b e l ( ' t ime [ h ] ' ) ;

36 y l a b e l ( ' Temperature [ °C ] ' ) ;

% heat pump s t a t i s t i c s39 step = str2double ( get_param ( ' heat_pump ' , ' F ixedStep ' ) ) ;

Qhpsum = sum( Qhp ) *step/1e3 ; % i n kWhPhpsum = sum( Php ) *step/1e3 ; % i n kWh

42 Qauxsum = sum( Qaux ) *step/1e3 ; % i n kWhHPhours = ( s i z e ( f i n d ( Php ) , 1 ) − 1) *step ;HPswitches = 0 ;

45 toggle = 0 ;shortOnTime = inf ;longOnTime = 0 ;

48 onTime = 0 ;f o r i=1: s i z e ( Php , 1 )

i f ( Php ( i ) > 0)51 i f ( toggle == 0)

HPswitches = HPswitches + 1 ;end

54 toggle = 1 ;onTime = onTime + 1 ;

e l s e57 toggle = 0 ;

i f ( onTime > 0)shortOnTime = min ( shortOnTime , onTime ) ;

60 longOnTime = max( longOnTime , onTime ) ;onTime = 0 ;

end63 end

endshortOnTime = shortOnTime*step ;

66 longOnTime = longOnTime*step ;

% p l o t power consumpt ion69 s u bp l o t ( 3 , 1 , 3 ) ;

s t a i r s (t , [ Qhp Php Qaux Qdem ] /1 e3 ) ;a x i s tight ;

72 t i t l e ( [ 'Power consumpt ion (JAZ = ' , s p r i n t f ( '%0.2 f ' , Qhpsum/Phpsum ) , ' ,←↩heat pump sw i t ched on ' , num2str ( HPswitches ) , ' t imes f o r a t o t a l←↩o f ' , s p r i n t f ( '%0.2 f ' , HPhours ) , ' hours , s h o r t e s t on t ime ' ,←↩

s p r i n t f ( '%0.2 f ' , shortOnTime ) , ' hours , l o n g e s t on t ime ' , s p r i n t f (←↩'%0.2 f ' , longOnTime ) , ' hour s ) ' ] ) ;

x l a b e l ( ' t ime [ h ] ' ) ;y l a b e l ( 'Power [kW] ' ) ;

75 l e g end ( [ 'Q_{hp} (\ i n t= ' , s p r i n t f ( '%0.2 f ' , Qhpsum ) , 'kWh) ' ] , [ 'P_{hp} (\←↩i n t= ' , s p r i n t f ( '%0.2 f ' , Phpsum ) , 'kWh) ' ] , [ 'Q_{aux} (\ i n t= ' , s p r i n t f (←↩'%0.2 f ' , Qauxsum ) , 'kWh) ' ] , 'Q_{dem} ' , ' Loca t i on ' , ' South ' , '←↩Or i e n t a t i o n ' , ' h o r i z o n t a l ' ) ;

APPENDIX A. APPENDIX 39

A.2 Matlab Implementation for System Aggrega-tion

A.2.1 Create Random Parameter Sets

% Returns a s t r u c t c o n t a i n i n g random ( normal d i s t r i b u t i o n ) b u i l d i n g ←↩paramete r v e c t o r s o f l e n g t h n

f u n c t i o n s = create_param_building (n , sigma )3

% s t r u c t h o l d i n g a l l b u i l d i n g pa ramete r ss = struct ;

6

% bu i l d i n g 1% get the normal pa ramete r s

9 [ CWs , CWr , mBcB , CG , mWcW , kWB , kB , kG , QDOT , facHP , nb ] = get_param_building (←↩'Wimmer1 ' ) ;

% gene r a t e normal d i s t r i b u t e d random va l u e s f o r each paramete rs . b1 . CWs = normrnd ( CWs , CWs*sigma , n , 1) ;

12 s . b1 . CWr = normrnd ( CWr , CWr*sigma , n , 1) ;s . b1 . mBcB = normrnd ( mBcB , mBcB*sigma , n , 1) ;s . b1 . CG = normrnd ( CG , CG*sigma , n , 1) ;

15 s . b1 . mWcW = normrnd ( mWcW , mWcW*sigma , n , 1) ;s . b1 . kWB = normrnd ( kWB , kWB*sigma , n , 1) ;s . b1 . kB = normrnd ( kB , kB*sigma , n , 1) ;

18 s . b1 . kG = normrnd ( kG , kG*sigma , n , 1) ;s . b1 . QDOT = normrnd ( QDOT , QDOT*sigma , n , 1) ;s . b1 . facHP = normrnd ( facHP , facHP*sigma , n , 1) ;

21 s . b1 . nb = normrnd ( nb , nb*sigma , n , 1) ;

% b u i l d i n g 224 % get the normal pa ramete r s

[ CWs , CWr , mBcB , CG , mWcW , kWB , kB , kG , QDOT , facHP , nb ] = get_param_building (←↩'Wimmer2 ' ) ;

% gene r a t e normal d i s t r i b u t e d random va l u e s f o r each paramete r27 s . b2 . CWs = normrnd ( CWs , CWs*sigma , n , 1) ;

s . b2 . CWr = normrnd ( CWr , CWr*sigma , n , 1) ;s . b2 . mBcB = normrnd ( mBcB , mBcB*sigma , n , 1) ;

30 s . b2 . CG = normrnd ( CG , CG*sigma , n , 1) ;s . b2 . mWcW = normrnd ( mWcW , mWcW*sigma , n , 1) ;s . b2 . kWB = normrnd ( kWB , kWB*sigma , n , 1) ;

33 s . b2 . kB = normrnd ( kB , kB*sigma , n , 1) ;s . b2 . kG = normrnd ( kG , kG*sigma , n , 1) ;s . b2 . QDOT = normrnd ( QDOT , QDOT*sigma , n , 1) ;

36 s . b2 . facHP = normrnd ( facHP , facHP*sigma , n , 1) ;s . b2 . nb = normrnd ( nb , nb*sigma , n , 1) ;

A.2.2 Main File

% Simu l a t e s a p a r a l l e l a g g r e g a t i o n o f s e v e r a l heat pump sys tems2 f u n c t i o n [ results , data ] = heat_pump_sim ( params , arguments )

% s t a r t t ime measurement5 t i c ;

% d e f a u l t v a l u e s8 i f ( n a r g i n < 1)

d i s p ( ' need paramete r s t r u c t ( generate_param_bui ld ing ( n ) ) ' ) ;r e t u r n ;

APPENDIX A. APPENDIX 40

11 end

s = struct ( . . .14 'n ' , s i z e ( params . b1 . nb , 1 ) , . . .

' f i g u r e s ' , 1 , . . .' b u i l d i n g ' , ' b1 ' , . . .

17 'Tr_day ' , 20 , . . .'Tr_night ' , 20 , . . .'Ta ' , ' p r o f i l e ' , . . .

20 ' c o n t r o l l e r ' , 0 , . . .'DB ' , 1 , . . .' Ts o i l ' , 10 , . . .

23 ' d s t a r t ' , 1 , . . .' du r a t i o n ' , 24 , . . .' s t e p ' , 0 . 1 ) ;

26 args = char ( fieldnames ( s ) ) ;f o r i = 1 : l e n g t h ( args )

i f ( isfield ( arguments , strcat ( args (i , : ) ) ) )29 s . ( strcat ( args (i , : ) ) ) = arguments . ( strcat ( args (i , : ) ) ) ;

endend

32

i f ( s . n > s i z e ( params . b1 . nb , 1 ) )d i s p ( [ ' not enough paramete r s e t s ( ' , num2str ( s i z e ( params . b1 . nb , 1 ) )←↩

, ' ) f o r s t a t e d number o f p a r a l l e l s im u l a t i o n s ( ' , num2str ( s . n )←↩, ' ) ' ] ) ;

35 r e t u r n ;end

38 % i n i t i a l c o n d i t i o n sd i s p ( ' i n i t i a l i z i n g ' ) ;

41 data = heat_pump_init ( params , s ) ;

i f ( s . duration < 24)44 rows = s . duration / s . step ;

e l s erows = 24 / s . step ;

47 end

time = (( s . dstart*24+s . step ) : s . step : ( s . dstart*24+s . duration ) ) ' ;50 timeinterval = ze r o s ( rows , 1 ) ;

Ta = i n t e r p 1 ( data . Tamb ( : , 1 ) , data . Tamb ( : , 2 ) , time ) ;53 Tainterval = ze r o s ( rows , 1 ) ;

Tr_setp = ze r o s ( rows , 1 ) ;56

Tb = ze r o s ( rows , s . n*data . nxb ) ;Tb ( 1 , : ) = data . Tbinit ;

59

Tg = ze r o s ( rows , s . n*data . nxg ) ;Tg ( 1 , : ) = s . Tsoil * ones (1 , data . nxg*s . n ) ;

62

Qdem = ze r o s ( rows , s . n ) ;Qhp = Qdem ;

65 Php = Qdem ;Qaux = Qdem ;

68 HP_status = data . HP_status ;LP_status = data . HP_status ;

APPENDIX A. APPENDIX 41

71 % s imu l a t i o nd i s p ( ' s t a r t s imu l a t i o n ' ) ;

74 k = 0 ;row = 0 ;day = s . dstart ;

77 progress = 0 ;

f o r t = time '

80 k = k + 1 ;row = row + 1 ;timeinterval ( row ) = t ;

83 Tainterval ( row ) = Ta ( k ) ;

i f (~mod (k , c e i l ( s . duration /( s . step * 20) ) ) )86 Telapsed = toc ;

progress = progress + 1 ;d i s p ( [ num2str ( progress *5) , '%, e l a p s e d t ime : ' , s p r i n t f ( '%7.2 f ' ,←↩

Telapsed ) , ' s econds ' ] ) ;89 end

% room tempe ra tu r e s e t p o i n t92 i f ( mod (t , 2 4 ) < 6 | | mod (t , 2 4 ) > 22)

Tr_setp ( row ) = s . Tr_night ;e l s e

95 Tr_setp ( row ) = s . Tr_day ;end

98 % loop heat pumpsf o r j = 1 : s . n

101 % get heat demand[ TSS , Qdem ( row , j ) ] = get_steady_state_building ( data . Abc , data . Bbc ,←↩

Tr_setp ( row ) , Ta ( k ) , j ) ;

104 % c a l c u l a t e heat pump and a u x i l i a r y powercols = ( data . nxb *(j−1)+1) : ( data . nxb *(j−1)+2) ;[ Qhp ( row , j ) , Php ( row , j ) , Qaux ( row , j ) , HP_status ( j ) , LP_status ( j ) ] = ←↩

get_hp_power ( Tb ( row , cols ) , TSS (2 ) , Qdem ( row , j ) , Tg ( row , data . nxg←↩*(j−1)+1) , s . DB , data . Qaux_max ( j ) , data . facHP ( j ) , HP_status ( j ) ,←↩LP_status ( j ) , s . controller ) ;

107

% s imu l a t e dynamicsi f ( t < max( time ) )

110 cols = ( data . nxb *(j−1)+1) : ( data . nxb*j ) ;Tb ( row+1,cols ) = [ data . Abd {1 , j}*Tb ( row , cols ) '+data . Bbd {1 , j }* [←↩

Ta ( k ) ; Qhp ( row , j ) ; Qaux ( row , j ) ] ] ' ;

113 cols = ( data . nxg *(j−1)+1) : ( data . nxg*j ) ;Tg ( row+1,cols ) = [ data . Agd {1 , j}*Tg ( row , cols ) '+data . Bgd {1 , j }* [←↩

Qhp ( row , j )−Php ( row , j ) ; s . Tsoil ] ] ' ;end

116

end

119 i f ( row >= rows )results = struct ( ' a r g s ' ,s , 'Tb ' , Tb ( 1 : ( end−1) , : ) , 'Tr_setp ' , Tr_setp←↩

, 'Ta ' , Tainterval , 'Tg ' , Tg ( 1 : ( end−1) , : ) , 'Qhp ' , Qhp , 'Php ' , Php , '←↩Qaux ' , Qaux , 'Qdem ' , Qdem , ' day ' , day , ' t ime ' , timeinterval ) ;

s ave ( [ ' r e s u l t s_ ' , num2str ( day ) ] , ' r e s u l t s ' ) ;122 Tb ( 1 , : ) = Tb ( row+1 , :) ;

Tg ( 1 , : ) = Tg ( row+1 , :) ;

APPENDIX A. APPENDIX 42

day = day + 1 ;125 row = 0 ;

end

128 end

d i s p ( ' s imu l a t i o n f i n i s h e d ' ) ;131

results = struct ( ' a r g s ' ,s , 'Tb ' , Tb , 'Tr_setp ' , Tr_setp , 'Ta ' , Ta , 'Tg ' , Tg ,←↩'Qhp ' , Qhp , 'Php ' , Php , 'Qaux ' , Qaux , 'Qdem ' , Qdem , ' t ime ' , time ) ;

134 % p l o t ou tpu t si f ( s . figures )

d i s p ( ' p l o t ou tpu t s ' ) ;137 heat_pump_plot ( ' r e s u l t s ' ) ;

end

140 % stop t ime measurementTelapsed = toc ;d i s p ( [ ' t o t a l t ime : ' , s p r i n t f ( '%7.2 f , ' , Telapsed ) , ' s econds ' ] ) ;

A.2.3 Create Systems, Initialization

% Returns a s t r u c t c o n t a i n i n g s t a t e space mat r i c e s , pa ramete r s and ←↩i n i t i a l v a l u e s

2 f u n c t i o n s = heat_pump_init ( params , args )

% s t r u c t h o l d i n g i n i t i a l c o n d i t i o n s5 s = struct ;

% b u i l d i n g8 % number o f s t a t e s i n b u i l d i n g

s . nxb = 4 ;% con t i nuou s b u i l d i n g model

11 sysbc{args . n} = 0 ;sysbd{args . n} = 0 ;s . Abd{args . n} = 0 ;

14 s . Bbd{args . n} = 0 ;[ s . Abc , s . Bbc , s . Qaux_max , s . facHP , nb ] = get_sys_building ( params , args . n←↩

, args . building , 'h ' ) ;f o r i = 1 : args . n

17 s . Abc{i} = s . Abc{i} .* args . step ;s . Bbc{i} = s . Bbc{i} .* args . step ;sysbc{i} = ss ( s . Abc{i } , s . Bbc{i } , eye ( s . nxb ) , z e r o s ( s . nxb , s i z e ( s . Bbc{←↩

i } ,2) ) ) ;20 % d i s c r e t e b u i l d i n g model

sysbd{i} = c2d ( sysbc{i } ,1) ;[ s . Abd{i } , s . Bbd{i } ] = ssdata ( sysbd{i }) ;

23 end

% ground26 % number o f s t a t e s i n the ground

s . nxg = 12 ;% con t i nuou s ground model

29 s . Bgc{args . n} = 0 ;sysgc{args . n} = 0 ;sysgd{args . n} = 0 ;

32 s . Agd{args . n} = 0 ;s . Bgd{args . n} = 0 ;[ s . Agc , Bgc ] = get_sys_ground ( s . nxg , 'h ' , 'W' ) ;

35 s . Agc = s . Agc .* args . step ;

APPENDIX A. APPENDIX 43

Bgc = Bgc .* args . step ;f o r i = 1 : l e n g t h ( nb )

38 s . Bgc{i} = Bgc ;s . Bgc{i }(1 ,1 ) = s . Bgc{i }(1 ,1 ) / nb ( i ) ; % Qground = u4sysgc{i} = ss ( s . Agc , s . Bgc{i } , eye ( s . nxg ) , z e r o s ( s . nxg , s i z e ( s . Bgc{i←↩

} ,2) ) ) ;41 % d i s c r e t e ground model

sysgd{i} = c2d ( sysgc{i } , 1) ;[ s . Agd{i } , s . Bgd{i } ] = ssdata ( sysgd{i }) ;

44 end

% ambient t empe ra tu r e ( h ou r l y data )47 i f ( s t rcmp ( args . Ta , ' p r o f i l e ' ) )

% ambient t empe ra tu r e p r o f i l es . Tamb = load ( 'Ukkel_Tamb . t x t ' ) ;

50 Tamb_init = s . Tamb ( 1 , 2 ) ;e l s e% con s t an t ambient t empe ra tu r e

53 Tamb_init = args . Ta ;s . Tamb = [ ( 1 : args . duration ) ' , args . Ta * ones ( args . duration , 1) ] ;

end56

% room s e t p o i n t t empe ra tu r eTr_setp_init = args . Tr_day ;

59

% i n i t i a l c o n d i t i o nf o r i = 1 : args . n

62 s . Tbinit ( 1 , ( s . nxb *(i−1)+1) : ( s . nxb*i ) ) = get_steady_state_building (←↩s . Abc , s . Bbc , Tr_setp_init , Tamb_init , i ) ;

ends . Tbinit = s . Tbinit .* normrnd ( 1 , 0 . 0 5 , [ 1 , s i z e ( s . Tbinit , 2 ) ] ) ;

65 s . HP_status ( args . n ) = 0 ;s . LP_status ( args . n ) = 0 ;

% Retu rns the s t a t e space r e p r e s e n t a t i o n o f the b u i l d i n gf u n c t i o n [ A , B , QDOT , facHP , nb ] = get_sys_building ( params , number ,←↩

building , time_unit )3

A{number} = 0 ;B{number} = 0 ;

6 QDOT = ze r o s (1 , number ) ;facHP = ze r o s (1 , number ) ;nb = ze r o s (1 , number ) ;

9

f o r i = 1 : numberCWs = params . ( building ) . CWs ( i ) ;

12 CWr = params . ( building ) . CWr ( i ) ;mBcB = params . ( building ) . mBcB ( i ) ;CG = params . ( building ) . CG ( i ) ;

15 mWcW = params . ( building ) . mWcW ( i ) ;kWB = params . ( building ) . kWB ( i ) ;kB = params . ( building ) . kB ( i ) ;

18 kG = params . ( building ) . kG ( i ) ;QDOT ( i ) = params . ( building ) . QDOT ( i ) ;facHP ( i ) = params . ( building ) . facHP ( i ) ;

21 nb ( i ) = params . ( building ) . nb ( i ) ;

% System equa t i o n s24 Amat = ze r o s (4 , 4 ) ;

Bmat = ze r o s (4 , 3 ) ;

APPENDIX A. APPENDIX 44

27 % TwsAmat ( 1 , 1 ) = −mWcW / CWs ; % 1/ sAmat ( 1 , 2 ) = mWcW / CWs ; % 1/ s

30

% TwrAmat ( 2 , 1 ) = mWcW/ CWr ; % 1/ s

33 Amat ( 2 , 2 ) = ( −mWcW − kWB ) / CWr ; % 1/ sAmat ( 2 , 3 ) = kWB / CWr ; % 1/ s

36 % TfAmat ( 3 , 1 ) = 0 ; % 1/ sAmat ( 3 , 2 ) = kWB / mBcB ; % 1/ s

39 Amat ( 3 , 3 ) = −( kWB + kB ) / mBcB ; % 1/ sAmat ( 3 , 4 ) = kB / mBcB ; % 1/ s

42 % TrAmat ( 4 , 3 ) = kB / CG ; % 1/ sAmat ( 4 , 4 ) = −( kB + kG ) / CG ; % 1/ s

45

Bmat ( 1 , 2 ) = 1 / CWs ; % K/J < QhpBmat ( 2 , 3 ) = 1 / CWr ; % K/J < Qaux

48 Bmat ( 4 , 1 ) = kG / CG ; % 1/ s < Tamb

i f st rcmp ( time_unit , 'h ' )51 Amat = Amat .* 3600 ;

Bmat = Bmat .* 3600 ;end

54

A{i} = Amat ;B{i} = Bmat ;

57 end

% Retu rns the s t a t e space r e p r e s e n t a t i o n o f the groundf u n c t i o n [ A , B , C , D ] = get_sys_ground ( nx_bf , time_unit , power_unit )

3

i f nx_bf > 6load ( 'RC_Eskilson_start_dt_450_nx_12 ' , ' ID_re su l t ' )

6 sys12 = ID_result . sys ;

i f ( nx_bf == 12)9 sys = sys12 ;

e l s edisplay ( 'Warning ! Reduced model ! I n v e s t i g a t e c o r r e c t n e s s o f use ←↩

i n ode ' )12 method = 'MatchDC ' ;

sys = balred ( sys12 , nx_bf , ' E l im i n a t i o n ' , method ) ;end

15

[ A , B , C , D ] = ssdata ( sys ) ;e l s e

18 switch nx_bf

case 1l oad ( 'RC_Eskilson_opt_IDset2_normal_dt_450_nx_1 ' , ' ID_re su l t ' )

21 case 2l oad ( 'RC_Eskilson_opt_IDset2_normal_dt_450_nx_2 ' , ' ID_re su l t ' )

case 324 l o ad ( 'RC_Eskilson_opt_IDset2_normal_dt_450_nx_3 ' , ' ID_re su l t ' )

case 4l oad ( 'RC_Eskilson_opt_IDset2_normal_dt_450_nx_4 ' , ' ID_re su l t ' )

27 case 5l oad ( 'RC_Eskilson_opt_IDset2_normal_dt_450_nx_5 ' , ' ID_re su l t ' )

APPENDIX A. APPENDIX 45

case 630 l o ad ( 'RC_Eskilson_opt_IDset2_normal_dt_450_nx_6 ' , ' ID_re su l t ' )

end[ A , B , C , D ] = ssdata ( ID_result . sys ) ; % dt = 1 hour

33 end

i f s t rcmp ( time_unit , ' s ' )36 A = A . / 3 600 ; % dt = 1h −−> 1 s

B = B . / 3 600 ;end

39

i f s t rcmp ( power_unit , 'W' )B ( 1 , 1 ) = B ( 1 , 1 ) * 3 . 6 ; % i npu t o f kJ/h −−> W

42 D ( 1 , 1 ) = D ( 1 , 1 ) * 3 . 6 ; % i npu t o f kJ/h −−> Wend

A.2.4 Heat Demand

% Ca l c u l a t e s the s t e ady s t a t e o f a b u i l d i n g wi th i ndoo r t empe ra tu r e ←↩Tr and outdoor t empe ra tu r e Ta . Ac co r d i n g l y the s t e ady s t a t e heat←↩i n pu t and powers a r e c a l c u l a t e d .

2 f u n c t i o n [ TSS , Qdem ] = get_steady_state_building (A , B , Tr_setp , Ta , i )% Steady s t a t e c o n d i t i o n : dot_T = 0% or : ATss + BUss = 0

5 % known : Tr , Ta% 5 unknowns : Ts1 , Ts2 , Tf , Qhp , Qaux% 4 equa t i o n s −−> 1 DOF: Qhp + Qaux !

8 % (That i s why o p t im i z a t i o n p o t e n t i a l )

% Choose Qaux = 011 % Co e f f i c i e n t s o f unknowns :

Amat = ze r o s (4 , 4 ) ;14 Bmat = ze r o s (4 , 1 ) ;

Amat ( : , 1 : 3 ) = A{i } ( : , 1 : 3 ) ;17 Amat ( : , 4 ) = B{i } ( : , 2 ) ;

Bmat ( : ) = −A{i } ( : , 4 ) * Tr_setp − B{i } ( : , 1 ) * Ta ;

20 SS = Amat \ Bmat ;TSS = [ SS ( 1 : 3 , 1 ) ; Tr_setp ] ' ;%USS = [Ta ; SS (4 , 1 ) ; 0 ] ;

23 Qdem = SS ( 4 , 1 ) ;

A.2.5 Heat Pump/Auxiliary Power

1 % Ca l c u l a t e s the heat pump power and a u x i l i a r y power based on a ←↩weather dependent h e a t i n g cu r ve s t r a t e g y .

% 1 . The s e t p o i n t t empe r a tu r e s and s e t p o i n t heat demand a r e ←↩c a l c u l a t e d . These depend on

% (* ) i n pu t 1 : the h e a t i n g system and b u i l d i n g pa ramete r s4 % (* ) i n pu t 2 : the s e t p o i n t t empe ra tu r e f o r the room% (* ) i n pu t 3 : the d a i l y ave r age outdoor t empe ra tu r e% (* ) i n pu t 4 : the c u r r e n t s t a t e o f the system

7 % 2. I t i s i n v e s t i g a t e d i f the h e a t i n g demand can be e n t i r e l y ←↩d e l i v e r e d by the heat pump .

% 3 . I f the heat pump can not produce a l l the heat r e qu i r e d , the ←↩backup may

% be s t a r t e d IF the r e t u r n water t empe ra tu r e f a l l s under a g i v en ←↩t r e s h o l d .

APPENDIX A. APPENDIX 46

10 f u n c t i o n [ Qhp , Php , Qaux , HP_status , LP_status ] = get_hp_power ( Tb , Twrss ,←↩Qdem , Tg , DB , Qaux_max , facHP , HP_status , LP_status , controller )

Tr_setp = Twrss ; % s e t p o i n t r e t u r n t empe ra tu r e13 Qaux = 0 ; % De f au l t no a u x i l i a r y h e a t i n g

i f LP_status == 0 % low p r e s s u r e a larm : heat pump unab led16 i f Tg (1 ) >= 0 ;

LP_status = 1 ; % re−enab l e heat pumpend

19 Qhp = 0 ;Php = 0 ;

e l s e22 i f Tg (1 ) <= −3; % low p r e s s u r e a larm : unab l e heat pump

LP_status = 0 ;Qhp = 0 ;

25 Php = 0 ;e l s e

i f HP_status % Heat pump on at p r e v i o u s t ime s t ep28 i f Tb (2 ) < ( Tr_setp + DB ) % Twr s t i l l be low upper band

i f ( controller )Qvec = Qdem ;

31 e l s eQvec = Q_range_HP ( Tb (1 ) , Tg (1 ) ) ;

end34 [ Qhp , Php ] = HP_lookup_TLWC_TLWE_Qdem_ext ( Tb (1 ) , Tg (1 ) , Qvec←↩

( end ) , facHP ) ;Qaux = max (0 , min ( Qaux_max , Qdem−Qhp ) ) ;

e l s e % Twr above upper band37 Qhp = 0 ;

Php = 0 ;HP_status = 0 ; % sw i t ch o f f heat pump

40 ende l s e % HP was i n o f f−mode

i f Tb (2 ) < ( Tr_setp − DB ) % T exceeded l owe r deadband43 i f ( controller )

Qvec = Qdem ;e l s e

46 Qvec = Q_range_HP ( Tb (1 ) , Tg (1 ) ) ;end[ Qhp , Php ] = HP_lookup_TLWC_TLWE_Qdem_ext ( Tb (1 ) , Tg (1 ) , Qvec←↩

( end ) , facHP ) ;49 HP_status = 1 ;

e l s eQhp = 0 ;

52 Php = 0 ;HP_status = 0 ; % sw i t ch o f f heat pump

end55 end

endend

The functions Q_range_HP, get_HP_data_ext and HP_lookup_TLWC_TLWE_Qdem_ext arethe same as in the Matlab/Simulink implementation for a single system (seeSections A.1.1 and A.1.3 respectively).

A.2.6 Plot Outputs

% Plo t s the output o f the s imu l a t i o nf u n c t i o n heat_pump_plot3 (v , dstart , dend )

3

APPENDIX A. APPENDIX 47

s = load ( [ v , '_ ' , num2str ( dstart ) ] ) ;fn = fieldnames ( s ) ;

6 s = s . ( fn {1}) ;

figsize = get (0 , ' Sc r e e nS i z e ' ) + [50 ,100 ,−100 ,−200] ;9 f i g u r e ( 'name ' , [ ' Bu i l d i n g : ' , s . args . building , ' , pa ramete r s e t s : ' , ←↩

num2str ( s . args . n ) , ' , s imu l a t i o n p e r i o d : ' , num2str ( s . args .←↩duration ) , 'h , s t e p s i z e : ' , num2str ( s . args . step ) , 'h ' ] , '←↩Out e rPo s i t i o n ' , figsize ) ;

d = dstart ;12 wh i l e d

% p l o t b u i l d i n g and ambient t empe r a tu r e ss u bp l o t ( 3 , 1 , 1 ) ;

15 ho ld on ;f o r i = 1 : s . args . n

p l o t ( s . time , s . Tb ( : , ( 4 * ( i−1)+1) : ( 4* i ) ) ) ;18 i f ( i == 1)

ho ld a l l ;s t a i r s ( s . time , s . Tr_setp ( : , 1 ) ) ;

21 p l o t ( s . time , s . Ta ( : , 1 ) ) ;ho ld on ;

end24 end

i f ( d == dstart )27 t i t l e ( ' Bu i l d i n g and ambient t empe r a tu r e s ' ) ;

x l a b e l ( ' t ime [ h ] ' ) ;y l a b e l ( ' Temperature [ °C ] ' ) ;

30 l e g end ( 'T_{ws} ' , 'T_{wr} ' , 'T_{ f } ' , 'T_{ r } ' , 'T_{r , s e t p } ' , . . .'T_{a} ' , ' Loca t i on ' , ' East ' ) ;

end33

% p l o t ground t empe ra tu r e ss u bp l o t ( 3 , 1 , 2 ) ;

36 ho ld on ;f o r i = 1 : s . args . n

p l o t ( s . time , s . Tg ( : , ( 1 2 * ( i−1)+1) : ( 12* i ) ) ) ;39 end

i f ( d == dstart )42 t i t l e ( 'Ground t empe ra tu r e s ' ) ;

x l a b e l ( ' t ime [ h ] ' ) ;y l a b e l ( ' Temperature [ °C ] ' ) ;

45 end

c l e a r s ;48

d = d + 1 ;i f ( d <= dend && e x i s t ( [ v , '_ ' , num2str ( d ) , ' . mat ' ] , ' f i l e ' ) )

51 s = load ( [ v , '_ ' , num2str ( d ) ] ) ;fn = fieldnames ( s ) ;s = s . ( fn {1}) ;

54 e l s eb reak ;

end57 end

% p l o t power consumpt ion60 s = load ( [ v , '_ ' , num2str ( dstart ) ] ) ;

fn = fieldnames ( s ) ;s = s . ( fn {1}) ;

APPENDIX A. APPENDIX 48

63

s u bp l o t ( 3 , 1 , 3 ) ;

66 d = dstart ;wh i l e d

[ axes , line1 , line2 ] = plotyy ( . . .69 s . time , [ s . Qhp ( : , 1 ) , s . Php ( : , 1 ) , s . Qaux ( : , 1 ) , s . Qdem ( : , 1 ) ] / 1e3←↩

, . . .s . time , sum( s . Php , 2 ) / 1e6 , ' s t a i r s ' , ' s t a i r s ' ) ;

72 i f ( d == dstart )l e g end ( 'Q_{HP} ' , 'P_{HP} ' , 'Q_{aux} ' , 'Q_{dem} ' , ' \Sigma P_{HP} ' , . . .

' Loca t i on ' , ' NorthEast ' ) ;75 end

ho ld on ;78 f o r i = 2 : s . args . n

s t a i r s ( s . time , [ s . Qhp ( : , i ) , s . Php ( : , i ) , s . Qaux ( : , i ) , s . Qdem ( : , i )←↩] / 1e3 ) ;

end81

i f ( d == dstart )t i t l e ( 'Power consumpt ion ' ) ;

84 x l a b e l ( ' t ime [ h ] ' ) ;y l a b e l ( 'Power [kW] ' ) ;s e t ( ge t ( axe s (2 ) , ' Y l ab e l ' ) , ' S t r i n g ' , ' \Sigma P_{HP} [MW] ' ) ;

87 s e t ( line2 , ' LineWidth ' , 2 ) ;end

90 c l e a r s ;

d = d + 1 ;93 i f ( d <= dend && e x i s t ( [ v , '_ ' , num2str ( d ) , ' . mat ' ] , ' f i l e ' ) )

s = load ( [ v , '_ ' , num2str ( d ) ] ) ;fn = fieldnames ( s ) ;

96 s = s . ( fn {1}) ;e l s e

b reak ;99 end

end

Bibliography

[1] M. A. Bianchi. Adaptive Modellbasierte Prädiktive Regelung einer Klein-wärmepumpenanlage. Institute for Dynamic Systems and Control, ETHZürich, Switzerland, 2006.

[2] Bundesamt für Energie BFE. www.bfe.admin.ch, 11.03.2010.

[3] Fachvereinigung Wärmepumpen Schweiz FWS. www.fws.ch, 16.06.2010.

[4] IEA Heat Pump Centre. www.heatpumpcentre.org, 15.03.2010.

[5] S. Koch, M. Zima, and G. Andersson. Active Coordination of ThermalHousehold Appliances for Load Management Purposes. IFAC Symposiumon Power Plants and Power Systems Control, Tampere, Finland, July 2009.

[6] S. Koch, M. Zima, and G. Andersson. Potentials and Applications of Coordi-nated Groups of Thermal Household Appliances for Power System ControlPurposes. IEEE-PES/IAS Conference on Sustainable Alternative Energy,Valencia, Spain, September 2009.

[7] R. E. Rink, V. Gourishankar, and M. Zaheeruddin. Optimal Control ofHeat-Pump/Heat-Storage Systems with Time-of-Day Energy Price Incen-tive. Journal of Optimization Theory and Applications, Vol. 58, No. 1, July1988.

[8] J. Schuberth and H. Kaschenz. Elektrische Wärmepumpen - eine erneuer-bare Energie? Fachgebiet I 2.4 Energiee�zienz, Umweltbundesamt, June2007.

[9] L. Seon-Woo, J. Moon-Jong, J. Bo-In, Y. Chang-Hyun, K. Sang-Gweon,and P. Yoon-Ser. Fuzzy Precompensated PI Controller for A Variable Capac-ity Heat Pump. International Conference on Control Applications, Trieste,Italy, September 1998.

[10] C. Verhelst, D. Axehill, C.N. Jones, and L. Helsen. Study of optimal con-trol formulations for an air-to-water heat pump system. 8th InternationalConference on System Simulation in Buildings, Liège, Belgium, December2010.

49

BIBLIOGRAPHY 50

[11] C. Verhelst and L. Helsen. Model predictive control of ground coupled heatpump systems. Optec Dynamic Optimization Software Meeting, Leuven,Belgium, April 2009.

[12] C. Verhelst, G. Vandersteen, J. Schoukens, and L. Helsen. A linear dynamicborehole model for use in Model based Predictive Control. InternationalConference on Energy Storage, E�stock, Stockholm, Sweden, June 2009.

[13] R. W. Wimmer. Regelung einer Wärmepumpenanlage mit Model PredictiveControl. Institute for Dynamic Systems and Control, ETH Zürich, Switzer-land, 2004.