pterasoftware.FreeFlightUnsteadyProblem

class pterasoftware.FreeFlightUnsteadyProblem(
*,
movement: FreeFlightMovement,
mass: float | int,
I_BP1_CgP1: np.ndarray | Sequence[Sequence[float | int]],
external_loads_fn: Callable[[OperatingPoint, Airplane], tuple[np.ndarray, np.ndarray]] | None = None,
k_max: int = 20,
integrator: str = 'RK4',
extra_xml: dict[str, str] | None = None,
mujoco_assets: dict[str, bytes] | None = None,
)

A class used to contain problems with coupled unsteady aerodynamics and rigid body dynamics.

Parameters:
  • movement -- The FreeFlightMovement that defines the prescribed Airplane geometry for this FreeFlightUnsteadyProblem. The initial Airplane and OperatingPoint are derived from the FreeFlightMovement at the first time step. The FreeFlightMovement must contain exactly one AirplaneMovement; multi-airplane free flight is not supported in this release.

  • mass -- A number (int or float) representing the mass of the Airplane. It must be greater than zero and will be converted internally to a float. The units are in kilograms. It must satisfy weight == mass * np.linalg.norm(g_E) within floating point tolerance, where weight is the Airplane's weight and g_E is the OperatingPoint's gravitational acceleration, which keeps the Airplane's weight, the supplied mass, and the gravitational field mutually consistent.

  • I_BP1_CgP1 -- An array-like object of numbers (int or float) with shape (3,3) representing the inertia matrix of the Airplane (in the first Airplane's body axes, relative to the first Airplane's CG). It must be symmetric. Can be a tuple, list, or ndarray. Values are converted to floats internally. The units are in kilogram square meters.

  • external_loads_fn -- A callable that computes additional forces and moments to apply to the Airplane during the simulation. It takes an OperatingPoint and an Airplane and returns a tuple of two (3,) ndarrays of floats: the additional force (in wind axes, in Newtons) and the additional moment (in wind axes, relative to the first Airplane's CG, in Newton meters). The return value is validated on the callable's first invocation; a return that is not a pair of (3,) finite numeric vectors raises a descriptive error. The physical correctness of the forces and moments themselves is not checked. Setting this to None applies no additional loads. The default is None. This is the only mechanism for non-aerodynamic loads in free flight: the OperatingPoint's externalFX_W is never applied and must be zero.

  • k_max -- An int giving the maximum number of strongly coupled sub- iterations per free-flight time step. Each time step drives the aerodynamic loads and the rigid body state to mutual consistency with an Aitken-relaxed fixed-point sub-iteration; this caps the iterations spent before the step is accepted. A step that reaches the cap without converging is accepted anyway, with a warning. It must be greater than zero and will be converted internally to an int. Raising it trades more work per step for a tighter solve when convergence is slow, which can happen for a very light vehicle (a large added-mass ratio). The default is 20.

  • integrator -- A str naming the MuJoCo integrator used to advance the rigid body dynamics. It must be one of "Euler", "RK4", "implicit", or "implicitfast". The choice is baked into the generated MuJoCo model XML, so it survives saving and loading. "RK4" is accurate for smooth dynamics but handles contacts poorly, so runs with collision geometry (injected via extra_xml) should prefer "implicit" or "implicitfast". The default is "RK4".

  • extra_xml -- A dict mapping injection point names to XML fragment strings to inject into the MuJoCo model's XML. Supported keys are "default", "asset", "visual", "worldbody", and "body". Setting this to None injects no extra XML. The default is None. The argument is checked to be a dict (or None) whose keys are supported injection points and whose values are strings; the XML fragments themselves are not validated, which is left to MuJoCo, so this is an advanced-user parameter. Any file a fragment references (such as a mesh) must be supplied through mujoco_assets, and construction raises a ValueError if a fragment references an on-disk path instead.

  • mujoco_assets -- A dict mapping virtual filenames to their binary contents for the MuJoCo model. Setting this to None provides no extra assets. The default is None. Each key must be a bare filename with a nonempty extension (for example "body.stl"), with no path separators or drive prefixes, because MuJoCo selects its asset decoder from the extension and machine-specific paths must stay out of saved files. Supply a file by reading its bytes (for example Path("body.stl").read_bytes()) under the virtual filename that the extra_xml fragments reference. Whether a referenced asset is actually supplied is left to MuJoCo, so this is an advanced-user parameter. The assets are serialized into saved files, so a FreeFlightUnsteadyProblem built with mujoco_assets saves and loads without touching the filesystem.

Returns:

None

diagram(
*,
step: int = -1,
show_airplane_axes_and_points: bool | np.bool = True,
show_wing_axes_and_points: bool | np.bool = False,
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,
) → None

Displays a diagram of one time step's SteadyProblem's Airplanes' Wings' Panels, along with their axes and points.

The diagram is the time step's SteadyProblem's diagram, so it is drawn in the first Airplane's geometry axes, relative to the first Airplane's CG, at that time step. It shows the Earth axes at the Earth origin and every Wing's Panels. The units are in meters.

Some problems, such as AeroelasticUnsteadyProblems and FreeFlightUnsteadyProblems, create each time step's SteadyProblem while they are solved, so before then only the first time step can be drawn. If step is negative and some time steps' SteadyProblems haven't been created yet, a warning is logged, because step then counts back from the last time step created so far rather than from the last time step.

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:
  • step -- The time step to draw, as an index into this problem's SteadyProblems. Negative values count back from the last one, so the default of -1 draws the last time step whose SteadyProblem has been created. It must be an int in the range from negative the number of SteadyProblems created so far, inclusive, to that number, exclusive.

  • show_airplane_axes_and_points -- Determines whether to draw each Airplane's geometry axes at its CG. Can be a bool or a numpy bool and will be converted internally to a bool. The default is True.

  • 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 False.

  • 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 and its Airplane's numbers (such as "Cppr3c2Wn1P2"). 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

property finalCrosswindForceCoefficients_W: list[float]

The final crosswind force coefficient experienced by each Airplane (in wind axes).

Crosswind force coefficient corresponds to the wind axes' -y basis direction, so each entry is the negative of the corresponding finalForceCoefficients_W entry's y component.

Returns:

The final crosswind force coefficients, one entry per Airplane. Empty if finalForceCoefficients_W has not been populated.

property finalCrosswindForces_W: list[float]

The final crosswind force experienced by each Airplane (in wind axes).

Crosswind force points along the wind axes' -y basis direction, so each entry is the negative of the corresponding finalForces_W entry's y component.

Returns:

The final crosswind forces in Newtons, one entry per Airplane. Empty if finalForces_W has not been populated.

property finalInducedDragCoefficients_W: list[float]

The final induced drag force coefficient experienced by each Airplane (in wind axes).

Induced drag coefficient corresponds to the wind axes' -x basis direction, so each entry is the negative of the corresponding finalForceCoefficients_W entry's x component.

Returns:

The final induced drag coefficients, one entry per Airplane. Empty if finalForceCoefficients_W has not been populated.

property finalInducedDrags_W: list[float]

The final induced drag force experienced by each Airplane (in wind axes).

Induced drag points along the wind axes' -x basis direction, so each entry is the negative of the corresponding finalForces_W entry's x component.

Returns:

The final induced drag forces in Newtons, one entry per Airplane. Empty if finalForces_W has not been populated.

property finalLiftCoefficients_W: list[float]

The final lift force coefficient experienced by each Airplane (in wind axes).

Lift coefficient corresponds to the wind axes' -z basis direction, so each entry is the negative of the corresponding finalForceCoefficients_W entry's z component.

Returns:

The final lift coefficients, one entry per Airplane. Empty if finalForceCoefficients_W has not been populated.

property finalLifts_W: list[float]

The final lift force experienced by each Airplane (in wind axes).

Lift points along the wind axes' -z basis direction, so each entry is the negative of the corresponding finalForces_W entry's z component.

Returns:

The final lift forces in Newtons, one entry per Airplane. Empty if finalForces_W has not been populated.

property finalMeanCrosswindForceCoefficients_W: list[float]

The final cycle averaged crosswind force coefficient experienced by each Airplane (in wind axes).

Crosswind force coefficient corresponds to the wind axes' -y basis direction, so each entry is the negative of the corresponding finalMeanForceCoefficients_W entry's y component.

Returns:

The final cycle averaged crosswind force coefficients, one entry per Airplane. Empty if finalMeanForceCoefficients_W has not been populated.

property finalMeanCrosswindForces_W: list[float]

The final cycle averaged crosswind force experienced by each Airplane (in wind axes).

Crosswind force points along the wind axes' -y basis direction, so each entry is the negative of the corresponding finalMeanForces_W entry's y component.

Returns:

The final cycle averaged crosswind forces in Newtons, one entry per Airplane. Empty if finalMeanForces_W has not been populated.

property finalMeanInducedDragCoefficients_W: list[float]

The final cycle averaged induced drag force coefficient experienced by each Airplane (in wind axes).

Induced drag coefficient corresponds to the wind axes' -x basis direction, so each entry is the negative of the corresponding finalMeanForceCoefficients_W entry's x component.

Returns:

The final cycle averaged induced drag coefficients, one entry per Airplane. Empty if finalMeanForceCoefficients_W has not been populated.

property finalMeanInducedDrags_W: list[float]

The final cycle averaged induced drag force experienced by each Airplane (in wind axes).

Induced drag points along the wind axes' -x basis direction, so each entry is the negative of the corresponding finalMeanForces_W entry's x component.

Returns:

The final cycle averaged induced drag forces in Newtons, one entry per Airplane. Empty if finalMeanForces_W has not been populated.

property finalMeanLiftCoefficients_W: list[float]

The final cycle averaged lift force coefficient experienced by each Airplane (in wind axes).

Lift coefficient corresponds to the wind axes' -z basis direction, so each entry is the negative of the corresponding finalMeanForceCoefficients_W entry's z component.

Returns:

The final cycle averaged lift coefficients, one entry per Airplane. Empty if finalMeanForceCoefficients_W has not been populated.

property finalMeanLifts_W: list[float]

The final cycle averaged lift force experienced by each Airplane (in wind axes).

Lift points along the wind axes' -z basis direction, so each entry is the negative of the corresponding finalMeanForces_W entry's z component.

Returns:

The final cycle averaged lift forces in Newtons, one entry per Airplane. Empty if finalMeanForces_W has not been populated.

property finalMeanPitchingMomentCoefficients_W_Cg: list[float]

The final cycle averaged pitching moment coefficient experienced by each Airplane (in wind axes, relative to its own CG).

Pitching moment coefficient corresponds to the wind axes' +y basis direction, so each entry equals the corresponding finalMeanMomentCoefficients_W_Cg entry's y component.

Returns:

The final cycle averaged pitching moment coefficients, one entry per Airplane. Empty if finalMeanMomentCoefficients_W_Cg has not been populated.

property finalMeanPitchingMoments_W_Cg: list[float]

The final cycle averaged pitching moment experienced by each Airplane (in wind axes, relative to its own CG).

Pitching moment acts about the wind axes' +y basis direction, so each entry equals the corresponding finalMeanMoments_W_Cg entry's y component.

Returns:

The final cycle averaged pitching moments in Newton-meters, one entry per Airplane. Empty if finalMeanMoments_W_Cg has not been populated.

property finalMeanRollingMomentCoefficients_W_Cg: list[float]

The final cycle averaged rolling moment coefficient experienced by each Airplane (in wind axes, relative to its own CG).

Rolling moment coefficient corresponds to the wind axes' +x basis direction, so each entry equals the corresponding finalMeanMomentCoefficients_W_Cg entry's x component.

Returns:

The final cycle averaged rolling moment coefficients, one entry per Airplane. Empty if finalMeanMomentCoefficients_W_Cg has not been populated.

property finalMeanRollingMoments_W_Cg: list[float]

The final cycle averaged rolling moment experienced by each Airplane (in wind axes, relative to its own CG).

Rolling moment acts about the wind axes' +x basis direction, so each entry equals the corresponding finalMeanMoments_W_Cg entry's x component.

Returns:

The final cycle averaged rolling moments in Newton-meters, one entry per Airplane. Empty if finalMeanMoments_W_Cg has not been populated.

property finalMeanYawingMomentCoefficients_W_Cg: list[float]

The final cycle averaged yawing moment coefficient experienced by each Airplane (in wind axes, relative to its own CG).

Yawing moment coefficient corresponds to the wind axes' +z basis direction, so each entry equals the corresponding finalMeanMomentCoefficients_W_Cg entry's z component.

Returns:

The final cycle averaged yawing moment coefficients, one entry per Airplane. Empty if finalMeanMomentCoefficients_W_Cg has not been populated.

property finalMeanYawingMoments_W_Cg: list[float]

The final cycle averaged yawing moment experienced by each Airplane (in wind axes, relative to its own CG).

Yawing moment acts about the wind axes' +z basis direction, so each entry equals the corresponding finalMeanMoments_W_Cg entry's z component.

Returns:

The final cycle averaged yawing moments in Newton-meters, one entry per Airplane. Empty if finalMeanMoments_W_Cg has not been populated.

property finalPitchingMomentCoefficients_W_Cg: list[float]

The final pitching moment coefficient experienced by each Airplane (in wind axes, relative to its own CG).

Pitching moment coefficient corresponds to the wind axes' +y basis direction, so each entry equals the corresponding finalMomentCoefficients_W_Cg entry's y component.

Returns:

The final pitching moment coefficients, one entry per Airplane. Empty if finalMomentCoefficients_W_Cg has not been populated.

property finalPitchingMoments_W_Cg: list[float]

The final pitching moment experienced by each Airplane (in wind axes, relative to its own CG).

Pitching moment acts about the wind axes' +y basis direction, so each entry equals the corresponding finalMoments_W_Cg entry's y component.

Returns:

The final pitching moments in Newton-meters, one entry per Airplane. Empty if finalMoments_W_Cg has not been populated.

property finalRollingMomentCoefficients_W_Cg: list[float]

The final rolling moment coefficient experienced by each Airplane (in wind axes, relative to its own CG).

Rolling moment coefficient corresponds to the wind axes' +x basis direction, so each entry equals the corresponding finalMomentCoefficients_W_Cg entry's x component.

Returns:

The final rolling moment coefficients, one entry per Airplane. Empty if finalMomentCoefficients_W_Cg has not been populated.

property finalRollingMoments_W_Cg: list[float]

The final rolling moment experienced by each Airplane (in wind axes, relative to its own CG).

Rolling moment acts about the wind axes' +x basis direction, so each entry equals the corresponding finalMoments_W_Cg entry's x component.

Returns:

The final rolling moments in Newton-meters, one entry per Airplane. Empty if finalMoments_W_Cg has not been populated.

property finalYawingMomentCoefficients_W_Cg: list[float]

The final yawing moment coefficient experienced by each Airplane (in wind axes, relative to its own CG).

Yawing moment coefficient corresponds to the wind axes' +z basis direction, so each entry equals the corresponding finalMomentCoefficients_W_Cg entry's z component.

Returns:

The final yawing moment coefficients, one entry per Airplane. Empty if finalMomentCoefficients_W_Cg has not been populated.

property finalYawingMoments_W_Cg: list[float]

The final yawing moment experienced by each Airplane (in wind axes, relative to its own CG).

Yawing moment acts about the wind axes' +z basis direction, so each entry equals the corresponding finalMoments_W_Cg entry's z component.

Returns:

The final yawing moments in Newton-meters, one entry per Airplane. Empty if finalMoments_W_Cg has not been populated.