aerosandbox.aerodynamics.aero_2D#

Subpackages#

Submodules#

Package Contents#

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.

class aerosandbox.aerodynamics.aero_2D.AirfoilInviscid(airfoil, op_point, ground_effect=False)[source]#

Bases: aerosandbox.common.ImplicitAnalysis

An implicit analysis for inviscid analysis of an airfoil (or family of airfoils).

Key outputs:

  • AirfoilInviscid.Cl

Parameters:
__repr__()[source]#

Return repr(self).

_setup_unknowns()[source]#
calculate_velocity(x_field, y_field)[source]#
Return type:

[aerosandbox.numpy.ndarray, aerosandbox.numpy.ndarray]

_enforce_governing_equations()[source]#
_calculate_forces()[source]#
draw_streamlines(res=200, show=True)[source]#
draw_cp(show=True)[source]#
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)[source]#

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:

>>> xf = 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) –

  • 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]) –

__repr__()[source]#

Return repr(self).

_default_keystrokes(airfoil_filename, output_filename)[source]#

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)[source]#

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()[source]#

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)[source]#

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)[source]#

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.

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)[source]#

Bases: 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:

>>> 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) –

  • 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) –

run(alpha=0.0, Re=0.0, mach=0.01)[source]#
Parameters:
  • alpha (Union[float, aerosandbox.numpy.ndarray, List]) –

  • Re (Union[float, aerosandbox.numpy.ndarray, List]) –

  • mach (Union[float, aerosandbox.numpy.ndarray, List]) –