aerosandbox.aerodynamics.aero_2D.xfoil#

Module Contents#

Classes#

XFoil

An interface to XFoil, a 2D airfoil analysis tool developed by Mark Drela at MIT.

Attributes#

af

class aerosandbox.aerodynamics.aero_2D.xfoil.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.

aerosandbox.aerodynamics.aero_2D.xfoil.af[source]#