pterasoftware.geometry.airplane¶
Contains the Airplane class.
Classes¶
A class used to contain airplanes. |
Module Contents¶
- class pterasoftware.geometry.airplane.Airplane(wings: list[pterasoftware.geometry.wing.Wing], name: str = 'Untitled Airplane', Cg_GP1_CgP1: numpy.ndarray | collections.abc.Sequence[float | int] = (0.0, 0.0, 0.0), weight: float | int = 0.0, s_ref: float | int | None = None, c_ref: float | int | None = None, b_ref: float | int | None = None)[source]¶
A class used to contain airplanes.
Contains the following methods:
__deepcopy__: Creates a deep copy of this Airplane, preserving mesh geometry but resetting solver state.
deep_copy_with_Cg_GP1_CgP1: Creates a deep copy of this Airplane with a different Cg_GP1_CgP1 position.
num_panels: The total number of Panels across all Wings.
T_pas_G_Cg_to_GP1_CgP1: The passive transformation matrix from this Airplane’s geometry axes, relative to this Airplane’s CG to the first Airplane’s geometry axes, relative to the first Airplane’s CG.
draw: Draws the 3D geometry of this Airplane.
get_plottable_data: Returns plottable data for this Airplane’s Airfoils’ outlines and mean camber lines.
validate_first_airplane_constraints: Validates that the first Airplane in a simulation has Cg_GP1_CgP1 set to zeros.
process_wing_symmetry: Processes a Wing to determine what type of symmetry it has. If necessary, it then modifies the Wing. If type 5 symmetry is detected, it also creates a second reflected Wing. Finally, it returns a list of Wings.
Notes:
The Airplane class is responsible for: (1) Defining the local body axes and geometry axes, (2) managing Wings and their coordinate transformations, (3) processing symmetric Wings and converting them to separate wings when the symmetry plane is not coincident with the Wing’s axes xz plane (type 5 symmetry), and (4) providing reference dimensions for aerodynamic calculations.
Every Airplane has a body axis system, where +x points forward along fuselage, +y points to the right (starboard direction), and +z points downward (completing a right-handed system).
Every Airplane also has a geometry axis system, where +x points aft along fuselage, +y points to the right (starboard direction), and +z points upward (completing a right-handed system).
Immutable attributes (wings, name, Cg_GP1_CgP1, weight, s_ref, c_ref, and b_ref) are set during initialization and cannot be modified afterward. The numpy array Cg_GP1_CgP1 is made read only to prevent in place mutation. The wings attribute is stored as a tuple to prevent external mutation.
Derived properties (num_panels and T_pas_G_Cg_to_GP1_CgP1) are lazily evaluated and cached since they depend only on immutable attributes.
The forces_W, forceCoefficients_W, moments_W_CgP1, and momentCoefficients_W_CgP1 attributes remain mutable as they are set by the solver during simulation.
Citation:
Adapted from: geometry.Airplane in AeroSandbox
Author: Peter Sharpe
Date of retrieval: 04/23/2020
- Parameters:
wings – A list of the airplane’s wings defined as Wings. It must contain at least one Wing. Wings with symmetric=True and non coincident symmetry planes will be automatically processed into separate Wings during initialization (type 5 symmetry).
name – A sensible name for your airplane. The default is “Untitled Airplane”.
Cg_GP1_CgP1 – An array-like object of 3 numbers representing the position of this Airplane’s CG (in the first Airplane’s geometry axes, relative to the first Airplane’s CG). Can be a list, tuple, or ndarray. Values are converted to floats internally. For the first Airplane in a simulation, this must be equivalent to (0.0, 0.0, 0.0) by definition. The units are in meters. The default is (0.0, 0.0, 0.0).
weight – A number (int or float) representing the weight of the aircraft in Newtons. This is used by the trim functions. It must be greater than or equal to zero. The default is 0.0. In free flight, it must also be consistent with the FreeFlightUnsteadyProblem’s mass and the OperatingPoint’s gravitational acceleration, satisfying weight == mass * |g_E| within floating point tolerance.
s_ref – A number (int or float) representing the reference wetted area. If not set or set to None (the default), it populates from first Wing. If set, it must be greater than zero, and will be converted to a float internally. The units are square meters.
c_ref – A number (int or float) representing the reference chord length. If not set or set to None (the default), it populates from first Wing. If set, it must be greater than zero, and will be converted to a float internally. The units are meters.
b_ref – A number (int or float) representing the reference span. If not set or set to None (the default value), it populates from first Wing. If set, it must be greater than zero, and will be converted to a float internally. The units are meters.
- deep_copy_with_Cg_GP1_CgP1(new_Cg_GP1_CgP1: numpy.ndarray | collections.abc.Sequence[float | int]) Airplane[source]¶
Creates a deep copy of this Airplane with a different Cg_GP1_CgP1 position.
This method is used by AirplaneMovement to create Airplanes at different time steps that share the same geometry but have different positions in the formation. It maintains immutability by returning a new Airplane rather than modifying the existing one.
Only Cg_GP1_CgP1 and its derived cache (_T_pas_G_Cg_to_GP1_CgP1) need to differ from a standard deep copy because (1) Wing geometry (Ler_Gs_Cgs, panels, etc.) is defined relative to this Airplane’s own CG, not the formation position, so it remains valid, (2) Panel local coordinates (_G_Cg) are independent of formation position (global coordinates (_GP1_CgP1) are reset to None by Panel’s __deepcopy__ and will be recomputed by the Problem using the new transformation matrix), and (3) all other child objects (WingCrossSections, Airfoils, vortices) have no dependency on Cg_GP1_CgP1.
- Parameters:
new_Cg_GP1_CgP1 – An array-like object of 3 numbers representing the position of the new Airplane’s CG (in the first Airplane’s geometry axes, relative to the first Airplane’s CG). Can be a list, tuple, or ndarray. Values are converted to floats internally. The units are in meters.
- Returns:
A new Airplane with the specified position and deep copied geometry.
- property num_panels: int¶
The total number of Panels across all Wings.
- Returns:
The total number of Panels.
- property T_pas_G_Cg_to_GP1_CgP1: numpy.ndarray¶
The passive transformation matrix from this Airplane’s geometry axes, relative to this Airplane’s CG to the first Airplane’s geometry axes, relative to the first Airplane’s CG.
Computes the transformation chain: G_Cg > GP1_CgP1. This transformation matrix is used to position Airplanes relative to one another, in problems with more than one Airplane. If this Airplane is the first Airplane (where Cg_GP1_CgP1 = [0, 0, 0]), it returns an identity transformation.
- Returns:
A (4,4) ndarray of floats representing the passive transformation matrix from this Airplane’s geometry axes, relative to its CG to the first Airplane’s geometry axes, relative to its CG.
- draw(save: bool | numpy.bool_ = False, testing: bool | numpy.bool_ = False) None[source]¶
Draws the 3D geometry of this Airplane.
This method provides a convenient way to visualize the Airplane’s Panels without needing to create a solver object first. It shows the Panel’s surfaces in 3D using PyVista.
- Parameters:
save – Set to True to save the image as a WebP. Can be a bool or a numpy bool and will be converted internally to bool. The default value is False.
testing – Set to True to close the image after 1 second, which is useful for running test suites. Can be a bool or a numpy bool and will be converted internally to bool. The default value is False.
- Returns:
None
- get_plottable_data(show: bool | numpy.bool_ = False) list[list[list[numpy.ndarray]]] | None[source]¶
Returns plottable data for this Airplane’s Airfoils’ outlines and mean camber lines.
- Parameters:
show – Determines whether to display the plot. If True, the method displays the plot and returns None. If False, the method returns the data without displaying. Can be a bool or a numpy bool and will be converted internally to a bool. The default is False.
- Returns:
If show is True, returns None. If show is False, returns a list of sub lists (one sub list for each of this Airplane’s Wings). Each sub list contains sub sub lists (one for each of this Wing’s WingCrossSections). Each sub sub list contains two ndarrays. The first ndarray contains points on that WingCrossSection’s Airfoil’s outline and the second contains points on its mean camber line. The points are in geometry axes, relative to the CG. The units are in meters.
- validate_first_airplane_constraints() None[source]¶
Validates that the first Airplane in a simulation has Cg_GP1_CgP1 set to zeros.
This method should be called by SteadyProblem or UnsteadyProblem.
- Returns:
None
- static process_wing_symmetry(wing: pterasoftware.geometry.wing.Wing) list[pterasoftware.geometry.wing.Wing][source]¶
Processes a Wing to determine what type of symmetry it has.
If necessary, it then modifies the Wing. If type 5 symmetry is detected, it also creates a second reflected Wing. Finally, it returns a list of Wings.
- Parameters:
wing – The Wing to process for symmetry analysis and potential modification.
- Returns:
The list of processed Wings. For types 1-4 symmetry it contains only the one modified Wing, but for type 5 symmetry it contains the modified Wing followed by the new reflected Wing. Before returning them, it also calls each Wing’s generate_mesh method, preparing them for use simulation.