Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 5049901f authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

correct testcases for fuel-consumption in VTP calculation

parent 1bf55295
No related branches found
No related tags found
No related merge requests found
...@@ -524,6 +524,7 @@ namespace TUGraz.VectoCore.Models.Declaration ...@@ -524,6 +524,7 @@ namespace TUGraz.VectoCore.Models.Declaration
public static readonly Second SamplingInterval = 0.5.SI<Second>(); 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 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 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>(); public static readonly Second FCAccumulationWindow = 10.SI(Unit.SI.Minute).Cast<Second>();
......
...@@ -61,7 +61,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -61,7 +61,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
return base.Initialize(); return base.Initialize();
} }
private void PrepareCycleData() protected internal void PrepareCycleData()
{ {
foreach (var entry in Data.Entries) { foreach (var entry in Data.Entries) {
var wheelSpeed = (entry.WheelSpeedLeft + entry.WheelSpeedRight) / 2; var wheelSpeed = (entry.WheelSpeedLeft + entry.WheelSpeedRight) / 2;
...@@ -117,7 +117,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -117,7 +117,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
sumEWheel -= window[(idx + 1) % count].EWheel; sumEWheel -= window[(idx + 1) % count].EWheel;
idx++; idx++;
if (sumEWheel.IsSmaller(1.SI(Unit.SI.Kilo.Watt.Hour))) { if (sumEWheel.IsSmaller(DeclarationData.VTPMode.MinPosWorkAtWheelsForFC)) {
continue; continue;
} }
if (sumFC / sumEWheel < DeclarationData.VTPMode.LowerFCThreshold ) { if (sumFC / sumEWheel < DeclarationData.VTPMode.LowerFCThreshold ) {
......
...@@ -111,6 +111,10 @@ namespace TUGraz.VectoCore.OutputData.XML ...@@ -111,6 +111,10 @@ namespace TUGraz.VectoCore.OutputData.XML
target.Parameters.Add(new MethodCallParameter("${level}")); target.Parameters.Add(new MethodCallParameter("${level}"));
target.Parameters.Add(new MethodCallParameter("${message}")); target.Parameters.Add(new MethodCallParameter("${message}"));
var config = LogManager.Configuration; var config = LogManager.Configuration;
if (config == null) {
config = new LoggingConfiguration();
LogManager.Configuration = config;
}
cycleChecksRule = new LoggingRule(typeof(VTPCycle).FullName, LogLevel.Error, target); cycleChecksRule = new LoggingRule(typeof(VTPCycle).FullName, LogLevel.Error, target);
config.AddTarget(VTPReportTartetName, target); config.AddTarget(VTPReportTartetName, target);
config.LoggingRules.Add(cycleChecksRule); config.LoggingRules.Add(cycleChecksRule);
......
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using NLog; using NLog;
using NLog.Config; using NLog.Config;
using NLog.Targets; using NLog.Targets;
...@@ -398,11 +399,14 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent ...@@ -398,11 +399,14 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
{ {
SetupLogging(); 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 = ""; var cycleEntries = "";
for (var i = 0; i < 2000; i++) 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) { var container = new VehicleContainer(ExecutionMode.Declaration) {
RunData = new VectoRunData() { RunData = new VectoRunData() {
...@@ -412,9 +416,11 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent ...@@ -412,9 +416,11 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
var cycle = InputDataHelper.InputDataAsStream(Header, cycleEntries.Split('\n')); var cycle = InputDataHelper.InputDataAsStream(Header, cycleEntries.Split('\n'));
var cycleData = DrivingCycleDataReader.ReadFromDataTable(VectoCSVFile.ReadStream(cycle), "VTP Cycle", false); var cycleData = DrivingCycleDataReader.ReadFromDataTable(VectoCSVFile.ReadStream(cycle), "VTP Cycle", false);
var vtpCycle = new VTPCycle(container, cycleData); var vtpCycle = new VTPCycle(container, cycleData);
vtpCycle.PrepareCycleData();
vtpCycle.VerifyInputData(); vtpCycle.VerifyInputData();
Assert.Greater(LogList.Count, 1); 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 ...@@ -423,11 +429,14 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
{ {
SetupLogging(); 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 = ""; var cycleEntries = "";
for (var i = 0; i < 2000; i++) 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) { var container = new VehicleContainer(ExecutionMode.Declaration) {
RunData = new VectoRunData() { RunData = new VectoRunData() {
...@@ -437,6 +446,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent ...@@ -437,6 +446,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
var cycle = InputDataHelper.InputDataAsStream(Header, cycleEntries.Split('\n')); var cycle = InputDataHelper.InputDataAsStream(Header, cycleEntries.Split('\n'));
var cycleData = DrivingCycleDataReader.ReadFromDataTable(VectoCSVFile.ReadStream(cycle), "VTP Cycle", false); var cycleData = DrivingCycleDataReader.ReadFromDataTable(VectoCSVFile.ReadStream(cycle), "VTP Cycle", false);
var vtpCycle = new VTPCycle(container, cycleData); var vtpCycle = new VTPCycle(container, cycleData);
vtpCycle.PrepareCycleData();
vtpCycle.VerifyInputData(); vtpCycle.VerifyInputData();
Assert.AreEqual(0, LogList.Count); Assert.AreEqual(0, LogList.Count);
...@@ -448,11 +458,14 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent ...@@ -448,11 +458,14 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
{ {
SetupLogging(); 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 = ""; var cycleEntries = "";
for (var i = 0; i < 2000; i++) 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) { var container = new VehicleContainer(ExecutionMode.Declaration) {
RunData = new VectoRunData() { RunData = new VectoRunData() {
...@@ -462,10 +475,11 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent ...@@ -462,10 +475,11 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
var cycle = InputDataHelper.InputDataAsStream(Header, cycleEntries.Split('\n')); var cycle = InputDataHelper.InputDataAsStream(Header, cycleEntries.Split('\n'));
var cycleData = DrivingCycleDataReader.ReadFromDataTable(VectoCSVFile.ReadStream(cycle), "VTP Cycle", false); var cycleData = DrivingCycleDataReader.ReadFromDataTable(VectoCSVFile.ReadStream(cycle), "VTP Cycle", false);
var vtpCycle = new VTPCycle(container, cycleData); var vtpCycle = new VTPCycle(container, cycleData);
vtpCycle.PrepareCycleData();
vtpCycle.VerifyInputData(); vtpCycle.VerifyInputData();
Assert.Greater(LogList.Count, 1); Assert.Greater(LogList.Count, 1);
Assert.IsTrue(LogList.Any(x => x.StartsWith("Fuel consumption for the previous 10 [min] above threshold")));
} }
[TestCase()] [TestCase()]
...@@ -473,11 +487,14 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent ...@@ -473,11 +487,14 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
{ {
SetupLogging(); 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 = ""; var cycleEntries = "";
for (var i = 0; i < 2000; i++) 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) { var container = new VehicleContainer(ExecutionMode.Declaration) {
RunData = new VectoRunData() { RunData = new VectoRunData() {
...@@ -487,6 +504,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent ...@@ -487,6 +504,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
var cycle = InputDataHelper.InputDataAsStream(Header, cycleEntries.Split('\n')); var cycle = InputDataHelper.InputDataAsStream(Header, cycleEntries.Split('\n'));
var cycleData = DrivingCycleDataReader.ReadFromDataTable(VectoCSVFile.ReadStream(cycle), "VTP Cycle", false); var cycleData = DrivingCycleDataReader.ReadFromDataTable(VectoCSVFile.ReadStream(cycle), "VTP Cycle", false);
var vtpCycle = new VTPCycle(container, cycleData); var vtpCycle = new VTPCycle(container, cycleData);
vtpCycle.PrepareCycleData();
vtpCycle.VerifyInputData(); vtpCycle.VerifyInputData();
Assert.AreEqual(0, LogList.Count); Assert.AreEqual(0, LogList.Count);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment