Optimal design of an indoor environment using an adjoint RNG k- ε turbulence model

. The computational fluid dynamics (CFD)-based adjoint method can determine design variables of an indoor environment according to the optimal design objective, such as minimal predicted mean vote (PMV) for thermal comfort. The method calculates the gradient of the objective function over the design variables so that the objective function can be minimized along the fastest direction using an optimization algorithm. Since the RNG k- ε model is the most popular model used in CFD, the corresponding adjoint equations of the turbulence model should be solved during the design process, rather than the “frozen turbulence” assumption used in the existing approach. This investigation developed adjoint equations for the RNG k- ε turbulence model and applied it to a two -dimensional ventilated cavity. Design processes with the adjoint RNG k- ε turbulence model led to a near -zero design function for the cavity case, while that one with the RNG k- ε turbulence model did not.


Introduction
To create a thermally comfortable and healthy indoor environment, conventional designs use a trial-and-error process [1] that assumes certain thermo-fluid boundary conditions, such as air supply inlet size, number, and locations, air supply velocity and temperature, etc. An appropriate method is then used to estimate the resulting distributions of air temperature, velocity, relative humidity, and contaminant concentrations. The trial-anderror process is very time consuming because the assumed thermo-fluid boundary conditions may not be desirable. Recently, inverse or optimal design processes [2] have emerged, such as the CFD-based [3] genetic algorithm (GA) method [4], CFD-based proper orthogonal decomposition (POD) method [5], CFDbased artificial neural network (ANN) method [6], and CFD-based adjoint method [7].
To design a desirable indoor environment, the CFDbased GA method must calculate a large number of samples, and the number of calculations increases exponentially with the number of design variables. To reduce computing effort, Wei et al. [5] developed a CFD-based POD method that can transform the nonlinear problem into a linear one and build a causeeffect mapping relationship between the objective function and design variables. Since it is a reduced-order method, the accuracy of this method is greatly reduced. The CFD-based ANN method can also build the mapping relationship between the objective function and design variables, in this case by selecting a certain number of samples to train the ANN model. With a well-trained ANN model, the design objective can be predicted without CFD calculations. However, the accuracy of this method depends on the number of samples. In addition, the mapping relationship established by either the CFD-based POD method or the CFD-based ANN method is applicable only to a specific case. For a different case, the relationship would change. The CFD-based adjoint method can quickly find the optimal design of an indoor environment using an optimization algorithm without building a mapping relationship for each new problem, although it may become trapped in local optima [1]. The CFD-based adjoint method is the most efficient and suitable method for the inverse design of a thermally comfortable and healthy indoor environment.
The CFD-based adjoint method was developed recently for inversely designing an indoor environment by solving a set of Navier-Stokes equations and adjoint equations, alternatively. The adjoint equations are derived from the continuous Navier-Stokes equations [8]. Liu and Chen [7] used the CFD-based adjoint method to inversely identify the thermo-fluid boundary conditions required to achieve the optimal design of ventilation for an enclosed environment. Liu et al. [9] then adopted this method to improve the thermal comfort level for an airline cabin. Zhao et al. [10] also attempted to use the CFD-based adjoint method combined with areaconstrained topology and cluster analysis to design a thermally comfortable indoor environment. However, the results of these studies indicated that this method cannot make the objective functions reach the ideal values. One reason may be that the objective functions become trapped in local optima. Another reason may be that the CFD-based adjoint method, which was used in previous studies [7,[9][10][11][12], derives only the adjoint equations of the Reynolds-averaged Navier-Stokes (RANS) equations with the "frozen turbulence" assumption. The assumption is to use the turbulent viscosity calculated in the forward RANS modeling when the adjoint equations are solved. The assumption can reduce deriving manually effort [12,13] by neglecting variations in the turbulent variables. However, this method can provide only approximate gradients, or even incorrect gradients, which may not lead to global optima for the design.
A variant of the method is the discrete adjoint method [14], which first discretizes the Navier-Stokes equations and then derives the discrete adjoint equations from the discrete Navier-Stokes equations. Since the discrete adjoint method derives the complete adjoint equations that include the adjoint equations for calculating turbulent viscosity, it can provide accurate gradients [15]. However, it requires a large amount of computational memory, which may not be affordable in practice. To obtain accurate gradients and reduce computational memory, one option is to develop a continuous adjoint method without using the "frozen turbulence" assumption [16].
Since the turbulent viscosity ν t in the momentum equation can be solved by introducing an appropriate turbulence model, some studies have derived the complete continuous adjoint equations with an appropriate adjoint turbulence model. Zymaris et al. proposed a Spalart-Allmaras one-equation adjoint turbulence model [17] and a standard k-ε adjoint turbulence model [18] to minimize duct pressure losses. Papoutsis-Kiachagias [19] developed a low-Reynoldsnumber Launder-Sharma k-ε adjoint turbulence model to optimize duct shape, with the aim of minimizing viscous losses. All these applications have proved that an appropriate adjoint turbulence model can provide an accurate gradient of the objective function over the design variables. However, none of the above turbulence models is suitable for inversely designing an indoor environment. Chen [20] and Zhang et al. [21] compared different turbulence models and found that the RNG k-ε turbulence model was the most suitable method for solving indoor airflow. Therefore, this study aimed to develop an adjoint RNG k-ε turbulence model for inversely designing an indoor environment.

Objective function
To design an indoor environment using the adjoint method, we must first construct a suitable objective function. For example, the objective function J is a desirable distribution of air velocity V and temperature T in the design domain Θ: where ξ is a vector that represents the design variables, such as air supply inlet size, number, and locations; air supply velocity, V inlet ; air supply temperature, T inlet , etc., that could lead to the desirable distribution. In this study, air velocity V and temperature T in the design domain Θ, as shown in Eq. (1), are controlled by the incompressible, steady-state RANS equations, as shown in Eqs.
In these equations, p represents the air pressure; ν eff the effective viscosity; ν the kinematic (laminar) viscosity; D(V) = (∇V+(∇V) T )/2 the rate of strain tensor; γ the thermal expansion coefficient of air; g the gravity vector; T op the operating air temperature; κ effective thermal conductivity; k the turbulent kinetic energy; ν k the effective diffusivity for k; P k the shear production rates of the turbulence kinetic energy; G b buoyancy production rates of turbulent kinetic energy; ε the turbulent energy dissipation; ν ε the effective diffusivity for ε; c μ = 0.0845; η 0 = 4.38; β = 0.012; C ε1 = 1.42; C ε2 = 1.68; C ε3 = 1; V i , V j the components of the air velocity in the x i , x j directions, respectively, i, j = x, y, z; N represents the incompressible, steady-state RANS equations in residual form; and R the residual form of the RNG k-ε turbulence model equations.
The purpose of the above constrained design problem is to identify a set of design variables which can lead to a minimum objective function. To minimize the objective function as shown in Eq. (1), the most common method is to use the optimization algorithm. This investigation used the steepest decent method [23] as shown in Eq. (8) to update the design variables. During the optimization process, the key was to calculate the gradient of the objective function over the design variables. Since the objective function implicitly contains the design variables, we cannot directly calculate the gradient of the objective function over the design variables. Therefore, the CFD-based adjoint method was introduced in previous studies [7,[9][10][11][12] to calculate the gradients used in Eq. (8).
where n represents the design cycle, n ≥ 1 and λ is the constant step size.

CFD-based adjoint method with the RNG k-ε turbulence model
To calculate the gradient of the objective function over the design variables, the CFD-based adjoint method first introduces an augmented objective function L as shown in Eq. (9) and transforms the constrained design problem into an unconstrained optimization problem. Since we use RNG k-ε turbulence model to calculate the ν t in N, the p, V, and T in N and k and ε in R are unknown variables when we derive the adjoint equations. Therefore, Eq. (9) should include the RNG k-ε turbulence model equations.
where Ω represents the computational domain and p a , V a , T a , k a , and ε a are the adjoint pressure, adjoint velocity, adjoint temperature, adjoint turbulence kinetic energy, and adjoint rate of dissipation of turbulent energy, respectively. With this arrangement, the problem of solving the gradient of the objective function over the design variables becomes one of calculating the gradient of the augmented objective function over the design variables. In Eq. (9), the augmented objective function L is a nonlinear function of a set of discrete variables (p, V, T, k, and ε). In the gradient equation of the augmented objective function L over the design variables, p, V, T, k, and ε are related to the design variables. So, the most direct approach to evaluate the gradient is to apply the chain rule using the following equation: However, direct calculation of the gradient of the augmented objective function over the air pressure p, velocity V, air temperature T, turbulence kinetic energy k, and rate of dissipation of turbulence energy ε is almost impossible with numerical algorithm today. In previous studies [7,[9][10][11][12], the CFD-based adjoint method only considered variations in the state variables. The method assumed that variations in the turbulent variables, such as k and ε, over the design variables were equal to zero. With the "frozen turbulence" assumption, the k and ε calculated when solving the RANS equations are used in solving the adjoint equations. The assumption is apparently incorrect, because the k and ε are not the same as adjoint k and adjoint ε. Thus, the following gradient of the augmented objective function over the design variables computed by the CFD-based adjoint method with the RNG k-ε turbulence model could lead to significant errors: Furthermore, the CFD-based adjoint method with the RNG k-ε turbulence model sets the sum of the last three terms of Eq. (11) to zero: Now we can obtain the formula for the gradient of the augmented objective function over the design variables: (13) The detailed gradient formulas for the objective function over the air supply velocity V inlet and air supply temperature T inlet can be derived from Eq. (13). Note that the unknown variables in Eq. (13) are the adjoint variables. Therefore, we need to derive the adjoint equations from Eq. (12) and numerically solve the adjoint equations with the use of CFD software. Detailed information about the adjoint equations of the CFD-based adjoint method with the RNG k-ε turbulence model can be found in [12]. Because the "frozen turbulence" assumption was used (i.e., the variation of the turbulent viscosity is equal to zero) to derive the adjoint equations and the RNG k-ε turbulence model was solved to provide the turbulent (or eddy) viscosity ν t values when solving the adjoint equations, p a , V a , and T a calculated were not very accurate. Thus the gradient of the augmented objective function over the design variables was inaccurate [17][18][19]. The "frozen turbulence" assumption is correct only for laminar flow [24]. For turbulent flow, the turbulent viscosity ν t is used to evaluate the effect of unresolved velocity fluctuations u′. Neglecting the variation in turbulent viscosity ν t will lead to incomplete adjoint equations and inaccurate gradients. Therefore, we need to derive the complete adjoint equations for p a , V a , T a , k a , and ε a rather than partial set of the RANS equations only for p a , V a , and T a in order to obtain more accurate results.

CFD-based adjoint method with RNG k-ε adjoint turbulence model
Unlike the CFD-based adjoint method with the RNG k-ε turbulence model, the adjoint RNG k-ε turbulence model considers variations in the turbulent variables, k and ε, over the design variables, as shown in Eq. (10). It is difficult to directly calculate the gradient of the augmented objective function over the air pressure p, velocity V, temperature T, turbulence kinetic energy k, and rate of dissipation of turbulence energy ε. Thus, the sum of the last five terms of Eq. (10) is set to zero: Eq. (14) can then be used to derive the corresponding adjoint equations of the RANS equations closed with the RNG k-ε turbulence model. Since Eq. (14) is equal to zero, the gradient of the augmented objective function over the design variables of Eq. (10) can be expressed by Similar to Eq. (13), the detailed gradient formulas for the objective function over the design variables can be derived from Eq. (15) using the finite volume method. The CFD-based adjoint method with the RNG k-ε turbulence model adopted the RNG k-ε turbulence model for solving the RANS equations and the adjoint RNG k-ε turbulence model for solving the adjoint RANS equations. When the RANS equations closed with the RNG k-ε turbulence model and the adjoint equations are numerically solved in succession, all state fields and adjoint fields needed for calculating the gradient of the objective function over the design variables are available.

Numerical method
The CFD-based adjoint method with the RNG k-ε turbulence model and the adjoint RNG k-ε turbulence model were previously implemented in OpenFOAM (Open Field Operation And Manipulation) [25]. This investigation first used Gambit [26] to spatially discretize the geometric models and then employed the finite volume method to discretize the RANS equations closed with the turbulence model and adjoint equations. The convection and diffusion terms of the RANS equations closed with the turbulence model and adjoint equations were discretized by the first-order upwind scheme and the central difference scheme, respectively. Previous studies [1,7,[9][10][11] all used the first-order upwind scheme to discretize the convection terms of both set of equations and none of the studies have not reported any accuracy issues. Thus, we used the same scheme and did not explore high-order numerical scheme. This investigation applied the generalized geometric-algebraic multi-grid (GAMG) solver [27] to solve the continuity equation and smoothSolver (a solver that uses a smoother) [25] to solve the other equations, respectively. The semi-implicit method for pressurelinked equations (SIMPLE) algorithm [28] turns the continuity equation into a pressure equation when solving the RANS equations. Similarly, this investigation introduced an adjoint pressure equation to replace the adjoint continuity equation. The Boussinesq approximation [29] was used to simulate the thermal plume generated by the temperature difference. The convergence criterion was set as |J n -J n-1 | < δ (where n ≥ 2 and δ = 10 -3 )

Results
In order to verify the performance of the adjoint RNG kε turbulence model for inverse design of an indoor environment, this study tested the proposed method by applying it to a two-dimensional ventilated cavity [30].
To prove the accuracy of the proposed method and the necessity of developing a new method, the CFD-based adjoint method with the RNG k-ε turbulence model was conducted as a comparison.

Two-dimensional ventilated cavity
The first case is a simple two-dimensional ventilated cavity, as shown in Figure 1, with experimental data (i.e., velocity and temperature) along the green center lines and detailed information about all boundary conditions available [30]. The experiment supplied air through the inlet at the top of the left wall and exhausted air through the outlet at the bottom of the right wall. With the exception of the floor, which was heated to 35.5 ºC, the temperatures of the ceiling and walls were all controlled at 15.0 ºC.

Fig. 1. Schematic of a two-dimensional ventilated cavity
• Forward CFD simulation: Before starting the inverse design process, we needed to prove that we had the ability to conduct the forward CFD simulation correctly. This investigation conducted forward CFD simulation using experimental boundary conditions. Experimental data along the green center lines was used to verify the results of the simulation. Figure 2 compares the air velocity and temperature profiles predicted by CFD with the RNG k-ε turbulence model and the experimental data at x = 0.5 l. The comparison indicates that we were able to predict the air distribution accurately in the ventilated cavity. However, the simulation results did not coincide completely with the experimental results. The mean relative error of the air temperature between the CFD simulation results and the experimental data is 2.2%. However, the mean relative error of the air velocity is a little higher, that is because the velocity at the center of the cavity is very small. Thus, there were errors between the experimental data and the results predicted by CFD. The discrepancies may have arisen from measurement errors and uncontrollable factors during the experiment, and numerical errors in the forward CFD simulation. Such errors may affect the inverse design results, and therefore we could not set the experimental data along the green lines as the target values for construction of the objective function.
(a) (b) Fig. 2. Comparison of air velocity and temperature profiles predicted by CFD with the RNG k-ε turbulence model and experimental data from Blay et al. [30] along the x = 0.5 l section • Inverse design process: Since our purpose was to verify the performance of the proposed method using the numerical method, we set the forward CFD simulation results along the two midsections (green lines) as target values to eliminate the influence of experimental errors and numerical errors, and the air supply parameters as the design variables to construct the objective function. If the air supply parameters identified were found to be consistent with the experimental air supply parameters, the proposed method would be verified. For this case, we used the predicted air velocity V 0, ii (vector) and air temperature T 0, ii in a design domain (the values along the two midsections), Θ, as the target values to construct the objective function, which can be expressed as: where W 1 and W 2 are the weighting factors, assumed to be 0.5 in this study; V norm and T norm the normalization factors; T max and T min are equal to 35.5ºC and 15.0ºC, respectively; V inlet, x inlet air velocity in the x directions; m the total number data in the design domain; and V ii and T ii the inversely designed results in the design domain, in this case, respectively. With the above objective function, the adjoint RNG k-ε turbulence model started its inverse design process from the initial inlet boundary conditions. These boundary conditions were V inlet = (0.8, 0) m/s and T inlet = 22.0 ºC. For each design cycle, both the RANS equations closed with the turbulence model and the adjoint equations were calculated with the use of 2,000 iterations to ensure convergence.
• Ruling out the influence of step size: To study the accuracy of the gradient calculated by the proposed method and rule out the influence of step size, we adopted the steepest descent method with proper constant step size in Eq. (8) to update the design variables. Since an improper constant step size could cause the objective function to become trapped in local optima or the calculation to diverge, this investigation used different step sizes for Cases A-0, A-1, A-2, and A-3, as shown in Table 1. Figure 3 depicts the variation in the objective function with the design cycle during the inverse design process. A comparison of Case A-0 with Case A-1 indicates that the smaller step sizes would cause the objective function to become trapped in local optima and stop decreasing after a certain number of design cycles. As we continued to increase the step sizes in Case A-2, the convergence speed accelerated. If the step sizes were too large, as in Case A-3, the method would cause the calculation to diverge. After comparing the above four cases, we selected the appropriate step sizes of Case A-2 in the two-dimensional ventilated cavity and ruled out the influence of step size for further analysis. Table 1 also shows that the air supply parameters in Case A-2 were the closest to the experimental air supply boundary conditions. With the step sizes from Case A-2 and the same initialized air supply parameters, we also used the CFDbased adjoint method with the RNG k-ε turbulence model to inversely identify the optimal design variables for the ventilated cavity, in order to illustrate the need for the new method. Figure 4 compared the k with ka (adjoint k) of these two methods when solving the adjoint equations at the first design cycle that was because these two methods have the same air supply parameters only in this design cycle during the inverse design process. The k is the forward turbulent energy, while the k a is backward turbulent energy. The forward turbulent energy represents the degree of chaos of the flow, while the backward turbulent energy is the opposite. They are very different because two sets of equations are different. As a result, the gradients calculated by these two methods are different. When the objective function of the CFD-based adjoint method with the RNG k-ε turbulence model met the convergence criteria, as shown in Figure 5, the objective function of the adjoint RNG k-ε turbulence model reached the same value at almost the same time. However, the new method can cause the objective function to continue to decrease. The design variables identified by the adjoint RNG k-ε turbulence model for Case A-2 were almost the same as the known experimental data, as shown in Table 2. This indicates that the adjoint RNG k-ε turbulence model has higher calculation accuracy.   After the optimal air supply parameters, as shown in Table 2, had been identified by the two methods, we conducted forward CFD simulation to determine whether the optimized air distribution was consistent with the target values. Figure 6 illustrates the velocity vector and temperature profiles in the design domain predicted with the RNG k-ε turbulence model and with the adjoint RNG k-ε turbulence model. The air distribution in the design domain optimized with the adjoint RNG k-ε turbulence model was closer to the target values than the distribution optimized with the RNG k-ε turbulence model, especially in the center of the design domain. The air temperatures at x = 0.5 l predicted with the RNG k-ε turbulence model were also much lower than the actual values. Thus, the performance of the adjoint RNG k-ε turbulence model was better.
(a) (b) Fig. 6. Comparison of air velocity vectors in the design domain and temperature profiles at x = 0.5 l predicted with the RNG kε turbulence model and with the adjoint RNG k-ε turbulence model, and the forward CFD simulation results using experimental boundary conditions from Blay et al. [30]

Discussions
The adjoint RNG k-ε turbulence model improved the optimal design accuracy, but it could not overcome the inherent disadvantages of the CFD-based adjoint method. The objective function could also become trapped in local optima. If the initial design variables were far away from the optimal values or the step size was not appropriate, the calculation might not lead to the optimal design. This study used only air velocity distribution and temperature distribution to test the performance of the proposed method. With the adjoint method, one could add further design objectives without increasing the computing costs. This study only derived the adjoint equations of the RANS equations with the RNG k-ε turbulence model. However, the turbulence viscosity ν t determined by the RNG k-ε turbulence model cannot uniquely determine the effect of the turbulence and direct numerical simulation (DNS) can provide the results closest to reality, so the most accurate method is deriving the adjoint equations of the N-S equations directly. Due to space limitations, this article does not discuss three-dimensional cases. We will explore the application of the new method to the three-dimensional case in the future study.

Conclusions
This investigation developed an adjoint RNG k-ε turbulence model for the CFD-based adjoint method for optimal design of the indoor environment. The following conclusions can be drawn from this study: • The CFD-based adjoint method with the adjoint RNG k-ε turbulence model can be used to design the optimal air velocity distribution and temperature distribution for a two-dimensional ventilated cavity. • The design process with the adjoint RNG k-ε turbulence model identified design variables that were more accurate than those identified with the RNG k-ε turbulence model. However, the design variables identified with the RNG k-ε turbulence model were more stable during the inverse design process.