Post · 4 min read· pp. 335–339

aerosandbox.aerodynamics.aero_2D.xfoil

Attributes

Classes

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

Module Contents

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) : Bases: aerosandbox.common.ExplicitAnalysis

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

```default

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.

code

    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.xfoil.af"></a> aerosandbox.aerodynamics.aero\_2D.xfoil.af