From bda66c7135033d1e539cf6d9928236fe841af6f6 Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Mon, 20 Apr 2020 11:56:33 +0200
Subject: [PATCH] add rounding for tc data, engine fc entries on drag curve

---
 .../GenericModelData/GenericBusEngineData.cs  |  8 +++----
 .../GenericTorqueConverterData.cs             | 24 +++++++++----------
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/VectoCore/VectoCore/Models/GenericModelData/GenericBusEngineData.cs b/VectoCore/VectoCore/Models/GenericModelData/GenericBusEngineData.cs
index 1f64039e29..e625cd2caa 100644
--- a/VectoCore/VectoCore/Models/GenericModelData/GenericBusEngineData.cs
+++ b/VectoCore/VectoCore/Models/GenericModelData/GenericBusEngineData.cs
@@ -145,13 +145,13 @@ namespace TUGraz.VectoCore.Models.Declaration
 			foreach (var entry in clusterResult) {
 				var dragTorque = fullLoadCurve.DragLoadStationaryTorque(entry.RPMtoRad()).Value();
 				var newRow = denormalizedData.NewRow();
-				newRow[FuelConsumptionMapReader.Fields.EngineSpeed] = entry;
-				newRow[FuelConsumptionMapReader.Fields.Torque] = dragTorque;
+				newRow[FuelConsumptionMapReader.Fields.EngineSpeed] = Math.Round(entry, 2, MidpointRounding.AwayFromZero);
+				newRow[FuelConsumptionMapReader.Fields.Torque] =  Math.Round(dragTorque, 2, MidpointRounding.AwayFromZero);
 				newRow[FuelConsumptionMapReader.Fields.FuelConsumption] = 0;
 				denormalizedData.Rows.Add(newRow);
 				var newRow2 = denormalizedData.NewRow();
-				newRow2[FuelConsumptionMapReader.Fields.EngineSpeed] = entry;
-				newRow2[FuelConsumptionMapReader.Fields.Torque] = dragTorque - 100;
+				newRow2[FuelConsumptionMapReader.Fields.EngineSpeed] = Math.Round(entry, 2, MidpointRounding.AwayFromZero);
+				newRow2[FuelConsumptionMapReader.Fields.Torque] = Math.Round(dragTorque - 100, 2, MidpointRounding.AwayFromZero);
 				newRow2[FuelConsumptionMapReader.Fields.FuelConsumption] = 0;
 				denormalizedData.Rows.Add(newRow2);
 			}
diff --git a/VectoCore/VectoCore/Models/GenericModelData/GenericTorqueConverterData.cs b/VectoCore/VectoCore/Models/GenericModelData/GenericTorqueConverterData.cs
index 3ba997b518..c8c57899a5 100644
--- a/VectoCore/VectoCore/Models/GenericModelData/GenericTorqueConverterData.cs
+++ b/VectoCore/VectoCore/Models/GenericModelData/GenericTorqueConverterData.cs
@@ -63,30 +63,30 @@ namespace TUGraz.VectoCore.Models.Declaration
 
 			// stall point
 			var stallPt = retVal.NewRow();
-			stallPt[colSpeedRatio] = speedRatioStallPt * ratio;
-			stallPt[colTqRatio] = torqueRatioStallPt / speedRAtioOverrunPt / ratio;
-			stallPt[colRefTq] = refTorqueStallPt;
+			stallPt[colSpeedRatio] = Math.Round(speedRatioStallPt * ratio, 4, MidpointRounding.AwayFromZero);
+			stallPt[colTqRatio] = Math.Round(torqueRatioStallPt / speedRAtioOverrunPt / ratio, 2, MidpointRounding.AwayFromZero);
+			stallPt[colRefTq] = Math.Round(refTorqueStallPt;
 			retVal.Rows.Add(stallPt);
 
 			// intermediate point
 			var intermediatePt = retVal.NewRow();
-			intermediatePt[colSpeedRatio] = speedRatioIntermediatePt * ratio;
-			intermediatePt[colTqRatio] = torqueRatioIntermediatePt / ratio;
-			intermediatePt[colRefTq] = refTorqueStallPt * refTorqueIntermediatePtFactor;
+			intermediatePt[colSpeedRatio] = Math.Round(speedRatioIntermediatePt * ratio, 4, MidpointRounding.AwayFromZero);
+			intermediatePt[colTqRatio] = Math.Round(torqueRatioIntermediatePt / ratio, 2, MidpointRounding.AwayFromZero);
+			intermediatePt[colRefTq] = Math.Round(refTorqueStallPt * refTorqueIntermediatePtFactor, 2, MidpointRounding.AwayFromZero);
 			retVal.Rows.Add(intermediatePt);
 
 			//coupling point
 			var couplingPt = retVal.NewRow();
-			couplingPt[colSpeedRatio] = speedRatioCouplingPt * speedRAtioOverrunPt * ratio;
-			couplingPt[colTqRatio] = torqueRatioCouplingPt / speedRAtioOverrunPt / ratio;
-			couplingPt[colRefTq] = refTorqueStallPt * refTorqueCouplingPtFactor;
+			couplingPt[colSpeedRatio] = Math.Round(speedRatioCouplingPt * speedRAtioOverrunPt * ratio, 4, MidpointRounding.AwayFromZero);
+			couplingPt[colTqRatio] = Math.Round(torqueRatioCouplingPt / speedRAtioOverrunPt / ratio, 2, MidpointRounding.AwayFromZero);
+			couplingPt[colRefTq] = Math.Round(refTorqueStallPt * refTorqueCouplingPtFactor, 2, MidpointRounding.AwayFromZero);
 			retVal.Rows.Add(couplingPt);
 
 			// overrun point
 			var overrunPt = retVal.NewRow();
-			overrunPt[colSpeedRatio] = speedRAtioOverrunPt * ratio;
-			overrunPt[colTqRatio] = torqueRatioOverrunPt / speedRAtioOverrunPt / ratio;
-			overrunPt[colRefTq] = refTorqueStallPt * refTorqueOverrunPtFactor;
+			overrunPt[colSpeedRatio] = Math.Round(speedRAtioOverrunPt * ratio, 4, MidpointRounding.AwayFromZero);
+			overrunPt[colTqRatio] = Math.Round(torqueRatioOverrunPt / speedRAtioOverrunPt / ratio, 2, MidpointRounding.AwayFromZero);
+			overrunPt[colRefTq] = Math.Round(refTorqueStallPt * refTorqueOverrunPtFactor, 2, MidpointRounding.AwayFromZero);
 			retVal.Rows.Add(overrunPt);
 
 			return retVal;
-- 
GitLab