diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/TransmissionLossMap.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/TransmissionLossMap.cs index b99b110f89a18fd94265a92995d891740dd7c6dc..99c6052f8810ffbadfea2f6def5b22892dcaea29 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/TransmissionLossMap.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/TransmissionLossMap.cs @@ -194,8 +194,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox { var torqueLoss = _invertedLossMap.Interpolate(inAngularVelocity.ConvertTo().Rounds.Per.Minute.Value(), inTorque.Value()); + if (torqueLoss.HasValue) + return (inTorque - torqueLoss.Value.SI<NewtonMeter>()) / _ratio; - if (!torqueLoss.HasValue && allowExtrapolation) { + if (allowExtrapolation) { torqueLoss = _invertedLossMap.Extrapolate(inAngularVelocity.ConvertTo().Rounds.Per.Minute.Value(), inTorque.Value()); return (inTorque - torqueLoss.Value.SI<NewtonMeter>()) / _ratio; } diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponentData/FuelConsumptionMapTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponentData/FuelConsumptionMapTest.cs index aea37d3ea41ea5bcd69ea20093737020fabe4d76..440bbc14f64d00f39a9a71b26081282e5a1f1d88 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponentData/FuelConsumptionMapTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponentData/FuelConsumptionMapTest.cs @@ -29,11 +29,11 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ +using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using Microsoft.VisualStudio.TestTools.UnitTesting; -using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine; @@ -60,19 +60,13 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData AssertMapValuesEqual(lines, map); } - private static void AssertMapValuesEqual(string[] lines, FuelConsumptionMap map) + private static void AssertMapValuesEqual(IReadOnlyList<string> lines, FuelConsumptionMap map) { - for (var i = 1; i < lines.Count(); i++) { + for (var i = 1; i < lines.Count; i++) { var entry = lines[i].Split(',').Select(x => double.Parse(x, CultureInfo.InvariantCulture)).ToArray(); - try { - Assert.AreEqual(entry[2].SI().Gramm.Per.Hour.ConvertTo().Kilo.Gramm.Per.Second.Value(), - map.GetFuelConsumption(entry[1].SI<NewtonMeter>(), entry[0].RPMtoRad()).Value(), - Tolerance, - string.Format("Line: {0}, n_eng_avg={1}, T={2}", (i + 2), entry[0].SI().Rounds.Per.Minute, entry[1])); - } catch (VectoException ex) { - throw new VectoException(string.Format("Row {0}: Error in ConsumptionMap n_eng_avg={1}, T={2}: {3}", - i + 2, entry[0], entry[1], ex.Message)); - } + + Assert.AreEqual(entry[2].SI().Gramm.Per.Hour.ConvertTo().Kilo.Gramm.Per.Second.Value(), + map.GetFuelConsumption(entry[1].SI<NewtonMeter>(), entry[0].RPMtoRad(), true).Value(), Tolerance); } } } diff --git a/VectoCore/VectoCoreTest/Utils/DelauneyMapTest.cs b/VectoCore/VectoCoreTest/Utils/DelauneyMapTest.cs index 745253d6bbc8493b6f34a998ce7a3384d0309ba7..6319a472f2e9ad519c685b0f6a7cc02555a1c132 100644 --- a/VectoCore/VectoCoreTest/Utils/DelauneyMapTest.cs +++ b/VectoCore/VectoCoreTest/Utils/DelauneyMapTest.cs @@ -82,10 +82,10 @@ namespace TUGraz.VectoCore.Tests.Utils AssertHelper.AreRelativeEqual(1.5, map.Interpolate(0, 0.75).Value); // extrapolation (should fail) - AssertHelper.Exception<VectoException>(() => map.Interpolate(1, 1), "TEST: Interpolation failed. x: 1, y: 1"); - AssertHelper.Exception<VectoException>(() => map.Interpolate(-1, -1), "TEST: Interpolation failed. x: -1, y: -1"); - AssertHelper.Exception<VectoException>(() => map.Interpolate(1, -1), "TEST: Interpolation failed. x: 1, y: -1"); - AssertHelper.Exception<VectoException>(() => map.Interpolate(-1, 1), "TEST: Interpolation failed. x: -1, y: 1"); + Assert.IsNull(map.Interpolate(1, 1)); + Assert.IsNull(map.Interpolate(-1, -1)); + Assert.IsNull(map.Interpolate(1, -1)); + Assert.IsNull(map.Interpolate(-1, 1)); } public void Test_DelaunayMapPlane()