## 1. Introduction

Intensive production systems are established in order to obtain the highest yields in the evolution of agriculture as the primary sector. One of the techniques of crop production is protected agriculture. Greenhouse has helped to increase production, improve quality, and provide sustained and profitable yields. By confining the environment in a greenhouse, the local atmosphere must fit well for cultivation. Making these adjustments sometimes cannot be easy, because the components of the atmosphere (temperature, humidity, CO_{2}) are intrinsically linked. The Computational Fluid Dynamics (CFD) is a tool that provides alternatives for analysis and management of greenhouse environment from a numerical point of view. CFD has advantages over other simulators, because it allows spatial and temporal analysis of the dynamics of the air inside the greenhouse, by introducing local climatic variables as starting conditions. The mathematical approach is based on physical laws expressed as partial differential equations dealing with the dependent variables as unknowns. Therefore, solving this system of equations allows either to see specific details or monitoring of greenhouse environment.

## 2. Models applied to protected agriculture

The inside greenhouse climate depends mainly on local environmental factors, geometry, as well as the type of materials, but they all effect the global distributional variables like: inner air temperature, exterior temperature, relative humidity, solar radiation, and wind speed and direction, further the case of the crop in the greenhouse changes transpiration rate, steam and carbon dioxide. The mentioned variables are complex factors which force solutions for a better approximation.

### 2.1. Lumped mechanistic models

Mechanistic models are based on physical equations. A general representation of this model is shown in Eq. (1). The main equation calculates the temperature inside the greenhouse depending on the factors described on the right side:

Depending on the components of the greenhouse, a more complete equation can be formulated as follows:

In Eq. (1) and (2) are avoided culture or transport of energy by radiation because it does not provide low temperature. Eq. (2) describes the energy representing the greenhouse environment taking into account the ground effect.

### 2.2. Black box model (ARX)

The black box model allows statistical description based on the outputs, given inputs on a limited range. The model only uses data obtained from direct measurements and is considered an empirical approach. So this system also provides a description of the climate of a greenhouse [1].

In general, a mathematical way to write the ARX model with one input and one output is represented in Eq. (3)

where

y (t) = output of the ARX model for t = t, t_{-1} t_{-na}...

u (t) = input of the ARX model for t = t_{-nk}, t_{-nk-1}.... t_{-nk-nb + 1}

na = number of time steps out in the past

nb = number of time steps in the past entry

nk = entry delay, u(t), the output y(t)

### 2.3. Artificial intelligence techniques: artificial neural networks, fuzzy logic-based systems, evolutionary algorithms

Artificial neural networks are nonlinear empirical models, which have been successfully used for modeling greenhouse climate [2]. The nonlinear models are suitable candidates for dealing with complexities observed in the greenhouse behavior as moisture. However, in reference [3] mentions that require a large amount of data and time. Perhaps the best use of neural networks in the case of the greenhouse system is a combination of other alternatives: mechanistic models [4, 5]. Thus, either technical or artificial intelligence as systems based on neural networks and fuzzy logic (neural-fuzzy system) would be extended and promising future applications.

### 2.4. Distributed fluid dynamics models

CFD techniques treat the values of the dependent variables as primary unknowns in a finite number of points, then a set of algebraic equations derived from the fundamental equations applied to the domain are solved through predefined algorithms. Three fundamental physical principles supporting the known Navier–Stokes equations are mass, momentum, and energy conservation. These are obtained for balance on a defined volume control, as given by Eq. (4)

where the four terms correspond to transient, convection, diffusion, and source, respectively. They represent the variable ∅ depending on mass, velocity, temperature, and chemical species distributed in all locations in a given time (φ = φ (x, y, z, t)), in a Cartesian system with Euler viewpoint description. *ρ* denotes density (kg m^{-3}); *t* is time (s); *ϕ* denotes the state variable like air temperature (K), ammonia (NH_{3}), and mass of fraction (kg kg^{-1}); *u* is the wind speed (m s^{-1}); Γ is the diffusion coefficient (m^{2} s^{-1}); and *S*_{φ} is the source term which represents the variation of the amount of material transported.

The computational studies of flow and heat transfer are mainly based on the solution of these equations together with the particular initial and boundary conditions that fulfill the problem. Commercial software regarding fluid dynamics have been designed with a user-friendly environment. To minimize the possibility of erroneously run away the desirable results by the numerical model is recommended to use prototype problems (benchmarks) [6, 7, 8].

#### 2.4.1. Processes representation

