diff --git a/VectoCoreTest/Integration/SimpleDrivingCycles.cs b/VectoCoreTest/Integration/SimpleDrivingCycles.cs index 4b1d3c06f7d5c058fd8d0604ed18d614cd5b7a83..80ca9514393add548e54057d0241e9d28145c2dc 100644 --- a/VectoCoreTest/Integration/SimpleDrivingCycles.cs +++ b/VectoCoreTest/Integration/SimpleDrivingCycles.cs @@ -28,16 +28,22 @@ namespace TUGraz.VectoCore.Tests.Integration public class SimpleDrivingCycles { public static DrivingCycleData CreateCycleData(string[] entries) + { + var cycleData = InputDataAsStream("<s>,<v>,<grad>,<stop>", entries); + return DrivingCycleDataReader.ReadFromStream(cycleData, CycleType.DistanceBased); + } + + public static MemoryStream InputDataAsStream(string header, string[] entries) { var cycleData = new MemoryStream(); var writer = new StreamWriter(cycleData); - writer.WriteLine("<s>,<v>,<grad>,<stop>"); + writer.WriteLine(header); foreach (var entry in entries) { writer.WriteLine(entry); } writer.Flush(); cycleData.Seek(0, SeekOrigin.Begin); - return DrivingCycleDataReader.ReadFromStream(cycleData, CycleType.DistanceBased); + return cycleData; } #region Accelerate diff --git a/VectoCoreTest/Models/SimulationComponentData/GearboxDataTest.cs b/VectoCoreTest/Models/SimulationComponentData/GearboxDataTest.cs index ccc6bff1cd77eb1689235a006dc5ed891df7bd3c..d72634a9ea613bff147b6c6936cfd5f2eaa0d164 100644 --- a/VectoCoreTest/Models/SimulationComponentData/GearboxDataTest.cs +++ b/VectoCoreTest/Models/SimulationComponentData/GearboxDataTest.cs @@ -21,8 +21,11 @@ using System.Data; using System.Globalization; using Microsoft.VisualStudio.TestTools.UnitTesting; using TUGraz.VectoCore.Exceptions; +using TUGraz.VectoCore.InputData.Reader.DataObjectAdaper; using TUGraz.VectoCore.Models.SimulationComponent.Data; +using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine; using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; +using TUGraz.VectoCore.Tests.Integration; using TUGraz.VectoCore.Tests.Utils; using TUGraz.VectoCore.Utils; @@ -267,9 +270,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData AssertHelper.AreRelativeEqual(25, map.GetOutTorque(120.RPMtoRad(), 50.SI<NewtonMeter>(), true)); // test extrapolation not allowed - AssertHelper.Exception<VectoException>(() => { - map.GetOutTorque(120.RPMtoRad(), 50.SI<NewtonMeter>()); - }); + AssertHelper.Exception<VectoException>(() => { map.GetOutTorque(120.RPMtoRad(), 50.SI<NewtonMeter>()); }); } [TestMethod] @@ -280,6 +281,37 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData Assert.Inconclusive("test another file which is not correct"); } + [TestMethod] + public void TestFullLoadCurveIntersection() + { + var engineFLDString = new[] { + "560, 1180, -149", + "600, 1282, -148", + "800, 1791, -149", + "1000, 2300, -160", + "1200, 2300, -179", + "1400, 2300, -203", + "1600, 2079, -235", + "1800, 1857, -264", + "2000, 1352, -301", + "2100, 1100, -320", + }; + var gbxFLDString = new[] { + "560, 2500", + "2100, 2500" + }; + var dataEng = + VectoCSVFile.ReadStream(SimpleDrivingCycles.InputDataAsStream("n [U/min],Mfull [Nm],Mdrag [Nm]", engineFLDString)); + var engineFLD = EngineFullLoadCurve.Create(dataEng, true); + + var dataGbx = VectoCSVFile.ReadStream(SimpleDrivingCycles.InputDataAsStream("n [U/min],Mfull [Nm]", gbxFLDString)); + var gbxFLD = FullLoadCurve.Create(dataGbx, true); + + var fullLoadCurve = AbstractSimulationDataAdapter.IntersectFullLoadCurves(engineFLD, gbxFLD); + + Assert.AreEqual(10, fullLoadCurve.FullLoadEntries.Count); + } + protected PerSecond SpeedToAngularSpeed(double v, double r) { return ((60 * v) / (2 * r * Math.PI / 1000)).RPMtoRad();