# Cost Functions

ADflow works in three dimensions (\(x, y, z\)) and application of angles such as `alpha`

and `beta`

change the inflow angle, not the mesh itself.
For example, a high lift airfoil at \(\alpha=20^{\circ}\) has the same mesh as that same airfoil at \(\alpha=0^{\circ}\).
Similarly, a moth T-foil at a \(\beta=5^{\circ}\) leeway angle has the same mesh at \(\beta=0^{\circ}\).

The relevant subroutines for the evaluation of cost functions are located in `surfaceIntegrations.F90`

and `zipperIntegrations.F90`

.
The primary cost functions that are computed in the Fortran code are defined in the `adflowCostFunctions`

dictionary in `pyADflow.py`

.
The following list describes each primary cost function and specifies its units.

- lift
Surface stresses (this includes shear/viscous, normal/pressure, and momentum/unsteady stresses) integrated in the direction of the

`liftIndex`

but perpendicular to the streamwise direction (i.e., dot product in this direction). To clarify, the angle of attack`alpha`

does affect the direction of the force projection. Units:`Newton`

- drag
Surface stresses (this includes shear/viscous, normal/pressure, and momentum/unsteady stresses) integrated in the streamwise direction (i.e., dot product in this direction). Units:

`Newton`

- cl
Lift coefficient computed as \(\frac{L}{qA}\) where \(A\) is

`areaRef`

declared in`AeroProblem()`

and \(q\) is dynamic pressure. Units:`None`

- cd
Drag coefficient computed as \(\frac{D}{qA}\) where \(A\) is

`areaRef`

declared in`AeroProblem()`

and \(q\) is dynamic pressure. Units:`None`

- clp
Component of the lift coefficient

`cl`

from pressure / normal stresses. Units:`None`

- clv
Component of the lift coefficient

`cl`

from viscous / shear stresses. Units:`None`

- clm
Momentum component of the lift coefficient

`cl`

that stems from time rate of change of velocity (unsteady simulation). Units:`None`

- cdp
Component of the drag coefficient

`cd`

from pressure / normal stresses. Units:`None`

- cdv
Component of the drag coefficient

`cd`

from viscous / shear stresses. Units:`None`

- cdm
Momentum component of the drag coefficient

`cd`

that stems from time rate of change of velocity (unsteady simulation). Units:`None`

- fx
Force from surface stresses (this includes shear/viscous, normal/pressure, and momentum/unsteady stresses) integrated in the global \(x\) direction. This direction does not change based on angle of attack and side slip angle. Units:

`Newton`

- fy
Like

`fx`

but in the global \(y\) direction Units:`Newton`

- fz
Like

`fx`

but in the global \(z\) direction Units:`Newton`

- cfx
Force coefficient in the global \(x\) direction computed as \(\frac{F_x}{qA}\) where \(A\) is

`areaRef`

. Units:`None`

- cfxp
Components of the fx coefficient

`cfx`

from pressure / normal stresses. Units:`None`

- cfxv
Components of the fx coefficient

`cfx`

from viscous / shear stresses. Units:`None`

- cfxm
Momentum component of the fx coefficient

`cfx`

that stems from time rate of change of velocity (unsteady simulation). Units:`None`

- cfy
Like

`cfx`

but in the global \(y\) direction.

- cfyp
Like

`cfxp`

but in the global \(y\) direction.

- cfyv
Like

`cfxv`

but in the global \(y\) direction.

- cfym
Like

`cfxm`

but in the global \(y\) direction.

- cfz
Like

`cfx`

but in the global \(z\) direction.

- cfzp
Like

`cfxp`

but in the global \(z\) direction.

- cfzv
Like

`cfxv`

but in the global \(z\) direction.

- cfzm
Like

`cfxm`

but in the global \(z\) direction.

- mx
Moment about \(x\) axis, computed at the location (

`xRef`

,`yRef`

,`zRef`

) as defined in`AeroProblem`

. Units:`Newton * meter`

- my
Moment about \(y\) axis, computed at the location (

`xRef`

,`yRef`

,`zRef`

) as defined in`AeroProblem`

. Units:`Newton * meter`

- mz
Moment about \(z\) axis, computed at the location (

`xRef`

,`yRef`

,`zRef`

) as defined in`AeroProblem`

. Units:`Newton * meter`

- cmx
Moment coefficient about \(x\) axis computed as \(\frac{M_x}{qAc_{ref}}\) where \(A\) is

`areaRef`

and \(c_{ref}\) is a reference length (`AeroProblem.chordRef`

). Units:`None`

- cmy
Moment coefficient about \(y\) axis computed as \(\frac{M_y}{qAc_{ref}}\) where \(A\) is

`areaRef`

and \(c_{ref}\) is a reference length (`AeroProblem.chordRef`

). Units:`None`

- cmz
Moment coefficient about \(z\) axis computed as \(\frac{M_z}{qAc_{ref}}\) where \(A\) is

`areaRef`

and \(c_{ref}\) is a reference length (`AeroProblem.chordRef`

). Units:`None`

- cm0
NOTE: Time spectral stability derivatives are broken as of 2023. Moment coefficient about the \(z\) axis at the zero value of the time spectral motion perturbation.

- cmzalpha
NOTE: Time spectral stability derivatives are broken as of 2023. Derivative of the moment coefficient about the \(z\) axis with respect to angle of attack.

- cmzalphadot
NOTE: Time spectral stability derivatives are broken as of 2023. Derivative of the moment coefficient about the \(z\) axis with respect to the time derivative of angle of attack.

- cl0
NOTE: Time spectral stability derivatives are broken as of 2023. Lift coefficient at the zero value of the time spectral motion perturbation.

- clalpha
NOTE: Time spectral stability derivatives are broken as of 2023. Derivative of the lift coefficient with respect to angle of attack.

- clalphadot
NOTE: Time spectral stability derivatives are broken as of 2023. Derivative of the lift coefficient with respect to the time derivative of angle of attack.

- cfy0
NOTE: Time spectral stability derivatives are broken as of 2023. Force coefficient in the \(y\) axis direction at the zero value of the time spectral motion perturbation.

- cfyalpha
NOTE: Time spectral stability derivatives are broken as of 2023. Derivative of the force coefficient in the \(y\) axis direction with respect to angle of attack.

- cfyalphadot
NOTE: Time spectral stability derivatives are broken as of 2023. Derivative of the force coefficient in the \(y\) axis direction with respect to the time derivative of angle of attack.

- cd0
NOTE: Time spectral stability derivatives are broken as of 2023. Drag coefficient at the zero value of the time spectral motion perturbation.

- cdalpha
NOTE: Time spectral stability derivatives are broken as of 2023. Derivative of the drag coefficient with respect to angle of attack.

- cdalphadot
NOTE: Time spectral stability derivatives are broken as of 2023. Derivative of the drag coefficient with respect to the time derivative of angle of attack.

- cmzq
NOTE: Time spectral stability derivatives are broken as of 2023. Derivative of the moment coefficient about the \(z\) axis with respect to pitch rate.

- cmzqdot
NOTE: Time spectral stability derivatives are broken as of 2023. Derivative of the moment coefficient about the \(z\) axis with respect to the time derivative of pitch rate.

- clq
NOTE: Time spectral stability derivatives are broken as of 2023. Derivative of the lift coefficient with respect to pitch rate.

- clqdot
NOTE: Time spectral stability derivatives are broken as of 2023. Derivative of the lift coefficient with respect to the time derivative of pitch rate.

- cbend
NOTE: Broken as of 2023. Root bending moment coefficient.

- sepsensor
The separation values for the given surface is provided by this cost function. See Kenway and Martins [1] for more details.

- sepsensoravgx
The separation sensor average in x direction. The sensor times the distance in x direction value is computed here.

- sepsensoravgy
The separation sensor average in y direction. The sensor times the distance in y direction value is computed here.

- sepsensoravgz
The separation sensor average in z direction. The sensor times the distance in z direction value is computed here.

- cavitation
Cavitation sensor, not to be confused with the cavitation number. It is a modified Heaviside function accounting for how much \(-C_p\) exceeds the cavitation number over the given surface family. The

`computeCavitation`

flag must be set to True because this introduces additional computations. The most common use case of this cost function involves constraining it over a specific surface family, not all walls. See Liao*et al.*[2] for more details. Units:`None`

- cpmin
Minimum coefficient of pressure (\(C_p\)) over the given surface family. This function is computed with Kreisselmeier-Steinhauser (KS) function aggregation resulting in a conservative constraint because the

`cpmin`

outputted will always be more negative than the true \(C_{p,min}\). The`computeCavitation`

flag must be set to`True`

because this introduces additional computations involving global communications across processors. If`False`

, the returned value is zero. Units:`None`

- mdot
Mass flow rate through the integration surface. Units:

`kg / s`

- mavgptot
Mass flow rate averaged total pressure. Units:

`Pascal`

- aavgptot
Area averaged total pressure. Units:

`Pascal`

- aavgps
Area averaged static pressure. Units:

`Pascal`

- mavgttot
Mass flow rate averaged total temperature. Units:

`Kelvin`

- mavgps
Mass flow rate averaged static pressure. Units:

`Pascal`

- mavgmn
Mass flow rate averaged Mach number. Units:

`None`

- area
The area of the integrated surface. Units:

`meter^2`

- axismoment
Moments about the axis given by

`momentAxis`

defined in the`AeroProblem()`

. Units:`Newton * meter`

- flowpower
Added power by actuator region to the flow volume computed from volume integration. Units:

`Watt`

- forcexpressure
Pressure component of force in the global \(x\) direction. The pressure is calcualted as the difference of the pressure on the wall and the free stream pressure. For closed surfaces, the free stream pressure delta will cancel and the resulting force calculation is correct. However, integrating the force on open surfaces will not result in the free stream static pressure contribution cancelling out. Dimensional

`cfxp`

Units:`Newton`

- forceypressure
Like

`forcexpressure`

but in the global \(y\) direction. Units:`Newton`

- forcezpressure
Like

`forcexpressure`

but in the global \(z\) direction. Units:`Newton`

- forcexviscous
Viscous component of force in x direction. Dimensional version of

`cfxv`

. Units:`Newton`

- forceyviscous
Viscous component of force in y direction. Units:

`Newton`

- forcezviscous
Viscous component of force in z direction. Units:

`Newton`

- forcexmomentum
Momentum component of force in x direction. Units:

`Newton`

- forceymomentum
Momentum component of force in y direction. Units:

`Newton`

- forcezmomentum
Momentum component of force in z direction. Units:

`Newton`

- dragpressure
Pressure drag. Units:

`Newton`

- dragviscous
Viscous drag. Units:

`Newton`

- dragmomentum
Momentum drag from time rate of change of velocity (unsteady simulations). Dimensional

`cdm`

Units:`Newton`

- liftpressure
Pressure component of lift. Units:

`Newton`

- liftviscous
Viscous component of lift. Units:

`Newton`

- liftmomentum
Momentum lift (due to changing momentum of flow in unsteady simulation). Units:

`Newton`

- mavgvx
Mass-averaged \(x\) velocity (i.e., \(\Sigma \dot{m}_x / \Sigma \dot{m}\)). Units:

`m / s`

- mavgvy
Mass-averaged \(y\) velocity. Units:

`m / s`

- mavgvz
Mass-averaged \(z\) velocity. Units:

`m / s`

- mavgvi
A derived velocity average.

- cperror2
The square of the difference between computed cp and target cp* for inverse design. See

`setTargetCp()`

call.

- cofxx
The following center of force cost functions first list the force component (e.g., Fx) and then the coordinate (e.g., x coordinate). These cost functions look at the sum of all forces. Center of

`x`

force,`x`

coordinate. Units:`Meter`

- cofxy
Center of

`x`

force,`y`

coordinate. See`cofxx`

description for more details. Units:`Meter`

- cofxz
Center of

`x`

force,`z`

coordinate. See`cofxx`

description for more details. Units:`Meter`

- cofyx
Center of

`y`

force,`x`

coordinate. See`cofxx`

description for more details. Units:`Meter`

- cofyy
Center of

`y`

force,`y`

coordinate. See`cofxx`

description for more details. Units:`Meter`

- cofyz
Center of

`y`

force,`z`

coordinate. See`cofxx`

description for more details. Units:`Meter`

- cofzx
Center of

`z`

force,`x`

coordinate. See`cofxx`

description for more details. Units:`Meter`

- cofzy
Center of

`z`

force,`y`

coordinate. See`cofxx`

description for more details. Units:`Meter`

- cofzz
Center of

`z`

force,`z`

coordinate. See`cofxx`

description for more details. Units:`Meter`

- colx
Center of lift force,

`x`

coordinate. Units:`Meter`

- coly
Center of lift force,

`y`

coordinate. Units:`Meter`

- colz
Center of lift force,

`z`

coordinate. Units:`Meter`

# References

Gaetan K. W. Kenway and Joaquim R. R. A. Martins. Buffet-onset constraint formulation for aerodynamic shape optimization. *AIAA Journal*, 55(6):1930–1947, June 2017. doi:10.2514/1.J055172.

Yingqian Liao, Joaquim R. R. A. Martins, and Yin Lu Young. 3-D high-fidelity hydrostructural optimization of cavitation-free composite lifting surfaces. *Composite Structures*, 268:113937, July 2021. doi:10.1016/j.compstruct.2021.113937.

James G. Coder, Thomas H. Pulliam, David Hue, Gaetan K. W. Kenway, and Anthony J. Sclafani. Contributions to the 6th AIAA CFD Drag Prediction Workshop using structured grid methods. In *AIAA SciTech Forum*. American Institute of Aeronautics and Astronautics, January 2017. doi:10.2514/6.2017-0960.

Nitin Garg, Gaetan K. W. Kenway, Joaquim R. R. A. Martins, and Yin Lu Young. High-fidelity multipoint hydrostructural optimization of a 3-D hydrofoil. *Journal of Fluids and Structures*, 71:15–39, May 2017. doi:10.1016/j.jfluidstructs.2017.02.001.

Mads H. Aa. Madsen, Frederik Zahle, Niels N. Sørensen, and Joaquim R. R. A. Martins. Multipoint high-fidelity CFD-based aerodynamic shape optimization of a 10 MW wind turbine. *Wind Energy Science*, 4:163–192, April 2019. doi:10.5194/wes-4-163-2019.