## 4 HVAC Control
### Thermal Model  
The first step involves defining a theoretical model for the temperature evolution within an enclosure. Based on the First Law of Thermodynamics, when applied to a control volume, the principle of energy conservation dictates how temperature changes within that space. This relationship can be generally expressed as the following differential Equation (1):  
\[\dot{E}_{vol}=\dot{E}_{in/out}+\dot{E}_{g}+\dot{Q}_{clim} \tag{1}\]  
where \(\dot{E}_{vol}\) represents the rate of change in energy stored in the volume, expressed in W, \(\dot{E}_{in/out}\) denotes the rate of energy exchanged with the outside of the enclosure, expressed in W, and \(\dot{E}_{g}\) represents the rate of energy generated in the volume, expressed in W.  
By applying the generic control volume approach to a specific enclosure, we derive the equation that describes its thermal behavior. In this context, several considerations can be made to further break down the previously defined terms. The \(\dot{E}_{vol}\) term (2) represents the sum of the rate of thermal energy change in the air inside the enclosure plus the rate of thermal energy change in the materials within the enclosure. It is assumed that the air temperature is uniform and consistent throughout the entire enclosure. Based on this, the following Equation (2) is obtained:  
\[\dot{E}_{vol}=\left(m_{air}\cdot c_{p_{air}}+\sum_{j}m_{matj}\cdot c_{p_{matj}} \right)\,\dot{T}=M\,\dot{T} \tag{2}\]In (2), \(m_{air}\) and \(m_{matj}\) represent the mass of air inside the enclosure and the mass of each material in the enclosure, respectively, both measured in kg. The terms \(c_{pair}\) and \(c_{p_{mat,\ j}}\) denote the specific heat capacities of the air and the materials, expressed in J/(kg\(\cdot\)K). Finally, \(\dot{T}\) represents the rate of change in the temperature over time. The term \(\dot{E}_{in/out}\) in (1) includes the thermal power related to the solar radiation received (\(\dot{Q}_{rad}\)), the heat transferred through the envelope (\(\dot{Q}_{enc}\)), and the ventilation thermal load (\(\dot{Q}_{cent}\)) required to maintain indoor air quality in compliance with legal standards. The breakdown of this term is as follows in (3):  
\[\dot{E}_{in/out}=\dot{Q}_{rad}+\dot{Q}_{enc}+\dot{Q}_{cent} \tag{3}\]  
The heat due to solar radiation \(\dot{Q}_{rad}\), expressed in W, is indicated in (4):  
\[\dot{Q}_{rad}=\dot{G}_{i}\cdot S\cdot F\cdot Or\cdot f \tag{4}\]  
In (4), \(\dot{G}_{i}\) represents the global irradiance, expressed in W/m\({}^{2}\), while \(S\) denotes the area of the window on which it is incident, expressed in m\({}^{2}\). \(F\) signifies the modified solar factor, \(Or\) denotes the solar radiation coefficient according to the orientation of the window, and \(f\) represents the attenuation correction factor for elements such as curtains or awnings. The heat transmitted through a wall \(j\), denoted \(\dot{Q}_{enc\ j}\), expressed in W, is calculated as follows in (5):  
\[\dot{Q}_{enc\ j}=U_{j}\cdot S_{j}\cdot\left(T_{ext\ j}-T\right) \tag{5}\]  
In (5), the heat transmission coefficient for a wall, \(U_{j}\), is expressed in W/(K m\({}^{2}\)), while the area, \(S_{j}\), is expressed in m\({}^{2}\). The indoor temperature, \(T\), is expressed in K, as is the temperature of the external environment with which the enclosure area contacts, \(T_{ext\ j}\). It is important to note that this external environment includes both the external environment and other possible enclosures. In consideration of the fact that an enclosure may comprise multiple walls, the general expression is represented in (6):  
\[\dot{Q}_{enc}=\sum_{j}U_{j}\cdot S_{j}\cdot\left(T_{ext\ j}-T\right) \tag{6}\]  
where the subscript \(j\) indicates the number of walls present in the entire enclosure.