A New Methodology for Decision-Making in Buildings Energy Optimization

Featured Application: A new methodology for decision-making at the time of building design or retroﬁt is shown. Abstract: When designing or retroﬁtting a building, not too many tools let architects and engineers to deﬁne the optimal conditions to reduce energy consumption with the minimal economic investment. This is because di ﬀ erent software resources must be employed and an iterative calculation must be done which, most of times, is not possible. The present study aims to deﬁne an original methodology that let researchers and architects to select the best option between di ﬀ erent possibilities. To reach this objective, Monte Carlo method is employed on the ISO 13790 standard reaching the probability distribution of the energy consumption of each building after each possible modiﬁcation. From main results, two mathematical models were obtained from a real case study showing the relation between annual energy consumption and economic investment of each di ﬀ erent building retroﬁts. What is more, in disagreement with the expected result, the best retroﬁt option was not the one with the highest cost and qualities. In conclusion, this methodology can be a useful tool for researchers and professionals to improve their decision-making.


Introduction
The energy consumption of the residential sector in the European Union represents 39% of CO 2 emissions, as is clear from the information published in JRC Energy Report 2018 [1]. For this reason, the impact of optimizing the efficiency of these buildings implies not only environmental improvements, but also a reduction in energy dependency. Concerns about improving the energy efficiency of buildings began in the Council Directive 93/76/EEC of 13 September 1993, which approved the Directive "(SAVE)" [2], regarding the limitation of carbon dioxide emissions through improved energy efficiency. This directive consists of a list of actions that member states should take to improve energy efficiency in buildings and thereby reduce their greenhouse gas emissions.
It was followed by the signing of the Kyoto protocol (1997) [3], the publication of Directive 2002/91/EC (Energy Performance of Buildings Directive) [4], which obliges to recent built, sold or rented buildings of member states to be accompanied by an Energy Efficiency Certificate. Later, in 2010, the directive was recast into Directive 2010/31/EU [5], incorporating very important concepts such as the Nearly Zero Energy Consumption Buildings (nZEB building) and being mandatory for buildings constructed from December 31, 2020.
It also sets targets for reducing consumption, increasing the use of renewable energy sources and increasing efficiency by 20% by 2020 and in 2050 an economy with net-zero greenhouse gas emissions [6]. It also establishes the need for a common methodology for calculating the integrated energy performance of buildings. This methodology should integrate all the elements that determine energy efficiency and not only the quality of the building's insulation. This integrated approach should take into account elements such as heating and cooling installations, lighting installations, the location and orientation of the building, heat recovery and renewable energy sources, between others.
Currently, the energy certification model designed contemplates: (i) the architectural aspects of the building; construction materials, geographical area, orientation, insulation, gaps and its typology, etc.; and (ii) the characteristics of the equipment and facilities of the building (lighting, heating, cooling, heat pumps, solar panels, demand for Domestic Hot Water (DHW), demand for air conditioning, etc.) are considered. With all this information and the use of the certification software of each different country [7,8], a "building model" with an energy demand is obtained. In parallel, the software with the data from the architecture and facilities builds the "building object" of the project and obtains a rating.
It is interesting to highlight that the minimal changes in the different input parameters can vary the energy demand. In particular, Dirk Jacob et al. [9] showed how Monte Carlo Method [10] can be employed based on ISO 13790 standard [11] to quantify the impact of uncertainty of model parameters. This effect was related to the fact that building energy systems are no linear, requiring adjustment of previously found optimal solutions.
In 2017, Sørensen et al. [12] employed Monte Carlo method to simulate energy performance and indoor climate in office buildings. In this sense, thousands of combinations were done with Be15 and BSim software showing a great amount of possible solution to let architects choose between possible options. What is more, Østergård [13] developed a study based on BSim software to determine the best way to perform building simulations, showing the main advantages of Monte Carlo Method.
Finally, in the last years, it was found that the TERDMM can support risk-conscious decision-making by explicitly quantifying risks [14], but it is a so complex analysis which is a little far from architects' daily decision-making. In consequence, algorithms or general recommendations to select the best option were no developed. Consequently, most of these works aim that future applications with more complex buildings can be done.
Different recent research works employ the Monte Carlo Method as a mathematical tool to relate the energy consumption with a change in various related variables and not each variable separately [13]. In this sense, most of works, like Sorensen et al. [12], employs the Monte Carlo Method with the instantaneous energy consumption of buildings to be related to energy consumption, looking for a high precision at the cost of greater data insertion time. At the same time, none of these previous works define the economic effect of each energetic improvement. What is more, these methodologies are not too much easy to be employed by engineers for energy rating and decision-making and actually they do it with CE3X software.
In this sense, CE3X is an "efficient" program since it allows technicians to reduce time in preparing the energy rating. Despite this, such a software does not show the optimal retrofitting option (most of time limited to a maximum economic investment). Consequently, the proposed calculation procedure, centered in the ISO 13790, simplifies calculation method and the CE3X software economic investment report (a new output variable of CE3X respect the other similar software resources), thereby aiming to show a new and useful procedure for technicians at the time of retrofitting decision-making.
Finally, as an inverse engineering analysis, future research works will let us to analyze each term of the obtained models and to relate this with the main energy and mass balance equations, which are the origin of the ISO 13790 standard philosophy.

Materials and Methods
As it was commented before, different software resources are usually employed to define buildings' energy consumption in accordance with the ISO 13790. Despite this, most of them are too much complex to be employed in an iterative procedure to define the optimal modification towards an energy consumption optimization during the design or retrofitting process.
In consequence, the present study aims to show an original methodology based on this same standard, but implemented with Monte Carlo Method to define the real distribution of the energy consumption and not only an average value as it is showed by most of these software resources and research works [15] as it will be described in the present section.

