aerosandbox.aerodynamics.aero_2D
Submodules
- aerosandbox.aerodynamics.aero_2D.IBL2
- aerosandbox.aerodynamics.aero_2D.airfoil_inviscid
- aerosandbox.aerodynamics.aero_2D.airfoil_optimizer
- aerosandbox.aerodynamics.aero_2D.airfoil_polar_functions
- aerosandbox.aerodynamics.aero_2D.mses
- aerosandbox.aerodynamics.aero_2D.singularities
- aerosandbox.aerodynamics.aero_2D.xfoil
Classes
AirfoilInviscid | An implicit analysis for inviscid analysis of an airfoil (or family of airfoils). |
XFoil | An interface to XFoil, a 2D airfoil analysis tool developed by Mark Drela at MIT. |
MSES | An interface to MSES, MSET, and MPLOT, a 2D airfoil analysis system developed by Mark Drela at MIT. |
Package Contents
class aerosandbox.aerodynamics.aero_2D.AirfoilInviscid(airfoil, op_point, ground_effect=False)
: Bases: aerosandbox.common.ImplicitAnalysis
An implicit analysis for inviscid analysis of an airfoil (or family of airfoils).
Key outputs:
> - AirfoilInviscid.Cl
Parameters:
: - **airfoil** (*Union**[*[*aerosandbox.geometry.Airfoil*](/u/b315363d35db77b2#aerosandbox-geometry-airfoil)*,* *List**[*[*aerosandbox.geometry.Airfoil*](/u/b315363d35db77b2#aerosandbox-geometry-airfoil)*]**]*) –
- **op\_point** ([*aerosandbox.performance.OperatingPoint*](/u/ef68b15c282639e3#aerosandbox-performance-operatingpoint)) –
- **ground\_effect** (*bool*) –
op\_point
ground\_effect *= False*
\_\_repr\_\_()
\_setup\_unknowns()
calculate\_velocity(*x\_field*, *y\_field*)
: Return type:
: [aerosandbox.numpy.ndarray, aerosandbox.numpy.ndarray]
\_enforce\_governing\_equations()
\_calculate\_forces()
draw\_streamlines(*res=200*, *show=True*)
draw\_cp(*show=True*) class aerosandbox.aerodynamics.aero_2D.XFoil(airfoil, Re=0.0, mach=0.0, n_crit=9.0, xtr_upper=1.0, xtr_lower=1.0, hinge_point_x=0.75, full_potential=False, max_iter=100, xfoil_command='xfoil', xfoil_repanel=True, xfoil_repanel_n_points=279, include_bl_data=False, verbose=False, timeout=30, working_directory=None)
: Bases: aerosandbox.common.ExplicitAnalysis
An interface to XFoil, a 2D airfoil analysis tool developed by Mark Drela at MIT.
Requires XFoil to be on your computer; XFoil is available here: <https://web.mit.edu/drela/Public/web/xfoil/>
It is recommended (but not required) that you add XFoil to your system PATH environment variable such that it can
be called with the command xfoil. If this is not the case, you need to specify the path to your XFoil
executable using the xfoil\_command argument of the constructor.
Usage example:
```defaultxf = XFoil( airfoil=Airfoil("naca2412").repanel(n_points_per_side=100), Re=1e6, )
result_at_single_alpha = xf.alpha(5) result_at_several_CLs = xf.cl([0.5, 0.7, 0.8, 0.9]) result_at_multiple_alphas = xf.alpha([3, 5, 60]) # Note: if a result does not converge (such as the 60 degree case here), it will not be included in the results.
Parameters:
: - **airfoil** ([*aerosandbox.geometry.Airfoil*](/u/b315363d35db77b2#aerosandbox-geometry-airfoil)) –
- **Re** (*float*) –
- **mach** (*float*) –
- **n\_crit** (*float*) –
- **xtr\_upper** (*float*) –
- **xtr\_lower** (*float*) –
- **hinge\_point\_x** (*float*) –
- **full\_potential** (*bool*) –
- **max\_iter** (*int*) –
- **xfoil\_command** (*str*) –
- **xfoil\_repanel** (*bool*) –
- **xfoil\_repanel\_n\_points** (*int*) –
- **include\_bl\_data** (*bool*) –
- **verbose** (*bool*) –
- **timeout** (*Union**[**float**,* *int**,* *None**]*) –
- **working\_directory** (*Union**[**pathlib.Path**,* *str**]*) –
*exception* XFoilError
: Bases: `Exception`
Common base class for all non-exit exceptions.
airfoil
Re *= 0.0*
mach *= 0.0*
n\_crit *= 9.0*
xtr\_upper *= 1.0*
xtr\_lower *= 1.0*
hinge\_point\_x *= 0.75*
full\_potential *= False*
max\_iter *= 100*
xfoil\_command *= 'xfoil'*
xfoil\_repanel *= True*
xfoil\_repanel\_n\_points *= 279*
include\_bl\_data *= False*
verbose *= False*
timeout *= 30*
\_\_repr\_\_()
\_default\_keystrokes(*airfoil\_filename*, *output\_filename*)
: Returns a list of XFoil keystrokes that are common to all XFoil runs.
Returns:
: A list of strings, each of which is a single XFoil keystroke to be followed by <enter>.
Parameters:
: - **airfoil\_filename** (*str*) –
- **output\_filename** (*str*) –
Return type:
: List[str]
\_run\_xfoil(*run\_command*, *read\_bl\_data\_from=None*)
: Private function to run XFoil.
Args: run\_command: A string with any XFoil keystroke inputs that you’d like. By default, you start off within the OPER
menu. All of the inputs indicated in the constructor have been set already, but you can override them here (for
this run only) if you want.
Returns: A dictionary containing all converged solutions obtained with your inputs.
Parameters:
: - **run\_command** (*str*) –
- **read\_bl\_data\_from** (*str*) –
Return type:
: Dict[str, aerosandbox.numpy.ndarray]
open\_interactive()
: Opens a new terminal window and runs XFoil interactively. This is useful for detailed analysis or debugging.
Returns: None
Return type:
: None
alpha(*alpha*, *start\_at=0*)
: Execute XFoil at a given angle of attack, or at a sequence of angles of attack.
Parameters:
: - **alpha** (*Union**[**float**,* *aerosandbox.numpy.ndarray**]*) – The angle of attack [degrees]. Can be either a float or an iterable of floats, such as an array.
- **start\_at** (*Union**[**float**,* *None**]*) – Chooses whether to split a large sweep into two runs that diverge away from some central value,
- **example** (*to improve convergence. As an*) –
- **alpha=20** (*if you wanted to sweep from alpha=-20 to*) –
- **want** (*you might*) –
- **together** (*to instead do two sweeps and stitch them*) –
0 to 20, and 0 to -20. start\_at can be either:
- None, in which case the alpha inputs are run as a single sequence in the order given.
- A float that corresponds to an angle of attack (in degrees), in which case the alpha inputs are
split into two sequences that diverge from the start\_at value. Successful runs are then sorted by
alpha before returning.
Return type:
: Dict[str, aerosandbox.numpy.ndarray]
Returns: A dictionary with the XFoil results. Dictionary values are arrays; they may not be the same shape as
your input array if some points did not converge.
cl(*cl*, *start\_at=0*)
: Execute XFoil at a given lift coefficient, or at a sequence of lift coefficients.
Parameters:
: - **cl** (*Union**[**float**,* *aerosandbox.numpy.ndarray**]*) – The lift coefficient [-]. Can be either a float or an iterable of floats, such as an array.
- **start\_at** (*Union**[**float**,* *None**]*) – Chooses whether to split a large sweep into two runs that diverge away from some central value,
- **example** (*to improve convergence. As an*) –
- **cl=1.5** (*if you wanted to sweep from cl=-1.5 to*) –
- **to** (*you might want*) –
- **together** (*instead do two sweeps and stitch them*) –
0 to 1.5, and 0 to -1.5. start\_at can be either:
- None, in which case the cl inputs are run as a single sequence in the order given.
- A float that corresponds to an lift coefficient, in which case the cl inputs are
split into two sequences that diverge from the start\_at value. Successful runs are then sorted by
alpha before returning.
Return type:
: Dict[str, aerosandbox.numpy.ndarray]
Returns: A dictionary with the XFoil results. Dictionary values are arrays; they may not be the same shape as
your input array if some points did not converge.
<a id="aerosandbox.aerodynamics.aero_2D.MSES"></a> *class* aerosandbox.aerodynamics.aero\_2D.MSES(*airfoil*, *n\_crit=9.0*, *xtr\_upper=1.0*, *xtr\_lower=1.0*, *max\_iter=100*, *mset\_command='mset'*, *mses\_command='mses'*, *mplot\_command='mplot'*, *use\_xvfb=None*, *xvfb\_command='xvfb-run -a'*, *verbosity=1*, *timeout\_mset=10*, *timeout\_mses=60*, *timeout\_mplot=10*, *working\_directory=None*, *behavior\_after\_unconverged\_run='reinitialize'*, *mset\_alpha=0*, *mset\_n=141*, *mset\_e=0.4*, *mset\_io=37*, *mset\_x=0.85*, *mses\_mcrit=0.99*, *mses\_mucon=-1.0*)
: Bases: [`aerosandbox.common.ExplicitAnalysis`](/u/6d3330afd901bed5#aerosandbox-common-explicitanalysis)
An interface to MSES, MSET, and MPLOT, a 2D airfoil analysis system developed by Mark Drela at MIT.
Requires compiled binaries for all the programs to be on your computer;
MSES is available here: <https://web.mit.edu/drela/Public/web/mses/>
Academics can get a copy by emailing the MIT Tech. Licensing Office;
MIT affiliates can find a copy on Athena.
It is recommended (but not required) that you add MSES, MSET, and MPLOT to your system PATH environment variable
such that they can be called with the commands mses, mset, and mplot. If this is not the case, you need to
specify the path to these executables using the command arguments of the constructor.
Note that MSES, MSET, and MPLOT by default open up X11 windows on your computer. If you prefer that this doesn’t
happen (for extra speed), or if you cannot have this happen (e.g., you are computing in an environment without
proper X11 support, like Windows Subsystem for Linux), you should use XVFB. <https://en.wikipedia.org/wiki/Xvfb>
XVFB is a virtual “display” server that can receive X11 output and safely dump it. (If you don’t use XVFB and you
don’t have proper X11 support on your computer, this AeroSandbox MSES module will simply error out during the
MSET call - probably not what you want.)
To install XVFB on a Linux machine, use:
``bash
sudo apt-get install xvfb
``
Then, when instantiating this MSES instance in AeroSandbox, pass the use\_xvfb flag to be True. Default behavior
here is that this class will look for the XVFB executable, xvfb-run, on your machine. If it finds it,
it will run with XVFB enabled. If it does not, it will run without XVFB.
---
Usage example:
```default
>>> ms = MSES(
>>> airfoil=Airfoil("naca2412").repanel(n_points_per_side=100),
>>> Re=1e6,
>>> mach=0.2,
>>> )
>>>
>>> result_at_single_alpha = ms.alpha(5)
>>> #result_at_several_CLs = ms.cl([0.5, 0.7, 0.8, 0.9])
>>> result_at_multiple_alphas = ms.alpha([3, 5, 60]) # Note: if a result does not converge (such as the 60 degree case here), it will not be included in the results.Parameters:
: - **airfoil** ([*aerosandbox.geometry.Airfoil*](/u/b315363d35db77b2#aerosandbox-geometry-airfoil)) –
- **n\_crit** (*float*) –
- **xtr\_upper** (*float*) –
- **xtr\_lower** (*float*) –
- **max\_iter** (*int*) –
- **mset\_command** (*str*) –
- **mses\_command** (*str*) –
- **mplot\_command** (*str*) –
- **use\_xvfb** (*bool*) –
- **xvfb\_command** (*str*) –
- **verbosity** (*int*) –
- **timeout\_mset** (*Union**[**float**,* *int**,* *None**]*) –
- **timeout\_mses** (*Union**[**float**,* *int**,* *None**]*) –
- **timeout\_mplot** (*Union**[**float**,* *int**,* *None**]*) –
- **working\_directory** (*str*) –
- **behavior\_after\_unconverged\_run** (*str*) –
- **mset\_alpha** (*float*) –
- **mset\_n** (*int*) –
- **mset\_e** (*float*) –
- **mset\_io** (*int*) –
- **mset\_x** (*float*) –
- **mses\_mcrit** (*float*) –
- **mses\_mucon** (*float*) –
airfoil
n\_crit *= 9.0*
xtr\_upper *= 1.0*
xtr\_lower *= 1.0*
max\_iter *= 100*
mset\_command *= 'mset'*
mses\_command *= 'mses'*
mplot\_command *= 'mplot'*
use\_xvfb *= None*
xvfb\_command *= 'xvfb-run -a'*
verbosity *= 1*
timeout\_mses *= 60*
timeout\_mset *= 10*
timeout\_mplot *= 10*
working\_directory *= None*
behavior\_after\_unconverged\_run *= 'reinitialize'*
mset\_alpha *= 0*
mset\_n *= 141*
mset\_e *= 0.4*
mset\_io *= 37*
mset\_x *= 0.85*
mses\_mcrit *= 0.99*
mses\_mucon *= -1.0*
run(*alpha=0.0*, *Re=0.0*, *mach=0.01*)
: Parameters:
: - **alpha** (*Union**[**float**,* *aerosandbox.numpy.ndarray**,* *List**]*) –
- **Re** (*Union**[**float**,* *aerosandbox.numpy.ndarray**,* *List**]*) –
- **mach** (*Union**[**float**,* *aerosandbox.numpy.ndarray**,* *List**]*) –