AeroSandbox

by Peter Sharpe (<pds [at] mit [dot] edu>)

About

AeroSandbox is a Python package for aircraft design optimization, fully-coupled viscous/inviscid 3D aerodynamics, and reverse-mode automatic differentiation for computing gradients of design variables.

The 10-second elevator pitch: In half a second, you can calculate not only the aerodynamic performance of an airplane, but also the sensitivity of aerodynamic performance with respect to an effectively-infinite number of design variables. This can be used to perform gradient-based aircraft design optimization extremely quickly.

Work in progress!

VLM3 Image VLM3 simulation of a glider, aileron deflections of +-30°. Runtime of 0.35 sec on a typical laptop (i7-8750H).

PANEL1 Image PANEL1 simulation of a wing (extruded NACA2412, α=15°, AR=4). Note the strong three-dimensionality of the flow near the tip.

Getting Started

Installation

There are several easy ways to get started with AeroSandbox! (Assuming you already have Python >=3.7 installed, preferably via the Anaconda distribution - if not, do this first.)

  1. (Recommended) Download the latest release here: https://github.com/peterdsharpe/AeroSandbox/releases. Then, run “pip install AeroSandbox” in your command prompt to ensure that all dependencies are satisfied.

  2. If you just want the raw package (and no test cases or examples), install by simply entering “pip install AeroSandbox” into your terminal.

  3. Both of the above options will download the latest official release of AeroSandbox. If you’d rather get a nightly/dev version (which has more features but may be buggy), clone or download directly from the AeroSandbox GitHub page.

There are many example cases you can try out in the /examples/ directory! Specifically, try running “/examples/vlm3_conventional.py”.

Usage

AeroSandbox is designed to have extremely intuitive, high-level, and human-readable code. You (yes, you!) can probably learn to analyze a simple airplane and visualize airflow around it within 5 minutes of downloading AeroSandbox. For example, here is all the code that is needed to design a glider, analyze its aerodynamics in flight, and visualize it (found in “/examples/vlm3_conventional.py”):

from aerosandbox import *

glider = Airplane(
    name="Peter's Glider",
    xyz_ref=[0, 0, 0], # CG location
    wings=[
        Wing(
            name="Main Wing",
            xyz_le=[0, 0, 0], # Coordinates of the wing's leading edge
            symmetric=True,
            xsecs=[ # The wing's cross ("X") sections
                WingXSec(  # Root
                    xyz_le=[0, 0, 0], # Coordinates of the XSec's leading edge, relative to the wing's leading edge.
                    chord=0.18,
                    twist=2, # degrees
                    airfoil=Airfoil(name="naca4412"),
                    control_surface_type='symmetric',  # Flap # Control surfaces are applied between a given XSec and the next one.
                    control_surface_deflection=0, # degrees
                    control_surface_hinge_point=0.75 # as chord fraction
                ),
                WingXSec(  # Mid
                    xyz_le=[0.01, 0.5, 0],
                    chord=0.16,
                    twist=0,
                    airfoil=Airfoil(name="naca4412"),
                    control_surface_type='asymmetric',  # Aileron
                    control_surface_deflection=0,
                    control_surface_hinge_point=0.75
                ),
                WingXSec(  # Tip
                    xyz_le=[0.08, 1, 0.1],
                    chord=0.08,
                    twist=-2,
                    airfoil=Airfoil(name="naca4412"),
                )
            ]
        ),
        Wing(
            name="Horizontal Stabilizer",
            xyz_le=[0.6, 0, 0.1],
            symmetric=True,
            xsecs=[
                WingXSec(  # root
                    xyz_le=[0, 0, 0],
                    chord=0.1,
                    twist=-10,
                    airfoil=Airfoil(name="naca0012"),
                    control_surface_type='symmetric',  # Elevator
                    control_surface_deflection=0,
                    control_surface_hinge_point=0.75
                ),
                WingXSec(  # tip
                    xyz_le=[0.02, 0.17, 0],
                    chord=0.08,
                    twist=-10,
                    airfoil=Airfoil(name="naca0012")
                )
            ]
        ),
        Wing(
            name="Vertical Stabilizer",
            xyz_le=[0.6, 0, 0.15],
            symmetric=False,
            xsecs=[
                WingXSec(
                    xyz_le=[0, 0, 0],
                    chord=0.1,
                    twist=0,
                    airfoil=Airfoil(name="naca0012"),
                    control_surface_type='symmetric',  # Rudder
                    control_surface_deflection=0,
                    control_surface_hinge_point=0.75
                ),
                WingXSec(
                    xyz_le=[0.04, 0, 0.15],
                    chord=0.06,
                    twist=0,
                    airfoil=Airfoil(name="naca0012")
                )
            ]
        )
    ]
)

