From 562a302c4256fe6f7805ea2d2ab345fcaf9a5b5d Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Thu, 23 Jun 2016 11:13:08 +0200
Subject: [PATCH] gearbox: fix: inertia loss is 0 if angularvelocity is 0

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

diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs
index 4b0121463b..9f46216ef1 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs
@@ -378,8 +378,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 					: 0.SI<NewtonMeter>();
 				inTorque += CurrentState.InertiaTorqueLossOut / ModelData.Gears[Gear].Ratio;
 
-				var inertiaTorqueLossIn =
-					Formulas.InertiaPower(outAngularVelocity, PreviousState.OutAngularVelocity, ModelData.Inertia, dt) /
+				var inertiaTorqueLossIn = avgOutAngularVelocity.IsEqual(0, 1e-9)
+					? 0.SI<NewtonMeter>()
+					: 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;
-- 
GitLab