From dcf2c3635d3d11027b5d18d97a31914de9eaf8d4 Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Sat, 29 Dec 2018 14:24:18 +0100
Subject: [PATCH] Gearbox: set torque loss to 0 if angular speed is 0. already
 done for transmission component and gearbox when disengaged. added for
 engaged gear.

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

diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs
index 31e770803a..1cb7cfdbf6 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs
@@ -314,6 +314,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 			var avgInAngularVelocity = (PreviousState.InAngularVelocity + inAngularVelocity) / 2.0;
 			var avgOutAngularVelocity = (PreviousState.OutAngularVelocity + outAngularVelocity) / 2.0;
 			var inTorqueLossResult = ModelData.Gears[Gear].LossMap.GetTorqueLoss(avgOutAngularVelocity, outTorque);
+			if (avgOutAngularVelocity.IsEqual(0, 1e-9)) {
+				inTorqueLossResult.Value = 0.SI<NewtonMeter>();
+			}
 			var inTorque = !avgInAngularVelocity.IsEqual(0)
 				? outTorque * (avgOutAngularVelocity / avgInAngularVelocity)
 				: outTorque / ModelData.Gears[Gear].Ratio;
-- 
GitLab