HULC and CE3x Software
The Spanish ministries of industry, energy and tourism, together with the Spanish Ministry of Development, has delegated the task of making available to the public valid methodologies for the energy efficiency rating of buildings to the Institute for the Diversification and Energy Saving (IDEA [16]). In consequence, to model buildings based on the result of the application of R.D. 235/2013, the following programs are currently recognized: The first one and the most recognized, is the Lider Calener unified tool [20] is a software developed by the Spanish Ministry of Industry, Energy and Tourism. It brings together in one application the Lider and Calener Vyp tools, which were previously developed by a research group from the department of Thermotechnology of the University of Seville belonging to the Andalusian Association for Research and Industrial Cooperation (AICIA, Sevilla, Spain). The tool complies with the provisions of article 4.1 of the Spanish R.D. 235/2013 [21] being the procedure for the energy efficiency rating of a building in Spain. It employs as calculation engine ESTO 2 based on DOE2 developed by the US Department of Energy as the calculation engine. This software was updated in accordance with the energy certification methodology in Spain and has incorporated the latest modifications to the technical building code in the field of energy demand (basic document HE0 [22]) and latest modifications of the regulation of thermal installations in buildings (RITE [23]).
The Lider Calener unified tool is analogous to the CE3X software which was developed by Efinovatic and the Spanish National Centre for Renewable Energies (CENER [8]) and was validated by its own Ministry of Building. In particular, CE3X is another simplified energy rating procedure for existing and new construction buildings, but it presents a new advantage respect other existing software resources due to it generates an economical investment as output report. What is more, this is the more used Spanish software by architects due to the reduce time to introduce the information and get the simulation results.
It is worth noting that this software approaches its simulations to the building objective of study by means of global dimensionless variables and a statistical adjustment [24] respect to buildings simulated previously with the old Calener Vyp, as it is represented in Figure 1. This fact supposes that the CE3X software does not analyze the dynamics of the target building but adjusts the dynamics of a simulated-type building in the provincial capitals with reference software.
In order to use these tools to reach the objective of building energy analysis, an initial problem of entering input data were found. Particularly, in all of them, since modifying a single input parameter requires generating a new project before proceeding to start the calculation engine to analyze the results. To solve this problem, present study shows a new methodology based on modeling the building's energy consumption in spreadsheets using ISO 13790 after being validated by CE3X [25] software results.  [11] as "Energy efficiency of buildings. Calculation of energy consumption for space heating and cooling. (ISO 13790:2008)". Currently, many of the used programs, both nationally and internationally, use this ISO standard, which generally operates with the inputs shown in Figure 2.
In this sense, ISO13790 employs three calculation procedures to define the Energy needs for heating and cooling, but all of them are centered into heat and mass transfer in the building system as a multiple or just only one zone.
It is interesting to highlight that the second procedure is based on the model of five resistors and one capacitance being a simplification of the dynamic simulation [9] and that the third procedure, dynamic method, must pass the validation tests (Annex A of ISO 13790). In consequence, based on the main objective of stochastic approach, for our research work the monthly and seasonal method was selected. This method was established in three sections to define the heating and cooling energy needs of a building. First, for the heating energy consumption, the ISO 13790:2011 defines the Equations (1) and (2):

ISO 13790 standard
At European level, the prEN ISO 13790:1999 was approved in 1999, which gave final form to the ISO 13790:2004 standard, later revised in 2008. In Spain, it was transposed into the UNE-EN ISO 13790:2011 standard [11] as "Energy efficiency of buildings. Calculation of energy consumption for space heating and cooling. (ISO 13790:2008)". Currently, many of the used programs, both nationally and internationally, use this ISO standard, which generally operates with the inputs shown in Figure 2.
In this sense, ISO13790 employs three calculation procedures to define the Energy needs for heating and cooling, but all of them are centered into heat and mass transfer in the building system as a multiple or just only one zone.
Detailed simulation method.
It is interesting to highlight that the second procedure is based on the model of five resistors and one capacitance being a simplification of the dynamic simulation [9] and that the third procedure, dynamic method, must pass the validation tests (Annex A of ISO 13790). In consequence, based on the main objective of stochastic approach, for our research work the monthly and seasonal method was selected. This method was established in three sections to define the heating and cooling energy needs of a building. First, for the heating energy consumption, the ISO 13790:2011 defines the Equations (1) and (2) where Q H,nd,cont is the energy needed as continuous heating (MJ), Q H,ht is the total heat transfer (MJ), Q H,gn are the total heating gains (MJ) and η H,gn represents a dimensionless factor of use of heat gains (MJ). For cooling energy consumption, the ISO proposes the Equation (2): where Q C,nd,cont is the continuous cooling energy needed (MJ), Q C,ht is the heat transfer for the cooling mode (MJ), Q C,gn are the total heat gains (MJ) and η C,ls represents a dimensionless factor of heat losses (MJ). Finally, for each building zone and calculation step (month in our case study) the heat transfer is calculated in accordance with the Equation (3): where Q tr+ is the total heat transfer (MJ) and Q ve is the total heat transfer by ventilation (MJ). Finally, total heat gains are defined by the Equation (4): where Q int+ are the total internal heat gains in the calculation period (MJ) and Q sol are the total solar heat gains during the calculation period (MJ).
Appl. Sci. 2020, 10, x FOR PEER REVIEW 5 of 20 where Q , , is the energy needed as continuous heating (MJ), Q , is the total heat transfer (MJ), Q , are the total heating gains (MJ) and η , represents a dimensionless factor of use of heat gains (MJ). For cooling energy consumption, the ISO proposes the Equation (2): where Q , , is the continuous cooling energy needed (MJ), Q , is the heat transfer for the cooling mode (MJ), Q , are the total heat gains (MJ) and η , represents a dimensionless factor of heat losses (MJ). Finally, for each building zone and calculation step (month in our case study) the heat transfer is calculated in accordance with the Equation (3): where Q is the total heat transfer (MJ) and Q is the total heat transfer by ventilation (MJ). Finally, total heat gains are defined by the Equation (4): where Q are the total internal heat gains in the calculation period (MJ) and Q are the total solar heat gains during the calculation period (MJ).

MONTECARLO Method
In the search for the energetic optimization of a building, many variables influence its consumption. In order to define which variables are the optimal to reach this objective, a mathematical problem with multiple unknowns and nonlinear variations must be solved.
Currently, the use of computer tools based on "artificial intelligence", which normally require a "learning" process, is booming. However, many of the input variables that we usually employ in calculating the energy demand of a building have a random component, such as weather, ventilation or solar radiation. Despite this, artificial intelligence procedures will give us just a network of the average value of each variable and, despite the fact it can give us the optimal point of this network, it will not give us the trends of each input data modification in the primary energy consumption.
In previous research works, it was showed that the combination of stochastic models with optimization is rare in the building sector [9]. In this sense, since the mid-1940s, some mathematical tools began to be used for this type of analysis based on the Monte Carlo method [10], which consists in obtaining a solution limited by the random repetition of innumerable simulations. The random

MONTECARLO Method
In the search for the energetic optimization of a building, many variables influence its consumption. In order to define which variables are the optimal to reach this objective, a mathematical problem with multiple unknowns and nonlinear variations must be solved.
Currently, the use of computer tools based on "artificial intelligence", which normally require a "learning" process, is booming. However, many of the input variables that we usually employ in calculating the energy demand of a building have a random component, such as weather, ventilation or solar radiation. Despite this, artificial intelligence procedures will give us just a network of the average value of each variable and, despite the fact it can give us the optimal point of this network, it will not give us the trends of each input data modification in the primary energy consumption.
In previous research works, it was showed that the combination of stochastic models with optimization is rare in the building sector [9]. In this sense, since the mid-1940s, some mathematical tools began to be used for this type of analysis based on the Monte Carlo method [10], which consists in obtaining a solution limited by the random repetition of innumerable simulations. The random input of values of each variable will lead us to the solution of the problem showing the Gaussian bell of building energy consumption as a function of each input variable. In consequence, with this tool, it was possible to carry out multiple energy simulations by modifying environmental parameters, such as external temperature data, which directly affect the building's energy consumption.

Proposed Calculation Procedure
Based on this calculation procedure and, once established the possible input variables in accordance with the weather conditions of the region and the commercial values of carpentry, transmittance and type of heating, domestic hot water generation and fuel between others, a stochastic analysis of the probability distribution of each change was done, as it is showed in Figure 3. This Figure 3 sum ups the proposed calculation procedure. First, it can be observed the initial building and the retrofitting variables to be selected for each test employed and, combined with a random input of outdoor temperature in the ISO standard to define the probability density function of the primary energy consumption after more than 200 iterations.
From the primary energy consumption defined by the standard and the economic investment, defined by the CE3X software, a list of possible retrofitting combinations was obtained and ordered in accordance different criteria (row number). From this initial step and based on surface response curve fitting, two models were obtained. The first model will give us the primary energy consumption and the other give us the economic investment of each retrofitting process.
Once obtained, these models can be optimized by GRG algorithms to define the optimal retrofitting, which can be that with a minimum possible primary energy consumption or that which implies the minimum energy consumption for a limited maximum economical investment in this retrofitting. These models will give us a new procedure for decision making due to it is a new parameter really needed from the moment that the CE3X software was improved respect previous software resources.

Instrumentation
As is done in most of research work [26,27], to validate calculation procedures, real sampled values are necessary. In this sense, it is interesting to highlight that, since the application of the RITE of 1998, the installation of energy meters in homes is compulsory in Spain. To reach this objective, the M-bus standard is a system developed to cover the need to remotely read energy, gas and electricity or water meters. Most of the equipment installed today complies with this protocol, defined in a standard UNE-EN 1434-3:2016 [25]. When a request is sent to the counter, it returns the information it has collected to be stored in a common master system. This system can be, for example, a computer or any device, which is connected at periodic intervals of time to read the sampled variables. Once the M-Bus meters were available in different buildings, there was a need to carry out a hardware design for the acquisition and storage of readings as it is explained in this section.

Hardware
As starting hardware, a low-cost prototyping equipment was selected under the need to be easy to implement and able to store the volume of information to be processed (data from multiple meters). In particular, the selected hardware is a Raspberry Pi board [28], developed by the "Raspberry Pi Foundation" in England, and which has been marketed since 2012 with the aim of promoting computer science in education centers, becoming a standard and the pillar of development and elaboration of the infinity of prototypes for research.
The selected model, used since 2016, is the version 3 that has Wi-Fi, ethernet, Bluetooth connectivity and infinite possibilities thanks to a GPIO port, as we can see in Figure 4. It is interesting to highlight that the Raspberry PI hardware must be protected in its installation in the electrical panel. What is more, a suitable enclosure that guarantees at least a minimum tightness that avoids direct or indirect contacts in the conventional maintenance operations of the boiler rooms must be selected. In this sense, a Phoenix-contact-type enclosure is chosen, designed according to DIN 43880 standard, they are stackable and can be fixed on a standard DIN rail.
Appl. Sci. 2020, 10, x FOR PEER REVIEW 7 of 20 Once obtained, these models can be optimized by GRG algorithms to define the optimal retrofitting, which can be that with a minimum possible primary energy consumption or that which implies the minimum energy consumption for a limited maximum economical investment in this retrofitting. These models will give us a new procedure for decision making due to it is a new parameter really needed from the moment that the CE3X software was improved respect previous software resources.

