Development of a Python-based algorithm for adaptive thermal comfort: Theoretical formulation and application cases.

. Adaptive thermal comfort has gained momentum within the scientific community as a cost effective and affordable way of maintaining acceptable levels of comfort in dwellings while abating energy expenditure. At the moment two international standards, namely the European EN16798-1 and the American ASHRAE55-2010 shape the understanding of adaptive comfort around the world. However, in recent years concerns have raised about whether they can accurately represent comfort conditions considering the cultural and societal background of different countries, and whether adaptive thermal comfort will be still feasible in future scenarios of climate change. Considering these challenges, this study presents an algorithm which can model different adaptive comfort models; additionally, it can be implemented into energy simulation engines and therefore used to predict energy consumption under different climates, building typologies, and dynamic comfort conditions. This contribution presents the development of the aforementioned algorithm, called ACCIS (Adaptive-Comfort-Control-Implementation Script), originally written in EnergyPlus Runtime Language (ERL) and later nested in a Python package called ACCIM (Adaptive-Comfort-Control-Implemented Model)", its main characteristics, and also the implementation into two cases studies: The thermal comfort in social dwellings in Spain and Japan considering present and future climate change scenarios namely Representative Concentration Pathways (RCP) 2.6, 4.5 and 8.5 for years 2050, 2080 and 2100. The results show that the predicted energy consumption of low-income families is strongly influenced by the adaptive comfort model chosen to model their thermal routine and suggest that international standards should be put under revision to consider the local particularities of dwellers in subsidized housing projects. The results of this research can be useful to devise public policies aimed at abating energy cost for low-income dwellers that benefit from social housing programs, particularly in the light of the increment of energy costs for heating and cooling associated with climate change..


Introduction
Adaptive comfort models are powerful tools to represent human comfort conditions in the built environment and to reduce the energy needed to acclimatize indoor spaces. The classical approach based on the PMV model, which was developed in the 70s, has left room for more complex comfort models, known as adaptive comfort models (ACM). These models consider that the interaction between the buildings and its occupants is dynamic. Thus, the comfort conditions depend on a complex interaction between the indoor and outdoor temperatures, as well as other adaptations techniques, such as the variation of clothing, operation of windows, and air movement inside buildings.
At present time, two main standards govern the understanding of adaptive thermal comfort, namely, EN 16798-1:2019 [1] and ASHRAE 55-2020 [2]. Both of them consider that comfort conditions can be divided into two main zones: The dynamic zone, where occupants can adapt to the local variations of the environment to some extent, and the static zone, where too cold or too hot conditions require the use of artificial conditioning systems, therefore resorting to static setpoint temperatures. Applying these models have allowed for a significant reduction of energy consumption in buildings, as recent studies have highlighted.
Additionally, Building Energy Simulation (BES), has gained momentum in the last years as a power full tool to simulate all kinds of physical phenomena in buildings, among which ACM is included. Among the myriad of software available for users, EnergyPlus has become the standard in the field because of its customizability and user friendliness.
However, the authors have identified some important drawbacks of the application of ACMs in Energy Plus, which have been pointed out in previous publications [3]. The main problem is related to the determination of setpoint temperatures, for which designers must resort to rudimentary methods, also prone to human error. For example, users can specify different setpoint temperatures for each of the 12 months of the year, and then do the monthly calculation ignoring the daily or even hourly variations of this parameter that reflect the dynamic perception of the thermal environment by humans. Alternative methods resort to objects in EnergyPlus running code, such as Schedule:Compact, by which setpoint temperatures are stored in an Excel spreadsheet, and then copied into the Schedule:Compact object; later, the user must match the former file with the EPW file representing the local climate. Logically, manipulating such huge amounts of data is time consuming; moreover, the process is error prone as it is managed by humans.
So far, little attention has been paid to the possibilities that modern programming languages combined with the open-source code from EnergyPlus can offer to designers and researchers in the field of adaptive thermal comfort. The automatization of the process for simulating different ACM in the same climate can allow for a rapid comparison between different scenarios, and also eliminate the possibility of human error.
This contribution presents the work carried out by the authors in the past three years and is organized into two main sections. First, we present the main characteristics of the developed model (ACCIM); second, we present two case studies to validate the ACCIM, considering prototypes of social dwelling in Spain and Japan. The authors consider residents of social dwelling can greatly benefit from the application of such models because they usually belong to the lower strata of society, and therefore face the risk of energy poverty; a careful consideration of their thermal comfort conditions by simulating different ACMs can allow for the design and operation of social dwelling improved comfort conditions while abating energy costs.

Formulation of the ACCIM
The main characteristics of the ACCIM package are presented in this section; it should be clarified that only the main features of the module from an end-user point of view are presented for the sake of clarity and brevity. All the details regarding the theoretical basis of the programming process and technical validation can be found in previous publications by the authors [3].
As a general description, the ACCIM module is an Energy Management System script written in Python. The main purpose of ACCIM is to implement an ACM chosen by the designer into the energy simulation of a building modelled in EnergyPlus, giving as a result a set of adaptive setpoint temperatures for heating and cooling, which can be used by EnergyPlus to estimate the energy demand and energy consumption of the said building.

Step 1
First, the user is prompted to choose the adaptive comfort standard to be considered in the simulations. ACCIM offer full customization of the model through the input of 16 different parameters (Table. 1), which in Python are denoted as sensors; a sensor is an object that gathers data to be used in the simulations. After this, the actuators are added so that it will be possible to change the state of windows (closed or open), and the values of the schedules allocated to each cooling and heating setpoint temperatures.

Step 2
In Step 2 ACCIM gathers information from all the sensors and actuators to define the global variables stated. This is probably the most important part of ACCIM because it gives as an output the setpoint temperatures for heating and cooling using the equations below.
set ACST = RMOT*m+n+ACSToffset+ACSTtol (1) set AHST = RMOT*m+n+AHSToffset+AHSTtol (2) In both equations, the directive set stores the global variables for cooling (ACST) and heating (AHST), taking the values from the running mean outdoor temperature sensor (RMOT) ; m and n are the coeficients of the considered adaptive comfort model ; ACSToffset and AHSToffset are global variables from the offset of comfort temperature previously stored in ACCIM, which refers to the occupant expectations; ACSTtol and AHSTtol are values used as tolerances to make sure the operative temperature falls within comfort limits at all hours (i.e. for ±0.1°C if the upper and lower adaptive comfort limits are 27.4 and 22.4°C, the final adaptive setpoint temperatures would be adjusted to 27.3 and 22.5°C).

Step 3
Once all the setpoint temperatures have been calculated, it is time to model the state of the windows, which is a crucial factor in adaptive comfort. ACCIM uses a combination of Boolean operators to simulate the windows state: 1 means that the window is open, 0 means the windows is closed; also, if operators are used to check whether some conditions for natural ventilation are met: • The first if block determines if the environmental conditions are suitable for mixed ventilation.
• The second if block work similarly to the first block, but checking whether free-running mode is applicable.
The third if block modifies the values of the schedule depending on the type of artificial air conditioning and the setpoint temperatures.

Step 4
The fourth and final stage compiles all the information from the three previous stages and delivers a set of variables that EnergyPlus can use in the BES, whose list is given below along with its variable:

