Application of sensitivity analysis and genopt to optimize the energy performance of a building in Morocco

The worldwide demographic and economic growth increases the global need for energy and directly contributes to climate change. In Morocco, the residential real estate is the third largest consumer of energy after transport and industry sectors. Thus, the aim of this study is to help engineers improve the energy performance of residential buildings by coupling the TRNSYS software both with a sensitivity analysis method and with an optimization tool. In fact, sensitivity analysis allows reducing the number of input parameters of any studied model, by ranking their degree of impact on any chosen output, and then discard the parameters with the least influence on that output. To do so, we developed algorithms in Python programming language to combine the open source library SALib, available in Github platform, with the TRNSYS software. Then, the chosen input parameters can be optimized through coupling the generic optimization program Genopt with TRNSYS. This article will also explain how these tools were applied to reduce the heating & air-conditioning needs of a high-energy consumption building in Morocco, while studying the variation of nineteen input parameters in TRNSYS. The main aim is to meet the energy performance requirement of the Moroccan thermal regulation for buildings.


Introduction
The unceasing global demographic and economic growths draw continuously the energy needs and the greenhouse gas emissions upwards and lead to the global warming of our planet. Indeed, the energy demand could double by 2050 [1]. The Moroccan energetic background is marked by 95% of dependence on energy from abroad and by an annual growth of primary energy demand of 5% per year since 2004. Consequently, the Moroccan government has engaged in reducing primary energy consumption by approximately 12 to 15% by 2020 and by almost 25% by 2030 [2], [3]. The residential sector is the third largest consumer of energy in Morocco (behind transport and industry), with a share of 18% [2]. Several Moroccan authors studied the improvement of the energy performance of residential buildings; Inter alia, S. Babbah [4] evaluated the needed energy to reach a suitable comfort level in cold and hot periods by using local building materials. R. Idchabani [5] studied the impact of the thermal insulation thickness on the energy needs in the six Moroccan climatic zones. Thus in the scope of this work, we study the reduction of energy consumption of residential buildings, through the development of an optimization methodology of their energy efficiency. In fact, a sensitivity analysis approach is developed and applied in the environment of Settat. It allows reducing the number of input parameters of the models by ranking their impact. Then, the remaining parameters are studied to optimize the energy performance of a building via Genopt.

Weather data
The tools developed in this paper are applied to the environment of Settat, a Moroccan city located between the national capital Rabat and Marrakech. Coordinates of Settat: 33.0°N, -7.6°E and 385m of altitude. The Moroccan thermal regulation for buildings (RTCM) [6], published in 2015, split the Moroccan territory into homogeneous climatic zones by analyzing the climatic data recorded by 37 weather stations over 10 years (1999)(2000)(2001)(2002)(2003)(2004)(2005)(2006)(2007)(2008). The construction of these zones was carried out according to the heating/cooling "degree-day" method. According to the RTCM, Settat is located within the zone of Agadir (Zone 1), and is bordering the climatic zones of Marrakech (Zone 5) and Fez (Zone 3).

Heating & cooling degree days analysis
"Heating degree days", or "HDD", are a measure of how much (in degrees), and for how long (in days), outside air temperature is lower than a specific "base temperature" (or "balance point"). They are used for calculations relating to the energy consumption required to heat buildings. "Cooling degree days", or "CDD", are a measure of how much (in degrees), and for how long (in days), outside air temperature is higher than a specific base temperature. They are used for calculations relating to the energy consumption required to cool buildings. HDD and CDD can be calculated using the equations (1) an (2) respectively. This method is precise and is used when the hourly data are known; indeed, instead of using average day temperatures, hourly temperatures are used: (1) 18°C and 21°C are the base temperatures for the calculation of HDD and CDD respectively [6] and Ti is the outside temperature of the hour i. During calculation, negative values are not retained. Consequently, according to the method of degree-days and independently of the building to study, it is recommended to heat in Settat between mid-November and mid-May and to cool between mid-May and mid-November.

