flight_mech.airfoil module#

Module to analyse airfoil aerodynamic properties.

class flight_mech.airfoil.Airfoil(airfoil: str | None = None)[source]#

Bases: object

Class to define an airfoil and compute its characteristics.

property camber_z_array: ndarray#

Array of the camber line z coordinates.

property chord_length: float#

Length of the chord.

property chord_z_array: ndarray#

Array of the chord line z coordinates.

compute_airfoil_fourrier_coefficients(nb_points: int = 1000)[source]#

Compute the airfoil Fourrier’s coefficients to be able to compute lift and moment values.

Parameters:

nb_points (int) – Number of points to use for the interpolation.

Returns:

Fourier’s coefficients.

Return type:

tuple[float,float,float]

compute_alpha_zero_lift()[source]#

Compute the angle of incidence for which the airfoil’s lift is zero.

Returns:

Angle of incidence at zero lift.

Return type:

float

compute_lift_coefficient(alpha: float)[source]#

Compute the lift coefficient for a given angle of incidence.

Parameters:

alpha (float) – Angle of incidence in radians.

Returns:

Lift coefficient.

Return type:

float

compute_momentum_coefficient_at_aero_center(alpha: float)[source]#

Compute the momentum coefficient at the aerodynamic center for a given angle of incidence.

Parameters:

alpha (float) – Angle of incidence in radians.

Returns:

Momentum coefficient.

Return type:

float

compute_momentum_coefficient_at_leading_edge(alpha: float)[source]#

Compute the momentum coefficient at leading edge for a given angle of incidence.

Parameters:

alpha (float) – Angle of incidence in radians.

Returns:

Momentum coefficient.

Return type:

float

extrados_z_array: ndarray | None = None#
get_chord_incidence()[source]#
get_rotated_selig_arrays(angle: float, rotation_center: float = 0.25)[source]#

Returns the selig arrays of the airfoil rotated by a given angle.

Parameters:
  • angle (float) – Angle of rotation.

  • rotation_center (float) – Center of rotation in fraction of the chord.

Returns:

Tuple containing the selig arrays.

Return type:

tuple[np.ndarray,np.ndarray]

import_from_airfoiltools(airfoil_name: str = '', max_thickness: float | None = None, min_thickness: float | None = None, max_camber: float | None = None, min_camber: float | None = None, maximise_glide_ratio_at_reynolds: Literal['50k', '100k', '200k', '500k', '1M', '2M', '5M'] | None = None, airfoil_data_folder: str = '/home/runner/work/flight-mech/flight-mech/flight_mech/airfoil_database')[source]#

Import an airfoil from airfoiltools.

Parameters:
  • airfoil_name (str, optional) – Name of the airfoil to search, by default “”

  • max_thickness (float | None, optional) – Max thickness value in percent, by default None

  • min_thickness (float | None, optional) – Min thickness value in percent, by default None

  • max_camber (float | None, optional) – Max camber value in percent, by default None

  • min_camber (float | None, optional) – Min camber value in percent, by default None

  • maximise_glide_ratio_at_reynolds (Literal["50k", "100k", "200k", "500k", "1M", "2M", "5M"] | None, optional) – Indicate Reynolds number to sort by optimal ratio, by default None

  • airfoil_data_folder (str, optional) – Folder containing the airfoil database, by default default_airfoil_database

Warning

The thickness and camber values must be expressed in percents.

Raises:

ValueError – Raise error if no corresponding profile is found.

import_xz_selig_arrays(x_selig_array: ndarray, z_selig_array: ndarray)[source]#

Import x and z arrays containing an airfoil in selig format.

Parameters:
  • x_selig_array (np.ndarray) – X coordinates.

  • z_selig_array (np.ndarray) – Z coordinates.

intrados_z_array: ndarray | None = None#
list_airfoils_in_database(airfoil_data_folder: str = '/home/runner/work/flight-mech/flight-mech/flight_mech/airfoil_database')[source]#

Return the list of airfoils stored in the database.

Parameters:

airfoil_data_folder (str, optional) – Name of the airfoil database folder, by default default_airfoil_database

Returns:

List of airfoils stored in the database.

Return type:

list

load_database_airfoil(airfoil_name: str, airfoil_data_folder: str = '/home/runner/work/flight-mech/flight-mech/flight_mech/airfoil_database')[source]#

Load an airfoil contained in the database.

Parameters:
  • airfoil_name (str) – Name of the airfoil.

  • airfoil_data_folder (str, optional) – Folder containing the airfoil file, by default default_airfoil_database

load_selig_file(file_path: str, skiprows: int = 1)[source]#

Load an airfoil contained in a selig txt file.

Parameters:
  • file_path (str) – Path of the file to load.

  • skiprows (int, optional) – Number of rows to skip at the beginning of the file, by default 1

property max_camber: float#

Max camber value.

property max_camber_location: float#

Location of the max camber value in x.

property max_thickness: float#

Max thickness value.

property max_thickness_location: float#

Location of the max thickness value in x.

name: str | None = None#
plot(hold_plot=False, show_chord=False, show_camber_line=False)[source]#

Plot the geometry of the airfoil.

Parameters:
  • hold_plot (bool, optional) – Indicate if the plot shall be kept for later, by default False

  • show_chord (bool, optional) – Display the chord line if true, by default False

  • show_camber_line (bool, optional) – Display the camber line if true, by default False

plot_CL_graph(alpha_min: float = -1, alpha_max: float = 1, nb_points: int = 100, mode: Literal['deg', 'rad'] = 'rad', hold_plot: bool = False, save_path: str | None = None, clear_before_plot: bool = False)[source]#

Plot the CL graph of the airfoil.

Parameters:
  • alpha_min (float, optional) – Minimum value of alpha, by default -1

  • alpha_max (float, optional) – Maximum value of alpha, by default 1

  • nb_points (int, optional) – Number of points, by default 100

  • mode (Literal["deg", "rad"], optional) – Mode for alpha definition, by default “rad”

  • hold_plot (bool, optional) – Indicate wether to display the plot or keep it, by default False

  • save_path (str | None, optional) – Path to save the figure, by default None

  • clear_before_plot (bool, optional) – Indicate wether to clear the plot before display, by default False

plot_Cm_graph(alpha_min: float = -1, alpha_max: float = 1, nb_points: int = 100, mode: Literal['deg', 'rad'] = 'rad', location: Literal['leading_edge', 'aero_center'] = 'aero_center', hold_plot: bool = False, save_path: str | None = None, clear_before_plot: bool = False)[source]#

Plot the Cm graph of the airfoil.

Parameters:
  • alpha_min (float, optional) – Minimum value of alpha, by default -1

  • alpha_max (float, optional) – Maximum value of alpha, by default 1

  • nb_points (int, optional) – Number of points, by default 100

  • mode (Literal["deg", "rad"], optional) – Mode for alpha definition, by default “rad”

  • location (Literal["leading_edge","aero_center"]) – Location of the Cm, by default “aero_center”

  • hold_plot (bool, optional) – Indicate wether to display the plot or keep it, by default False

  • save_path (str | None, optional) – Path to save the figure, by default None

  • clear_before_plot (bool, optional) – Indicate wether to clear the plot before display, by default False

re_interpolate(new_x_array: ndarray, update_x_array: bool = True)[source]#

Re-interpolate the extrados and intrados on the given array.

Parameters:
  • new_x_array (np.ndarray) – New x array on which to interpolate.

  • update_x_array (bool, optional) – Indicate wether to update the x array, by default True

re_interpolate_with_cosine_distribution(nb_points: int)[source]#

Re-interpolate the extrados and the intrados on a x array defined by a cosine distribution.

Parameters:

nb_points (int) – Number of points in the cosine distribution.

set_chord_at_zero_incidence()[source]#
property thickness_array: ndarray#

Array of the thickness of the airfoil.

property x_array: ndarray#

Array of x coordinates used for the airfoil definition.

property x_selig_array: ndarray#
property z_selig_array: ndarray#
flight_mech.airfoil.convert_float_or_none_to_string(value: float | None)[source]#
flight_mech.airfoil.download_web_file(url, output_file)[source]#
flight_mech.airfoil.naca_airfoil_generator(maximum_camber: float | None = None, maximum_camber_position: float | None = None, maximum_thickness: float | None = None, naca_name: str | None = None, nb_points: int = 200)[source]#

Generate a NACA airfoil.

Parameters:
  • maximum_camber (float) – Maximum camber value.

  • maximum_camber_position (float) – Maximum camber position.

  • thickness (float) – Maximum thickness value.

  • naca_name (str) – Name of the NACA airfoil. If provided, the other geometry parameters will not be used.

  • nb_points (int, optional) – Number of points, by default 200

flight_mech.airfoil.rotate_arrays(x_array: ndarray, z_array: ndarray, angle: float, rotation_center: float = 0.25, x_length: float | None = None)[source]#

Rotate the given x and z arrays.

Parameters:
  • x_array (np.ndarray) – X array to rotate.

  • z_array (np.ndarray) – Z array to rotate.

  • angle (float) – Angle of rotation in rad.

  • rotation_center (float, optional) – Center of rotation in % of the x array, by default 0.25

Returns:

Tuple containing the rotated arrays.

Return type:

tuple[np.ndarray, np.ndarray]