From cc54aaf048c2be8218c675b70289b38342e909c9 Mon Sep 17 00:00:00 2001 From: Markus Quaritsch <markus.quaritsch@tugraz.at> Date: Mon, 23 Mar 2015 16:15:04 +0100 Subject: [PATCH] adding addtional test-cases for engine-only simulation. results match with modified Vecto 2.0 engine-only computation --- .../Simulation/Impl/SimulationFactory.cs | 1 + .../Data/DrivingCycleData.cs | 40 +++++++++---------- VectoCore/VectoCore.csproj | 1 + .../Models/Simulation/DrivingCycleTests.cs | 1 + .../CombustionEngineTest.cs | 22 +++++++++- 5 files changed, 44 insertions(+), 21 deletions(-) diff --git a/VectoCore/Models/Simulation/Impl/SimulationFactory.cs b/VectoCore/Models/Simulation/Impl/SimulationFactory.cs index bc3dcb7224..98782e2b94 100644 --- a/VectoCore/Models/Simulation/Impl/SimulationFactory.cs +++ b/VectoCore/Models/Simulation/Impl/SimulationFactory.cs @@ -3,6 +3,7 @@ using Common.Logging; using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Models.SimulationComponent.Impl; +using EngineOnlyDrivingCycle = TUGraz.VectoCore.Models.SimulationComponent.Impl.EngineOnlyDrivingCycle; namespace TUGraz.VectoCore.Models.Simulation.Impl { diff --git a/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs b/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs index 02084c8ba4..25512f938d 100644 --- a/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs +++ b/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs @@ -259,14 +259,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data { var entry = new DrivingCycleEntry { - Distance = row.GetDouble(Fields.Distance), - VehicleSpeed = row.GetDouble(Fields.VehicleSpeed), - RoadGradient = row.GetDoubleOrDefault(Fields.RoadGradient), - AdditionalAuxPowerDemand = row.GetDoubleOrDefault(Fields.AdditionalAuxPowerDemand), - EngineSpeed = row.GetDoubleOrDefault(Fields.EngineSpeed), - Gear = row.GetDoubleOrDefault(Fields.Gear), - AirSpeedRelativeToVehicle = row.GetDoubleOrDefault(Fields.AirSpeedRelativeToVehicle), - WindYawAngle = row.GetDoubleOrDefault(Fields.WindYawAngle) + Distance = row.ParseDouble(Fields.Distance), + VehicleSpeed = row.ParseDouble(Fields.VehicleSpeed), + RoadGradient = row.ParseDoubleOrGetDefault(Fields.RoadGradient), + AdditionalAuxPowerDemand = row.ParseDoubleOrGetDefault(Fields.AdditionalAuxPowerDemand), + EngineSpeed = row.ParseDoubleOrGetDefault(Fields.EngineSpeed), + Gear = row.ParseDoubleOrGetDefault(Fields.Gear), + AirSpeedRelativeToVehicle = row.ParseDoubleOrGetDefault(Fields.AirSpeedRelativeToVehicle), + WindYawAngle = row.ParseDoubleOrGetDefault(Fields.WindYawAngle) }; // todo: implement additional aux as dictionary! @@ -300,14 +300,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data { var entry = new DrivingCycleEntry { - Time = row.GetDoubleOrDefault(Fields.Time), - VehicleSpeed = row.GetDouble(Fields.VehicleSpeed), - RoadGradient = row.GetDoubleOrDefault(Fields.RoadGradient), - AdditionalAuxPowerDemand = row.GetDoubleOrDefault(Fields.AdditionalAuxPowerDemand), - Gear = row.GetDoubleOrDefault(Fields.Gear), - EngineSpeed = row.GetDoubleOrDefault(Fields.EngineSpeed), - AirSpeedRelativeToVehicle = row.GetDoubleOrDefault(Fields.AirSpeedRelativeToVehicle), - WindYawAngle = row.GetDoubleOrDefault(Fields.WindYawAngle) + Time = row.ParseDoubleOrGetDefault(Fields.Time), + VehicleSpeed = row.ParseDouble(Fields.VehicleSpeed), + RoadGradient = row.ParseDoubleOrGetDefault(Fields.RoadGradient), + AdditionalAuxPowerDemand = row.ParseDoubleOrGetDefault(Fields.AdditionalAuxPowerDemand), + Gear = row.ParseDoubleOrGetDefault(Fields.Gear), + EngineSpeed = row.ParseDoubleOrGetDefault(Fields.EngineSpeed), + AirSpeedRelativeToVehicle = row.ParseDoubleOrGetDefault(Fields.AirSpeedRelativeToVehicle), + WindYawAngle = row.ParseDoubleOrGetDefault(Fields.WindYawAngle) }; // todo: implement additional aux as dictionary! @@ -339,25 +339,25 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data { var entry = new DrivingCycleEntry(); - entry.EngineSpeed = row.GetDouble(Fields.EngineSpeed); + entry.EngineSpeed = row.ParseDouble(Fields.EngineSpeed); if (row.Table.Columns.Contains(Fields.EngineTorque)) { if (row.Field<string>(Fields.EngineTorque).Equals("<DRAG>")) entry.Drag = true; else - entry.EngineTorque = row.GetDouble(Fields.EngineTorque); + entry.EngineTorque = row.ParseDouble(Fields.EngineTorque); } else { if (row.Field<string>(Fields.EnginePower).Equals("<DRAG>")) entry.Drag = true; else - entry.EngineTorque = VectoMath.ConvertPowerToTorque(row.GetDouble(Fields.EnginePower), entry.EngineSpeed); + entry.EngineTorque = VectoMath.ConvertPowerToTorque(row.ParseDouble(Fields.EnginePower), entry.EngineSpeed); } if (row.Table.Columns.Contains(Fields.AdditionalAuxPowerDemand)) - entry.AdditionalAuxPowerDemand = row.GetDouble(Fields.AdditionalAuxPowerDemand); + entry.AdditionalAuxPowerDemand = row.ParseDouble(Fields.AdditionalAuxPowerDemand); return entry; } diff --git a/VectoCore/VectoCore.csproj b/VectoCore/VectoCore.csproj index 0e5c752c70..0f12f1278d 100644 --- a/VectoCore/VectoCore.csproj +++ b/VectoCore/VectoCore.csproj @@ -82,6 +82,7 @@ <Compile Include="Models\SimulationComponent\IDrivingCycle.cs" /> <Compile Include="Models\SimulationComponent\Impl\DistanceBasedDrivingCycle.cs" /> <Compile Include="Models\SimulationComponent\Impl\TimeBasedDrivingCycle.cs" /> + <Compile Include="Models\Simulation\Data\EngineOnlyDrivingCycle.cs" /> <Compile Include="Utils\IMemento.cs" /> <Compile Include="Models\SimulationComponent\Impl\CombustionEngine.cs" /> <Compile Include="Models\SimulationComponent\Impl\EngineOnlyGearbox.cs" /> diff --git a/VectoCoreTest/Models/Simulation/DrivingCycleTests.cs b/VectoCoreTest/Models/Simulation/DrivingCycleTests.cs index 03c771ef42..4bbc521bf7 100644 --- a/VectoCoreTest/Models/Simulation/DrivingCycleTests.cs +++ b/VectoCoreTest/Models/Simulation/DrivingCycleTests.cs @@ -6,6 +6,7 @@ using TUGraz.VectoCore.Models.SimulationComponent; using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Models.SimulationComponent.Impl; using TUGraz.VectoCore.Tests.Utils; +using EngineOnlyDrivingCycle = TUGraz.VectoCore.Models.SimulationComponent.Impl.EngineOnlyDrivingCycle; namespace TUGraz.VectoCore.Tests.Models.Simulation { diff --git a/VectoCoreTest/Models/SimulationComponent/CombustionEngineTest.cs b/VectoCoreTest/Models/SimulationComponent/CombustionEngineTest.cs index 4721e7b2f2..2a18e2907d 100644 --- a/VectoCoreTest/Models/SimulationComponent/CombustionEngineTest.cs +++ b/VectoCoreTest/Models/SimulationComponent/CombustionEngineTest.cs @@ -81,15 +81,35 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent absTime += dt; } - port.Request(absTime, dt, VectoMath.ConvertPowerToTorque(2329.973, 644.4445), 644.4445); + engineSpeed = 644.4445; + port.Request(absTime, dt, VectoMath.ConvertPowerToTorque(2329.973, engineSpeed), engineSpeed); engine.CommitSimulationStep(dataWriter); absTime += dt; Assert.AreEqual(1152.40304, dataWriter.GetDouble(ModalResultField.PaEng), 0.001); + torque = 4264.177; for (var i = 0; i < 2; i++) { port.Request(absTime, dt, torque, engineSpeed); + engine.CommitSimulationStep(dataWriter); + absTime += dt; } + + engineSpeed = 869.7512; + port.Request(absTime, dt, VectoMath.ConvertPowerToTorque(7984.56, engineSpeed), engineSpeed); + engine.CommitSimulationStep(dataWriter); + absTime += dt; + + Assert.AreEqual(7108.32, dataWriter.GetDouble(ModalResultField.PaEng), 0.001); + + engineSpeed = 644.4445; + port.Request(absTime, dt, VectoMath.ConvertPowerToTorque(7984.56, engineSpeed), engineSpeed); + engine.CommitSimulationStep(dataWriter); + absTime += dt; + + Assert.AreEqual(-7108.32, dataWriter.GetDouble(ModalResultField.PaEng), 0.001); + + } [DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "|DataDirectory|\\TestData\\EngineTests.csv", "EngineTests#csv", DataAccessMethod.Sequential)] -- GitLab