Instrumentation
As is done in most of research work [26,27], to validate calculation procedures, real sampled values are necessary. In this sense, it is interesting to highlight that, since the application of the RITE of 1998, the installation of energy meters in homes is compulsory in Spain. To reach this objective, the M-bus standard is a system developed to cover the need to remotely read energy, gas and electricity or water meters. Most of the equipment installed today complies with this protocol, defined in a standard UNE-EN 1434-3:2016 [25]. When a request is sent to the counter, it returns the information it has collected to be stored in a common master system. This system can be, for example, a computer or any device, which is connected at periodic intervals of time to read the sampled variables. Once the M-Bus meters were available in different buildings, there was a need to carry out a hardware design for the acquisition and storage of readings as it is explained in this section.

Hardware
As starting hardware, a low-cost prototyping equipment was selected under the need to be easy to implement and able to store the volume of information to be processed (data from multiple meters). In particular, the selected hardware is a Raspberry Pi board [28], developed by the "Raspberry Pi Foundation" in England, and which has been marketed since 2012 with the aim of promoting computer science in education centers, becoming a standard and the pillar of development and elaboration of the infinity of prototypes for research.
The selected model, used since 2016, is the version 3 that has Wi-Fi, ethernet, Bluetooth connectivity and infinite possibilities thanks to a GPIO port, as we can see in Figure 4. It is interesting to highlight that the Raspberry PI hardware must be protected in its installation in the electrical panel.
What is more, a suitable enclosure that guarantees at least a minimum tightness that avoids direct or indirect contacts in the conventional maintenance operations of the boiler rooms must be selected. In this sense, a Phoenix-contact-type enclosure is chosen, designed according to DIN 43880 standard, they are stackable and can be fixed on a standard DIN rail.  To the hardware of the raspberry, we must add the possibility of M-Bus communication. In this sense, due to most of the boiler rooms have an M-Bus master with RS-232 serial communication, this option was selected. However, it was necessary to incorporate an RS-232 port through compatible USB communication due to Raspberry Pi 3 hardware does not have a serial port. Finally, the complete hardware developed for reading different energy counters is shown in Figure 5. To the hardware of the raspberry, we must add the possibility of M-Bus communication. In this sense, due to most of the boiler rooms have an M-Bus master with RS-232 serial communication, this option was selected. However, it was necessary to incorporate an RS-232 port through compatible USB communication due to Raspberry Pi 3 hardware does not have a serial port. Finally, the complete hardware developed for reading different energy counters is shown in Figure 5.

Software
In this section, the software capable of managing M-Bus communication, reading the counters at a certain frequency and finally storing this information for later analysis is described. The software implemented on the Raspberry Pi, was developed on the Raspbian operating system that comes to be a Raspberry implementation of the most used Linux distributions "Debian". In addition to being one of the most widely used operating systems in the world, it is free software and has a multitude of open source support that will facilitate the installation and even compilation of all the software necessary for our monitoring process. In this operating system, drivers for the serial port and a library to be able to access to communicate through the M-Bus protocol were incorporated. For this purpose, the free code library "libmbus" developed and maintained by the Swedish company Raditex Control AB was used. The library is programmed with source code in C language. This library was used to communicate with M-bus slaves (meters) through the wired M-bus protocol incorporating simple applications for network scanning, meter reading and presentation of the data of each meter in XML format, simplifying the future treatment of the information. The library allows us, in addition to the use of the serial port, communication through the TCP IP Internet protocol, being able to access any Mbus Master equipment on the market that we find in the facilities to be monitored.
Thus, our prototype already has tools to communicate, to access a scan or meter reading, although it is necessary to have a place to store such data as a database. Following the line of free software, it was found the option to use the MySQL database [29]. MySQL is a relational database management system developed under two types of licenses: general public license and commercial license by Oracle Corporation. It is considered the most popular open source database in the world and one of the most popular in general with Oracle and Microsoft SQL Server, especially for web development environments. For its implementation in raspberry pi, the public license version is already available in the repository of the "Raspbian [30]" operating system itself, so it was selected to be used as a pillar of the storage of reading data.
Finally, the prototype must have a small web interface to consult the stored data, so a small web application is designed capable of communicating with the database and executing shell commands in Linux. It was selected to program this application in PHP language (hypertext preprocessor), since it is an open source programming language widely used in web development that can be embedded in HTML code.

Software
In this section, the software capable of managing M-Bus communication, reading the counters at a certain frequency and finally storing this information for later analysis is described. The software implemented on the Raspberry Pi, was developed on the Raspbian operating system that comes to be a Raspberry implementation of the most used Linux distributions "Debian". In addition to being one of the most widely used operating systems in the world, it is free software and has a multitude of open source support that will facilitate the installation and even compilation of all the software necessary for our monitoring process. In this operating system, drivers for the serial port and a library to be able to access to communicate through the M-Bus protocol were incorporated. For this purpose, the free code library "libmbus" developed and maintained by the Swedish company Raditex Control AB was used. The library is programmed with source code in C language. This library was used to communicate with M-bus slaves (meters) through the wired M-bus protocol incorporating simple applications for network scanning, meter reading and presentation of the data of each meter in XML format, simplifying the future treatment of the information. The library allows us, in addition to the use of the serial port, communication through the TCP IP Internet protocol, being able to access any Mbus Master equipment on the market that we find in the facilities to be monitored.
Thus, our prototype already has tools to communicate, to access a scan or meter reading, although it is necessary to have a place to store such data as a database. Following the line of free software, it was found the option to use the MySQL database [29]. MySQL is a relational database management system developed under two types of licenses: general public license and commercial license by Oracle Corporation. It is considered the most popular open source database in the world and one of the most popular in general with Oracle and Microsoft SQL Server, especially for web development environments. For its implementation in raspberry pi, the public license version is already available in the repository of the "Raspbian [30]" operating system itself, so it was selected to be used as a pillar of the storage of reading data.
Finally, the prototype must have a small web interface to consult the stored data, so a small web application is designed capable of communicating with the database and executing shell commands in Linux. It was selected to program this application in PHP language (hypertext preprocessor), since it is an open source programming language widely used in web development that can be embedded in HTML code.

Results
The first stage of this work was to measure real sampled data in real buildings and to validate our calculation procedure. To do this, the ISO 13790 standard was implemented in a spreadsheet and its results were compared with the tools recognized by the Spanish Ministry of Industry (CE3X software version 2.3), both applied in an isolated residential building of Figure 6. It is interesting to highlight that this building, after an initial sample of its energy demand, was modified towards a reduction of its energy consumption. In consequence, an initial validation respect CE3X software and standards was done in its initial conditions and, a second validation after a retrofit process, with a more detailed information, was done too.

Results
The first stage of this work was to measure real sampled data in real buildings and to validate our calculation procedure. To do this, the ISO 13790 standard was implemented in a spreadsheet and its results were compared with the tools recognized by the Spanish Ministry of Industry (CE3X software version 2.3), both applied in an isolated residential building of Figure 6. It is interesting to highlight that this building, after an initial sample of its energy demand, was modified towards a reduction of its energy consumption. In consequence, an initial validation respect CE3X software and standards was done in its initial conditions and, a second validation after a retrofit process, with a more detailed information, was done too. As it was explained before, the energy certification model designed contemplates the architectural aspects of the building, the characteristics of the equipment and facilities of the building. This information was summarized to be introduced in the CE3X software and in our calculation procedure as: In this case, information such as dimensions, typology of holes and carpentry, domestic hot water (DHW) facilities, boilers and heating installations-among others-were the main input data into the CE3X software. In particular, for all the certifications done, it was defined-for a static value of dry temperatures-to obtain the results of the energy certification shown Figure 7. In this case, the results showed an amount of a total primary energy consumption of 224,500 kWh/m 2 year. What is more, from the data obtained from the CE3X unified tool, a consumption distribution of 173,410 kWh/m 2 year for heating and 51,040 kWh/m 2 year for DHW was observed in Figure 8. As it was explained before, the energy certification model designed contemplates the architectural aspects of the building, the characteristics of the equipment and facilities of the building. This information was summarized to be introduced in the CE3X software and in our calculation procedure as: In this case, information such as dimensions, typology of holes and carpentry, domestic hot water (DHW) facilities, boilers and heating installations-among others-were the main input data into the CE3X software. In particular, for all the certifications done, it was defined-for a static value of dry temperatures-to obtain the results of the energy certification shown Figure 7. In this case, the results showed an amount of a total primary energy consumption of 224,500 kWh/m 2 year. What is more, from the data obtained from the CE3X unified tool, a consumption distribution of 173,410 kWh/m 2 year for heating and 51,040 kWh/m 2 year for DHW was observed in Figure 8.  After this initial analysis, the next step was to carry out the same automatic calculation procedure of the ISO 13790 standard by spreadsheets and validate the obtained results with the CE3X certification. In particular, it is interesting to highlight that the input data used in the spreadsheet are identical to those used with CE3X and the differences obtained are minimal, as we can observe in Table 1. At the same time, the real sample data showed that the information available only corresponds to fuel consumption for heating and reaches amounts to 74,910 kWh/m 2 year. Finally, Table 1 shows a sum up of the different analysis for the same building construction. This Table 1 showed an actual consumption much lower than the estimated data of the 177,410 kWh/m 2 year from the CE3X software. The reason why the energy consumption was not in agreement with the certified software resources indications are only the difference of occupation levels between the average expected by the standards and the real occupation. It implies a change in the liters per day of hot water and the real air changes in residential buildings being this effect explained in depth in the section "H.3. Analysis of errors of the ISO 13790". In particular, in agreement with this H3 section, the half of the obtained energy consumption of the software resources (86,705 kWh/(m 2 ·year)) are similar with the real sampled primary energy 74,910 kWh/(m 2 ·year).
As it was explained before, this is a consequence of to employ average occupation values (Tabulated in the standard) instead real occupation, which is lower in this case for the particular characteristics of their occupants. Despite this, the aim of the work is to show a new methodology for decision making and, this is a certified software by the Spanish Ministry considering standard conditions. In consequence, this difference respect real sampled data is not so important for this study and it is of more interest to compare the main results with both software resources (CE3X and ISO 13790 of our calculation procedure).  After this initial analysis, the next step was to carry out the same automatic calculation procedure of the ISO 13790 standard by spreadsheets and validate the obtained results with the CE3X certification. In particular, it is interesting to highlight that the input data used in the spreadsheet are identical to those used with CE3X and the differences obtained are minimal, as we can observe in Table 1. At the same time, the real sample data showed that the information available only corresponds to fuel consumption for heating and reaches amounts to 74,910 kWh/m 2 year. Finally, Table 1 shows a sum up of the different analysis for the same building construction. This Table 1 showed an actual consumption much lower than the estimated data of the 177,410 kWh/m 2 year from the CE3X software. The reason why the energy consumption was not in agreement with the certified software resources indications are only the difference of occupation levels between the average expected by the standards and the real occupation. It implies a change in the liters per day of hot water and the real air changes in residential buildings being this effect explained in depth in the section "H.3. Analysis of errors of the ISO 13790". In particular, in agreement with this H3 section, the half of the obtained energy consumption of the software resources (86,705 kWh/(m 2 ·year)) are similar with the real sampled primary energy 74,910 kWh/(m 2 ·year).

Validation of the Final Building Construction
As it was explained before, this is a consequence of to employ average occupation values (Tabulated in the standard) instead real occupation, which is lower in this case for the particular characteristics of their occupants. Despite this, the aim of the work is to show a new methodology for decision making and, this is a certified software by the Spanish Ministry considering standard conditions. In consequence, this difference respect real sampled data is not so important for this study and it is of more interest to compare the main results with both software resources (CE3X and ISO 13790 of our calculation procedure). After this initial analysis, the next step was to carry out the same automatic calculation procedure of the ISO 13790 standard by spreadsheets and validate the obtained results with the CE3X certification. In particular, it is interesting to highlight that the input data used in the spreadsheet are identical to those used with CE3X and the differences obtained are minimal, as we can observe in Table 1. At the same time, the real sample data showed that the information available only corresponds to fuel consumption for heating and reaches amounts to 74,910 kWh/m 2 year. Finally, Table 1 shows a sum up of the different analysis for the same building construction. This Table 1 showed an actual consumption much lower than the estimated data of the 177,410 kWh/m 2 year from the CE3X software. The reason why the energy consumption was not in agreement with the certified software resources indications are only the difference of occupation levels between the average expected by the standards and the real occupation. It implies a change in the liters per day of hot water and the real air changes in residential buildings being this effect explained in depth in the section "H.3. Analysis of errors of the ISO 13790". In particular, in agreement with this H3 section, the half of the obtained energy consumption of the software resources (86,705 kWh/(m 2 ·year)) are similar with the real sampled primary energy 74,910 kWh/(m 2 ·year).
As it was explained before, this is a consequence of to employ average occupation values (Tabulated in the standard) instead real occupation, which is lower in this case for the particular characteristics of their occupants. Despite this, the aim of the work is to show a new methodology for decision making and, this is a certified software by the Spanish Ministry considering standard conditions. In consequence, this difference respect real sampled data is not so important for this study and it is of more interest to compare the main results with both software resources (CE3X and ISO 13790 of our calculation procedure).

Validation of the Final Building Construction
In this second section, a second validation of the calculation procedure is done in accordance the ISO 13790 respect the CE3X software in this same building after a real retrofit. This retrofit aims to reduce the energy consumption and, in consequence, CO 2 emission and, at the same time, to improve the economic savings. In this sense, the main possibilities for improving a building energy consumption are: • Level of permeability of the windows carpentry employed. Finally, in this particular case study, the owners decided to change the electric boiler for fuel with the aim of unifying the generation of DHW and Heating by installing a gas condensing equipment. This new data was introduced in the CE3X software tool with the aim to recalculate the new certification level after this retrofitting, as it is shown in Figure 9 and is summed up in Table 2.
Appl. Sci. 2020, 10, x FOR PEER REVIEW 11 of 20 In this second section, a second validation of the calculation procedure is done in accordance the ISO 13790 respect the CE3X software in this same building after a real retrofit. This retrofit aims to reduce the energy consumption and, in consequence, CO2 emission and, at the same time, to improve the economic savings. In this sense, the main possibilities for improving a building energy consumption are: • Level of permeability of the windows carpentry employed. Finally, in this particular case study, the owners decided to change the electric boiler for fuel with the aim of unifying the generation of DHW and Heating by installing a gas condensing equipment. This new data was introduced in the CE3X software tool with the aim to recalculate the new certification level after this retrofitting, as it is shown in Figure 9 and is summed up in Table 2. At the same time, once again, to determine the difference between the standards and real sample data, the building's energy consumption for 3 years (2017-2019) was sampled. To do it, the monitoring hardware explained before was employed to record the daily heating and DHW energy consumption. In this sense, the real primary energy consumption during the year 2017 was about 45.948 kWh/m 2 year and it can be compared to the different calculation procedures from Table 2. In particular, the actual primary energy consumption of the building shows much lower value than those presented by the energy certification (28% of the estimate).  At the same time, once again, to determine the difference between the standards and real sample data, the building's energy consumption for 3 years (2017-2019) was sampled. To do it, the monitoring hardware explained before was employed to record the daily heating and DHW energy consumption. In this sense, the real primary energy consumption during the year 2017 was about 45.948 kWh/m 2 year and it can be compared to the different calculation procedures from Table 2. In particular, the actual primary energy consumption of the building shows much lower value than those presented by the energy certification (28% of the estimate).

Monte Carlo Method
From the data obtained during 3 years it was concluded that there are important differences respect the calculated energy demand. Regarding the causes of this deviation, the occupation of the building and environmental variables such as outdoor temperature, climatology, etc. were analyzed. In this sense, the present study aims to analyze the outdoor temperature effect over standards indications by means the Monte Carlo method. This iterative methodology will allow us to analyze the impact of multiple variables on the energy efficiency of the building and will let us show the better retrofit option to reach the energetic optimization.
It starts from the modeling of the energy certification method by spreadsheets and into comparing it with the results obtained by the CE3X software, observing that the deviations between the two are minimal, as it was shown in previous sections. After this, the application of the Monte Carlo method over this standard will let us to obtain thousands of energy certifications and the obtained bell of Gauss will let us define a mathematical model that relates main retrofit parameters with the cost of the actions and the energy consumption.
In this sense, the building objective of this study is located in the province of La Coruña, with the environmental data (maximum temperature (T max ), minimum temperature (T min ), dry bulb temperature (T dry bulb ), relative humidity (RH)) obtained from DB-HE1 standard showed in Table 3. As we can see in Table 3, outdoor temperature data can oscillate between the minimum and maximum-recorded value. With the aim to obtain the probability distribution of the energy consumption for each different retrofitting option, in accordance with the Monte Carlo method indications, the calculation of building energy consumption was modified from this monthly average value to a random one. Because of this random process, a bell of Gauss of the energy consumption for each different possible modification was obtained. In particular, after a minimum of 200 iterations, defined this number in accordance with previous research work results [31][32][33], it can be carried out an energetic analysis of the energy consumption distribution, respect the value proposed by CE3X software for constant outdoor temperature, reflected in Figure 10.
On one hand, at the time to prepare the energy certification of this building a static value of dry temperatures defined by the Spanish technical building code (Table 3), 0.67 ach and category 2 window permeability (27 m 3 /h m 2 ) was selected and gave us a base value 56.520 kWh/m 2 . On the other hand, if a random outdoor dry bulb temperature is employed, the distribution of frequencies describes a bell of Gauss centered in 63.480 kWh/m 2 . This difference shows the need of an analysis of deviation causes as it will be done in the discussion section.

Optimization Possibilities
In a third phase of analysis, it was proposed to use the Monte Carlo method to the building model in order to observe the impact of the available efficiency measures and obtain an optimization method that maximizes efficiency, minimizing investment. For this, different possibilities of action are proposed like:  In order to determine the impact of each measure and the impact of each of the possible combinations, we have proceeded to establish the matrix of combinations and in each of them Monte Carlo method was employed in order to determine the average value of the probability of consumption and its related economical cost. The result was sum up in Table 4. With these experiments, a response surface was carried out by Minitab software, trying to obtain a polynomial capable of determining the energy and economical effects of the possible retrofit combinations. The obtained polynomials are defined by the Equations (5) and (6) with a determination factor of 85.26 and 97.42, respectively.

Discussion
In this section, an analysis of the different results obtained is done with the aim of the understanding of the obtained models and the better way to employ this towards building design and retrofit.

Deviation Causes Analysis
It begins by consulting the average outside temperatures obtained from the nearest meteorological station-and by comparing these with those used in the calculation of the CE3X program-as we can see in Table 5. From Table 5 it was observed that the annual average temperature values have decreased by 1.05% compared to the reference one defined by the standard. This would imply a slightly higher consumption than the obtained in the certification, although we have obtained 43.69 kWh/m 2 year compared to 160.51 kWh/m 2 calculation. Performing the same analysis in the period 2017-2019, it was obtained that the values of total annual consumption have increased (21.7%) from the year 2017 to 2018. In the 2018-2019 period, the energy consumption decreased by 8.63%, while the average temperature decreased by 0.52%.
It was observed that the average outdoor temperature is more or less constant, decreasing slightly each year, so the slight increase in consumption registered in 2018 and 2019 has its justification, as demand and occupancy of the building continue.

Numeric Optimization
These two Equations (5) and (6) are in accordance with commons sense expectative. In this way, the equation of cost shows a base value of 254,641 euros which is more reduced when the variables ACH, UF, UC experiment their highest values related with the actual conditions and low-cost materials. It is interesting to highlight that it happens when the boiler is not changed (0) due to, in this condition, the photovoltaic electrical production will exert an inverse effect increasing the cost at the time that the PV production increases. When a change of boiler is done, this previous effect of the PV production is modified by new terms of this Equation (1) that now are not neglected.
If we now analyze the second equation, Equation (2), the same conclusions cannot be obtained so easily about the effect of each variable in the energy consumption.
With the mathematical models defined by Equations (5) and (6), it can be now obtained the energy consumption and economic investment of each possible retrofits process (columns 4-8 of Tables 6  and 7). If all these possibilities are ordered in accordance with their economic investment (row number), it is obtained Table 6. In consequence, Table 6 starts in row 1 showing the more expensive actions in the building and its related energy consumption. In consequence, on one hand, it was observed that the investment with the highest economical cost does not provide the lowest energy consumption. In this sense, a selection of carpentry category 1 (the best), transmittance of facade 0.59 (the best), transmittance of cover 0.45 (the best), natural gas and nonincorporation of photovoltaic electrical production corresponds to an investment of 215,345 € and reduces consumption to 134.800 kW/m 2 as we can see in Table 6 in its row 1. In this Table 6, it can be observed that the effect to change the boiler from the diesel boiler (0) to a natural gas boiler (1) will exert a higher effect over the final cost with independence of the level of photovoltaic energy generated. This maximum cost is obtained for changing the boiler and carpentry and transmittances in its better values, as we can see in rows 1 to 5. At the same time, the PV production exerts in these initial combinations a slight decrement of the cost at the time PV value increases.
From this same table, it can be observed that, only when the maximum available photovoltaic energy production is combined with a carpentry level 2, without changing the diesel boiler, the cost will be as higher than the previous combinations after changing to a natural gas boiler, see row 13. Despite this similar economical cost of retrofit combinations, it can be observed that the change to PV production instead a boiler implies a so high-energy consumption of 201.000 kWh/m 2 in this row 13 which is nearly the double of the energy consumption of the previous combination showed in the row 12 for nearly the same economical investment.
Another conclusion that can be observed form this Table 6 is that the maximum investments are always obtained remaining the transmittance of the facade and the cover in its minimum value of 0.59 (W/m 2 ·K) and 0.45 (W/m 2 ·K), respectively.
Finally, looking for the optimization of the energy consumption equation, Equation (2), it was obtained that the better option is carpentry category 2 (medium), transmittance of facade 0.59 (the best), transmittance of cover 2.27 (the current one), natural gas as fuel and the incorporation of photovoltaic energy production 15.000 kWp. This investment corresponds to 196,204 € and reduces consumption to 52.970 kW/m 2 , as we can see in Table 6 row 55.
To understand why a more expensive retrofit process will not reach the optimal building design some explanations must be done. In this sense, it is interesting to remember that it is a so complex and nonlinear process where each modification from the more expensive retrofit to the optimal one must be analyzed in depth. In this sense, row 4 of Table 6 shows that just improving the photovoltaic energy production, an initial reduction of the investment and energy consumption is observed. What is more, in row 6 just changing the carpentry permeability to a no so tight material respect the more expensive case implies a reduction of the cost and the energy consumption, but it is not so intense than changing the PV production.
Finally, the row 42 of Table 6 shows a high decrement of the economical investment and energy consumption due to, in this case, a building without changing the transmittance of the cover is considered. The simultaneous combination of all these modifications will let to reach the optimal retrofit at the lowest cost, row 55.
From this result, it can be concluded that, for the particular weather condition of the region where the building is placed, the effect of the facade is more important that the effect of the transmittance of the cover. Furthermore, this modification combined with a change of the boiler are the main parameters towards a reduction of the energy consumption.
Another derived conclusion is that, in this case study, an increment of infiltrations, within reasonable values, will exert a decrement of energy consumption and economical investment. This same effect happens with solar panels, but, as it will be observed in Figure 11, the effect of PV is not a linear variable and, to reach the optimal point, an intermediate value of 15.000 kWp must be employed.

