Aircraft design optimization made fast through modern automatic differentiation

Overview

AeroSandbox ✈️

by Peter Sharpe ( )

Downloads Monthly Downloads Build Status

Overview

AeroSandbox is a Python package for design optimization of engineered systems such as aircraft.

At its heart, AeroSandbox is an optimization suite that combines the ease-of-use of familiar NumPy syntax with the power of modern automatic differentiation.

This automatic differentiation dramatically improves optimization performance on large problems: design problems with tens of thousands of decision variables solve in seconds on a laptop.

AeroSandbox also comes with dozens of end-to-end-differentiable aerospace physics models, allowing you to simultaneously optimize an aircraft's aerodynamics, structures, propulsion, mission trajectory, stability, and more.

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

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

Getting Started

Installation

Use pip install aerosandbox[full] for a complete install.

For a lightweight installation with minimal dependencies, use pip install aerosandbox. All optimization, numerics, and physics models are included this headless install, but some visualization dependencies are not installed.

Tutorials, Examples, and Documentation

To get started, check out the tutorials folder here! All tutorials are viewable in-browser, or you can open them as Jupyter notebooks by cloning this repository.

For a more detailed and theory-heavy introduction to AeroSandbox, please see this thesis.

For a yet-more-detailed developer-level description of AeroSandbox modules, please see the developer README.

You can print documentation and examples for any AeroSandbox object by using the built-in help() function (e.g., help(asb.Airplane)). AeroSandbox code is also documented extensively in the source and contains hundreds of unit test examples, so examining the source code can also be useful.

Usage Details

One final point to note: as we're all sensible and civilized here, all inputs and outputs to AeroSandbox are expressed in base SI units, or derived units thereof (e.g, m, N, kg, m/s, J, Pa).

The only exception to this rule is when units are explicitly noted via variable name suffix. For example:

  • battery_capacity -> Joules
  • battery_capacity_watt_hours -> Watt-hours.

All angles are in radians, except for α and β which are in degrees due to long-standing aerospace convention. (In any case, units are marked on all function docstrings.)

If you wish to use other units, consider using aerosandbox.tools.units to convert easily.

Project Details

Contributing

Please feel free to join the development of AeroSandbox - contributions are always so welcome! If you have a change you'd like to make, the easiest way to do that is by submitting a pull request.

The text file CONTRIBUTING.md has more details for developers and power users.

If you've already made several additions and would like to be involved in a more long-term capacity, please message me! Contact information can be found next to my name near the top of this README.

Donating

If you like this software, please consider donating to support development via PayPal or GitHub Sponsors! I'm a grad student, so every dollar that 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!

Versioning

AeroSandbox loosely uses semantic versioning, which should give you an idea of whether or not you can probably expect backward-compatibility and/or new features from any given update. However, the code is a work in progress and things change rapidly - for the time being, please freeze your version of AeroSandbox for any serious deployments. Commercial users: I'm more than happy to discuss consulting work for active AeroSandbox support if this package proves helpful!

Citation

If you find AeroSandbox useful in a research publication, please cite it using the following BibTeX snippet:

@mastersthesis{aerosandbox,
    title = {AeroSandbox: A Differentiable Framework for Aircraft Design Optimization},
    author = {Sharpe, Peter D.},
    school = {Massachusetts Institute of Technology},
    year = {2021}
}

License

MIT License, full terms here.

Stargazers over time

Stargazers over time

