@sh.add_function(dsp, inputs_kwargs=True, outputs=['k_factor_curve'])
def define_k_factor_curve(stand_still_torque_ratio=1.0, lockup_speed_ratio=0.0):
"""
Defines k factor curve.
:param stand_still_torque_ratio:
Torque ratio when speed ratio==0.
.. note:: The ratios are defined as follows:
- Torque ratio = `gear box torque` / `engine torque`.
- Speed ratio = `gear box speed` / `engine speed`.
:type stand_still_torque_ratio: float
:param lockup_speed_ratio:
Minimum speed ratio where torque ratio==1.
..note::
torque ratio==1 for speed ratio > lockup_speed_ratio.
:type lockup_speed_ratio: float
:return:
k factor curve.
:rtype: callable
"""
from scipy.interpolate import InterpolatedUnivariateSpline
if lockup_speed_ratio == 0:
x = [0, 1]
y = [1, 1]
elif lockup_speed_ratio == 1:
x = [0, 1]
y = [stand_still_torque_ratio, 1]
else:
x = [0, lockup_speed_ratio, 1]
y = [stand_still_torque_ratio, 1, 1]
return InterpolatedUnivariateSpline(x, y, k=1)