120
Dynamic Optimization of Power Consumption Anders Thavlov (s011270) Kongens Lyngby 2008

Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

Embed Size (px)

Citation preview

Page 1: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

Dynamic Optimization

of

Power Consumption

Anders Thavlov (s011270)

Kongens Lyngby 2008

Page 2: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

Technical University of Denmark

Informatics and Mathematical Modelling

Building 321, DK-2800 Kongens Lyngby, Denmark

Phone +45 45253351, Fax +45 45882673

[email protected]

www.imm.dtu.dk

Page 3: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

Summary

This thesis formulates a grey-box model of the heat dynamics of an actual lightbuilding, placed at Risø DTU. The model is formulated as a lumped RC-modelin accordance with the commonly used thermal-electrical analogy. The unknownphysical parameters in the model are estimated by maximizing the likelihoodfunction. After model estimation, the model is verified both in the time domainby the autocorrelation function and in the frequency domain by the cumulatedperiodogram. The identified model is then used to determine the optimal heatinput, from electrical heaters,a in the building, due to a given price signal ofelectricity.

Page 4: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

ii Summary

Page 5: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

Preface

This master thesis has been prepared at the Department of Informatics andMathematical Modelling (IMM) at the Technical University of Denmark (DTU),as a part of the requirements for acquiring a Master degree in Engineering. Thework conducted during this thesis represents 30 ECTS points. The project ranfrom October 2007 to March 2008 and was completed cooperation with RisøDTU.

The thesis was supervised by Professor Henrik Madsen, with Associate Profes-sor Niels Kjølstad Poulsen and Senior Scientist Henrik W. Bindner from Risøas external supervisors.

I would like to thank Henrik Madsen and Niels Kjølstad Poulsen for giving metheir time during our many meetings and also Henrik W. Bindner for letting medo my thesis in cooperation with Risø.

In addition I would like to thank my friends and family for their support throughthis project and especially my girlfriend Anette Hansen for being patient withme during the last weeks of the project.

Last I would like to thank Francesco Sottini for his help in deveolping the con-trol software.

Page 6: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

iv

Page 7: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

Contents

Summary i

Preface iii

1 Introduction 1

1.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

1.2 SYSLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

1.3 Problem Formulation . . . . . . . . . . . . . . . . . . . . . . . . . 6

1.4 Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

2 Heat Dynamics Theory 9

2.1 Heat Dynamics . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

2.2 RC-Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

3 The Heat Transfer Model 19

3.1 Modelling Technique . . . . . . . . . . . . . . . . . . . . . . . . . 19

Page 8: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

vi CONTENTS

3.2 Model Approximations . . . . . . . . . . . . . . . . . . . . . . . . 20

3.3 Room Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

3.4 Stochastic Linear State Space Model in Continuous Time . . . . 24

3.5 Stochastic Linear State Space Model in Discrete Time . . . . . . 25

4 Data 27

4.1 FlexHouse Software . . . . . . . . . . . . . . . . . . . . . . . . . . 28

4.2 FlexHouse Hardware . . . . . . . . . . . . . . . . . . . . . . . . . 29

4.3 Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

4.4 PRBS - Pseudo Random Binary Sequence . . . . . . . . . . . . . 34

4.5 Experimental Design . . . . . . . . . . . . . . . . . . . . . . . . . 35

5 Model Estimation 39

5.1 Maximum Likelihood Estimator . . . . . . . . . . . . . . . . . . . 39

5.2 CTSM - Continuous Time Stochastic Modeling . . . . . . . . . . 42

5.3 Principal Components Analysis . . . . . . . . . . . . . . . . . . . 44

6 Model Validation 49

6.1 Validation Using the Autocorrelation Function . . . . . . . . . . 49

6.2 Cumulated Periodogram . . . . . . . . . . . . . . . . . . . . . . . 50

7 Results 53

7.1 Maximum Likelihood Estimates . . . . . . . . . . . . . . . . . . . 53

7.2 Time Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

Page 9: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

CONTENTS vii

7.3 Linear State Space Model in Discrete Time . . . . . . . . . . . . 58

7.4 Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58

7.5 Prediction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

7.6 Model Verification . . . . . . . . . . . . . . . . . . . . . . . . . . 63

8 System Control 65

8.1 Dynamic Control . . . . . . . . . . . . . . . . . . . . . . . . . . . 66

8.2 Energy Price . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67

8.3 Simulation of a Static Controller . . . . . . . . . . . . . . . . . . 69

8.4 Simulation of Dynamic Controller . . . . . . . . . . . . . . . . . . 70

8.5 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72

9 Future Work 75

10 Conclusion 79

A CTSM Results 83

B Application Source Code 87

C Measurement Data 89

D Simulated and Measured Indoor Temperature 91

E Predicted and Measured Indoor Temperature 95

F MATLAB Source Code 101

Page 10: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

viii CONTENTS

G Simulated Indoor Temperature due to Dynamic Controller 105

Page 11: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

Chapter 1

Introduction

1.1 Background

The amount of electricity produced by renewable energy sources cannot be di-rectly controlled. For example the production by wind turbines dependends onhow much the wind blows. If traditional energy production, e.g. by coal, isto be replaced by such an uncontrollable energy production, new methods forenergy usage and distribution are required.

One approach to exploit renewable sources is to store the energy, e.g. by usingbatteries or by producing hydrogen. These methods, however, only allow forapproximately 80 % of the energy to be used after storage. Another approach isto use the energy when it is available. This requires that the demand for elec-tricity can be controlled such that it can be supplied by the present productionof renewable energy. This approach has to involve consumers as active playersin the distribution system. One way to do this, is to let the price of energyvary with the energy production, such that a low production result in a highprice and a high production in a low price. By this approach consumers areencouraged to use the energy at the right time. To begin with heavy energyconsuming products are in focus, e.g. washing machines, dryers and electricalhouse heating. Especially electrical house heating is very energy consuming.

Page 12: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

2 Introduction

Intelligent systems could be developed to control the electrical heating of house-holds such that heating mostly takes place when the production of renewableenergy is high. This would benefit both energy suppliers, consumers and mostof all the environment.

Before such an intelligent system can be utilized, many technical solutions haveto be found, e.g. how to communicate between suppliers and consumers. An-ders Stouge ([Sto07]), Danish Energy Industries Federation, suggests that threerequirements have to be fulfilled

1. Households must have an electricity meter that can be remotely read, suchthat electricity consumption can be read on an hourly basis.

2. Communication methods, that allow highly energy consuming products toswitch off when the production is low, must be developed.

3. Consumers have to be economicaly encouraged to alter their demand.

1.2 SYSLAB

The energy production system of today consist of large centralized power sta-tions using fossil fuels. These are connected in a grid that allows distributionof energy from the production plants to the consumers through a distributionnetwork. This kind of static network only allows distribution of energy in onedirection. Besides centralized power stations, the future energy production sys-tems will consist of many small local energy producing units, e.g. wind turbinesand solar panels. To be able to integrate these into the energy distributionsystem, a much more flexible network has to be developed. Future distributedenergy systems, will allow energy to distributed in many different directions,depending on where the energy is produced. Controlling such a system in real-time, however, is a great task and new methods are needed in order to controlthe flow. The two kinds of networks are depicted in Figure 1.11.

At Risø DTU, SYSLAB 2 has been build to provide an experimental platformfor investigation of distributed energy systems, consisting of both power pro-ducing units and power consuming units.

1http://ec.europa.eu/research/energy/nn/nn rt/nn rt dg/article 1158 en.htm2http://www.risoe.dk/rispubl/risnyt/risnyt2006/1 2006/SYSLAB.htm

Page 13: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

1.2 SYSLAB 3

Figure 1.1: Present and future energy distribution system.

The power producing units in the SYSLAB distribution network are:

• Gaia wind turbine [11 kW ].

• Bonus wind turbine [55 kW ].

• A vanadium battery [15 kW ].

• A diesel generator [48 kW ].

• A solar panel [7 kW ].

where the values in brackets states the maximum energy production.

The power consuming units in the SYSLAB grid are:

• A dump load [75 kW ].

• FlexHouse [≈ 20 kW ].

In the future a hybrid car will also be connected to the system. The aim is tocharge the battery when excess renewable energy is available in the system butalso allowing energy to flow in the opposite direction, that is, sending energy

Page 14: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

4 Introduction

back into the network, for example to FlexHouse. In this way the battery of thecar can be used as a buffer for renewable energy.

As an active player in the SYSLAB network, FlexHouse is of special interest inthis project due to the possibilities for data gathering and heat control.

1.2.1 FlexHouse

FlexHouse is an office building, operating as an active load to the distributedsystem that SYSLAB provides. The energy supply to FlexHouse is producedby the units in the SYSLAB network and is purely electrical. One of the aimsof FlexHouse is to act as an active player in the system and provide services toSYSLAB, e.g. by lowering its power consumption when the energy productionis low. For this to work the SYSLAB network has to, somehow, inform Flex-House, that the energy production is low. As described in Section 1.1, this canbe obtained by sending a price signal to the controller. A platform for simula-tion of price signals has already been integrated into the SYSLAB network. Ifthe energy produced in the SYSLAB grid is to be used optimally, space heatingin FlexHouse has to take place when the renewable energy production is high,i.e. the price is low. Thus, an intelligent controller should try to minimize thetotal energy cost over time, but without exposing the users of the house to greatfluctuations in temperature.

The load that FlexHouse provides to the energy system is due to the electricalcomponents installed in FlexHouse. These are:

• 10 electrical space heaters [1 kW ].

• A refrigerator [0.5 kW ].

• A water heater with storage tank [4 kW ].

• A coffee machine [2 kW ].

• Five air-conditioners [1 kW ].

The size of FlexHouse is approximately 125 m2 divided between eight rooms anda toilet. The rooms have been numbered 0 to 7 to distinguish between them.A layout of FlexHouse can be seen in Figure 1.2 where also the room numbersare shown. Room 1–7 have been arranged as small offices, each with a desk,

Page 15: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

1.2 SYSLAB 5

Figure 1.2: FlexHouse layout

office chair and a computer. The main room, room 0, has been furnished withtables and chairs to accommodate meetings. Moreover room 0 contains a smallkitchen with a refrigerator and a coffee machine. The southern wall in the mainroom is dominated by a large window facade. From the main room access to atoilet is possible, where the water heater is placed. The five air-conditioners aremounted in the five rooms facing south, i.e. room 0–4. Electrical space heatersare mounted in room 1–6, whereas room 0 and 7 each has two heaters mounted.

Even though FlexHouse is arranged as an office building, the building is onlyused approximately once a week by student helpers working on the controllingsoftware running on a server in room 0.

Page 16: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

6 Introduction

1.3 Problem Formulation

At present time simple controlling software has been developed for the electri-cal space heaters in FlexHouse. These are controlled through actuators thatcommunicate wirelessly with the server placed in the main room in FlexHouse.More intelligent controlling software must be developed. Good predictions ofthe temperature in FlexHouse is essential for a controller to work optimal. Thusa model of the heat dynamics of FlexHouse has to be formulated and the phys-ical parameters of the house have to be determined.

The aim of this thesis is to develop a mathematical basis for controlling theelectrical heating in FlexHouse. First, a dynamic model of the heat flow in Flex-House is established. Then a number of experiments are conducted in FlexHousewith the purpose generating data for estimation of the physical parameters inthe model of the heat flow. When the parameters have been estimated, themodel should be validated. After successful model validation a control strategy,which optimizes the cost of the energy consumed by the electrical heaters basedon a given price signal, should be found. The control strategy should be ableto maintain a temperature around a given reference specified by the residentsof the house.

1.4 Outline

In Chapter 2 the physics behind heat dynamics are stated. In Chapter 3 themechanisms behind heat flow and heat accumulation are used as building blocksto formulate a model of the heat dynamics. The model is formulated as flowof electric charge, i.e. current, in an electrical network. This model type iscalled a lumped RC-model with equivalent thermal parameters. In Chapter 4the possibilities of gathering data in FlexHouse described along with a descrip-tion of how the data was gathered. Chapter 4 also contains a description ofhow the electrical space heaters in FlexHouse can be controlled. An optimalstrategy for controlling heat input, by use of PRBS-signals is also explained inthis chapter. Chapter 5 describes a method for finding the most likely estimatesof the unknown parameters in the model based on FlexHouse performance data.Methods for validation of the model of the heat dynamics, based on the one stepprediction residuals, are described in Chapter 6. In Chapter 7 the results of theestimated parameters are stated and discussed. The estimates are used for sim-ulations of the indoor temperature in FlexHouse, which are compared to the

Page 17: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

1.4 Outline 7

actual measured temperature. This chapter also determines the time constantsof the system. In Chapter 8 a cost function associated with the space heating ofFlexHouse is formulated. The dynamic control of the temperature in FlexHousecan then be considered as a minimization problem of the cost function over agiven horizon. In Chapter 9 the future work related to this project is described.Chapter 10 contains the conclusion of this thesis.

Page 18: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

8 Introduction

Page 19: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

Chapter 2

Heat Dynamics Theory

Before a realistic mathematical model of the heat flow in FlexHouse can bederived, the mechanisms behind heat transfer must be considered. By heattransfer is meant the exchange of energy due to temperature differences, i.e.energy flow due to temperature differences.

In the first section, the materials ability to store heat is described. Here theequation for heat capacity is stated. In Section 2.1.2 the three mechanismsbehind heat transfer are described and the mathematical model for the flow isderived for each type of heat transfer. When the equations of the heat dynamicshave been derived, these can be used as building blocks in a model that describesa system with both conduction and heat capacity. This is used in Section 2.2,where the heat flow is modeled as flow of electric charge in an electrical networkwith capacitors and resistors. This type of electrical network is called an RC-network.

Page 20: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

10 Heat Dynamics Theory

2.1 Heat Dynamics

Theory of heat dynamics describes the flow of energy, due to temperature dif-ferences. According to the laws of thermodynamics the flow is always towardsareas with low energy, i.e. in the direction of the negative temperature gradient.In this way a system always tries to equalize the temperature.

2.1.1 Heat Capacity

Heat capacity describes a materials capability to accumulate heat. When energyin form of heat is added to a material, it will lead to an increase in temperature.If an increase in temperature, dT , is observed after adding infinitesimal heat,dQ, to a system, the specific heat capacity of the system, c(T ) is given by

dQ = mc(T )dT = C(T )dT (2.1)

where m is the mass of the medium and C(T ) is the total heat capacity attemperature T . Dividing Equation 2.1 with infinitesimal time, dt, gives thetemperature development in time, due to energy flow into the system, i.e.

dQ

dt= Q = mc(T )

