diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs index 5029b0ba3c44ac0afa12b4a8e13efd659da5ec4c..94f85088e9c18441cc1ec94697686a8cd043c9b2 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs @@ -30,6 +30,7 @@ */ using System; +using System.Linq; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; @@ -250,7 +251,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var minTorque = CurrentState.FullDragTorque; var maxTorque = CurrentState.DynamicFullLoadTorque; - CurrentState.EngineTorque = totalTorqueDemand.LimitTo(minTorque, maxTorque); + try { + CurrentState.EngineTorque = totalTorqueDemand.LimitTo(minTorque, maxTorque); + } catch (Exception) { + var extrapolated = avgEngineSpeed > ModelData.FullLoadCurves[0].FullLoadEntries.Last().EngineSpeed; + Log.Error("Engine full-load torque is below drag torque. max_torque: {0}, drag_torque: {1}, extrapolated: {2}", maxTorque, minTorque, extrapolated); + throw; + } CurrentState.EnginePower = CurrentState.EngineTorque * avgEngineSpeed; if (totalTorqueDemand.IsGreater(0) && diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPCombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPCombustionEngine.cs index d89e7bd5204e62fc0516dc1b78eec3e1a00220b1..2ad3c5a8b72dee75b4be2725d3d8f60c2243311b 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPCombustionEngine.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPCombustionEngine.cs @@ -30,6 +30,7 @@ */ using System; +using System.Linq; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Configuration; @@ -56,7 +57,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var fullDragTorque = ModelData.FullLoadCurves[DataBus.Gear].DragLoadStationaryTorque(avgEngineSpeed); - var fullLoadTorque = ModelData.FullLoadCurves[DataBus.Gear].FullLoadStationaryTorque(angularVelocity); + var fullLoadTorque = ModelData.FullLoadCurves[DataBus.Gear].FullLoadStationaryTorque(avgEngineSpeed); var inertiaTorqueLoss = Formulas.InertiaPower(angularVelocity, PreviousState.EngineSpeed, ModelData.Inertia, dt) / @@ -107,7 +108,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var minTorque = CurrentState.FullDragTorque; var maxTorque = CurrentState.DynamicFullLoadTorque; - CurrentState.EngineTorque = totalTorqueDemand.LimitTo(minTorque, maxTorque); + try { + CurrentState.EngineTorque = totalTorqueDemand.LimitTo(minTorque, maxTorque); + } catch (Exception) { + var extrapolated = avgEngineSpeed > ModelData.FullLoadCurves[0].FullLoadEntries.Last().EngineSpeed; + Log.Error("Engine full-load torque is below drag torque. max_torque: {0}, drag_torque: {1}, extrapolated: {2}", maxTorque, minTorque, extrapolated); + throw; + } CurrentState.EnginePower = CurrentState.EngineTorque * avgEngineSpeed; if (totalTorqueDemand.IsGreater(0) &&