From 2a11fe131d90b66b027402ecc443e374b86ccf4f Mon Sep 17 00:00:00 2001 From: Markus Quaritsch <markus.quaritsch@tugraz.at> Date: Mon, 31 May 2021 14:49:27 +0200 Subject: [PATCH] intersect engine FLD: only add intersection point if it is not already part of the entries. --- .../AbstractSimulationDataAdapter.cs | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs index 502dfae3a8..044d401678 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs @@ -308,17 +308,22 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter }); } else { // segment intersects maxTorque line -> add new entry at intersection - var edgeFull = Edge.Create(new Point(entry.Item1.EngineSpeed.Value(), entry.Item1.TorqueFullLoad.Value()), + var edgeFull = Edge.Create( + new Point(entry.Item1.EngineSpeed.Value(), entry.Item1.TorqueFullLoad.Value()), new Point(entry.Item2.EngineSpeed.Value(), entry.Item2.TorqueFullLoad.Value())); - var edgeDrag = Edge.Create(new Point(entry.Item1.EngineSpeed.Value(), entry.Item1.TorqueDrag.Value()), + var edgeDrag = Edge.Create( + new Point(entry.Item1.EngineSpeed.Value(), entry.Item1.TorqueDrag.Value()), new Point(entry.Item2.EngineSpeed.Value(), entry.Item2.TorqueDrag.Value())); var intersectionX = (maxTorque.Value() - edgeFull.OffsetXY) / edgeFull.SlopeXY; - entries.Add(new EngineFullLoadCurve.FullLoadCurveEntry { - EngineSpeed = intersectionX.SI<PerSecond>(), - TorqueFullLoad = maxTorque, - TorqueDrag = VectoMath.Interpolate(edgeDrag.P1, edgeDrag.P2, intersectionX).SI<NewtonMeter>() - }); - entries.Add(new EngineFullLoadCurve.FullLoadCurveEntry { + if (!entries.Any(x => x.EngineSpeed.IsEqual(intersectionX))) { + entries.Add(new EngineFullLoadCurve.FullLoadCurveEntry { + EngineSpeed = intersectionX.SI<PerSecond>(), + TorqueFullLoad = maxTorque, + TorqueDrag = VectoMath.Interpolate(edgeDrag.P1, edgeDrag.P2, intersectionX).SI<NewtonMeter>() + }); + } + + entries.Add(new EngineFullLoadCurve.FullLoadCurveEntry { EngineSpeed = entry.Item2.EngineSpeed, TorqueFullLoad = entry.Item2.TorqueFullLoad > maxTorque ? maxTorque : entry.Item2.TorqueFullLoad, TorqueDrag = entry.Item2.TorqueDrag -- GitLab