dT

dt= C(T )

dT

dt(2.2)

As indicated in Equation 2.2 the total heat capacity is a function of temperature.In the following, however, the total heat capacity is assumed to be constant, i.e.C(T ) ≈ C. This is reasonable since the interval, in which the temperature inFlexHouse is to be controlled, is rather small, i.e. within 3− 4 ◦C. Without lossof generality the total heat capacity will be used to model the heat capacitiesin FlexHouse, instead of the specific heat capacity.

Page 21: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

2.1 Heat Dynamics 11

2.1.2 Heat Transfer

Heat transfer can occur due to three different mechanisms

• Conduction

• Convection

• Radiation

Heat transfer is always from areas of higher temperature toward areas of lowertemperature and is in general a combination of the three stated mechanisms.

2.1.2.1 Conduction

Any medium (solid, liquid or gas) having a temperature gradient will conductheat. The conduction of heat is due to interaction between particles in themedium. When a homogeneous medium is conducting heat, the energy flow perunit area is proportional to the temperature gradient in the medium, i.e.

1

A

dQ

dt=

1

AQ = −λ∇T = −λ

[

∂T

∂x;∂T

∂y;∂T

∂z

]

(2.3)

where A is the surface area through which the energy flows, λ is the thermalconductivity of the medium and Q is the heat flow. The minus sign ensuresflow in the direction of the negative gradient. The conductivity is in generaldependent on several physical factors, e.g. temperature and moisture, but isassumed to be constant in the following.

The change in temperature is described by the diffusion equation. When noheat sinks or sources exist in the conducting medium, the diffusion equation isgiven by

dT

dt=

λ

cρ∇2T =

λ

(

∂2T

∂x2+

∂2T

∂y2+

∂2T

∂z2

)

(2.4)

where c is the specific heat capacity and ρ is the density of the conductor.

When the heat flow in a wall is considered, it can be approximated to be inthe normal direction of the wall only, i.e. the x-direction. This approximation

Page 22: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

12 Heat Dynamics Theory

Figure 2.1: Heat flow due to constant temperature gradient in a heat conductor.

is reasonable far away from the corners where the flow is more complex. Thisreduces Equation 2.3 and 2.4 to one dimension. Assuming stationary condition,T = 0, it can be seen from Equation 2.4 that the temperature gradient is con-stant. The temperature gradient is given by the temperatures on the boundariesand the width of the wall, i.e.

dT

dt= T = 0 ⇒ d2T

dx2= 0 ⇒ dT

dx= k =

T2 − T1

d(2.5)

where k is a constant, T1 and T2 are the temperatures on each side of the walland d is the width of the wall. The heat flow due to conduction is illustrated inFigure 2.1.

Equation 2.5 inserted into Equation 2.3 gives

1

AQ = −λ

dT

dx= −λ

d(T2 − T1) ⇔ Q =

λA

d(T1 − T2) (2.6)

where Q is the flow from 1 to 2. λA/d is sometimes referred to as the UA-value of the material which is a parameter that describes a materials ability toconduct heat.

If the conductor consists of more than one homogeneous parallel layer, which isthe case for most walls, the flow through a layer, i, is given by

Page 23: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

2.1 Heat Dynamics 13

1

AQi =

λi

di(Ti − Ti+1) (2.7)

where Ti and Ti+1 are the temperatures on each side of layer i. Assuming thatthe heat flow in the wall is stationary, the flow through each layer is the same,i.e. Qi = Q for all i. Equation 2.7 can be rewritten to

Ti = Ti+1 +di

λiAQi for i = 1 · · ·N − 1 (2.8)

and used recursively to find the flow due to the temperatures T1 and TN on theboundaries.

T1 = T2 +d1

λ1

1

AQ = T3 +

d2

λ2

1

AQ +

d1

λ1

1

AQ = T3 +

(

d2

λ2+

d1

λ1

)

1

AQ

= TN +N−1∑

1

(

di

λi

)

1

AQ = TN +

r

AQ ⇔

Q =A

r(T1 − TN) = (2.9)

where r is the heat resistance of the wall and determined by

r =

N−1∑

1

(

di

λi

)

(2.10)

Here the UA-value is given by A/r. Without loss of generality the resistance,r/A, can be modeled as a total resistance, R, against heat conduction.

Equation 2.9 shows that the heat flow through a wall, build from several ho-mogeneous layers, is approximately proportional to the temperature differenceacross the wall.

2.1.2.2 Convection

Energy transfer by convection is due to a combination of conduction and masstransfer. When a fluid is adjacent to a solid material, heat is transferred betweenthem. If the fluid has a lower temperature than the solid, heat is transferredfrom the solid to the fluid by conduction. This increases the temperature of

Page 24: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

14 Heat Dynamics Theory

Figure 2.2: Resistance to heat by convection

the fluid near the wall, which makes the fluid rise and this is replaced by newfluid. The opposite can also happen where warm fluid transfer heat to the solidwhich sinks down and is replaced by new fluid. The first example is illustratedin Figure 2.2.

Convection is divided into two categories

• Forced convection

• Free convection

Forced convection is the result of forced fluid flow, e.g. with fans or pumps. Infree convection the fluid flows naturally due to density differences in the fluid.For the heat transfer in FlexHouse only free convection will be regarded as amechanism for exchanging heat between the indoor air and walls.

The heat flow by convection is given by Newton’s law of cooling

Q = hA(Ts − T∞) (2.11)

where h is the convection heat transfer coefficient, A is the area of the shared

Page 25: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

2.1 Heat Dynamics 15

surface, Ts is the temperature of the solid and T∞ is the temperature of thefluid far from the solid. A typical value of h is 2 − 25 W/(m2 ◦C), [Cen99], forfree convection of gases.

Equation 2.11 can be written in the same form as Equation 2.9, where hA = 1/R.Convection can therefore be modeled in the same way as conduction, i.e. witha resistance against heat transfer between the air and walls.

2.1.2.3 Radiation

Heat exchange by radiation occurs between all objects, having different tem-perature, that are in optical contact, e.g. radiation is the mode by which heatis transferred from the sun to the earth. The energy is emitted in the form ofelectromagnetic waves and therefore does not need a medium to propagate in.The energy emitted by a surface is given by

Q = εσAsT4s (2.12)

where ε is the emissivity of the surface, σ = 5.670 · 10−8 W/(m2K4) is Stefan-Boltzmann’s constant, As is the area of the surface that radiates the energyand Ts is the surface temperature. In general heat transfer by radiation is verycomplex to calculate, since it involves integration over visible surfaces. The heatexchange, however, between a body and a totally surrounding surface can easilybe calculated

Q = εσAs

(

T 4s − T 4

)

(2.13)

Heat exchanged by radiation between inner surfaces in FlexHouse, is in thefollowing assumed to be so small that it can be neglected in the heat transfermodel. This is a reasonable assumption, since the surface temperature differ-ences between the walls are relatively small. The solar radiation, however, hasa big impact on the temperature inside buildings and therefore solar radiationhas to be a part of the heat transfer model. The heat flow through a windowdue to solar radiation can be described by

Q = AwΦs (2.14)

where Aw is the effective window area and Φs is the outdoor solar radiation inW/m2.

Page 26: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

16 Heat Dynamics Theory

2.1.2.4 Ventilation

Ventilation does not directly cause heat transfer, but due to mass transfer heatis transferred. For most old buildings, like FlexHouse, the house envelope is byno means airtight and the indoor temperature is therefore very dependent onthe speed and direction of the wind. The total heat exchange due to ventilationis given by

Q = vc (2.15)

where v is the amount of ventilated air and c is the specific heat capacity of air.

As with convection, ventilation can either be free or forced. For the heat transferin FlexHouse only free ventilation is regarded as mode of exchanging heat be-tween the indoor and outdoor air assuming that the air-conditioners are turnedoff. The amount of free ventilated air is very complex to calculate and is depen-dent on many factors, e.g. leakage area, wind speed and direction, moreover theamount of ventilated air is by no means linear. In previous research conductedin FlexHouse ([Ara]) the following relation was proposed for the amount of ven-tilated air

v =∑

(

Al

A∆T + BV 2)

(2.16)

where the sum is over all sides of the building, Al is the effective leakage area,A is the stack coefficient, B is the wind coefficient, V is the wind componentand ∆T is the temperature difference between the indoor and the outdoor tem-perature.

Due to the age off FlexHouse, the house envelope cannot be assumed to beairtight. [Ara] estimates the heat loss, in FlexHouse, due to ventilation to beapproximately 30% of the total heat loss. This heat loss has to be accountedfor in the model of the heat flow. In [Ara] Equation 2.16 is approximated to beproportional to the temperature difference across the wall, i.e. ventilation losscan be approximated with

Qi = k (Ti − Ta) =1

Ra(Ti − Ta) (2.17)

where Ti is the indoor air temperature, Ta is the outdoor temperature and Ra

is the resistance to heat transfer directly to the outside. This approximationholds for low wind speed, but if the wind speed is high (> 5 m/s, [Fri06]) the

Page 27: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

2.2 RC-Network 17

heat transfer becomes nonlinear.

From this section it is seen that conduction, convection and ventilation, approx-imately, can be modeled as a resistances against heat transfer. The energy flowinto the building due to radiation can be directly calculated using Equation 2.14if the outdoor solar radiation is known.

2.2 RC-Network

From the previous section several similarities with electrical systems are seen.For example is the equation for the heat capacity, Equation 2.2, of the sameform as the flow of electric charge in a capacitor

i(t) =dQ

dt= C

dV

dt(2.18)

Analogously the heat flow in Equation 2.9, 2.11 and 2.17 can be described asflow of electric charge in a resistor, where the temperature differences are inter-preted as potential differences.

Due to the similarities between heat flow and current flow, a model of heatdynamics can be modelled with an electrical network of resistors and capaci-tors, where the heat flow corresponds to flow of electrical charge, i.e. current.This model type is called a lumped RC-model with the constants Rj and Cj asequivalent thermal parameters. An example of such a system is illustrated inFigure 2.3.

The first order system depicted in Figure 2.3, could be used as a very simplemodel of the heat flow of a single room. From the diagram, it can be seen thatthe indoor temperature, Ti, is linked to the outdoor temperature, Ta, througha resistor, Ra. Moreover it is seen that the indoor temperature receives a heatinput, Φh, e.g. from a heater. This example is very simple but illustrates theconcept of heat flow modeled in RC-networks. The diagram in Figure 2.3 couldalso be used to model the water temperature in an electric kettle receiving heatfrom a heating element.

Page 28: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

18 Heat Dynamics Theory

Figure 2.3: RC-network for flow in a simple single room model.

Page 29: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

Chapter 3

The Heat Transfer Model

In this chapter a model of the heat dynamics of FlexHouse is formulated. Themodel is formulated as a distributed model approximated by a lumped model.

In the first section different modelling techniques are discussed and then someapproximations for the model are stated. In Section 3.3 the actual model isformulated as a deterministic linear state space model in continuous time. InSection 3.4 the model is reformulated as a stochastic linear state space model incontinuous time. By integration the model is formulated as a stochastic linearstate space model in discrete time in Section 3.5.

3.1 Modelling Technique

When formulating a model for the heat dynamics of buildings, three differ-ent approaches can be used. The first method is the traditional approach, orthe deductive approach, where knowledge about physical characteristics of thebuilding are used to formulate a model. Equation 2.10 could, for example, beused together with data of building materials to estimate the resistance againstheat transfer to the outside through the outer walls. This type of model is calleda white-box model. However, such a method requires many simplifications and

Page 30: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

20 The Heat Transfer Model

the accuracy of the model is therefore very hard to predict. Another approachis the inductive approach, where a black-box model is formulated. In black-boxmodels experimental data is used statistically to derive a model. The last ap-proach is the grey-box model. This type of model is a combination of the white-and black-box model, where the model is formulated from physical knowledgeand experimental data is then used statistically to estimate the parameters inthe model. The advantage of this type of model, is that it combines a physicalderived model with experimental data. Due to the use of experimental data andthe physical formulated model it is easy to interpret the estimated parametersin the model.

A grey-box model has been chosen as the method for formulating a model forheat dynamics of FlexHouse due to the easy physical interpretation of modelparameters and the good possibilities of collecting data in FlexHouse. Further-more this approach has shown good results in [MH95] and [MNSW].

3.2 Model Approximations

Due to complexity of the heat flow in FlexHouse, approximations of the heatdynamics of FlexHouse have to be formulated. In the remainder of this thesisthe following approximations are made.

• The heat capacity of the house envelope, i.e. walls and floor, is concen-trated in a thin layer inside the walls.

• The heat capacity of the inner wall is concentrated in a thin layer insidethe walls.

• The toilet is assumed to be a part if the main room.

• The temperature of the air is homogeneously distributed in the house.

• The surface temperature of the walls is the same as in the heat accumu-lating layer.

• The air-conditioners are assumed to be turned off.

• Doors and windows are assumed to be closed.

• The heat input from the heaters only affects the indoor air temperature.

• The model parameters does not vary in time.

Page 31: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

3.3 Room Model 21

3.3 Room Model

The model of heat dynamics of FlexHouse is formulated as one large room ex-changing heat with an ambient environment. This crude approximation is nec-essary, since the building performance data, collected in FlexHouse, has shownto be insufficient to estimate the amount of parameters associated with a moreadvanced model.

In previous research, [MH95] and [Mad85], it is argued that at least a secondorder dynamic model is needed to describe both the short and long time varia-tions of the indoor temperature in buildings. However, during the first modelsestimation it was evident that three time constants were needed to describe theheat flow in FlexHouse. Therefore three states are used to describe the develop-ment of the indoor temperature in FlexHouse. The first state is the indoor airtemperature, Ti, the second state is the temperature of heat accumulating layerin the building envelope, Tom and the third state is the temperature in the heataccumulating layer in the inner walls and floor, Tim.

The inner part of FlexHouse receives energy from radiation through the win-dows. Assuming that the energy flow through the windows due to solar radiationis not absorbed by the heat accumulating layer in the outer walls, the energyis distributed between the heat accumulating layer in the inner walls and theindoor air. If p is the part of the solar radiation which directly affecting Tim,the energy flow due to solar radiation is given by

Qim = AwpΦs

Qi = Aw (1 − p)Φs

where Qim is the heat flow into the inner wall heat accumulating layer, Aw isthe effective window area of FlexHouse and Qi is the heat flow into air. Theenergy balance for the heat accumulating layer in the inner walls can now beformulated as

CimdTim

dt= hA (Ti − Tim) + Qim =

1

Ri(Ti − Tim) + AwpΦs (3.1)

