General Functions

The following functions are available directly through the pyprop module.

pyprop.to_rads(rpm)

Converts rpm to rads per second

Parameters:rpm (float) – Angular velocity in rpm.
Returns:Angular velocity in radians per second.
Return type:float
pyprop.to_rpm(rads)

Converts rads per second to rpm.

Parameters:rads (float) – Angular velocity in radians per second.
Returns:Angular velocity in rpm.
Return type:float
pyprop.create_component_from_database(**kwargs)

Fetches the necessary information from the database to assemble a component.

This function will randomly select a component that satisfies all the parameters given. So if none are given except what type of component is needed, that component will be selected at random from the database. If the manufacturer is given, then a component made by that manufacturer will be selected at random. If the name is given, then that exact component will be selected.

For numerical values, such as Kv for motors or capacity for batteries, the component with the value of this closest to the value given will be selected. In case of a tie, the selection is made randomly.

Alternatively, a two-element list can be given, as in

“Kv” : [300.0, 500.0]

This specifies that a motor with a Kv between these two values should be chosen.

The following components are affected by the following parameters:

prop: pitch, diameter, prop_type motor: Kv battery: capacity, num_cells ESC: I_max

Only one exact numeric parameter may be given (i.e. you are not allowed to specify { “pitch” : 12, “diameter” : 3}), as doing otherwise leaves the program with an unsolvable problem, namely, which parameter am I to match more closely? Yes, there are cases where both can be matched exactly, but this is not guaranteed. Multiple parameter ranges may be specified (i.e. { “pitch” : [3, 5], “diameter” : [12, 14] }).

Parameters:
  • component (str) – Can be “prop”, “battery”, “ESC”, or “motor”.
  • name (str, optional) – Name of the component. This should be exactly as the name appears in pyprop/components.db.
  • manufacturer (str, optional) – Component manufacturer.
  • dbid (int, optional) – ID of the component in the database.
  • prop_type (str, optional) – Type of the propeller model to use. Can either be “fit” or “data”. “data” type props will calculate the torque and thrust coefficients based off of linearly interpolating experimental data. “fit” type props calculate the coefficients based off of fits of the same data. Defaults to “data”.
  • capacity (float or list, optional) – Battery capacity in mAh.
  • cell_arrangement (tuple, optional) – Number of series and parallel cells in the battery. Note that batteries are stored as single cells in the database, so all batteries are available with an arbitrary number of cells (this may not reflect commercial availability). If not specified, this defaults to a random integer between 1 and 8 for both series and parallel cells. The exception to this is for batteries added to the database by the user. If the user has given a specific cell arrangement, then only this cell arrangement can be used. For the purpose of specifying a range of random cells, each tuple element can be a two element list specifying the limits of the range.
  • I_max (float or list, optional) – Maximum ESC current draw.
  • Kv (float or list, optional) – Motor speed constant.
  • diameter (float or list, optional) – Propeller diameter in inches.
  • pitch (float or list, optional) – Propeller pitch in inches.
Returns:

The component specified, pulled from the database.

Return type:

Motor, Battery, ESC, DatabaseDataProp, or DatabaseFitProp