Powertrain¶
- class Powertrain(motor: MotorBase)¶
Bases:
objectPowertrainobject.Attributes¶
Methods¶
plot()It plots time variables for each element in the powertrain’s
elements.reset()It resets the computed time variables.
snapshot()Computes a snapshot of the time variables of the elements in the powertrain at the specified
target_time.update_time()It updates the
timeby appending theinstantsimulated time step.export_time_variables()It exports the powertrain’s rotating objects’ computed time variables to some files.
Raises
TypeErrorIf
motorparameter is not an instance ofMotorBase.ValueErrorIf
motoris not connected to any other element.NameErrorIf two or more elements in the powertrain elements share the same
name.
- property elements: tuple[RotatingObject]¶
Rotating objects in the powertrain.
The first element is the driving motor, the next elements are in order, from the closest to the farthest from the motor. Each element is driven by the previous one and it drives the following one.
Returns¶
tupleRotating objects in the powertrain.
- export_time_variables(folder_path: str, time_unit: str | None = 'sec', angular_position_unit: str | None = 'rad', angular_speed_unit: str | None = 'rad/s', angular_acceleration_unit: str | None = 'rad/s^2', torque_unit: str | None = 'Nm', driving_torque_unit: str | None = 'Nm', load_torque_unit: str | None = 'Nm', force_unit: str | None = 'N', stress_unit: str | None = 'MPa', current_unit: str | None = 'A') None¶
It exports the powertrain’s
elements’ computed time variables to some files.It creates a file for each rotating object in the powertrain’s
elements. The file name is taken from the rotating object’sname.The exported files are a
.csvfiles. The time variables are exported in a tabular form, in which each column is a time variable and each row is a simulated time step. The columns are separated by a comma. The first column reports the simulated time steps and the first row reports the column names.Parameters¶
folder_pathstrPath to the folder in which to save the time variables’ files. It must be a non-empty
str.time_unitstr, optionalSymbol of the unit of measurement to which convert the time values in the exported files. It must be a
str. Default is'sec'. SeeTime.unitfor more details.angular_position_unitstr, optionalSymbol of the unit of measurement to which convert the angular position values in the exported files. It must be a
str. Default is'rad'. SeeAngularPosition.unitfor more details.angular_speed_unitstr, optionalSymbol of the unit of measurement to which convert the angular speed values in the exported files. It must be a
str. Default is'rad/s'. SeeAngularSpeed.unitfor more details.angular_acceleration_unitstr, optionalSymbol of the unit of measurement to which convert the angular acceleration values in the exported files. It must be a
str. Default is'rad/s^2'. SeeAngularAcceleration.unitfor more details.torque_unitstr, optionalSymbol of the unit of measurement to which convert the torque values in the exported files. It must be a
str. Default is'Nm'. SeeTorque.unitfor more details.driving_torque_unitstr, optionalSymbol of the unit of measurement to which convert the driving torque values in the exported files. It must be a
str. Default is'Nm'. SeeTorque.unitfor more details.load_torque_unitstr, optionalSymbol of the unit of measurement to which convert the load torque values in the exported files. It must be a
str. Default is'Nm'. SeeTorque.unitfor more details.force_unitstr, optionalSymbol of the unit of measurement to which convert the force values in the exported files. It must be a
str. Default is'N'. SeeForce.unitfor more details.stress_unitstr, optionalSymbol of the unit of measurement to which convert the stress values in the exported files. It must be a
str. Default is'MPa'. SeeStress.unitfor more details.current_unitstr, optionalSymbol of the unit of measurement to which convert the electric current values in the exported files. It must be a
str. Default is'A'. SeeCurrent.unitfor more details.
Raises
TypeErrorIf
folder_pathis not astr,if
time_unitis not astr,if
angular_position_unitis not astr,if
angular_speed_unitis not astr,if
angular_acceleration_unitis not astr,if
torque_unitis not astr,if
driving_torque_unitis not astr,if
load_torque_unitis not astr,if
force_unitis not astr,if
stress_unitis not astr,if
current_unitis not astr.
ValueErrorIf
folder_pathis an emptystr.
- plot(elements: list[RotatingObject | str] | None = None, variables: list[str] | None = None, angular_position_unit: str | None = 'rad', angular_speed_unit: str | None = 'rad/s', angular_acceleration_unit: str | None = 'rad/s^2', torque_unit: str | None = 'Nm', force_unit: str | None = 'N', stress_unit: str | None = 'MPa', current_unit: str | None = 'A', time_unit: str | None = 'sec', figsize: tuple | None = None) None¶
It plots time variables for selected
elementsin the powertrain’selements.It generates a grid of subplots, one column for each selected element of the powertrain’s
elementsand one row for each selected time variable.The available elements are listed in
elementsand the available variables are:'angular position','angular speed','angular acceleration','torque','driving torque'and'load torque'. The motor can have additional variableselectric currentandpwmwhile gears can have additional variablestangential force,bending stressandcontact stress, depending on instantiation parameters.The time variables are plotted in the described order, from the top row to the bottom one; torques are grouped together in a single row as well as stresses are grouped together. Plotted values’ units are managed with optional parameters.
Elements to be plotted can be passed as instances or names (
str) in alist.Parameters¶
elementslist, optionalElements of the powertrain’s
elementswhich time variables have to be plotted. Each single element can be passed as instance or name (str). Default is all elements in the powertrain’selements.variableslist, optionalTime variables to be plotted. Default is all available time variables.
angular_position_unitstr, optionalSymbol of the unit of measurement to which convert the angular position values in the plot. It must be a
str. Default is'rad'. SeeAngularPosition.unitfor more details.angular_speed_unitstr, optionalSymbol of the unit of measurement to which convert the angular speed values in the plot. It must be a
str. Default is'rad/s'. SeeAngularSpeed.unitfor more details.angular_acceleration_unitstr, optionalSymbol of the unit of measurement to which convert the angular acceleration values in the plot. It must be a
str. Default is'rad/s^2'. SeeAngularAcceleration.unitfor more details.torque_unitstr, optionalSymbol of the unit of measurement to which convert the torque values in the plot. It must be a
str. Default is'Nm'. SeeTorque.unitfor more details.force_unitstr, optionalSymbol of the unit of measurement to which convert the force values in the plot. It must be a
str. Default is'N'. SeeForce.unitfor more details.stress_unitstr, optionalSymbol of the unit of measurement to which convert the stress values in the plot. It must be a
str. Default is'MPa'. SeeStress.unitfor more details.current_unitstr, optionalSymbol of the unit of measurement to which convert the electric current values in the plot. It must be a
str. Default is'A'. SeeCurrent.unitfor more details.time_unitstr, optionalSymbol of the unit of measurement to which convert the time values in the plot. It must be a
str. Default is'sec'. SeeTime.unitfor more details.figsizetuple, optionalWidth and height of the window size, in inches. If not provided defaults to
[6.4, 4.8].
Raises
TypeErrorIf
elementsis not alist,if an element of
elementsis not an instance ofRotatingObjector astr,if
variablesis not alist,if an element of
variablesis not astr,if
angular_position_unitis not astr,if
angular_speed_unitis not astr,if
angular_acceleration_unitis not astr,if
torque_unitis not astr,if
force_unitis not astr,if
stress_unitis not astr,if
current_unitis not astr,if
time_unitis not astr,if
figsizeis not atuple,
ValueError
- reset() None¶
It resets the computed time variables.
For each element in the powertrain’s
elements, it resets each time variables and alsotimeproperty.
- property self_locking: bool¶
Whether the powertrain can only be moved by the motor and not by the effect of the load.
This property is given by the presence of a self-locking mating between a
WormGearand aWormWheelin the powertrain. This type of gear mating can be self-locking if the amount of friction is high enough with respect to the gear pressure and helix angles.If the powertrain is self-locking, then it can only be moved by the motor and not by the load, even if the load torque is greater than the motor driving torque.
Once the property is defined at the
Powertraininstantiation, it cannot be changed afterward.Returns¶
boolWhether the powertrain can only be moved by the motor and not by the effect of the load.
See Also
- snapshot(target_time: Time, variables: list[str] | None = None, angular_position_unit: str | None = 'rad', angular_speed_unit: str | None = 'rad/s', angular_acceleration_unit: str | None = 'rad/s^2', torque_unit: str | None = 'Nm', driving_torque_unit: str | None = 'Nm', load_torque_unit: str | None = 'Nm', force_unit: str | None = 'N', stress_unit: str | None = 'MPa', current_unit: str | None = 'A', print_data: bool | None = True) DataFrame¶
It computes a snapshot of the time variables of the elements in the powertrain at the specified
target_time.It returns a
pandas.DataFramewith the computed time variables. Each element in the powertrain’selementsis a row of the DataFrame, while the columns are the time variables'angular position','angular speed','angular acceleration','torque','driving torque'and'load torque'. The motor can have additional variables'electric current'and'pwm', while gears can have additional parameters'tangential force','bending stress'and'contact stress', depending on instantiation parameters.It is possible to select the variables to be printed with the
variablesparameter.Each time variable is converted to the relative unit passed as optional parameter.
If the
target_timeis not among simulated time steps in thetimeproperty, it computes a linear interpolation from the two closest simulated time steps.Parameters¶
target_timeTimeThe time to which compute the powertrain time variables’ snapshot. It must be an instance of
Time, whose value must be within minimum and maximum simulated time steps intimeproperty.variableslist, optionalTime variables to be printed. It must be a
list. Default is all available time variables.angular_position_unitstr, optionalSymbol of the unit of measurement to which convert the angular position values in the DataFrame. It must be a
str. Default is'rad'. SeeAngularPosition.unitfor more details.angular_speed_unitstr, optionalSymbol of the unit of measurement to which convert the angular speed values in the DataFrame. It must be a
str. Default is'rad/s'. SeeAngularSpeed.unitfor more details.angular_acceleration_unitstr, optionalSymbol of the unit of measurement to which convert the angular acceleration values in the DataFrame. It must be a
str. Default is'rad/s^2'. SeeAngularAcceleration.unitfor more details.torque_unitstr, optionalSymbol of the unit of measurement to which convert the torque values in the DataFrame. It must be a
str. Default is'Nm'. SeeTorque.unitfor more details.driving_torque_unitstr, optionalSymbol of the unit of measurement to which convert the driving torque values in the DataFrame. It must be a
str. Default is'Nm'. SeeTorque.unitfor more details.load_torque_unitstr, optionalSymbol of the unit of measurement to which convert the load torque values in the DataFrame. It must be a
str. Default is'Nm'. SeeTorque.unitfor more details.force_unitstr, optionalSymbol of the unit of measurement to which convert the force values in the DataFrame. It must be a
str. Default is'N'. SeeForce.unitfor more details.stress_unitstr, optionalSymbol of the unit of measurement to which convert the stress values in the DataFrame. It must be a
str. Default is'MPa'. SeeStress.unitfor more details.current_unitstr, optionalSymbol of the unit of measurement to which convert the electric current values in the DataFrame. It must be a
str. Default is'A'. SeeCurrent.unitfor more details.print_databool, optionalWhether to print the computed time variables DataFrame. Default is
True.
Returns¶
pandas.DataFrameThe DataFrame containing time variables values at the specified
target_timefor each element in the powertrain’selements.
Raises
TypeErrorIf an element of
timeis not an instance ofTime,if
target_timeis not an instance ofTime,if
variablesis not alist,if an element of
variablesis not astr,if
angular_position_unitis not astr,if
angular_speed_unitis not astr,if
angular_acceleration_unitis not astr,if
torque_unitis not astr,if
driving_torque_unitis not astr,if
load_torque_unitis not astr,if
force_unitis not astr,if
stress_unitis not astr,if
current_unitis not astr,if
print_datais not abool.
ValueError