flight_mech.wing module#

Module to analyse wing aerodynamic properties.

class flight_mech.wing.Wing[source]#

Bases: object

Class to define a wing and compute its characteristics.

property aspect_ratio#

Aspect ratio. It corresponds to the squared wing span over the reference surface.

base_airfoil: Airfoil | None = None#
property center_x_array: ndarray#

Array of the x coordinates of the mean between leading and trailing edges coordinates.

check_initialization()[source]#

Check that the wing is correctly initialized.

chord_length_array: ndarray | None = None#
compute_fourrier_coefficients(alpha: float, nb_points_fourrier: int = 10)[source]#

Compute the fourrier coefficients used to determine the lift and induced drag.

Parameters:
  • alpha (float) – Angle of incidence of the wing.

  • nb_points_fourrier (int, optional) – Number of points for the fourrier decomposition, by default 10

Returns:

Tuple containing the fourrier coefficients and their ids.

Return type:

tuple[np.ndarray,np.ndarray]

compute_lift_and_induced_drag_coefficients(alpha: float, nb_points_fourrier: int = 10)[source]#

Compute the coefficients of lift and induced drag.

Parameters:
  • alpha (float) – Angle of incidence of the wing.

  • nb_points_fourrier (int, optional) – Number of points for the fourrier decomposition, by default 10

Returns:

Tuple containing the lift and induced drag coefficients.

Return type:

tuple[float,float]

compute_zero_lift_drag(velocity: float, rho: float, nu: float, drag_method: Literal['blasius', 'polhausen', 'simulation'] = 'polhausen', velocity_method: Literal['constant', 'panels'] = 'constant', nb_points: int = 1000, face: Literal['both', 'upper', 'lower'] = 'both')[source]#

Compute the drag of the half-wing at zero lift.

Parameters:
  • velocity (float) – Velocity of the external flow.

  • rho (float) – Density of the fluid.

  • nu (float) – Kinematic viscosity of the fluid.

  • drag_method (Literal["blasius", "polhausen", "simulation"], optional) – Method to use for the drag computation, by default “polhausen”

  • velocity_method (Literal["constant", "panels"], optional) – Method to use for the velocity computation, by default “constant”

  • nb_points (int, optional) – Number of points to use for the computation, by default 1000

  • face (Literal["both", "upper", "lower"]) – Indicate on which face to compute the drag.

Returns:

Drag at zero lift

Return type:

float

compute_zero_lift_drag_on_wing_slice(y_index: int, velocity: float, rho: float, nu: float, drag_method: Literal['blasius', 'polhausen', 'simulation'] = 'polhausen', velocity_method: Literal['constant', 'panels'] = 'constant', nb_points: int = 1000, return_array: bool = False, face: Literal['upper', 'lower'] = 'upper')[source]#

Compute the drag of the wing at zero lift.

Parameters:
  • y_index (int) – Index of the slice.

  • velocity (float) – Velocity of the external flow.

  • rho (float) – Density of the fluid.

  • nu (float) – Kinematic viscosity of the fluid.

  • drag_method (Literal["blasius", "polhausen", "simulation"], optional) – Method to use for the drag computation, by default “polhausen”

  • velocity_method (Literal["constant", "panels"], optional) – Method to use for the velocity computation, by default “constant”

  • nb_points (int, optional) – Number of points to use for the computation, by default 1000

  • face (Literal["upper", "lower"]) – Indicate on which face to compute the drag.

Returns:

Drag on the wing slice.

Return type:

float

Raises:

NotImplementedError – Raise error if the given method is not defined.

create_3D_animation(output_path: str, nb_points_airfoil: int = 50, nb_frames: int = 60, time_step: float = 0.05, **kwargs)[source]#

Create a rotating 3D animation of the wing.

Parameters:
  • output_path (str) – Path of the output gif.

  • nb_points_airfoil (int, optional) – Number of points to use for the airfoil, by default 50

  • nb_frames (int, optional) – Number of frames in the animation, by default 60

  • time_step (float, optional) – Time step between each frame, by default 0.05

  • kwargs (dict) – Parameters to pass to the plot 3D function.

