From da5715dc74725f7e05bc15ce06e3f2595b7f5a65 Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Fri, 21 Apr 2017 10:47:38 +0200
Subject: [PATCH] full load power can't be negative

---
 .../Models/SimulationComponent/Impl/CombustionEngine.cs        | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs
index 318ea49f4c..e35060782f 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs
@@ -183,6 +183,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 
 			var fullDragTorque = ModelData.FullLoadCurve.DragLoadStationaryTorque(avgEngineSpeed);
 			var dynamicFullLoadPower = ComputeFullLoadPower(avgEngineSpeed, dt, dryRun);
+			if (dynamicFullLoadPower < 0) {
+				dynamicFullLoadPower = 0.SI<Watt>();
+			}
 			var dynamicFullLoadTorque = dynamicFullLoadPower / avgEngineSpeed;
 			var inertiaTorqueLoss =
 				Formulas.InertiaPower(angularVelocity, PreviousState.EngineSpeed, ModelData.Inertia, dt) /
-- 
GitLab