diff --git a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs index cb8017175cb847cb1f6ac197fda504d376babc25..63a506717ce480fad69882a30def0de9e6167eed 100644 --- a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs +++ b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs @@ -524,6 +524,7 @@ namespace TUGraz.VectoCore.Models.Declaration public static readonly Second SamplingInterval = 0.5.SI<Second>(); + public static readonly WattSecond MinPosWorkAtWheelsForFC = 1.SI(Unit.SI.Kilo.Watt.Hour).Cast<WattSecond>(); public static readonly SpecificFuelConsumption LowerFCThreshold = 180.SI(Unit.SI.Gramm.Per.Kilo.Watt.Hour).Cast<SpecificFuelConsumption>(); public static readonly SpecificFuelConsumption UpperFCThreshold = 600.SI(Unit.SI.Gramm.Per.Kilo.Watt.Hour).Cast<SpecificFuelConsumption>(); public static readonly Second FCAccumulationWindow = 10.SI(Unit.SI.Minute).Cast<Second>(); diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPCycle.cs index 5f75ce6edf61bab5883ad608945287a4aed63b4e..730257240dfc240da6696d5e73cc4aaa98cb6d62 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPCycle.cs @@ -61,7 +61,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return base.Initialize(); } - private void PrepareCycleData() + protected internal void PrepareCycleData() { foreach (var entry in Data.Entries) { var wheelSpeed = (entry.WheelSpeedLeft + entry.WheelSpeedRight) / 2; @@ -117,7 +117,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl sumEWheel -= window[(idx + 1) % count].EWheel; idx++; - if (sumEWheel.IsSmaller(1.SI(Unit.SI.Kilo.Watt.Hour))) { + if (sumEWheel.IsSmaller(DeclarationData.VTPMode.MinPosWorkAtWheelsForFC)) { continue; } if (sumFC / sumEWheel < DeclarationData.VTPMode.LowerFCThreshold ) { diff --git a/VectoCore/VectoCore/OutputData/XML/XMLVTPReport.cs b/VectoCore/VectoCore/OutputData/XML/XMLVTPReport.cs index e059e1f3162df712868b016dfb78b84573284e09..59f188415dae0a7d2d788835fd917e100f27ff44 100644 --- a/VectoCore/VectoCore/OutputData/XML/XMLVTPReport.cs +++ b/VectoCore/VectoCore/OutputData/XML/XMLVTPReport.cs @@ -111,6 +111,10 @@ namespace TUGraz.VectoCore.OutputData.XML target.Parameters.Add(new MethodCallParameter("${level}")); target.Parameters.Add(new MethodCallParameter("${message}")); var config = LogManager.Configuration; + if (config == null) { + config = new LoggingConfiguration(); + LogManager.Configuration = config; + } cycleChecksRule = new LoggingRule(typeof(VTPCycle).FullName, LogLevel.Error, target); config.AddTarget(VTPReportTartetName, target); config.LoggingRules.Add(cycleChecksRule); diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/VTPCycleValidationTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/VTPCycleValidationTest.cs index b713e4c8a6b88253209498abddf09699275e6d29..dcebf21ca4aa6f48fb4432876c30fdba6338db52 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/VTPCycleValidationTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/VTPCycleValidationTest.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using NLog; using NLog.Config; using NLog.Targets; @@ -398,11 +399,14 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent { SetupLogging(); - var fanSpeed = 0.95 * DeclarationData.VTPMode.MaxFanSpeed.AsRPM; + // Approach: calculate min. FC for a certain FC in g/kWh (cycle demands ~10kW constant, i.e., 500NM @ 100rpm at both wheels) + // construct cycle with slightly decreasing FC so that FC falls below threshold + var fcLimit = (DeclarationData.VTPMode.LowerFCThreshold * (2 * 500.SI<NewtonMeter>() * 100.RPMtoRad())).Cast<KilogramPerSecond>(); + var cycleEntries = ""; for (var i = 0; i < 2000; i++) - cycleEntries += string.Format(" {0} , 0, 600, 400, 300 , 290 , 50 , 50 , {1}, 3 \n", i / 2.0, DeclarationData.VTPMode.LowerFCThreshold.ConvertToGrammPerHour() / 1.01); + cycleEntries += string.Format(" {0} , 0, 600, 400, 500 , 500 , 100 , 100 , {1}, 3 \n", i / 2.0, (fcLimit * 1.01 * (1 - i/100000.0)).ConvertToGrammPerHour().Value); var container = new VehicleContainer(ExecutionMode.Declaration) { RunData = new VectoRunData() { @@ -412,9 +416,11 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var cycle = InputDataHelper.InputDataAsStream(Header, cycleEntries.Split('\n')); var cycleData = DrivingCycleDataReader.ReadFromDataTable(VectoCSVFile.ReadStream(cycle), "VTP Cycle", false); var vtpCycle = new VTPCycle(container, cycleData); + vtpCycle.PrepareCycleData(); vtpCycle.VerifyInputData(); Assert.Greater(LogList.Count, 1); + Assert.IsTrue(LogList.Any(x => x.StartsWith("Fuel consumption for the previous 10 [min] below threshold"))); } @@ -423,11 +429,14 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent { SetupLogging(); - var fanSpeed = 0.95 * DeclarationData.VTPMode.MaxFanSpeed.AsRPM; + // Approach: calculate min. FC for a certain FC in g/kWh (cycle demands ~10kW constant, i.e., 500NM @ 100rpm at both wheels) + // construct cycle with constant FC slightly above min. FC + + var fcLimit = (DeclarationData.VTPMode.LowerFCThreshold * (2 * 500.SI<NewtonMeter>() * 100.RPMtoRad())).Cast<KilogramPerSecond>(); var cycleEntries = ""; for (var i = 0; i < 2000; i++) - cycleEntries += string.Format(" {0} , 0, 600, 400, 300 , 290 , 50 , 50 , {1}, 3 \n", i / 2.0, DeclarationData.VTPMode.LowerFCThreshold.ConvertToGrammPerHour() * 1.01); + cycleEntries += string.Format(" {0} , 0, 600, 400, 500 , 500 , 100 , 100 , {1}, 3 \n", i / 2.0, (fcLimit * 1.0001).ConvertToGrammPerHour().Value); var container = new VehicleContainer(ExecutionMode.Declaration) { RunData = new VectoRunData() { @@ -437,6 +446,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var cycle = InputDataHelper.InputDataAsStream(Header, cycleEntries.Split('\n')); var cycleData = DrivingCycleDataReader.ReadFromDataTable(VectoCSVFile.ReadStream(cycle), "VTP Cycle", false); var vtpCycle = new VTPCycle(container, cycleData); + vtpCycle.PrepareCycleData(); vtpCycle.VerifyInputData(); Assert.AreEqual(0, LogList.Count); @@ -448,11 +458,14 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent { SetupLogging(); - var fanSpeed = 0.95 * DeclarationData.VTPMode.MaxFanSpeed.AsRPM; + // Approach: calculate max. FC for a certain FC in g/kWh (cycle demands ~10kW constant, i.e., 500NM @ 100rpm at both wheels) + // construct cycle with slightly decreasing FC so that FC falls below threshold + + var fcLimit = (DeclarationData.VTPMode.UpperFCThreshold * (2 * 500.SI<NewtonMeter>() * 100.RPMtoRad())).Cast<KilogramPerSecond>(); var cycleEntries = ""; for (var i = 0; i < 2000; i++) - cycleEntries += string.Format(" {0} , 0, 600, 400, 300 , 290 , 50 , 50 , {1}, 3 \n", i / 2.0, DeclarationData.VTPMode.UpperFCThreshold.ConvertToGrammPerHour() * 1.01); + cycleEntries += string.Format(" {0} , 0, 600, 400, 500 , 500 , 100 , 100 , {1}, 3 \n", i / 2.0, (fcLimit * 0.99 * (1 + i / 100000.0)).ConvertToGrammPerHour().Value); var container = new VehicleContainer(ExecutionMode.Declaration) { RunData = new VectoRunData() { @@ -462,10 +475,11 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var cycle = InputDataHelper.InputDataAsStream(Header, cycleEntries.Split('\n')); var cycleData = DrivingCycleDataReader.ReadFromDataTable(VectoCSVFile.ReadStream(cycle), "VTP Cycle", false); var vtpCycle = new VTPCycle(container, cycleData); + vtpCycle.PrepareCycleData(); vtpCycle.VerifyInputData(); Assert.Greater(LogList.Count, 1); - + Assert.IsTrue(LogList.Any(x => x.StartsWith("Fuel consumption for the previous 10 [min] above threshold"))); } [TestCase()] @@ -473,11 +487,14 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent { SetupLogging(); - var fanSpeed = 0.95 * DeclarationData.VTPMode.MaxFanSpeed.AsRPM; + // Approach: calculate max. FC for a certain FC in g/kWh (cycle demands ~10kW constant, i.e., 500NM @ 100rpm at both wheels) + // construct cycle with constant FC slightly below max FC + + var fcLimit = (DeclarationData.VTPMode.UpperFCThreshold * (2 * 500.SI<NewtonMeter>() * 100.RPMtoRad())).Cast<KilogramPerSecond>(); var cycleEntries = ""; for (var i = 0; i < 2000; i++) - cycleEntries += string.Format(" {0} , 0, 600, 400, 300 , 290 , 50 , 50 , {1}, 3 \n", i / 2.0, DeclarationData.VTPMode.UpperFCThreshold.ConvertToGrammPerHour() / 1.01); + cycleEntries += string.Format(" {0} , 0, 600, 400, 500 , 500 , 100 , 100 , {1}, 3 \n", i / 2.0, (fcLimit * 0.9999).ConvertToGrammPerHour().Value); var container = new VehicleContainer(ExecutionMode.Declaration) { RunData = new VectoRunData() { @@ -487,6 +504,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var cycle = InputDataHelper.InputDataAsStream(Header, cycleEntries.Split('\n')); var cycleData = DrivingCycleDataReader.ReadFromDataTable(VectoCSVFile.ReadStream(cycle), "VTP Cycle", false); var vtpCycle = new VTPCycle(container, cycleData); + vtpCycle.PrepareCycleData(); vtpCycle.VerifyInputData(); Assert.AreEqual(0, LogList.Count);