# Energy-Water Management System Based on MPC for a Greenhouse in a Mapuche Indigenous Community
## 4 Climate Predictions
### Short-Term Climate Prediction
#### 4.1.2 Prediction of Internal Climatic Variables  
Phenomenological equations and the predictions of the external variables provided by the neural networks were used to predict the internal climatic variables that affect short-term greenhouse behavior. This was carried out because the greenhouse did not contain instrumentation that could provide real climate data inside the greenhouse, so a phenomenological model was used to represent their behavior. The model was based on the gain and loss in heat and water vapor, similar to the models used in [19; 20; 21]. The model considered in this work was based on that used in [22; 23], where the relationship between the temperature in the greenhouse \(T_{gr}\), the underground temperature \(T_{ss}\), and the absolute humidity \(X_{gr}\) was established considering heat and water vapor exchange. However, this equation could not be applied directly in the control system, because the controller proposed in this work required predictions with a large sampling time \(\Delta t\). The precision of the predictions would be low if the phenomenological model was applied with the same sampling step as the controller. Therefore, to avoid a loss in accuracy, the phenomenological model was used with the sampling time \(\Delta t_{s}\), such that \(J=\frac{\Delta t}{\Delta t_{s}}\in\mathbb{Z}\). Therefore, the dynamics of each internal climatic condition were encompassed by the auxiliary variables \(T_{gr}^{aux}\), \(T_{ss}^{aux}\), and \(X_{gr}^{aux}\), which were used to obtain the values \(T_{gr}\), \(T_{ss}\), and \(X_{gr}\) required by the controller. The auxiliary variables represent estimated values of the greenhouse temperature, ground temperature, and greenhouse absolute humidity based on samples. Thus, the phenomenological model used in this work for the internal temperatures is defined as:\[T_{gr}^{aux}\bigg{(}k+\frac{j}{l}\bigg{)} =T_{gr}^{aux}\bigg{(}k+\frac{j-1}{l}\bigg{)}+\Delta t_{s}\cdot \frac{Q_{l}\Big{(}k+\frac{j-1}{l}\Big{)}}{\bigg{(}p_{air}\cdot c_{pa}+\frac{X_{ gr}\big{(}k+\frac{j-1}{l}\big{)}\cdot c_{pv}}{1000}\bigg{)}V_{gr}}, \tag{6}\] \[T_{ss}^{aux}\bigg{(}k+\frac{j}{l}\bigg{)} =T_{ss}^{aux}\bigg{(}k+\frac{j-1}{l}\bigg{)}+\Delta t_{s}\cdot \frac{Q_{g}\Big{(}k+\frac{j-1}{l}\Big{)}}{A_{g}L_{ss}c_{pg}\rho_{g}}, \tag{7}\]  
where \(j\in[1,\cdots,J]\) is the index of the intermediate steps used to calculate the auxiliary variables available within a given sampling time. In Equation (6), the value \(Q_{t}\) is the heat exchanged, which is computed as:  
\[ \begin{array}{l}Q_{t}\Big{(}k+\frac{j-1}{l}\Big{)}=Q_{rad}\Big{(}k+\frac{j- 1}{l}\Big{)}-Q_{cc}\Big{(}k+\frac{j-1}{l}\Big{)}-Q_{ren}\Big{(}k+\frac{j-1}{l }\Big{)}...\\ -Q_{g}\Big{(}k+\frac{j-1}{l}\Big{)}-Q_{evap}\Big{(}k+\frac{j-1}{l}\Big{)}, \end{array}  \tag{8}\]  
where \(Q_{rad}\) is the heat gained via radiation in W, defined as the sum of the solar radiation that enters the greenhouse \(R_{sol}\) and the thermic radiation from the greenhouse's structure \(R_{ter}\). \(Q_{cc}\) is the heat exchange via conduction and convection, which is defined as:  
\[Q_{cc}(k)=A_{cu}\cdot U_{cc}(k)\cdot\big{(}T_{gr}(k)-T_{ext}(k)\big{)}, \tag{9}\]  
with \(A_{cu}\) being the area of the external surface of the greenhouse structure, \(U_{cc}\) the convective heat transfer coefficient, \(T_{gr}\) the temperature inside the greenhouse, and \(T_{ext}\) the temperature measured outside. Additionally, in Equation (8), \(Q_{ren}\) is the heat exchange related to air renovation, which is represented by the following relationship between the temperature (\(T_{gr}\), \(T_{ext}\)) and humidity (\(X_{gr}\), \(X_{ext}\)) measured inside and outside the greenhouse:  
\[ \begin{array}{ll}Q_{ren}(k)=&C_{1}(T_{gr}(k)-T_{ext}(k))+C_{2}(X_{gr}(k)-X_{ ext}(k))\\ &\qquad+C_{3}\big{(}X_{gr}(k)T_{gr}(k)-X_{ext}(k)T_{ext}(k)\big{)}\end{array} , \tag{10}\]  
where \(\{C_{1},C_{2},C_{3}\}\) are constants determined by the air renovation rate and the characteristics of the greenhouse, following the equations described in [22].