pterasoftware.Airplane¶
- class pterasoftware.Airplane(
- *,
- wings: list[Wing],
- name: str = 'Untitled Airplane',
- Cg_GP1_CgP1: np.ndarray | 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,
A class used to contain airplanes.
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).
The reference planform supplies the default reference dimensions. It is the planform of the first element of the wings passed to the Airplane, including its mirrored half if it has type 4 symmetry, or the reflected Wing that symmetry processing creates for it if it has type 5 symmetry. It is built from the set geometry, in geometry axes, as a set of strips. For a Wing built from WingCrossSections, each strip joins two neighboring WingCrossSections' leading points and undeflected trailing points, so control surface deflections have no effect. An edge_defined Wing's whole half is one strip, bounded by its stored, untrimmed leading and trailing edge curves. For type 5 symmetry, one more strip joins the two halves' root chords, filling any gap between them. The strips are then projected onto the geometry axes' xy plane. The default s_ref is the sum of the strips' projected areas, the default b_ref is the extent of all the strips' points along the geometry axes' y axis, and the default c_ref is the mean aerodynamic chord: the integral of the square of the projected chord along the geometry axes' y axis, divided by the default s_ref. A strip that is edge-on in the projection, such as a vertical winglet, contributes nothing to s_ref or c_ref.
Computing the defaults raises a ValueError in two cases. The first is when the reference planform is too steeply inclined: its area projected onto the geometry axes' xy plane is less than 1 / sqrt(2) times its area projected onto the xy plane of the wing axes of the first element of wings (for type 5 symmetry, both areas leave out the strip joining the halves). The second is when the reference planform's projection is ill-formed: a strip crosses over itself, two strips overlap, or, for type 5 symmetry, the two halves overlap along the geometry axes' y axis. In either case, s_ref, c_ref, and b_ref must all be passed explicitly.
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 load attributes remain mutable as they are set by the solver during simulation. The forces_W, forceCoefficients_W, moments_W_CgP1, and momentCoefficients_W_CgP1 attributes hold the total force (in wind axes), the total moment (in wind axes, relative to the first Airplane's CG), and their coefficients. The forces_G, forceCoefficients_G, moments_G_Cg, momentCoefficients_G_Cg, moments_W_Cg, and momentCoefficients_W_Cg attributes hold the total force (in geometry axes), the total moment (in geometry axes, relative to the CG), the total moment (in wind axes, relative to the CG), and their coefficients. Because every Airplane's geometry axes are parallel to the first Airplane's geometry axes, the components of forces_G equal the components of the total force (in the first Airplane's geometry axes). For the first Airplane, moments_W_Cg equals moments_W_CgP1, and momentCoefficients_W_Cg equals momentCoefficients_W_CgP1.
Citations:
Adapted from: geometry.Airplane in AeroSandbox
Author: Peter Sharpe
Date of retrieval: 04/23/2020
Reference area, span, and mean aerodynamic chord conventions adapted from: Section 6.1 of "Flight Vehicle Aerodynamics" (2014)
Author: Mark Drela
Date of retrieval: 09/23/2026
Reference area and span conventions adapted from: Section 2.2 of "Aircraft Control and Simulation" (third edition, 2016)
Authors: Brian L. Stevens, Frank L. Lewis, and Eric N. Johnson
Date of retrieval: 09/23/2026
- 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 * np.linalg.norm(g_E) within floating point tolerance.
s_ref -- A number (int or float) representing the reference area. If not set or set to None (the default), it populates from the projected area of the reference planform, as described in the class docstring. If set, it must be greater than zero, and will be converted to a float internally. The units are square meters. Airplanes derived from this one (those at each time step of an unsteady simulation, those refined by a convergence analysis, and those tried by a trim analysis) inherit the resulting value rather than recomputing it from their own Wings, so all of their load coefficients share one normalization.
c_ref -- A number (int or float) representing the reference chord length. If not set or set to None (the default), it populates from the mean aerodynamic chord of the projected reference planform, as described in the class docstring. If set, it must be greater than zero, and will be converted to a float internally. The units are meters. Derived Airplanes inherit the resulting value in the same way as s_ref.
b_ref -- A number (int or float) representing the reference span. If not set or set to None (the default value), it populates from the span of the projected reference planform, as described in the class docstring. If set, it must be greater than zero, and will be converted to a float internally. The units are meters. Derived Airplanes inherit the resulting value in the same way as s_ref.
- 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.
- property inducedDrag_W: float | None¶
The total induced drag force experienced by this Airplane (in wind axes).
Induced drag points along the wind axes' -x basis direction, so it is the negative of the wind axes' x force component.
- Returns:
The induced drag force in Newtons, or None if forces_W has not been set.
- property crosswindForce_W: float | None¶
The total crosswind force experienced by this Airplane (in wind axes).
Crosswind force points along the wind axes' -y basis direction, so it is the negative of the wind axes' y force component.
- Returns:
The crosswind force in Newtons, or None if forces_W has not been set.
- property lift_W: float | None¶
The total lift force experienced by this Airplane (in wind axes).
Lift points along the wind axes' -z basis direction, so it is the negative of the wind axes' z force component.
- Returns:
The lift force in Newtons, or None if forces_W has not been set.
- property inducedDragCoefficient_W: float | None¶
The total induced drag force coefficient experienced by this Airplane (in wind axes).
Induced drag coefficient corresponds to the wind axes' -x basis direction, so it is the negative of the wind axes' x force coefficient component.
- Returns:
The induced drag coefficient, or None if forceCoefficients_W has not been set.
- property crosswindForceCoefficient_W: float | None¶
The total crosswind force coefficient experienced by this Airplane (in wind axes).
Crosswind force coefficient corresponds to the wind axes' -y basis direction, so it is the negative of the wind axes' y force coefficient component.
- Returns:
The crosswind force coefficient, or None if forceCoefficients_W has not been set.
- property liftCoefficient_W: float | None¶
The total lift force coefficient experienced by this Airplane (in wind axes).
Lift coefficient corresponds to the wind axes' -z basis direction, so it is the negative of the wind axes' z force coefficient component.
- Returns:
The lift coefficient, or None if forceCoefficients_W has not been set.
- property rollingMoment_W_Cg: float | None¶
The total rolling moment experienced by this Airplane (in wind axes, relative to the CG).
Rolling moment acts about the wind axes' +x basis direction, so it equals the wind axes' x moment component.
- Returns:
The rolling moment in Newton-meters, or None if moments_W_Cg has not been set.
- property pitchingMoment_W_Cg: float | None¶
The total pitching moment experienced by this Airplane (in wind axes, relative to the CG).
Pitching moment acts about the wind axes' +y basis direction, so it equals the wind axes' y moment component.
- Returns:
The pitching moment in Newton-meters, or None if moments_W_Cg has not been set.
- property yawingMoment_W_Cg: float | None¶
The total yawing moment experienced by this Airplane (in wind axes, relative to the CG).
Yawing moment acts about the wind axes' +z basis direction, so it equals the wind axes' z moment component.
- Returns:
The yawing moment in Newton-meters, or None if moments_W_Cg has not been set.
- property rollingMomentCoefficient_W_Cg: float | None¶
The total rolling moment coefficient experienced by this Airplane (in wind axes, relative to the CG).
Rolling moment coefficient corresponds to the wind axes' +x basis direction, so it equals the wind axes' x moment coefficient component.
- Returns:
The rolling moment coefficient, or None if momentCoefficients_W_Cg has not been set.
- property pitchingMomentCoefficient_W_Cg: float | None¶
The total pitching moment coefficient experienced by this Airplane (in wind axes, relative to the CG).
Pitching moment coefficient corresponds to the wind axes' +y basis direction, so it equals the wind axes' y moment coefficient component.
- Returns:
The pitching moment coefficient, or None if momentCoefficients_W_Cg has not been set.
- property yawingMomentCoefficient_W_Cg: float | None¶
The total yawing moment coefficient experienced by this Airplane (in wind axes, relative to the CG).
Yawing moment coefficient corresponds to the wind axes' +z basis direction, so it equals the wind axes' z moment coefficient component.
- Returns:
The yawing moment coefficient, or None if momentCoefficients_W_Cg has not been set.
- diagram(
- *,
- show_wing_axes_and_points: bool | np.bool = True,
- show_wing_cross_section_axes_and_points: bool | np.bool = False,
- show_airfoil_axes_and_points: bool | np.bool = False,
- show_airfoils: bool | np.bool = False,
- show_mcls: bool | np.bool = False,
- show_collocation_points: bool | np.bool = False,
- label_collocation_points: bool | np.bool = False,
- math_labels: bool | np.bool = False,
- save: bool | np.bool = False,
- path: str | Path = 'diagram.webp',
- quality: int | float = 75.0,
Displays a diagram of this Airplane's Wings' Panels, along with its axes and points.
The diagram is drawn in geometry axes, relative to the CG. It shows the geometry axes at the CG and every Wing's Panels. The units are in meters.
A label can be edited by double-clicking it in the diagram's window. Its raw text is then shown in a monospaced font with a caret, which the left and right arrow keys move. Enter keeps the new text, Escape restores the old text, and entering empty text deletes the label. Text between pairs of dollar signs is written as math in Matplotlib's mathtext syntax, and the label is shown in red while that math isn't valid.
- Parameters:
show_wing_axes_and_points -- Determines whether to draw each Wing's axes at its leading edge root point. Can be a bool or a numpy bool and will be converted internally to a bool. The default is True.
show_wing_cross_section_axes_and_points -- Determines whether to draw each WingCrossSection's axes at its leading point. Can be a bool or a numpy bool and will be converted internally to a bool. The default is False.
show_airfoil_axes_and_points -- Determines whether to draw each WingCrossSection's Airfoil's axes at its leading point. Can be a bool or a numpy bool and will be converted internally to a bool. The default is False.
show_airfoils -- Determines whether to draw each WingCrossSection's Airfoil's outline and mean camber line. Can be a bool or a numpy bool and will be converted internally to a bool. The default is False.
show_mcls -- Determines whether to draw each Airfoil's mean camber line. It has no effect if show_airfoils is False. Can be a bool or a numpy bool and will be converted internally to a bool. The default is False.
show_collocation_points -- Determines whether to draw the Wings' Panels' collocation points. The labels number each Panel by its chordwise row and spanwise column, starting at one, followed by its Wing's number (such as "Cppr3c2Wn1"). Can be a bool or a numpy bool and will be converted internally to a bool. The default is False.
label_collocation_points -- Determines whether to label the collocation points. If False, they are still marked. It has no effect if show_collocation_points is False. Can be a bool or a numpy bool and will be converted internally to a bool. The default is False.
math_labels -- Determines whether to write the axes and point labels as math, set in the STIX font. Each basis direction arrow is then labeled with a unit vector whose superscript lists its axes' abbreviations, and each point with its name in capitals, whose subscript lists what it belongs to, if anything. If False, each label is the plain ID, set in a monospaced font. Can be a bool or a numpy bool and will be converted internally to a bool. The default is False.
save -- Determines whether to save the diagram as a WebP with a white background once its window is closed, which keeps the view's orientation and any labels dragged by hand. Can be a bool or a numpy bool and will be converted internally to a bool. The default is False.
path -- The file path to save the diagram to. It can be a str or a Path, must end with ".webp", and its directory must already exist. It has no effect if save is False. The default is "diagram.webp".
quality -- The quality of the saved WebP, where 0.0 is the smallest file with the most compression artifacts and 100.0 is the largest file with the fewest. It can be an int or a float and will be converted internally to a float. It has no effect if save is False. The default is 75.0.
- Returns:
None