Theory for Stationary Sensitivity Analysis
Evaluating the sensitivity of a scalar-valued objective function Q(ξ) with respect to the control variables, ξ, at a specific point, ξ0, can be rephrased as the problem of calculating the derivative Q/∂ξ at ξ = ξ0. In the context of a multiphysics model, Q is usually not an explicit expression in the control variables ξ alone. Rather, Q(u(ξ), ξ) is also a function of the solution variables u, which are in turn implicitly functions of ξ.
The multiphysics problem is a PDE, which after discretization is represented as a system of equations L(u(ξ), ξ) = 0. If the PDE has a unique solution u = L-1(ξ), the sensitivity problem can be informally rewritten using the chain rule as that of finding
The first term, which is an explicit partial derivative of the objective function with respect to the control variables, is easy to compute using symbolic differentiation. The second term is more difficult. Assuming that the PDE solution has N degrees of freedom and that there are n control variables ξi, Q/∂u is an N-by-1 matrix, u/∂L is an N-by-N matrix (because L1 is unique), and L/∂ξ is an N-by-n matrix.
The system of equations, L, is here assumed to include any constraints present in the multiphysics model. The number of degrees of freedom, N, therefore in theory includes also Lagrange multipliers for the constraints. In practice, constraints are usually eliminated, which imposes some restrictions on the sensitivity analysis; see The Sensitivity Analysis Algorithm in the COMSOL Multiphysics Reference Manual.
The first and last factors, Q/∂u and L/∂ξ, can be computed directly using symbolic differentiation. The key to evaluating the complete expression lies in noting that the middle factor can be computed as u/∂L = (∂L/∂u)1 and that L/∂u is the PDE Jacobian at the solution point:
(2-4)
Actually evaluating the inverse of the N-by-N Jacobian matrix is too expensive. In order to avoid that step, an auxiliary linear problem can be introduced. This can be done in two different ways, each requiring at least one additional linear solution step (see Forward Sensitivity Methods and Adjoint Sensitivity Method below).
If an incomplete Jacobian has been detected during the sensitivity analysis, an attempt to assemble the complete Jacobian is done. If the assembly succeeds, the complete Jacobian is used in sensitivity computations in the following way:
Assume that the Jacobian in Equation 2-4 above is incomplete and denote it by .
Let the complete Jacobian be . Hence, the system to solve is
(2-5)
Using
the previous system becomes
Then, the solution to the system in Equation 2-5 is approximated iteratively by
where n is the iteration number.
The iterations are terminated either when the estimated error is less than the relative tolerance used by the current solver (convergence), or when the number of iterations has reached the maximum number of iterations specified in the Fully Coupled or Segregated attribute node (nonconvergence).
If the previous algorithm does not converge (that is, the estimated error is larger than the given tolerance), the sensitivity computations are repeated using the incomplete Jacobian and the warning Jacobian is incomplete. No convergence when attempting to use the complete Jacobian is written.
If the assemble of the complete Jacobian fails, the incomplete Jacobian is used and the warning Unable to assemble the complete Jacobian. Using incomplete Jacobian for sensitivity analysis is written.
In the Optimization interface, a warning is written only if the optimization problem does not converge.
Forward Sensitivity Methods
To use the forward sensitivity methods, introduce the N-by-n matrix of solution sensitivities
These can be evaluated by solving n linear systems of equations
using the same Jacobian L/∂u, evaluated at u0). Inserting the result into Equation 2-4, the desired sensitivities can be easily computed as
Adjoint Sensitivity Method
To use the adjoint sensitivity method, introduce instead the N-by-1 adjoint solution u, which is defined as
Multiplying this relation from the right with the PDE Jacobian L/∂u and transposing leads to a single linear system of equations
using the transpose of the original PDE Jacobian.