pterasoftware.output

Contains functions for visualizing geometry and results.

Functions

draw

Draws a solver’s Airplane(s).

animate

Animates the Airplane(s) of an UnsteadyRingVortexLatticeMethodSolver or one of its subclasses (the aeroelastic or free flight solver).

plot_results_versus_time

Plots the loads and load coefficients of an UnsteadyRingVortexLatticeMethodSolver or one of its subclasses (the aeroelastic or free flight solver) as a function of time.

log_results

Logs a solver’s load and load coefficients.

Module Contents

pterasoftware.output.draw(
solver: pterasoftware.steady_horseshoe_vortex_lattice_method.SteadyHorseshoeVortexLatticeMethodSolver | pterasoftware.steady_ring_vortex_lattice_method.SteadyRingVortexLatticeMethodSolver | pterasoftware.unsteady_ring_vortex_lattice_method.UnsteadyRingVortexLatticeMethodSolver,
scalar_type: str | None = None,
show_streamlines: bool | numpy.bool_ = False,
show_wake_vortices: bool | numpy.bool_ = False,
show_mujoco_geometry: bool | numpy.bool_ = False,
window_size: collections.abc.Sequence[int] = (1024, 768),
save: bool | numpy.bool_ = False,
path: str | pathlib.Path = 'draw.webp',
quality: int | float = 75.0,
testing: bool | numpy.bool_ = False,
) None

Draws a solver’s Airplane(s).

For a FreeFlightUnsteadyRingVortexLatticeMethodSolver, the final time step’s geometry is rendered in Earth axes at its true position and orientation, so the body’s flight attitude is visible, rather than being drawn body-fixed in geometry axes.

Citation:

Adapted from: vlm3.draw in AeroSandbox

Author: Peter Sharpe

Date of retrieval: 03/28/2020

Parameters:
  • solver – The solver whose Airplane(s) will be plotted. This can be a SteadyHorseshoeVortexLatticeMethodSolver, a SteadyRingVortexLatticeMethodSolver, or an UnsteadyRingVortexLatticeMethodSolver. The UnsteadyRingVortexLatticeMethodSolver’s subclasses, the AeroelasticUnsteadyRingVortexLatticeMethodSolver and the FreeFlightUnsteadyRingVortexLatticeMethodSolver, are also accepted.

  • scalar_type – Determines how to color the Panels. Setting this to None colors the Panels uniformly. If the solver has been run, it can also be “induced drag”, “side force”, or “lift”, which respectively use each Panel’s induced drag, side force, and lift coefficient. The default is None.

  • show_streamlines – Set this to True to show the streamlines emanating from the back of the Wings. If True, the solver’s streamlines must have already been calculated. Can be a bool or a numpy bool and will be converted internally to a bool. The default is False.

  • show_wake_vortices – Set this to True to show any wake ring vortices. If True, the solver must be an UnsteadyRingVortexLatticeMethodSolver and must have already been run. Can be a bool or a numpy bool and will be converted internally to a bool. The default is False.

  • show_mujoco_geometry – Set this to True to show the MuJoCo geometry that extra_xml and mujoco_assets inject into the solver’s model, with body geoms posed at the drawn time step and worldbody geoms static in Earth axes. If True, the solver must be a FreeFlightUnsteadyRingVortexLatticeMethodSolver. Can be a bool or a numpy bool and will be converted internally to a bool. The default is False.

  • window_size – The width and height, in pixels, of the render window. This also sets the resolution of the saved WebP. It must be a sequence of two positive ints, and, when rendering on screen, must fit within the area the window manager grants, which is the display less any docks or bars and less the window’s own title bar. The text and line widths scale with it, so a larger or smaller window is legible rather than being drawn with the same pixel counts as the default. The default is (1024, 768).

  • save – Set this to True to save the image as a WebP. It 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 image to. It can be a str or a Path, must end with ‘.webp’, and its directory must already exist. This has no effect unless save is True. The default is “draw.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. This has no effect unless save is True. The default is 75.0.

  • testing – Set this to True to close the image after one second, which is useful for running test suites. It can be a bool or a numpy bool and will be converted internally to a bool. The default is False.

Returns:

None