Building model
The selected building for this study is a square room (5m x 5m x 3m). It contains a window (initially set at 2m²) in each one of its frontages. The selected properties of the walls were taken as reference in the calculation of the Moroccan thermal regulation for buildings [6]. They represent the Moroccan constructive mode (table 1). For the windows, we consider a simple-glazing configuration with a thermal conductivity of 5.74 W/m².K and a solar factor of 0.87 [8].
The floor is in contact with the soil. The soil vertical distribution of temperature was modelled by Kasuda [7] and used by G. Floridas and S. Kalogirou [9], [7]. Kasuda demonstrated that the temperature of the soil is function of time and depth below surface and can be described by the equation (3); • T = Temperature of soil; • Tmean = Mean surface temperature (average air temperature) : the temperature of the ground at an infinite depth will be this temperature (17.9°C in our case study); • Tamp = Amplitude of surface temperature (the maximum surface temperature will be Tmean+Tamp and the minimum value will be Tmean-Tamp) (21.7°C in our case study); • Z = Depth below the surface; • α = Thermal diffusivity of the ground (soil); • tnow = current time (day); • tshift = day of the year with the minimum surface temperature (day 37.5 in our case study).
Sick [10] used TRNSYS to establish the Moroccan Thermal Regulation for buildings. We use the same tool to study the building model and to determine its energy performance.

Internal temperature evolution without heating/cooling
We simulated the internal temperature of the building as in table 1, without activation of heating nor of cooling. Results are presented in figure 4 and will be compared with the results of 'degree-days' method. 20°C and 26°C are respectively the recommended base temperatures of heating and cooling by the RTCM [6]. These results confirm the conclusions of the HDD/CDD methods: the building is to cool between mid-May and mid-November and to heat between mid-November and mid-May approximately.

Heating & cooling needs calculation
In this paragraph, we assess the energy needs of heating & cooling necessary to maintain the temperature of the building between the base temperatures of 20 an 26°C [6]. Thus, the annual energy requirement in heating/cooling is equal to 7400 kWh (equivalent to 296 kWh/m² per year). The RTCM, through its performance approach for residential buildings [6], obliges an energy consumption in heating/cooling equal to a maximum of 40 kWh/m² per year in zone 1 (Agadir). Our building's energy requirement exceeds approximately 7 times the recommendation of the RTCM. We will use sensitivity analysis on a panel of the building's input parameters in order to choose the most influential ones and then optimize the energy performance of the building with Genopt tool.

Definition
Buildings/systems simulated on dynamic thermal simulation tools present numerous input parameters. In order to optimize a chosen output of these tools according to the combinations made up of input parameters, sensitivity analysis allows the identification of the parameter or set of parameters that have the greatest influence on the model output, and then not to study the parameters with a low influence on the model. Sensitivity analysis helps determining how a digital model answers variations intervening on its inputs [12], [13]. Sobol sensitivity analysis determines the contribution of each input parameter and their interactions to the overall model output variance. The sensitivity of the output compared to the parameters is given by three indices of sensitivity. The first order index is given by: It makes it possible to study the effect of the variation of a single parameter on the chosen output, while fixing the value of all other parameters. Sobol [14] split the function to study in a sum of functions of increasing size, or representation ANOVA (ANalysis Of VAriance) (Equation 5) to define a decomposition of the variance (Equation 6): The index of the second order is given by: It makes it possible to study the effect of the interactions of two parameters on the output [14]. The total index by: It allows studying both the effect of the parameter alone and the effect of its interaction with the other parameters on the variation of the output. The indices of Sobol are appreciated because they are synthetic and easy to interpret: • If the first order index is high => the parameter is influential on Y, but not vice versa. • If the total order index is low => the parameter has a low influence on Y. • If the first order index is low and its total order index is high, the effects of interaction between the variables give to the parameter its influence on Y. • If the first order index is positive, then the output increases by increasing the parameter, and it is the reverse if it is negative.

