implements forward-mode Automatic Differentiation using derived types and operator ... The use of automatic differentiation decreases computational cost and ...
Wing Optimization using Dual Number Automatic Differentiation in MachUp Joshua D. Hodson *, Douglas F. Hunsaker †, and Robert E. Spall ‡ Utah State University, Logan, UT, 84322, USA The design and optimization of lifting surfaces on an aircraft is a difficult problem, and is typically performed using computational fluid dynamics, which is an expensive process. This paper demonstrates the capabilities of MachUp and Optix to provide cheap early-design optimization of lifting surfaces. MachUp is an open-source software tool that implements a modern numerical lifting-line algorithm to compute lift and drag for multiple lifting surfaces with arbitrary twist, sweep, and dihedral. Optix is an open-source software tool that implements the BFGS optimization algorithm for solving nonlinear optimization problems. Derivatives needed by Optix can be computed using Dual Number Automatic Differentiation, an open-source Fortran library which implements forward-mode Automatic Differentiation using derived types and operator overloading. The use of automatic differentiation decreases computational cost and increases accuracy of the derivatives. Results are presented which demonstrate efficient and accurate optimization of lifting surfaces to minimize induced drag through variation of chord, twist, and camber.
Nomenclature b C Di
= wing span = induced-drag coefficient
C Di ,α ~ CD
= change in induced-drag with angle of attack
CD0 C D1 CD2 CL ~ CL
= section parasitic drag coefficient at zero lift
P
C L,α ~ C L,α c N n RA
RT x z α
α L0 ∆α
= section parasitic drag coefficient = linear coefficient in section parasitic drag equation = quadratic coefficient in section parasitic drag equation = wing lift coefficient = airfoil section lift coefficient = wing lift slope = airfoil section lift slope = = = =
chord length degrees of freedom number of design variables aspect ratio
= = = = = =
taper ratio chordwise location spanwise location geometric angle of attack relative to the freestream zero-lift angle of attack angle-of-attack perturbation magnitude
Graduate Student, Mechanical and Aerospace Engineering, 4130 Old Main Hill, AIAA Student Member Assistant Professor, Mechanical and Aerospace Engineering, 4130 Old Main Hill, AIAA Member ‡ Professor, Mechanical and Aerospace Engineering, 4130 Old Main Hill * †
1 American Institute of Aeronautics and Astronautics
ω Ω opt
A
= normalized washout distribution function = optimum total washout
I. Introduction
ERODYNAMIC shape optimization is an important step in the design process of modern aircraft. This step allows designers to tailor the aerodynamic features of an aircraft to meet a specific set of mission requirements in the most effective way possible. Optimization can be performed early in the design process to identify what features are most important to a design, and toward the end of the design process to refine certain aspects of the design to best meet specific requirements and improve aircraft performance. In many cases, high-fidelity Computational Fluid Dynamics (CFD) analyses are used for this1-4. While CFD analyses provide significant insight into the specific flow characteristics of a design, they come at a relatively high cost due to the complex computational meshes and substantial computing resources required. This is especially true for optimization studies in which many cases must be run to evaluate performance changes with respect to design variables. As a result, CFD is not always the best solution for early-stage optimization when insights into trends and interactions between design parameters are more important than highly-accurate performance characteristics. The computational challenge of using full CFD simulations for aerodynamic optimization are compounded when the application is a morphing wing. In an effort to improve aircraft efficiency through all phases of flight, several morphing-wing technologies are currently in development5-7. In order to take full advantage of the benefits provided by morphing-wing technologies, performance characteristics and control derivatives for the wing in multiple morphed configurations must be readily available. Due to the large number of possible configurations for a morphing wing with even just a few degrees of freedom, the efficiency of aerodynamic and structural computations is of concern. Several alternatives to full CFD simulations are available for wing optimization. The first practical method dates back to the early 20th century when Lanchester8, and later Prandtl9,10, developed what is known today as Prandtl’s classical lifting-line theory. While this was the first mathematical model able to predict lift distributions over a threedimensional wing with reasonable accuracy, the original formulation is restricted to analyses of a single finite wing with a straight quarter-chord and moderate-to-high aspect ratio in an incompressible, inviscid flow. This method has been used to minimize induced drag11,12 and maximize lift13 of various wing planforms. Low-fidelity methods such as the vortex-lattice method and vortex panel method represent another alternative. These potential flow methods are widely used in industry and academia, and their development can be found in common aerodynamic textbooks. For a well-cited overview of these methods, see Katz and Plotkin14. These methods can be used to predict lift, induced drag, and pressure distributions over complex geometries, but are generally unable to account for viscous effects and airfoil thickness. A more recent development in aerodynamic analysis is a modern numerical lifting-line method presented by Phillips and Snyder15. This model is the numerical analog to Prandtl’s classical lifting-line theory but uses the more general three-dimensional vortex lifting law. The numerical formulation allows for the analysis of a system of interacting lifting surfaces with arbitrary camber, twist, sweep, and dihedral. It also allows for the inclusion of viscous effects through the use of two-dimensional airfoil section data. This model should not be confused with the vortexlattice method (using only a single element in the chordwise direction). Although the placement of the horseshoe vortices is similar in both methods, the fundamental equations are significantly different. For example, the vortexlattice method places a control point at the three-quarter-chord position, and closes the formulation by requiring the normal velocity relative to the local camber line at the control point to be zero. On the other hand, the numerical lifting-ling algorithm of Phillips and Snyder15 uses the two-dimensional section lift produced by the local airfoil section to calculate the three-dimensional vortex lift of the finite wing. The latter approach is the numerical equivalent to the analytical approach taken by Prandtl10. It is worth noting that numerical methods for solving the lifting-line equation have been presented by McCormick16 and Anderson et al.17. These methods show accurate results for wings below stall, but they neglect the downwash produced by the bound vorticity and are therefore limited in application to isolated straight wings without sweep or dihedral. In this work, we present a unique implementation of the modern numerical lifting line model developed by Phillips and Snyder15. The purpose of this software tool is to provide an accurate and efficient alternative to CFD simulations for preliminary design analysis, optimization, and morphing-wing characterization. We discuss integrated methods for efficiently evaluating gradients from the software using automatic differentiation (AD) technology. We also present a light-weight, gradient-based optimization framework that can readily interface with the numerical lifting line solver. 2 American Institute of Aeronautics and Astronautics
II. MachUp: A Numerical Lifting Line Tool MachUp is an open-source tool for evaluating the aerodynamic characteristics of systems of finite wings. It uses the numerical lifting-line algorithm developed by Phillips and Snyder15, which, although rooted in inviscid theory, has the ability to include viscous effects. MachUp is written in modern, object-oriented Fortran and interfaces with web applications and other tools through human-readable input and output files. The open-source code is available on Github *. A somewhat simplified version with a browser-based graphical user interface is available on the web. The following sections outline some notable aspects of MachUp. A. Aerodynamic Modeling The core aerodynamic analysis in MachUp is based on the modern numerical lifting-line algorithm developed by Phillips and Snyder15. This algorithm is the numerical analog to Prandtl’s classical lifting-line theory. However, unlike Prandlt’s original theory, this numerical algorithm can be used for systems of wings with sweep and dihedral. The algorithm equates the 3D vortex theory of lift to the 2D section lift at a user-defined number of spanwise locations to solve for the bound vortex strength at each spanwise location. This development produces a nonlinear system of equations that must be solved iteratively. A linear approximation for the solution is used as an initial guess, and Newton’s method is used to iteratively solve the system until a user-specified convergence criterion is met. The algorithm has been used for a number of wing design studies including the evaluation of propeller/wing interactions18 and the prediction of lift and induced drag in ground effect19. The method is generally accepted to be accurate for wings with aspect ratios greater than about four 10,15. Prandtl’s classical lifting-line theory and the modern numerical lifting-line algorithm assume that the bound spanwise vorticity at each spanwise location is located at the local airfoil aerodynamic center. Consistent with the prediction from thin airfoil theory that the aerodynamic center is at the quarter-chord20, MachUp assumes that the bound vortex follows the quarter-chord of the finite wing. Because the aerodynamic center shifts aft at Mach numbers greater than about 0.3, MachUp can currently only be used for incompressible analysis. B. Code Structure MachUp is written in modern object-oriented Fortran, which allows for significant flexibility in geometry specification while maintaining the speed inherent in Fortran array operations. The code is organized into modules which contain variable type definitions for aircraft properties. For example, the system of lifting surfaces is defined by an airplane object that contains an array of wing objects, each representing a single wing. Each wing object contains an array of section objects, each representing a single spanwise location along the wing. Each section object contains local geometric and aerodynamic information and has access to a user-defined library of airfoils from which aerodynamic properties can be obtained. The tool allows for any number of lifting surfaces to be specified with arbitrary spans and nonlinear distributions of chord, sweep, twist, and dihedral. Each of these geometrical properties are specified through input files, along with operating conditions and reference geometry information. Control surfaces can also be specified along portions of a lifting surface to evaluate control authority, trim settings, and control derivatives. C. Notable Features Several features have been developed in MachUp, which allow the tool to easily be used for a wide range of wing design, analysis, and optimization purposes. Each of these features is briefly explained here. 1. Geometry Definition Simple and complex geometries can be easily specified in MachUp. For example, simple tapered and swept wings with linear washout and constant dihedral are specified in the input file by defining a root chord, tip chord, quarterchord sweep, root twist, tip twist, and dihedral angle. This type of geometry definition is sufficient for many common wing types. More complex geometries are specified with input tables. For example, a wing with a variable chord distribution can be specified with a data table that contains the spanwise location in the first column and the chord length in the second column. This data is linearly interpolated between the specified points to create the full wing geometry. Tabulated data can be used to specify chord, sweep, twist, and dihedral distributions. These input options allow very complex geometries to be specified very easily. For example, Fig. 1 shows a wing with an aspect ratio of 8; a taper ratio of 0.5; zero washout; linear sweep of 0 deg at the centerline and 45 deg at the tips; and linear dihedral
*
https://github.com/usuaero/MachUp 3 American Institute of Aeronautics and Astronautics
Figure 1. Complex nonlinear wing geometry with an aspect ratio of 8, taper ratio of 0.5, zero washout, and linearly varying sweep and dihedral. of 0 deg at the centerline, 10 deg at 80% span, and 80 deg at the tip. This wing was generated using only two input tables shown in Tables 1 and 2. Wings can be connected to the root or tip of a previously defined wing, which simplifies the process of specifying the geometric locations of multiple-lifting-surface structures. A stereolithography (STL) file can be output which allows the geometry to be read into computer-aided design (CAD) software for further analysis, or sent to a 3D printer for rapid prototyping. Table 1. Sweep definition for wing shown in Fig. 1. Normalized Semispan Location Sweep (deg) 0.0 0.0 1.0 45.0 Table 2. Dihedral definition for wing shown in Fig. 1. Normalized Semispan Location Dihedral (deg) 0.0 0.0 0.8 10.0 1.0 80.0 2. Viscous Effects Classical lifting-line theory and the modern numerical algorithm are both rooted in inviscid theory. However, Reynolds number and viscous effects can be included through the use of two-dimensional nonlinear airfoil section data. The airfoil section data are used in the numerical algorithm to evaluate lift as a function of angle of attack. This is used in the nonlinear system of equations to iteratively evaluate the bound vorticity at each spanwise location. Once the bound vorticity is known, the local angle of attack at each spanwise location can be computed. This angle of attack is then used to evaluate the local parasitic drag from the user-specified airfoil properties according to the relation
~ ~ ~ C DP = C D 0 + C D1C L + C D 2 C L2
(1)
The individual section parasitic drag components are summed about the aircraft center of gravity to evaluate global viscous forces and moments21. Airfoil properties can be specified one of two ways. 1) the user can specify linear properties for the airfoil lift slope, moment slope, zero-lift angle of attack, and zero-lift moment coefficient, as well as parabolic coefficients for the parasitic drag, or 2) the user can specify a lookup table for lift, pitching moment, and parasitic drag as a function of angle of attack. These airfoil properties can be stored in an airfoil library that is referenced from the MachUp input file.
4 American Institute of Aeronautics and Astronautics
3. Multi-Airfoil It is often beneficial to use different airfoils along the wingspan. MachUp is designed to allow an arbitrary number of airfoils to be specified along any wing section. For example, a NACA 2412 could be used at the wing root, a NACA 4412 could be used at the wing mid-span, and a NACA 0012 could be used at the wing tip. MachUp linearly interpolates between the bounding airfoils at internal spanwise locations. This allows the user great flexibility in aerodynamic design, and is very useful for wing optimization. 4. Ground Effect Within the limits of potential flow, a ground plane can be treated as a symmetry plane or a slip wall14. At each point along a symmetry plane there can be no component of normal flow. Thus the presence of the ground can be modeled by creating a mirror image of the system of lifting surfaces reflected across the ground plane. MachUp models the aerodynamics in ground effect through this reflection method, and has been used to evaluate the aerodynamics of wings of varying planform and aspect ratio19. Use of a ground plane is set by a flag in the input file specifying the aircraft height above ground. The mirrored aircraft is then automatically generated by MachUp for ground effect simulations. 5. Built-In Functions Several useful functions have been built into MachUp, allowing the tool to be used to quickly evaluate airframe performance characteristics. For example, a desired lift coefficient can be specified, and MachUp will iterate on the angle of attack until the specified lift coefficient is obtained. If the aircraft has a control surface, a trim function can be called to evaluate the pitch trim setting for the control surface. Stability, damping, and control derivatives can be evaluated, and the location of the aircraft aerodynamic center can be automatically computed. Lift, viscous drag, and other aerodynamic and geometric distribution information as a function of spanwise location can be output for further analysis. Finally, reports can be created that summarize information and make interfacing to other tools, including optimization tools, extremely easy. These and other built-in functions provide powerful routines to automate the analysis. 6. Input and Output MachUp uses JavaScript Object Notation (JSON) data structures for most input and output files. This format has been implemented because it is a widely used and actively supported format for storing and passing information between software tools. For example, this format is widely used for web development, and can easily interface to other common engineering tools such as Matlab and Python. Furthermore, JSON object files have the additional advantage of being human readable and can be edited in a simple text editor. The JSON data structures are handled through the use of an open-source JSON parsing tool written by Jacob Williams and available on Github *. Figure 2 shows a sample input file that contains a single wing of aspect ratio 8, taper ratio of 0.5, zero sweep, zero dihedral, and zero washout, along with global aircraft definitions and sample run commands.
{
{ "plane": { "name": "MyAirplane", "CGx": 0, "CGy": 0, "CGz": 0 }, "reference": { "area": 8, "longitudinal_length": 1, “lateral_length": 8 }, "airfoil_DB": "../AirfoilDatabase", "wings": { "Wing_1": { "name": "MainWing", "ID": 1, "is_main": 1, "side": "both", "connect": { "ID": 0, "location": "tip", "dx": 0, "dy": 0, "dz": 0, "yoffset": 0.0 }, "span": 4, "sweep": 0, "dihedral": 0, "mounting_angle": 0, "washout": 0, "root_chord": 1, "tip_chord": 0.5, "airfoils": {"NACA_0012"}, "grid": 100 } }, "condition": { "alpha": 0, "beta": 0 }, "run": { "forces": "", "derivatives":"", "stl" : "" }, "solver": { "type": "nonlinear", "convergence": 1.0e-12, "relaxation": 0.9 } }
Figure 2. Sample input file in JSON format for creating a single wing with an aspect ratio of 8, a taper ratio of 0.5, zero sweep, zero dihedral, and zero washout.
*
https://github.com/jacobwilliams/json-fortran 5 American Institute of Aeronautics and Astronautics
D. Accuracy and Order of Convergence To evaluate the accuracy of the numerical lifting-line algorithm, it is convenient to consider a case for which there is a known closed-form analytical solution. Here we consider the case of an elliptic wing with a straight quarter chord. The chord distribution of an elliptic wing is
c( z ) =
4b
πR A
1 − ( 2 z / b) 2
(2)
where z is the spanwise coordinate measured from the root of the wing. The lift coefficient of a finite wing is C L = C L ,α (α − α L 0 )
(3)
~ where the finite wing lift slope, C L,α , of an elliptic wing is related to the airfoil section lift slope, C L,α according to
C L,α =
~ C L,α
~ 1 + C L,α (πR A )
(4)
The induced drag of an untwisted elliptic wing is C Di =
C L2 πR A
(5)
Here we consider an elliptic wing of aspect ratio 8 with a thin symmetric airfoil having a section lift slope of 2π. Using this in Eqs. (3)-(5) gives the aerodynamic properties
CL =
8π 8π 8π 2 16π , C Di = α , C L,α = α , C Di ,α = α 5 5 25 25
(6)
To evaluate the accuracy of the numerical lifting-line algorithm, MachUp was used to solve for the lift and induced drag using between 10 and 500 nodes per semispan on an elliptic wing. Figure 3 shows an example of an elliptic planform with 40 nodes per semispan. Note that MachUp uses cosine clustering to distribute nodes along each semispan. Figure 4 shows the lift and induced drag coefficients predicted by MachUp for this wing at 5 degrees angle of attack as a function of the number of nodes per semispan used for the computation. Figure 5 shows the percent error between the MachUp solution and the closed-form analytical solutions given in Eq. (6) for both lift and induced drag. All lift and induced drag results from MachUp with at least 10 nodes per semispan are within 1% of the analytical solution, and results produced using more than 100 nodes per semispan are within 0.03% of the analytical solution. Thus a general rule of thumb to obtain sufficiently accurate solutions from MachUp is to use between 100 and 200 nodes per semispan. The order of convergence of the numerical method can be estimated by considering how the solution changes as the number of nodes is increased. Figure 6 shows the absolute value of the percent difference between the lift and drag computed for each case relative to that computed using 500 nodes per semispan. Plotting on a log-log plot reveals a second-order convergence rate for the algorithm.
Figure 3. An elliptic planform with an aspect ratio of 8 and 40 nodes per semispan. 6 American Institute of Aeronautics and Astronautics
-03
-01
7.66x10
4.39x10
-03
7.64x10
CL
CDi
4.38x10-01
-03
7.62x10
4.37x10-01 7.60x10-03
Eq. (6) MachUp 4.36x10-01
50
Nodes per Semispan
100 150 200
Eq. (6) MachUp
7.58x10-03
50
Nodes per Semispan
100 150 200
(a) (b) Figure 4. (a) Lift and (b) drag coefficients for an elliptic wing of aspect ratio 8 predicted by MachUp as a function of nodes per semispan, compared to the closed-form solution given by Eq. (6). 0
Percent Error
-0.2
-0.4
-0.6
-0.8
CL CDi
-1
50
Nodes per Semispan
150 200
100
Figure 5. Percent error in MachUp calculations vs. Eq. (6). 0
Percent Difference
10
10-1
10-2 CL CDi 10-3
0.01
(Nodes per Semispan)-1
0.1
Figure 6. Percent difference in MachUp results for various node densities vs. 500 nodes per semispan. 7 American Institute of Aeronautics and Astronautics
0.0
0.0
-0.1
-0.2
Percent Error in CD,α
Percent Error in CL,α
E. Gradient Calculations using Automatic Differentiation Dual Number Automatic Differentiation (DNAD) is an open-source implementation of forward-mode AD in Fortran22,23. Details on the theory and mathematics behind forward-mode AD can be found in Griewank and Walther24, and is implemented in DNAD through the use of operator overloading and derived data types. The DNAD module consists of a derived data type containing the variable value and a gradient vector, a set of functions that define appropriate derivative calculations to perform for each intrinsic operator available, and a set of interfaces defining the relationships between these functions and intrinsic Fortran operators. Previous work by the authors produced a modified version of the DNAD module that has additional intrinsic Fortran operators that were not included in the original offering, implicit precision declarations so that precision can be controlled at compile-time through compiler options, and a precompiler macro that allows the number of design variables (and therefore the length of the gradient vector in the derived data type) to be set without the need to modify source code. In order to facilitate accurate and efficient gradient calculations within MachUp, this modified DNAD module has been integrated into the MachUp source code. Because gradient calculations can be computationally expensive, all modifications to the MachUp source code for DNAD integration were wrapped within precompiler macros. This allows a single code base to be maintained for MachUp from which both normal and AD versions of MachUp can be generated based on arguments to the compiler. To the authors’ knowledge, this is the first time a single code base has been successfully used to generate both normal and AD versions of a practical analysis tool. The DNAD module is activated within the source code by including the optional argument “-ndv=” when invoking the build script, where “” is the number of design variables for which derivatives will be calculated. Excluding this optional argument when invoking the build script will default to a standard MachUp executable without DNAD capabilities. An elliptic wing was again used to evaluate the accuracy of derivative calculations from the DNAD module. Derivatives of lift and drag with respect to angle of attack were evaluated using three methods: the DNAD module, finite difference (FD) approximations, and the analytical solutions from Eq. (6). Results are shown in Fig. 7 as percent error compared to the analytical solution. Note that the FD results converge to the DNAD results as the perturbation size (∆𝛼𝛼) is reduced. Using a perturbation size of ∆α = 0.001° (not shown) for this analysis produced FD results consistent with DNAD results to machine precision. However, the appropriate perturbation size is not expected to be constant between analyses or for derivatives with respect to other design variables and must be determined case-bycase. Using too large of a perturbation size will result in excessive truncation error, while using too small of a perturbation size will result in subtractive cancellation error. The absence of this perturbation size represents a significant advantage to using AD methods over FD methods for gradient calculations.
-0.2 -0.3 DNAD FD (∆α=1°) FD (∆α=5°) FD (∆α=10°)
-0.4 -0.5 -0.6
10
Nodes per Semispan
-0.4 -0.6 DNAD FD (∆α=1°) FD (∆α=5°) FD (∆α=10°)
-0.8 -1.0
100
-1.2
10
Nodes per Semispan
100
(a) (b) Figure 7. Derivatives of (a) lift and (b) drag with respect to angle of attack as a function of grid size.
8 American Institute of Aeronautics and Astronautics
Because of the additional calculations being performed to compute gradients, enabling the DNAD module within MachUp results in increased execution time for a given analysis. This increase in execution time is dependent on the number of design variables specified when compiling MachUp. Figure 8 shows the CPU time of a MachUp analysis using DNAD for gradient calculations as a function of the number of design variables in the analysis. Results are normalized by the time required to run this simulation in a standard MachUp executable without DNAD integration. Also shown are normalized CPU times required for computing gradients using first-order and second-order finite differencing methods without DNAD integration. It is clear that DNAD holds a strong advantage over the finite difference approximations in regard to required CPU time, especially as the number of design variables increases. The simplicity of the dual number data type implemented in the DNAD module allows variable sensitivities to be requested through the JSON input file and written to the JSON output file. Any floating-point variable specified within the input file is a candidate for use as a design variable. In addition, any floating-point variable written to the output file will be accompanied by its first partial derivatives with respect to each design variable and is therefore a candidate for use in an optimization cost function and any constraints.
III. Optix: A Parallel-Capable Optimization Tool Optix is an open-source, gradient-based optimization tool available on Github * for solving nonlinear optimization problems. It is written in Python, and has the capability of solving a wide range of nonlinear optimization problems. It also offers some unique features that set it apart from similar optimization frameworks. The following sections outline some of the major aspects of Optix. Optix was written in Python specifically to take advantage of the flexibility of a scriptable language. It is simple to interface with and can easily be customized and extended to solve unique optimization problems. Optix also inherits the cross-platform characteristics of Python, meaning it can be run on any machine where Python is available, and any combination of software can be executed within the objective function. This allows an objective function, which is typically the most computationally expensive part of an optimization analysis, to be written in a high-performance language such as Fortran or C++. A. Optimization Method Optix uses the well-known Broyden25, Fletcher26, Goldfarb27, and Shanno28 (BFGS) method to approximate the Hessian matrix of the objective function. The Hessian matrix, along with the local gradient of the objective function, are then used to calculate a search direction. A line search is then performed to find the local minimum in the search direction. The minimum is used as the next design point in the BFGS algorithm, which updates the Hessian matrix and local gradient and the process repeats.
Normalized CPU Time
20
DNAD FD (1st-order) FD (2nd-order)
15
10
5
0
0
1
2
3
4
5
6
7
Number of Design Variables
8
9
10
Figure 8. Normalized CPU time for MachUp using FD and DNAD. *
https://github.com/usuaero/Optix 9 American Institute of Aeronautics and Astronautics
At the beginning of this process, the Hessian matrix is initialized to the identity matrix so that the first line search proceeds in the direction of steepest descent. With each iteration, the Hessian matrix is updated using information from the new design point and all previous iterations. This process repeats until the change in the objective function between iterations falls below a user-specified threshold, at which point the Hessian matrix is reset to the identity matrix. The entire process is then repeated using the last minimum as the initial design point. The process is complete when the first iteration (where the line search is conducted in the direction of steepest descent) produces a change in the objective function smaller than the user-specified threshold. The design point and corresponding value of the objective function are then returned to the user, and Optix terminates. B. Code Structure Optix is composed of two object classes and several utility functions. The first object class handles execution of the user-specified objective function. The objective function is a Python function provided by the user that must accept as arguments the current design point and a case identifier, and return the value of the objective function evaluated at the current design point. A second function can be provided to evaluate gradients of the objective function, but is not required. This function, if specified, must accept the same arguments as the objective function, but must return the gradient of the objective function evaluated at the current design point in addition to the value itself. If this function is not specified, Optix uses a second-order central differencing algorithm to approximate the gradient of the objective function. The step size used within this FD algorithm can be specified by the user. The second object class contained within the Optix source code is used for controlling the optimizer. The number of design variables, their names, and their initial values are specified through this class. In addition, line search settings such as the starting step size, stopping criterion, and whether to use the linear or quadratic line search algorithm are set here. A helper function is also provided through which the user can specify a JSON file from which to load these optimizer settings. The only utility function that is user-callable is the optimize function. This function accepts as arguments one instance each of the two object classes described above. Once invoked, the entire optimization process is run to completion. The optimize function relies on the Python NumPy package * for efficient matrix computations. C. Notable Features There are two features that make Optix uniquely suited to solving a wide variety of gradient-based optimization problems efficiently. These features are briefly explained here. 1. Parallel Execution of Independent Function Evaluations Optix uses the Python multiprocessing module to execute independent evaluations of the objective function simultaneously. For example, each function evaluation within the line search is independent of all other line search evaluations, so the entire line search can be evaluated at the cost of only a single function evaluation (provided enough computing resources are available). In addition, if the built-in second-order central differencing function is used to approximate gradients of the objective function, these function evaluations can also be executed in parallel. One gradient evaluation using second-order central differencing requires 2n + 1 objective function evaluations, where n is the number of design variables. Therefore, executing these evaluations in parallel can significantly reduce the total optimization time when large numbers of design variables are involved. 2. Linear and Quadratic Line Searching As mentioned previously, Optix relies on a line search to locate the minimum point in a search direction. Optix provides two different algorithms for conducting this line search – a linear algorithm and a quadratic algorithm. The linear line searching algorithm evaluates the objective function at multiple locations in the search direction until the value of the objective function begins to increase, at which point it fits a parabola through the design point corresponding to the minimum objective function evaluation and its two closest neighbors. The next design point is placed at the parabola’s vertex. The quadratic line searching algorithm evaluates the objective function at a userspecified number of points along the search direction, and then uses a least-squares algorithm to fit a quadratic function to the data points. The minimum of the quadratic function is then used as the next design point in the optimization process. For convex problems, the quadratic line searching algorithm can significantly reduce the total optimization time as compared to other line searching methods. For non-convex problems, the linear line searching algorithm provides a more reliable solution. *
https://www.numpy.org 10 American Institute of Aeronautics and Astronautics
IV. Results Optix and MachUp have been used to solve several wing optimization problems to which closed-form solutions are known. Results from these simulations are presented and discussed within the following subsections. Each simulation begins with the same base model, namely a spanwise-symmetric rectangular wing with an aspect ratio of R A = 8 and no geometric or aerodynamic washout, operating at a lift coefficient of C L = 0.5 . Control points (locations where the optimizer is allowed to vary geometric and aerodynamic properties of the wing) are spaced uniformily along one semispan of the wing. The airfoil properties used in these analyses are shown in Table 3 and correspond to the NACA 4-digit X410 family of airfoils with maximum cambers ranging from -2% to 8% of the chord length. The optimization problems included below are compared to analytical solutions that do not account for viscosity; therefore, the the last three columns of Table 3 are not used. Camber
Table 3. Aerodynamic properties for the family of airfoils used in this study. C m ,α (rad-1) C mL 0 α L0 (rad) C L,α (rad-1) C D0 C D1
C D2
NACA -2410
0.03678
6.19764
0.05246
0.03258
0.00569
0.00450
0.01040
NACA 0010
0.00000
6.43365
0.00000
0.00000
0.00513
0.00000
0.00984
NACA 2410
-0.03678
6.19764
-0.05246
0.03258
0.00569
-0.00450
0.01040
NACA 4410
-0.07457
6.28807
-0.10446
0.01404
0.00839
-0.01036
0.00969
NACA 6410
-0.11158
6.12955
-0.15481
0.03094
0.01233
-0.01571
0.01040
NACA 8410
-0.14469
6.29908
-0.19912
-0.01202
0.01918
-0.02706
0.01611
A. Optimum Planform Shape for Minimum Induced Drag In 1921, Prandtl10 published analytical results showing that a finite wing with no geometric or aerodynamic washout will produce the minimum amount of induced drag for a given aspect ratio and lift coefficient when the planform shape is elliptical. To solve this problem numerically, the optimizer was allowed to adjust the local chord length at each control point and a linear variation in chord length was used between control points. MachUp was used to evaluate the induced drag coefficient for each planform shape requested by the optimizer. A penalty factor was added to ensure the final solution would have an aspect ratio of 8, effectively making the degrees of freedom ( N ) for this problem one less than the number of control points defined along a semispan. The gradient of the induced drag coefficient with respect to the chord length at each control point along the wingspan was calculated internally within MachUp through the DNAD module. Optix was used to optimize the plaform shape using 1, 2, 5, and 10 degrees of freedom. Results are summarized in Table 4. The case for one degree of freedom corresponds to a traditional tapered wing with a taper ratio of RT = 0.365 . Adding a second degree of freedom reduces the percent difference by a factor of about four, and brings the induced drag to within half a percent of the induced drag produced by an elliptic planform. As the degrees of freedom are increased, the induced drag for the optimized solution converges toward that of an elliptic planform, but at the expense of increasing design complexity and computational cost. Table 4. Result Summary – Optimum Planform Shape for Minimum Induced Drag Degrees of Freedom ( N ) 1
Number of BFGS Optimization Steps 8
Minimum Induced Drag 0.0100689
% Difference from Elliptic Solution 1.220%
2
15
0.0099797
0.327%
5
28
0.0099528
0.057%
10
43
0.0099489
0.018%
Figure 9 compares the final planform design of each optimization simulation to the initial rectangular planform and an elliptic planform of the same aspect ratio. All results do a reasonable job of matching the overall geometry of
11 American Institute of Aeronautics and Astronautics
0.5
x/c
0.0
0.0
0.1
0.2
0.3
z/b
0.4
0.5
-0.5
-1.0
-1.5
Elliptic (Eq. 2)
N=1
N=5
Rectangular
N=2
N=10
Figure 9. Comparison of Elliptic, Rectangular, and Optimized Planform Shapes. the elliptic planform, with the optimized solution converging to the elliptic planform as the number of degrees of freedom is increased. The maximum deviation from the elliptic planform is at the wing tip, where the curvature is highest but the section lift coefficient is smallest. The section lift coefficient at the root is a maximum and therefore has a larger influence on the total induced drag, so the optimizer tends toward a solution that minimizes the deviation at the root at the expense of a larger deviation at the tip. B. Optimum Geometric Washout for Minimum Induced Drag In 2004, Phillips11 extended Prandtl’s original work to show that the minimum induced drag produced by a wing of elliptic planform with no geometric or aerodynamic washout operating at a particular lift coefficient could also be achieved by a wing of arbitrary planform at the same lift coefficient by prescribing the twist and camber as a function of wingspan. Phillips presented an analytical solution to the optimum washout distribution for a rectangular wing with geometric and/or aerodynamic washout. The optimum washout distribution as a function of spanwise location is given by
(α − α L 0 )root − (α ( z ) − α L 0 ( z ) ) = Ω opt 1 −
1 − (2 z / b) 2
(7)
where the total washout is related to the lift coefficient according to Ω opt =
4C L ~ πC L ,α
(8)
For a rectangular wing with no aerodynamic washout, α L 0 ( z ) = (α L 0 ) root and Eq. (7) reduces to
α root − α ( z ) = Ω opt 1 − 1 − (2 z / b) 2
(9)
Note that Eq. (9) specifies only a difference between the angles of attack at the spanwise location and the root. Therefore, it is necessary to specify a fixed angle of attack at some spanwise location in order to fully constrain the solution. In this analysis, we set the twist at the root to be α root = 0 rad. Here we present optimization analyses that solve for the optimum twist distribution of a rectangular wing with no aerodynamic washout, again with the goal of minimizing induced drag. The optimization solutions begin with a 12 American Institute of Aeronautics and Astronautics
rectangular wing of uniform, symmetric cross-section, an aspect ratio of 8, and no geometric or aerodynamic washout. The airfoil data corresponding to the NACA 0010 from Table 4 were applied uniformily along the wingspan. The lift coefficient is constrained to 0.5. The control point at the root is constrained to 0 degrees of twist, so the degrees of freedom are again one less than the number of control points along a semispan. Optix was used to optimize the twist distribution using 1, 2, 5, and 10 degrees of freedom. Results are summarized in Table 5. The case of linear twist ( N = 1 ) does better at reducing induced drag than the case of linear taper discussed previously, and at half the computational cost. Again we see continued reduction in induced drag and increase in computational cost as the number of degrees of freedom is increased, with the induced drag approaching that of an elliptic lift distribution with increasing N . Note that fewer iterations are needed for optimizing the twist distribution than were needed for optimizing the chord distribution for equivalent degrees of freedom. This is due to the inclusion of a penalty constraint to maintain the appropriate aspect ratio when chord was used as the design parameter. Table 5. Result Summary – Optimum Twist Distribution for Minimum Induced Drag Degrees of Freedom ( N ) 1
Number of BFGS Optimization Steps 4
Minimum Induced Drag 0.0100334
% Difference from Elliptic Solution 0.866%
2
11
0.0099609
0.138%
5
12
0.0099482
0.010%
10
27
0.0099473
0.001%
Figure 10 compares the twist distribution of each simulation to that prescribed by Eq. (9). Again we see that the optimization solutions converge to the expected solution as the number of degrees of freedom is increased. The largest deviation from the twist distribution prescribed by Eq. (9) is at the wing tip.
6 Eq. (9) N=1 N=2 N=5 N = 10
5
αroot - α (deg)
4
3
2
1
0
0
0.1
0.2
z/b
0.3
0.4
Figure 10. Comparison of Elliptic and Optimized Twist Distributions.
13 American Institute of Aeronautics and Astronautics
0.5
C. Optimum Aerodynamic Washout for Minimum Induced Drag Similar to the previous section, here we present optimization analyses that minimize induced drag by solving for the optimum camber distribution of a rectangular wing with no geometric twist. In this case, α ( z ) = α root and Eq. (7) reduces to
α L 0 ( z ) − (α L 0 )root = Ω opt 1 − 1 − (2 z / b )2
(10)
The amount of camber as a function of wingspan can then be interpolated from the data in Table 3. Similar to the twist distribution in Eq. (9), Eq. (10) specifies only a difference between the zero-lift angles of attack at the spanwise location and the root. Therefore, it is necessary to first specify a fixed zero-lift angle of attack at some spanwise location in order to fully constrain the solution. In this analysis, we use a symmetric airfoil at the wing tip such that (α L 0 )tip = 0 rad. This solution began from the same rectangular wing used in the previous section, but instead of varying degrees of twist at each control point the optimizer was configured to vary the section airfoil definition. The optimizer was allowed to choose from any of the airfoil definitions listed in Table 4. In addition, intermediate airfoils were defined through linear interpolation of the airfoil data. For example, if the optimizer specified an airfoil at a certain control point to have a zero-lift angle of attack of α L 0 = −0.0092 rad, MachUp would interpolate the airfoil characteristics at this location to be approximately 75% NACA 0010 and 25% NACA 2410. MachUp also uses this same linear interpolation to define section airfoil characteristics for spanwise locations between control points. The same uniformily-spaced control points as have been used in previous sections were again used here. In this case, however, the control point at the tip was fixed to a NACA 0010 airfoil section, so the degrees of freedom are again one less than the number of control points along a semispan. Optix was used to optimize the camber distribution using 1, 2, 5, and 10 degrees of freedom. Results are summarized in Table 6. Induced drag results are quite comparable to those presented in Table 5 for optimum twist, but optimizing on camber is more computationally expensive. Table 6. Result Summary – Optimum Camber Distribution for Minimum Induced Drag Degrees of Freedom ( N ) 1
Number of BFGS Optimization Steps 6
Minimum Induced Drag 0.0100476
% Difference from Elliptic Solution 1.010%
2
16
0.0099638
0.167%
5
28
0.0099483
0.012%
10
102
0.0099473
0.001%
Figure 11 compares the camber distribution of each simulation to that prescribed by Eq. (10). The profiles appear nearly identical to those shown in Fig. 10, as indeed would be suggested from a comparison of Eqs. (9) and (10). The slight differences between Figs. 10 and 11, and Tables 5 and 6, are due to the piecewise linear variations in α L 0 and
C L ,α when camber is varied, as opposed to a spanwise linear variation in α and constant C L ,α when twist is varied.
Conclusions A set of numerical analysis tools has been presented that can be used for wing optimization during the initial design phases of an airframe. The aerodynamic tool, called MachUp, is an open-source code based on a modern numerical lifting-line algorithm accurate for wings with aspect ratios greater than 4. This tool has been developed in modern object-oriented Fortran, and can easily interface with other analysis tools through the commonly used JSON data structure. The tool is capable of handling complex nonlinear geometries including nonlinear sweep, dihedral, chord distributions, and twist distributions, as well as multiple airfoil definitions along a wing. Furthermore, it can account for Reynolds number and viscous effects. MachUp has several useful built-in functions including the ability to model ground effect, trim an aircraft in pitch, locate the aerodynamic center, and compute stability, control, and damping derivatives. Furthermore, a common form of automatic differentiation using dual numbers has been incorporated into
14 American Institute of Aeronautics and Astronautics
6 Eq. (10) N=1 N=2 N=5 N = 10
αL0 - (αL0)root (deg)
5
4
3
2
1
0
0
0.1
0.2
z/b
0.3
0.4
0.5
Figure 11. Comparison of Elliptic and Optimized Zero-lift Angle of Attack Distributions. the code, allowing it to calculate gradients of any output value with respect to any input value. This provides an extremely versatile computational tool that can be used for wing optimization. Sample computations from MachUp using 100 nodes per semispan for an elliptic wing of aspect ratio of 8 match closed-form analytical solutions for lift and drag coefficients to within 0.03%. Computational convergence results demonstrate that the method is second order. Additionally, the automatic differentiation results match the analytical results for an elliptic wing of aspect ratio of 8 to within 0.05%. Finally, it is shown that the automatic differentiation method is significantly less computationally expensive than using first- or second-order finite differencing methods to evaluate gradients. An open-source gradient-based optimization tool, called Optix, is also presented. This tool is written in Python and is based on the well-known BFGS optimization method. Optix was developed specifically to take advantage of the automatic differentiation capabilities of MachUp, and leverages parallel processing for independent computations. For example, computations for line searches and/or finite-difference gradients are parallelized, which significantly reduces the computational time required for each optimization step. MachUp and Optix were used to perform three main benchmark optimization studies: 1) optimization of a wing planform to minimize induced drag, 2) optimization of wing geometric twist to minimize induced drag, and 3) optimization of wing aerodynamic twist to minimize induced drag. A straight wing of aspect ratio of 8 at a target lift coefficient of 0.5 was used for each study. Several cases were run for each study, with a varying number of optimization control points along the wing. It was shown that as the number of optimization control points increased, results for the optimum planform, geometric twist, and aerodynamic twist approached those of the optimum closedform solution. Furthermore, it was shown that using linear washout with this wing geometry can produce minimum induced drag within 1% of the elliptic solution at the target lift coefficient. Although this work has only considered optimization of planform, geometric twist, and aerodynamic twist on a straight wing, the tools presented here can be used to evaluate and optimize geometries of multiple interacting lifting surfaces as well as wings with more complex geometries. Examples of interacting lifting surfaces include the interaction of main wings and stabilizers, wings in formation, wings with winglets, and wings in ground effect. Due to modern composite manufacturing methods, very complex wing shapes can be designed and manufactured. The tools presented in this work are capable of considering nonlinear sweep and dihedral, and can be used for optimization of nonlinear geometries. The optimization of interacting lifting surfaces as well as complex geometries will be considered in future work.
15 American Institute of Aeronautics and Astronautics
Acknowledgments This work was partially performed during a summer faculty fellowship sponsored by the Air Force Research Laboratory (AFRL). The authors wish to express their appreciation to Dr. James Joo and AFRL for their support. The modified DNAD module referred to in this work was developed under a Department of Energy Nuclear Energy University Program Graduate Fellowship.
References Baysal, O. and Eleshaky, M., “Aerodynamic Design Optimization Using Sensitivity Analysis and Computational Fluid Dynamics”, AIAA Journal, Vol. 30, No. 3, Mar. 1992, pp 718-725. 2 Samareh, J., “Aerodynamic Shape Optimization Based on Free-form Deformation,” 10th AIAA/ISSMO Multidisciplinary Analysis and Optimization Conference, AIAA Paper 2004-4630, Albany, NY, Aug. 30-Sept. 1, 2004. 3 Reuther, J., Jameson, A., Alonso, J., Rimlinger, M., and Saunders, D., “Constrained Multipoint Aerodynamic Shape Optimization Using an Adjoint Formulation and Parallel Computers, Part 2,” J. Aircraft, Vol. 36, No. 1, 1999, pp. 61-74. 4 Lyu, Z., Kenway, G., and Martins, J., “Aerodynamic Shape Optimization Investigations of the Common Research Model Wing Benchmark,” AIAA Journal, Vol. 53, No. 4, Apr. 2015, pp. 968-985. 5 Joo, J., Marks, C., Zientarski, L., and Culler, A., “Variable Camber Compliant Wing – Design”, 23rd AIAA/AHS Adaptive Structures Conference, AIAA SciTech, AIAA Paper 2015-1050, Jan. 2015. 6 Su, W., Swei, S., and Zhu, G., “Optimum Wing Shape of Highly Flexible Morphing Aircraft for Improved Flight Performance,” J. Aircraft, Vol. 53, No. 5, Sept.-Oct. 2016, pp. 1305-1316. 7 Barbarino, S., Bilgen, O., Ajaj, R., Friswell, M., and Inman, D., “A Review of Morphing Aircraft”, Journal of Intelligent Material Systems and Structures, Vol. 22, June 2011, pp. 823-877. 8 Lanchester, F., Aerodynamics: constituting the first volume of a complete work on aerial flight, London, A. Constable, 1907. 9 Prandtl, L., “Tragflügel Theorie,” Nachricten von der Gesellschaft der Wissenschaften zu Göttingen, Ges-chäeftliche Mitteilungen, Klasse, Germany, 1918, pp. 451–477. 10 Prandtl, L., “Applications of Modern Hydrodynamics to Aeronautics,” NACA TR-116, June 1921. 11 Phillips, W., “Lifting-Line Analysis for Twisted Wings and Washout-Optimized Wings,” J. Aircraft, Vol. 41, No. 1, Jan.Feb. 2004, pp. 128-136. 12 Phillips, W., Alley, N., and Goodrich, W., “Lifting-Line Analysis of Roll Control and Variable Twist,” J. Aircraft, Vol. 41, No. 5, Sept.-Oct. 2004, pp. 1169-1176. 13 Phillips, W. and Alley, N., “Predicting Maximum Lift Coefficient for Twisted Wings Using Lifting-Line Theory,” J. Aircraft, Vol. 44, No. 3, May-June 2007, pp. 898-910. 14 Katz, J., and Plotkin, A., “Three-Dimensional Numerical Solutions,” Low-Speed Aerodynamics, 2nd. Ed., Cambridge, New York, 2001, pp. 331 – 368. 15 Phillips, W. and Snyder, D., “Modern Adaptation of Prandtl’s Classic Lifting-Line Theory,” J. Aircraft, Vol. 37, No. 4, Jul. 2000, pp. 662-670. 16 McCormick, B., “The Lifting Line Model,” Aerodynamics, Aeronautics, and Flight Mechanics, 2nd Ed., Wiley, NY, 1995, pp. 112-119. 17 Anderson, J., Corda, S., and Van Wie, D., “Numerical Lifting-Line Theory Applied to Drooped Leading-Edge Wings Below and Above Stall,” J. Aircraft, Vol. 17, No. 12, 1980, pp. 898-904 18 Hunsaker, D. and Snyder, D., “A Lifting-Line Approach to Estimating Propeller / Wing Interactions,” 24th Applied Aerodynamics Conference, San Fransisco, CA, Jun. 5-8, 2006, AIAA Paper 2006-3466. 19 Phillips, W. and Hunsaker, D., “Lifting-Line Predictions for Induced Drag and Lift in Ground Effect,” J. Aircraft, Vol. 50, No. 4, Jul.-Aug. 2013, pp. 1226-1233. 20 Abbott, I. and Von Doenhoff, A., “Theory of Thin Wing Sections,” Theory of Wing Sections, Dover, NY, 1959, pp. 64-79. 21 Phillips, W., “The Numerical Lifting-Line Method”, Mechanics of Flight, 2nd Ed., Wiley, Hoboken, NJ, 2010, pp. 96-107. 22 Yu, W. and Blair, M., “DNAD: A Simple Tool for Automatic Differentiaton of Fortran Codes Using Dual Numbers”, Proc. th 35 Annual Dayton-Cincinnati Aerospace Science Symposium, Dayton, OH, 2010. 23 Spall, R. and Yu, W., “Imbedded Dual-Number Automatic Differentiation for Computational Fluid Dynamics Sensitivity Analysis”, J. Fluids Eng., Vol. 135, 014501, 2013. 24 Griewank, A., and Walther, A., Evaluating Derivatives: Principles and Techniques of Algorithmic Differentiation, 2nd Ed., Society of Industrial and Applied Mathematics, 2008. 25 Broyden, C., “The Convergence of a Class of Double-Rank Minimization Algorithms,” Journal of the Institute of Mathematics and Its Applications, Vol. 6, 1970, pp. 76-90. 26 Fletcher, R., “A New Approach to Variable Metric Algorithms,” Computer Journal, Vol. 13, No. 3, 1970, pp. 317-322. 27 Goldfarb, D., “A Family of Variable Metric Updates Derived by Variational Means,” Mathematics of Computation, Vol. 24, No. 109, 1970, pp. 23-26. 28 Shanno, D, “Conditioning of Quasi-Newton Methods for Function Minimization,” Mathematics of Computation, Vol. 24, No. 111, 1970, pp. 647-656. 1
16 American Institute of Aeronautics and Astronautics