Skip to main content
Version: Next

The adjoint

Scirocco's gradients come from a discrete adjoint: it differentiates the equations the solver actually solves, so the derivatives are exact for the discretized model, to the solver's tolerance.

The idea​

Let be the converged state, the inputs (coordinates, , , ), and the discrete equations. For an output such as , the chain rule gives

Computing directly costs one linear solve per input. Instead, solve one transposed system for the adjoint vector :

That's one solve per output, however many inputs there are. Scirocco reuses the factorization of from the last Newton step, so each adjoint solve is a back-substitution. Most of the cost is in the product : differentiating the residual, and above all the panel influence coefficients, with respect to every node coordinate. See Performance.

The chain​

Moving a node changes more than the panel it sits on. The derivative chain runs through:

  1. The panel influence coefficients and the inviscid solution.
  2. Arc lengths along the surface and the wake, which follow the nodes.
  3. The boundary-layer residuals at every station.
  4. The force integration.

With a lift target, the chain also includes the angle-of-attack change that keeps on target. The adjoint always uses the plain converged Jacobian, without the PTC damping term.

How it's tested​

The reference is mfoil, the Python code Scirocco was ported from, run with complex-step differentiation. Complex step gives derivatives accurate to machine precision, with no step-size trade-off. The test suites compare against it piece by piece (influence coefficients, residual partials, the geometric chain, force partials) and end to end, for coordinates, , , and .

Limits​

The gradient describes the discretized model at the converged state. Where transition jumps from one panel to the next, the discrete model has a kink, and a gradient taken on one side doesn't describe the other. The gradient says nothing about whether the model itself is physically accurate.

Source: adjoint.cpp.