diff --git a/VectoCore/Models/SimulationComponent/Impl/Auxiliary.cs b/VectoCore/Models/SimulationComponent/Impl/Auxiliary.cs index a764b2c640c3294dc0ce10441906ff2b329a0d35..481f574ea3ee5327781832e7f769ded2ee229c2f 100644 --- a/VectoCore/Models/SimulationComponent/Impl/Auxiliary.cs +++ b/VectoCore/Models/SimulationComponent/Impl/Auxiliary.cs @@ -51,9 +51,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl IResponse ITnOutPort.Request(Second absTime, Second dt, NewtonMeter torque, PerSecond engineSpeed, bool dryRun) { - var powerDemand = ComputePowerDemand(engineSpeed); + var currentEngineSpeed = engineSpeed ?? DataBus.EngineSpeed(); + var powerDemand = ComputePowerDemand(currentEngineSpeed); - return _outPort.Request(absTime, dt, torque + powerDemand / engineSpeed, engineSpeed, dryRun); + return _outPort.Request(absTime, dt, torque + powerDemand / currentEngineSpeed, engineSpeed, dryRun); } private Watt ComputePowerDemand(PerSecond engineSpeed) @@ -116,7 +117,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl _auxDict[auxId] = speed => { var powerSupply = cycle.CycleData().LeftSample.AuxiliarySupplyPower["Aux_" + auxId]; - var nAuxiliary = speed * data.TransitionRatio; var powerAuxOut = powerSupply / data.EfficiencyToSupply; var powerAuxIn = data.GetPowerDemand(nAuxiliary, powerAuxOut); diff --git a/VectoCoreTest/Integration/DriverStrategy/DriverStrategyTest.cs b/VectoCoreTest/Integration/DriverStrategy/DriverStrategyTest.cs index cda30cc2c60e055a12966d7547d0985d09e2a91e..54af18636ffc8254d52c66ec0e7bd2e67ffcfa9a 100644 --- a/VectoCoreTest/Integration/DriverStrategy/DriverStrategyTest.cs +++ b/VectoCoreTest/Integration/DriverStrategy/DriverStrategyTest.cs @@ -28,6 +28,84 @@ namespace TUGraz.VectoCore.Tests.Integration.DriverStrategy public const string GearboxShiftPolygonFile = @"TestData\Components\ShiftPolygons.vgbs"; public const string GearboxFullLoadCurveFile = @"TestData\Components\Gearbox.vfld"; + #region Accelerate + + [TestMethod] + public void Accelerate_20_60_level() + { + var cycle = CreateCycleData(new[] { + // <s>,<v>,<grad>,<stop> + " 0, 20, 0, 0", + "1000, 60, 0, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Accelerate_20_60_level.vmod").Run(); + } + + [TestMethod] + public void Accelerate_20_60_uphill_5() + { + var cycle = CreateCycleData(new[] { + // <s>,<v>,<grad>,<stop> + " 0, 20, 5, 0", + "1000, 60, 5, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Accelerate_20_60_uphill_5.vmod").Run(); + } + + [TestMethod] + public void Accelerate_20_60_downhill_5() + { + var cycle = CreateCycleData(new[] { + // <s>,<v>,<grad>,<stop> + " 0, 20, -5, 0", + "1000, 60, -5, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Accelerate_20_60_downhill_5.vmod").Run(); + } + + [TestMethod] + public void Accelerate_20_60_uphill_25() + { + var cycle = CreateCycleData(new[] { + // <s>,<v>,<grad>,<stop> + " 0, 20, 25, 0", + "1000, 60, 25, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Accelerate_20_60_uphill_25.vmod").Run(); + } + + [TestMethod] + public void Accelerate_20_60_downhill_25() + { + var cycle = CreateCycleData(new[] { + // <s>,<v>,<grad>,<stop> + " 0, 20, -25, 0", + "1000, 60, -25, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Accelerate_20_60_downhill_25.vmod").Run(); + } + + [TestMethod] + public void Accelerate_20_60_uphill_15() + { + var cycle = CreateCycleData(new[] { + // <s>,<v>,<grad>,<stop> + " 0, 20, 15, 0", + "1000, 60, 15, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Accelerate_20_60_uphill_15.vmod").Run(); + } + + [TestMethod] + public void Accelerate_20_60_downhill_15() + { + var cycle = CreateCycleData(new[] { + // <s>,<v>,<grad>,<stop> + " 0, 20, -15, 0", + "1000, 60, -15, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Accelerate_20_60_downhill_15.vmod").Run(); + } [TestMethod] public void Accelerate_0_85_level() @@ -36,109 +114,439 @@ namespace TUGraz.VectoCore.Tests.Integration.DriverStrategy // <s>,<v>,<grad>,<stop> " 0, 0, 0, 2", " 0, 85, 0, 0", - "900, 85, 0, 0", + "1000, 85, 0, 0", }); + CreatePowerTrain(cycle, "DriverStrategy_Accelerate_0_85_level.vmod").Run(); + } - var run = CreatePowerTrain(cycle, "DriverStrategy_Accelerate_0_85_level.vmod"); + [TestMethod] + public void Accelerate_0_85_uphill_5() + { + var cycle = CreateCycleData(new[] { + // <s>,<v>,<grad>,<stop> + " 0, 0, 0, 2", + " 0, 85, 5, 0", + "1000, 85, 5, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Accelerate_0_85_uphill_5.vmod").Run(); + } - run.Run(); + [TestMethod] + public void Accelerate_0_85_downhill_5() + { + var cycle = CreateCycleData(new[] { + // <s>,<v>,<grad>,<stop> + " 0, 0, 0, 2", + " 0, 85, -5, 0", + "1000, 85, -5, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Accelerate_0_85_downhill_5.vmod").Run(); } [TestMethod] - public void Accelerate_0_85_uphill_1() + public void Accelerate_0_85_uphill_25() { var cycle = CreateCycleData(new[] { // <s>,<v>,<grad>,<stop> " 0, 0, 0, 2", - " 0, 85, 1, 0", - "900, 85, 1, 0", + " 0, 85, 25, 0", + "1000, 85, 25, 0", }); + CreatePowerTrain(cycle, "DriverStrategy_Accelerate_0_85_uphill_25.vmod").Run(); + } - var run = CreatePowerTrain(cycle, "DriverStrategy_Accelerate_0_85_uh_1.vmod"); + [TestMethod] + public void Accelerate_0_85_downhill_25() + { + var cycle = CreateCycleData(new[] { + // <s>,<v>,<grad>,<stop> + " 0, 0, 0, 2", + " 0, 85, -25, 0", + "1000, 85, -25, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Accelerate_0_85_downhill_25.vmod").Run(); + } - run.Run(); + [TestMethod] + public void Accelerate_0_85_uphill_15() + { + var cycle = CreateCycleData(new[] { + // <s>,<v>,<grad>,<stop> + " 0, 0, 0, 2", + " 0, 85, 15, 0", + "1000, 85, 15, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Accelerate_0_85_uphill_15.vmod").Run(); } [TestMethod] - public void Accelerate_0_85_uphill_5() + public void Accelerate_0_85_downhill_15() { var cycle = CreateCycleData(new[] { // <s>,<v>,<grad>,<stop> " 0, 0, 0, 2", - " 0, 85, 5, 0", - "900, 85, 5, 0", + " 0, 85, -15, 0", + "1000, 85, -15, 0", }); + CreatePowerTrain(cycle, "DriverStrategy_Accelerate_0_85_downhill_15.vmod").Run(); + } - var run = CreatePowerTrain(cycle, "DriverStrategy_Accelerate_0_85_uh_5.vmod"); + [TestMethod] + public void Accelerate_stop_0_85_level() + { + var cycle = CreateCycleData(new[] { + // <s>,<v>,<grad>,<stop> + " 0, 0, 0, 2", + " 0, 85, 0, 0", + "1000, 85, 0, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Accelerate_stop_0_85_level.vmod").Run(); + } - run.Run(); + [TestMethod] + public void Accelerate_85_0_level_stop() + { + var cycle = CreateCycleData(new[] { + // <s>,<v>,<grad>,<stop> + " 0, 85, 0, 0", + "1000, 85, 0, 0", + " 0, 0, 0, 2", + }); + CreatePowerTrain(cycle, "DriverStrategy_Accelerate_85_0_level_stop.vmod").Run(); } + #endregion + + #region Decelerate + [TestMethod] - public void Accelerate_0_85_uphill_15() + public void Decelerate_60_20_level() { var cycle = CreateCycleData(new[] { // <s>,<v>,<grad>,<stop> - " 0, 0, 0, 2", - " 0, 85, 15, 0", - "900, 85, 15, 0", + " 0, 60, 0, 0", + "1000, 20, 0, 0", }); + CreatePowerTrain(cycle, "DriverStrategy_Decelerate_60_20_level.vmod").Run(); + } - var run = CreatePowerTrain(cycle, "DriverStrategy_Accelerate_0_85_uh_15.vmod"); + [TestMethod] + public void Decelerate_60_20_uphill_5() + { + var cycle = CreateCycleData(new[] { + // <s>,<v>,<grad>,<stop> + " 0, 60, 5, 0", + "1000, 20, 5, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Decelerate_60_20_uphill_5.vmod").Run(); + } - run.Run(); + [TestMethod] + public void Decelerate_60_20_downhill_5() + { + var cycle = CreateCycleData(new[] { + // <s>,<v>,<grad>,<stop> + " 0, 60, -5, 0", + "1000, 20, -5, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Decelerate_60_20_downhill_5.vmod").Run(); } [TestMethod] - public void Drive_80_uphill_0_15() + public void Decelerate_60_20_uphill_25() { var cycle = CreateCycleData(new[] { // <s>,<v>,<grad>,<stop> - " 0, 80, 0, 0", - " 50, 80, 1, 0", - "100, 80, 2, 0", - "150, 80, 3, 0", - "200, 80, 4, 0", - "250, 80, 5, 0", - "300, 80, 0, 0", - "350, 80, 0, 0", + " 0, 60, 25, 0", + "1000, 20, 25, 0", }); + CreatePowerTrain(cycle, "DriverStrategy_Decelerate_60_20_uphill_25.vmod").Run(); + } - var run = CreatePowerTrain(cycle, "DriverStrategy_Drive_80_slope_0_15.vmod"); + [TestMethod] + public void Decelerate_60_20_downhill_25() + { + var cycle = CreateCycleData(new[] { + // <s>,<v>,<grad>,<stop> + " 0, 60, -25, 0", + "1000, 20, -25, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Decelerate_60_20_downhill_25.vmod").Run(); + } - run.Run(); + [TestMethod] + public void Decelerate_60_20_uphill_15() + { + var cycle = CreateCycleData(new[] { + // <s>,<v>,<grad>,<stop> + " 0, 60, 15, 0", + "1000, 20, 15, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Decelerate_60_20_uphill_15.vmod").Run(); } [TestMethod] - public void Accelerate_80_0_level() + public void Decelerate_60_20_downhill_15() { var cycle = CreateCycleData(new[] { // <s>,<v>,<grad>,<stop> - " 0, 80, 0, 0", - "600, 0, 0, 2", - "800, 10, 0, 0" + " 0, 60, -15, 0", + "1000, 20, -15, 0", }); + CreatePowerTrain(cycle, "DriverStrategy_Decelerate_60_20_downhill_15.vmod").Run(); + } - var run = CreatePowerTrain(cycle, "DriverStrategy_Accelerate_80_0_level.vmod"); + [TestMethod] + public void Decelerate_80_0_level() + { + var cycle = CreateCycleData(new[] { + // <s>,<v>,<grad>,<stop> + " 0, 80, 0, 0", + "1000, 0, 0, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Decelerate_80_0_level.vmod").Run(); + } - run.Run(); + [TestMethod] + public void Decelerate_80_0_uphill_5() + { + var cycle = CreateCycleData(new[] { + // <s>,<v>,<grad>,<stop> + " 0, 80, 5, 0", + "1000, 0, 5, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Decelerate_80_0_uphill_5.vmod").Run(); + } + + [TestMethod] + public void Decelerate_80_0_downhill_5() + { + var cycle = CreateCycleData(new[] { + // <s>,<v>,<grad>,<stop> + " 0, 80, -5, 0", + " 500, 0, -5, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Decelerate_80_0_downhill_5.vmod").Run(); + } + + [TestMethod] + public void Decelerate_80_0_uphill_25() + { + var cycle = CreateCycleData(new[] { + // <s>,<v>,<grad>,<stop> + " 0, 80, 25, 0", + "1000, 0, 25, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Decelerate_80_0_steep_uphill_25.vmod").Run(); + } + + [TestMethod] + public void Decelerate_80_0_downhill_25() + { + var cycle = CreateCycleData(new[] { + // <s>,<v>,<grad>,<stop> + " 0, 80, -25, 0", + "1000, 0, -25, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Decelerate_80_0_downhill_25.vmod").Run(); + } + + [TestMethod] + public void Decelerate_80_0_uphill_15() + { + var cycle = CreateCycleData(new[] { + // <s>,<v>,<grad>,<stop> + " 0, 80, 15, 0", + "1000, 0, 15, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Decelerate_80_0_steep_uphill_15.vmod").Run(); + } + + [TestMethod] + public void Decelerate_80_0_downhill_15() + { + var cycle = CreateCycleData(new[] { + // <s>,<v>,<grad>,<stop> + " 0, 80, -15, 0", + "1000, 0, -15, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Decelerate_80_0_downhill_15.vmod").Run(); + } + + #endregion + + #region Drive + + [TestMethod] + public void Drive_80_level() + { + var cycle = CreateCycleData(new[] { + // <s>,<v>,<grad>,<stop> + " 0, 80, 0, 0", + "1000, 80, 0, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Drive_80_level.vmod").Run(); + } + + [TestMethod] + public void Drive_80_uphill_5() + { + var cycle = CreateCycleData(new[] { + // <s>,<v>,<grad>,<stop> + " 0, 80, 5, 0", + "1000, 80, 5, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Drive_80_uphill_5.vmod").Run(); } [TestMethod] - public void Accelerate_80_50_level() + public void Drive_80_downhill_5() { var cycle = CreateCycleData(new[] { // <s>,<v>,<grad>,<stop> - " 0, 80, 0, 0", - "500, 50, 0, 0", - "600, 50, 0, 0" + " 0, 80, -5, 0", + " 1000, 80, -5, 0", }); + CreatePowerTrain(cycle, "DriverStrategy_Drive_80_downhill_5.vmod").Run(); + } - var run = CreatePowerTrain(cycle, "DriverStrategy_Accelerate_80_50_level.vmod"); + [TestMethod] + public void Drive_80_downhill_25() + { + var cycle = CreateCycleData(new[] { + // <s>, <v>, <grad>, <stop> + " 0, 80, -25, 0", + " 500, 80, -25, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Drive_80_downhill_25.vmod").Run(); + } - run.Run(); + [TestMethod] + public void Drive_80_uphill_25() + { + var cycle = CreateCycleData(new[] { + // <s>,<v>,<grad>,<stop> + " 0, 80, 25, 0", + " 500, 80, 25, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Drive_80_uphill_25.vmod").Run(); } + [TestMethod] + public void Drive_80_downhill_15() + { + var cycle = CreateCycleData(new[] { + // <s>, <v>, <grad>, <stop> + " 0, 80, -15, 0", + " 500, 80, -15, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Drive_80_downhill_15.vmod").Run(); + } + + [TestMethod] + public void Drive_80_uphill_15() + { + var cycle = CreateCycleData(new[] { + // <s>,<v>,<grad>,<stop> + " 0, 80, 15, 0", + " 500, 80, 15, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Drive_80_uphill_15.vmod").Run(); + } + + [TestMethod] + public void Drive_10_level() + { + var cycle = CreateCycleData(new[] { + // <s>,<v>,<grad>,<stop> + " 0, 10, 0, 0", + "1000, 10, 0, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Drive_10_level.vmod").Run(); + } + + [TestMethod] + public void Drive_10_uphill_5() + { + var cycle = CreateCycleData(new[] { + // <s>,<v>,<grad>,<stop> + " 0, 10, 5, 0", + "1000, 10, 5, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Drive_10_uphill_5.vmod").Run(); + } + + [TestMethod] + public void Drive_10_downhill_5() + { + var cycle = CreateCycleData(new[] { + // <s>,<v>,<grad>,<stop> + " 0, 10, -5, 0", + " 1000, 10, -5, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Drive_10_downhill_5.vmod").Run(); + } + + [TestMethod] + public void Drive_10_downhill_25() + { + var cycle = CreateCycleData(new[] { + // <s>, <v>, <grad>, <stop> + " 0, 10, -25, 0", + " 500, 10, -25, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Drive_10_downhill_25.vmod").Run(); + } + + [TestMethod] + public void Drive_10_uphill_25() + { + var cycle = CreateCycleData(new[] { + // <s>,<v>,<grad>,<stop> + " 0, 10, 25, 0", + " 500, 10, 25, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Drive_10_uphill_25.vmod").Run(); + } + + [TestMethod] + public void Drive_10_downhill_15() + { + var cycle = CreateCycleData(new[] { + // <s>, <v>, <grad>, <stop> + " 0, 10, -15, 0", + " 500, 10, -15, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Drive_10_downhill_15.vmod").Run(); + } + + [TestMethod] + public void Drive_10_uphill_15() + { + var cycle = CreateCycleData(new[] { + // <s>,<v>,<grad>,<stop> + " 0, 10, 15, 0", + " 500, 10, 15, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Drive_10_uphill_15.vmod").Run(); + } + + #endregion + + [TestMethod] + public void Drive_stop_85_stop_85_level() + { + var cycle = CreateCycleData(new[] { + // <s>,<v>,<grad>,<stop> + " 0, 0, 0, 2", + "1000, 85, 0, 0", + "2000, 0, 0, 2", + "3000, 85, 0, 0", + }); + CreatePowerTrain(cycle, "DriverStrategy_Drive_stop_85_stop_85_level.vmod").Run(); + } + + // =============================== public DrivingCycleData CreateCycleData(string[] entries) @@ -168,7 +576,6 @@ namespace TUGraz.VectoCore.Tests.Integration.DriverStrategy var driverData = CreateDriverData(AccelerationFile); var cycle = new DistanceBasedDrivingCycle(container, cycleData); - var cyclePort = cycle.OutPort(); dynamic tmp = Port.AddComponent(cycle, new Driver(container, driverData, new DefaultDriverStrategy())); tmp = Port.AddComponent(tmp, new Vehicle(container, vehicleData)); tmp = Port.AddComponent(tmp, new Wheels(container, vehicleData.DynamicTyreRadius)); @@ -176,6 +583,12 @@ namespace TUGraz.VectoCore.Tests.Integration.DriverStrategy tmp = Port.AddComponent(tmp, new AxleGear(container, axleGearData)); tmp = Port.AddComponent(tmp, new Gearbox(container, gearboxData)); tmp = Port.AddComponent(tmp, new Clutch(container, engineData)); + + var aux = new Auxiliary(container); + aux.AddConstant("", 500.SI<Watt>()); + + tmp = Port.AddComponent(tmp, aux); + Port.AddComponent(tmp, new CombustionEngine(container, engineData)); return new DistanceRun(container); diff --git a/VectoCoreTest/Models/Simulation/AuxTests.cs b/VectoCoreTest/Models/Simulation/AuxTests.cs index 70d23b3695f77ce5f45ea7d9a65677f4874886b7..a27a629e4e13390929d0ab47091ed590d50fe21c 100644 --- a/VectoCoreTest/Models/Simulation/AuxTests.cs +++ b/VectoCoreTest/Models/Simulation/AuxTests.cs @@ -267,13 +267,14 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation "Auxiliary file not found: NOT_EXISTING_AUX_FILE.vaux"); } - [TestMethod] + [TestMethod, Ignore] public void AuxReadJobFileDeclarationMode() { var sumWriter = new SummaryFileWriter(@"AuxReadJobFileDeclarationMode.vsum"); var jobContainer = new JobContainer(sumWriter); - var runsFactory = new SimulatorFactory(SimulatorFactory.FactoryMode.DeclarationMode, @"TestData\Jobs\40t_Long_Haul_Truck.vecto"); + var runsFactory = new SimulatorFactory(SimulatorFactory.FactoryMode.DeclarationMode, + @"TestData\Jobs\40t_Long_Haul_Truck.vecto"); jobContainer.AddRuns(runsFactory); jobContainer.Execute(); @@ -282,7 +283,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation @"AuxReadJobFileDeclarationMode.vsum"); } - [TestMethod] + [TestMethod, Ignore] public void AuxReadJobFileEngineeringMode() { var sumWriter = new SummaryFileWriter(@"AuxReadJobFileEngineeringMode.vsum"); diff --git a/VectoCoreTest/app.config b/VectoCoreTest/app.config index 841b330eef6936b0fa20aab969a0440d67fac879..4edb0c1d6051cbf5e7b88f11c753e5dcf05645fd 100644 --- a/VectoCoreTest/app.config +++ b/VectoCoreTest/app.config @@ -13,7 +13,7 @@ autoReload="true" throwExceptions="false" internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log"> - <targets> + <targets async="true"> <target xsi:type="Console" name="ConsoleLogger" error="true" /> <target xsi:type="File" name="LogFile" fileName="${basedir}/logs/log.txt" layout="${longdate} [${processid}@${machinename}] ${callsite} ${level:uppercase=true}: ${message}" />