create_wing_3D_surface(nb_points_airfoil: int = 50)[source]#

Create a wing surface PyVista object for 3D plotting.

Parameters:

nb_points_airfoil (int, optional) – Number of points to use for the airfoil, by default 50

Returns:

Pyvista 3D surface.

Return type:

pv.PointSet

initialize()[source]#

Initialize the wing by setting the undefined array to default values.

Raises:

ValueError – Raise error if the y array is not defined.

property leading_edge_x_array: ndarray#

Array of x coordinates of the leading edge.

name: str | None = None#
plot_2D(save_path: str | None = None, hold_plot: bool = False, clear_before_plot: bool = False)[source]#

Plot the shape of the wing in 2D.

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

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

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

plot_3D(nb_points_airfoil: int = 50, show_symmetric_wing: bool = False, show_drag: None | Literal['blasius', 'polhausen', 'simulation'] = None, velocity_method: Literal['constant', 'panels'] = 'constant', velocity: float | None = None, rho: float | None = None, nu: float | None = None, for_animation: bool = False, title: str | None = None)[source]#

Plot the shape of the wing in 3D.

re_interpolate(new_y_array: ndarray, update_y_array: bool = True)[source]#

Re-interpolate the wing arrays.

Parameters:
  • new_y_array (np.ndarray) – New y array on which to interpolate.

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

property reference_surface#

Reference surface of the wings of the plane. Equal to 2 times the surface of a single wing.

save_3D_shape(output_path: str, nb_points_airfoil: int = 50)[source]#

Save the wing shape as a 3D object. The format can be ‘.ply’, ‘.vtp’, ‘.stl’, ‘.vtk’, ‘.geo’, ‘.obj’ or ‘.iv’.

Parameters:
  • output_path (str) – Path of the output file.

  • nb_points_airfoil (int, optional) – Number of points to use for the airfoil, by default 50

property single_side_surface#

Surface of a single wing.

property sweep_angle_at_leading_edge#

Sweep angle at the leading edge of the wing.

property sweep_angle_at_trailing_edge#

Sweep angle at the trailing edge of the wing.

property taper_ratio#

Taper ratio. It corresponds to the ratio of the min chord and the max chord.

property trailing_edge_x_array: ndarray#

Array of x coordinates of the trailing edge.

twisting_angle_array: ndarray | None = None#
property wing_span#

Wing span.

x_center_offset_array: ndarray | None = None#
property y_array: ndarray#

Array of y coordinates used for the wing definition.

flight_mech.wing.check_pyvista_import()[source]#

Verify that pyvista is successfully imported.

Raises:

ImportError – Raise error if pyvista cannot be accessed.

flight_mech.wing.compute_chord_min_and_max_for_trapezoidal_wing(reference_surface: float, aspect_ratio: float, taper_ratio: float)[source]#

Compute the chord min and max values for a trapezoidal wing.

Parameters:
  • reference_surface (float) – Reference surface of the wing.

  • aspect_ratio (float) – Aspect ratio of the wing.

  • taper_ratio (float) – Taper ratio of the wing.

Returns:

Tuple containing the chord min and max values.

Return type:

tuple[float,float]

flight_mech.wing.convert_theta_to_y(theta_array: ndarray, wing_span: float)[source]#

Convert a theta array to y.

Parameters:
  • theta_array (np.ndarray) – Values of theta coordinates.

  • wing_span (float) – Wing span.

Returns:

Y coordinates array.

Return type:

np.ndarray

flight_mech.wing.convert_y_to_theta(y_array: ndarray, wing_span: float)[source]#

Convert a y array to theta.

Parameters:
  • y_array (np.ndarray) – Values of y coordinates.

  • wing_span (float) – Wing span.

Returns:

Theta array.

Return type:

np.ndarray