From 8cddb13ff53f043dd8bad79bee446f4efab8116e Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Tue, 22 Jan 2019 18:07:52 +0100
Subject: [PATCH] driver demand response: if operating point exceeds full-load,
 reduce acceleration (and thus cardan power demand) to full-load

---
 .../Impl/AMTShiftStrategyV2.cs                | 22 +++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategyV2.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategyV2.cs
index bc244f1702..cebddf9124 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategyV2.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategyV2.cs
@@ -307,6 +307,28 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 				0.SI<Second>(), Constants.SimulationSettings.TargetTimeInterval, driverAccelerationAvg, gradient,
 				true);
 
+			if (respDriverDemand.DeltaFullLoad.IsGreater(0)) {
+				driverAccelerationAvg = SearchAlgorithm.Search(driverAccelerationAvg, respDriverDemand.DeltaFullLoad,
+					Constants.SimulationSettings.OperatingPointInitialSearchIntervalAccelerating,
+					getYValue: response => {
+						var r = (ResponseDryRun)response;
+						return r.DeltaFullLoad;
+					},
+					evaluateFunction:
+						acc => {
+							var response = TestContainer.VehiclePort.Request(0.SI<Second>(), Constants.SimulationSettings.TargetTimeInterval, acc, gradient, true);
+							return response;
+
+						},
+					criterion: response => {
+						var r = (ResponseDryRun)response;
+						return r.DeltaFullLoad.Value();
+					});
+				respDriverDemand = (ResponseDryRun)TestContainer.VehiclePort.Request(
+					0.SI<Second>(), Constants.SimulationSettings.TargetTimeInterval, driverAccelerationAvg, gradient,
+					true);
+			}
+
 			if (respAccRsv.EngineSpeed < PowertrainConfig.EngineData.IdleSpeed ||
 				respAccRsv.EngineSpeed > PowertrainConfig.EngineData.FullLoadCurves[0].N95hSpeed) {
 				return new GearRating(GearRatingCase.E, 0, 0.RPMtoRad());
-- 
GitLab