diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Strategies/HybridStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Strategies/HybridStrategy.cs index fee6cfa041247b64411e0c16b440cba9e0902723..64450d2e5cf84d8f915f4e6b6e30b36d9f975f6e 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Strategies/HybridStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Strategies/HybridStrategy.cs @@ -1097,12 +1097,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies NextGear = nextGear, MechanicalAssistPower = ElectricMotorsOff }; - var firstResponse = RequestDryRun(absTime, dt, outTorque, outAngularVelocity, nextGear, tmp); - debug.Add($"[AHS.HBA-0] DryRun Gear={nextGear}", firstResponse); + var response = RequestDryRun(absTime, dt, outTorque, outAngularVelocity, nextGear, tmp); + debug.Add($"[AHS.HBA-0] DryRun Gear={nextGear}", response); var endSpeed = DataBus.VehicleInfo.VehicleSpeed + DataBus.DriverInfo.DriverAcceleration * ModelData.GearboxData.TractionInterruption; - if (EngineSpeedTooLow(firstResponse) + if (EngineSpeedTooLow(response) && DataBus.GearboxInfo.GearboxType.ManualTransmission() && endSpeed.IsSmallerOrEqual(disengageSpeedThreshold, 0.1.KMPHtoMeterPerSecond())) { var responseEmOff = ResponseEmOff; @@ -1114,7 +1114,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies } if (GearList.HasPredecessor(nextGear) - && EngineSpeedTooLow(firstResponse) + && EngineSpeedTooLow(response) && (!vehiclespeedBelowThreshold || AllowEmergencyShift)) { // engine speed would fall below idling speed - consider downshift var estimatedVelocityPostShift = VelocityDropData.Valid @@ -1130,12 +1130,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies } do { nextGear = GearList.Predecessor(nextGear); - firstResponse = RequestDryRun(absTime, dt, outTorque, outAngularVelocity, nextGear, tmp); - debug.Add($"[AHS.HBA-1] DryRun Gear={nextGear}", firstResponse); - } while (GearList.HasPredecessor(nextGear) && firstResponse == null); + response = RequestDryRun(absTime, dt, outTorque, outAngularVelocity, nextGear, tmp); + debug.Add($"[AHS.HBA-1] DryRun Gear={nextGear}", response); + } while (GearList.HasPredecessor(nextGear) && response == null); } - if (nextGear.Equals(GearList.First()) && EngineSpeedTooLow(firstResponse)) { + if (nextGear.Equals(GearList.First()) && EngineSpeedTooLow(response)) { // disengage gearbox... var responseEmOff = ResponseEmOff; responseEmOff.Gear = new GearshiftPosition(0); @@ -1145,7 +1145,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies return; } - if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission() && firstResponse == null && nextGear.Equals(GearList.First())) { + if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission() && response == null && nextGear.Equals(GearList.First())) { var downshift = ResponseEmOff; downshift.Gear = nextGear; eval.Add(downshift); @@ -1154,7 +1154,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies if (tmp.CombustionEngineOn) { var firstEntry = new HybridResultEntry(); - CalculateCosts(firstResponse, dt, firstEntry, AllowICEOff(absTime), dryRun); + CalculateCosts(response, dt, firstEntry, AllowICEOff(absTime), dryRun); var minimumShiftTimePassed = (DataBus.GearboxInfo.LastShift + ModelData.GearshiftParameters.TimeBetweenGearshifts).IsSmallerOrEqual(absTime); if (DataBus.GearboxInfo.GearEngaged(absTime) && !vehiclespeedBelowThreshold) { var reEngaged = !PreviousState.GearboxEngaged && DataBus.GearboxInfo.GearEngaged(absTime); @@ -1162,7 +1162,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies firstEntry.IgnoreReason.EngineSpeedTooLow()) && !reEngaged) { // ICE torque below FLD is OK as EM may regenerate and shift ICE operating point on drag line // for negative torques the shift line is vertical anyway ;-) - var best = FindBestGearForBraking(nextGear, firstResponse); + var best = FindBestGearForBraking(nextGear, response); if (!best.Equals(currentGear)) { // downshift required! var downshift = ResponseEmOff; @@ -1184,11 +1184,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies } var deltaDragTqFirst = disengaged ? - (firstResponse as ResponseDryRun).DeltaDragLoadTorque - : firstResponse.Engine.TotalTorqueDemand - firstResponse.Engine.DragTorque; + (response as ResponseDryRun).DeltaDragLoadTorque + : response.Engine.TotalTorqueDemand - response.Engine.DragTorque; - if (!firstResponse.Engine.EngineOn && DataBus.GearboxInfo.GearboxType.AutomaticTransmission()) { - deltaDragTqFirst = firstResponse.Gearbox.InputTorque; + if (!response.Engine.EngineOn && DataBus.GearboxInfo.GearboxType.AutomaticTransmission()) { + deltaDragTqFirst = response.Gearbox.InputTorque; } if (deltaDragTqFirst.IsGreater(0)) { @@ -1208,15 +1208,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies return; } - if (!firstResponse.Gearbox.Gear.Engaged && !ElectricMotorCanPropellDuringTractionInterruption) { + if (!response.Gearbox.Gear.Engaged && !ElectricMotorCanPropellDuringTractionInterruption) { // we are disengaged and EM cannot recuperate - switch EM off eval.Add(ResponseEmOff); return; } - if (firstResponse.ElectricMotor.MaxRecuperationTorque == null) { + if (response.ElectricMotor.MaxRecuperationTorque == null) { var retVal = ResponseEmOff; - retVal.Gear = firstResponse.Gearbox.Gear; + retVal.Gear = response.Gearbox.Gear; eval.Add(retVal); return; } @@ -1226,7 +1226,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies GearboxInNeutral = false, NextGear = nextGear, MechanicalAssistPower = new Dictionary<PowertrainPosition, Tuple<PerSecond, NewtonMeter>> { - { emPos, Tuple.Create(firstResponse.ElectricMotor.AngularVelocity, VectoMath.Max(firstResponse.ElectricMotor.MaxRecuperationTorque, 0.SI<NewtonMeter>())) } + { emPos, Tuple.Create(response.ElectricMotor.AngularVelocity, VectoMath.Max(response.ElectricMotor.MaxRecuperationTorque, 0.SI<NewtonMeter>())) } } }; var maxRecuperationResponse = RequestDryRun(absTime, dt, outTorque, outAngularVelocity, nextGear, maxRecuperation); @@ -1262,7 +1262,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies GearboxInNeutral = false, NextGear = nextGear, MechanicalAssistPower = new Dictionary<PowertrainPosition, Tuple<PerSecond, NewtonMeter>> { - { emPos, Tuple.Create(firstResponse.ElectricMotor.AngularVelocity, firstResponse.ElectricMotor.MaxRecuperationTorque) } + { emPos, Tuple.Create(response.ElectricMotor.AngularVelocity, response.ElectricMotor.MaxRecuperationTorque) } } } }); @@ -1290,7 +1290,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies GearboxInNeutral = false, NextGear = nextGear, MechanicalAssistPower = new Dictionary<PowertrainPosition, Tuple<PerSecond, NewtonMeter>> { - { emPos, Tuple.Create(firstResponse.ElectricMotor.AngularVelocity, emTq) } + { emPos, Tuple.Create(response.ElectricMotor.AngularVelocity, emTq) } } }; return RequestDryRun(absTime, dt, outTorque, outAngularVelocity, DataBus.GearboxInfo.GearEngaged(absTime) ? nextGear : new GearshiftPosition(0), cfg); @@ -1308,7 +1308,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies searcher: this ); if (emRecuperationTq.IsBetween( - firstResponse.ElectricMotor.MaxDriveTorque ?? 0.SI<NewtonMeter>(), firstResponse.ElectricMotor.MaxRecuperationTorque ?? 0.SI<NewtonMeter>())) { + response.ElectricMotor.MaxDriveTorque ?? 0.SI<NewtonMeter>(), response.ElectricMotor.MaxRecuperationTorque ?? 0.SI<NewtonMeter>())) { var entry = new HybridResultEntry { ICEOff = !DataBus.EngineInfo.EngineOn, Gear = nextGear, @@ -1317,7 +1317,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies GearboxInNeutral = false, NextGear = nextGear, MechanicalAssistPower = new Dictionary<PowertrainPosition, Tuple<PerSecond, NewtonMeter>> { - { emPos, Tuple.Create(firstResponse.ElectricMotor.AngularVelocity, emRecuperationTq) } + { emPos, Tuple.Create(response.ElectricMotor.AngularVelocity, emRecuperationTq) } } } }; @@ -1334,7 +1334,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies GearboxInNeutral = false, NextGear = nextGear, MechanicalAssistPower = new Dictionary<PowertrainPosition, Tuple<PerSecond, NewtonMeter>> { - { emPos, Tuple.Create(firstResponse.ElectricMotor.AngularVelocity, firstResponse.ElectricMotor.MaxRecuperationTorque) } + { emPos, Tuple.Create(response.ElectricMotor.AngularVelocity, response.ElectricMotor.MaxRecuperationTorque) } } } });