Since the atmosphere inside the greenhouse is influenced by local environmental variables, roofing material, irrigation systems, crop type, among others, a model based on computational fluid dynamics is able to represent these variables [9]. A simulation of wind distribution using CFD in a greenhouse is shown in Figure 1.

## 3. Computational fluid dynamics process simulation in a greenhouse

The CFD is based on the Navier–Stokes equations, expressed as a solution of partial differential equations for mass and momentum balances. Their deduction is typically extended through heat and mass balance contained in a control volume. Such equations can be expressed in a generalized form as Eq. 4 [10]. Based on the three basics principles of conservation, mass, momentum, and energy, they can be represented in a conservative way

**Continuity**

Equation 5 is valid for any infinitesimal element, where ρ is the density of fluid (kg cm^{-3}) and **V** the flow velocity.

Momentum and energy equations are expressed for each component in Cartesian coordinates.

**Momentum**

X component:

Y component:

Z component:

**Energy**

(9) |

where q is the rate of heat volumetric flow (kJ/m^{3} s), k is the thermal conductivity(W/(m °C)), ρ is the fluid density(kg/m^{3}), e is the internal energy of the fluid element due to random molecular motion per unit mass (J), V^{2} / 2 is the kinetic energy per unit mass (m^{2}/s^{2}); this is due to translational movement of the fluid element, T is the fluid temperature (°C), f is the force (N), and τ is the Reynolds stress, which represents the turbulent fluctuations of the fluid.

The equation for the internal energy e can be expressed as the static enthalpy h. Indeed, the total enthalpy is given by h = h + V^{2} / 2.

The simulation is performed assuming steady-state conditions. Additionally, the greenhouse airflow patterns are assumed to be turbulent and the *k*-*ε* model is applied to solve for the kinetic energy (*k*) and the viscous dissipation rate of turbulent energy (*ε*). Several researchers have shown that this model makes good representation of the turbulent nature of fluid flow within controlled environments [11, 12, 13, 14] and it is one of the most commonly used [15].

Because low wind speeds prevailed in the experimental site through the year, the average wind speed and gust speed computed from the measured values were 1.89 and 4.34 m s^{-1}, respectively. Free and mixed convection may drive air exchange, instead of forced convection. Similar convection regimes were simulated in this study, as in previous studies performed on the same location [16].

### 3.1. Problem formulation

The simulation of physical and biological processes within the greenhouses is the challenge of the century from the numerical point of view. Although the theoretical basis had been established over the last centuries, advances in scalar or visualization representation were not given until this decade.

It is common to simulate single physical and biological processes, but is still pending models which combine, for example, the processes of photosynthesis and respiration, in order to improve the production of greenhouse crops.

#### 3.1.1. Climate modeling

The analysis by CFD involving heat and mass transfer following the numerical solution of the fundamental equations of mass, energy, and momentum conservation, can deal with transient and distributed solutions, illustrating in space (2 or 3 dimensions) and time the variables of the climate and atmosphere, simultaneously.

Air movement will be based on a temperature gradient and consequently phenomenon of convection mass transport. Two models are essential for the analysis of this case; the flotation model for natural convection accounts for the variation of density as a function of temperature. Boussinesq model is used for suitable results and is given by Eq. (10) [17].

where *ρ* is the density (kg m^{-3}), *β* is the coefficient of thermal expansion (K^{-1}), *T* is the air temperature (K), and the subscript *i* means inside.

Finally, air movement assumes a mixture of liquid, steam, and nonconsumable gas, the standard equation that governs the mixture model and the mixing turbulence model flow for vapor mass fraction (f) can be written as Eq. (11) [18].

Beginning from this statement, the air movement has been exposed. For instance, Figures 2, 3, and 4 show the dynamics of the air into the greenhouse, under different frames, cenital (Figure 2), tunnel (Figure 3), and screen house (Figure 4).

#### 3.1.2. Mechanical ventilation

The mechanical ventilation is less used than natural ventilation, therefore investigation about this is scanty. For instance, the American Society of Agricultural Engineers (ASAE) provides the rules for the design of the mechanical ventilation system [19]; however, [20] there are limitations to these rules, such as the difficulty to incorporate approximate values for the transpiration coefficient in the calculus of the ventilation system.

Other studies like [21] and [22], show that the ventilator allows more control on the temperature in the greenhouse than the passive ventilation [23], and found a vertical gradient of temperature and humidity in the air much more homogeneous with mechanical ventilation. However, in other studies like [19], it was observed that even with mechanical ventilation there can be a notable lack of thermal and humidity homogeneity. Since they measured major temperatures in the high part of the crop for some time, the homogeneity can also be improved if roof windows are lightly open, especially when the greenhouse is big [24]. Both, mechanical and natural ventilation are processes with a high degree of difficulty in the analysis. So the investigation about the combination between natural and mechanical ventilation is very incipient and limited.

Nowadays, Computational Fluid Dynamics (CFD) is a strong tool for analysis, because it allows to study in detail the ventilation process and climatic variables inside of the greenhouse [24, 25]. Questions on the management of the system of ventilation to support sufficient traffic of the air and to achieve acceptable levels of heat transmission and mass between crop and the air can be solved by means of the application of this tool [13, 25–28]. An example of mechanical ventilation in a greenhouse is shown in Figure 5.

#### 3.1.3. Heating system

Greenhouse heating is one of the factors with a significant impact on crop production. From the environmental and economic points of view, the use of fossil fuels in agricultural production is costly; however, in regions with cold winters, the use of heating systems is essential to achieve sustainable production. A method to prevent the temperature going below the minimum threshold for crop production could be based on the forces of convection.

The heating source can be of various types such as collector walls or heating systems, based on water or gas driven through pipes. Heating pipes are effective devices used to keep the greenhouse warm and are implemented in many of the cold climate greenhouses to maintain a targeted temperature [29]. Their principles for heat transfer are convection and radiation; however there is a need to find ways to increase their efficiency. The position of the pipes in the greenhouse and the power of the heating system influence the spatial distribution of temperature and flow patterns due to convective forces.

Reference [29] reported that the best place to locate the pipes is at a half crop height, with the tubes near to the leaves. Other configurations have been studied by several researchers [30, 31], which highlighted the influence of the heating system on the cultivation in terms of convection and radiation. As a result of these studies, the advantages of placing a pipe heating system at the bottom of the crop without affecting the evapotranspiration from plants were discovered. Reference [32], reported that this type of heating system favors the removal of moisture. Humidity, as well as other factors, such as condensation [33] and cooling [34], especially in closed greenhouses [9], have been analyzed by computational fluid dynamics (CFD).

From the numerical point of view, reference [35] performed an experimental validation of a greenhouse model based on CFD to analyze its air thermal gradients. They found that the largest temperature differences occur in the zones close to the ground and under the roof. Conversely, air temperatures inside the greenhouse were more uniform and had a homogeneous distribution. Similarly, Tadj et al. [36] used ANSYS CFX to analyze the airflow and temperature patterns under three scenarios simulating several pipe locations and a tomato crop. They observed the same behavior of the air and temperature patterns, which consisted of strong thermal gradients near the floor and ceiling, and a homogeneous distribution in the rest of the greenhouse.

In this chapter the feasibility of the natural convection phenomena as an energy transference process has been analyzed through simulations, produced in a Venlo type greenhouse with the presence of a fully developed tomato crop. Convection forces were assumed to be produced by the energy stored naturally in the soil mainly due to solar radiation and the energy produced from a pipe heating system (figure 6). The crop was simulated with the “single leaf” approach [37] by considering the plant canopy as a porous zone. CFD simulations were performed for the analysis considering the effects of an adiabatic wall temperature and the external environment. External temperature was given as a boundary condition for the plastic cover (figure 7). Results show the behavior of the greenhouse environment when it is driven by natural convection and assisted by a heating system of this kind.

#### 3.1.4. Mass diffusion within turbulent flows

Air is assumed as a mixture of liquid, vapor, and non-consumable gases. In this study, the species transport model available in FLUENT is possibly used to simulate the mass transport of different gases, such as CO_{2}, nitrogen, ammonia, etc., beginning from the diffusion flux of species *i*, which arises due to gradients of concentration and temperature. Such species model uses the dilute approximation (Ficks’s law) to model mass diffusion. For turbulent flows, mass diffusion can be written as in Eq. 12 [18]

where *J*_{i} (m^{2}/s) is the diffusion flux of species *i* (ammonia), *ρ* is the density of the mixture (kg/m^{3}), *D*_{i,m} is the mass diffusion coefficient for specie *i* in the mixture *m* (m^{2} /s), *D*_{T, i} is the turbulent diffusion coefficient (m^{2} s^{-1}), *Yi* is the mass fraction of specie *i,* and *T* is the temperature of the flow (K).

