 June 19, 2023 Comments Off on The Continuous Adjoint Method For Optimization Problems  Views: 360

# The Continuous Adjoint Method For Optimization Problems

Aerodynamics is a discipline filled with optimization problems. Whether it is drag, lift or downforce, an aerodynamicists’ goal is to maximise the potential performance of an object within a set of constraints. To achieve this, the typical approach is to change an input variable and analyse the effect on the output. However, a more efficient way to solve optimization problems is to identify the changes required to the input to achieve the desired effect on the output, known as the adjoint method.

The adjoint method is a mathematical technique that efficiently calculates the gradient of a function. In this way, the search direction or sensitivity of this function is also calculated and can then be used together with a gradient-based optimization algorithm to define a new point. The gradient of this new point is then calculated, and the process is repeated until the maximum or minimum of the function is found, which represents the optimum solution.

To run through an example of how the adjoint method can be used to find the optimum camber and angle of attack of an airfoil for the maximum lift/drag ratio, check out our blog on the adjoint method. Optimization problems are the key to unlocking performance in a myriad of applications. Here, shape optimization has been used to improve the mass flow within an exhaust port. CREDIT: Stanford University

The adjoint method is based on the adjoint equations which are linear differential equations that relate the desired change in output to the necessary change in input. In CFD solvers, adjoint algorithms first solve the primal equations which are the Navier Stokes equations. The algorithm then solves the adjoint equations which requires a process of discretisation, linearisation and iteration. There are two different approaches to this: 1) continuous adjoint and 2) discrete adjoint.

Continuous adjoint generates the adjoint equations from the primal equations analytically first and then discretises and solves them. Whereas discrete adjoint discretises the primal equations before linearising and solving to get the discrete adjoint system of equations.

The continuous adjoint method offers a number of advantages over discrete adjoint, an important one being the lower memory and CPU cost. ‘With continuous adjoint you don’t need to store the Jacobian matrix, whereas in discrete adjoint you do,’ highlights Pavlos Alexias, Senior CFD Developer at Engys.

‘This matrix takes up large amounts of memory because it contains all the derivatives of the fields, w.r.t. the design variables. Also, discrete adjoint typically uses automatic differentiation tools which lead to memory overheads that slow down the code and increase its complexity. In comparison, continuous adjoint consumes less CPU power and memory which means it can solve faster.’   This allows continuous adjoint to scale easier to more complex problems, such as external aerodynamics, without being that constrained by the number of cells in a computational grid. Shape optimization sensitivity results of a Volkswagen XL1. CREDIT: Stanford University

Another difference is that discrete adjoint requires duality. In other words, if the primal doesn’t converge, some additional effort is necessary to converge the solution. ‘For continuous adjoint, you don’t need to have a fully converged primal and can use techniques such as field averaging to resemble the primal solution,’ explains Alexias.

‘For example, typically you wouldn’t be able to converge a car in low residuals in a steady-state simulation due to vortex shedding and this would make the usage of discrete adjoint very cumbersome. Whereas continuous adjoint can be deployed in such a scenario without issues.’ ‘This is why, with continuous adjoint, you can easily use a high-fidelity unsteady DES [Detached Eddy Simulation] simulation for the primal problem, average the fields and then solve the equivalent steady adjoint version. Of course, as an alternative, both methods can be used to solve a fully transient primal and adjoint simulation, but this has its own known drawbacks for both.’

‘It’s this efficiency and flexibility that has bought significant benefits to customers, particularly on the roadcar side as it enables them to reduce turnaround times which is key when iterating through designs,’ continues Alexias.

‘From a software development perspective, I find it easier to implement new capabilities with continuous adjoint as existing, primal, algorithms can be re-used for the added adjoint equations. Another nice thing is that with continuous adjoint you get the physical understanding of the adjoint system since the equations and their boundary conditions are in closed form.’

It is also very stable and flexible which is why Engys integrated continuous adjoint into its HELYX software and became the first company to offer a CFD adjoint solution to the market.