development of a consistent discrete adjoint solver for ... euroad workshop - tim albring... ·...
TRANSCRIPT
Development of a Consistent Discrete Adjoint Solverfor the SU2 Framework
Tim Albring, Max Sagebaum, Nicolas Gauger
Chair for Scientific ComputingTU Kaiserslautern
16th Euro-AD Workshop, JenaDecember 8, 2014
Open-source multiphysics suite SU2
Some key facts
Developed at Stanford University (with global collaboration).
Comprises complete self-contained optimization environment.
Finite-Volume Discretization of (U)RANS equations and turbulencemodels using a highly modular C++ code-structure.
Convergence Acceleration using Multigrid and local time-steppingmethods.
Albring Development of a Consistent Discrete Adjoint Solver 2/ 24
Demands for a (discrete) Adjoint Solver
Automatic advancement with the flow solver:
Number of commits per week to the SU2 repository.
Smooth integration into the optimization framework (reuse of existingroutines).
Robustness: Inheritance of convergence properties of the flow solver.
Consistency: Resulting gradients should constitute as the exactderivatives based on the particular numerical methods used in the flowsolver.
Albring Development of a Consistent Discrete Adjoint Solver 3/ 24
Generic problem formulation
Given the state vector y ∈ Y ⊂ RN , the discrete design vector χ, thecomputational mesh u and the state equation c(y , u) = 0, the optimizationproblem can be formulated by the following generic problem description:
minχ
J(y(u(χ)), u(χ))
subject to R(y(u(χ)), u(χ)) = 0.
Gradient computation of J is based on an implicitly defined state y .
f can be e.g. CD , CL or CMz .
Usually, there are additional constraints.
Albring Development of a Consistent Discrete Adjoint Solver 4/ 24
Aerodynamic Design ChainComponents
Mesh
DeformationFlow Solver
χ u J, y
Mesh DeformationSurface Deformation usingHicks-Henne functions
∆usurf (x) =n∑
i=1
χi sin(πx
log 5log ti
)Mesh Movement based on theLinear Elasticity Method
Flow SolverJST-based centered spatialdiscretization
Implicit Euler temporaldiscretization
SA or SST turbulence model
Albring Development of a Consistent Discrete Adjoint Solver 5/ 24
The Discrete Adjoint SolverPrerequisites
For Newton-type methods, R(y , u) can be transformed into fixed-pointequation y = G (y , u) by using
G (y , u) := I − P(y , u)R(y , u)
with some suitable preconditioner P.Feasible solutions y = y(u) are then computed from the iteration
yn+1 = G (yn, u).
It is natural to assume that G is stationary only at feasible points, i.e.
R(y∗, u) = 0 iff. y∗ = G (y∗, u).
But: For a complex flow solver, the explicit structure of P (and G) isunknown!
Albring Development of a Consistent Discrete Adjoint Solver 6/ 24
The Discrete Adjoint SolverLagrange viewpoint
Mesh Deformation is included by adding a constraint M(χ) = u to theoptimization problem∗ .Lagrangian function:
L(χ, y , u, y , u) = J(y , u) + yT (G (y , u)︸ ︷︷ ︸=:N, Shifted Lagrangian
−y) + uT (M(χ)− u)
KKT conditions give equations for y , u and dL/dχ:
y =∂
∂yJ(y , u) +
∂
∂yGT (y , u)y =
∂
∂yNT (y , y , u)
u =∂
∂uJ(y , u) +
∂
∂uGT (y , u)y =
∂
∂uNT (y , y , u)
dL
dχ=
d
dχMT (χ)u
∗E.J. Nielsen and M.A. Park. ‘Using An Adjoint Approach to Eliminate Mesh Sensitivities in Computational Design.’, AIAA Journal, Vol.40, No. 5, 2006.
Albring Development of a Consistent Discrete Adjoint Solver 7/ 24
Comparison of Standard Form and Fixed-Point Form∗System of equations is solved using the iterationDn +
∂Rn
∂y
∆yn = −Rn, yn+1 = yn + ∆yn
∗Vamshi M. Korivi. ‘An Incremental Strategy for Calculating Consistent Discrete CFD Sensitivity Derivatives’. Hampton, LangleyResearch Center, 1992.
Albring Development of a Consistent Discrete Adjoint Solver 8/ 24
Comparison of Standard Form and Fixed-Point Form∗System of equations is solved using the iterationDn +
∂Rn
∂y
∆yn = −Rn, yn+1 = yn + ∆yn
Approximation to ∂Rn
∂y due to
first order spatialdiscretizations only,
inconsistent boundaryconditions,
approximate solutions ofthe linear system.
∗Vamshi M. Korivi. ‘An Incremental Strategy for Calculating Consistent Discrete CFD Sensitivity Derivatives’. Hampton, LangleyResearch Center, 1992.
Albring Development of a Consistent Discrete Adjoint Solver 8/ 24
Comparison of Standard Form and Fixed-Point Form∗System of equations is solved using the iterationDn +
∂Rn
∂y
∆yn = −Rn, yn+1 = yn + ∆yn
Approximation to ∂Rn
∂y due to
first order spatialdiscretizations only,
inconsistent boundaryconditions,
approximate solutions ofthe linear system.
(∂R∗
∂y
)T
λ =∂J∗
∂y
∗Vamshi M. Korivi. ‘An Incremental Strategy for Calculating Consistent Discrete CFD Sensitivity Derivatives’. Hampton, LangleyResearch Center, 1992.
Albring Development of a Consistent Discrete Adjoint Solver 8/ 24
Comparison of Standard Form and Fixed-Point Form∗System of equations is solved using the iterationDn +
∂Rn
∂y
∆yn = −Rn, yn+1 = yn + ∆yn
Approximation to ∂Rn
∂y due to
first order spatialdiscretizations only,
inconsistent boundaryconditions,
approximate solutions ofthe linear system.
(∂R∗
∂y
)T
λ =∂J∗
∂y
No approximations allowed inthis formulation to get correct(consistent) gradient.
∗Vamshi M. Korivi. ‘An Incremental Strategy for Calculating Consistent Discrete CFD Sensitivity Derivatives’. Hampton, LangleyResearch Center, 1992.
Albring Development of a Consistent Discrete Adjoint Solver 8/ 24
Comparison of Standard Form and Fixed-Point Form∗System of equations is solved using the iterationDn +
∂Rn
∂y
∆yn = −Rn, yn+1 = yn + ∆yn
Approximation to ∂Rn
∂y due to
first order spatialdiscretizations only,
inconsistent boundaryconditions,
approximate solutions ofthe linear system.
yn+1 =
(∂G∗
∂y
)T
yn +∂J∗
∂y
Uses same approximative Jaco-bian, thus features convergenceto consistent gradient with thesame rate as state iteration.
XG∗ := y∗ −(D∗ +
∂R∗
∂y
)−1
R∗
∗Vamshi M. Korivi. ‘An Incremental Strategy for Calculating Consistent Discrete CFD Sensitivity Derivatives’. Hampton, LangleyResearch Center, 1992.
Albring Development of a Consistent Discrete Adjoint Solver 8/ 24
The Discrete Adjoint SolverNotes on the Implementation
Based on Algorithmic Differentiation for the gradient computation:
Uses a modified version of the Adept C++ software library∗ (alsoprepared for dco and ADOL-C).
Requires almost no modifications in the flow solver.
Highly efficient in runtime:
Time for adjoint solution
Time for flow solution≈ 1.2− 2.5
Actual value depends on the numerical methods used.
Parallelized using AdjointMPI.
∗Robin J. Hogan, ’Fast reverse-mode automatic differentiation using expression templates in C++’, ACM Trans. Math. Softw., 40,26:1-26:16, 2014.
Albring Development of a Consistent Discrete Adjoint Solver 9/ 24
Performance TuningIn the AD-context
1 Solve linear system in Reverse Sweep using analytic formulation:
2 Assume a passive preconditioner P in the non-linear fixed-point solver:
∂G (y , u)
∂y= I − P(y , u)
∂R(y , u)
∂y+∂P(y , u)
∂yR(y , u)
Reasonable to drop this term
since R(yk , u) goes to zero.
u = W−1v Reverse Mode
s = W−T u
W −= s · uT
v += s
u = 0
Both methods can efficiently be combined.
Albring Development of a Consistent Discrete Adjoint Solver 10/ 24
Setting and Performance
GMRES + LU-SGS Preconditioner (BCGSTAB also possible).
Matrix stored using Block Compressed Row Storage.
Linear System in Reverse Sweep solved using same solver withdifferentiated Matrix-Vector product.
Multi-grid disabled.
Flow Solver performance: 0.21s per Iteration (5 Iter. of Linear Solver), 85MB peak memory
Full Taping Active Prec. Passive Prec.Linear Iter. - 5 2 5 2
Runtime 1.42 2.21 1.46 1.74 1.20Memory 30.04 24.42 23.52 21.91 21.76
Relative performance of Adjoint Solver.
Albring Development of a Consistent Discrete Adjoint Solver 11/ 24
Convergence - Adjoint Solverρrms = 10−4
Passive Preconditioner leads to small difference in gradient (error ≈ 0.05%).Much faster with reduced number of linear iterations (despite slightly highernumber of outer iterations).
(a) Convergence yρ (b) Convergence u
Albring Development of a Consistent Discrete Adjoint Solver 12/ 24
Convergence - Adjoint Solverρrms = 10−7
(c) Convergence yρ (d) Convergence u
Albring Development of a Consistent Discrete Adjoint Solver 13/ 24
Inviscid FlowTest case definition
Baseline design: NACA0012
Flow ConditionsMa∞ = 0.8
α = 1.25◦
Numerical Settings
Mesh: 10216 Elements
Multigrid: 3 Level W-Cycle,CFL = 4.0.
38 Hicks-Henne functions
Problem statement:
minχ
CD(χ)
subject to: CL(χ) ≥ 0.326
CMz(χ) ≥ 0.0336.
Albring Development of a Consistent Discrete Adjoint Solver 14/ 24
Inviscid FlowResults
Validation of gradient with Finite Differences resulted in l2-Norm distance of0.068%.
(e) Optimization History (f) Pressure Distribution Cp
Albring Development of a Consistent Discrete Adjoint Solver 15/ 24
Viscous Flow - SATest case definition
Baseline design: RAE2822
Flow conditionsMa∞ = 0.729
α = 2.31◦
Re = 6.5 Mio
Numerical Settings
Mesh: 59976 Elements
3 Level W-Cycle, CFL = 4.0
38 Hicks-Henne functions
Problem statement
minχ
CD(χ)
subject to: CL(χ) = 0.707
CMz(χ) ≥ −0.088
Area = Areainitial .
Albring Development of a Consistent Discrete Adjoint Solver 16/ 24
Viscous Flow - SAValidation
(g) Drag Gradient (h) Lift Gradient
Albring Development of a Consistent Discrete Adjoint Solver 17/ 24
Viscous Flow - SAResults - Optimization History
(i) Discrete Adjoint (j) Continuous Adjoint
Albring Development of a Consistent Discrete Adjoint Solver 18/ 24
Viscous Flow - SAResults - Cp
(k) Pressure Distribution
Albring Development of a Consistent Discrete Adjoint Solver 19/ 24
Viscous Flow - SSTResults
(l) Optimization History (m) Pressure Distribution
Albring Development of a Consistent Discrete Adjoint Solver 20/ 24
Viscous FlowPressure Contours
(n) Baseline (o) Optimized - Discrete Adjoint
Albring Development of a Consistent Discrete Adjoint Solver 21/ 24
3D - Turbulent Flow
Figure: Magnitude of usurf for the Onera-M6 test case using the SST turbulencemodel.
Albring Development of a Consistent Discrete Adjoint Solver 22/ 24
Summary & Outlook
Summary
Differentiation of the entire design chain of SU2.
Consistent gradients of complex flow models.
Efficient and easy maintainable/extensible adjoint solver.
OutlookFurther performance optimizations.
Application to 3D and unsteady flows.
Release of the software suite to the public (early 2015).
Extension to multi-disciplinary optimization (aeroacoustics,aero-structure coupling).
Albring Development of a Consistent Discrete Adjoint Solver 23/ 24