where Cim is the total heat capacity of the inner walls, Φs is the solar radiationand Ri is total resistance against heat flow by convection between the innerwalls and the indoor air.

Page 32: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

22 The Heat Transfer Model

The house envelope exchanges heat by convection to both the inside and theoutside of the building. This can be formulated as

ComdTom

dt=

1

Rim(Ti − Tom) +

1

Ram(Ta − Tom) (3.2)

where Com is the total heat capacity of the heat accumulating layer in the houseenvelope, Rim and Ram are the total resistances against heat flow by convec-tion to the inside and outside air respectively and Ta is the ambient (outdoor)temperature.

The indoor air exchanges heat to the outside due to ventilation and by conduc-tion through the windows. Moreover, there is a heat exchange by convectionbetween the air and both inner and outer walls. The indoor air also receivesenergy from solar radiation and the electrical space heaters. From this the equa-tion for the heat balance of the indoor air can be written as

CidTi

dt=

1

Ra(Ta − Ti) +

1

Ri(Tim − Ti) +

1

Rim(Tom − Ti) + Aw (1 − p)Φs + Φh

(3.3)

where Ci is the total heat capacity of the indoor air, Ra is the total resistanceagainst heat flow to the outside, through windows and due to ventilation, andΦh is the energy input from the electrical heaters.

A model of the flow can be seen in Figure 3.1 where the equivalent RC-networkis also depicted.

Equations 3.1, 3.2 and 3.3 can be written with matrix notation

Page 33: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

3.3 Room Model 23

Figure 3.1: Heat flow diagram and RC-network model of the heat dynamics ofFlexHouse.

dTi

dt

dTim

dt

dTom

dt

=

−1Ci

(

1Ra

+ 1Ri

+ 1Rim

)

1RiCi

1RimCi

1RiCim

− 1RiCim

0

1RimCom

0 −1Com

(

1Ram

+ 1Rim

)

Ti

Tim

Tom

+

1raCi

Aw(1−p)Ci

1Ci

0 AwpCim

0

1RamCom

0 0

Ta

Φs

Φh

(3.4)

This type of equation is a deterministic linear state space model in continuous

Page 34: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

24 The Heat Transfer Model

time and can be formulated as

dT

dt= AT + BU ⇒ dT = ATdt + BUdt (3.5)

where T = [Ti, Tim, Tom]′ is the state vector and U = [Ta, Φs, Φh]′ is the inputvector. A defines how the current state affects future states and B defines howinput enters the system.

For other models of the heat dynamics of buildings see [MNSW].

3.4 Stochastic Linear State Space Model in Con-

tinuous Time

Equation 3.4 describes a deterministic system where future states can be pre-cisely predicted if the input and the initial state vector are known. Due toapproximations and unknown disturbances in the system, e.g. from wind, thisidealization cannot be assumed to be correct. Thus an additive noise term,dω(t), is introduced to describe the variation between the model temperatureand the actual temperature. This leads to the stochastic linear state spacemodel in continuous time

dT = ATdt + BUdt + dω(t) (3.6)

where ω(t) is a stochastic process describing the variations from the Equation3.4. ω(t) is in the following assumed to be a process with independent incre-ments, i.e. a Wiener process, with incremental covariance R1.

Unfortunately it is not all states that can be measured, i.e. the temperatures ofthe heat accumulating layers. Therefore a vector of measurable states is intro-duced. This is defined by

Tr = CT + DU + e(t) (3.7)

where e(t) is the measurement error. It is assumed that e(t) is normal dis-tributed white noise with zero mean and variance Re. Furthermore it is as-sumed that e(t) and ω(t) are mutually uncorrelated. C and D defines how the

Page 35: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

3.5 Stochastic Linear State Space Model in Discrete Time 25

measured states are influenced by the state and input respectively. The inputhas no direct influence on the measured air temperature in FlexHouse, thereforeD = 0. C is used to select the states that are measured. For the heat dynamicsmodel only the indoor air temperature is measured, i.e. C = [1 0 0]. The mea-sured indoor temperature is thus given by

Tr = [1 0 0]

Ti

Tim

Tom

+ e(t) = Ti + e(t) (3.8)

3.5 Stochastic Linear State Space Model in Dis-

crete Time

In the previous section it was found that the model of the heat flow in Flex-House can be written as a stochastic differential equation. The measurements,however, are collected in discrete time and therefore a discrete time formulationof Equation 3.6 is needed for estimation of the unknown parameters in A. Thesolution to the differential equation in Equation 3.6 can analytically be foundto ([Pou07])

T(t) = exp(A(t − t0))T(t0) +

∫ t

t0

exp(A(t − s))BU(s)ds

+

∫ t

t0

exp(A(t − s))dω(s) (3.9)

where

expA =

∞∑

k=0

1

k!Ak = I + A +

1

2A2 + · · · (3.10)

Given the state vector at time t, T(t), the new state vector at time t+τ is givenby

T(t + τ) = exp(A(t + τ − t))T(t) +

∫ t+τ

t

exp(A(t + τ − s))BU(s)ds

+

∫ t+τ

t

exp(A(t + τ − s))dω(s) (3.11)

Page 36: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

26 The Heat Transfer Model