Application case: Social dwelling in
Spain.
The first case study under which the ACCIM package has been validated is represented by a prototype of social dwelling located in Spain. The typical apartment building was built in 1973, has 8 floors and 2 units per floor, each of them being composed of a living room, a kitchen, a bathroom, and 3 bedrooms; the usable area of each unit is around 73m2, and the apartments face South and have cross ventilation.
The Spanish Building code (CTE) divides the country into 9 different climate zones, depending on the severity of winter and summer seasons, which, in turn, determine the heating and cooling load respectively. In this study, 3 representative locations were selected: The city of Sevilla, which belong to zone B4 and features a Csa climate according to Köppen-Geiger classification; the city of Madrid, located in the D3 zone with a BSh climate; the city of Ávila, in the E1 climate zone sith a Csb climate.
In this case study, four scenarios were calculated for each location. First, the apartment unit was modelled in EnergyPlus and the cooling, heating, and total energy consumption were calculated using the static setpoint temperatures for heating and cooling specified by the Spanish CTE. Second, the simulations were carried out using three different adaptive comfort models. The OUT-CTE, which contains adaptive setpoint temperatures as per the Spanish CTE, which have been incorporated to the code recently. Second, OUT-SEN 15251, which represents the static setpoint temperatures of the former EN15251. Third, the OUT-AEN 15251, where upper and lower comfort limits are extended to maximize the applicability of the adaptive comfort model. For each model, three scenarios of climate change were modelled: Current scenario, 2050, and 2080.
A detailed explanation of all the parameters considered in these simulations, such as plans and elevations of the considered buildings, constructive features, equations of adaptive comfort for the considered models, etc, can be found in previous publications by the authors [4].
The results from the simulations show that heating, cooling, and total energy consumption can be remarkably reduced in all locations for both scenarios; it is also interesting how the adaptive comfort models show flexibility in reducing the energy consumption in different climate zones of the country, which shows evidence of its applicability in reducing both heating and cooling loads (Table. 2).

Application case: Social dwelling in Japan.
The second case study that was used for validation is a prototype of a social dwelling in Japan, named as 51C. This prototype has been profusely used in many social dwelling complexes across the country and, leaving aside the cultural differences between Japan and Spain, has approximately the same configuration in terms of architectural and design features.
The apartment buildings usually have four or five floors, and two apartments per floor. The typical apartment consists of a 2DK: A dining-kitchen as the main living space (circa 10 sqm each), and 2 bedrooms (circa 8 sqm each). The apartments face South and have a big balcony in their main orientation; they also benefit from cross ventilation because of the double orientation and generous separation between apartment blocks. Again, a detailed description of the constructive and design features of the apartment for this case study can be found in previous publications by the authors [5]. The apartment was modelled in EnergyPlus and simulations were carried out for each of the 8 different zones into which Japan is divided to estimate the cooling and heating load of buildings, as per the Japanese building code. For an easy identification, the EPW file for a representative location was chosen for each climate zone: Asahikawa, Sapporo, Morioka, Niigata, Maebashi, Tokyo, Kagoshima, and Naha.
In this case study three different comfort models were considered. First, static setpoint temperatures were simulated using two models as a reference: The ASHRAE 55 (adaptive model) and the COOL BIZ's static setpoint temperatures in order to provide a reference of static setpoint temperatures consistent with the culture of Japan. Since Japan does not yet have a static comfort model implemented in its buiding code, the model developed by Rijal [6] was chosen because of its high reliability and the number of thermal comfort votes collected in Japanese residential environments.
Using these three models, the cooling, heating ,and total energy consumption for the prototype apartment was modelled for each climate zone; additionally, three climate change scenarios (RCP26, RCP45, and RCP85) were considered for the present time, the year 2050 and 2100. Table 3. Maximum percentage of reduction of total energy consumption for the Japanese adaptive comfort model by Rijal, compared with the ASHRAE 55 and the COOLBIZ model. Table 3 shows that a significant reduction in the energy consumption of social dwellings can be achieved when a model suited to the local cultural preferences of Japanese residents is considered; it is also remarkable that these reductions are also significant when compared to international comfort models, which are supposed to find applicability to a variety of contexts.
Our results also show that climate change will have a controversial impact on the applicability of this model, particularly in the extent to which natural ventilation can provide residents with comfort. When compared with the present scenario, the effectivity of natural ventilation will show increments in Niigata (7%), Kagoshima (6%), and Naha (21%); on the contrary, Asahikawa, Sapporo, Morioka, Maebashi, and Tokyo, will see a reduction of 13%, 22%, 7%, 16% and 2 %, respectively.