From 8ab7d56193124a5871ebc8ecec122df5b0349ffa Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Tue, 16 Jul 2019 15:37:53 +0200
Subject: [PATCH] bugfix: use correct shiftloss energy in second simulation
 interval when shift losses are split among two intervals

---
 .../VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs    | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs
index 51da402b0e..3e16a27a67 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs
@@ -299,7 +299,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 			if (_powershiftLossEnergy != null) {
 				var remainingShiftLossLime = ModelData.PowershiftShiftTime - (absTime - LastShift);
 				if (remainingShiftLossLime.IsGreater(0)) {
-					aliquotEnergyLoss = _powershiftLossEnergy * VectoMath.Min(1.0, dt / remainingShiftLossLime);
+					aliquotEnergyLoss = _powershiftLossEnergy * VectoMath.Min(1.0, VectoMath.Min(dt, remainingShiftLossLime) / ModelData.PowershiftShiftTime);
 					var avgEngineSpeed = (DataBus.EngineSpeed + outAngularVelocity * effectiveRatio) / 2;
 					powershiftLoss = aliquotEnergyLoss / dt / avgEngineSpeed;
 					inTorque += powershiftLoss;
@@ -317,7 +317,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 				CurrentState.Gear = Gear;
 				CurrentState.TransmissionTorqueLoss = inTorque * effectiveRatio - outTorque;
 				CurrentState.PowershiftLoss = powershiftLoss;
-				CurrentState.PowershiftLossEnergy = _powershiftLossEnergy ?? 0.SI<WattSecond>() - aliquotEnergyLoss;
+				CurrentState.PowershiftLossEnergy = _powershiftLossEnergy;
 				TorqueConverter.Locked(CurrentState.InTorque, CurrentState.InAngularVelocity, CurrentState.InTorque,
 					CurrentState.InAngularVelocity);
 			}
-- 
GitLab