In [2]:
# Configure Jupyter so figures appear in the notebook
%matplotlib inline
# Configure Jupyter to display the assigned value after an assignment
%config InteractiveShell.ast_node_interactivity='last_expr_or_assign'
import pint
UNITS = pint.UnitRegistry()
Quantity = UNITS.Quantity
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
In [3]:
plt.plot(1, 1, None)
In [21]:
meter = UNITS.meter
minute = UNITS.minute
newton = UNITS.newton
Out[21]:
And a few more parameters in the Params
object.
In [22]:
max_torque = 240 * newton * meter
Out[22]:
In [23]:
max_rpm = 5500 / minute
Out[23]:
In [24]:
def available_torque(rpm):
if rpm > max_rpm:
return 0 * newton * meter
return max_torque * (1 - rpm/max_rpm)
In [25]:
available_torque(0 / minute)
Out[25]:
In [26]:
rpms = np.linspace(0, max_rpm*1.1, 21) / minute
Out[26]:
In [27]:
taus = [available_torque(rpm) for rpm in rpms]
Out[27]:
In [33]:
series = pd.Series(taus, index=rpms.magnitude)
Out[33]:
In [34]:
plt.plot(series)
plt.xlabel('Motor speed (rad/s)')
plt.ylabel('Available torque (N m)')
In [ ]: