Full text
Research Assignment for exchange students Building comfort control using MPC Development of a Coupled EnergyPlus-MATLAB Simulation Framework for Model Predictive Control of Integrated Electrical and Thermal Residential Renewable Energy System. Author: Vincenzo Ezio Santovito Director: Ramon Costa Castelló Call: July 2022 Escola Tècnica Superior d’Enginyeria Industrial de Barcelona
2
Building comfort control using MPC 3 Abstract The urge of modernizing the building stock in the European Union comes from one clear evidence: it is the largest energy consuming sector, accounting for up to one-third of the total final energy consumption. The vast majority of houses and offices in EU countries were built before 1990 and did not undergo any renovation, meaning they show poor thermal insulation capability, and no smart technique is implemented for the control and reduction of both the electricity and heating demands. This results in significantly high emissions. Almost 40% of EU carbon dioxide emissions indeed come from the building sector [1] , indirectly in the construction process and directly during operation. The set of contaminants also include greenhouse gases such as hydrofluorocarbons, fine particles (PM2.5/PM10) and toxic dusts recognized as one of the main causes of cancer onset [2]. This is precisely related to the fuel mix each country employs to cover the sector needs: 38.2% of the OECD countries residential demand is covered by natural gas and a phasing-out 10% by oil [3]. Technologically advanced solutions such as hydrogen Fuel Cells, integrated with other renewable sources, can represent a clean solution to push down emissions but also energy consumptions by digitalizing the system and implementing control strategies to optimally match demand and generation. This study aims at developing a coupled EnergyPlus-MATLAB Simulation Framework of an integrated electrical and thermal residential renewable energy system with a Model Predictive Controller (MPC) to size and control the operation of a fuel cell stack. A recently renovated single-family house in the province of Turin (IT) is the case-study modelled in EnergyPlus. The simulation requires the building geometry and thermophysical properties and the weather conditions as inputs, and by designing appropriately the controller, a schedule for the heating demand and the resulting evolution of the indoor temperature is obtained.
4 Table of contents TABLE OF CONTENTS _________________________________________ 4 1. INTRODUCTION ___________________________________________ 5 2. THE CORTAU HOUSE CASE-STUDY __________________________ 8 2.1. The Nearly-Zero Energy Building concept ....................................................... 8 2.2. Introduction to the case study .......................................................................... 9 2.3. Building modelling in EnergyPlus .................................................................. 16 3. PROTON EXCHANGE MEMBRANE FUEL CELL ________________ 20 3.1. Introduction .................................................................................................... 20 3.2. PEMFC basics and mathematical model ...................................................... 21 4. MODEL PREDICTIVE CONTROL IMPLEMENTATION ____________ 35 4.1. Introduction to MPC ....................................................................................... 35 4.2. Model Predictive Control design parameters ................................................. 37 4.3. The controller mathematical formulation ....................................................... 39 4.4. MATLAB – EnergyPlus co-simulation interface ............................................. 43 4.5. MPC implementation to the CorTau house ................................................... 49 4.5.1. Linear model development .................................................................................. 49 4.5.2. MPC implementation without EnergyPlus .......................................................... 55 4.5.3. MPC implementation with EnergyPlus co-simulation ......................................... 63 CONCLUSIONS ______________________________________________ 69 BIBLIOGRAPHY ______________________________________________ 70 APPENDIX A – MATLAB CODE _________________________________ 72
Building comfort control using MPC 5 1. Introduction 1.1. Project motivation The renovation and decarbonization of the EU’s building stock is among the key objectives of the Green Deal set of initiatives through which the European Commission aims at reaching the ambitious goal of carbon neutrality by 2050. The reasons behind the high effort put in this direction can be found primarily in the evidence that the building sector is responsible for almost 40% of the total European countries demand for energy according to the DIRECTIVE 2010/31/EU of Energy Performance of Buildings (EPBD). The sector produces about 36% of the total EU greenhouse gases (GHG) emissions, with more than 60% of all imported natural gas used to cover houses and offices energy demand. Given that 86% of the housing stock in south Europe was built before 1990 and did not undergo any renovation, an improvement in their energy performance is necessary to drastically reduce their footprint. Poor thermal insulation capability, infrequent implementation of electricity saving strategies and the reliance on fossil fuels for both heating and power demand are the main issues that nowadays the building sector needs to alleviate. Last but not least, an efficient building performance directly reflects on bills reduction and the improvement of the household living quality, in terms of both thermal and lightning comfort and air quality levels. The amended Energy Efficiency Directive (EU) 2018/2002 updated the Directive 2012/27/EU, setting a target of energy efficiency improvement of at least 32.5% for 2030. The Article 9 of the EPBD introduced the concepts of the Net zero-energy building (NZEB) or nearly (nZEB) [4] , whose design is made following bioclimatic architecture principles in order to cut down the energy request. Each EU country transposes both directives to their regulation, establishing a 10-year integrated national energy and climate plan (NECP) for 2021-2030 to reach the goals in the defined timeframe. A variegate set of actions can be taken to modernize the building stock. This include on one side the improvement of the thermophysical properties of the envelope, for instance adopting PCM material to insulate the building, renovating the windows glazing and sealing connections and integrating the newest technologies to supply heat and power to increase the independence from both the gas and electricity grids. The implementation of Demand Side Management strategies can further push down wastes and the costs charged to the house inhabitants. A combination of these expedients can contribute to save on fuel consumption, (between 50-70% reduction), using more efficient heating and cooling equipment to satisfy loads (for instance Fuel Cells), implementing energy control strategies, i.e. digitalizing the energy systems for buildings. In this context, this work aims at developing a control algorithm to integrate a hydrogen Fuel Cell into the single-family Cor-Tau House located in Livorno Ferraris (IT) to supply heat in the winter season. Fuel cells are actually among the most promising technologies in the decarbonization process of all energy intensive sectors, from industry to residential to transport. This is particularly true when the hydrogen employed as energy vector is produced from renewables using electrolyzers. The advantage of this technology is that it can provide both heat and electricity through an electrochemical process.
6 1.2. Methodology The first requirement to develop the research is the availability of a building model suited to perform energy balance simulation. EnergyPlus™ is a whole building energy simulation program that engineers, architects, and researchers use to model both energy consumption for heating, cooling, ventilation, lighting and plug and process loads and water use in buildings. [5] The building is commonly modelled as an Intermediate Data Format (IDF) file, a format used to interoperate between electronic design automation (EDA) software and solid modeling mechanical computer-aided design (CAD) software [6]. This IDF file contains all the information needed to run an energy dynamic simulation, including the geometrical charachterization of the building and a number of functionality and advanced features to make it as real as possible. For instance, it can include occupancy and lightning schedules, HVAC system operation, combined heat and mass transfer models and the building subdivision in thermal zones. The software requires a weather data file in the EPW format, which provides a database of weather data for a given specific location. The controller is designed in MATLAB, and the YALMIP Toolbox is used to declare both the decision and the output variables and to formulate the core optimization algorithm of the MPC, namely the objective function and the problem constraints. The following step would be setting the co-simulation between EnergyPlus and the MATLAB environment to implement the Model Predictive Control (MPC) technique. This can be achieved with the aid of sophisticated MATLAB toolboxes like MLE+ and the Building Controls Virtual Test Bed to implement the data exchange as input to and output from EnergyPlus. MPC is a powerful feedback control algorithm based on optimization. It uses a model to make predictions about future outputs of a process, in this specific case the Fuel Cell operation in the building. Starting from an initial state, the main idea is to run forecasts of the model over a short time period, minimizing at each timestep the deviation of the indoor temperature from the setpoint for each heated room. The variable over which the optimization is performed is the heat generated by the fuel cell as a by-product of the H2/O2 reaction. The reasons behind the spread of this powerful control strategy are first its capability of handling multi-input multi-output (MIMO) systems, in which a change on one single output can have an impact on all the others, and secondly the possibility of imposing constraints on the system state, meaning that in principle both the decision and the output variable can be limited within some previously defined boundaries during the controller operation. This is a MPC peculiarity, as for other techniques in which the actuation is thought-out as a continuous variable, in some cases the controller optimization core could compute an input sequence resulting unfeasible for the real application it refers to. Last but not least, Model Predictive Control can be implemented for both linear and nonlinear models. Even if the linear MPC design is easier and the controller optimizer works faster, a large number of real-world phenomena are however intrinsically non-linear, and they are therefore described by non-linear models. If this nonlinearity is nonetheless moderate, the so-called Adaptive and Gain Scheduled MPC controllers are the two available methods to couple with a local linearization of the model.
Building comfort control using MPC 7 For the case study in analysis here, the model to feed to the controller would be a linearized energy balance on each thermal zone of the building. As the control action sequence is computed, the hydrogen rate to feed a market available fuel cell stack will be the ultimate result of the analysis.
8 2. The CorTau House Case-study 2.1. The Nearly-Zero Energy Building concept The building sector produces about 36% of the total EU greenhouse gases (GHG) emissions, with more than 60% of all imported natural gas used to cover houses and offices energy demand. Given that 86% of the housing stock in south Europe was built before 1990 and did not undergo any renovation, an improvement in their energy performance is necessary to drastically reduce their footprint. The amended Energy Efficiency Directive (EU) 2018/2002 updated the Directive 2012/27/EU, setting a target of energy efficiency improvement of at least 32.5% for 2030. The Article 9 of the EPBD introduced the concepts of the Net zeroenergy building (NZEB) or nearly (nZEB) [7] , whose design is made following bioclimatic architecture principles in order to cut down the energy request. Each EU country transposes both directives to their regulation, establishing a 10-year integrated national energy and climate plan (NECP) for 2021-2030 to reach the goals in the defined timeframe. The Italian implementation of the Energy Performance of Building Directive sets the minimum requirements for existing buildings according to the extent of the renovation intervention: • Major renovations – first level (defined as “refurbishment of at least 50% of the envelope and renovation of the heating and/or cooling plant of the entire building”). For building enlargements (new volume > 15% of the existing volume or > 500 m3 ) these standards apply to the new volume. • Major renovations – second level (defined as “refurbishment of at least 25% of the external surfaces of the building with or without renovation of the heating and/or cooling plant”). The U-value of the concerned surfaces is lower than the limit values. The mean transmission heat transfer coefficient of refurbished building elements is lower that the limit value. The mean efficiencies of renovated technical building systems are higher than the reference values. • Minor renovations (defined as “refurbishment of less than 25% of the external surfaces of the building and/or modification of the heating and/or cooling plants). The performance of single components or of the technical building systems has to comply with mandatory limit values.
Building comfort control using MPC 9 2.2. Introduction to the case study Within the context of the implementation of the DIRECTIVE 2010/31/EU of Energy Performance of Buildings (EPBD) and thus the development and construction of nZEB, the CorTau house is a significative project developed in Livorno Ferraris, a municipality in the Province of Vercelli in the Italian region of Piedmont, located about 40 kilometers northeast of Turin and about 25 kilometers west of Vercelli. The project consisted in the full recovery and renovation of a typical rural building of the Piedmont region called “curmà”. The construction of this single-family house begun in March 2014 and ended in 2016. Figure 2.2.1 – The CorTau House project The CorTau House experience, as a renovation of a typical Piedmont rural building, can be extended to a variety of already existing building, complying with the requirements of the Italian NZEB legislation, ensuring the total independence from fossil fuels being the house completely electric and self-sufficient in terms of energy production, with the on-site energy production sustained by PV panels on the roof and the heat extraction from groundwater.
16 2.3. Building modelling in EnergyPlus The detailed description of the modelling process in EnergyPlus is out of the scope of this document, however a focus on the aspects directly affecting the MPC design and response is needed to fully understand how the MATLAB and EnergyPlus co-simulation actually works, and which are the major factors influencing the temperature evolution. The CorTau House is subdivided in eight thermal zones, and the controller will work independently on each of the heated ones, therefore the entrance bush will not be included in the simulation. Figure 2.3.1 – EnergyPlus building model subdivision in thermal zones Table 2.3.1 -Thermal zones list Zone Name Floor Area (m2) Heating ZT 1 Kitchen 48,7 YES ZT 2 Living Room 19,1 YES ZT 3 Night Area 27,4 YES ZT 4 Studio 20,5 YES
Building comfort control using MPC 17 ZT 5 Bathroom1 5,3 YES ZT 6 Bathroom2 3,5 YES ZT 7 Bathroom3 6,9 YES ZT 8 Entrance bush 5 NO To define each thermal zone the software requires first the orientation with respect to the North direction and the zone dimensions, thus the ceiling height, the internal volume and the floor area. Once this is completed, the next step would be detailing all the surfaces charachteristics for each thermal zone in a new EnergyPlus object. Here the outdoor wall for the ZT1 Kitchen zone is reported as an example, assigned to the ZT1 Kitchen zone and the External Wall construction objects. !- ======== ALL OBJECTS IN CLASS: BUILDINGSURFACE:DETAILED ======= BuildingSurface:Detailed, ZT1P1, !- Name Wall, !- Surface Type External Wall, !- Construction Name ZT 1 Kitchen, !- Zone Name , !- Space Name Outdoors, !- Outside Boundary Condition , !- Outside Boundary Condition Object SunExposed, !- Sun Exposure WindExposed, !- Wind Exposure autocalculate, !- View Factor to Ground autocalculate, !- Number of Vertices
18 5.52,0,3.15, !- X,Y,Z ==> Vertex 1 {m} 5.52,0,0, !- X,Y,Z ==> Vertex 2 {m} 5.52,-3.85,0, !- X,Y,Z ==> Vertex 3 {m} 5.52,-3.85,3.15; !- X,Y,Z ==> Vertex 4 {m} The construction object includes all the material layers, which are in turn defined in a corresponding material object. The examples for the External Wall and its coating are reported below. !- =========== ALL OBJECTS IN CLASS: CONSTRUCTION =========== Construction, External Wall, !- Name EW - RIV. EST., !- Outside Layer EW - ISOL., !- Layer 2 EW - LAT., !- Layer 3 EW - CART., !- Layer 4 EW - INT.; !- Layer 5 !- =========== ALL OBJECTS IN CLASS: MATERIAL =========== Material, EW - RIV. EST., !- Name MediumRough, !- Roughness 0.004, !- Thickness {m} 45, !- Conductivity {W/m-K} 7680, !- Density {kg/m3} 840; !- Specific Heat {J/kg-K}
Building comfort control using MPC 19 Various parameters can be extracted by running the EnergyPlus IDF File through the EP- Launch, the official software launcher managing input and output files and performing batch simulations. Among the various thermal zone object outputs, the Zone Mean Air Temperature is the one of interest in the controller design.
20 3. Proton Exchange Membrane Fuel Cell 3.1. Introduction Fuel cell is nowadays among the most promising technologies in the framework of energy transition. The high interest put in this direction by the scientific community is primarily due to the fact that most fuel cells are hydrogen-fuelled devices able to supply clean and safe electrical but also thermal energy thanks to electrochemistry. The first attempt to exploit hydrogen to produce electricity is dated back to 1839, when Sir William Grove developed a rudimental fuel cell with a combination of sheet iron, copper and porcelain plates, and a solution of sulphate of copper and dilute acid. [8] A number of sectors found in fuel cells an interesting alternative to more standard solutions, with the first commercial use being the deployment of an Alkaline Fuel Cell (AFC) in a manned flight of the NASA Gemini 5 space program in 1965. With the development of other fuel cell types, the focus shifted on stationary power production, terrestrial transportation applications and both portable devices and building supply of electricity. Figure 3.1.1– Fuel cell schematic
Building comfort control using MPC 21 An electrochemical cell is converting the chemical energy of a fuel, often but not always hydrogen H2, into electricity through RedOx reactions with oxygen O2. The performance is strictly related to the technology but in general the conversion efficiencies reach values way above those observed in classical heat engines based on combustion. The thermal energy obtained as a secondary product can be either expelled or employed in a variety of applications, as in this case building heating. The main difference between traditional combustion devices and this technology is that while in the first the reduction and oxidation reactions occur at the same place and time, in fuel cells they are separated in space, letting the resulting electron flow supply a load connected to the cell’s terminals The temperature difference ΔT is the thermodynamic driver for the gas-turbine engines operation. This is not the case for fuel cells, where the thermodynamic driver is actually the chemical potential difference between the species involved in the RedOx reactions. In addition to this, the electricity is produced directly from electrochemistry avoiding the multiple conversion steps needed for power production through standard combustion engines. Last but not least, fuel cell output scales with the surface area and not the device volume. This means that, differently from heat engines, they can be made efficient at small sizes. All the heat engines are subject to the Carnot cycle limitation on the efficiency (3.1.1) and similarly, also Fuel Cells are subject to an efficiency limitation coming from the analysis of the ideal reversible operation. [9] 3.2. PEMFC basics and mathematical model Proton-exchange membrane fuel cells are one of the most promising technology due to their light weight, the low pressure and temperature ranges of operation and the fact that they can
22 employ pure hydrogen and oxygen to produce primarily electricity but also water and heat as by-products. H2 undergoes the oxidation half reaction at the anode side while oxygen undergoes reduction at the cathode side, as reported in the figure below. Figure 3.2.1 – RedOx reactions for PEM Fuel Cell The fuel cell theoretical potential es computed for the overall reaction is 1.23 V. The measured voltage for real cell operation reduces because of various losses to analyse later. Figure 3.2.2 – Membrane electrode assembly of PEMFC
Building comfort control using MPC 23 Various materials are needed to accomplish the electrochemical production of electricity from the fuel cell. The device is built as a membrane electrode assembly (MEA), constituted of a thin proton-exchange membrane (generally NafionTM) permeable to hydrogen ions (protons, H+) but impermeable to electronic flows, but also two electrodes (the cell anode and cathode) physically separated by the PEM and a carbon supported catalyst layer on both. o Proton-Exchange Membrane It is made of a fluorocarbon polymer backbone on which sulfonic acid groups SO-3 have been bonded through a chemical process, as in the fluoropolymer NafionTM commercialized by DuPont. The membrane is designed to let ionic flows from the cathode side to the anode while acting as an electronic insulator. The main functions of the membrane are thus the separation of the two RedOx semi-reactions and the fact that it avoids the recombination of H+ and e- (i.e., the cell short circuit), acting as a barrier to the crossover mixing of the fuel and the oxidant. An external circuit connected to the load is provided for the electron current. [10] The membrane must provide both mechanical and chemical stability to bear the oxidizing and the reducing environment at the two electrodes sides. The characterization of the PEM is mainly done through three parameters [11] - Proton conductivity σ - Methanol permeability P (as employed also in Direct Methanol Fuel Cells DMFC) - Thermal stability The Nafion® membrane, the most common proton exchange membrane employed in fuel cells applications, shows a proton conductive resistance that is inversely proportional to the membrane water content [12] and thus a proper hydration of the electrolyte membrane is required. The water management issue is crucial to the cell performance and a recirculation from the reaction site towards the membrane to keep it at the correct level of water content is possible. This could be both active (involving additional external elements) or passive (by means of pressure and concentration gradients along the electrolyte). A water layer management at the cathode side is typically added to the fuel cell structure to increase the water flow resistance towards the external environment and therefore to promote its passive back flow to the anode. o Catalytic Layer
24 The catalytic layer CL is the most active sublayer of the cell membrane assembly, being its main functions the increase of the reaction rates at both electrodes and the selectivity towards the desired products. A number of materials or alloys can be employed, with PtM, M=Ru, Pd, Ni, Rh, V, Mo, W at the anode side and PtN, N=Co, Fe or Mn at the cathode being the most common. Figure 3.2.3 – Catalytic layer configuration The catalyst design is key to the cell performance. In the most common configuration for PEM Fuel cells, Pt nanoparticles with a diameter of about 5 nm are supported on a carbon structure able to supply a large surface area, good electrical conductivity and inertness as far as the cell reactions are concerned. The catalyst loading and utilization is typically in the range of 0.3-0.4 mg/cm2 on both electrodes. The CL is designed as a 3D network in order to maximize the contact between the ion conductor (the electrolyte), the electron conductor (the electrode) and the gas phase in what is called Triple Phase Boundary TPB, the electrochemically active sites where the reaction takes place. Half of the total FC cost is due to the need of precious metals in the catalytic layer [13] . For this reason, a high effort is put in finding alternative solutions in order to make PEMFC economically favourable over other technologies. The other main issue related to the catalyst is that the cell voltage, and thus the power production, is greatly reduced when the CL is poisoned by carbon monoxide CO or sulphur Z. Nowadays the hydrogen production still massively relies on steam reforming of light hydrocarbons, whose product is a gas mixture containing hydrogen but also poisoning species. Additional fuel processing is required if hydrogen is feeding a PEMFC.
Building comfort control using MPC 25 o Collector and Gas diffusion layer The collector plate on one side provides a pathway for the reactant gases and the product water ensuring a uniform gas distribution over the electrode active area, and on the other gives the assembly mechanical support and structural rigidity. The gas diffusion section instead is a porous structure made of carbon fibre-based material composed of two sublayers, one being the electrode and the other being the proper microporous layer. As a whole, they allow the flow of both the reactants and the water produced in the reaction, and they must be both electrically and thermally conductive to dissipate the heat generated during the cell operation towards either the external environment or a heat recovery system. The following gives an idea on how and where the various steps of the FC operation take place. Figure 3.2.4 – PEMFC operation steps 1. H2 and O2 gaseous flow through the collector plates’ channels
32 The model is obtained setting an ideal voltage of 79.95 V for the FC stack, as obtained multiplying the theoretical ideal voltage of 1.23 V by the number of cells in the stack. Figure 3.2.7 – Curve Fitting Toolbox setting a = 24.33 V b = 1.242 V R = 19.82 Ω cm2 , total internal resistance of the FC stack.
Building comfort control using MPC 33 Figure 3.2.8 – Nedstack PS6 polarization curve fitting residuals As far as the power production is concerned, the electrical generation would simply be the product of the voltage at the stack terminal and the current produced, while the thermal loss would be the difference between the electrical generation in ideal conditions and the actual production. Figure 3.2.9 – Voltage contributions to the stack electrical and thermal power
34 Figure 3.2.10 – Fuel Cell stack power curves
Building comfort control using MPC 35 4. Model Predictive Control implementation 4.1. Introduction to MPC Model Predictive Control, commonly referred to as MPC, is a control strategy widely employed in various sector, from autonomous vehicles to industry automatization to building integration, based on an iterative and finite-horizon optimization of a plant model. It first appeared in literature in the late 1970s, but its implementation gained popularity in the Chemical Process Industry sector in the 1980s. The feedback algorithm which the controller is based on takes advantage of an already defined dynamic model to make predictions about future actions effect on the system output [17]. Model Predictive Control is also commonly known as Receding Horizon Control because of the forward-moving nature of the prediction horizon. One of the strengths of MPC is its capability to handle multi-input multi-output systems (MIMO), meaning it can control more than one single parameter receiving a number of inputs and therefore performing multi-dimensional optimizations. In other words, MPC is a multivariable controller simultaneously acting on a number of outputs taking into account the interaction between the system parameters. In MIMO plants a single output variation can in fact have an influence on all the others. Model Predictive Control relies on optimization algorithms over a more or less wide timeframe called control horizon, performed at each time step of the prediction horizon. The main idea is to build a flexible procedure for which, once the system model and a reference for the output are well defined, a forecast of the plant behaviour is performed forward in time. At the initial time step the controller receives measured quantities characterizing the present state of the system. For the Fuel Cell case study analyzed here, a sensor will monitor the indoor temperature of the building, whose regulation directly depends on the cell heat production. This means that the controller receives the initial indoor air temperature, optimizes the heat release and the fuel cell operates until the subsequent time instant. The temperature is measured again and compared with the setpoint. The resulting deviation of the predicted outputs from the goal temperature setpoint is the quantity that the optimizer will minimize. The cycle ends with the input updating, the control horizon shifting and the problem reinitialization.
36 Figure 4.1.1 – Basic Structure of Model Predictive Control [18] Another reason behind the wide spread of MPC controllers is the chance to impose constraints on the state of the system but also on the input coming from the controller. The introduction of a plant state monitoring to ensure that its variables never fall out of a specified range and a constraint in the controller optimization algorithm can be extremely helpful, as for instance in this study the indoor temperature should be kept below a certain threshold and at the same time the cell heat production is always linked to and limited by its rated electrical power. The whole process can get computationally expensive when a multi-variable optimization is performed at each time step. Nowadays a compromise between the deviation of the output from the reference minimization and the machine computational effort is asked for but in the future the development of increasingly fast computers and hardware will alleviate this issue. It is necessary to remark that MPC requires a system model to run the control algorithm. Linear models are easily controllable, while non-linear ones require a linearization process and specific algorithms. In summary, the goal of the controller is the evaluation of the input to the plant such that the system output reaches and follows as fast as possible a target reference. The way Model Predictive Control carries out this simple idea is actually predicting the future plant output behaviour through a mathematical model of the system, minimizing the error between the prediction and the target.
Building comfort control using MPC 37 4.2. Model Predictive Control design parameters The first task to accomplish in the design process of the MPC controller is the parameters setting. By choosing adequately their values the controller performance can be improved and the computational complexity of the online algorithm reduced. The most important ones are • Sample Time ts • Control Horizon c (with the corresponding number of timesteps Nc) • Prediction Horizon p (with the corresponding number of timesteps Np) The sample time ts is the time step at which the MPC is actuated. It sets the rate at which the control algorithm is executed. If the sample time is too big, the controller could be unable to react fast enough to disturbances possibly interfering with the system. On the other hand if it is too small, the performance would be surely improved but with an increased computational cost. The general recommendation is to set ts between 10% and 25% of the minimum desired closed-loop response time [19]. The total number of time steps over which the control strategy is implemented is called prediction horizon p. This can alternatively be defined as the timeframe over which the prediction is made. This quantifies how far the MPC pushes the prediction in time. In buildings application p is commonly set in the range of days or weeks, subordinate to the availability and reliability of weather data. The external temperature, the solar radiation, the indoor and outdoor air humidity and the wind speed all affect the system state (i.e. the internal temperature Tindoor) through heat exchange processes between the outdoor and the indoor ambient. The sample time ts and the prediction horizon p settings should be among the first steps of the controller design, with the first easily adjustable once the user understands which value can capture disturbances and system dynamics without dramatically increasing the computational cost. The controller operates the optimization over a more or less wide timeframe called control horizon c. This parameter can naturally range between the sample time ts and the entire prediction horizon p. At the current timestep the optimization algorithm works over the entire control horizon providing a set of control actions uk , … , uk+c that are all discarded except for uk+1 , the one related to the following timestep. This is recorded, actuated and thus used to reinitialize the controller. The control horizon is then shifted one time step forward. The
38 smaller is c, the less are the control actions that the optimizer has to compute but prediction quality will lack accuracy since at the current time step the controller receives a larger amount of information about the future disturbance on the system (i.e. the weather condition) and can therefore calibrate the control action set . Nevertheless control moves’ effect on the predicted output behaviour significantly weakens throughout the control horizon. A good rule of thumb for c is setting it to around 10 ÷ 20% of p and covering at least 2-3 time steps. Figure 4.2.1 – MPC Design Parameters [20] MPC can incorporate constraints on the input and output values but also on the inputs’ rate of change. This means that the algorithm typically implements a limitation on the variation of the u value from one time step to the subsequent along with the minimization of the output deviation from the goal. Here this will translate in limiting the variation of the fuel cell heat production over time, since fast changes could affect the household comfort. Constraints can be either hard or soft, according to whether a violation is actually possible (even if not desirable) or definitely not. Having hard constraints on both inputs and outputs is not advisable since they could conflict one with each other or lead to unrealistic solutions. Another recommendation is to avoid having simultaneously hard constraints on inputs and their rate of change. The MPC controller looks for the output evolution in time that gets as close as possible to the
Building comfort control using MPC 39 set target, but at the same time a set of smooth control moves is desired from the user perspective in order to avoid abrupt changes in the system state. The way to achieve a balanced performance between these competing goals is to weigh the input rates and output relative to each other in the optimization objective function J, also commonly referred to as cost function. It is represented as a weighted squared sum of the predicted errors and the input increments. While minimizing the cost function at the current time step, the MPC controller also checks that both inputs and outputs stay within the constraints, as pointed out previously. The smallest value of the cost function J determines the optimal input sequence over the control horizon c. At the current time step k the controller records the first value of the u optimal sequence found by the algorithm and erases all the others. The controller gets a new measurement of the system state variable resulting from the combination of the optimal input found before and the effect of the disturbances. This might be slightly different than what the controller had predicted in the optimization over c. 4.3. The controller mathematical formulation Optimization is the core of MPC. How the controller searches for the optimal set of input values at each time step strongly depends on the mathematical formulation of the system model, and the chance of linearizing it as the major discriminating factor. If the model is linear, it has linear constraints and a quadratic cost function is built, the system can be controlled by a linear time-invariant MPC. In this case the cost function is naturally convex, thus showing one single global optimum. The algorithm goal will therefore be finding this optimum, whose existence is ensured when the properties listed before are all verified. If the system is instead nonlinear, linear MPC can be however implemented if the model itself can be linearized, with all the benefits of the convex optimization problem. The adaptive and gain-scheduled MPC controllers are the two methods available for this kind of problem. For instance adaptive MPC updates at each time step the nonlinear model with its linearization. The optimization problem keeps the same mathematical formulation between a time step and the subsequent over the entire prediction horizon, and so do the constraints. Gain-scheduled MPC is commonly carried out if instead a tracking on the operating condition to modify the constraints is needed. Here the linearization at the operating point is performed offline and a thus a linear controller is designed for each operating point. These controllers are equipped with their own variables’ constraints and work independently
40 one from each other. The algorithm needs a code to switch between controllers when the plant operating conditions change. Gain-scheduled MPC evidently requires a larger memory to store all the pre-defined controllers. The general recommendation is to resort to the adaptive method when the plant model can be locally linearized, and the design constraints are fixed independently from the system state. In case of nonlinear system that cannot be represented at all with linearized models, then nonlinear Model Predictive Control is needed. The system modeling can be highly realistic and as a consequence the controller prediction can be extremely accurate. Solving the optimization problem for a nonlinear cost function can get extremely tough when nonlinear constraints are set on the variables, since J becomes nonconvex, meaning it shows multiple local minimum. Finding the global one among them is not an easy numerical task. The general quadratic cost function formulation for a multi-input and multi-output problem in 2-Norm is (4.3.1) where - N is the time control horizon - is the input variables’ vector - and are Squared Euclidean Norms - are positive semi-definite matrices - is a positive definite matrix The Constrained Finite-Time Optimal Control (CFTOC) problem can be formulated as a minimization of the cost function over the time horizon N
Building comfort control using MPC 41 (4.3.2) In this problem the linear multi-variable system is described as (4.3.3) meaning that at the future time step k+1 the plant state xk+1 is a linear combination of the current state xk and input uk. , and are polyhedral regions, namely the variables’ domains in multi-dimensional application. Here the constraints are included. For SISO models, they naturally translates into intervals in . For Predictive Control (i.e. Receding Horizon Control), coupled with a linear model defined as (4.3.4) a CFTOC is solved in the form of
48 The first and simplest implementation of the controller is now described in detail. The IDF Building file needs to be updated to include the Fuel Cell heat production. At this early stage this can be achieved through the EnergyPlus OtherEquipment object. This provides a heat gain or loss directly to the zone with the advantage of avoiding the design of an entire HVAC system. !- =========== ALL OBJECTS IN CLASS: MPC =========== OtherEquipment, , !- Name , !- Fuel Use Type , !- Zone or ZoneList or Space or SpaceList Name HeatingRatePower, !- SCHEDULE Name EquipmentLevel, !- Design Level calculation method , !- Design Level {W} , !- Power per Zone Floor Area {watts/m2} , !- Power per Person {watts/person} , !- Fraction Latent , !- Fraction Radiant , !- Fraction Lost , !- Carbon Dioxide Generation Rate ; !- End-Use Subcategory The HeatingRatePower schedule is defined in MATLAB and called here though the External Interface object. The nominal power of the Fuel Cell is defined in the Design Level {W} field, and at each time step of the co-simulation the schedule sets the fraction of the nominal power delivered to the zone.
Building comfort control using MPC 49 4.5. MPC implementation to the CorTau house 4.5.1. Linear model development The implementation of the controller is performed on the case study by gradually increasing the complexity of the algorithm. At first the controller is intended to operate for a quite short time window, for instance between 00:00 am and 01:00 am on January 1st, in order to easily check its correct behaviour without spending a too long execution time. As already pointed out previously, a weather file in the EPW format is required by EnergyPlus to correctly run the simulation. The International Weather for Energy Calculations (IWEC) data file for Turin is used here, which is the result of the ASHRAE Research Project 1015 by Numerical Logics and Bodycote Materials Testing Canada for ASHRAE Technical Committee 4.2 Weather Information. Figure 4.5.1 – Outdoor temperature from the EPW file database After loading the building IDF file and the EPW one, the first and easiest attempt would be sending from MATLAB to EnergyPlus a pre-defined heating schedule un , … , un+N in order to check on one side that the co-simulation works and the building model response to the signal is realistic, and on the other to fit a linear model for the energy balance of each thermal zone
50 of the building. In the next implementation of the algorithm the MPC controller will be in charge of providing the heating schedule as a result of the optimization. The only design parameter to set at this stage is the simulation sample-time • ts = 60 s The idea here is to define the same schedule for all the house thermal zones which are actually heated in the original IDF file. The following tables show the heating power fraction schedule with respect to a nominal maximum value set to 300 W/m2 for each of the seven thermal zones. Table 4.5.1 – Pre-defined heating schedule Time interval Power Fraction 00:00:00 – 00:19:00 0.5 00:20:00 – 00:40:00 1 00:41:00 – 01:00:00 0.5 Table 4.5.2 – Nominal heating power ZT 1 Kitchen 14610 W ZT 2 Living Room 5730 W ZT 3 Night Area 8220 W ZT 4 Studio 6150 W
Building comfort control using MPC 51 ZT 5 Bathroom1 1590 W ZT 6 Bathroom2 1050 W ZT 7 Bathroom3 2070 W Figure 4.5.2 – Pre-defined heating schedule
52 Figure 4.5.3 – Simulation results with the pre-defined heating schedule The results are not subject to any constraint on the indoor temperature levels as the aim of this first simulation was just checking that the software communication works well and that an increase in the delivered power directly reflects in a temperature increase. When the heating fraction value is instantaneously pushed from 0 to 0.5 or similarly from 0.5 to 1, the indoor temperature as computed by EnergyPlus is not showing such a fast instantaneous increase, but actually seems to behave as a first order model. A first evidence is that the size of the thermal zone is clearly not the only parameter affecting the model response to the heating input since different thermal levels are reached even if the same amount of heat per square meter is delivered. Each thermal zone actually responds to the signal in a unique way depending on its orientation, on the ratio between the opaque and the transparent envelope and the boundary conditions imposed at the walls, which could be alternatively external or internal partitions. An adiabatic condition is imposed on the last to avoid an interaction between the rooms whose modeling would be extremely difficult for this kind of study. The heating schedule and the resulting Tindoor are used to fit a linear model for the energy balance in the zone that will be later used in the optimization core of the MPC controller. Assuming that the outdoor temperature Texternal is the only disturbance on the system
Building comfort control using MPC 53 (4.5.1) and by discretizing the time derivative with a forward Euler scheme (4.5.2) must be equal to the co-simulation sample time ts since the data coming from the EnergyPlus simulation are computed at this exact same rate. The thermal balance on the zone can be rearranged as to express the indoor temperature at the future timestep as a linear combination of its current value, the actual external temperature and the thermal power injection . (4.5.3) and by substituting
54 a linear model for the building indoor temperature evolution is obtained at each time-step. The value of the indoor temperature at the end of the control horizon N can be expressed as a linear combination of the initial and all the previous and . (4.5.4) This procedure can be repeated for all the thermal zones in the building, so that in the end each will have its own linear model to work with in the MPC design. The values of the A, B and C coefficients are obtained in MATLAB through a linear regression on the data. Table 4.5.3 - Linear regression coefficients for each heated thermal zone A B C ZT 1 Kitchen 0.9241 1.6202e-04 7.6800e-02 ZT 2 Living Room 0.9154 3.9579e-04 8.6357e-02 ZT 3 Night Area 0.9185 1.6539e-04 8.4316e-02 ZT 4 Studio 0.9174 2.5104e-04 8.4885e-02 ZT 5 Bathroom 1 0.9138 1.6542e-03 8.7988e-02 ZT 6 Bathroom 2 0.8960 2.7442e-03 1.0758e-01 ZT 7 Bathroom 3 0.9007 1.2420e-03 1.0141e-01 Figure XYZ shows how well the linear model approximates the temperature computed by EnergyPlus for each of the heated thermal zones.
Building comfort control using MPC 55 Figure 4.5.4 – Indoor temperature linear fitting 4.5.2. MPC implementation without EnergyPlus The easiest way to implement the controller is closing the algorithm loop in MATLAB with the linear model developed in the previous section avoiding the comunication with EnergyPlus. This system is expected to perfectly respond to the signal since the plant to which the controller is sending the input is exactly the linear model over which the optimization is performed at each time-step. YALMIP is a MATLAB Toolbox used to solve optimization problems typically occurring in control theory. It was first develop to work on semidefinite programming (SDP) and linear matrix inequalities but nowadays supports a variegate set of models and optimization techniques, relying both on free and commercial solvers. YALMIP can automatically detect the kind of problem the user defined and the most suitable way to solve it. [23] As already pointed out previously, the MPC requires some design parameter to be set before simulating. • Sample time ts = 60 s
56 • Control Horizon Nc = 60 timesteps • Prediction Horizon Np = 5 timesteps • Setpoint Tsetpoint = 20°C The first step in the controller implementation is the definition of the decision variable through the sdpvar object, being in this case the heat delivered to the thermal zone. This will be a 1x7 array, each column assigned to a thermal zone. >> q = sdpvar(1,7) The output variable is also defined similarly to the decision variable but as a Np x 7 array in which each row corresponds to a timestep in the prediction horizon >> x = sdpvar(5,7) The initial indoor temperature as resulting from the EnergyPlus simulation run in the previous section is assigned to the first row of the output matrix and will be the plant starting condition from which the controller begins to operate. At the current instant and for each thermal zone, the indoor temperature at the subsequent step xt+1 is calculated through the A,B,C linear model. The objective function J to minimize over the prediction horizon p can take into account both the deviation of the indoor temperature from the setpoint but also the rate of variation of the heat delivery to the zone. As a single objective function is formulated, the two entries need to be dimensionless. A weighting factor λ ranging from 0 to 1 sets wether reaching rapidly the setpoint is more important than limiting the rate of the heat delivery or viceversa. (4.5.5)
Building comfort control using MPC 57 Numerical errors occurring in the optimization affect the controller output if the temperature entries of the objective function are expressed in Kelvin, as the order of magnitude of the numerator and the denominator is different. For this reason both the output variable xl and Tsepoint are expressed in Celsius. YALMIP automatically sets the optimization solver to the quadratic programming one called quadprog, which was not able to provide an accurate solution for the entire controller operation. For this reason it was substituted by the highly performing SeDuMi solver, a software for optimization over symmetric cones developed by Jos F. Sturm. The convergence of the optimization problem is ensured for all the thermal zones at each timestep with a maximum number of iterations equal to 1000. >> options = sdpsettings('solver','sedumi'); >> options.sedumi.maxiter = 1000; Figure 4.5.5 – Controller implementation in MATLAB
64 Figure 4.5.14 – Co-simulation workflow The following shows the code development through the YALMIP and MLE+ toolboxes aid. Figure 4.5.15 – Controller development with YALMIP and MLE+
Building comfort control using MPC 65 Closing the loop with the EnergyPlus building model and sending the thermal zone indoor air temperature as the feedback towards the controller requires some additional consideration. The CorTau House model as built in EnergyPlus includes the effect of all the weather variables, mainly the wind blowing on the walls exposed to the external environment, but also the dynamics introduced by the heat capacitance and the infiltration through the transparent and opaque envelopes. This result in an increase of the time required by the optimizer to let the indoor temperature stabilize and for this reason the control horizon is increased to two hours. • Sample time ts = 60 s • Control Horizon Nc = 120 timesteps • Prediction Horizon Np = 5 timesteps • Setpoint Tsetpoint = 20°C The temperature response to the thermal power input shows an initial oscillation that can be reduced acting on the weighting factor λ. The value of lambda that reduces the temperature oscillation whitout drastically increasing the time required by each thermal zone to reach steady-state is 0.2. For lambda lower than 0.1 a too big oscillation is introduced, while for lambda values higher than 0.2 the temperature steady-state is reached in more than two hours. A comparison in the results for λ = 0.1 and λ = 0.2 is shown below.
66 • CASE 1 : λ = 0.1 Figure 4.5.16 – MPC Heat demand with EnergyPlus co-simulation, λ = 0.1 Figure 4.5.17 – MPC Indoor temperature response from EnergyPlus, λ = 0.1 • CASE 2 : λ = 0.2
Building comfort control using MPC 67 Figure 4.5.18 – MPC Heat demand with EnergyPlus co-simulation, λ = 0.2 Figure 4.5.19 – MPC Indoor temperature response from EnergyPlus, λ = 0.2 The oscillation still present for the three bathrooms control can be further attenuated with a weighting factor of 0.3. As the simulation is performed at night the low amount of oscillation
68 still observed in these thermal zones are not relevant. With a weighting factor λ = 0.2, the hydrogen rate required to supply the thermal power as computed by the controller is calculated starting from the stack electrical consumption and a single cell voltage as [24] (4.5.6) As the total nominal value set for the heat delivery is 30460 W and a single stack of the chosen NedStack technology is able to supply a maximum of 9357 W in the ohmic losses region, three Fuel Cell stack are required. Figure 4.5.20 – Hydrogen consumption with three NedStack PS6 fuel cell stacks The decrease in the hydrogen consumption is a direct consequence of the increase of the external temperature observed in the time window over which the controller is operating.
Building comfort control using MPC 69 Conclusions The aim of this work was developing and verifying a controller for the indoor temperature ina real-case building for residential use in the winter season. The analysis carreid out lead to a reasonable result for the evolution of both the indoor temperature and the heating power demand both when the MPC loop is closed with the building linear model but also when the co-simulation between EnergyPlus and MATLAB is implemented. In this last case a longer control horizon is required to let the output variable stabilize to a temperature level as close as possible to the setpoint of 20°C accordingly to the value of the weighting factor λ included in the objective function but also to the maximum values for the heating power that can be delivered to each zone. Further reasearch in this topic could be the development of a more refined objective function to include additional requirements on the MPC operation, but also improving the building model over which the optimizer is working, by adopting a schedule for the occupancy, the artificial lighting and the equipment loads, all affecting the internal energy balance. Another interesting field of research would be including
70 Bibliography [1] International Energy Agency. (n.d.). Energy Efficiency: Buildings. [online] Available at: https://www.iea.org/topics/energyefficiency/buildings/ [2] Roadmap on carcinogens. (n.d.). Hardwood Dust [online] Available at: https://roadmaponcarcinogens.eu/hardwooddust/ [3] IEA (2021), World Energy Balances: Overview, IEA, Paris [online] Available at: https://www.iea.org/reports/world-energy-balances-overview [4] Directive (EU) 2018/844 of the European Parliament and of the Council of 30 May 2018 amending Directive 2010/31/EU on the energy performance of buildings and Directive 2012/27/EU on energy efficiency [5] EnergyPlus Version 9.6. US Department of Energy [6] David Kehmeier, Intermedius Design Integration, LLC. Intermediate Data Format. Mechanical Data Exchange Specification for the Design and Analysis of. Printed Wiring Assemblies. Version 3.0. October 31, 1996. [7] Directive (EU) 2018/844 of the European Parliament and of the Council of 30 May 2018 amending Directive 2010/31/EU on the energy performance of buildings and Directive 2012/27/EU on energy efficiency [8] Grove, W. R. (1838). "On a new voltaic combination". The London and Edinburgh Philosophical Magazine and Journal of Science. 3rd series. 13 (84): 430–431. [9] Frano Barbir, PEM Fuel Cells, Theory and Practice, 2005, Elsevier [10] Schalenbach, Maximilian; Hoefner, Tobias; Paciok, Paul; Carmo, Marcelo; Lueke, Wiebke; Stolten, Detlef (2015-10-28). "Gas Permeation through Nafion. Part 1: Measurements". The Journal of Physical Chemistry C. 119 (45): 25145– 25155. doi:10.1021/acs.jpcc.5b04155. [11] Nakhiah Goulbourne. "Research Topics for Materials and Processes for PEM Fuel Cells REU for 2008". Virginia Tech. Archived from the original on 27 February 2009. Retrieved 18 July 2008. [12] Yoshitsugu Sone, Per Ekdunge and Daniel Simonsson, Proton Conductivity of Nafion 117 as Measured by a Four ‐ Electrode AC Impedance Method, 1996 ECS – The Electrochemical Society, Journal of The Electrochemical Society, Volume 143, Number 4
Building comfort control using MPC 71 [13] E. Proietti, F. Jaouen, M. Lefevre, N. Larouche, J. Tian, J. Herranz, and J.-P. Dodelet. 2011 Iron-based cathode catalyst with enhanced power density in polymer electrolyte membrane fuel cells" Nature Communications 2(1) [14] Welaya, Yousri & Elgohary, Mohamed & Ammar, Nader. (2011). A comparison between fuel cells and other alternatives for marine electric power generation. International Journal of Naval Architecture and Ocean Engineering. 3. 141-149. 10.3744/JNAOE.2011.3.2.141. [15] Louzazni, M.; Al-Dahidi, S.; Mussetta, M. Fuel Cell Characteristic Curve Approximation Using the Bézier Curve Technique. Sustainability 2020, 12, 8127. [16] Kandidayeni, M.; Macias, A.; Khalatbarisoltani-Boulon, A.L.; Kelouwani, S. Benchmark of proton exchange membrane fuel cell parameters extraction with metaheuristic optimization algorithms. Energy 2019, 183, 912–925. [CrossRef] [17] Carlos E. García, David M. Prett, Manfred Morari, Model predictive control: Theory and practice—A survey, Automatica, Volume 25, Issue 3, 1989, Pages 335-348, ISSN 0005-1098 [18] Pendleton, Scott & Andersen, Hans & Du, Xinxin & Shen, Xiaotong & Meghjani, Malika & Eng, You & Rus, Daniela & Jr, Marcelo. (2017). Perception, Planning, Control, and Coordination for Autonomous Vehicles. Machines. 5. 6. 10.3390/machines5010006. [19] MATLAB. (R2021b). Natick, Massachusetts: The MathWorks Inc.; 2022. [20] Negenborn, R.R. & De Schutter, Bart & Wiering, Marco & Hellendoorn, J.. (2022). Experience-based model predictive control using reinforcement learning. [21] Building Controls Virtual Test Bed User Manual Version 1.6.0, Simulation Research Group Building Technology and Urban Systems Department Environmental Energy Technologies Division Lawrence Berkeley National Laboratory Berkeley, CA 94720, April 20, 2016. [22] MLE+: A MATLAB-ENERGYPLUS CO-SIMULATION INTERFACE Truong X. Nghiem Automatic Control Laboratory Ecole Polytechnique Fed´ erale de Lausanne (EPFL), Switzerland [23] Johan Löfberg, A toolbox for modeling and optimization in MATLAB, October 2004 [24] JE, Larminie & Dicks, Andrew. (2013). Fuel Cell System Explained. 10.1002/9781118878330.
72 Appendix A – MATLAB code %% CorTau House - MPC design and operation clear all close all clc nominal = [14610, 5730, 8220, 6150, 1590, 1050, 2070]; %[W/m2] % ZT 1 Kitchen % ZT 2 Living Room % ZT 3 Night Area % ZT 4 Studio % ZT 5 Bathroom 1 % ZT 6 Bathroom 2 % ZT 7 Bathroom 3 %% Create mlep instance and configure it % Instantiate co-simulation tool ep = mlep; % Building simulation configuration file ep.idfFile = 'CorTau - AllroomsInternalAdiabatic'; % Weather file ep.epwFile = 'ITA_Torino.160590_IWEC'; %% Input/output configuration % Initialize the co-simulation. This will load the IDF file. ep.initialize; % Display inputs/outputs defined in the IDF file. disp('Input/output configuration.'); inputTable = ep.inputTable; outputTable = ep.outputTable; %% EnergyPlus simulation with pre-defined heating schedule % Specify simulation duration endTime = 60*60; %[s] % Start the co-simulation process and communication. ep.start % The simulation loop t = 0; n = 1; fuel_cell = zeros(1,7); heat_rate(n,:) = fuel_cell; while t <= endTime if t < 60*18 || t > 60*38 fuel_cell(:) = 0.5; else fuel_cell(:) = 1; end % Prepare inputs (possibly from last outputs) u = fuel_cell; %[heating rate fraction] % Get outputs from EnergyPlus [y, t] = ep.read;
Building comfort control using MPC 73 % Send inputs to EnergyPlus ep.write(u,t); heat_rate(n,:) = fuel_cell; TemperaturePre(n,:) = y(2:end); OutdoorT(n) = y(1); time(n) = t; n = n+1; end % Stop co-simulation process ep.stop; xlswrite('OutdorTemperatureTurin',OutdoorT(:),'A1:A160'); %% Plot results - Indoor and outdoor temperature - Heat rate (predefined) figure(1) plot(TemperaturePre,'linewidth',1.2); xlabel('Time (min)'); ylabel('Temperature [°C]'); xlim([1 60]); grid on box on set(gca,'fontsize',14) legend('ZT 1 Kitchen', 'ZT 2 Living Room', 'ZT 3 Night Area', 'ZT 4 Studio', 'ZT 5 Bathroom 1', 'ZT 6 Bathroom 2', 'ZT 7 Bathroom 3', 'location', 'best'); title('Pre-defined heating schedule simulation results, January 1^s^t'); figure(2) plot(heat_rate(:,1)); xlabel('Time (min)'); ylabel('Heating power fraction [-]'); title('Pre-defined heating schedule, January 1^s^t'); xlim([1 60]); ylim([0 1.2]); grid on box on set(gca,'fontsize',14) %% Evaluation of A,B,C parameters for the linear building model for j = 1:7 Heat_pre(:,j) = heat_rate(:,j)*nominal(j); %[W] end OutdoorT = OutdoorT + 273.15; %[K] TemperaturePre = TemperaturePre + 273.15; %[K] timestep = 60; for i = 1:7 X = [TemperaturePre(1:end-1,i) , Heat_pre(1:end-1,i) , OutdoorT(1:end-1)']; Y = TemperaturePre(2:end,i); P = regress(Y,X); A(i) = P(1); B(i) = P(2); C(i) = P(3); end %% Comparison between the A,B,C model and the results coming from EnergyPlus % A,B,C model Tabc(1,1:7) = TemperaturePre(1,1:7); for j = 1:7