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

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

testcase + bugfix for torque converter data (finding correct segment for...

testcase + bugfix for torque converter data (finding correct segment for torque ratio / torque calculation
parent 5ab9328d
No related branches found
No related tags found
No related merge requests found
......@@ -107,7 +107,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox
private double MuLookup(double nu)
{
int index;
TorqueConverterEntries.GetSection(x => x.SpeedRatio > nu, out index);
TorqueConverterEntries.GetSection(x => x.SpeedRatio < nu, out index);
var muEdge =
Edge.Create(new Point(TorqueConverterEntries[index].SpeedRatio, TorqueConverterEntries[index].TorqueRatio),
new Point(TorqueConverterEntries[index + 1].SpeedRatio, TorqueConverterEntries[index + 1].TorqueRatio));
......@@ -136,6 +136,31 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox
throw new VectoException("No solution for output speed/input speed found! n_out: {0}, n_in: {1}", outAngularVelocity,
inAngularVelocity);
}
public TorqueConverterOperatingPoint GetOutTorqueAndSpeed(NewtonMeter inTorque, PerSecond inAngularVelocity)
{
var referenceTorque = inTorque.Value() / inAngularVelocity.Value() / inAngularVelocity.Value() *
ReferenceSpeed.Value() * ReferenceSpeed.Value();
var maxTorque = TorqueConverterEntries.Max(x => x.Torque.Value());
if (referenceTorque.IsGreaterOrEqual(maxTorque)) {
referenceTorque = 0.9 * maxTorque;
}
var solutions = new List<double>();
foreach (var edge in TorqueConverterEntries.Pairwise(
(p1, p2) => Edge.Create(new Point(p1.SpeedRatio, p1.Torque.Value()), new Point(p2.SpeedRatio, p2.Torque.Value())))) {
var x = (referenceTorque - edge.OffsetXY) / edge.SlopeXY;
if (x >= edge.P1.X && x < edge.P2.X) {
solutions.Add(x * inAngularVelocity.Value());
}
}
if (solutions.Count == 0) {
throw new VectoSimulationException(
"Failed to find torque converter Operating Point for inputTorque/inputSpeed! n_in: {0}, tq_in: {1}",
inAngularVelocity, inTorque);
}
return GetOutTorque(inAngularVelocity, solutions.Max().SI<PerSecond>());
}
}
public class TorqueConverterOperatingPoint
......
......@@ -62,6 +62,42 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData
//Assert.AreEqual(tqInExpected, inTorque.Value(), 10);
}
[Test,
TestCase(898, 463)]
public void TestTorqueConverterOperatingPointForward(double nIn, double tqIn)
{
var tqLimit = 1600;
var tqInput = new[] {
"0.0, 4.5, 700",
"0.1, 3.5, 640 ",
"0.2, 2.7, 560 ",
"0.3, 2.2, 460 ",
"0.4, 1.6, 350 ",
"0.5, 1.2, 250 ",
"0.6, 0.9, 160 ",
"0.74, 0.9, 1",
};
var tqData =
TorqueConverterDataReader.ReadFromStream(InputDataHelper.InputDataAsStream("Speed Ratio, Torque Ratio,MP1000",
tqInput), 1000.RPMtoRad(), tqLimit.RPMtoRad());
var operatingPoint = tqData.GetOutTorqueAndSpeed(tqIn.SI<NewtonMeter>(), nIn.RPMtoRad());
Assert.AreEqual(operatingPoint.InTorque.Value(), tqIn, 1e-6);
Assert.AreEqual(operatingPoint.InAngularVelocity.Value(), nIn.RPMtoRad().Value(), 1e-6);
var reverseOP = tqData.FindOperatingPoint(operatingPoint.OutTorque, operatingPoint.OutAngularVelocity);
Assert.AreEqual(operatingPoint.InTorque.Value(), reverseOP.InTorque.Value(), 1e-6);
Assert.AreEqual(operatingPoint.OutTorque.Value(), reverseOP.OutTorque.Value(), 1e-6);
Assert.AreEqual(operatingPoint.InAngularVelocity.Value(), reverseOP.InAngularVelocity.Value(), 1e-6);
Assert.AreEqual(operatingPoint.OutAngularVelocity.Value(), reverseOP.OutAngularVelocity.Value(), 1e-6);
}
[Test]
public void TestTorqueConverterComparisonV2()
{
......
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