diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Strategies/HybridStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Strategies/HybridStrategy.cs index 583e500f2f09b9b09acd55d2d3ab9100c146a9c0..de25e1aef0244aabe316006c1b8ec12dd831ce3d 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Strategies/HybridStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Strategies/HybridStrategy.cs @@ -208,7 +208,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies if (ElectricMotorCanPropellDuringTractionInterruption || DataBus.GearboxInfo.GearEngaged(absTime)) { var emPos = ModelData.ElectricMachinesData.First().Item1; - var currentGear = PreviousState.GearboxEngaged ? DataBus.GearboxInfo.Gear : Controller.ShiftStrategy.NextGear.Gear; + var currentGear = !DataBus.GearboxInfo.GearEngaged(absTime) + ? Controller.ShiftStrategy.NextGear.Gear + : (PreviousState.GearboxEngaged + ? DataBus.GearboxInfo.Gear + : Controller.ShiftStrategy.NextGear.Gear); var tmp = new HybridStrategyResponse() { CombustionEngineOn = DataBus.EngineInfo.EngineOn, // AllowICEOff(absTime), GearboxInNeutral = false, @@ -220,8 +224,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies var firstEntry = new HybridResultEntry(); CalcualteCosts(firstResponse, dt, firstEntry, AllowICEOff(absTime)); - if ((firstEntry.IgnoreReason & (HybridConfigurationIgnoreReason.EngineSpeedTooLow | - HybridConfigurationIgnoreReason.EngineSpeedBelowDownshift)) != 0) { + if (DataBus.GearboxInfo.GearEngaged(absTime) && (firstEntry.IgnoreReason & (HybridConfigurationIgnoreReason.EngineSpeedTooLow | + HybridConfigurationIgnoreReason.EngineSpeedBelowDownshift)) != 0) { // downshift required! var downshift = ResponseEmOff; downshift.Gear = currentGear - 1; @@ -303,17 +307,18 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies ); if (emRecuperationTq.IsBetween( firstResponse.ElectricMotor.MaxDriveTorque, firstResponse.ElectricMotor.MaxRecuperationTorque)) { - eval.Add( - new HybridResultEntry() { - ICEOff = !DataBus.EngineInfo.EngineOn, - Setting = new HybridStrategyResponse() { - CombustionEngineOn = DataBus.EngineInfo.EngineOn, - GearboxInNeutral = false, - MechanicalAssistPower = new Dictionary<PowertrainPosition, NewtonMeter>() { - { emPos, emRecuperationTq } - } + var entry = new HybridResultEntry() { + ICEOff = !DataBus.EngineInfo.EngineOn, + Setting = new HybridStrategyResponse() { + CombustionEngineOn = DataBus.EngineInfo.EngineOn, + GearboxInNeutral = false, + MechanicalAssistPower = new Dictionary<PowertrainPosition, NewtonMeter>() { + { emPos, emRecuperationTq } } - }); + } + }; + entry.Response = RequestDryRun(absTime, dt, outTorque, outAngularVelocity, currentGear, entry.Setting); + eval.Add(entry); } else { if (emRecuperationTq.IsGreater(0)) { eval.Add( diff --git a/VectoCore/VectoCoreTest/Integration/Hybrid/ParallelHybridTest.cs b/VectoCore/VectoCoreTest/Integration/Hybrid/ParallelHybridTest.cs index ffcff3f527dd20fb1bea36840ebc6339980c4aac..24b2ea3eaad5999cd90e8b754514bff8d37118af 100644 --- a/VectoCore/VectoCoreTest/Integration/Hybrid/ParallelHybridTest.cs +++ b/VectoCore/VectoCoreTest/Integration/Hybrid/ParallelHybridTest.cs @@ -397,9 +397,54 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid GraphWriter.Write(modFilename); } - // - - - - - - - - - - - - - - - - - - - - - - - - - - [ + [ + TestCase("LongHaul", 2000, 0.5, 0, TestName = "P3 Hybrid DriveCycle LongHaul, SoC: 0.5 Payload: 2t P_auxEl: 0kW"), + TestCase("RegionalDelivery", 2000, 0.5, 0, TestName = "P3 Hybrid DriveCycle RegionalDelivery, SoC: 0.5 Payload: 2t P_auxEl: 0kW"), + TestCase("UrbanDelivery", 2000, 0.5, 0, TestName = "P3 Hybrid DriveCycle UrbanDelivery, SoC: 0.5 Payload: 2t P_auxEl: 0kW"), + TestCase("Construction", 2000, 0.5, 0, TestName = "P3 Hybrid DriveCycle Construction, SoC: 0.5 Payload: 2t P_auxEl: 0kW"), + TestCase("Urban", 2000, 0.5, 0, TestName = "P3 Hybrid DriveCycle Urban, SoC: 0.5 Payload: 2t P_auxEl: 0kW"), + TestCase("Suburban", 2000, 0.5, 0, TestName = "P3 Hybrid DriveCycle SubUrban, SoC: 0.5 Payload: 2t P_auxEl: 0kW"), + TestCase("Interurban", 2000, 0.5, 0, TestName = "P3 Hybrid DriveCycle InterUrban, SoC: 0.5 Payload: 2t P_auxEl: 0kW"), + TestCase("Coach", 2000, 0.5, 0, TestName = "P3 Hybrid DriveCycle Coach, SoC: 0.5 Payload: 2t P_auxEl: 0kW"), + ] + public void P3HybriDriveCycle(string declarationMission, double payload, double initialSoC, double pAuxEl) + { + GraphWriter.Yfields = Yfields.Concat(new[] { ModalResultField.P_electricMotor_mech_P3 }).ToArray(); + + var cycleData = RessourceHelper.ReadStream( + DeclarationData.DeclarationDataResourcePrefix + ".MissionCycles." + + declarationMission + + Constants.FileExtensions.CycleFile); + var cycle = DrivingCycleDataReader.ReadFromStream(cycleData, CycleType.DistanceBased, "", false); + + const bool largeMotor = true; + + var modFilename = string.Format("SimpleParallelHybrid-P3_cycle_{0}-{1}_{2}_{3}.vmod", declarationMission, initialSoC, payload, pAuxEl); + const PowertrainPosition pos = PowertrainPosition.HybridP3; + var run = CreateEngineeringRun( + cycle, modFilename, initialSoC, pos, largeMotor: true, pAuxEl: pAuxEl, payload: payload.SI<Kilogram>()); + + var hybridController = (HybridController)((VehicleContainer)run.GetContainer()).HybridController; + Assert.NotNull(hybridController); + + var modData = ((ModalDataContainer)((VehicleContainer)run.GetContainer()).ModData).Data; + + var data = run.GetContainer().RunData; + //File.WriteAllText( + // $"{modFilename}.json", + // JsonConvert.SerializeObject(data, Formatting.Indented)); + + run.Run(); + Assert.IsTrue(run.FinishedWithoutErrors); + + Assert.IsTrue(modData.Rows.Count > 0); + GraphWriter.Write(modFilename); + } + + // - - - - - - - - - - - - - - - - - - - - - - - - - + + [ TestCase(30, 0.7, 0, 0, TestName = "P4 Hybrid ConstantSpeed 30km/h SoC: 0.7, level"), TestCase(50, 0.7, 0, 0, TestName = "P4 Hybrid ConstantSpeed 50km/h SoC: 0.7, level"), TestCase(80, 0.7, 0, 0, TestName = "P4 Hybrid ConstantSpeed 80km/h SoC: 0.7, level"),