pterasoftware.output.animate(
unsteady_solver: pterasoftware.unsteady_ring_vortex_lattice_method.UnsteadyRingVortexLatticeMethodSolver,
scalar_type: str | None = None,
show_wake_vortices: bool | numpy.bool_ = False,
show_mujoco_geometry: bool | numpy.bool_ = False,
window_size: collections.abc.Sequence[int] = (1024, 768),
save: bool | numpy.bool_ = False,
path: str | pathlib.Path = 'animate.webp',
quality: int | float = 75.0,
speed: int | float | None = None,
testing: bool | numpy.bool_ = False,
) None

Animates the Airplane(s) of an UnsteadyRingVortexLatticeMethodSolver or one of its subclasses (the aeroelastic or free flight solver).

For a FreeFlightUnsteadyRingVortexLatticeMethodSolver, each time step’s geometry is rendered in Earth axes at its true position and orientation, so the body flies through the scene along its trajectory rather than staying fixed while the wake streams behind it. The camera frames the whole trajectory.

Parameters:
  • unsteady_solver – The UnsteadyRingVortexLatticeMethodSolver whose Airplane(s) will be animated. Its subclasses, the AeroelasticUnsteadyRingVortexLatticeMethodSolver and the FreeFlightUnsteadyRingVortexLatticeMethodSolver, are also accepted.

  • scalar_type – Determines how to color the Panels. Setting this to None colors the Panels uniformly. If the solver has been run, it can also be “induced drag”, “side force”, or “lift”, which respectively use each Panel’s induced drag, side force, and lift coefficient. The default is None.

  • show_wake_vortices – Set this to True to show any wake ring vortices. If True, the solver must have already been run. Can be a bool or a numpy bool and will be converted internally to a bool. The default is False.

  • show_mujoco_geometry – Set this to True to show the MuJoCo geometry that extra_xml and mujoco_assets inject into the solver’s model, with body geoms re- posed every time step and worldbody geoms static in Earth axes. If True, the unsteady_solver must be a FreeFlightUnsteadyRingVortexLatticeMethodSolver. Can be a bool or a numpy bool and will be converted internally to a bool. The default is False.

  • window_size – The width and height, in pixels, of the render window. This also sets the resolution of the saved WebP. It must be a sequence of two positive ints, and, when rendering on screen, must fit within the area the window manager grants, which is the display less any docks or bars and less the window’s own title bar. The text and line widths scale with it, so a larger or smaller window is legible rather than being drawn with the same pixel counts as the default. The default is (1024, 768).

  • save – Set this to True to save the animation as an animated WebP. It 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 animation to. It can be a str or a Path, must end with ‘.webp’, and its directory must already exist. This has no effect unless save is True. The default is “animate.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. This has no effect unless save is True. The default is 75.0.

  • speed – The playback speed of the saved animation, as a multiple of real time, where 1.0 plays the simulation at true speed and 0.5 plays it at half speed. Setting this to None plays at true speed, slowing the animation down only when true speed would need more than 50.0 frames per second, which is the fastest some programs will render a WebP. Any speed that would need more than 50.0 frames per second is instead reached by saving only every Nth frame, which trades the animation’s temporal resolution for its speed. It can be an int or a float, must be positive, and will be converted internally to a float. A speed so slow that the animation would save fewer than one frame per second of playback, or so fast that it would save fewer than two frames in total, is rejected. This has no effect unless save is True. The default is None.

  • testing – Set this to True to start the animation after one second, which is useful for running test suites. It can be a bool or a numpy bool and will be converted internally to a bool. The default is False.

Returns:

None

pterasoftware.output.plot_results_versus_time(
unsteady_solver: pterasoftware.unsteady_ring_vortex_lattice_method.UnsteadyRingVortexLatticeMethodSolver,
show: bool | numpy.bool_ = True,
figure_size_in: collections.abc.Sequence[int | float] = (6.4, 4.8),
save: bool | numpy.bool_ = False,
save_csv: bool | numpy.bool_ = False,
directory: str | pathlib.Path = '.',
prefix: str = '',
resolution_dpi: int | float = 300.0,
) None

Plots the loads and load coefficients of an UnsteadyRingVortexLatticeMethodSolver or one of its subclasses (the aeroelastic or free flight solver) as a function of time.

