diff --git a/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs b/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs index 7ae4f076bc1a35df70232a4236724ad8ea898735..e840a4b221d27126653cd6b31b5e340a76f15e84 100644 --- a/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs +++ b/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs @@ -158,8 +158,25 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } return 1; } + for (var gear = (uint)Data.Gears.Count; gear > 1; gear--) { + var response = Gearbox.Initialize(gear, outTorque, outEngineSpeed); + + var currentPower = response.EnginePowerRequest; + var inAngularSpeed = outEngineSpeed * Data.Gears[gear].Ratio; + var inTorque = currentPower / inAngularSpeed; + + var fullLoadPower = currentPower - response.DeltaFullLoad; + var reserve = 1 - (currentPower / fullLoadPower).Cast<Scalar>(); + + if (!IsBelowDownShiftCurve(gear, inTorque, inAngularSpeed) && !IsAboveUpShiftCurve(gear, inTorque, inAngularSpeed) && + reserve >= Data.StartTorqueReserve / 100) { + return gear; + } + if (IsAboveUpShiftCurve(gear, inTorque, inAngularSpeed) && gear < Data.Gears.Count) { + return gear + 1; + } + } - // todo else return 1; } } diff --git a/VectoCoreTest/Models/SimulationComponent/GearboxPowertrainTest.cs b/VectoCoreTest/Models/SimulationComponent/GearboxPowertrainTest.cs index d85995518cb6c279094233351901a3210adc2a42..9eb57c45cfd290edcfe59e9a1d4d683a8b25b414 100644 --- a/VectoCoreTest/Models/SimulationComponent/GearboxPowertrainTest.cs +++ b/VectoCoreTest/Models/SimulationComponent/GearboxPowertrainTest.cs @@ -93,6 +93,29 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent AssertHelper.AreRelativeEqual(593.202.RPMtoRad(), container.EngineSpeed); } + [TestMethod] + public void Gearbox_Initialize_85_RefLoad() + { + var cycle = CreateCycleData(new[] { + // <s>,<v>,<grad>,<stop> + " 0, 85, 2.95016969027809, 0", + " 100, 85, 2.95016969027809, 0", + }); + var container = CreatePowerTrain(cycle, "Gearbox_Initialize.vmod", 7500.0.SI<Kilogram>(), 19300.SI<Kilogram>()); + var retVal = container.Cycle.Initialize(); + Assert.AreEqual(11u, container.Gear); + Assert.IsInstanceOfType(retVal, typeof(ResponseSuccess)); + + AssertHelper.AreRelativeEqual(1195.996.RPMtoRad(), container.EngineSpeed); + + var absTime = 0.SI<Second>(); + var ds = 1.SI<Meter>(); + + retVal = container.Cycle.Request(absTime, ds); + container.CommitSimulationStep(absTime, retVal.SimulationInterval); + absTime += retVal.SimulationInterval; + } + // ===============================