pterasoftware.trim

Contains functions to analyze the trim conditions of SteadyProblems and UnsteadyProblems.

Functions

analyze_steady_trim

Attempts to calculate a trim condition of a SteadyProblem by varying the operating conditions until the net loads are sufficiently low.

analyze_unsteady_trim

Attempts to calculate a trim condition of an UnsteadyProblem by varying the base operating conditions until the net loads are sufficiently low.

Module Contents

pterasoftware.trim.analyze_steady_trim(problem: pterasoftware.problems.SteadyProblem, solver_type: str, boundsVCg__E: tuple[float | int, float | int], alpha_bounds: tuple[float | int, float | int], beta_bounds: tuple[float | int, float | int], boundsExternalFX_W: tuple[float | int, float | int], objective_cut_off: float | int = 0.01, num_calls: int = 100) tuple[float, float, float, float] | tuple[None, None, None, None][source]

Attempts to calculate a trim condition of a SteadyProblem by varying the operating conditions until the net loads are sufficiently low.

Procedure:

Trim is found by minimizing an objective function that combines the net load coefficients’ magnitudes.

The optimization process varies four parameters (vCg__E, alpha, beta, and externalFX_W) within their specified bounds. At each iteration, a steady solver is run to compute aerodynamic loads. These loads are combined with the external loads to compute a net load coefficient.

The function uses a two-stage optimization approach: first attempting a local search using L-BFGS-B, and if that fails to converge, it performs a global search using dual annealing.

The search terminates early if the objective function falls below the specified cutoff value. If no trim condition is found within the maximum number of function calls, the function returns None values and logs a critical error.

Parameters:
  • problem – The SteadyProblem whose trim condition will be found. It must contain exactly one Airplane. The problem’s OperatingPoint will be modified during the trim search.

  • solver_type – Determines what type of steady solver will be used to analyze the SteadyProblem. The options are “steady horseshoe vortex lattice method” and “steady ring vortex lattice method”.

  • boundsVCg__E – A tuple of two positive numbers (ints or floats), in ascending order, determining the range of speeds of the Airplane’s CG (in the Earth frame) to search. The SteadyProblem’s OperatingPoint’s initial vCg__E must be within these bounds. Values are converted to floats internally. The units are in meters per second.

  • alpha_bounds – A tuple of two numbers (ints or floats), in ascending order, determining the range of angles of attack to search. The SteadyProblem’s OperatingPoint’s initial alpha must be within these bounds. Values are converted to floats internally. The units are in degrees.

  • beta_bounds – A tuple of two numbers (ints or floats), in ascending order, determining the range of sideslip angles to search. The SteadyProblem’s OperatingPoint’s initial beta must be within these bounds. Values are converted to floats internally. The units are in degrees.

  • boundsExternalFX_W – A tuple of two numbers (ints or floats), in ascending order, determining the range of external forces (in the wind axes’ x direction) to search. The SteadyProblem’s OperatingPoint’s initial externalFX_W must be within these bounds. Values are converted to floats internally. The units are in Newtons.

  • objective_cut_off – A positive number (int or float) for the trim search’s convergence threshold. When the objective function falls below this value, the search terminates successfully. Lower values result in tighter trim conditions but may require more iterations. Values are converted to floats internally. The default is 0.01.

  • num_calls – A positive int for the maximum number of objective function evaluations allowed during optimization. This limit applies separately to the local search and global search stages. Higher values allow for more thorough searching but increase computation time. The default is 100.

Returns:

A tuple of four floats representing the trimmed parameters found. In order, they are: vCg__E (in meters per second), alpha (in degrees), beta (in degrees), and externalFX_W (in Newtons). If no trim condition was found, it will instead return a tuple of four Nones.

pterasoftware.trim.analyze_unsteady_trim(problem: pterasoftware.problems.UnsteadyProblem, boundsVCg__E: tuple[float | int, float | int], alpha_bounds: tuple[float | int, float | int], beta_bounds: tuple[float | int, float | int], boundsExternalFX_W: tuple[float | int, float | int], objective_cut_off: float | int = 0.01, num_calls: int = 100, show_solver_progress: bool | numpy.bool_ = True) tuple[float, float, float, float] | tuple[None, None, None, None][source]

Attempts to calculate a trim condition of an UnsteadyProblem by varying the base operating conditions until the net loads are sufficiently low.

Procedure:

Trim is found by minimizing an objective function that combines the net final load coefficients’ magnitudes. For problems with non static geometry, the final load coefficients are the RMS values from the final motion cycle. For problems with static geometry, they are the load coefficients at the final time step.

The optimization process varies four of the base OperatingPoint’s parameters (vCg__E, alpha, beta, externalFX_W) within their specified bounds. At each iteration, an UnsteadyRingVortexLatticeMethodSolver is run to compute aerodynamic loads. These loads are combined with the external loads to compute a net load coefficient.

The function uses a two-stage optimization approach: first attempting a local search using L-BFGS-B, and if that fails to converge, it performs a global search using dual annealing.

The search terminates early if the objective function falls below the specified cutoff value. If no trim condition is found within the maximum number of function calls, the function returns None values and logs a critical error.

Parameters:
  • problem – The UnsteadyProblem whose trim condition will be found. The UnsteadyProblem’s Movement must contain exactly one AirplaneMovement. The problem’s OperatingPointMovement’s base OperatingPoint will be modified during the trim search.

  • boundsVCg__E – A tuple of two positive numbers (ints or floats), in ascending order, determining the range of base speeds of the Airplane’s CG (in the Earth frame) to search. The base OperatingPoint’s initial vCg__E must be within these bounds. Values are converted to floats internally. The units are in meters per second.

  • alpha_bounds – A tuple of two numbers (ints or floats), in ascending order, determining the range of angles of attack to search. The base OperatingPoint’s initial alpha must be within these bounds. Values are converted to floats internally. The units are in degrees.

  • beta_bounds – A tuple of two numbers (ints or floats), in ascending order, determining the range of sideslip angles to search. The base OperatingPoint’s initial beta must be within these bounds. Values are converted to floats internally. The units are in degrees.

  • boundsExternalFX_W – A tuple of two numbers (ints or floats), in ascending order, determining the range of external forces (in the wind axes’ x direction) to search. The base OperatingPoint’s initial externalFX_W must be within these bounds. Values are converted to floats internally. The units are in Newtons.

  • objective_cut_off – A positive number (int or float) for the trim search’s convergence threshold. When the objective function falls below this value, the search terminates successfully. Lower values result in tighter trim conditions but may require more iterations. Values are converted to floats internally. The default is 0.01.

  • num_calls – A positive int for the maximum number of objective function evaluations allowed during optimization. This limit applies separately to the local search and global search stages. Higher values allow for more thorough searching but increase computation time. The default is 100.

  • show_solver_progress – Set this to True to show the TQDM progress bar during each run of the unsteady solver. For showing progress bars and displaying log statements, set up logging using the setup_logging function. It can be a bool or a numpy bool and will be converted internally to a bool. The default is True.

Returns:

A tuple of four floats representing the trimmed parameters found. In order, they are: vCg__E (in meters per second), alpha (in degrees), beta (in degrees), and externalFX_W (in Newtons). If no trim condition was found, it will instead return a tuple of four Nones.