For a FreeFlightUnsteadyRingVortexLatticeMethodSolver, this also plots the first Airplane’s six-degree-of-freedom state history: its position, velocity, orientation, angular velocity, and aerodynamic angles versus time. These describe the first Airplane, the rigid body the dynamics integrate, so they are plotted once for the whole simulation rather than per Airplane.

Each file is named after the Airplane it describes, so an Airplane whose name holds a path separator is rejected when save or save_csv is True. Such a name would compose a destination outside the directory that was asked for.

Parameters:
  • unsteady_solver – The UnsteadyRingVortexLatticeMethodSolver whose loads and load coefficients will be plotted. Its subclasses, the AeroelasticUnsteadyRingVortexLatticeMethodSolver and the FreeFlightUnsteadyRingVortexLatticeMethodSolver, are also accepted. For a FreeFlightUnsteadyRingVortexLatticeMethodSolver, the first Airplane’s state history is plotted as well.

  • show – Set this to True to show the plots. It can be a bool or a numpy bool and will be converted internally to a bool. The default is True.

  • figure_size_in – The width and height, in inches, of each figure. Multiplying this by resolution_dpi gives the resolution of each saved PNG. It must be a sequence of two positive numbers. The default is (6.4, 4.8), which is Matplotlib’s own default.

  • save – Set this to True to save the plots as PNGs. It can be a bool or a numpy bool and will be converted internally to a bool. The default is False.

  • save_csv – Set this to True to save the plotted data as CSVs, which is independent of save, so the data can be exported without rendering any images. One file holds the loads and load coefficients of each Airplane, and, for a FreeFlightUnsteadyRingVortexLatticeMethodSolver, a second holds the first Airplane’s state history. The two are separate files because the load histories begin at the solver’s first results step while the state history begins at time step 0, so they have different numbers of rows. It can be a bool or a numpy bool and will be converted internally to a bool. The default is False.

  • directory – The directory to save the PNGs and CSVs in. It can be a str or a Path and must already exist. This has no effect unless save or save_csv is True. The default is “.”, the current working directory.

  • prefix – A prefix to prepend to each file’s name, which distinguishes one run’s output from another’s. It must be a str and must be a file name component rather than a path. With the default, an empty string, each file is named after its Airplane and the quantity it holds, as in “example_airplane_forces.png”. With a non-empty prefix, each name becomes “<prefix>_<airplane>_<quantity>.<ext>”. The Airplane’s name is included either way, since dropping it would collide across the Airplanes of a formation simulation. This has no effect unless save or save_csv is True.

  • resolution_dpi – The dots per inch at which to save each PNG. It can be an int or a float and will be converted internally to a float. This has no effect unless save is True. The default is 300.0.

Returns:

None

pterasoftware.output.log_results(
solver: pterasoftware.steady_horseshoe_vortex_lattice_method.SteadyHorseshoeVortexLatticeMethodSolver | pterasoftware.steady_ring_vortex_lattice_method.SteadyRingVortexLatticeMethodSolver | pterasoftware.unsteady_ring_vortex_lattice_method.UnsteadyRingVortexLatticeMethodSolver,
) None

Logs a solver’s load and load coefficients.

The logging level must be set to INFO or lower in order to see results. See set_up_logging for details on configuring the logging level.

For a FreeFlightUnsteadyRingVortexLatticeMethodSolver, this also logs the first Airplane’s initial and final six-degree-of-freedom state: its position, velocity, orientation, angular velocity, and aerodynamic angles.

Parameters:

solver – The solver whose load and load coefficients will be logged. This can be a SteadyHorseshoeVortexLatticeMethodSolver, a SteadyRingVortexLatticeMethodSolver, or an UnsteadyRingVortexLatticeMethodSolver. The UnsteadyRingVortexLatticeMethodSolver’s subclasses, the AeroelasticUnsteadyRingVortexLatticeMethodSolver and the FreeFlightUnsteadyRingVortexLatticeMethodSolver, are also accepted. For a FreeFlightUnsteadyRingVortexLatticeMethodSolver, the first Airplane’s initial and final state is logged as well.

Returns:

None