Numeric Optimization for a Limit Investment
Now, based on previous results showed in Table 6, a polynomial optimization was done with tabulated data and by generalized reduced gradient (GRG) algorithm. For this optimization process, standard values of each input variable such as insulation levels, carpentry category, etc. were employed. In this way, implementing the different bounded and tabulated variables, the combinations are obtained, being able to select the optimal one for the limit of the investment desired. In particular, the possible solutions obtained, excluding that with a higher economical investment than 100,000 euros (maximum investment), were ordered in accordance with the minimum energy consumption, as we can see in Table 7.  Figure 11. Numeric optimization of the mathematical model.

Numeric Optimization for a Limit Investment
Now, based on previous results showed in Table 6, a polynomial optimization was done with tabulated data and by generalized reduced gradient (GRG) algorithm. For this optimization process, standard values of each input variable such as insulation levels, carpentry category, etc. were employed. In this way, implementing the different bounded and tabulated variables, the combinations are obtained, being able to select the optimal one for the limit of the investment desired. In particular, the possible solutions obtained, excluding that with a higher economical investment than 100,000 euros (maximum investment), were ordered in accordance with the minimum energy consumption, as we can see in Table 7.
In our case study, it can be observed that, to make an investment in efficiency with a maximum budget of 100,000 euros, there are many combinations, but the one that obtains the highest level of energy efficiency is to employ a carpentry category 2 (medium), transmittance of facade 1.69 (the current one), transmittance of cover 1, natural gas as fuel and the incorporation of photovoltaic electrical production (15 kWp). This investment corresponds to 78,484 euros and reduces consumption to 112,375 kW/m 2 , as we can see in Table 7, row 1. This conclusion is in clear agreement with previous results and shows that just a reduction in the investment in the facade is enough to reduce the cost and, in consequence, it must be the initial variable to be analyzed at the time to take this so important decision. Table 7. Retrofit options ordered by energy consumption (limited to an investment (100,000 €).

Row Cost (€)
Once again, in Table 7, row 1, it can be observed that the lowest economical investment will reach the highest energy saving after changing the boiler to natural gas (1), remaining the transmittance in facade and cover in its worst values and just modifying the medium values of carpentry (Level 2) and photovoltaic electrical production.
At the same time, it can be observed that it is of interest to not change the boiler and the transmittance of the facade only when the transmittance is changed to a better value in the cover and intermediate value of PV production and carpentry, as it can be observed in its row 55. In consequence, it can be observed that the maximum transmittance (the worst) in the facade remains as one of the more important parameters linked to this low energy consumption list.
As it was explained before, if the numeric optimization is done without any limitation and supposing that all the variables are continuous, the minimum energy consumption is defined at 35 ACH, 059 UF, 2.27 UF, Comb heat changed to natural gas and a PV of 16.910 kWp, as we can see in Figure 11. What is more, if now the cost is limited to a value of 100,000 Euros, the proposal of retrofits to a minimum energy consumption is similar to the ideal situation and just a little improvement in carpentry (from 35.50 m 3 /h·m 2 to 33.02 m 3 /h·m 2 ) is proposed, as we can see in Figure 12. Once again, in Table 7, row 1, it can be observed that the lowest economical investment will reach the highest energy saving after changing the boiler to natural gas (1), remaining the transmittance in facade and cover in its worst values and just modifying the medium values of carpentry (Level 2) and photovoltaic electrical production.
At the same time, it can be observed that it is of interest to not change the boiler and the transmittance of the facade only when the transmittance is changed to a better value in the cover and intermediate value of PV production and carpentry, as it can be observed in its row 55. In consequence, it can be observed that the maximum transmittance (the worst) in the facade remains as one of the more important parameters linked to this low energy consumption list.
As it was explained before, if the numeric optimization is done without any limitation and supposing that all the variables are continuous, the minimum energy consumption is defined at 35 ACH, 059 UF, 2.27 UF, Comb heat changed to natural gas and a PV of 16.910 kWp, as we can see in Figure 11. What is more, if now the cost is limited to a value of 100,000 Euros, the proposal of retrofits to a minimum energy consumption is similar to the ideal situation and just a little improvement in carpentry (from 35.50 m 3 /h·m 2 to 33.02 m 3 /h·m 2 ) is proposed, as we can see in Figure 12. Finally, it is interesting to highlight that all the methodology developed showed a so interesting procedure to understand the real effect of each different variable defined by standards over building energy consumption and economical investment being a so interesting tool at the time of decision making by architects and engineers.

Conclusions
The present study shows an original methodology based on the Monte Carlo method applied in Finally, it is interesting to highlight that all the methodology developed showed a so interesting procedure to understand the real effect of each different variable defined by standards over building energy consumption and economical investment being a so interesting tool at the time of decision making by architects and engineers.

Conclusions
The present study shows an original methodology based on the Monte Carlo method applied in the ISO 13790 standard to define the optimal energetic and economical retrofit to do in buildings to reach the better improvement under low cost. Results showed that, in disagreement with the expected results, the more expensive retrofit is not the more efficient and an adequate combination of these modifications will let architects and engineers to get the better energy savings for an initial fixed amount of money to invest. In consequence, present study shows a new procedure to be employed as a guide to architects and engineers at the time to take some decisions during its building designs and retrofit.