Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

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

Merge branch 'bugfix/VECTO-813-error-infinity-is-not-allowed-for-si-value'...

Merge branch 'bugfix/VECTO-813-error-infinity-is-not-allowed-for-si-value' into bugfix/VECTO-822-simulation-run-aborted-by-infinity
parents 43d47930 84f102a6
Branches
Tags
No related merge requests found
Showing with 57 additions and 41 deletions
......@@ -181,7 +181,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
_engageTime = absTime + dt;
}
var gear = NextGear.Gear;
if (ClutchClosed(absTime) && Disengaged && !outAngularVelocity.IsEqual(0)) {
ReEngageGear(absTime, dt, outTorque, outAngularVelocity);
Log.Debug("Gearbox engaged gear {0}", Gear);
}
var gear = Disengaged ? NextGear.Gear : Gear;
var avgOutAngularVelocity = (PreviousState.OutAngularVelocity + outAngularVelocity) / 2.0;
var inTorqueLossResult = ModelData.Gears[gear].LossMap.GetTorqueLoss(avgOutAngularVelocity, outTorque);
if (avgOutAngularVelocity.IsEqual(0, 1e-9)) {
......@@ -189,7 +194,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
}
var inAngularVelocity = outAngularVelocity * ModelData.Gears[gear].Ratio;
var inTorque = outTorque / ModelData.Gears[gear].Ratio + inTorqueLossResult.Value;
var avgInAngularVelocity = (PreviousState.InAngularVelocity + inAngularVelocity) / 2.0;
var inTorque = !avgInAngularVelocity.IsEqual(0)
? outTorque * (avgOutAngularVelocity / avgInAngularVelocity)
: outTorque / ModelData.Gears[Gear].Ratio;
inTorque += inTorqueLossResult.Value;
//var inTorque = outTorque / ModelData.Gears[gear].Ratio + inTorqueLossResult.Value;
var inertiaTorqueLossOut = !inAngularVelocity.IsEqual(0)
? Formulas.InertiaPower(outAngularVelocity, PreviousState.OutAngularVelocity, ModelData.Inertia, dt) /
avgOutAngularVelocity
......@@ -197,7 +208,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
inTorque += inertiaTorqueLossOut / ModelData.Gears[gear].Ratio;
var halted = DataBus.DrivingAction == DrivingAction.Halt;
var driverDeceleratingNegTorque = DataBus.DriverBehavior == DrivingBehavior.Braking &&
var driverDeceleratingNegTorque = DataBus.DriverBehavior == DrivingBehavior.Braking && DataBus.DrivingAction == DrivingAction.Brake &&
(DataBus.BrakePower.IsGreater(0) || inTorque.IsSmaller(0));
var vehiclespeedBelowThreshold =
DataBus.VehicleSpeed.IsSmaller(Constants.SimulationSettings.ClutchDisengageWhenHaltingSpeed);
......@@ -313,10 +324,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
//{
// Gear = _strategy.InitGear(absTime, dt, outTorque, outAngularVelocity);
//}
if (Disengaged && !outAngularVelocity.IsEqual(0)) {
ReEngageGear(absTime, dt, outTorque, outAngularVelocity);
Log.Debug("Gearbox engaged gear {0}", Gear);
}
var inAngularVelocity = outAngularVelocity * ModelData.Gears[Gear].Ratio;
......
......@@ -100,7 +100,8 @@ namespace TUGraz.VectoCore.Tests.Integration
AirdragData = airdragData,
GearboxData = gearboxData,
EngineData = engineData,
SimulationType = SimulationType.DistanceCycle
SimulationType = SimulationType.DistanceCycle,
Cycle = cycleData
};
container.RunData = runData;
cycle.AddComponent(new Driver(container, driverData, new DefaultDriverStrategy()))
......
......@@ -58,10 +58,10 @@ namespace TUGraz.VectoCore.Tests.Integration.Declaration
Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory);
}
[TestCase(null, 1.0, 45.5309587),
TestCase("CFRegPer", 1.2, 45.5309587 * 1.2),
TestCase("BFColdHot", 1.2, 45.5309587 * 1.2),
TestCase("CFNCV", 1.2, 45.5309587) // has no influence - only for documentation purpose
[TestCase(null, 1.0, 45.52476184, TestName = "Engine CF - NONE"),
TestCase("CFRegPer", 1.2, 45.52476184 * 1.2, TestName = "Engine CF - CFRegPer"),
TestCase("BFColdHot", 1.2, 45.52476184 * 1.2, TestName = "Engine CF - BFColdHod"),
TestCase("CFNCV", 1.2, 45.52476184, TestName = "Engine CF - CFNCV") // has no influence - only for documentation purpose
]
public void TestEngineCorrectionFactors(string correctionFactor, double value, double expectedFc)
{
......
......@@ -32,10 +32,10 @@ namespace TUGraz.VectoCore.Tests.Integration.Declaration
[
TestCase(Class5NG, 2, TankSystem.Liquefied, 253.7, 702.4),
TestCase(Class5NG, 2, TankSystem.Compressed, 259.4, 697.7),
TestCase(Class5NG, 6, TankSystem.Liquefied, 252.7, 699.8),
TestCase(Class5NG, 6, TankSystem.Compressed, 258.4, 695.4),
TestCase(Class5NG, 2, TankSystem.Liquefied, 253.7, 702.8, TestName = "Class5 LNG 2"),
TestCase(Class5NG, 2, TankSystem.Compressed, 259.5, 698.1, TestName = "Class5 CNG 2"),
TestCase(Class5NG, 6, TankSystem.Liquefied, 252.8, 700.4, TestName = "Class5 LNG 6"),
TestCase(Class5NG, 6, TankSystem.Compressed, 258.6, 695.7, TestName = "Class5 CNG 6"),
]
public void NaturalGasTankSystemTest(string filename, int runIdx, TankSystem tankSystem, double expectedFc, double expectedCo2)
{
......
......@@ -58,40 +58,40 @@ namespace TUGraz.VectoCore.Tests.Integration
[Category("Integration")]
[TestCase(FuelType.DieselCI, null,
@"TestData\Integration\DeclarationMode\Class2_RigidTruck_4x2\Class2_RigidTruck_DECL.vecto", 0,
0.0002199424, 0.0002199424, 26.311041667, 0.0006886, 9392.305166,
0.0002199424, 0.0002199424, 26.3060719, 0.0006886, 9390.531125,
TestName = "Diesel LH Low"),
TestCase(FuelType.EthanolCI, null,
@"TestData\Integration\DeclarationMode\Class2_RigidTruck_4x2\Class2_RigidTruck_DECL.vecto", 0,
0.0002199424, 0.0002225401, 27.1412517, 0.000402797, 5652.9799242,
0.0002199424, 0.0002225401, 27.136125, 0.000402797, 5651.912176,
TestName = "Ethanol/CI LH Low"),
TestCase(FuelType.DieselCI, null,
@"TestData\Integration\DeclarationMode\Class2_RigidTruck_4x2\Class2_RigidTruck_DECL.vecto", 1,
0.0002547295, 0.0002547295, 30.4604632, 0.0007971, 10873.5324987,
0.0002547295, 0.0002547295, 30.4611849, 0.0007971, 10873.790098,
TestName = "Diesel LH Ref"),
TestCase(FuelType.EthanolCI, null,
@"TestData\Integration\DeclarationMode\Class2_RigidTruck_4x2\Class2_RigidTruck_DECL.vecto", 1,
0.0002547295, 0.000257738, 31.421602924, 0.00046650, 6544.4914570,
0.0002547295, 0.000257738, 31.4223473, 0.00046650, 6544.646499,
TestName = "Ethanol/CI LH Ref"),
TestCase(FuelType.EthanolPI, null,
@"TestData\Integration\DeclarationMode\Class2_RigidTruck_4x2\Class2_RigidTruck_DECL.vecto", 1,
0.0002547295, 0.00025299078, 32.177003992, 0.0005312806, 7410.299665,
0.0002547295, 0.00025299078, 32.17776628, 0.0005312806, 7410.475219,
TestName = "Ethanol/PI LH Ref"),
TestCase(FuelType.PetrolPI, null,
@"TestData\Integration\DeclarationMode\Class2_RigidTruck_4x2\Class2_RigidTruck_DECL.vecto", 1,
0.0002547295, 0.00025472954, 34.04404719, 0.0007743778, 10567.9531310,
0.0002547295, 0.00025472954, 34.0448537, 0.0007743778, 10568.203491,
TestName = "Petrol/PI LH Ref"),
TestCase(FuelType.LPGPI, null,
@"TestData\Integration\DeclarationMode\Class2_RigidTruck_4x2\Class2_RigidTruck_DECL.vecto", 1,
0.0002547295, 0.0002547295, double.NaN, 0.00076928, 11713.8757597,
0.0002547295, 0.0002547295, double.NaN, 0.00076928, 11714.1532673,
TestName = "LPG/PI LH Ref"),
TestCase(FuelType.NGPI, TankSystem.Liquefied,
@"TestData\Integration\DeclarationMode\Class2_RigidTruck_4x2\Class2_RigidTruck_DECL.vecto", 1,
0.0002547295, 0.00023397765, double.NaN, 0.00064811809, 11484.69123399,
0.0002547295, 0.00023397765, double.NaN, 0.00064811809, 11484.963312,
TestName = "LNG/PI LH Ref"),
TestCase(FuelType.NGPI, TankSystem.Compressed,
@"TestData\Integration\DeclarationMode\Class2_RigidTruck_4x2\Class2_RigidTruck_DECL.vecto", 1,
0.0002547295, 0.0002393396, double.NaN, 0.000643823, 11484.69123399,
0.0002547295, 0.0002393396, double.NaN, 0.000643823, 11484.963312,
TestName = "CNG/PI LH Ref"),
]
public void TestFuelTypesCO2(FuelType fuelType, TankSystem? tankSystem, string jobName, int runIdx,
......
......@@ -29,6 +29,7 @@
* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology
*/
using System;
using System.Data;
using System.IO;
using System.Linq;
......@@ -253,12 +254,13 @@ namespace TUGraz.VectoCore.Tests.Integration
Assert.IsTrue(jobContainer.Runs.All(r => r.Success), string.Concat(jobContainer.Runs.Select(r => r.ExecException)));
var view = new DataView(sumData.Table, "", SummaryDataContainer.SORT, DataViewRowState.CurrentRows).ToTable();
Assert.AreEqual(201.3972, view.Rows[0][SummaryDataContainer.FCMAP_KM].ToString().ToDouble(), 1e-3);
Assert.AreEqual(239.2911, view.Rows[1][SummaryDataContainer.FCMAP_KM].ToString().ToDouble(), 1e-3);
Assert.AreEqual(170.1334, view.Rows[2][SummaryDataContainer.FCMAP_KM].ToString().ToDouble(), 1e-3);
Assert.AreEqual(183.0126, view.Rows[3][SummaryDataContainer.FCMAP_KM].ToString().ToDouble(), 1e-3);
Assert.AreEqual(224.1216, view.Rows[4][SummaryDataContainer.FCMAP_KM].ToString().ToDouble(), 1e-3);
Assert.AreEqual(254.3299, view.Rows[5][SummaryDataContainer.FCMAP_KM].ToString().ToDouble(), 1e-3);
Console.WriteLine(string.Join("; ", view.AsEnumerable().Select(x => x[SummaryDataContainer.FCMAP_KM].ToString().ToDouble())));
Assert.AreEqual(201.39195, view.Rows[0][SummaryDataContainer.FCMAP_KM].ToString().ToDouble(), 1e-3);
Assert.AreEqual(239.28546, view.Rows[1][SummaryDataContainer.FCMAP_KM].ToString().ToDouble(), 1e-3);
Assert.AreEqual(170.11718, view.Rows[2][SummaryDataContainer.FCMAP_KM].ToString().ToDouble(), 1e-3);
Assert.AreEqual(183.02680, view.Rows[3][SummaryDataContainer.FCMAP_KM].ToString().ToDouble(), 1e-3);
Assert.AreEqual(224.07271, view.Rows[4][SummaryDataContainer.FCMAP_KM].ToString().ToDouble(), 1e-3);
Assert.AreEqual(254.35646, view.Rows[5][SummaryDataContainer.FCMAP_KM].ToString().ToDouble(), 1e-3);
}
[TestCase(EngineSpeedLimitJobATDecl)]
......
......@@ -29,6 +29,7 @@
* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology
*/
using System.IO;
using NUnit.Framework;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.Models.Connector.Ports.Impl;
......@@ -40,6 +41,13 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
[TestFixture]
public class GearboxPowertrainTest
{
[OneTimeSetUp]
public void RunBeforeAnyTests()
{
Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory);
}
[TestCase]
public void Gearbox_Initialize_Empty()
{
......
......@@ -448,7 +448,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
TestCase(2, 50, 600, 9.096, typeof(ResponseSuccess)),
TestCase(2, 2050, 1200, 52.132, typeof(ResponseSuccess)),
TestCase(2, 850, 600, 25.096, typeof(ResponseSuccess)),
TestCase(1, 850, 0, 22.06, typeof(ResponseSuccess)),
TestCase(1, 850, 0, 0, typeof(ResponseSuccess)), // torque loss is 0 if speed is 0
]
public void Gearbox_Request_engaged(int gear, double t, double n, double loss, Type responseType)
{
......@@ -488,13 +488,11 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
var response = gearbox.OutPort().Request(absTime, dt, outTorque, angularVelocity);
Assert.IsTrue(response.GetType() == responseType);
if (responseType == typeof(ResponseSuccess)) {
AssertHelper.AreRelativeEqual(absTime, port.AbsTime);
AssertHelper.AreRelativeEqual(dt, port.Dt);
AssertHelper.AreRelativeEqual(expectedN, port.AngularVelocity);
AssertHelper.AreRelativeEqual(t, port.Torque, toleranceFactor: 1e-5);
}
}
[TestCase(8, 7, 1800, 750, typeof(ResponseGearShift)),
TestCase(7, 6, 1800, 750, typeof(ResponseGearShift)),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment