Sensitivity Analysis > Theory for the Sensitivity Interface > Issues to Consider Regarding the Objective Function

Issues to Consider Regarding the Objective Function
The Principle of Virtual Work
Potential energy has a special status among scalar objective functions because its derivatives with respect to scalar control variables can in many cases be interpreted as (true or generalized) forces.
Complex-Valued Objective Functions
Sensitivity analysis can be directly applied only when the objective function is a real differentiable or complex analytic function of the control variables. This is usually not a severe constraint, even for frequency-domain models where the PDE solution variables are complex valued. One reason is that physical quantities of interest to the analyst are always real valued, and if complex-valued control variables are required, it is possible to treat the real and imaginary parts separately.
Some PDE problem or the objective functions are, however, nonanalytic. This is the case, for example, when the equations or the objective function contain real(), imag(), or abs(). One solution in such cases is to enable Split complex variables in real and imaginary parts in the Compile Equations node corresponding to the study step for which sensitivity is computed. This converts the discretized PDE system from a complex-valued system to a real-valued system of double size, with separate degrees of freedom for the real and imaginary part. For this split system, also the nonanalytic functions are differentiable almost everywhere such that sensitivities can be computed.
One special from of nonanalytic objective function can be treated more efficiently than splitting the variables: many common quantities of interest are harmonic time averages, which can be written in the form Q = real(a·conj(b)), where a and b are complex-valued linear functions of the solution variables and therefore implicit functions of the control variables. The problem with this expression is that, while Q is indeed a real-valued differentiable function of the control variables, it is not an analytical function of a and b. This complicates matters slightly because the sensitivity solver relies on symbolic partial differentiation and the chain rule.
While the partial derivatives of Q with respect to a and b are, strictly speaking, undefined, it can be proven that if they are chosen such that
(17-3)
for any small complex increments δa and δb, the final sensitivities are evaluated correctly. The special function realdot(a,b) is identical to real(a*conj(b)) when evaluated but implements partial derivatives according to Equation 17-3. For that reason, use it in the definition of any time-average quantity set as objective function in a sensitivity analysis.