## 2 Methods
### Field Inversion
Since we are using the negative SA model, the correction is also applied to the negative production term when \(\tilde{\
u}\) becomes negative. In such cases, the equation becomes:  
\[\frac{\partial\varrho\bar{\
u}}{\partial t}+\
abla\cdot(\rho\mathbf{u}\bar{ \
u})=\rho(h(\beta)P_{n}-D_{n})+\frac{1}{\sigma}\
abla\cdot(\rho(\
u+\tilde{ \
u}f_{n})\
abla\bar{\
u})+\frac{cb_{2}}{\sigma}\rho(\
abla\bar{\
u})^{2}- \frac{1}{\sigma}(\
u+\tilde{\
u}f_{n})\
abla\rho\cdot\
abla\bar{\
u} \tag{25}\]  
To solve an optimization problem, evaluating the gradient of the objective function with respect to the correction field is essential. In the context of CFD, the discrete adjoint method is particularly efficient for this purpose. The discrete adjoint method is effective because it allows for the calculation of gradients with respect to a large number of design variables using only one additional adjoint simulation, rather than requiring multiple forward simulations. This approach not only reduces computational costs but also enhances the accuracy and efficiency of gradient computations. By solving the adjoint equations discretely, we obtain precise sensitivity information crucial for refining the optimization process. The equations governing this approach are detailed in the following:  
\[\frac{dG}{d\beta}=\frac{\partial G}{\partial\beta}+\psi^{T}\frac{\partial R}{ \partial\beta} \tag{26}\]  
\[\left[\frac{\partial R}{\partial\bar{u}}\right]^{T}\psi+\left[\frac{\partial G }{\partial\bar{u}}\right]^{T}=0 \tag{27}\]  
where \(\psi\) represents the adjoint field. Classically, the discrete adjoint method involves solving a linear system directly. While this method can be effective, it may struggle with convergence issues in larger or more complex problems, particularly when dealing with viscous or three-dimensional flows. The process often requires high memory usage and can become inefficient as the number of Krylov subspaces increases with each optimization iteration. To overcome these difficulties, a promising alternative is the use of pseudo-time stepping for solving adjoint Equations [47]. This approach leverages the mathematical concept of duality between flow and adjoint systems and allows the adjoint field to evolve in pseudo-time. By applying the same time-marching algorithms used for the primal equations, or other time integration schemes, this method provides flexibility in timestep selection. Unlike physical time, the choice of timestep in pseudo-time is arbitrary, enabling both fixed and increasing timestep techniques. This method not only mitigates convergence issues but also manages numerical transients effectively, making it a robust solution for handling complex adjoint problems. As a result, Equation (27) can be expressed as follows:  
\[\Delta V\frac{\partial\psi}{\partial t}+\left[\frac{\partial R}{\partial\bar{ u}}\right]^{T}\psi+\left[\frac{\partial G}{\partial\bar{u}}\right]^{T}=0 \tag{28}\]  
where \(\Delta V\) represents the discrete cell volumes of the mesh. Once the gradient is found, we update the correction field through the optimization iteration using a modified version of the Gauss-Newton method, as detailed in [46]. The following equations illustrate this process:  
\[\beta^{k+1}=\beta^{k}-\omega\frac{G^{k}-G_{tol}}{\frac{dG}{d\beta}\left|{}^{k} \cdot\frac{dG}{d\beta}\right|^{k}}\frac{dG}{d\beta}\left|{}^{k}\right. \tag{29}\]  
where \(\omega\) represents the under relaxation factor \(\omega\in[0,1]\) and \(G_{tol}\) is a tolerance for the goal function.