From d26024d6a1f2e05266f8cfe7ad417055594a6065 Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Mon, 12 Aug 2019 15:12:14 +0200
Subject: [PATCH] fix: set ignition state in torque converter if locked

---
 .../SimulationComponent/Impl/TorqueConverter.cs      | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/TorqueConverter.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/TorqueConverter.cs
index 499f73caca..b5916b05dd 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/TorqueConverter.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/TorqueConverter.cs
@@ -145,10 +145,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 		{
 			var prevInSpeed = PreviousState.IgnitionOn ? PreviousState.InAngularVelocity : DataBus.EngineIdleSpeed;
 			var avgEngineSpeed = (prevInSpeed + operatingPoint.InAngularVelocity) / 2;
-
-			//var prevInSpeed = PreviousState.OperatingPoint?.InAngularVelocity ?? PreviousState.InAngularVelocity;
-			//var prevInTorque = PreviousState.OperatingPoint?.InTorque ?? PreviousState.InTorque;
+			//var avgEngineSpeed = (PreviousState.InAngularVelocity + operatingPoint.InAngularVelocity) / 2;
 			//var prevInSpeed = PreviousState.InAngularVelocity;
+
+			////var prevInSpeed = PreviousState.OperatingPoint?.InAngularVelocity ?? PreviousState.InAngularVelocity;
+			////var prevInTorque = PreviousState.OperatingPoint?.InTorque ?? PreviousState.InTorque;
 			var prevInTorque = PreviousState.InTorque;
 			var avgPower = (prevInSpeed * prevInTorque +
 							operatingPoint.InAngularVelocity * operatingPoint.InTorque) / 2;
@@ -217,7 +218,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 					operatingPoint = ModelData.FindOperatingPoint(maxInputSpeed, outAngularVelocity);
 					corrected = true;
 				}
-				if (operatingPoint.InAngularVelocity.IsSmaller(DataBus.EngineIdleSpeed)) {
+				if (operatingPoint.InAngularVelocity.IsSmaller(DataBus.EngineIdleSpeed * 1.001)) {
 					operatingPoint = ModelData.FindOperatingPoint(lowerInputSpeed, outAngularVelocity);
 					corrected = true;
 				}
@@ -252,7 +253,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 		{
 			try {
 				var operatingPoint = ModelData.FindOperatingPointForPowerDemand(
-					engineResponse.DynamicFullLoadPower - engineResponse.AuxiliariesPowerDemand,
+					(engineResponse.DynamicFullLoadPower - engineResponse.AuxiliariesPowerDemand),
 					DataBus.EngineSpeed, outAngularVelocity, _engineInertia, dt, previousPower);
 				var maxInputSpeed = VectoMath.Min(ModelData.TorqueConverterSpeedLimit, DataBus.EngineN95hSpeed);
 				if (operatingPoint.InAngularVelocity.IsGreater(maxInputSpeed)) {
@@ -405,6 +406,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 			PerSecond outAngularVelocity)
 		{
 			CurrentState.SetState(inTorque, inAngularVelocity, outTorque, outAngularVelocity);
+			CurrentState.IgnitionOn = DataBus.IgnitionOn;
 		}
 
 		public class TorqueConverterComponentState : SimpleComponentState
-- 
GitLab