From 3b08b19e1e374cb467de3cdc778c917888582810 Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Thu, 16 Jun 2016 08:55:14 +0200
Subject: [PATCH] hotfix: account for gearbox inertia in dry-run

---
 .../VectoCore/Models/SimulationComponent/Impl/Gearbox.cs   | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs
index c52d979cd5..69cc09c244 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs
@@ -221,7 +221,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 			if (DataBus.VehicleStopped) {
 				_engageTime = absTime;
 			}
-			
+
 			IResponse retVal;
 			// TODO MQ 2016/03/10: investigate further the effects of having the condition angularvelocity != 0
 			if (ClutchClosed(absTime) /* && !angularVelocity.IsEqual(0) */) {
@@ -337,7 +337,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 					Log.Debug("EngineSpeed is below IdleSpeed, Gearbox disengage!");
 					return new ResponseEngineSpeedTooLow { Source = this, GearboxPowerRequest = outTorque * outAngularVelocity };
 				}
-				var dryRunResponse = NextComponent.Request(absTime, dt, inTorque, inAngularVelocity, true);
+				var inertiaTorqueLossIn =
+					Formulas.InertiaPower(outAngularVelocity, PreviousState.OutAngularVelocity, ModelData.Inertia, dt) /
+					avgOutAngularVelocity / ModelData.Gears[Gear].Ratio;
+				var dryRunResponse = NextComponent.Request(absTime, dt, inTorque + inertiaTorqueLossIn, inAngularVelocity, true);
 				dryRunResponse.GearboxPowerRequest = outTorque * (PreviousState.OutAngularVelocity + outAngularVelocity) / 2.0;
 				return dryRunResponse;
 			}
-- 
GitLab