From 19be1b347ee7b13f6ef020b2d2478caf2f2cabab Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Wed, 3 Feb 2021 15:00:56 +0100
Subject: [PATCH] torque converter: consider EM drag for P1 hybrid
 configurations

---
 .../SimulationComponent/Impl/TorqueConverter.cs | 17 +++++++++++++----
 .../Integration/Hybrid/ParallelHybridTest.cs    |  4 ++--
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/TorqueConverter.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/TorqueConverter.cs
index 2789778f60..89310fbb25 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/TorqueConverter.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/TorqueConverter.cs
@@ -33,6 +33,7 @@ using System;
 using System.Collections.Generic;
 using System.Linq;
 using TUGraz.VectoCommon.Exceptions;
+using TUGraz.VectoCommon.InputData;
 using TUGraz.VectoCommon.Models;
 using TUGraz.VectoCommon.Utils;
 using TUGraz.VectoCore.Configuration;
@@ -225,8 +226,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 			ResponseDryRun engineResponse, Watt previousPower)
 		{
 			try {
+				var emPower = DataBus.ElectricMotorInfo(PowertrainPosition.HybridP1) == null
+					? 0.SI<Watt>()
+					: engineResponse.ElectricMotor.ElectricMotorPowerMech;
 				var operatingPoint = ModelData.FindOperatingPointForPowerDemand(
-					engineResponse.Engine.DragPower - engineResponse.Engine.AuxiliariesPowerDemand,
+					engineResponse.Engine.DragPower - engineResponse.Engine.AuxiliariesPowerDemand - emPower,
 					DataBus.EngineInfo.EngineSpeed, outAngularVelocity, _engineInertia, dt, previousPower);
 				var maxInputSpeed = VectoMath.Min(ModelData.TorqueConverterSpeedLimit, DataBus.EngineInfo.EngineN95hSpeed);
 				var lowerInputSpeed = DataBus.EngineInfo.EngineIdleSpeed * 1.001; // VectoMath.Max(DataBus.EngineIdleSpeed * 1.001, 0.8 * DataBus.EngineSpeed);
@@ -259,8 +263,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 					absTime, dt, outAngularVelocity, engineSpeed,
 					x => x.DeltaDragLoad.IsGreater(0),
 					x => VectoMath.Abs(DataBus.EngineInfo.EngineSpeed - x.Engine.EngineSpeed).Value());
-				if (retVal != null)
-				retVal.Creeping = true;
+				if (retVal != null) {
+					retVal.Creeping = true;
+				}
+
 				return retVal;
 			}
 		}
@@ -272,8 +278,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 			ResponseDryRun engineResponse, Watt previousPower)
 		{
 			try {
+				var emPower = DataBus.ElectricMotorInfo(PowertrainPosition.HybridP1) == null
+					? 0.SI<Watt>()
+					: engineResponse.ElectricMotor.ElectricMotorPowerMech;
 				var operatingPoint = ModelData.FindOperatingPointForPowerDemand(
-					(engineResponse.Engine.DynamicFullLoadPower - engineResponse.Engine.AuxiliariesPowerDemand),
+					(engineResponse.Engine.DynamicFullLoadPower - engineResponse.Engine.AuxiliariesPowerDemand - emPower),
 					DataBus.EngineInfo.EngineSpeed, outAngularVelocity, _engineInertia, dt, previousPower);
 				var maxInputSpeed = VectoMath.Min(ModelData.TorqueConverterSpeedLimit, DataBus.EngineInfo.EngineN95hSpeed);
 				if (operatingPoint.InAngularVelocity.IsGreater(maxInputSpeed)) {
diff --git a/VectoCore/VectoCoreTest/Integration/Hybrid/ParallelHybridTest.cs b/VectoCore/VectoCoreTest/Integration/Hybrid/ParallelHybridTest.cs
index 51fd5b1871..8481931abf 100644
--- a/VectoCore/VectoCoreTest/Integration/Hybrid/ParallelHybridTest.cs
+++ b/VectoCore/VectoCoreTest/Integration/Hybrid/ParallelHybridTest.cs
@@ -265,10 +265,10 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid
 			TestCase(TestJobP1_APTP, 9, TestName = "P1 Hybrid APT-P, DriveCycle UrbanDelivery"),
 
             TestCase(TestJobCityBusP1_APTP, 0, TestName = "P1 CityBus Hybrid APT-P, DriveCycle LongHaul"),
-            //TestCase(TestJobCityBusP1_APTP, 1, TestName = "P1 CityBus Hybrid APT-P, DriveCycle Coach"),
+            TestCase(TestJobCityBusP1_APTP, 1, TestName = "P1 CityBus Hybrid APT-P, DriveCycle Coach"),
             TestCase(TestJobCityBusP1_APTP, 2, TestName = "P1 CityBus Hybrid APT-P, DriveCycle Construction"),
             TestCase(TestJobCityBusP1_APTP, 3, TestName = "P1 CityBus Hybrid APT-P, DriveCycle HeavyUrban"),
-            //TestCase(TestJobCityBusP1_APTP, 4, TestName = "P1 CityBus Hybrid APT-P, DriveCycle Interurban"),
+            TestCase(TestJobCityBusP1_APTP, 4, TestName = "P1 CityBus Hybrid APT-P, DriveCycle Interurban"),
             TestCase(TestJobCityBusP1_APTP, 5, TestName = "P1 CityBus Hybrid APT-P, DriveCycle MunicipalUtility"),
             TestCase(TestJobCityBusP1_APTP, 6, TestName = "P1 CityBus Hybrid APT-P, DriveCycle RegionalDelivery"),
             TestCase(TestJobCityBusP1_APTP, 7, TestName = "P1 CityBus Hybrid APT-P, DriveCycle Suburban"),
-- 
GitLab