From 73ae2bb7c2262cfff5e9b904c333b72c8626984c Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Tue, 15 May 2018 10:03:25 +0200
Subject: [PATCH] modified torque tolerance for VTP cycle

---
 .../Models/Declaration/DeclarationData.cs     |  3 +--
 .../SimulationComponent/Impl/VTPCycle.cs      | 26 +++++++------------
 .../VTPCycleValidationTest.cs                 | 16 ++++++------
 3 files changed, 18 insertions(+), 27 deletions(-)

diff --git a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs
index 63a506717c..2dceb56207 100644
--- a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs
+++ b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs
@@ -516,8 +516,7 @@ namespace TUGraz.VectoCore.Models.Declaration
 			public static readonly PerSecond WheelSpeedZeroTolerance = 0.1.RPMtoRad();
 			public static readonly PerSecond MaxWheelSpeedDifferenceStandstill = 1.RPMtoRad();
 
-			public static readonly NewtonMeter WheelTorqueZeroTolerance = 10.SI<NewtonMeter>();
-			public static readonly NewtonMeter MaxWheelTorqueZeroDifference = 100.SI<NewtonMeter>();
+			public static readonly NewtonMeter MaxWheelTorqueDifference = 200.SI<NewtonMeter>();
 
 			public static readonly PerSecond MinFanSpeed = 20.RPMtoRad();
 			public static readonly PerSecond MaxFanSpeed = 4000.RPMtoRad();
diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPCycle.cs
index 730257240d..5d79e47420 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPCycle.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPCycle.cs
@@ -149,22 +149,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 
 		private void VerifyWheelTorque(DrivingCycleData.DrivingCycleEntry entry)
 		{
-			if (!entry.TorqueWheelLeft.IsEqual(0.SI<NewtonMeter>(), DeclarationData.VTPMode.WheelTorqueZeroTolerance) &&
-				!entry.TorqueWheelRight.IsEqual(0.SI<NewtonMeter>(), DeclarationData.VTPMode.WheelTorqueZeroTolerance)) {
-				var torqueRatio = VectoMath.Max(
+			var torqueRatio = VectoMath.Max(
 					entry.TorqueWheelLeft / entry.TorqueWheelRight, entry.TorqueWheelRight / entry.TorqueWheelLeft);
-				if (torqueRatio > DeclarationData.VTPMode.WheelTorqueDifferenceFactor) {
-					Log.Error(
-						"Torque difference rel. (L/R) too high! t: {0} tq_left: {1}, tq_right: {2}", entry.Time, entry.TorqueWheelLeft,
-						entry.TorqueWheelRight);
-				}
-			} else {
-				if (VectoMath.Abs(entry.TorqueWheelLeft - entry.TorqueWheelRight) >
-					DeclarationData.VTPMode.MaxWheelTorqueZeroDifference) {
-					Log.Error(
-						"Torque difference abs. (L/R) too high! t: {0} tq_left: {1}, tq_right: {2}", entry.Time, entry.TorqueWheelLeft,
-						entry.TorqueWheelRight);
-				}
+			var torqueDiff = VectoMath.Abs(entry.TorqueWheelLeft - entry.TorqueWheelRight);
+			if (torqueRatio > DeclarationData.VTPMode.WheelTorqueDifferenceFactor && 
+				torqueDiff > DeclarationData.VTPMode.MaxWheelTorqueDifference) {
+				Log.Error(
+					"Torque difference (L/R) too high! t: {0} tq_left: {1}, tq_right: {2}", entry.Time, entry.TorqueWheelLeft,
+					entry.TorqueWheelRight);
 			}
 		}
 
@@ -176,14 +168,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 					entry.WheelSpeedLeft / entry.WheelSpeedRight, entry.WheelSpeedRight / entry.WheelSpeedLeft);
 				if (wheelSpeedRatio > DeclarationData.VTPMode.WheelSpeedDifferenceFactor) {
 					Log.Error(
-						"Wheel-speed difference rel. (L/R) too high! t: {0} n_left: {1}, n_right: {2}", entry.Time,
+						"Wheel-speed difference rel. (L/R) too high! t: {0} n_left: {1} rpm, n_right: {2} rpm", entry.Time,
 						entry.WheelSpeedLeft.AsRPM, entry.WheelSpeedRight.AsRPM);
 				}
 			} else {
 				if (VectoMath.Abs(entry.WheelSpeedLeft - entry.WheelSpeedRight) >
 					DeclarationData.VTPMode.MaxWheelSpeedDifferenceStandstill) {
 					Log.Error(
-						"Wheel-speed difference abs. (L/R) too high! t: {0} n_left: {1}, n_right: {2}", entry.Time,
+						"Wheel-speed difference abs. (L/R) too high! t: {0} n_left: {1} rpm, n_right: {2} rpm", entry.Time,
 						entry.WheelSpeedLeft.AsRPM, entry.WheelSpeedRight.AsRPM);
 				}
 			}
diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/VTPCycleValidationTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/VTPCycleValidationTest.cs
index dcebf21ca4..2a4cad939c 100644
--- a/VectoCore/VectoCoreTest/Models/SimulationComponent/VTPCycleValidationTest.cs
+++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/VTPCycleValidationTest.cs
@@ -171,7 +171,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
 			vtpCycle.VerifyInputData();
 
 			Assert.AreEqual(1, LogList.Count);
-			Assert.IsTrue(LogList[0].Contains("Torque difference rel."));
+			Assert.IsTrue(LogList[0].Contains("Torque difference"));
 		}
 
 
@@ -201,7 +201,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
 			vtpCycle.VerifyInputData();
 
 			Assert.AreEqual(1, LogList.Count);
-			Assert.IsTrue(LogList[0].Contains("Torque difference rel."));
+			Assert.IsTrue(LogList[0].Contains("Torque difference"));
 		}
 
 		[TestCase()]
@@ -209,14 +209,14 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
 		{
 			SetupLogging();
 
-			var torque = 0.95*DeclarationData.VTPMode.WheelTorqueZeroTolerance.Value();
+			var torque = 30; //0.95*DeclarationData.VTPMode.WheelTorqueZeroTolerance.Value();
 
 			var cycleEntries = string.Format(
 				@"  0   ,    0,  600, 400, {0}, {0} , 50 , 50 , 100, 3
 				    0.5 ,    0,  600, 400, {0}, {0} , 50 , 50 , 100, 3
 				    1   ,    0,  600, 400, {0}, {1} , 50 , 50 , 100, 3
 				    1.5 ,    0,  600, 400, {1}, {1} , 50 , 50 , 100, 3
-				", torque, torque + DeclarationData.VTPMode.MaxWheelTorqueZeroDifference.Value() * 1.1);
+				", torque, torque + DeclarationData.VTPMode.MaxWheelTorqueDifference.Value() * 1.1);
 
 			var container = new VehicleContainer(ExecutionMode.Declaration) {
 				RunData = new VectoRunData() {
@@ -230,7 +230,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
 			vtpCycle.VerifyInputData();
 
 			Assert.AreEqual(1, LogList.Count);
-			Assert.IsTrue(LogList[0].Contains("Torque difference abs."));
+			Assert.IsTrue(LogList[0].Contains("Torque difference "));
 		}
 
 		[TestCase()]
@@ -238,14 +238,14 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
 		{
 			SetupLogging();
 
-			var torque = 0.95 * DeclarationData.VTPMode.WheelTorqueZeroTolerance.Value();
+			var torque = 30; //0.95 * DeclarationData.VTPMode.WheelTorqueZeroTolerance.Value();
 
 			var cycleEntries = string.Format(
 				@"  0   ,    0,  600, 400, {0}, {0} , 50 , 50 , 100, 3
 				    0.5 ,    0,  600, 400, {0}, {0} , 50 , 50 , 100, 3
 				    1   ,    0,  600, 400, {1}, {0} , 50 , 50 , 100, 3
 				    1.5 ,    0,  600, 400, {1}, {1} , 50 , 50 , 100, 3
-				", torque, torque + DeclarationData.VTPMode.MaxWheelTorqueZeroDifference.Value() * 1.1);
+				", torque, torque + DeclarationData.VTPMode.MaxWheelTorqueDifference.Value() * 1.1);
 
 			var container = new VehicleContainer(ExecutionMode.Declaration) {
 				RunData = new VectoRunData() {
@@ -259,7 +259,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
 			vtpCycle.VerifyInputData();
 
 			Assert.AreEqual(1, LogList.Count);
-			Assert.IsTrue(LogList[0].Contains("Torque difference abs."));
+			Assert.IsTrue(LogList[0].Contains("Torque difference"));
 		}
 
 		[TestCase()]
-- 
GitLab