diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeVectoRunDataFactory.cs index 5b721125cc1654c5d802a1c21f57459edfb9cce2..9e4e04a75d05ead2796c41601e887a87e8a5dca2 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeVectoRunDataFactory.cs @@ -228,7 +228,6 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl mission.MissionType.GetNonEMSMissionType(), _engineData.WHTCRural, _engineData.WHTCUrban, _engineData.WHTCMotorway) * _engineData.ColdHotCorrectionFactor * _engineData.CorrectionFactorRegPer; - simulationRunData.EngineData.NCVCorrectionFactor = _engineData.FuelData.HeatingValueCorrection; simulationRunData.EngineData.ADASCorrectionFactor = DeclarationData.ADASBenefits.Lookup( _segment.VehicleClass, adasCombination, mission.MissionType, loading.Key); simulationRunData.VehicleData.VehicleClass = _segment.VehicleClass; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs index be6fd63edf1176416e35fc9fe343d2d231ae76c4..97fcc6e22c32a916a92ebe9d920652fa01be00ad 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs @@ -83,8 +83,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data public NewtonMeter MaxTorqueDeclared { get; internal set; } public FuelData.Entry FuelData { get; internal set; } - public double NCVCorrectionFactor { get; set; } - + public CombustionEngineData() { WHTCUrban = 1; @@ -93,7 +92,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data CorrectionFactorRegPer = 1; FuelConsumptionCorrectionFactor = 1; ADASCorrectionFactor = 1; - NCVCorrectionFactor = 1; } public CombustionEngineData Copy() @@ -117,7 +115,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data MaxTorqueDeclared = MaxTorqueDeclared, FuelData = FuelData, ADASCorrectionFactor = ADASCorrectionFactor, - NCVCorrectionFactor = NCVCorrectionFactor }; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs index 71894fc589448444dc7cdc2bfe7f5284bdb638fe..73d68125283bf90786f64d13d5f2c7ee24e98cc0 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs @@ -396,7 +396,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } var fc = result.Value; - var fcNCVcorr = fc * ModelData.NCVCorrectionFactor; // TODO: wird fcNCVcorr + var fcNCVcorr = fc * ModelData.FuelData.HeatingValueCorrection; // TODO: wird fcNCVcorr var fcWHTC = fcNCVcorr * WHTCCorrectionFactor; var fcAAUX = fcWHTC; diff --git a/VectoCore/VectoCore/Resources/Declaration/FuelTypes.csv b/VectoCore/VectoCore/Resources/Declaration/FuelTypes.csv index 672b035c4ecf0bc5bd09e9773a3d81e77f7cd43f..e8b77ff7d316267019af822a1195251daec73b74 100644 --- a/VectoCore/VectoCore/Resources/Declaration/FuelTypes.csv +++ b/VectoCore/VectoCore/Resources/Declaration/FuelTypes.csv @@ -1,22 +1,10 @@ FuelType , Tanksystem , FuelDensity [kg/m3] , CO2 per FuelWeight [kgCo2/kgFuel] , NCV_stdEngine [kJ/kg] , NCV_stdVecto [kJ/kg] Diesel CI , , 836 , 3.13 , 42700 , 42700 -Ethanol CI , , 820 , 1.83 , 25700 , 25700 +Ethanol CI , , 820 , 1.81 , 25700 , 25400 Petrol PI , , 748 , 3.04 , 41500 , 41500 -Ethanol PI , , 786 , 2.09 , 29100 , 29100 +Ethanol PI , , 786 , 2.10 , 29100 , 29300 LPG PI , , , 3.02 , 46000 , 46000 -NG PI , compressed , , 2.54 , 45100 , 45100 -NG PI , liquefied , , 2.77 , 45100 , 45100 +NG PI , compressed , , 2.69 , 45100 , 48000 +NG PI , liquefied , , 2.77 , 45100 , 49100 NG CI , compressed , , 1000 , 100000 , 100000 -NG CI , liquefied , , 1000 , 100000 , 100000 - -##NEW -#FuelType , Tanksystem , FuelDensity [kg/m3] , CO2 per FuelWeight [kgCo2/kgFuel] , NCV_stdEngine [kJ/kg] , NCV_stdVecto [kJ/kg] -#Diesel CI , , 836 , 3.13 , 42700 , 42700 -#Ethanol CI , , 820 , 1.81 , 25700 , 25400 -#Petrol PI , , 748 , 3.04 , 41500 , 41500 -#Ethanol PI , , 786 , 2.10 , 29100 , 29300 -#LPG PI , , , 3.02 , 46000 , 46000 -#NG PI , compressed , , 2.69 , 45100 , 48000 -#NG PI , liquefied , , 2.77 , 45100 , 49100 -#NG CI , compressed , , 1000 , 100000 , 100000 -#NG CI , liquefied , , 1000 , 100000 , 100000 \ No newline at end of file +NG CI , liquefied , , 1000 , 100000 , 100000 \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/Integration/FuelTypesTest.cs b/VectoCore/VectoCoreTest/Integration/FuelTypesTest.cs index d0b1144f7a0bcd13c0bcaee83a08d1afeabb5796..9abec0524a5a6f7989f67d65d10bcb2482744aa7 100644 --- a/VectoCore/VectoCoreTest/Integration/FuelTypesTest.cs +++ b/VectoCore/VectoCoreTest/Integration/FuelTypesTest.cs @@ -29,9 +29,12 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ +using System; using System.IO; using NUnit.Framework; +using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.InputData.FileIO.JSON; using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Models.Simulation.Impl; @@ -50,19 +53,46 @@ namespace TUGraz.VectoCore.Tests.Integration Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory); } - [TestCase(FuelType.DieselCI, - @"TestData\Integration\DeclarationMode\Class2_RigidTruck_4x2\Class2_RigidTruck_DECL.vecto", 0, 0.0006886, 9391.5411, + [TestCase(FuelType.DieselCI, null, + @"TestData\Integration\DeclarationMode\Class2_RigidTruck_4x2\Class2_RigidTruck_DECL.vecto", 0, + 0.0002199424, 0.0002199424, 26.308901, 0.0006886, 9391.5411, TestName = "Diesel LH Low"), - TestCase(FuelType.EthanolCI, - @"TestData\Integration\DeclarationMode\Class2_RigidTruck_4x2\Class2_RigidTruck_DECL.vecto", 0, 0.00040262, 5652.5200, - TestName = "Ethanol LH Low"), - TestCase(FuelType.DieselCI, - @"TestData\Integration\DeclarationMode\Class2_RigidTruck_4x2\Class2_RigidTruck_DECL.vecto", 1, 0.0007971, 10876.9518, + TestCase(FuelType.EthanolCI, null, + @"TestData\Integration\DeclarationMode\Class2_RigidTruck_4x2\Class2_RigidTruck_DECL.vecto", 0, + 0.0002199424, 0.0002225401, 27.1390439, 0.000402797, 5652.5200, + TestName = "Ethanol/CI LH Low"), + + TestCase(FuelType.DieselCI, null, + @"TestData\Integration\DeclarationMode\Class2_RigidTruck_4x2\Class2_RigidTruck_DECL.vecto", 1, + 0.0002547295, 0.0002547295, 30.4700418, 0.0007971, 10876.9518, TestName = "Diesel LH Ref"), - TestCase(FuelType.EthanolCI, - @"TestData\Integration\DeclarationMode\Class2_RigidTruck_4x2\Class2_RigidTruck_DECL.vecto", 1, 0.0004660, 6546.5494, - TestName = "Ethanol LH Ref"),] - public void TestFuelTypesCO2(FuelType fuelType, string jobName, int runIdx, double expectedCo2, double expectedMJ) + TestCase(FuelType.EthanolCI, null, + @"TestData\Integration\DeclarationMode\Class2_RigidTruck_4x2\Class2_RigidTruck_DECL.vecto", 1, + 0.0002547295, 0.000257738, 31.4314837, 0.00046650, 6546.5494, + TestName = "Ethanol/CI LH Ref"), + TestCase(FuelType.EthanolPI, null, + @"TestData\Integration\DeclarationMode\Class2_RigidTruck_4x2\Class2_RigidTruck_DECL.vecto", 1, + 0.0002547295, 0.00025299078, 32.1871223, 0.0005312806, 7412.62989, + TestName = "Ethanol/PI LH Ref"), + TestCase(FuelType.PetrolPI, null, + @"TestData\Integration\DeclarationMode\Class2_RigidTruck_4x2\Class2_RigidTruck_DECL.vecto", 1, + 0.0002547295, 0.00025472954, 34.054752636, 0.0007743778, 10571.27631, + TestName = "Petrol/PI LH Ref"), + TestCase(FuelType.LPGPI, null, + @"TestData\Integration\DeclarationMode\Class2_RigidTruck_4x2\Class2_RigidTruck_DECL.vecto", 1, + 0.0002547295, 0.0002547295, double.NaN, 0.00076928, 11717.55928, + TestName = "LPG/PI LH Ref"), + TestCase(FuelType.NGPI, TankSystem.Liquefied, + @"TestData\Integration\DeclarationMode\Class2_RigidTruck_4x2\Class2_RigidTruck_DECL.vecto", 1, + 0.0002547295, 0.00023397765, double.NaN, 0.00064811809, 11488.30269, + TestName = "LNG/PI LH Ref"), + TestCase(FuelType.NGPI, TankSystem.Compressed, + @"TestData\Integration\DeclarationMode\Class2_RigidTruck_4x2\Class2_RigidTruck_DECL.vecto", 1, + 0.0002547295, 0.0002393396, double.NaN, 0.000643823, 11488.30269, + TestName = "CNG/PI LH Ref"), + ] + public void TestFuelTypesCO2(FuelType fuelType, TankSystem? tankSystem, string jobName, int runIdx, + double expectedFCMap, double expectedFCFinal, double expectedFCperkm, double expectedCo2, double expectedMJ) { // the same engine fc-map is used for different fuel types, thus the difference in expected results var fileWriter = new FileOutputWriter(jobName); @@ -82,13 +112,27 @@ namespace TUGraz.VectoCore.Tests.Integration var run = jobContainer.Runs[runIdx]; var modContainer = (ModalDataContainer)run.Run.GetContainer().ModalData; var modData = modContainer.Data; - modContainer.FuelData = FuelData.Instance().Lookup(fuelType); + + var fuelData = FuelData.Instance().Lookup(fuelType, tankSystem); + modContainer.FuelData = fuelData; + ((VehicleContainer)run.Run.GetContainer()).RunData.EngineData.FuelData = fuelData; run.Run.Run(); // restore data table before assertions modContainer.Data = modData; + + Console.WriteLine("FC-Map g/m: {0}, FC-Final g/m {1}, FC-Final l/100km: {2}, CO2 g/m: {3}, Energy J/m: {4}", + modContainer.FCMapPerMeter().Value(), + modContainer.FuelConsumptionFinal().Value(), + modContainer.FuelConsumptionFinalVolumePerMeter()?.ConvertToLiterPer100Kilometer().Value ?? double.NaN, + modContainer.CO2PerMeter().Value(), + modContainer.EnergyPerMeter().Value()); + Assert.AreEqual(expectedFCMap, modContainer.FCMapPerMeter().Value(), 1e-6); + Assert.AreEqual(expectedFCFinal, modContainer.FuelConsumptionFinal().Value(), 1e-3); + Assert.AreEqual(expectedFCperkm, modContainer.FuelConsumptionFinalVolumePerMeter()?.ConvertToLiterPer100Kilometer().Value ?? double.NaN, 1e-6); + Assert.AreEqual(expectedCo2, modContainer.CO2PerMeter().Value(), 1e-6); Assert.AreEqual(expectedMJ, modContainer.EnergyPerMeter().Value(), 1e-3); } diff --git a/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs b/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs index a9b44abd354bd7bbabf6d77620fb4c3290a05c86..43e06d1c7be72a656d39de29232d864b5f30e270 100644 --- a/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs +++ b/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs @@ -2057,10 +2057,11 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration [ TestCase("Diesel CI", null, 1.0), - TestCase("Ethanol CI", null, 1.0), - TestCase("Ethanol PI", null, 1.0), - TestCase("NG PI", TankSystem.Liquefied, 1.0), - TestCase("NG PI", TankSystem.Compressed, 1.0) + TestCase("Ethanol CI", null, 1.011811), + TestCase("Petrol PI", null, 1.0), + TestCase("Ethanol PI", null, 0.993174), + TestCase("NG PI", TankSystem.Liquefied, 0.918533), + TestCase("NG PI", TankSystem.Compressed, 0.939583) ] public void TestNCVCorrection(string fuelTypeStr, TankSystem? tankSystem, double expectedCorrectionFactor) { diff --git a/VectoCore/VectoCoreTest/XML/XMLDeclarationInputTest.cs b/VectoCore/VectoCoreTest/XML/XMLDeclarationInputTest.cs index 5a7c1398e6a3ab07139ee2e52c3b14df3bfafbc6..32fa277ddf2585eded1eb86b674c3af463a376f0 100644 --- a/VectoCore/VectoCoreTest/XML/XMLDeclarationInputTest.cs +++ b/VectoCore/VectoCoreTest/XML/XMLDeclarationInputTest.cs @@ -127,22 +127,22 @@ namespace TUGraz.VectoCore.Tests.XML var helper = new XPathHelper(ExecutionMode.Declaration); helper.AddNamespaces(manager); - var technology = nav.SelectSingleNode(helper.QueryAbs( + var EngineFuelType = nav.SelectSingleNode(helper.QueryAbs( helper.NSPrefix(XMLNames.VectoInputDeclaration, Constants.XML.RootNSPrefix), XMLNames.Component_Vehicle, XMLNames.Vehicle_Components, XMLNames.Component_Engine, XMLNames.ComponentDataWrapper, XMLNames.Engine_FuelType), manager); - technology.SetValue(fuel); + EngineFuelType.SetValue(fuel); var modified = XmlReader.Create(new StringReader(nav.OuterXml)); var inputDataProvider = new XMLDeclarationInputDataProvider(modified, true); - var techInput = inputDataProvider.JobInputData.Vehicle.EngineInputData.FuelType; - Assert.AreEqual(fuel, techInput.ToXMLFormat()); - - Assert.NotNull(DeclarationData.FuelData.Lookup(techInput)); + var fuelTyle = inputDataProvider.JobInputData.Vehicle.EngineInputData.FuelType; + Assert.AreEqual(fuel, fuelTyle.ToXMLFormat()); + var tankSystem = fuelTyle == FuelType.NGPI || fuelTyle == FuelType.NGCI ? TankSystem.Liquefied : (TankSystem?)null; + Assert.NotNull(DeclarationData.FuelData.Lookup(fuelTyle, tankSystem)); } }