Optimizer Class¶
The Optimizer class contains useful functions for optimizing propulsion systems.
-
class
pyprop.Optimizer¶ A class for optimizing propulsion units. Will act as a wrapper for lower-level classes to provide easy analysis and optimization functionality to the user.
-
random_search(**kwargs)¶ Randomly searches the design space of components to maximize flight time. Plots these flight times against component parameters. User can select specific points in the design space to view component parameters and thrust curves.
Parameters: - goal_type (str) – Type of target required. Can be “thrust”, “thrust_to_weight_ratio”, or “power_to_weight_ratio”. Note that thrust to weight ratio is dimensionless and power to weight ratio is given in Watts per pound. It should also be noted that “power_to_weight_ratio” specifies the ratio of the propulsive power developed by the system at cruise speed to the weight, rather than the ratio of the maximum electric power available to the weight. The latter is commonly specified in the RC community but does not make much sense as an optimization target.
- goal_val (float) – Target value in whichever units are appropriate.
- airspeed (float) – The cruise velocity at which to evaluate each propulsion system in feet per second.
- altitude (float, optional) – The altitude at which to evaluate each propulsion system in feet. Defaults to 0.0.
- airframe_weight (float, optional) – Weight of the aircraft minus the propulsion system in lbf. Defaults to 0.0.
- n_units (int, optional) – The number of random combinations to try. Defaults to 1000.
- n_processes (int, optional) – The maximum number of computer processes that may be spawned at a time. Defaults to 8.
- filename (str, optional) – A file to export the results of the search to, sorted by flight time. Defaults to no file.
- plot (bool, optional) – Whether to plot the results of the search. Defaults to True. A figure will be displayed containing 6 plots which describe (in part) the design space. Each point on a plot represents a possible design; each design is reflected in each plot. The y axis of each plot is the flight time given by a design, and the x axis of each plot is a defining parameter of the design (currently: prop diameter, prop pitch, motor Kv constant, battery voltage, battery capacity, and total unit weight). The user may select any design in any one of the plots to see a plot of its thrust at various airspeeds and throttle settings. A corresponding plot of propeller speeds is also shown and all details of the design are printed to the terminal. Selecting a design will also highlight that design in each of the 6 plots, so that general patterns in the design space can be opserved.
- prop_kwargs (dict, optional) – Kwargs to pass to pyprop.create_component_from_database() when generating a prop. See the docstring for pyprop.create_component_from_database() for more information.
- motor_kwargs (dict, optional) – Kwargs to pass to pyprop.create_component_from_database() when generating a motor. See the docstring for pyprop.create_component_from_database() for more information.
- battery_kwargs (dict, optional) – Kwargs to pass to pyprop.create_component_from_database() when generating a battery. See the docstring for pyprop.create_component_from_database() for more information.
- esc_kwargs (dict, optional) – Kwargs to pass to pyprop.create_component_from_database() when generating an ESC. See the docstring for pyprop.create_component_from_database() for more information.
Returns: The best unit found.
Return type:
-