diff --git a/VECTOAux/VectoAuxiliariesTests/IntegrationTests/AuxDemandTest.vb b/VECTOAux/VectoAuxiliariesTests/IntegrationTests/AuxDemandTest.vb index 6c1b7e8bff805348cf4c0b047a0480a54b77fbb6..1382c0b47883d7bf41f18362bef72769b8a5f0a5 100644 --- a/VECTOAux/VectoAuxiliariesTests/IntegrationTests/AuxDemandTest.vb +++ b/VECTOAux/VectoAuxiliariesTests/IntegrationTests/AuxDemandTest.vb @@ -47,5 +47,77 @@ Namespace IntegrationTests Assert.AreEqual(expectedPowerDemand, power, 0.0001) End Sub + + <Test> + Public Sub AuxFCConsumtionTest() + + Dim driveLinePower As Double = 148 + Dim internalPower As Double = 148 + Dim engineSpeed As Double = 1256 + + + Dim engineFCMapFilePath = "TestFiles\Integration\24t Coach.vmap" + Dim auxFilePath = "TestFiles\Integration\AdvAuxTest.aaux" + + Dim aux As AdvancedAuxiliaries = New AdvancedAuxiliaries + + aux.VectoInputs.Cycle = "Coach" + aux.VectoInputs.VehicleWeightKG = 12000 + aux.VectoInputs.FuelDensity = 0.832 + Dim fuelMap As cMAP = New cMAP() + fuelMap.FilePath = engineFCMapFilePath + fuelMap.ReadFile(False) + fuelMap.Triangulate() + + aux.VectoInputs.FuelMap = fuelMap + + + aux.Signals.TotalCycleTimeSeconds = 15000 + aux.Signals.EngineIdleSpeed = 560 + + aux.Initialise(Path.GetFileName(auxFilePath), Path.GetDirectoryName(Path.GetFullPath(auxFilePath)) + "\") + + aux.Signals.ClutchEngaged = True + aux.Signals.EngineDrivelinePower = driveLinePower 'kW + aux.Signals.EngineSpeed = engineSpeed 'rpm + aux.Signals.EngineDrivelineTorque = driveLinePower * 1000 / (1256 * 2 * Math.PI / 60) + aux.Signals.EngineMotoringPower = 24 'kW - has to be positive + + aux.Signals.PreExistingAuxPower = 0 + aux.Signals.Idle = False + aux.Signals.InNeutral = False + aux.Signals.RunningCalc = True + aux.Signals.Internal_Engine_Power = internalPower 'kW + + Dim msg As String + For i As Integer = 0 To 9 + Assert.AreEqual(4537.96826, aux.AuxiliaryPowerAtCrankWatts, 0.001) + aux.CycleStep(1, msg) + Next + + Assert.AreEqual(78.4127, aux.AA_TotalCycleFC_Grams, 0.0001) + + aux.Signals.EngineDrivelinePower = -15 + aux.Signals.EngineDrivelineTorque = aux.Signals.EngineDrivelinePower * 1000 / (1256 * 2 * Math.PI / 60) + aux.Signals.Internal_Engine_Power = -50 + + For i As Integer = 0 To 9 + Assert.AreEqual(7405.0791, aux.AuxiliaryPowerAtCrankWatts, 0.001) + aux.CycleStep(1, msg) + Next + + Assert.AreEqual(81.0836, aux.AA_TotalCycleFC_Grams, 0.0001) + + aux.Signals.EngineDrivelinePower = driveLinePower + aux.Signals.EngineDrivelineTorque = aux.Signals.EngineDrivelinePower * 1000 / (1256 * 2 * Math.PI / 60) + aux.Signals.Internal_Engine_Power = internalPower + + For i As Integer = 0 To 9 + Assert.AreEqual(4537.96826, aux.AuxiliaryPowerAtCrankWatts, 0.001) + aux.CycleStep(1, msg) + Next + + Assert.AreEqual(160.08049, aux.AA_TotalCycleFC_Grams, 0.0001) + End Sub End Class End Namespace \ No newline at end of file diff --git a/VectoCoreTest/Integration/BusAuxiliaries/AuxDemandTest.cs b/VectoCoreTest/Integration/BusAuxiliaries/AuxDemandTest.cs index 3407f80991a4552bee2399e5d3766c93da16426b..fa1c84b21c813b2611a64994a3321af20b9427d7 100644 --- a/VectoCoreTest/Integration/BusAuxiliaries/AuxDemandTest.cs +++ b/VectoCoreTest/Integration/BusAuxiliaries/AuxDemandTest.cs @@ -1,4 +1,6 @@ -using NUnit.Framework; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; +using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.Simulation.Impl; using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine; @@ -44,10 +46,80 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries var engineSpeed = engineSpeedRpm.RPMtoRad(); busAux.Initialize(engineDrivelinePower / engineSpeed, engineSpeed); - var power = busAux.PowerDemand(0.SI<Second>(), 1.SI<Second>(), engineDrivelinePower / engineSpeed, + var torque = busAux.PowerDemand(0.SI<Second>(), 1.SI<Second>(), engineDrivelinePower / engineSpeed, (internalPower * 1000).SI<Watt>() / engineSpeed, engineSpeed); - Assert.AreEqual(expectedPowerDemand, (power * engineSpeed).Value(), 1e-4); + Assert.AreEqual(expectedPowerDemand, (torque * engineSpeed).Value(), 1e-4); + } + + [Test] + public void AuxFCConsumptionTest() + { + var driveLinePower = 148; + var engineSpeedRpm = 1256; + var internalPower = 148; + + + var auxFilePath = @"TestData\Integration\BusAuxiliaries\AdvAuxTest.aaux"; + var engineFLDFilePath = @"TestData\Integration\BusAuxiliaries\24t Coach.vfld"; + var engineFCMapFilePath = @"TestData\Integration\BusAuxiliaries\24t Coach.vmap"; + + var vehicle = new VehicleContainer(); + var fcMap = FuelConsumptionMap.ReadFromFile(engineFCMapFilePath); + var fld = EngineFullLoadCurve.ReadFromFile(engineFLDFilePath); + var modelData = new CombustionEngineData() { + ConsumptionMap = fcMap, + FullLoadCurve = fld, + IdleSpeed = 560.SI<PerSecond>() + }; + + var engine = new CombustionEngine(vehicle, modelData); + //new Vehicle(vehicle, new VehicleData()); + var driver = new MockDriver(vehicle) { VehicleStopped = false }; + var gbx = new MockGearbox(vehicle) { Gear = 1 }; + + var busAux = new BusAuxiliariesAdapter(vehicle, auxFilePath, "Coach", 12000.SI<Kilogram>(), + fcMap, modelData.IdleSpeed); + + + var engineDrivelinePower = (driveLinePower * 1000).SI<Watt>(); + var engineSpeed = engineSpeedRpm.RPMtoRad(); + busAux.Initialize(engineDrivelinePower / engineSpeed, engineSpeed); + + var modalData = new MockModalDataContainer(); + + for (int i = 0; i < 10; i++) { + var torque = busAux.PowerDemand(0.SI<Second>(), 1.SI<Second>(), engineDrivelinePower / engineSpeed, + (internalPower * 1000).SI<Watt>() / engineSpeed, engineSpeed); + Assert.AreEqual(4537.96826, (torque * engineSpeed).Value(), 1e-3); + busAux.CommitSimulationStep(modalData); + } + + Assert.AreEqual(78.4127, ((SI)modalData[ModalResultField.AA_TotalCycleFC_Grams]).Value(), 0.0001); + + engineDrivelinePower = -15000.SI<Watt>(); + internalPower = -50; + + for (int i = 0; i < 10; i++) { + var torque = busAux.PowerDemand(0.SI<Second>(), 1.SI<Second>(), engineDrivelinePower / engineSpeed, + (internalPower * 1000).SI<Watt>() / engineSpeed, engineSpeed); + Assert.AreEqual(7405.0791, (torque * engineSpeed).Value(), 1e-3); + busAux.CommitSimulationStep(modalData); + } + + Assert.AreEqual(81.0836, ((SI)modalData[ModalResultField.AA_TotalCycleFC_Grams]).Value(), 0.0001); + + engineDrivelinePower = (driveLinePower * 1000).SI<Watt>(); + internalPower = 148; + + for (int i = 0; i < 10; i++) { + var torque = busAux.PowerDemand(0.SI<Second>(), 1.SI<Second>(), engineDrivelinePower / engineSpeed, + (internalPower * 1000).SI<Watt>() / engineSpeed, engineSpeed); + Assert.AreEqual(4537.96826, (torque * engineSpeed).Value(), 1e-3); + busAux.CommitSimulationStep(modalData); + } + + Assert.AreEqual(160.08049, ((SI)modalData[ModalResultField.AA_TotalCycleFC_Grams]).Value(), 0.0001); } } } \ No newline at end of file