diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/ElectricMotor/ElectricMotorData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/ElectricMotor/ElectricMotorData.cs index c8f2e69bcc6db03b79920edd5b66335e9044d548..9cfa95a43e1b42704a656a743d0175a60877f288 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/ElectricMotor/ElectricMotorData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/ElectricMotor/ElectricMotorData.cs @@ -53,10 +53,18 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data var r1 = a.EfficiencyMap.LookupTorque(electricPower, avgSpeed, maxEmTorque); var r2 = b.EfficiencyMap.LookupTorque(electricPower, avgSpeed, maxEmTorque); - if (r1 == null && r2 == null) { + if (r1 is null && r2 is null) { return null; } + // if one of the values is limited by EM, but the other is not (is null): use maxEmTorque instead + if (r1 is null) { + r1 = maxEmTorque; + } + if (r2 is null) { + r2 = maxEmTorque; + } + var retVal = VectoMath.Interpolate(a.Voltage, b.Voltage, r1, r2, voltage); var elPwr = LookupElectricPower(voltage, avgSpeed, retVal, true);