Methodology
We developed algorithms on the Open Source programming language Python, in order to adapt our case study to the algorithms of the SAlib library (Sensitivity Analysis Library) available on Github [11]. We proceed to a coupling of TRNSYS File (with the detail of input parameters to vary) and Python. Python generates a sampling of these inputs according to their respective intervals of variation, and launches simulations on TRNSYS for each combination. Ultimately, Python calculates Sobol's sensitivity indices [11] of the chosen output.

Studied parameters
To establish the Moroccan thermal regulation, Sick [10] carried out a parametric analysis on the building envelope parameters below: • Insulation of walls, roof and floor • Insulation of windows • Solar protection of glazings and windows • Orientation of the building P. Heiselberg and al. [15] studied the impact of U-value of walls and of windows, solar protections, ventilation and lighting on the energy needs for an office building in Denmark. A. Shariah and al. [16] studied the impact of the variation of the absorption coefficients on the energy consumptions in Jordany and concluded that the use of light colours on the external face of the ceiling reduces significantly the heating & air conditioning needs. Thus, we will combine these various studies and propose the parameters of table 2. These parameters vary continuously on their respective intervals. (1) For the external walls, we vary the thickness of the air gap from 0 cm (2.463 W/m².K) to 20 cm (0.383 W/m².K).
(4/7) For the roof and the floor, we will use a thermal insulation material from the TRNSYS library [8] to reduce the thermal conductivity: • Roof : the insulation thickness vary from 0 cm (3.332 W/m².K) to 15 cm (0.247 W/m².K); • Floor : the insulation thickness vary from 0 cm (3.445 W/m².K) to 15 cm (0.249 W/m².K); (10/13) The total percentage of windows, doors and rooflights is defined (TGBV) by the RTCM [6] as being the sum of the surface of windows/doors/rooflight of heated-air conditioned rooms divided by the sum of surfaces of external walls of heated-air conditioned rooms. The RTCM recommends a maximum TGBV of 45% => a maximum of 27m² of windows in our case study. (2/3/5/6/8/9/15) The absorption coefficients of the walls depend on their painting colour. (14) For the windows frame, we study two alternatives: an aluminium (U = 4.3 W/m².K) and a wood frame (U = 1.3 W/m².K) alternatives [8]; (16/17/18/19) For shading devices, zero indicate that they are not used and one indicates that their ratio of use is 100%. In addition, we consider a systematic non-use between mid-November and mid-May of each year. These parameters are selected to study the sensitivity analysis of these outputs of TRNSYS: • Heating energy needs.
• Cooling energy needs. Our objective being the study of: • Total energy needs (Heating & cooling). The number of parameters is 19 inputs. Sensitivity analysis will allow us to determine the most influent of these parameters on the outputs.  For the heating needs, the dominating factors are:

Heating needs
• The insulation of external walls; • The insulation of the roof; • The absorption coefficient of external walls; • The insulation of the floor; • North-facing window surface and the absorption coefficient of the roof.  For the total energy needs, the three most important factors are relating to the thermal insulation of the roof, the external walls and the floor, followed by the surface of the windows, the absorption coefficients of the roof (external) and of the external walls (external) and the shading devices. Thus, for the optimization study, we retain the following parameters:

Cooling needs
• Thermal conductivity of the external walls, the roof and the floor; • Surface of the windows; • Absorption coefficient of the roof (external); • Absorption coefficient of the external walls (external).

Methodology
Nowadays, the use of system simulation for analyzing complex engineering problems is increasing. Usually users go through the lengthy process of varying the input data, running the simulation and comparing the various results to optimize their outputs. This process does not guarantee to find the optimum, especially when the number of studied parameters exceeds two or three parameters. Thus, it is possible to do automatic optimization and then reduce computing time and effort and obtain results that are more accurate. Our case study will expose the possibility of optimizing the energy performance of the model building by a coupling of TRNSYS and Genopt tool. Genopt -Generic Optimization Program -is a tool developed by the University of California on the programming language Java, making it possible to minimize any cost function according to the studied input parameters. The tool has the following advantages: • No restriction in GenOpt to the number of independent variables; it is however recommended to study between 5 and 20 parameters [17]; • The program is capable of minimizing a function for which no analytical properties are available. (black-box functions); This is interesting in our case study; • It is possible to couple the optimization program to any simulation program with text-based input and output, on any operating system that can run Java; • Possibility of studying continuous or discrete parameters. The algorithm used by Genopt [17] is "GPSPSOCCHJ". This is a hybrid global optimization algorithm that initially does a Particle Swarm Optimization for continuous and discrete independent variables and then switches to the Hooke-Jeeves Generalized Pattern Search algorithm to refine the continuous independent variables. We begin by specifying the parameters of the TRNSYS file that have to be varied (and within which range), the function to minimize in the output file and the location of the input and output files. Genopt reads the simulation input template file (TRNSYS file), where the numerical values of each independent parameter was replaced by its variable name. Genopt then replaces these variable names by numerical values and writes the simulation input files. Afterwards, Genopt launches TRNSYS, waits until the simulation is completed, and then reads the simulation log files and the simulation output files [17]. Genopt then searches the objective function value in the simulation output files, and continues this process until reaching the optimum value of the cost function. We will optimize heating and cooling consumptions according to the parameters retained in the sensitivity analysis, namely: • Thermal conductivity of the Low Floor; • Thermal conductivity of the external walls; • Thermal conductivity of the roof; • Surface of the windows (with minimal values of 2m²); • Absorption coefficient of the roof; • Absorption coefficient of the external walls. We will consider default values for the remaining parameters.  The minimum of 603 kWh was reached for the configuration above. For our simple glazing configuration, it is appropriate to limit to the minimum the surface of the north, east and west facing windows. However, a larger window in the south-facing frontage of the building contributes in natural heating during the day and then reduces the needs for heating. The absorption coefficients were taken to their maximum value to bring the maximum of heat to the room. Finally, thermal conductivities of the various walls were retained with their minimal values.  In opposition to the pervious study, we notice that the optimized value of absorption coefficients is 0.10 (low bound). All the windows have a surface of 2m² (low bound).   The combination of the table 8 makes it possible to obtain an annual energy need (heating + cooling) equal to 997 kWh, which is equivalent to 39,8 kWh/m² per year. Thus, we notice that the optimization of solely nine parameters makes it possible to improve the energy performance of our model building and then correspond to the requirement of the RTCM. The insulation of the walls, roof and floor is mandatory to obtain this level of energy consumption. We also retain that in the configuration "simple glazing", the surface of windows should be limited except the southern bay which lower the heating needs.

Optimization of final energy (heating + cooling) using the 19 initial parameters
In this paragraph, we will optimize the total energy (heating & cooling) without the reduction of parameters resulting from the sensitivity analysis. We thus carry out optimization on the 19 input parameters. While optimizing the 19 input parameters, we obtain a total energy needs of 948 kWh per year, against 997 kWh pear year obtained with the reduction of the parameters via the sensitivity analysis, that is to say a variation of 4,9%. Therefore, optimizing nine parameters instead of nineteen makes it possible in our case study to have an accurate optimization of the total energy of the building and confirms the interest of sensitivity analysis.

Conclusion
This article described a general approach of optimization of the energy performance of buildings. This approach is based on the development of algorithms on python to couple SALib library functions to TRNSYS. This coupling should permit to TRNSYS users a better comprehension of their models and a hierarchy of the impact of their Inputs on the studied outputs. Then, the coupling of TRNSYS and Genopt makes it possible to optimize the choice of input parameters retained as for the selected output.
In our case study, we succeeded in transforming our initial model into an energy efficient building (less than 40 kWh/m²/year in heating and cooling) while optimizing solely less than a dozen inputs.