To achieve the management of environment in the greenhouse, is fundamental the simulation, to know which scenario would be the best to obtain a better production for the specific case. That is why, the gasses simulation are necessary. One specific case is the animal farm. Rabbits and hens are the most representative cases of toxic gasses production. On the other hand, in a greenhouse, the CO_{2} production or extinction is a critical point in the crop production process.

As a result of the application of the diffusion equations and species model to simulate some gasses, specific simulations are shown in Figures 8 and 9.

#### 3.1.5. Distribution of ammonia

Wind direction is the most important factor to exchange air in a semi-closed farm. The concentration of ammonia is greater near the ground because it is where the ammonia is produced (source) and because air renovation is limited due to the vents being located at an elevated position (Figure 9).

Figures 9, 10, 11, and 12 represent ammonia distributions in a structure with rabbit production. If the wind is simulated parallel to the vents, the incoming air produced a lower concentration gradient at the zone beneath the cages (Figure 10). Lower concentration of ammonia results around the rabbit cages, even with the small ventilation rate produced. Thus, ammonia was more uniformly distributed when the wind direction was parallel.

Even though the air ventilation rate was much higher for the case when the wind direction was perpendicular to the vents, a notorious accumulation of ammonia in the area underneath the cages was produced (Figure 9). Ventilation rates increased at the vents level, but air circulation near the ground was limited. Therefore, the concentration of ammonia in the lower zone of the barn was higher than the concentration in the cages area and above. This was probably attributed to a limited air circulation within that zone.

If ammonia gets highly concentrated underneath, as it can be observed in Figure 10 for the scenario II, it represents a hazardous condition. The ammonia accumulated will eventually arise due to a flotation effect when high temperatures are present and that condition may be dangerous for the rabbits.

The ventilation system design is the restricted air circulation observed underneath the cages on the simulation. Thus, having both vent openings at an elevated position from the ground level may not be effective to promote enough ventilation rates and lower the ammonia concentrations sufficiently, especially beneath the rabbit cages. That could be alleviated by lowering the height of the vents in the rabbit barn. Therefore, a modification on the vents position was proposed and simulated.

The modification on the ventilation system of the rabbit barn consisted of having a difference in height between the vent inlet and the vent outlet (Figure 10). The vent inlet was at 0.2 m above the ground level and ran continuously 22 m along the barn. The position of the vent outlet remained as in the original design, at a height of 1.2 m from the ground level.

Air temperature and ammonia mass fraction on the vertical profile at the center of the barn are shown in Figures 11 and 12. Figure 11 shows the case when the wind is parallel and Figure 12, when the wind is perpendicular to the barn. For presentation purposes, the height of the barn is shown in the Y-axis (dependent variable). Results show an improvement on the vertical distribution of air temperature and the ammonia mass fraction with the inlet vent located at 0.2 m of height (Figure 11). Air circulation was particularly improved in the area underneath the rabbit cages, resulting in a reduction of ammonia concentration. A similar result can be seen in Figure 12 (parallel wind direction) where the thermal vertical gradient improved significantly and a reduction of ammonia concentration was achieved in the zone below the rabbit cages.

#### 3.1.6. Theoretical approach of crop

An approach in the analysis of greenhouse ventilation consists in establishing a reliable methodology that describes the interactions that are taking place in the interface porous matrix-fluid.

The flow characteristics in a permeable material can be described in terms of permeability and porosity [38]. If a specific volume is considered, the porosity is represented by the space for which the fluid flows in relation with the total space contained in this volume. The porosity is 0 for zero flow and when it does not exist flow restrictions, the porosity will be 1. The permeability is defined as the ability of the material to flow across itself, analogous when a conduit is totally opened the permeability tends to infinite.

One of the first works to model the flow was published by [39] and later was used by Miguel et al. [38], who indicated that Eq. 13 can be used for analysis of one-dimensional mass transfer across a permeable material

where u (u_{i} ε) is the superficial fluid speed (m/s), u_{i} is the speed across the material (m/s), ε is the porosity (m^{2}/m^{2}), ρ is the density of the fluid (kg/m^{3}), P is the pressure (Pa), μ is the dynamic viscosity (kg/m⋅s), Y is the factor of inertia, x is the flow direction (m), and K is the media permeability (1/m).

Equation 14 is a general equation in explicit form that indicates how the flow speed is related to the pressure gradient by the force to the viscous resistance

The effect of inertia due to the pore is included in the following relation

Equation 15 represents the flow of high pressure inertial loss. The force of viscous resistance due to the transfer at the moment in the interface matrix-fluid is included as Eq. 16

And the resistance for viscosity of the flow of the fluid as Eq. 17

The equation of fluid movement across a porous media can be derived from this equation.

#### 3.1.7. Crops (porous zone)

To study the effects of crop canopy in the airflow inside a greenhouse, Haxaire [40] made an experiment in a wind tunnel to determine the speed loss (drag effect) due to the presence of plants. He also analyzed the effect on the pressure drop (Dp) and the density of foliar area (L) due to changes in the air speed. The determination of the dragging coefficient has allowed new incursions in the study of the fluid dynamics; such studies have been conducted introducing this coefficient [41–44, 26].

The analysis and calculation of the effect of crops can be realized adding the term source into the Navier–Stokes Equation (Eq. 18):

The source term

where *v* is the speed of the air (m/s), L refers to the canopy density (m^{2}/m^{3}), and C_{D} is the friction coefficient (drag coefficient), which [40] experimentally established as 0.32. In order to include the effect of dragging or friction (drag effect) proportionally to the density of foliate area, the crop (cultures) was considered as porous media and it was described by Darcy-Forchheimer in [47], as shown in Eq. 20.

where C_{f} = is the loss coefficient.

In greenhouse ventilation studies, the wind speed is such that the quadratic term of Eq. 20 dominates the linear term. This term can be neglected due to the small lost coefficient in the linear moment equation. The intrinsic permeability K can be deduced combining Eq. 19 and Eq. 20 by the following relation (Eq. 21)

Dragging coefficients were estimated using experimental data for each crop as shown in Table 1, by applying Eq. 19 and Eq. 20. The flow reduction due to crop was simulated in the source term

The shape of the leaves determines air flow. Different crop shapes are shown in Figure 13.

The unload coefficient is the factor that determines momentum loss according the transport equation; when insect mesh windows are used, the pressure drop is 80 %, with a variation of 8 % depending on the mesh porosity [48]. This implies that air speeds inside the greenhouse usually are less than 1 m/s. The reduction is accentuated along the cropped area from the air inlet, depending on cropped length and in a staked crop.

In this case, the wind speed drop for two crops studies is shown in Figure 14. The results show that even if the leaves configuration is different, the pressure drop depends principally on canopy density. This can be attributed that differences in wind speed are not significant. In addition, we have the hypothesis that at the first contact with the crop (Figure 14), airflow modifies the angle inducing a leaves "alignment" that favor the flow and becomes constant and less restrictive. The presence of crop canopy represents a reduction in airflow, which increases as moved away from the wind-inlet window. In this study, an immediate drop was of 0.1 m/s, but as becomes stable, the speed variations are of ± 0.05 m/s in 34 m of greenhouse length.

Due to presence of canopy, there is a speed reduction of 33 % between the inlet and outlet windows (above) through crop canopy (Figure 15A). Inside the canopy, the wind speed is about 0.1 ms^{-1}, but above this, the increase is very small, up to 0.25 %; this can be very important for best placement of sensors to measure transpiration. This process is directly related to wind speed [49].

As a consequence of flow variation, the temperatures showed an increase toward the windows outlet. A 6 K increase was estimated (Figure 15B) with the particularity that this variable is dependent on the canopy height. This indicates the convective transport of the heat inside the greenhouse can be more homogeneous and independent from the air flow rate as it becomes stable.

Schematically, Figure 16 shows the distribution of the speed vectors in the dominant wind direction, and spatial distribution of the temperature in the greenhouse ambient.

## 4. Conclusions

Most of the processes that occur in a greenhouse are related to mass transfer events (relative humidity, transpiration), momentum (velocity, species), and energy or exchange heat (convection, radiation) and consequently, the computational fluid dynamics is a robust tool for greenhouses and animal farm behavior simulation. The inclusion of culture and auxiliary climatic control systems are essential to the production process from an agricultural point of view. The results of this study indicate that once experimentally validated models, the use of these allows to know the spatial characteristics of the variables involved. From the mechanical point of view, the use of anti-insect screens and crop presence causes a drop of 80% in speed. A heating system for hot pipes under conditions of central Mexico is only necessary for specific periods before sunrise. A change in the position of the greenhouse windows in zigzag increases air movement and homogenized conditions inside, even if you keep the same ventilation ratio, but a variation in the porosity of the mesh has side effects in the air renewal ratio. The prospect of computational fluid dynamics applied to the protected agriculture, will focus on building a dynamic model with many variables to make efficient use of resources and reduce the use of fossil fuels in crop production.