Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

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

testcase for bug when intersecting full-load curves.

parent 7ff55f64
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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();
......
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