Assuming that the input, U(t), is constant in the sample interval [t; t + τ [,Equation 3.11 can be reformulated to

T(t + τ) = exp(Aτ)T(t) −∫ 0

τ

exp(Ar)BdrU(t)

+

∫ t+τ

t

exp(A(t + τ − t))dω(s)

= exp(Aτ)T(t) +

∫ τ

0

exp(Ar)BdrU(t)

+

∫ t+τ

t

exp(A(t + τ − s))dω(s) (3.12)

where the substitution r = t + τ − s has been used. Defining

Φ(τ) = exp(Aτ)

Γ(τ) =

∫ τ

0

exp(Ar)Bdr (3.13)

v(t; τ) =

∫ t+τ

t

exp(A(t + τ − s))dω(s)

Equation 3.12 can then be written as

T(t + τ) = Φ(τ)T(t) + Γ(τ)U(t) + v(t, τ) (3.14)

Assuming that ω(t) is a Wiener process, v(t; τ) becomes normally distributedwhite noise with zero mean and covariance

R1(τ) = E[v(t; τ)v(t; τ)′ ] =

∫ τ

0

Φ(s)R1Φ(s)′ds

=

R11 0 00 R22 00 0 R33

(3.15)

If the sampling time is constant, the time scale in Equation 3.14 can be trans-formed such that the sampling time is equal to one time unit, i.e.

T(t + 1) = ΦT(t) + ΓU(t) + v(t) (3.16)

This formulation can be used for estimation of the unknown parameters inEquation 3.4 without loosing the physical interpretation of the parameters.

Page 37: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

Chapter 4

Data

Several experiments were conducted in FlexHouse during the period from Febru-ary 13th 2008 to April 1st 2008. Unfortunately some of the experiments faileddue to hardware problems, but four experiments were conducted without anysignificant problems. The purpose of the experiments were to generate buildingperformance data, that could be used to estimate the unknown parameters inEquation 3.4.

The first section in this chapter describes the software that was developed dur-ing this project. The main purpose of the software has been to control theheat input from the heaters and to store measurements. Section 4.2 describesthe hardware in FlexHouse. In Section 4.3 it is described how the data werecollected and in Section 4.4 Pseudo-Random Binary Sequence signals (PRBS)are explained. This is used in Section 4.5 to design the heat input from theelectrical heaters for six different experiments conducted in FlexHouse.

Page 38: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

28 Data

4.1 FlexHouse Software

Two applications were developed during this project. The purpose of the firstapplication, JavaPowerFlexHouse, is to control the states of FlexHouse and tostore measurements from the inner part of FlexHouse. The second application,WeatherStation, is used to get measurements from the outdoor environment.Both applications were developed in Java.

4.1.1 JavaPowerFlexHouse

In cooperation with Francesco Sottini the application, JavaPowerFlexHouse(JPFH), was developed to control the heating and lighting in each room inFlexHouse. The application communicates through a LabVIEW application tosensors and actuators placed around in FlexHouse.

The first version of JPFH had a simple heating controller implemented, whichturned on the heaters if the temperature in a room dropped below a definedthreshold. The second version added support for synchronous control of heatersthrough predefined PRBS-signals (Section 4.4). This version also added supportfor storing measurements in a log-file on the server. The second version of JPFHshowed to be very unstable due to the LabVIEW application having problems inprocessing the messages to the actuators and from the sensors. This resulted inlarge lags up to an hour and after some time the application would stop. In thethird version some corrections were made to the LabVIEW application and thenumber of messages sent from JPFH were reduced. This increased stability andsolved the problem with the large lags in communication. The system, however,still showed some instabilities due to hardware problems. This resulted in someof the measurements being lost. Unfortunately the hardware could not be re-placed and some of the measurements are therefore affected by this. The latestversion of JPFH still only allows the heaters to be synchronously controlled,therefore only one PRBS-signal is used to control the heaters. The main reasonwhy single heater control was not implemented was primarily due to the limi-tation of messages being processed by the hardware.

Page 39: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

4.2 FlexHouse Hardware 29

4.1.2 WeatherData

To be able to measure and store external data a weather station has been raisedon the east side of FlexHouse. The data from the weather station is sent througha telephone line (RS-232) to the server in the main room. The WeatherDataapplication interprets an incoming bit stream and extracts the needed data.When the measurements have been extracted, the data is passed on to JPFHthat handles the logging of the measurements on the server.

Source code from WeatherData.java can be found in Appendix B.

4.2 FlexHouse Hardware

The hardware installed in FlexHouse enables the temperature state of each roomto be monitored and controlled. The central point in the system is JPFH, thatruns on the server placed in the main room of FlexHouse. From the applicationit is possible to communicate wirelessly with the various sensors and actuatorsplaced around in FlexHouse. A layout of FlexHouse can be seen in Figure 4.1,where heat sensors, electrical heaters and windows are marked.

The following sections first describe the sensors which monitors the temperaturestates and secondly the actuators that are used to control the state of each room.

4.2.1 Hardware for Measurements

Several types of sensors have been installed in FlexHouse which communicateswirelessly with the server in FlexHouse. Each room, except the toilet, containsthe following sensors.

• Heat Sensor

• Door Sensor

• Window Sensor

• Motion Sensor

Page 40: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

30 Data

Figure 4.1: FlexHouse layout.

• Light switches

A heat sensor is mounted in each room, these play a key role in this projectby monitoring the indoor temperature state, i.e. Ti, in FlexHouse. The sensorsare of the type EnOcean SR-04 and are mainly driven by small solar panelsbuild into the sensors. In lack of light, power is provided by a battery. Theheat sensors have a resolution of 0.15 K and an accuracy of 0.5 K. The temper-ature cannot be read directly from the sensors but the measured temperatureis transmitted regularly to the server. According to the datasheet for the sen-sors1 temperature measurements should be transmitted every 100th second ifchanges are more than 0.8 K and every 1000th second otherwise. However, dur-ing the periods of measurements the heat sensors showed a poor performance,sometimes with more than an hour between transmissions. An example of theperformance of the heat sensors can be seen in Figure 4.2.

Unfortunately nothing could be done to increase performance of the heat sen-sors, therefore the temperature is in the following assumed to be constant untila new temperature measurement has been received. Unfortunately this crudeapproximation leads to large estimation errors on the unknown parameters.

1http://www.thermokon.de/downloads/service/44/Produktblatt SR04 10.pdf

Page 41: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

4.2 FlexHouse Hardware 31

Figure 4.2: Temperature measurements from the sensor in room.

A motion sensor has been mounted in each room and if a person is present asignal is sent to the server. For each measuring interval JPFH logs if a personhas been present. Although the data is available it is not a part of the modelformulated in Chapter 3, further work could extend the model to include infor-mation about presence.

Every door and window in FlexHouse has a sensor attached. As with the motionsensors it is logged for each interval if a door or a window has been open. Thisinformation is not used in this work, but could be used in an extended model.

Light switches are simply used to turn the light on and off. When a switch ishit JPFH is notified, which then tells the light actuator to change the state ofthe light source. The data from the switch sensors is not stored neither could itbe used to improve the heat transfer model. The data from the switches couldbe used in conjunction with the motion sensors to turn off the light if no one ispresent.

4.2.2 Weather Data

As described in Section 4.1.2, weather data were collected directly from outsideFlexHouse. The local weather data ensures optimal condition for measuring the

Page 42: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

32 Data

input data, i.e. Ta and Φs. Following weather data can be measured from theweather station

• Global radiation

• Outdoor (ambient) temperature

• Wind speed

• Wind direction

The weather station is placed 4 m above ground which is not the official stan-dard way to measure weather data. However, because local data is prioritisedand to get clear of buildings the measurements from the weather station areassumed to be a good approximation to standard data. Unlike the heat sensors,measurements from the weather station could be read at any time and showedno deviation from what is expected. Figure 4.3 shows a series of weather mea-surements from a day in February.

Figure 4.3: Weather data from February 28th 2008.

Wind data is not a part of the model derived in Chapter 3, but if a nonlinearmodel is to be derived it would be very relevant to add information about windconditions, especially for a house like FlexHouse for which the heat consumptionis very dependent on the wind.

Page 43: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

4.3 Data 33

4.2.3 Controlling Hardware

Actuators have been installed for most light and heat sources in FlexHouse.As stated in Section 4.2.1, the light actuators cannot improve the heat transfermodel. The actuators for the heaters, however, are of great importance sincethe heat input from the space heaters is the only input to Equation 3.4, that canbe controlled. The actuators for the space heaters are controlled from JPFHand hence support for control by PRBS-signals was implemented here.

The heaters are powered by electricity, which makes it easy to control the heatinput very precisely compared to hot water systems. The specification for theheaters states the effect to be 1.0 kW . This was verified by measuring the cur-rent flow to a heater. Here the current was found to be I = 4.6 A. Assuming theheater acts as a linear resistor, the effect is given by P = UI = 220 V · 4.6 A =1012W , which is consistent with the specification. In the following it is assumedthat the effect of each heater is 1.0 kW .

4.3 Data

Six experiments were conducted in FlexHouse during the period from February13th 2008 to April 1st 2008. Due to uncertainties in measurement time, thedata from the two first experiments have been discarded. Data from the follow-ing four experiments were acceptable but still some parts of the measurementswere lost due to application failure. For all experiments a sampling intervalof 5 minutes have been used. A typical series of measurements can be seen inFigure 4.4

From the figure it can be seen that the air temperature shows a time delay ofapproximately 20 minutes to heat input. That effect is probably due to the timeit takes to heat up the heaters. A sub model of the heat capacity of the heaterscould be used to extend the model in Equation 3.4. From the figure it is alsoseen that there is great variation in the measured solar radiation. This effect isdue to the variation in the cloud cover. Moreover the effect from solar radiationcan clearly be seen between measurement 75 to 120, where the temperature inFlexHouse rises even though the heaters are turned off.

All measurements were written as comma-separated values in a log-file on the

Page 44: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

34 Data

Figure 4.4: Temperature, heat- and radiation input from February 28th 2008

server. The log-file is a normal text file containing ASCII characters. Every5 minutes it was checked for each room, if a new temperature reading had beenreceived. If so the new temperature measurement was saved with a timestampin the log-file, otherwise the last received measurement was saved instead. Thestates of the motion-, window- and door-sensors were also saved in the log file.When all the measurements from FlexHouse had been logged, values from theweather station were collected and written to the log-file as well.

A typical output from a data file can be seen in Appendix C.

4.4 PRBS - Pseudo Random Binary Sequence

The input from the heaters is very important since it is the only input that canbe controlled. It is therefore crucial that the signal controlling the heat input isdesigned such that optimal conditions for estimation of the system parametersare achieved. A widely used method in the time domain is to use PRBS-signals,which is a deterministic signal with white-noise properties. Moreover PRBS-signals show no correlation with other external signals, e.g. weather data. Thesignal shifts between two levels and may only switch from one level to the otherat time t = 0, λ, 2λ, . . . , where λ is the clock period or the basic period of thesignal. The strength of PRBS-signals is that the signal is deterministic, there-

Page 45: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

4.5 Experimental Design 35

fore the signal can be designed before an experiment; also the experiments arerepeatable. PRBS-signals are periodic with period T0 = Nλ, where N is anodd integer. An example of a PRBS-signal with N = 63 and λ = 2, and thecorresponding autocorrelation function can be seen in Figure 4.5.

Figure 4.5: PRBS-signal and corresponding autocorrelation function.

One way to generate PRBS-signals is based on the maximum-length sequence forwhich N = 2n−1, where n is an integer. For a full description see [God80]. Thelongest interval in the sequence where the signal is either on or off is given by nλ.

PRBS-signals have been chosen to control the space heaters in FlexHouse, dueto the properties of the signal, moreover the signal corresponds well with theelectrical space heaters in FlexHouse, since these easily can be controlled by abinary signal.

4.5 Experimental Design

The design of the heat input signal is very important if good estimates are tobe achieved. Therefore the signal should be designed such that the system isexcited in areas where the time constants are located. The estimation of timeconstants for the model of the heat dynamics of FlexHouse is based on the re-sults found in [MS] and [MNSW], where the short and long time constant werefound to be τ1 = 26 minutes and τ2 = 154 hours respectively. However, theseresults are for a test cell which is extremely airtight and well insulated. For anold house, like FlexHouse, the time constants of the inner and outer walls can

Page 46: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

36 Data

be assumed to be much smaller. Therefore the short time constant is expectedto be around 30 minutes and the long time constants to be around 50 hours.

To excite the system in the area of the small time constant, λ should be chosento be around 30 minutes. To excite the system in the area of the long time con-stants, nλ, i.e. the longest interval where the signal is either on or off, shouldbe chosen to be around 50 hours. Unfortunately, due to the usage of FlexHouse,only 6 consecutive days of measurements are possible if noise from people is tobe avoided. This restricts the PRBS-signal to be less than 150 hours and it hastherefore been chosen to lower nλ to be 12 and 24 hours, when designing theheat input. Table 4.1 shows the design parameters for each experiment con-ducted in FlexHouse.

Experiment Measurement id. n λ N nλ T0 = Nλ Heaters

1 080201 6 2 h 63 12h 126h 102 080206 6 2 h 63 12h 126h 103 080213 6 2 h 63 12h 126h 104 080227 6 2 h 63 12h 126h 75 080305 6 4 h 63 24h 252h 2

6 20m 63 2 h 21 h 76 080326

5 3 h 31 15h 93 h 7

Table 4.1: Design parameters for PRBS-signals for measurements in FlexHouse

In the first two experiments all ten space heaters were controlled with the de-signed PRBS-signal. However, due to problems with the wireless communicationthe measurements collected were discarded for both experiments. The commu-nication problems caused large time lags between the messages being send tothe space heaters. Information about time during measurements was thereforelost, since it was not known when an actuator had received a message and hadturned on the heater. Furthermore JPFH stopped after a few days due to mes-sages piling up in the system. Further development in the controlling softwaresolved this problem and the time lags for messages in following experiments weresignificantly reduced. Unfortunately the system still showed some instabilitiesduring the following experiments and shut the application down several times.

The aim of the third experiment was a compromise between exciting the systemin the area of the small- and large time constants. However, the ten heatersproduced too much heat, such that the temperature rose to more than 30 ◦C,causing an internal switch turns off the heaters. Therefore the actual heat input

Page 47: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

4.5 Experimental Design 37

from the heaters was not known in periods with more than 30 ◦C. This canbe seen in Figure 4.6, where the indoor temperature seems to decrease frommeasurements 1400–1500 even though the heaters are on. The temperature de-creases because the ambient temperature decreases.

Figure 4.6: Heat input and average temperature for measurement 080213.

For the third experiment, data up to measurement 1350, i.e. the first 113 hours,have been used for estimation of parameters, whereas the following measure-ments were discarded.

To reduce the heat input the number of heaters were reduced to seven heatersin the fourth experiment. These were controlled by the same PRBS-signal as inexperiment three. Room two and three were selected not to have any heat inputdue to the large surface area towards inside of the building. This ensures thatthe heat is distributed more evenly throughout the house. Measurements fromthe fourth experiment produced good results and have been used for parameterestimation.

The fifth experiment was designed to excite the system in the area of the largetime constant, therefore a long clock period was chosen. To avoid that thetemperature rose to more than 30 ◦C, only two heaters were chosen to giveheat input. To ensure an even distribution of heat, the heaters in room twoand three were chosen to produce the heat input. The PRBS-signal was toolong to fit within the six days measurement period and after the sixth day the

Page 48: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

38 Data

measurements were stopped. Measurement from the six days, however, showedgood results and have been used for estimation of the unknown parameters inEquation 3.4.

The sixth experiment was designed with two PRBS-signal; the first signal wasdesigned to establish stationarity before the second PRBS signal, which wasdesigned to excite the system around the large time constants. The same sevenheaters as in the fourth experiment were selected to produce heat input, dueto the good results from the fourth experiment. Unfortunately the system shutdown after the third day and the following measurements were lost. Measure-ments from the first three days have been used to estimate the unknown param-eters.

To reduce unknown heat input the refrigerator and water heater were turnedoff during all experiments. PRBS-signals used for control of the heaters in Flex-House, have been generated using MATLABs idinput-function, which generatesa PRBS-signal, given input for N , λ and levels.

Page 49: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

Chapter 5

Model Estimation

In Chapter 3 the model of the heat dynamics of FlexHouse was derived. Thischapter describes a stochastic method for estimation of the unknown parametersin the model, i.e. the resistances against heat transfer and the heat capacities.

In Section 5.1 the maximum likelihood estimator is derived. This estimator canbe found with CTSM, an estimation tool developed at DTU. CTSM is describedin Section 5.2. In Section 5.3 principal component analysis is described, whichis used to reduce the dimension of the temperature measurements.

5.1 Maximum Likelihood Estimator

In Section 3.5, it was found that the stochastic linear state space model in con-tinuous time could be formulated as a difference equation in discrete time

T(t + 1) = ΦT(t) + ΓU(t) + v(t) t ∈ 0, 1, 2, . . .N (5.1)

when the sampling time is constant, that is, equally spaced observations. In

Page 50: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

40 Model Estimation

Equation 5.1 t corresponds to the measurement at time index t, i.e. the t’thmeasurement. The likelihood function can be used to estimate the unknownparameters in Φ and Γ, where the most likely estimator is given by

θ = arg maxθ

{L(Tr(N); θ)} (5.2)

where L, the likelihood function, is the joint probability distribution functionof all the observations.

Let Tr(t) = [Tr(t), Tr(t − 1), . . . , Tr(0)] be a vector containing all observationsup to and including t and θ be a vector containing all the unknown parametersin Φ and Γ, including R11, R22, R33 from Equation 3.15 and the measurementerror, Re. Then the likelihood function can be formulated as the joint probabil-ity distribution when θ is given, i.e.

L(Tr(N); θ) = p(Tr(N)| θ) = p (Tr(N)|Tr(N − 1), θ) p(Tr(N − 1)| θ)

=

(

N∏

t=1

p (Tr(t)|Tr(t − 1), θ)

)

p(Tr(0)| θ) (5.3)

where the rule P (A ∩ B) = P (A|B)P (B) has been used N -times to form thelikelihood function as a product of conditional densities. Since both v(t) ande(t), in Equation 3.16 and 3.7, are assumed to be normally distributed, theconditional density function is also normally distributed, and is thus fully char-acterized by its mean and variance. The multivariate normal distribution isgiven by

f(x) =1

(2π)n/2√

detΣexp

(

−1

2(x − µ)T Σ−1(x − µ)

)

(5.4)

where Σ > 0 is the covariance and µ is the mean. Introducing the conditionalmean

T(t|t − 1) = E[Tr(t)|Tr(t − 1), θ] (5.5)

the conditional variance

R(t|t − 1) = V [Tr(t)|Tr(t − 1), θ] (5.6)

and the one step prediction error

ε(t) = T(t) − T(t|t − 1) (5.7)

Page 51: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

5.1 Maximum Likelihood Estimator 41

Equation 5.3 can be reformulated to

L(Tr(N); θ) =

N∏

t=1

(

1

(2π)n/2√

detR(t|t − 1)exp

(

−1

2ε(t)T R(t|t − 1)−1ε(t)

)

)

where n is the dimension of Tr. To simplify the maximization the logarithm tothe likelihood function is maximized instead, i.e.

log L(Tr(N); θ) = log

(

N∏

t=1

(

1

(2π)n/2√

detR(t|t − 1)exp

(

−1

2ε(t)T R(t|t − 1)−1ε(t)

)

))

= −m

2

N∑

t=1

(2π) − 1

2

N∑

t=1

log(detR(t|t − 1)) +1

2ε(t)T R(t|t − 1)−1ε(t)

=1

2

N∑

t=1

[

ε(t)T R(t|t − 1)−1ε(t) − log(detR(t|t − 1))]

+ C

where C is a constant. A Kalman filter can be applied to recursively calculatethe conditional mean and variance.

The Kalman filter is a recursive filter, which can be used to estimate the states,of a linear stochastic state space model, given observations of U and T. Thereconstructed states and the corresponding covariance are given by Theorem 8.2in [Mad06]

T(t|t) = T(t|t − 1) + Kt

(

Tr(t) − CT(t|t − 1))

P(t|t) = P(t|t − 1) − KtR(t|t − 1)KTt

where Kt is the Kalman gain given by

Kt = P(t|t − 1)CTR(t|t − 1)−1 (5.8)

The predicted states are given by

T(t + 1|t) = ΦT(t|t) + ΓU(t)

Tr(t + 1|t) = CT(t + 1|t)P(t + 1|t) = ΦP(t|t)φT + R1

R(t + 1|t) = CP(t + 1|t)CT + R2

Page 52: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

42 Model Estimation

where following initial conditions are used

T(1|0) = E[T(1)] = µ0

P(1|0) = V [T(1)] = V0

Theorem 5.8 in [Mad06] states that

1. θ is consistent.

2. θ is normally distributed with E[θ] = θ and variance

V [θ] ∼= 2σ2εH

−1 (5.9)

where the matrix H is given by

hlk =∂2S (θ)

∂θl∂θk

θ=θ(5.10)

3. θ is asymptotic efficient.

Asymptotically it holds for the maximum likelihood estimator that the varianceof the estimate in Equation 5.9 is given by

V [θ] = I−1 (θ) (5.11)

where

I (θ) = −E

[

∂2 log L

∂θ2

]

(5.12)

5.2 CTSM - Continuous Time Stochastic Mod-

eling

A routine for maximizing the conditional likelihood function has been imple-mented in CTSM, a continuous time stochastic modeling tool. CTSM can be

Page 53: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

5.2 CTSM - Continuous Time Stochastic Modeling 43

used to estimate parameters in both linear time invariant-, linear time varying-and nonlinear models. The estimated parameters can either be found usingthe maximum likelihood (ML) method or the maximum a posteriori (MAP)method. The maximum a posteriori estimator is not used in this project but[MK03a] contains more information. When the maximum likelihood estimatorhas been found for L(Tr(N); θ) CTSM returns the estimate of θ.

CTSM also estimates the standard deviation of the estimated parameters. Thisis given by the estimated variance, which is found by setting the expected valuein Equation 5.12 equal to the observed value, i.e.

ilk = −(

∂2 log L(Tr(N); θ)

∂θl∂θk

)

(5.13)

CTSM has been developed at Department of Informatics and MathematicalModeling (IMM) at the Technical University of Denmark, (DTU), and can bedownloaded from IMM’s homepage 1, where a user’s guide, [MK03b], is alsoavailable.

5.2.1 Modeling in CTSM

Due to the ease of use, CTSM has been chosen for estimation of the parametersin Equation 3.4. When a model, of the same form as Equation 3.16, has beenformulated it can ne easily entered using the graphical user interface of CTSM.When the number of states, input and output have been defined, CTSM setsup the matrices, A, B, C and D, defined in Equation 3.6 and 3.7. When thematrices have been filled out it can be selected how to estimate each parame-ter, i.e. ML, MAP or if it is fixed. Boundaries are defined for each parameterthat is to be estimated. It should be noted, that ±∞ and 0 should be avoidedas boundary and initial values for the parameter estimation. Finally a sourceof data, which contain time, input and measured output, is specified and theparameters are estimated.

1http://www2.imm.dtu.dk/˜ctsm/

Page 54: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

44 Model Estimation

5.3 Principal Components Analysis

The heat dynamics model, formulated in Chapter 3, is based on one represent-ing indoor temperature. The measurements, however, are composed of eightdifferent measurements; one for each room. Therefore the dimensions of themeasurements have to be reduced before CTSM can estimate the unknown pa-rameters. One approach is simply to use the average temperature. However, dueto the variations between the room temperatures principal component analysishas been chosen to reduce the dimension of measurements to one representativetime series. This method accounts for more of the variation than the average,since the influence by diverging measurements is reduced. An example of thevariation between the measured temperatures in the eight rooms can be seen inFigure 5.1.

0 200 400 600 800 1000 1200 1400 1600 18005

10

15

20

25

30

35

Measurement, 5 minutes

Tem

pera

ture

, °C

Room Temperatures

Figure 5.1: Room temperatures for measurement 080213.

Principal component analysis is a linear transformation of data. The data istransformed to an orthogonal coordinate system, such that the first axis is par-allel to the highest variance of the data and the second is parallel to the secondhighest variation etc. The axes in the new coordinate system are called theprincipal axes and are determined by the eigenvectors of the covariance matrix.

Considering the eight measurements of the indoor air temperature,

X = [x0,x1, · · · ,x7] (5.14)

where x1 is the measurements from room one. To determine the first principalcomponent the mean is subtracted from the data,

Page 55: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

5.3 Principal Components Analysis 45

X = [x0 − x,x1 − x, · · · ,x7 − x] (5.15)

and the covariance matrix is calculated

Σ =1

nXX′ (5.16)

The principal axes can now be determined from

ΣΦ = ΦΛ (5.17)

where Λ is a diagonal matrix with the eigenvalues ordered in decreasing or-der. The eigenvector corresponding to the highest eigenvalue is the basis vectorthat accounts for most of the variation in the measurements. The first princi-pal component can be found from the eigenvector corresponding to the highesteigenvalue.

Y1 = φ′1X (5.18)

The amount of variance explained by the i’th principal component is given bythe corresponding normalized eigenvalue.

pi =λi

∑8i=1 λi

(5.19)

where λi is the eigenvalue corresponding to the i’th eigenvector.

Measurement p1 Eigenvector

080213 0.984 [0.341, 0.375, 0.380, 0.380, 0.345, 0.338, 0.347, 0.318]′

080227 0.934 [0.350, 0.381, 0.315, 0.303, 0.333, 0.375, 0.391, 0.371]′

080305 0.761 [0.276, 0.188, 0.571, 0.677, 0.286, 0.065, 0.101, 0.091]′

080326 0.738 [0.314, 0.392, 0.113, 0.153, 0.358, 0.526, 0.441, 0.336]′

Table 5.1: Eigenvectors for the covariance matrix

For the four successful experiments, 3–6, conducted in FlexHouse Table 5.1shows the amount of variance explained by the first principal component, p1,and eigenvectors that were found from the covariance matrix. From the table itcan be seen that the principal component of the two first experiments resemblesthe average temperature, i.e. each measurement contributes the same amount

Page 56: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

46 Model Estimation

to the first principal component. From these two series the variance explainedby the first principal components are very high. Therefore the first principalcomponent for these experiments should be sufficient to describe the indoortemperature. For the last two measurements the variance explained by the firstprincipal components is approximately 75 %. It should therefore be consideredif the first principal component is sufficient to describe the variation in the in-door temperature. However, since the model of the heat dynamics of FlexHouseis based on one indoor temperature only, it has been decided to estimate theparameters based on the first principal component only, even though it leads tolarger estimation errors.

In Figure 5.2 is the first principal component plotted for measurement 080213along with the heat input and average temperature. From the figure the vari-ation in the first principal component due to the heat input is clearly seen. Itcan also be seen that the principal component follows the average temperature,however with less variation.

Figure 5.2: First principal component, average temperature and heat input formeasurement 080213

Figure 5.3 shows the reconstructed temperature from the first principal compo-nent together with the average temperature. This shows that the reconstructedtemperature does not vary as much as the average temperature

The source code for a MATLAB function for calculation of principal componentscan be found in Appendix F.

Page 57: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

5.3 Principal Components Analysis 47

Figure 5.3: Reconstructed indoor temperature for measurement 080213

Page 58: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

48 Model Estimation

Page 59: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

Chapter 6

Model Validation

This chapter describes several methods that can be used to validate the model.In general the methods are based on the assumption that if the model describesall variations, then the one step residuals should resemble white noise.

Section 6.1 describes a method for validation in the time domain and Section6.2 describes a method for validation in the frequency domain.

6.1 Validation Using the Autocorrelation Func-

tion

The autocorrelation function is an effective tool for validating a stochastic modelin the time domain. From the autocorrelation function, of the one step resid-uals, it can been seen if all variations are described by the model. If all thevariations are described by the model the residuals will resemble white noise.Thus, the residuals should be uncorrelated.

Page 60: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

50 Model Validation

The autocorrelation function for white noise is given by

ρε(k) =

{

1 for k = 00 for k = ±1,±2, · · · (6.1)

The estimated autocorrelation of the residuals can be found from Equation 5.10in [Mad06]

ρ(k) =C(k)

C(0)(6.2)

where C(k) is the estimated autocovariance

Cεε(k) = C(k) =1

N

N−|k|∑

t=1

(ε(t) − ε(t)) (ε(t + |k|) − ε(t)) (6.3)

where the one step prediction residuals, ε(t) are given by Equation 5.7. Theorem5.1 in [Mad06] states that if ε(t) is white noise, then ρ(k) is asymptoticallynormally distributed with

E[ρ(k)] ' 0 for k 6= 0 (6.4)

V (ρ(k)) ' 1/N for k 6= 0

If ε(t) is white noise it should have an autocorrelation function that resemblesEquation 6.1. Due to the normal distribution of ρ(k), an approximate 95 %confidence interval for white noise is given by ±2σε around 0.

6.2 Cumulated Periodogram

Test in cumulated periodogram reveals if the residuals contains any periodicitiesthat are not described by the model. For white noise the variation is distributedover all frequencies (i.e. f(ω) = σ2

ε /2π). If ε(t) is described by white noise thevariation should be equally distributed over all frequencies. Thus the peri-odogram should be constant over all frequencies.

The periodogram or sample spectrum can be found from the one step predictionresiduals, ε(t),

I(νi) =1

N

(

N∑

t=1

ε(t) cos(2πνit)

)2

+

(

N∑

t=1

ε(t) sin(2πνit)

)2

(6.5)

Page 61: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

6.2 Cumulated Periodogram 51

where I(νi) is the amount of variation of ε(t) that is related to the frequency νi.

The cumulated periodogram is a cumulated sum over the sample spectrum orperiodogram. Since the spectrum for white noise is constant the cumulatedperiodogram should be a straight line. In general the cumulated sum is normal-ized such that the cumulated sum is straight line from 0 to 1 over all frequencies.

The normalized cumulated periodogram can be found from Equation 6.5

K(νi) =

∑ij=1 I(νj)

∑[N/2]j=1 I(νj)

(6.6)

which is a non-decreasing function defined for the frequencies νi = i/N, i =0, 1, 2, · · · , [N/2], where N is the number of residuals. An approximate 95 %confidence interval around the theoretical line is given by ([Mad06])

Iα = ±Kαq−0.5 = 1.36q−0.5, where q =

{

(N − 2)/2 for N even(N − 1)/2 for N odd

(6.7)

That is the confidence interval is bound by straight lines drawn at a distanceIα from the theoretical line.

Page 62: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

52 Model Validation

Page 63: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

Chapter 7

Results

7.1 Maximum Likelihood Estimates

Based on the experimental data collected in FlexHouse during experiment 3 to6, the maximum likelihood estimates have been found using CTSM. The param-eter estimates are based on concatenated data from all four experiments withoutthe measurements from the last third of the third experiment. The estimatedparameters and their associated standard deviations can be seen in Table 7.1.

From the table it is first noted that the estimated distribution of the solar radi-ation is 0.995, i.e. 99.5, % of the energy flow through the windows, due to solarradiation, is absorbed by the inner walls. Therefore the maximum likelihoodestimates of parameters were found again with p = 1.0. The new estimates canbe seen in Table 7.2. From the table it can be seen that an almost identicalresult is found. Thus it can be assumed that no solar radiation is absorbed bythe air.

The estimates in Table 7.2 show that the heat capacity of the outer walls isvery large, compared to the estimates of the other heat capacities and that theresistance against heat convection from the indoor air to the outer walls is small.

Page 64: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

54 Results

Parameter Maximum Likelihood Standard ErrorEstimate of Estimate

Ri 47.984 ◦C/kW 0.102

Ci 8.118 kWh/◦C 0.417

Rim 1.812 ◦C/kW 0.243

Ra 8.029 ◦C/kW 1.648

Cim 0.00540 kWh/◦C 0.000574

Com 295.860 kWh/◦C 8.031

Ram 0.0835 ◦C/kW 0.0332

Aw 20.203m2 1.659p 0.995 0.0133

log(R11,1) −2.749 ◦C2 0.348

log(R22,1) 6.391 ◦C2 0.0690

log(R33,1) −0.941 ◦C2 0.345

log(R2) −7.067 ◦C2 0.0848

Table 7.1: Maximum likelihood estimates for the unknown parameters in Equa-tion 3.4 with p 6= 0.

Parameter Estimate Standard Errorof Estimate

Ri 46.848 ◦C/kW 0.134

Ci 8.120 kWh/◦C 0.294

Rim 1.809 ◦C/kW 0.147

Ra 8.021 ◦C/kW 0.501

Cim 0.00553 kWh/◦C 0.000611

Com 292.950 kWh/◦C 7.675

Ram 0.0846 ◦C/kW 0.0294

Aw 20.212m2 1.491p 1.000 -

log(R11,1) −2.754 ◦C2 0.299

log(R22,1) 6.368 ◦C2 0.0586

log(R33,1) −0.943 ◦C2 0.312

log(R2) −7.066 ◦C2 0.0755

Table 7.2: Maximum likelihood estimates for the unknown parameters in Equa-tion 3.4 with p = 1.

Page 65: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

7.1 Maximum Likelihood Estimates 55

Moreover the resistance against heat conduction from the outer wall to the out-side is very small. This indicates that the heat capacity of the outer wall is in theouter layer of the building envelope, i.e. the outer planks of the building. Ram

is very low, but the estimate would probably be higher if data from periods withlow wind speeds was used instead. However based on the estimates it is clearlyseen that most of the heat lost to the outside goes through the building envelope.

The resistance against heat conduction directly to the outside, Ra, is muchhigher than the resistances for the outer wall. This does not agree with theapproximately 30% of the total heat loss is due to ventilation loss, found in[Ara]. However, some of the heat loss directly to the outside is probably hiddenby the parameters of the building envelope.

The estimated heat capacity of the inner walls, Cim, is very small and doesclearly not reflect the actual value. Simulations show that the temperature inthe inner walls rise several hundred degrees, when exposed to sunlight. The verylow heat capacity, however, makes the temperature drop very fast again, despiteof the high resistance against heat convection to the indoor air. This indicatesthat the inner walls can be regarded as a medium that delays the heat input bysolar radiation to the indoor air. The fact that log(R22,1) ≈ 6.368 shows thatnot much is known about the temperature in the inner walls.

The estimate of Ci seems much more reasonable. In [MH95] the heat capacityof the indoor air in a building of half the size of FlexHouse, was estimated tobe approximately 1.2 kWh/◦C. Considering the content of FlexHouse, is theestimated value of Ci not far from what could be expected.

The estimated parameters in Table 7.2 suggest that the model illustrated inFigure 3.1 could be changed to the one illustrated in Figure 7.1

Unfortunately no data, for physical parameters of FlexHouse, is available, thusmaking it hard to say anything general about the estimated values. However,the window area of FlexHouse is approximately 30 m2. Assuming that the ef-fective window area is approximately 60 % of the real window area, as was usedin [MH95], the estimated result of Aw is very close to the expected.

Printouts from CTSM can be found in Appendix A.

Page 66: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

56 Results

Figure 7.1: Updated single room model and equivalent RC-network.

7.2 Time Constants

The dynamic properties of the system is determined by A, defined in Equation3.5. Inserting the parameters estimates from Table 7.2, i.e. with p = 1, into A

gives

A =

−0.0861 0.0026 0.06813.8613 −3.8613 00.0019 0 −0.0422

(7.1)

Similarly has B been found to

B =

0.0154 0 0.12320 3.6562 0

0.0403 0 0

(7.2)

Page 67: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

7.2 Time Constants 57

From Equation 7.1 the eigenvalues and eigenvectors of A has been found.

λ1 = −3.864 , ν1 =

−6.958× 10−4

−1.000−3.436× 10−7

(7.3)

λ2 = −0.0863 , ν2 =

−0.699−0.7150.0299

(7.4)

λ3 = −3.864 , ν3 =

0.6400.6470.415

(7.5)

The time constants of the systems are given by

τi = −1/λi for i=1,2,3 (7.6)

which gives

τ1 = 0.259hours ≈ 15.5 minutes

τ2 = 11.590hours

τ3 = 25.442hours

These time constants agrees well with what could be expected and are close tothe estimated time constants that were used to design the heat input for exper-iment 3 to 6 in Section 4.5.

Page 68: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

58 Results

7.3 Linear State Space Model in Discrete Time

Now that A and B have been found, Φ and Γ, defined in Equation 3.16, can bedetermined from Equation 3.13. In MATLAB, Equation 3.10 has been used tocalculate the matrix exponential of A

Φ = exp(A) =

9.9288× 10−1 1.8661× 10−4 5.6429× 10−3

2.7410× 10−1 7.2489× 10−1 8.1923× 10−4

1.5641× 10−4 1.5459× 10−8 9.9649× 10−1

(7.7)

By numerical integration Γ has been found in MATLAB

Γ =

∫ τ

0

exp(Ar)Bdr =

1.2844× 10−3 2.9990× 10−2 1.0226× 10−2

1.8592× 10−4 2.6053× 102 1.4838× 10−3

3.3551× 10−3 1.6128× 10−6 8.0402× 10−7

(7.8)

Equation 7.7 and 7.8 can be used to run simulations of the indoor air tempera-ture. The simulated temperature states are given by.

T(t + 1) = ΦT(t) + ΓU(t) (7.9)

where U is the input to the system.

Source code for a MATLAB function for numerical integration of matrices canbe found in Appendix F.

7.4 Simulation

To verify that the model has been identified, Φ and Γ has be used to simulatethe indoor temperature. The measurements that were gathered during the thirdexperiment have been used as input for the simulation of the indoor tempera-ture. The simulated indoor temperature along with the measured temperaturecan be seen in Figure 7.2.

From Figure 7.2 it can be seen that variation of the simulated air temperatureis less than the measured temperature and that they tend to deviate a bit fromeach other after some time. However, the figure also shows that the tempera-tures show the same tendency. Thus is the tendency of the indoor temperature

Page 69: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

7.4 Simulation 59

Figure 7.2: Simulated and measured indoor air temperature for experiment 3.

described by the model. Figure 7.3 shows the difference between the measuredand simulated indoor temperature.

Figure 7.3: Difference between simulated and measured air temperature forexperiment 3.

The figure shows that the maximum deviation is approximately 3◦ over a fiveday period. Considering the complexity of the heat flow in FlexHouse this devi-ation is not large. However, the figure suggest that more can be done to improvethe model. The figure also shows a general tendency to underestimate the tem-

Page 70: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

60 Results

perature. This tendency, however, is not general for simulations based on datafrom the other experiments.

Figure 7.4 and 7.5 shows the simulated temperatures in the heat accumulationlayer in the inner and outer walls, respectively.

Figure 7.4: Simulated temperature in the inner walls using data from experiment3.

Figure 7.4 shows a very high increase in temperature in the inner walls, whenexposed to sun light. As stated in Section 7.1 this is due to the very low heatcapacity of the inner walls. However it is also seen from the figure that the tem-perature drops very rapidly again, when the sunlight disappears. This indicatesthat the energy in the inner walls is transferred to the indoor air very fast. Thusthe inner walls are delaying the solar heat input before it is absorbed by theindoor air.

From Figure 7.5 it can be seen that the temperature in the outer walls changesvery slowly. This is due to the very high heat capacity of the walls.

Page 71: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

7.5 Prediction 61

Figure 7.5: Simulated temperature in the outer walls using data from experiment3.

7.5 Prediction

CTSM has been used to calculate the one and twelve step predictions, i.e. the5 minute and 1 hour predictions, for the indoor temperature. The predictedindoor air temperatures can be seen in Figure 7.6 and Figure 7.7 where thecorresponding residuals are also plotted.

From Figure 7.6 it can be seen that the one step predicted temperature coin-cidence with the measured temperature. The associated residuals show thatpredicted temperatures does not deviate more than 0.25◦C. Thus the indoortemperature can be predicted very precisely within 5 minutes. This, however, iswhat could be expected since the variation in indoor temperature is very smallover a 5 minutes period. The one step prediction residuals plotted in Figure 7.6are in the following used to verify the model.

From the plot of the twelve step temperature prediction, in Figure 7.7, is seenthat the predicted temperature deviates a lot more than the one step predic-tion. The predicted temperature, however, still corresponds very well with themeasured temperature. From the residuals it can be seen that the predictedtemperature does not deviate more than 1◦C from the measured temperature.However, the effect of the heat input can clearly be seen in the residuals. Thisis because the input is assumed constant over the prediction horizon. Thus,when the heaters are turned on during the prediction interval a relative largeprediction error occurs.

Page 72: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

62 Results

Figure 7.6: 5 minutes predicted indoor air temperature based on data fromexperiment 3.

Figure 7.7: 1 hour predicted indoor air temperature based on data from experi-ment 3.

Page 73: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

7.6 Model Verification 63

7.6 Model Verification

If the model describes all variations the residuals plotted in Figure 7.6 shouldresemble white noise. In Figure 7.8 the autocorrelation function for the one stepprediction residual is plotted.

Figure 7.8: Autocorrelation function of the one step residuals plotted in Figure7.6

The autocorrelation function in Figure 7.8 shows some autocorrelation at lag1–25 outside the 95 % confidence interval. This indicates that not all variationsare described by the model and that the model can be improved. The autocor-relations, however, are not very large, why the model of the heat dynamics canbe used as a good approximation to actual model.

To verify that the variations of one step prediction residuals are distributedequally over all frequencies, the cumulated periodogram of the residuals plottedin Figure 7.6 has been found. The cumulated periodogram is plotted in Figure7.9.

The cumulated periodogram is almost within the 95 % confidence interval. Itcan therefore be concluded that the sample spectrum of the residuals is constantover all frequencies. Hence the residuals show white noise properties and almostall variations are described by the model.

Page 74: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

64 Results

0 0.5 1 1.5 2 2.5 30

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

Frequency

Nor

mal

ized

Cum

ulat

ed P

erio

dogr

am

Figure 7.9: Cumulated periodogram of the residuals plotted in Figure 7.6.

In Appendix D are predicted temperatures, autocorrelation function and cumu-lated periodogram found for each of the experiments conducted in FlexHouse.In general these show the results as were found in this section.

Page 75: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

Chapter 8

System Control

Now that the model of the heat dynamics of FlexHouse has been established andverified, a control strategy for the electrical space heaters should be found suchthat the total cost of the energy used in heating is minimized over a horizon.This, however, should not expose the users of the house to great temperaturefluctuations.

In the first section the control strategy is formulated as a minimization prob-lem of a cost function. In Section 8.2 actual prices from the Western Danishelectricity system is shortly explained. These are used for simulation of a pricesignal for the week, where the third experiment was conducted in FlexHouse.In Section 8.3 simulations of the temperature development in FlexHouse dueto a static controller are performed. The price signal is used in Section 8.4 tosimulate the temperature development in FlexHouse from a dynamic heat con-troller. Section 8.5 states the results of the simulations.

Page 76: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

66 System Control

8.1 Dynamic Control

The aim of the dynamic controller is to control the heat input in FlexHouse,with respect to a given price signal but without exposing the users of the houseto great temperature fluctuations. If the controller should maintain a temper-ature around a given reference temperature, Tref , the cost of deviation can beformulated as

Ji,T =

(

Ti − Tref

α

)4

(8.1)

where α is a parameter used to control the width of the interval in which thetemperature is to be controlled. From Equation 8.1 it can be seen that if thedifference between Ti and Tref is greater than α, the cost functions raises veryrapidly. The temperature difference to the fourth power has been selected tosharpen the boundaries of the control interval. This effect would not have beenachieved if the temperature difference was squared instead.

Equation 8.1 describes the cost of temperature without considering the price ofthe energy consumed by keeping the temperature around Tref . The cost asso-ciated with the consumption of energy, however, has to be considered. Thus acost function associated with the cost of consumed energy has to be formulated.The cost of consuming the energy, Φh,i∆t, can be formulated as

Ji,U = lPiΦh,i∆t (8.2)

where l is a price weight factor, determining the impact of the price, Pi and ∆tis the length of the period that the space heaters are on. Φh,i and Pi are as-sumed to be constant in the time interval [i; i+∆t]. Due to a constant samplinginterval, can l and ∆t be collected into a new price weight factor, k, withoutany loss of generality.

Equation 8.1 and 8.2 can now be used to formulate a total cost function for theheat input. At time t, the dynamic heat controller should find a series of heatinput that minimizes the total cost function over a given horizon, i.e.

U = arg minΦh

t+h∑

i=t

(Ji,T + Ji,U ) = argminΦh

t+h∑

i=t

{

(

Ti − Tref

α

)4

+ kPiΦh,i

}

(8.3)

where h is the horizon over which the heat input should be optimized and U is

Page 77: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

8.2 Energy Price 67

a vector that contains the optimal heat input from time t to t + h.

If the cost associated with having all ten heaters, i.e. Φh,i = 10 kW , turned on,it should approximately be the same as if the indoor temperature deviates tothe boundary of the control interval (≈ α), i.e. Ji,T = 1 . Then k can be foundfrom

k Pi Φh,i ≈ k P 10kW ≈ 1 ⇒ k ≈ 1

0.04 Euro/kWh10 kW= 2.5 h/Euro

where P is the average energy price, found to be approximately 0.04 Euro/kWh.

8.2 Energy Price

For simulation, hourly energy prices from the Western Danish electricity system(DK-West) have been used. These can be downloaded from the homepage ofEnerginet 1. An example of the hourly price can be seen in Figure 8.1.

Figure 8.1: Development in the hourly energy price in February 2008.

From Figure 8.1 it can be seen that the energy price varies a lot, which is due tolarge production of wind power in Denmark. The variations are due to the lowproduction costs of wind energy, so that when the energy production by windturbines is high the energy price in DK-West drops. Figure 8.1 also shows thatthe energy price at time t ≈ 30, drops to 0. This is because the energy produc-tion is very high compared to the demand, so the wind energy producers drop

1http://www.energinet.dk/da/menu/Marked/Marked.htm

Page 78: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

68 System Control

their energy price in order to prevent their wind farms to be forced to shut down.

The hourly energy prices from DK-West are given at least 12 hours in advance.Thus for a planning horizon less than 12 hours, the energy price can be assumedto be known. The time constants of FlexHouse, however, are so small that sucha long planning periods would never be relevant.

The hourly energy price for the days corresponding to the days where experi-ment three was conducted, can be seen in Figure 8.2.

0 20 40 60 80 1000.03

0.04

0.05

0.06

0.07

0.08

0.09

Time, hours

Ene

rgy

Pric

e, E

uro/

kWh

Figure 8.2: Development in the hourly energy price during the week whereexperiment three was conducted.

The energy prices shown in Figure 8.2 have been used for simulation of a pricesignal.

It should be noted that the price from DK-West are not the actual consumerprice, but the spot price between energy producers and energy suppliers. Theprice, however, does reflect the price that consumers must pay.

Page 79: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

8.3 Simulation of a Static Controller 69

8.3 Simulation of a Static Controller

The present heat controller implemented in FlexHouse is static and does notconsider the price associated with heating. Based on the model found in Sec-tion 7.3 a simulation of a static controller has been run in MATLAB. For thesimulations Equation 7.9 has been rewritten to

T(t + 1) = ΦT(t) + Γ1Z(t) + Γ1U(t) where [Γ1Γ2] = Γ (8.4)

where Z(t) = [Ta(t), Φs()]′ is the ambient input, at time t, that cannot be con-

trolled and Ut is the heat input that the heat controller determines.

A simulation where the temperature was controlled within a reference intervalgiven by Tref = [19; 21] can be seen in Figure 8.3.

Figure 8.3: Simulated indoor temperature and heat input from a static con-troller.

The simulation was run with ambient input given by the measurements fromexperiment 3.

Source code for a MATLAB function for finding the heat input from a staticcontroller can be found in Appendix F.

Page 80: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

70 System Control

8.4 Simulation of Dynamic Controller

Unfortunately no analytic solution can be found for Equation 8.3. Thus the op-timal heat input has to be found by a numerical method. For this the MATLABfunction fminunc-function was used. fminunc is a function that determines theunconstrained minimum of a multi-variable function using a line search method.Since fminunc can only be used to find the unconstrained minimum, a hugepenalty for heat input outside the interval [0; 10] kW , was implemented in thecost function.

Based on Equation 8.4, the price signal depicted in Figure 8.2 and ambientinput given by the measurements from experiment 3, several simulations wererun with different price weight factors, k. The optimal heat input was foundfor one hour at a time over a three hours horizon. To reduce the time it tookto find the optimal heat input, this was assumed to be constant in intervals of30 minutes. The costfunction was minimized with α = 1, such that an almostequal temperature reference interval as in the simulation of a static controllerwas used.

Figure 8.4 shows the heat input found with a price weight factor k = 0, i.e.without considering the price along with the simulated air temperature.

Figure 8.4: Simulated indoor temperature with heat input from a dynamiccontroller that minimizes Equation 8.3 with k = 0.

Page 81: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

8.4 Simulation of Dynamic Controller 71

From Figure 8.4 it can be seen that the cost function with k = 0 can be used tocontrol the indoor temperature very precisely. The rises in temperature is dueto solar radiation, which is not predicted accurately, since the ambient input isassumed to be constant in the prediction interval.

Figure 8.5 shows the heat input found with a price weight factor k = 2 alongwith the simulated air temperature.

Figure 8.5: Simulated indoor temperature with heat input from a dynamiccontroller that minimizes Equation 8.3 with k = 2.

In Figure 8.5, the effect of the price signal on the heat input is clearly seen.

In Figure 8.6 the price signal and heat input are plotted.

Figure 8.6: Energy price and optimal heat input for k = 2.

Page 82: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

72 System Control

From the figure it can be seen that, in general, the heat input drops when theprice goes up and vice versa. It can therefore be concluded that the right deci-sions are made to optimize the power consumption.

Simulations with k = 0.5, 1, 4, 8 and 16 were also conducted. The heat input inthese, however, resembles the same heat input illustrated in Figure 8.5. Plotsof the other simulations can be found in Appendix G.

Source code for the MATLAB functions for calculating the cost function andfor finding the optimal heat input can be found in Appendix F.

8.5 Results

The aim of this thesis is to minimize the cost of heating over a given horizon.Therefore the cost of optimal heating have been found for optimal heat input,with price weight factors k = 0, 0.5, 1, 2, 4, 8 and 16. The found total energyconsumed, the mean temperature, the cost of heating and the average energycost are shown in Table 8.1.

k Static 0 0.5 1Energy Usage, kWh 385 391.95 389.54 375.91Mean Temperature, ◦C 19.93 20.01 19.89 19.83Total Cost, Euro 20.77 20.90 20.53 19.77Average Energy Cost, Euro×10−3/kWh 53.95 53.33 52.70 52.60

k 2 4 8 16Energy Usage, kWh 389.13 367.17 354.54 342.63Mean Temperature, ◦C 20.00 19.78 19.64 19.51Total Cost, Euro 20.52 19.25 18.59 17.98Average Energy Cost, Euro×10−3/kWh 52.74 52.44 52.44 52.48

Table 8.1: Cost of heating

From the table it can be seen that the electrical heating in FlexHouse definitelycan be controlled such that the total energy cost is lower than if controlled bya static controller. The results, however, also show that the savings are rathersmall. If disregarding the difference in mean temperature the savings in totalcost is less than 5 % compared to the static controller, which is lower than ex-

Page 83: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

8.5 Results 73

pected. The low savings are mainly due to the large heat loss in FlexHouse.Since the heat cannot be stored in an internal medium with a large heat capac-ity, the possibility of storing cheap heat to periods of more expensive heat isgreatly reduced.

Page 84: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

74 System Control

Page 85: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

Chapter 9

Future Work

At the beginning of this project the intention was to identify a model of theheat flow for each room in FlexHouse. During estimation, however, it was evi-dent that the data that were collected during experiment 3–6 were insufficientto identify heat flow between rooms. This was mainly due to the synchronizedcontrol of heaters which lead to large estimation errors on the estimates of theresistances against heat transfer for the inner walls. Further development incontrolling software could implement non-synchronous control of the heaters inFlexHouse. This kind of control, however, would require hardware that is capa-ble to handle more messages being sent. A new approach could be to implementcontrol by wired actuators. This would require further investments in hardware.

Future work should strive to increase the performance of the heat sensors. Betterperformance is essential if more accurate estimates of the building parametersare to be achieved. Placing the heat sensors at new locations could possiblydecrease the time between transmissions, if better lighting conditions can befound. The sensors, however, must not be placed in direct sunlight. Also thebatteries in the heat sensors could be changed more often. As an alternative tothe wireless heat sensors wired sensors should be considered. This would greatlyincrease accuracy and reliability.

Page 86: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

76 Future Work

Besides better hardware performance more data is needed if better estimatesshould be found. This can be achieved by conducting more experiments inFlexHouse, if possible with longer periods of measurements. Longer periods ofmeasurements would also make it possible to design heat input by PRBS-signalswith a longer clock period. Especially new experiments should be conductedwith heat input designed with the purpose of identifying the time constant ofthe inner walls. As in the sixth experiment the PRBS-signal should composedby two signals, where the purpose of the first signal is to achieve stationaritybefore the second signal. Experiments could also be conducted where some ofthe input parameters have been eliminated. For example the windows could beblocked to avoid input from solar radiation.

The results in Chapter 7 indicate that not all variations are described by theidentified model. In general a lot of things can be done to improve the model ofthe heat dynamics of FlexHouse. One great improvement would be to includethe non-linear effects caused by wind. If a model of heat dynamics of each roomis found the effect of different wind directions would also be relevant to include,since rooms with outer walls exposed to wind would lose heat more rapidly thanwalls in shelter. When a wall is exposed to wind the heat flow to the outside, dueto convection, is no longer free but forced. This results in a much higher convec-tion heat transfer coefficient, i.e. the resistance against heat transfer decreases.Due to the open areas towards south and west, the outer walls facing these di-rections are especially exposed to wind and further work would probably revealthat the resistances of these are very dependent on the wind speed and direction.

As stated in Chapter 4 information about persons presence is already beingcollected. It would therefore be relevant to extend the model with an inputfor presence. An inactive person emit around 60 watts from body heat. Thus ifmany persons are joined in a single room, it can have an impact on temperature.This is especially the case in a meeting room, like the main room in FlexHouse,where many persons may be joined. If a more precise model is found an un-explained increase in temperature could, in conjunction with motion sensors,maybe be used to estimate the number of persons in a room.

Information from the door and window sensors would also be relevant to add toan extended model. Naturally the heater should be turned off automatically ifa window or a door is open.

Additional work in price signals should also be made. For example the connec-tion between the spot price, used in this project, and the actual end user price,

Page 87: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

77

including taxes, should be examined. Especially the effect of different price sig-nals would be interesting to examine.

At last a better optimization method could be implemented for optimization ofthe cost function, instead of using a MATLAB function.

Page 88: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

78 Future Work

Page 89: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

Chapter 10

Conclusion

A stochastic linear state space model in discrete time of the heat dynamics ofFlexHouse has been developed. The model is based on submodels of heat ca-pacity, heat conduction, heat convection and radiation. It has been shown howa linear model of the heat dynamics can be formulated as flow of charge in anelectric network, composed of resistors and capacitors.

Software for data acquisitions has been developed to collect performance data ofFlexHouse and another application was developed to gather local weather datafrom outside FlexHouse. The wireless heat sensors in FlexHouse have shown tobe insufficient to get exact measurements.

The dimension of temperature measurements was reduced by principal compo-nent analysis to one representing temperature.

From the building performance data collected in FlexHouse, the physical param-eters in the model have been estimated by optimizing the maximum likelihoodfunction.

Page 90: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

80 Conclusion

Based on the results found in Chapter 7, it can be concluded that the modelhas been identified, but also that not all effect are described. Both tests in theautocorrelation function and cumulated periodogram, suggest that the one stepprediction residuals, of the indoor temperature, resembles white noise. Thus themodel describes nearly all variations in the indoor temperature. The simulationsof the indoor temperature in Chapter 7 further supports the conclusion, that themodel has been identified, and that simulated values of the indoor temperaturecan be used as an approximation to real measurements. However simulationsof the temperature in the inner walls have also shown that the model fails todescribe a realistic temperature development here.

Despite of the good results in modelling the indoor air temperature, much canbe done to improve the model. Especially due to the age of FlexHouse the windconditions have a big influence on indoor climate. Thus a sub model of heatloss due to wind conditions should be used to improve the model of the heatdynamics of FlexHouse.

One of the prerequisites of the intelligent controller being a success in the futureis that it should not be too expensive to invest in. Therefore control by wirelesshardware offers a cheap solution compared to wired hardware which is expen-sive to install, due to the wires that have to be drawn. However, when buildingnew houses it would be a good solution to build in wired sensors, since thesewould completely remove the time lag between measurements, when comparedto those used in this project.

During the initial phase of this project, the intention was to identify the heat dy-namics between the rooms in FlexHouse. However, with the installed hardwarein FlexHouse it has shown to be difficult to control the space heaters individu-ally. Thus the resistances against heat conduction through the inner walls couldnot be estimated. Also the comparison of the measurements collected from thewired weather station with the measurements from the wireless heat sensors,show that the performance of wireless hardware has to be greatly increased be-fore good results can be achieved. It can therefore be concluded that betterhardware is needed if a more accurate model is to be identified.

The results from Chapter 8 show that it is possible to achieve a reduction intotal cost of house heating, without limiting the users of the house. However,the reduction in cost for FlexHouse is rather small, i.e. within 2 − 5 %, butFlexHouse is not a typical house. Thus if a controller was developed for houseswith a large internal heat capacity would greatly increase the savings in total

Page 91: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

81

cost of heating. Examples of houses with a large internal heat capacity arehouses, built of bricks, with cavity wall insulation and houses with floor heat-ing having a metal grating imbedded in the concrete floor to increase the heatcapacity. These types of houses are very common in Denmark, therefore, it canbe concluded that the effect of electricity price signals could have an effect inDenmark when regarding electric heating of houses.

The results of this thesis have shown that price signal can be a way to controlthe power consumption in electrical house heating. However, the results of thisthesis shall not be regarded as a ready to install solution, instead they shouldbe regarded as a proof of concept.

Page 92: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

82 Conclusion

Page 93: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

Appendix A

CTSM Results

The printsouts can also be found at: http://www2.imm.dtu.dk/˜s011270/ctsm/.

Page 94: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

84 CTSM Results

Figure A.1: CSTM printout for P 6= 1

Page 95: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

85

Figure A.2: CSTM printout for P = 1

Page 96: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

86 CTSM Results

Page 97: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

Appendix B

Application Source Code

Listing B.1: WeatherData.java� �

1 package management ;23 public c lass WindStationData {45 private s tat i c int DIVISION FACTOR = 2;6 private s tat i c int CLOCK FREQUENCY = 16000;78 private f l oat a1 r ad i a t io n ;9 private f l oat a23 windWane ;

10 private f l oat a4 humidity ;11 private f l oat a5 temperature ;12 private f l oat d1 windSpeed ;13 private St r ing timeStamp ;1415 public WindStationData( int a1 , int a2 , int a3 , int a4 , int a5 , int d1){16 this ( a1 , a2 , a3 , a4 , a5 , d1 , new java . u t i l . Date ( ) . t oS t r ing ( ) ) ;17 }1819 public WindStationData( int a1 , int a2 , int a3 , int a4 , int a5 , int d1 ,

St r ing time ){20 this . a 1 r ad i a t i on = toInputVoltage ( a1 ) ∗6.3291 f ;21 this . a23 windWane = 356.5 f ∗ toInputVoltage ( a2 ) / toInputVoltage ( a3 ) ;22 this . a4 humidity = toInputVoltage ( a4 ) ;23 this . a5 temperature = 100. f ∗ toInputVoltage ( a5 ) −40. f ;24 this . d1 windSpeed = 0.63390 f ∗ toInputFrequency ( d1 ) +0.18914 f ;25 this . timeStamp = time ;26 }2728 public f l oat getRadiat ion ( ) {29 return this . a 1 rad ia t i on ;30 }3132 public f l oat getWindDirection ( ) {33 return this . a23 windWane ;34 }3536 public f l oat getHumidity ( ) {37 return this . a4 humidity ;38 }3940 public f l oat getTemperature ( ){41 return this . a5 temperature ;

Page 98: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

88 Application Source Code

42 }4344 public f loat getWinSpeed ( ) {45 return this . d1 windSpeed ;46 }4748 public St r ing toSt r ing ( ) {49 return new Str ing ( ”Record Time : \ t ” + timeStamp +50 ”\nRadiation : \ t ” + a1 rad ia t i on +

” kW/m2”+51 ”\nWind : \ t\ t ” + a23 windWane + ”

deg re es ” +52 ”\nHumidity : \ t ” + a4 humidity + ”

%RH”+53 ”\nTemperature : \ t ” +

a5 temperature + ” deg re esCe l s iu s ”+

54 ”\nWindSpeed : \ t ” + d1 windSpeed +” m/ s” + ”\n” ) ;

55 }5657 private s tat i c f loat toInputVoltage ( int output ){58 return 5 . f ∗( output − 32768) /32768. f ;59 }6061 private s tat i c f loat toInputFrequency ( int output ){62 return ( f loat ) (CLOCK FREQUENCY∗DIVISION FACTOR)/output ;63 }64 }

� �

Page 99: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

Appendix C

Measurement Data

1;main_hall;13/1;17:18:3;17.72588;false;true;;;;;false;false

1;room1;13/1;17:18:3;20.07878;false;false;;;;;true;false

1;room2;13/1;17:18:3;21.49052;false;false;;;;;true;false

1;room3;13/1;17:18:3;18.98076;false;false;;;;;true;false

1;room4;13/1;17:18:3;15.52984;false;false;;;;;true;false

1;room5;13/1;17:18:3;14.58868;false;false;;;;;true;false

1;room6;13/1;17:18:3;14.43182;false;false;;;;;true;false

1;room7;13/1;17:18:3;15.21612;false;false;;;;;true;false

1;wc;13/1;17:18:3;;;;;;;;;

1;OutSide;13/1;17:18:3;;;;-0.002897232;4.86084;331.94644;1.7128235;;

2;main_hall;13/1;17:23:25;17.56902;false;false;;;;;false;false

2;room1;13/1;17:23:25;20.07878;false;false;;;;;true;false

2;room2;13/1;17:23:25;21.01994;false;false;;;;;true;false

2;room3;13/1;17:23:25;18.98076;false;false;;;;;true;false

2;room4;13/1;17:23:25;15.52984;false;false;;;;;true;false

2;room5;13/1;17:23:25;14.58868;false;false;;;;;true;false

2;room6;13/1;17:23:25;14.43182;false;false;;;;;true;false

2;room7;13/1;17:23:25;15.21612;false;false;;;;;true;false

2;wc;13/1;17:23:25;;;;;;;;;

2;OutSide;13/1;17:23:25;;;;-0.002897232;4.906616;313.27676;1.5461644;;

3;main_hall;13/1;17:28:2;17.56902;false;false;;;;;false;false

3;room1;13/1;17:28:2;20.07878;false;false;;;;;true;false

3;room2;13/1;17:28:2;21.01994;false;false;;;;;true;false

3;room3;13/1;17:28:2;18.8239;false;false;;;;;true;false

3;room4;13/1;17:28:2;15.52984;false;false;;;;;true;false

3;room5;13/1;17:28:2;14.43182;false;false;;;;;true;false

3;room6;13/1;17:28:2;14.27496;false;false;;;;;true;false

3;room7;13/1;17:28:2;15.05926;false;false;;;;;true;false

Page 100: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

90 Measurement Data

3;wc;13/1;17:28:2;;;;;;;;;

3;OutSide;13/1;17:28:2;;;;-0.002897232;4.937134;337.16733;1.9920729;;

4;main_hall;13/1;17:33:9;17.56902;false;false;;;;;false;false

4;room1;13/1;17:33:9;19.6082;false;false;;;;;true;false

4;room2;13/1;17:33:9;21.01994;false;false;;;;;true;false

4;room3;13/1;17:33:9;18.8239;false;false;;;;;true;false

4;room4;13/1;17:33:9;15.52984;false;false;;;;;true;false

4;room5;13/1;17:33:9;14.43182;false;false;;;;;true;false

4;room6;13/1;17:33:9;14.27496;false;false;;;;;true;false

4;room7;13/1;17:33:9;15.05926;false;false;;;;;true;false

4;wc;13/1;17:33:9;;;;;;;;;

4;OutSide;13/1;17:33:9;;;;-0.002897232;4.921875;320.93643;1.8657082;;

5;main_hall;13/1;17:38:8;17.2553;false;false;;;;;false;false

5;room1;13/1;17:38:8;19.6082;false;false;;;;;true;false

5;room2;13/1;17:38:8;20.70622;false;false;;;;;true;false

5;room3;13/1;17:38:8;18.51018;false;false;;;;;true;false

5;room4;13/1;17:38:8;15.52984;false;false;;;;;true;false

5;room5;13/1;17:38:8;14.43182;false;false;;;;;true;false

5;room6;13/1;17:38:8;14.1181;false;false;;;;;true;false

5;room7;13/1;17:38:8;14.9024;false;false;;;;;true;false

5;wc;13/1;17:38:8;;;;;;;;;

5;OutSide;13/1;17:38:8;;;;-0.002897232;4.8150635;355.89624;1.6138344;;

6;main_hall;13/1;17:43:7;17.2553;false;true;;;;;false;false

6;room1;13/1;17:43:7;19.6082;false;false;;;;;true;false

6;room2;13/1;17:43:7;20.70622;false;false;;;;;true;false

6;room3;13/1;17:43:7;18.51018;false;false;;;;;true;false

6;room4;13/1;17:43:7;15.52984;false;false;;;;;true;false

6;room5;13/1;17:43:7;14.43182;false;false;;;;;true;false

6;room6;13/1;17:43:7;14.1181;false;false;;;;;true;false

6;room7;13/1;17:43:7;14.9024;false;false;;;;;true;false

6;wc;13/1;17:43:7;;;;;;;;;

6;OutSide;13/1;17:43:7;;;;-0.002897232;4.906616;352.7116;2.0895333;;

7;main_hall;13/1;17:48:42;17.2553;false;true;;;;;false;false

7;room1;13/1;17:48:42;19.13762;false;false;;;;;true;false

7;room2;13/1;17:48:42;20.23564;false;false;;;;;true;false

7;room3;13/1;17:48:42;18.51018;false;false;;;;;true;false

7;room4;13/1;17:48:42;15.52984;false;false;;;;;true;false

7;room5;13/1;17:48:42;14.43182;false;false;;;;;true;false

7;room6;13/1;17:48:42;14.1181;false;false;;;;;true;false

7;room7;13/1;17:48:42;14.9024;false;false;;;;;true;false

7;wc;13/1;17:48:42;;;;;;;;;

7;OutSide;13/1;17:48:42;;;;-0.002897232;5.0439453;309.2279;1.5156375;;

8;main_hall;13/1;17:52:49;17.09844;false;true;;;;;false;false

8;room1;13/1;17:52:49;19.13762;false;false;;;;;true;false

8;room2;13/1;17:52:49;20.23564;false;false;;;;;true;false

8;room3;13/1;17:52:49;18.35332;false;false;;;;;true;false

8;room4;13/1;17:52:49;15.52984;false;false;;;;;true;false

8;room5;13/1;17:52:49;14.27496;false;false;;;;;true;false

8;room6;13/1;17:52:49;13.96124;false;false;;;;;true;false

8;room7;13/1;17:52:49;14.9024;false;false;;;;;true;false

8;wc;13/1;17:52:49;;;;;;;;;

8;OutSide;13/1;17:52:49;;;;-0.002897232;5.0286865;355.88437;2.372414;;

· · ·

Page 101: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

Appendix D

Simulated and Measured

Indoor Temperature

120 140 160 180 200 220 240 26012

14

16

18

20

22

24

26

Time, hours

Tem

pera

ture

, °C

SimulatedMeasured

Figure D.1: Simulated and measured air temperature for experiment 4

Page 102: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

92 Simulated and Measured Indoor Temperature

120 140 160 180 200 220 240 260−4

−3

−2

−1

0

1

2

3

4

Time, hours

Tem

pera

ture

, °C

Figure D.2: Temperature difference between measured and simulated indoor airtemperature for experiment 4

280 300 320 340 360 38010

11

12

13

14

15

16

17

18

19

20

Time, hours

Tem

pera

ture

, °C

SimulatedMeasured

Figure D.3: Simulated and measured air temperature for experiment 5

280 300 320 340 360 380−4

−3

−2

−1

0

1

2

3

4

Time, hours

Tem

pera

ture

, °C

Figure D.4: Temperature difference between measured and simulated indoor airtemperature for experiment 5

Page 103: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

93

400 410 420 430 440 450 460

16

18

20

22

24

26

Time, hours

Tem

pera

ture

, °C

SimulatedMeasured

Figure D.5: Simulated and measured air temperature for experiment 6

400 410 420 430 440 450 460−4

−3

−2

−1

0

1

2

3

4

Time, hours

Tem

pera

ture

, °C

Figure D.6: Temperature difference between measured and simulated indoor airtemperature for experiment 6

Page 104: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

94 Simulated and Measured Indoor Temperature

Page 105: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

Appendix E

Predicted and Measured

Indoor Temperature

120 140 160 180 200 220 240 260

14

16

18

20

22

24

26One step prediction

Time, hours

Tem

pera

ture

, °C

PredictedMeasured

120 140 160 180 200 220 240 260−0.5

0

0.5

Time, hours

Res

idua

ls, °

C

Figure E.1: One step prediction for experiment 4

Page 106: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

96 Predicted and Measured Indoor Temperature

120 140 160 180 200 220 240 260

14

16

18

20

22

24

2612 step prediction

Time, hours

Tem

pera

ture

, °C

PredictedMeasured

120 140 160 180 200 220 240 260−1.5

−1

−0.5

0

0.5

1

1.5

Time, hours

Tem

pera

ture

, °C

Figure E.2: Twelve step prediction for experiment 4

0 0.5 1 1.5 2 2.5 30

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

Frequency

Nor

mal

ized

Cum

ulat

ed P

erio

dogr

am

Figure E.3: Cumulated periodogram for the one step prediction for experiment4

Page 107: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

97

280 300 320 340 360 38010

12

14

16

18

20One step prediction

Time, hours

Tem

pera

ture

, °C

PredictedMeasured

280 300 320 340 360 380−0.5

0

0.5

Time, hours

Res

idua

ls, °

C

Figure E.4: One step prediction for experiment 5

280 300 320 340 360 38010

12

14

16

18

2012 step prediction

Time, hours

Tem

pera

ture

, °C

PredictedMeasured

280 300 320 340 360 380−1.5

−1

−0.5

0

0.5

1

1.5

Time, hours

Tem

pera

ture

, °C

Figure E.5: Twelve step prediction for experiment 5

Page 108: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

98 Predicted and Measured Indoor Temperature

0 0.5 1 1.5 2 2.5 30

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

Frequency

Nor

mal

ized

Cum

ulat

ed P

erio

dogr

am

Figure E.6: Cumulated periodogram for the one step prediction for experiment5

400 410 420 430 440 450 460

14

16

18

20

22

24

26One step prediction

Time, hours

Tem

pera

ture

, °C

PredictedMeasured

400 410 420 430 440 450 460−0.5

0

0.5

Time, hours

Res

idua

ls, °

C

Figure E.7: One step prediction for experiment 6

Page 109: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

99

400 410 420 430 440 450 460

14

16

18

20

22

24

2612 step prediction

Time, hours

Tem

pera

ture

, °C

PredictedMeasured

400 410 420 430 440 450 460−1.5

−1

−0.5

0

0.5

1

1.5

Time, hours

Tem

pera

ture

, °C

Figure E.8: Twelve step prediction for experiment 6

0 0.5 1 1.5 2 2.5 30

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

Frequency

Nor

mal

ized

Cum

ulat

ed P

erio

dogr

am

Figure E.9: Cumulated periodogram for the one step prediction for experiment6

Page 110: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

100 Predicted and Measured Indoor Temperature

Page 111: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

Appendix F

MATLAB Source Code

Listing F.1: Principal Component Analysis� �

1 function [Y W] = pca ( data , component )23 i f nargin == 14 component = 1 ;5 end

67 component = component − 1;89 N = length ( data ( 1 , : ) ) ;

10 M = length ( data ( : , 1 ) ) ;1112 U = sum( data , 2 ) . /N;1314 B = data−U∗ones (1 ,N) ;1516 C = B∗B’ . /N;17 [V,D] = eig (C) ;1819 g = D(M,M)/sum(sum(D) )2021 W = V( : ,M−component ) ;2223 s = sqrt ( diag (C) )∗ones (1 ,N) ;24 Z = B./ s ;2526 Y = W’∗Z ;

� �

Listing F.2: Matrix Integration� �

1 function Y = matint (X, n)2 x l = 0 ;3 xu = 1/12;45 s = l inspace ( xl , xu , n) ;6 ds = s (2 )−s (1) ;7 Y = expm(X.∗ s (1) ) .∗ ds ;89 for i = 2 : ( n−1)

10 Y = Y + expm(X.∗ s ( i ) ) .∗ ds ;11 end

� �

Page 112: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

102 MATLAB Source Code

Listing F.3: Temperature Simulation� �

1 function T = simulateTemp (T0 , Z , U, Phi , Gamma1, Gamma2, h)23 i f nargin < 74 h = length (U) ;5 end

67 T = zeros (3 , h+1) ;8 T( : , 1 ) = T0 ;9

10 for i =1:h11 T( : , i +1) = Phi∗T( : , i )+Gamma1∗Z ( : , i )+Gamma2∗U( i ) ;12 end

� �

Listing F.4: Static controller� �

1 function U = s t a t i cCont r o l (T0 , Z , TrefI , Phi , Gamma1, Gamma2, n)23 T( : , 1 ) = T0 ;45 Umin = importdata ( ’ data /Umin . txt ’ ) ;6 Umax = importdata ( ’ data /Umax . txt ’ ) ;78 U = ones (1 , n) .∗Umin ;9

10 for i =2:n11 i f T(1 , i −1) < Tref I (1)12 U( i −1) = Umax;13 e l s e i f T(1 , i −1) > Tre f I (2)14 U( i −1) = Umin ;15 e lse

16 U( i −1) = U( i −2) ;17 end

1819 T( : , i ) = Phi∗T( : , i −1)+Gamma1∗Z ( : , i −1)+Gamma2∗U( i −1) ;20 end

� �

Listing F.5: Cost Function� �

1 function [ J T] = costFunct ion (X)23 i f sum(X < 0) > 04 J = (min(X)−10) ˆ10 ;5 return ;6 e l s e i f sum(X > 10) > 07 J = (max(X) ) ˆ10 ;8 return ;9 end

1011 Gamma1 = importdata ( ’ data /Gamma1. txt ’ ) ;12 Gamma2 = importdata ( ’ data /Gamma2. txt ’ ) ;13 Phi = importdata ( ’ data /Phi . tx t ’ ) ;14 Z = importdata ( ’ data / ambientInput . tx t ’ ) ;15 Umin = importdata ( ’ data /Umin . txt ’ ) ;16 Pri c e = importdata ( ’ data / p r i c e s . tx t ’ ) ;1718 X = X + Umin ;1920 %−−−−−−−−−−−−−−−−−−−−−−−−21 t = importdata ( ’ i t e r . tx t ’ ) ;22 Ti = importdata ( ’T. txt ’ ) ;23 %−−−−−−−−−−−−−−−−−−−−−−−−2425 T0 = Ti ( : , t ) ;2627 p = Pr i ce (1 , t : ( t+35) ) ;2829 U = zeros (1 ,36) ;30 U( 1 : 6 ) = X(1 ) ;31 U( 7 : 1 2 ) = X(2) ;32 U(1 3 :18 ) = X(3) ;33 U(1 9 :24 ) = X(4) ;34 U(2 5 :30 ) = X(5) ;35 U(3 1 :36 ) = X(6) ;3637 Z = Z ( : , t ) ;3839 T = zeros (3 , h+1) ;40 T( : , 1 ) = T0 ;41

Page 113: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

103

42 for i =1:3543 T( : , i +1) = Phi∗T( : , i )+Gamma1∗Z+Gamma2∗U( i ) ;44 end

4546 Tref = −0.86623172407407; %˜20C

4748 k = 2;49 alpha = 1 ;50 J i = ( (T( 1 , : )−Tref ) . / alpha ) .ˆ4+k .∗p .∗ (U−Umin) ;51 J = sum( J i ) ;

� �

Listing F.6: Scripts for determining the optimal heat input� �

1 clear a l l ;23 initCF ;45 Umin = importdata ( ’ data /Umin . txt ’ ) ;6 T0 = importdata ( ’ data /T0 . txt ’ ) ;7 Z = importdata ( ’ data / ambientInput . tx t ’ ) ;8 Phi = importdata ( ’ data /Phi . tx t ’ ) ;9 Gamma1 = importdata ( ’ data /Gamma1. txt ’ ) ;

10 Gamma2 = importdata ( ’ data /Gamma2. txt ’ ) ;1112 for i =1:115 ,13 [X,FVAL,EXITFLAG,OUTPUT] = fminunc ( @costFunction , ones (1 ,6) ∗5)14 i f i ==1,15 U = x ( 1 : 2 ) ;16 e lse

17 U = [U x ( 1 : 2 ) ] ;18 end

1920 Uopt = getU (U) ;2122 T = simulateTemp (T0 , Z , Uopt , Phi , Gamma1, Gamma2)2324 i t e r = 1+12∗ i2526 save T. txt T −ASCII −DOUBLE;27 save U. txt U −ASCII −DOUBLE;28 save i t e r . tx t i t e r −ASCII ;29 end

� �

Listing F.7: Cost of heat� �

1 function [ p e ] = ge tPr i c e (U)2 Pri ce = importdata ( ’ p r i c e . tx t ’ ) ;34 n = length (U) ;56 e = sum(U) /12 ;7 p = sum(U.∗ Price ( 1 , 1 : n) ) /12 ;8 disp ( [ ’ Energy Usage : ’ num2str ( e ) ’kWh ’ ] ) ;9 disp ( [ ’ Pr ic e : ’ num2str (p ) ’ Euro ’ ] ) ;

10 disp ( [ ’ Average Pr i ce : ’ num2str (p/e ) ’ Euro ’ ] ) ;� �

Page 114: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

104 MATLAB Source Code

Page 115: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

Appendix G

Simulated Indoor

Temperature due to Dynamic

Controller

Figure G.1: Simulated indoor temperature with heat input from a dynamiccontroller that minimizes Equation 8.3 with k = 0.5.

Page 116: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

106 Simulated Indoor Temperature due to Dynamic Controller

Figure G.2: Simulated indoor temperature with heat input from a dynamiccontroller that minimizes Equation 8.3 with k = 1.

Figure G.3: Simulated indoor temperature with heat input from a dynamiccontroller that minimizes Equation 8.3 with k = 4.

Page 117: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

107

Figure G.4: Simulated indoor temperature with heat input from a dynamiccontroller that minimizes Equation 8.3 with k = 8.

Figure G.5: Simulated indoor temperature with heat input from a dynamiccontroller that minimizes Equation 8.3 with k = 16.

Page 118: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

108 Simulated Indoor Temperature due to Dynamic Controller

Page 119: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

Bibliography

[Ara] Ander Goikoetxea Arana. FlexHouse. Technical report, Risø.

[Cen99] Yunus A. Cengel. Heat and Mass Transfer - a Practical Approach.McGraw-Hill, 1999.

[Fri06] Nynne Friling. Stochastic Modelling of Building Integrated Photo-voltaic Modules. Master’s thesis, Technical University of Denmark,DTU, 2006.

[God80] K.R. Godfrey. Correlation methods. Automatica, 16:527–534, 1980.

[Mad85] Henrik Madsen. Statistically Determined Dynamical Models for Cli-

mate Processes. PhD thesis, Technical University of Denmark, DTU,1985.

[Mad06] Henrik Madsen. Time Series Analysis. IMM, 2006.

[MH95] Henrik Madsen and J. Holst. Estimation of continuous-time modelsfor the heat dynamics of a building. Energy and Buildings 22, 1995.

[MK03a] Henrik Madsen and Niels Rode Kristensen. CTSM 2.3 - MathematicsGuide, 2003.

[MK03b] Henrik Madsen and Niels Rode Kristensen. CTSM 2.3 - User’s Guide,2003.

[MNSW] Henrik Madsen, Allan A. Nielsen, Bjarne Saxhof, and Kim Wittchen.Models for the Heat Dynamics of Buildings. Technical report, Tech-nical University of Denmark, DTU.

Page 120: Dynamic Optimization of Power Consumptionetd.dtu.dk/thesis/220841/ep08_49_net.pdf · Dynamic Optimization of Power Consumption ... • A solar panel ... an intelligent controller

110 BIBLIOGRAPHY

[MS] Henrik Madsen and J.M. Schultz. Short Time Determination of theHeat Dynamics of Buildings. Technical report, Technical Universityof Denmark, DTU.

[Pou07] Niels Kjølstad Poulsen. Stokastisk Adaptiv Regulering. 2007.

[Sto07] Anders Stouge. Husholdninger skalbelønnes for intelligent elforbrug, 2007.http://www.prisfolsomtelforbrug.dk/documents/Husholdninger skal belonnes 08.01.07.pdf.