aero_problem = vlm3( # Analysis type: Vortex Lattice Method, version 3
    airplane=glider,
    op_point=OperatingPoint(
        velocity=10,
        alpha=5,
        beta=0,
        p=0,
        q=0,
        r=0,
    ),
)

aero_problem.run() # Runs and prints results to console
aero_problem.draw() # Creates an interactive display of the surface pressures and streamlines

The best part is that by adding just a few more lines of code, you can not only get the performance at a specified design point, but also the derivatives of any performance variable with respect to any design variable. Thanks to reverse-mode automatic differentiation, this process only requires the time of one additional flow solution, regardless of the number of design variables. For an example of this, see “/examples/gradient_test_vlm2.py”.

One final point to note: as we’re all sensible and civilized human beings here, all inputs and outputs to AeroSandbox are expressed in base metric units, or derived units thereof (meters, Newtons, meters per second, kilograms, etc.).

Dependencies

The fastest way to ensure that all dependencies are satisfied is by simply running “pip install AeroSandbox” in your command prompt. However, you can also install dependencies on your own if you’d like. You’ll need the following libraries:

If you installed Python via the Anaconda distribution, you likely have all of these except autograd. (Install this with “pip install autograd” in the command prompt.)

OpenGL is also required for visualization, though this should already be installed on nearly every computer. (No promises if you try to run AeroSandbox on a Raspberry Pi or something!)

Current Features

Purpose

The primary purpose for this repository is to explore existing methods for aerodynamic analysis and develop new methods within a unified code base.

This package eventually seeks to develop the following: An aerodynamics tool that models flow around any general triangulated 3D shape (with non-separated flow) using strongly-coupled viscous/inviscid methods. If successful, this could be orders of magnitude faster than volume-mesh-based CFD while retaining high accuracy (XFoil is a 2D example of this).

This code is made open-source in hopes that the aerospace community can benefit from this work. I’ve benefitted so much from open-source aerospace tools that came before me (XFoil, AVL, QProp, GPKit, XFLR5, OpenVSP, SU2, and SUAVE, just to name a few), so I hope to pay it forward, at least in small part!

Future Goals

In descending order of priority/feasibility:

Usefulness

AeroSandbox attempts to improve over existing conceptual-level aerodynamics tools. The following strengths and weaknesses are identified with existing tools, based purely off the author’s experience:

Strengths:

Weaknesses:

With any luck, the list of strengths and weaknesses here will help to drive AeroSandbox development to retain positive qualities and eliminate negative ones.

Specifically, the following desirable qualities (and associated quantitative metrics) have been identified:

Donating

If you like this software, please consider donating to support development via PayPal at paypal.me/peterdsharpe! I’m a poor grad student, so every dollar you donate helps wean me off my diet of instant coffee and microwaved ramen noodles.

Bugs

Please, please report all bugs by creating a new issue at https://github.com/peterdsharpe/AeroSandbox/issues!

Please note that, while the entirety of the codebase should be cross-platform compatible, AeroSandbox has only been tested on Windows 10 in Python 3.7 via the Anaconda distribution.

Contributing

Thanks for your interest in helping with the development of AeroSandbox - contributions are always so, so welcome! If you have a change you’d like to make, the easiest way to do that is by submitting a pull request.

If you’ve made several additions and would like to be involved in a more long-term capacity, please message me at (pds at mit dot edu) and we can add you as a collaborator here on Github!

Right now, branching is basically nonexistent. This is because there’s currently only one contributor - me. As soon as this changes, we’ll need to implement proper branching.

License

MIT License

Copyright (c) 2019 Peter Sharpe

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.