Code development platform for open source projects from the European Union institutions

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

Merge pull request #597 in VECTO/vecto-sim from...

Merge pull request #597 in VECTO/vecto-sim from ~EMQUARIMA/vecto-sim:bugfix/VECTO-679-engine-n95h-computation-gives-wrong-too-high-engine-speed to master

* commit '30d2e5b8':
  adding shiftpolygon drawing for XML job file
  fixing another testcase influenced by this bugfix
  adding check that the computed engine speed is within the current section of the FLD in case the torque is constant
  testcase showing wrong FLD computaion in case the torque is constant
parents f8b8cd5c 30d2e5b8
No related branches found
No related tags found
No related merge requests found
......@@ -355,7 +355,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine
if (d.IsEqual(0, 0.0001)) {
return new List<PerSecond>();
}
return (power / d).ToEnumerable();
return FilterSolutions((power / d).ToEnumerable(), p1, p2);
}
// non-constant torque: solve quadratic equation for engine speed (n_eng_avg)
......@@ -364,7 +364,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine
if (retVal.Length == 0) {
Log.Info("No real solution found for requested power demand: P: {0}, p1: {1}, p2: {2}", power, p1, p2);
}
return retVal.Where(x => x.IsGreaterOrEqual(p1.EngineSpeed.Value()) && x.IsSmallerOrEqual(p2.EngineSpeed.Value())).Select(x => Math.Round(x, 6).SI<PerSecond>());
return FilterSolutions(retVal.Select(x => Math.Round(x, 6).SI<PerSecond>()), p1, p2);
}
private IEnumerable<PerSecond> FilterSolutions(IEnumerable<PerSecond> solutions, FullLoadCurveEntry p1, FullLoadCurveEntry p2)
{
return solutions.Where(
x => x.IsGreaterOrEqual(p1.EngineSpeed.Value()) && x.IsSmallerOrEqual(p2.EngineSpeed.Value()));
}
protected internal Watt ComputeArea(PerSecond lowEngineSpeed, PerSecond highEngineSpeed)
......
......@@ -38,6 +38,7 @@ using TUGraz.VectoCommon.InputData;
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.InputData.FileIO.JSON;
using TUGraz.VectoCore.InputData.FileIO.XML.Declaration;
using TUGraz.VectoCore.InputData.Reader;
using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter;
using TUGraz.VectoCore.Models.Declaration;
......@@ -588,6 +589,69 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration
}
}
}
[TestCase]
public void ComputeShiftPolygonDeclarationTestConfidentialXMLJob()
{
var jobFile = @"E:\QUAM\Downloads\upshifts-missing_over-revving\FL_curve_orig.xml";
if (!File.Exists(jobFile)) {
Assert.Inconclusive("Confidential File not found. Test cannot run without file.");
}
var job = new XMLDeclarationInputDataProvider(jobFile, true);
var gearboxData = job.JobInputData.Vehicle.GearboxInputData;
var idlespeed = VectoMath.Max(
job.JobInputData.Vehicle.EngineIdleSpeed, job.JobInputData.Vehicle.EngineInputData.IdleSpeed);
var dao = new DeclarationDataAdapter();
var engineData = dao.CreateEngineData(
job.JobInputData.Vehicle.EngineInputData, idlespeed, gearboxData, job.JobInputData.Vehicle.TorqueLimits);
var axlegearRatio = job.JobInputData.Vehicle.AxleGearInputData.Ratio;
var rdyn = job.JobInputData.Vehicle.Axles.Where(x => x.AxleType == AxleType.VehicleDriven)
.Select(x => DeclarationData.Wheels.Lookup(x.Tyre.Dimension)).Average(x => x.DynamicTyreRadius.Value())
.SI<Meter>();
var fullLoadCurves = engineData.FullLoadCurves;
var gearboxFile = jobFile;
var shiftPolygons = new List<ShiftPolygon>();
var downshiftTransformed = new List<List<Point>>();
var downshiftOrig = new List<List<Point>>();
var upshiftOrig = new List<List<Point>>();
for (var i = 0; i < gearboxData.Gears.Count; i++) {
shiftPolygons.Add(DeclarationData.Gearbox.ComputeShiftPolygon(GearboxType.AMT, i, fullLoadCurves[(uint)(i + 1)],
gearboxData.Gears,
engineData, axlegearRatio, rdyn));
List<Point> tmp1, tmp2, tmp3;
ShiftPolygonComparison.ComputShiftPolygonPoints(i, fullLoadCurves[(uint)(i + 1)], gearboxData.Gears,
engineData, axlegearRatio, rdyn, out tmp1, out tmp2, out tmp3);
upshiftOrig.Add(tmp1);
downshiftTransformed.Add(tmp2);
downshiftOrig.Add(tmp3);
}
ShiftPolygonDrawer.DrawShiftPolygons(Path.GetDirectoryName(gearboxFile), fullLoadCurves, shiftPolygons,
Path.Combine(Path.GetDirectoryName(gearboxFile), "Shiftlines.png"),
DeclarationData.Gearbox.TruckMaxAllowedSpeed / rdyn * axlegearRatio * gearboxData.Gears.Last().Ratio, upshiftOrig,
downshiftTransformed, downshiftOrig);
var shiftLines = "";
var gear = 1;
foreach (var shiftPolygon in shiftPolygons) {
shiftLines += "Gear " + gear + "\n";
shiftLines += "Upshift\n";
foreach (var shiftPolygonEntry in shiftPolygon.Upshift) {
shiftLines += string.Format("{0} {1}\n", shiftPolygonEntry.AngularSpeed.AsRPM, shiftPolygonEntry.Torque.Value());
}
shiftLines += "Downshift\n";
foreach (var shiftPolygonEntry in shiftPolygon.Downshift) {
shiftLines += string.Format("{0} {1}\n", shiftPolygonEntry.AngularSpeed.AsRPM, shiftPolygonEntry.Torque.Value());
}
}
}
}
[TestFixture]
......
......@@ -131,7 +131,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData
Assert.AreEqual((0.51 * totalArea).Value(),
fldCurve.ComputeArea(fldCurve.EngineData.IdleSpeed, fldCurve.PreferredSpeed).Value(), 1E-3);
AssertHelper.AreRelativeEqual(194.515816596908.SI<PerSecond>(), fldCurve.N95hSpeed);
AssertHelper.AreRelativeEqual(83.81645.SI<PerSecond>(), fldCurve.LoSpeed);
AssertHelper.AreRelativeEqual(94.24639.SI<PerSecond>(), fldCurve.LoSpeed);
AssertHelper.AreRelativeEqual(219.084329211505.SI<PerSecond>(), fldCurve.HiSpeed);
AssertHelper.AreRelativeEqual(2300.SI<NewtonMeter>(), fldCurve.MaxTorque);
AssertHelper.AreRelativeEqual(-320.SI<NewtonMeter>(), fldCurve.MaxDragTorque);
......@@ -188,6 +188,43 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData
//AssertHelper.AreRelativeEqual(130.691151551712.SI<PerSecond>(), fldCurve.PreferredSpeed);
}
/// <summary>
/// [VECTO-679]
/// </summary>
[TestCase]
public void TestN95hComputation()
{
var fldData = new[] {
"590,486,-44,0.60 ",
"600,486,-44,0.60 ",
"800,755,-54,0.60 ",
"1000,883,-62,0.60 ",
"1200,899,-74,0.60 ",
"1300,899,-80,0.60 ",
"1400,899,-87,0.60 ",
"1500,899,-92,0.60 ",
"1600,899,-97,0.60 ",
"1700,890,-100,0.60 ",
"1800,881,-103,0.60 ",
"1900,867,-107,0.60 ",
"2000,853,-111,0.43 ",
"2150,811,-118,0.29 ",
"2200,802,-125,0.25 ",
"2300,755,-130,0.25 ",
"2400,705,-135,0.25 ",
"2500,644,-140,0.25 ",
"2600,479,-145,0.25 ",
"2700,0,-149,0.25 ",
};
var fldEntries = InputDataHelper.InputDataAsStream("n [U/min],Mfull [Nm],Mdrag [Nm],<PT1> [s] ", fldData);
var fldCurve = FullLoadCurveReader.Create(VectoCSVFile.ReadStream(fldEntries));
fldCurve.EngineData = new CombustionEngineData { IdleSpeed = 560.RPMtoRad() };
Assert.AreEqual(2420.5, fldCurve.N95hSpeed.AsRPM, 1);
}
/// <summary>
/// [VECTO-78]
/// </summary>
......
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