# Interactive Airfoil Optimization Using Parsec Parametrization and Adjoint Method
## 2 Theory of Adjoint Optimization
### Discrete Adjoint Method from the Lagrange Point of View: Governing Equations  
In this article, the nomenclature defined by [PERSON] in [3] is used. Thus, \(\mathbf{w}\) is a set of dependent variables, which are usually velocity components at the integration points, pressure at the integration points, and the like. In the panel method, the meaning of \(\mathbf{w}\) is a bit more complex and is clarified later. \(\mathbf{F}\) is the set of independent parameters (design variables) undergoing optimization; in this case, these are the parsec parameters describing the shape of an airfoil. Vectors \(\mathbf{w}\) and \(\mathbf{F}\) are implicitly tied via equations \(\mathbf{R}\), which allows the computing of \(\mathbf{w}\) from the known parameters \(\mathbf{F}\). The fixed parameters (like viscosity, etc.) are not mentioned here as they do not change during optimization. With all the variables defined, it is possible to define the discrete version of the cost function \(I\), where \(\mathbf{w}\) and \(\mathbf{F}\) are subject to constraints \(\mathbf{R}\). This leads to the classical constrained extremum problem solved via the Lagrange multipliers \(\mathbf{\lambda}\).  
\[\mathbf{w}=\begin{bmatrix}w_{1}\\ \vdots\\ w_{n}\end{bmatrix},\qquad\mathbf{F}=\begin{bmatrix}F_{1}\\ \vdots\\ F_{m}\end{bmatrix},\qquad\mathbf{R}=\begin{bmatrix}R_{1}\\ \vdots\\ R_{n}\end{bmatrix}=\mathbf{0},\qquad I=I(\mathbf{w},\mathbf{F}),\qquad\mathbf{\lambda}=\begin{bmatrix} \lambda_{1}\\ \vdots\\ \lambda_{n}\end{bmatrix} \tag{1}\]  
\[\phi(\mathbf{w},\mathbf{F},\mathbf{\Lambda})=I(\mathbf{w},\mathbf{F})+\mathbf{\lambda}^{T}\cdot\mathbf{R} (\mathbf{w},\mathbf{F}) \tag{2}\]  
\[grad(\phi)=\left(\frac{\partial\phi}{\partial w_{i}};\frac{\partial\phi}{ \partial F_{j}};\frac{\partial\phi}{\partial\lambda_{k}}\right)=\left(\frac{ \partial I}{\partial w_{i}}+\lambda_{l};\frac{\partial R_{l}}{\partial w_{i}}; \frac{\partial I}{\partial F_{j}}+\lambda_{l};\frac{\partial R_{l}}{\partial F _{j}};R_{k}\right) \tag{3}\]  
From the gradient, the total differential of \(\phi\) can be defined. However, as all variables in the function \(\phi\) are treated as independent in the Lagrange approach, the gradient of \(\phi\)  
Figure 2: Flowchart of the discrete adjoint method.  
with respect to \(F\) can only be solved when the first and last terms in Equation (4) are equal to zero. From there, two systems of Equations (5) and (6) arise, containing 2n equations in total, which makes it possible to compute \(w\) and \(\lambda\).  
\[d\phi=\bigg{(}\frac{\partial I}{\partial w_{i}}+\lambda_{l}\cdot\frac{ \partial R_{l}}{\partial w_{i}}\bigg{)}dw_{i}+\bigg{(}\frac{\partial I}{ \partial F_{j}}+\lambda_{l}\cdot\frac{\partial R_{l}}{\partial F_{j}}\bigg{)} dF_{j}+R_{k}d\lambda_{k} \tag{4}\]  
\[R=0 \tag{5}\]  
\[\bigg{(}\frac{\partial R}{\partial w}\bigg{)}^{T}\lambda=-\bigg{(}\frac{ \partial I}{\partial w}\bigg{)}^{T} \tag{6}\]  
In the case of linear constraints \(R\), Equation (5) can be written in matrix form, and the Jacobi matrix on the left side of Equation (6) can be easily computed. The system of equations then forms two systems of linear algebraic equations (LAEs): (8) and (9).  
\[R=Aw-b=0\quad\rightarrow\quad Aw=b,\quad\frac{\partial R}{\partial w}\equiv A \tag{7}\]  
\[Aw=b \tag{8}\]  
\[A^{T}\lambda=-\bigg{(}\frac{\partial I}{\partial w}\bigg{)}^{T} \tag{9}\]  
After solving for \(w\) and \(\lambda\), it is easy to obtain the gradient of \(\phi\) with respect to \(F\). It can be proven that this gradient is identically equal to the gradient of \(I\), as the constraints \(R\) must always be satisfied (5). Then, the simple algorithm of the steepest descent is applied to obtain the new approximation of the optimal parameters (11).  
\[G_{j}=\frac{\partial\phi}{\partial F_{j}}=\frac{\partial I}{\partial F_{j}}+ \lambda_{l}\cdot\frac{\partial R_{l}}{\partial F_{j}} \tag{10}\]  
\[F_{(n+1)}=F_{(n)}+\zeta G \tag{11}\]