Comments
  • Wing with a winglet

    Wing with a winglet

    Dear @peterdsharpe,

    I am planning on using your library to finish some assignments for an aerodynamical course.

    Do you reckon it would be possible to simulate a wing with a winglet, to compute it's induced drag?

    If the code does not support it yet, would you have an idea on how to do it, so I can implement it, use it and then merge it to your master branch?

    Thank you.

    opened by KikeM 15
  • Regarding Moments Estimation

    Regarding Moments Estimation

    Hi @peterdsharpe, I was validating the code with avl and I found that the moments estimated from this code is way off. Upon looking at vlm3.py I found the formula for moments are incorrect. Could you please check and confirm with it.

    opened by dnsuman25 12
  • AVL Fortran runtime error: End of file

    AVL Fortran runtime error: End of file

    Bug Description

    When running 01 - AVL.ipynb AVL produces the following error:

    
     Reading file: airplane.avl  ...
    
     Configuration: Example Airplane                                            
    
       Building surface: Wing                                    
    At line 629 of file ../src/ainput.f
    Fortran runtime error: End of file
    
    Error termination. Backtrace:
    #0  0x7f67df8dcd5a
    #1  0x7f67df8dd869
    #2  0x7f67df8de54f
    #3  0x7f67dfb21c5b
    #4  0x7f67dfb1b15c
    #5  0x7f67dfb1bdc9
    #6  0x5606701ea350
    #7  0x5606701cb015
    #8  0x5606701cc652
    #9  0x7f67df5870b2
    #10  0x5606701c86bd
    #11  0xffffffffffffffff
    

    Steps to Reproduce

    1. I first installed AVL using steps found here: https://ubuntuforums.org/showthread.php?t=2274062
    2. Added AVL to system path.
    3. Ran ~~01 - Basic Aircraft Geometry.ipynb~~ 01 - AVL.ipynb

    System Information

    • Operating System: Ubuntu 20.04
    • Python Version: 3.9
    • AeroSandbox Verion: 3.3.0
    • AVL Version: 3.32

    Other Information

    I tested AVL on the supergee.avl example and obtained the following plots, so I am confident it is installed correctly. image image

    opened by sr71684 8
  • Unable to Run Example Script

    Unable to Run Example Script

    Bug Description

    Trying to run example script from the readme

    Steps to Reproduce

    Install package (either local or with pypi, tried both) Copy script from readme Run program

    Expected Behavior

    Produce images from readme, instead there is some incompatibility with WingXSec, these are easily fixed.

    However, VLM3 is not found, and the existing example uses only airplane and op_point, while the current implementation also expects an "opti" param. I'm not sure how to incorporate this?

    System Information

    • Operating System: MacOS
    • Python Version: 3.7.0
    • AeroSandbox Verion: 3.0.11

    Other Information

    Thanks! Would love to experiment with this program more, but need a basis to work off. I am trying to do some analysis for different car wing setups (single + dual element). Mostly interested in doing L/D analysis for various airfoil designs.

    Anything to get me in the right direction would be appreciated! Thanks!

    opened by KarlTaht 7
  • Unsteady aero library

    Unsteady aero library

    Hey @antoniosgeme ! This unsteady aero library looks really solid, awesome work!

    I'm creating this PR just as a bookmark to remind us to merge this at some point down the line when you feel it's ready. No rush at all, and thanks for the great contributions!

    -Peter

    opened by peterdsharpe 7
  • ployly module not found error.

    ployly module not found error.

    Hi, i'm quite new to this but have been having problems getting anything to run as any example i run comes up with ModuleNotFoundError: No module named 'plotly'. I have installed various versions of plotly to try and get it to work but it hasn't. Any help would be appreciated.

    Python 3.8.2 (v3.8.2:7b3ab5921f, Feb 24 2020, 17:52:18) [Clang 6.0 (clang-600.0.57)] on darwin Type "help", "copyright", "credits" or "license()" for more information.

    = RESTART: /Users/bradleyrelyea/Desktop/AeroSandbox-1.1.5/casvlm1_conventional_analysis_alpha_sweep.py Traceback (most recent call last): File "/Users/bradleyrelyea/Desktop/AeroSandbox-1.1.5/casvlm1_conventional_analysis_alpha_sweep.py", line 3, in from aerosandbox import * File "/Users/bradleyrelyea/Desktop/AeroSandbox-1.1.5/aerosandbox/init.py", line 1, in from .aerodynamics import * File "/Users/bradleyrelyea/Desktop/AeroSandbox-1.1.5/aerosandbox/aerodynamics/init.py", line 1, in from .casvlm1 import * File "/Users/bradleyrelyea/Desktop/AeroSandbox-1.1.5/aerosandbox/aerodynamics/casvlm1.py", line 1, in from .aerodynamics import * File "/Users/bradleyrelyea/Desktop/AeroSandbox-1.1.5/aerosandbox/aerodynamics/aerodynamics.py", line 1, in from ..geometry import * File "/Users/bradleyrelyea/Desktop/AeroSandbox-1.1.5/aerosandbox/geometry.py", line 1, in import plotly.express as px ModuleNotFoundError: No module named 'plotly'

    opened by BradRR 5
  • Include versioneer.py to have automatic version update in setup.py

    Include versioneer.py to have automatic version update in setup.py

    Is your feature request related to a problem? I have realized that you update manually the version number. This could create problems and mismatches.

    Describe the solution you'd like Include versioneer in the project.

    It is a great tool, since when you haven't explicitly created a new tag, it indicates from the most recent tag you are working from, the number of commits you are ahead and the commit hash. When a clean tag is created, it's caught and correctly set.

    I can implement this feature if you want to.

    opened by KikeM 5
  • Units

    Units

    Nice project. I noticed your note re SI units

    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 (meters, Newtons, kilograms, etc.).

    So may I take it that velocity is in m/s? If I wrote a pull request going through and annotating the docstrings to reflect would that be ok?

    opened by jonititan 5
  • Incorrect Inviscid Airfoil Analysis

    Incorrect Inviscid Airfoil Analysis

    Bug Description

    Running an inviscid analysis on a NACA 0012 airfoil at 0 degrees angle of attack produces non-zero lift coefficient.

    Steps to Reproduce

    from aerosandbox import Airfoil, AirfoilInviscid, OperatingPoint
    a = AirfoilInviscid(
        airfoil=[
            Airfoil("naca0012")
                .repanel(50)
        ],
        op_point=OperatingPoint(
            velocity=1,
            alpha=0,
        )
    )
    print(f"CL: {a.Cl}")
    

    CL: -0.17311351475463538

    Expected Behavior

    CL: 0

    System Information

    • Operating System: Windows 10
    • Python Version: 3.9
    • AeroSandbox Version: 3.0.13
    opened by GodotMisogi 4
  • error when run the file

    error when run the file" \examples\geometry_engine\airfoil\airfoil_xfoil_parallel.py"

    when run the airfoil_xfoil_parallel.py file under spyder envirement, the out put are as follows:

    Running XFoil sweeps on Airfoil sd7032... Traceback (most recent call last):

    File "D:\PROGRAM\python\AeroSandbox\examples\geometry_engine\airfoil\airfoil_xfoil_parallel.py", line 8, in parallel=True

    File "C:\ProgramData\Anaconda3\lib\site-packages\aerosandbox\geometry\airfoil.py", line 987, in get_xfoil_data pool = mp.Pool(mp.cpu_count())

    File "C:\ProgramData\Anaconda3\lib\site-packages\multiprocess\context.py", line 119, in Pool context=self.get_context())

    File "C:\ProgramData\Anaconda3\lib\site-packages\multiprocess\pool.py", line 176, in init self._repopulate_pool()

    File "C:\ProgramData\Anaconda3\lib\site-packages\multiprocess\pool.py", line 241, in _repopulate_pool w.start()

    File "C:\ProgramData\Anaconda3\lib\site-packages\multiprocess\process.py", line 112, in start self._popen = self._Popen(self)

    File "C:\ProgramData\Anaconda3\lib\site-packages\multiprocess\context.py", line 322, in _Popen return Popen(process_obj)

    File "C:\ProgramData\Anaconda3\lib\site-packages\multiprocess\popen_spawn_win32.py", line 46, in init prep_data = spawn.get_preparation_data(process_obj._name)

    File "C:\ProgramData\Anaconda3\lib\site-packages\multiprocess\spawn.py", line 172, in get_preparation_data main_mod_name = getattr(main_module.spec, "name", None)

    AttributeError: module 'main' has no attribute 'spec'

    opened by gkbatchelor 4
  • Infeasible Problem Detected - CasLL1 alpha sweep with custom Cl, Cd and Cm functions

    Infeasible Problem Detected - CasLL1 alpha sweep with custom Cl, Cd and Cm functions

    Hey Peter, I'm trying to use casll1 as a solver instead of optimizing and I'm performing an alpha sweep analysis on a conventional configuration using my own functions for the sectional Cl, Cd and Cm. These functions are just polynomial fits to data obtained from CFD analyses on the airfoil for the Reynolds and Mach number of interest. I'm defining the aircraft and running the alpha sweep the same way presented in the examples with the addition of the custom airfoil functions. However, depending on the operating point, the solver raises an error, which can be read using the cas.Opti().debug method:

    sol
    Opti(Opti {
      instance #0
      #variables: 2 (nx = 144)
      #parameters: 1 (np = 1)
      #constraints: 2 (ng = 144)
      CasADi solver allocated.
      CasADi solver was called: Infeasible_Problem_Detected
    })
    

    I played around with the solver settings and various paneling combinations, however, the issue persisted. Is this an issue with the casll1 solver or does it have to do with CasADI? Is there a way to use the casll1 solver without setting up an optimization environment?

    I am also attaching the code I'm using along with a json file containing all the data required for the aircraft and operating point definition. aircraft_casll1.zip

    Sorry for the long question. I really think what you are building here is great!

    opened by alexandroslessis 4
  • Fuselage Display

    Fuselage Display

    Hi Peter,

    Great work! This is an awesome repo and I know it all takes work. I am curious about fuselages. In the examples, there is a definition for a fuselage (i.e. in the glider definition for example) but in the output display it is not shown? Is there a way to display a fuselage easily in the output? Is the fuselage not included in the aerodynamic analysis?

    Thanks for your help!

    opened by VallesMarinerisExplorer 0
  • ControlSurface not working

    ControlSurface not working

    Hi Peter,

    I have been experimenting with your software and now I wanted to model control surfaces on a wing as well. The picture in the ReadMe shows a VLM simulation with an aileron deflection. I tried to reproduce it but can't make it work, the deflection never shows up. Are control surfaces currently not working because they are under a rework? If so, in what version do they work? I'm using aerosandbox 3.5.9

    Thank you for your time. Best, Max

    opened by max-97 0
  • 3D Panel method

    3D Panel method

    Hi Peter!

    I want to use the panel method to evaluate the pressure field on the lower and the upper surfaces of an extruded NACA profile. The presence of the fuselage can be neglected and the profile considered as a cantilever beam fixed on one end. The resulting pressure field is then integrated to calculate the resultant at specific points.

    Here is an example: {D00B17B5-8332-4707-98AE-E3A926380B2C} png

    My question is, then, how can I use the AeroSandbox package to evaluate the pressure field? I saw this image (https://peterdsharpe.github.io/AeroSandbox/media/images/panel1_naca4412.png) on the package readme.md and I wanted to do the same. The problem is that I looked extensively at the package's code and tutorials and I didn't find any reference to the panel method. Is any sort of panel method implemented in your toolbox? Or I'm completely wrong and you calculated the pressure field in the image using the VLM?

    Keep up with the wonderful work you're doing, the outcomes of AeroSandbox are really interesting.

    opened by enricostragiotti 0
  • VLM for trajectory optimization

    VLM for trajectory optimization

    Hi,

    I am trying to use vortex lattice methods for optimal control problems. I successfully used the AeroBuildup module for optimizing a trajectory, but optimizing the design with this module doesn't make sense because my design isn't to adapted to it. When trying to switch to vortex lattice method with a number of variables > 1 using the following code:

    import aerosandbox.numpy as np
    import aerosandbox as asb
    
    opti = asb.Opti()
    
    n_vars = 2
    alpha = opti.variable(n_vars=n_vars)
    beta = np.linspace(0,2,n_vars)
    
    vlm_results = asb.VortexLatticeMethod(
        airplane=airplane,
        op_point=asb.OperatingPoint(
            atmosphere=asb.Atmosphere(),
            alpha = alpha,
            beta = beta
        )
    ).run()
    
    opti.subject_to([
        vlm_results["F_g"][1] = 100
    ])
    
    sol = opti.solve()
    

    I get this error:

    Traceback (most recent call last):
      File "AeroSandbox/aerosandbox/aerodynamics/aero_3D/vortex_lattice_method.py", line 197, in run
        steady_freestream_velocity = self.op_point.compute_freestream_velocity_geometry_axes()  # Direction the wind is GOING TO, in geometry axes coordinates
      File "AeroSandbox/aerosandbox/performance/operating_point.py", line 235, in compute_freestream_velocity_geometry_axes
        return self.compute_freestream_direction_geometry_axes() * self.velocity
      File "AeroSandbox/aerosandbox/performance/operating_point.py", line 231, in compute_freestream_direction_geometry_axes
        return self.compute_rotation_matrix_wind_to_geometry() @ np.array([-1, 0, 0])
      File "AeroSandbox/aerosandbox/performance/operating_point.py", line 212, in compute_rotation_matrix_wind_to_geometry
        alpha_rotation = np.rotation_matrix_3D(
      File "AeroSandbox/aerosandbox/numpy/rotations.py", line 104, in rotation_matrix_3D
        return array(rot)
      File "/AeroSandbox/aerosandbox/numpy/array.py", line 31, in array
        return _cas.vertcat(
      File "/home/charles/miniconda3/envs/py39/lib/python3.9/site-packages/casadi/casadi.py", line 466, in vertcat
        def vertcat(*args): return _vertcat(args)
      File "/home/charles/miniconda3/envs/py39/lib/python3.9/site-packages/casadi/casadi.py", line 20204, in _vertcat
        return _casadi._vertcat(*args)
    NotImplementedError: Wrong number or type of arguments for overloaded function '_vertcat'.
      Possible prototypes are:
        _vertcat([Sparsity])
        _vertcat([DM])
        _vertcat([SX])
        _vertcat([MX])
      You have: '(([MX|int],DM,[MX|int]))'
    

    I guess this compute_rotation_matrix_wind_to_geometry does not support mixed types. Is it a feature that is planned to be available any time soon ?

    Thank you

    opened by carlitador 4
  • Openvsp geometry conversion to Aerosandbox

    Openvsp geometry conversion to Aerosandbox

    I have been working on geometry conversion from openvsp to aerosandbox and am creating the pull request for discussion.

    I was thinking the workflow could be:

    • create model in openvsp gui tool and save model
    • make openvsp file available to a jupyter notebook running against a docker container.
    • run geometry conversion inside notebook
    • Use aerosandbox for further analysis and use interfaces to xfoil and avl.

    Is there interest in this feature? Is this the correct folder for it?

    Here is a test conversion of an openvsp model: (some small bugs still...)

    Fuselage difference can be seen because openvsp allows curves between xsec while aerosandbox uses lines. If you are drawing your own model you can increase the number of xsec used. This model taken from openvsp hangar is using 2 fuselage to make the main body shape.

    I also use scivm account so other pull request related to docker/jupyter is from me.

    image

    image

    opened by opme 0
Owner
Peter Sharpe
MIT AeroAstro PhD Candidate | Engineering design optimization, aircraft design, and aerodynamics. Hello and welcome to my GitHub! :)
Peter Sharpe
Automatic Differentiation Multipole Moment Molecular Forcefield

Automatic Differentiation Multipole Moment Molecular Forcefield Performance notes On a single gpu, using waterbox_31ang.pdb example from MPIDplugin wh

null 4 Jan 7, 2022
Theano is a Python library that allows you to define, optimize, and evaluate mathematical expressions involving multi-dimensional arrays efficiently. It can use GPUs and perform efficient symbolic differentiation.

============================================================================================================ `MILA will stop developing Theano <https:

null 9.6k Dec 31, 2022
Theano is a Python library that allows you to define, optimize, and evaluate mathematical expressions involving multi-dimensional arrays efficiently. It can use GPUs and perform efficient symbolic differentiation.

============================================================================================================ `MILA will stop developing Theano <https:

null 9.6k Jan 6, 2023
Theano is a Python library that allows you to define, optimize, and evaluate mathematical expressions involving multi-dimensional arrays efficiently. It can use GPUs and perform efficient symbolic differentiation.

============================================================================================================ `MILA will stop developing Theano <https:

null 9.3k Feb 12, 2021
JAX code for the paper "Control-Oriented Model-Based Reinforcement Learning with Implicit Differentiation"

Optimal Model Design for Reinforcement Learning This repository contains JAX code for the paper Control-Oriented Model-Based Reinforcement Learning wi

Evgenii Nikishin 43 Sep 28, 2022
ShapeGlot: Learning Language for Shape Differentiation

ShapeGlot: Learning Language for Shape Differentiation Created by Panos Achlioptas, Judy Fan, Robert X.D. Hawkins, Noah D. Goodman, Leonidas J. Guibas

Panos 32 Dec 23, 2022
Automatic self-diagnosis program (python required)Automatic self-diagnosis program (python required)

auto-self-checker 자동으로 자가진단 해주는 프로그램(python 필요) 중요 이 프로그램이 실행될때에는 절대로 마우스포인터를 움직이거나 키보드를 건드리면 안된다(화면인식, 마우스포인터로 직접 클릭) 사용법 프로그램을 구동할 폴더 내의 cmd창에서 pip

null 1 Dec 30, 2021
HyperaPy: An automatic hyperparameter optimization framework ⚡🚀

hyperpy HyperPy: An automatic hyperparameter optimization framework Description HyperPy: Library for automatic hyperparameter optimization. Build on t

Sergio Mora 7 Sep 6, 2022
🔥 Cogitare - A Modern, Fast, and Modular Deep Learning and Machine Learning framework for Python

Cogitare is a Modern, Fast, and Modular Deep Learning and Machine Learning framework for Python. A friendly interface for beginners and a powerful too

Cogitare - Modern and Easy Deep Learning with Python 76 Sep 30, 2022
Genetic Algorithm, Particle Swarm Optimization, Simulated Annealing, Ant Colony Optimization Algorithm,Immune Algorithm, Artificial Fish Swarm Algorithm, Differential Evolution and TSP(Traveling salesman)

scikit-opt Swarm Intelligence in Python (Genetic Algorithm, Particle Swarm Optimization, Simulated Annealing, Ant Colony Algorithm, Immune Algorithm,A

郭飞 3.7k Jan 3, 2023
library for nonlinear optimization, wrapping many algorithms for global and local, constrained or unconstrained, optimization

NLopt is a library for nonlinear local and global optimization, for functions with and without gradient information. It is designed as a simple, unifi

Steven G. Johnson 1.4k Dec 25, 2022
Racing line optimization algorithm in python that uses Particle Swarm Optimization.

Racing Line Optimization with PSO This repository contains a racing line optimization algorithm in python that uses Particle Swarm Optimization. Requi

Parsa Dahesh 6 Dec 14, 2022
A Web API for automatic background removal using Deep Learning. App is made using Flask and deployed on Heroku.

Automatic_Background_Remover A Web API for automatic background removal using Deep Learning. App is made using Flask and deployed on Heroku. ?? https:

Gaurav 16 Oct 29, 2022
Official repo for AutoInt: Automatic Integration for Fast Neural Volume Rendering in CVPR 2021

AutoInt: Automatic Integration for Fast Neural Volume Rendering CVPR 2021 Project Page | Video | Paper PyTorch implementation of automatic integration

Stanford Computational Imaging Lab 149 Dec 22, 2022
Fast and scalable uncertainty quantification for neural molecular property prediction, accelerated optimization, and guided virtual screening.

Evidential Deep Learning for Guided Molecular Property Prediction and Discovery Ava Soleimany*, Alexander Amini*, Samuel Goldman*, Daniela Rus, Sangee

Alexander Amini 75 Dec 15, 2022
An optimization and data collection toolbox for convenient and fast prototyping of computationally expensive models.

An optimization and data collection toolbox for convenient and fast prototyping of computationally expensive models. Hyperactive: is very easy to lear

Simon Blanke 422 Jan 4, 2023
An implementation of "Optimal Textures: Fast and Robust Texture Synthesis and Style Transfer through Optimal Transport"

Optex An implementation of Optimal Textures: Fast and Robust Texture Synthesis and Style Transfer through Optimal Transport for TU Delft CS4240. You c

Hans Brouwer 33 Jan 5, 2023