@sh.add_function(dsp, outputs=['clutch_tc_speeds_delta'])
def predict_clutch_tc_speeds_delta(
clutch_tc_speed_model, times, clutch_phases, accelerations,
velocities, gear_box_speeds_in, gears, gear_box_torques_in):
"""
Predicts engine speed delta due to the clutch or torque converter [RPM].
:param clutch_tc_speed_model:
Clutch or Torque converter speed model.
:type clutch_tc_speed_model: callable
:param times:
Time vector [s].
:type times: numpy.array
:param clutch_phases:
When the clutch is active [-].
:type clutch_phases: numpy.array
:param accelerations:
Acceleration vector [m/s2].
:type accelerations: numpy.array
:param velocities:
Vehicle velocity [km/h].
:type velocities: numpy.array
:param gear_box_speeds_in:
Gear box speed vector [RPM].
:type gear_box_speeds_in: numpy.array
:param gears:
Gear vector [-].
:type gears: numpy.array
:param gear_box_torques_in:
Torque required vector [N*m].
:type gear_box_torques_in: numpy.array
:return:
Engine speed delta due to the clutch or torque converter [RPM].
:rtype: numpy.array
"""
b = dfl.functions.predict_clutch_tc_speeds_delta.ENABLE
if b and clutch_phases.any():
func, kwargs = clutch_tc_speed_model, dict(
accelerations=accelerations,
gear_box_torques_in=gear_box_torques_in,
gear_box_speeds_in=gear_box_speeds_in, gears=gears,
velocities=velocities
)
return np.where(clutch_phases, func(times, **kwargs), 0)
return np.zeros_like(clutch_phases, float)