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

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

Merge branch 'feature/VECTO-112-simple-shifting-strategy' of...

Merge branch 'feature/VECTO-112-simple-shifting-strategy' of https://webgate.ec.europa.eu/CITnet/stash/scm/~emkrispmi/vecto-sim into feature/VECTO-116-refactor-driver-implementation
parents dffd8d12 a10971a4
No related branches found
No related tags found
No related merge requests found
......@@ -687,12 +687,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
if (!targetVelocity.IsEqual(0) || !DataBus.VehicleSpeed.IsEqual(0)) {
throw new NotImplementedException("TargetVelocity or VehicleVelocity is not zero!");
}
var oldGear = DataBus.Gear;
//DataBus.Gear = 0;
DataBus.BreakPower = double.PositiveInfinity.SI<Watt>();
var retVal = NextComponent.Request(absTime, dt, 0.SI<MeterPerSquareSecond>(), gradient);
CurrentState.dt = dt;
//DataBus.Gear = oldGear;
CurrentState.Acceleration = 0.SI<MeterPerSquareSecond>();
return retVal;
}
......
......@@ -47,7 +47,7 @@ namespace TUGraz.VectoCore.Utils
public static Watt InertiaPower(PerSecond currentOmega, PerSecond previousOmega, KilogramSquareMeter inertia,
Second dt)
{
var deltaOmega = previousOmega - currentOmega;
var deltaOmega = currentOmega - previousOmega;
var avgOmega = (currentOmega + previousOmega) / 2;
var alpha = deltaOmega / dt;
......
......@@ -788,6 +788,7 @@ namespace TUGraz.VectoCore.Utils
/// ATTENTION: Before returning an SI Unit, ensure to cancel Conversion Mode (with or Cast).
/// </summary>
/// <returns></returns>
[DebuggerHidden]
public SI ConvertTo()
{
return new SI(Linear, reciproc: false, reverse: true);
......@@ -797,6 +798,7 @@ namespace TUGraz.VectoCore.Utils
/// Casts the SI Unit to the concrete unit type (if the units allow such an cast).
/// </summary>
/// <typeparam name="T">the specialized SI unit. e.g. Watt, NewtonMeter, Second</typeparam>
[DebuggerHidden]
public T Cast<T>() where T : SIBase<T>
{
var t = SIBase<T>.Create(Val);
......
......@@ -252,7 +252,7 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns
ResultFileHelper.TestSumFile(@"TestData\Results\Integration\job.vsum", @"job.vsum");
ResultFileHelper.TestModFile(@"TestData\Results\Integration\job_1-Gear-Test-dist.vmod",
@"TestData\job_1-Gear-Test-dist.vmod");
@"TestData\job_1-Gear-Test-dist.vmod", testRowCount: false);
}
......
......@@ -151,7 +151,6 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
var vehicleData = CreateVehicleData(33000.SI<Kilogram>());
var driverData = CreateDriverData();
var modalWriter = new ModalDataWriter("Coach_MinimalPowertrain.vmod", SimulatorFactory.FactoryMode.EngineeringMode);
......@@ -168,7 +167,6 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
AddComponent(tmp, new CombustionEngine(vehicleContainer, engineData));
var gbx = new MockGearbox(vehicleContainer);
gbx.Gear = 1;
var driverPort = driver.OutPort();
......@@ -183,7 +181,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
vehicleContainer.CommitSimulationStep(absTime, response.SimulationInterval);
absTime += response.SimulationInterval;
Assert.AreEqual(0.908, modalWriter.GetValues<SI>(ModalResultField.acc).Last().Value(), Tolerance);
Assert.AreEqual(0.9613, modalWriter.GetValues<SI>(ModalResultField.acc).Last().Value(), Tolerance);
response = driverPort.Request(absTime, 1.SI<Meter>(), 10.SI<MeterPerSecond>(), 0.SI<Radian>());
......@@ -192,18 +190,14 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
vehicleContainer.CommitSimulationStep(absTime, response.SimulationInterval);
absTime += response.SimulationInterval;
Assert.AreEqual(0.7973, modalWriter.GetValues<SI>(ModalResultField.acc).Last().Value(), Tolerance);
Assert.AreEqual(0.7904, modalWriter.GetValues<SI>(ModalResultField.acc).Last().Value(), Tolerance);
// change vehicle weight, cannot reach minimum acceleration...
vehicleData.Loading = 70000.SI<Kilogram>();
try {
response = driverPort.Request(absTime, 1.SI<Meter>(), 10.SI<MeterPerSecond>(), 0.05.SI<Radian>());
Assert.Fail();
} catch (VectoSimulationException e) {
Assert.AreEqual("Could not achieve minimum acceleration", e.Message);
}
//Assert.IsInstanceOfType(response, typeof(ResponseSuccess));
AssertHelper.Exception<VectoSimulationException>(() => {
driverPort.Request(absTime, 0.1.SI<Meter>(), 10.SI<MeterPerSecond>(), 0.05.SI<Radian>());
}, "Could not achieve minimum acceleration");
}
[TestMethod]
......
......@@ -30,7 +30,8 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
public const string AccelerationFile = @"TestData\Components\Coach.vacc";
public const string GearboxLossMap = @"TestData\Components\Indirect Gear.vtlm";
public const string IndirectLossMap = @"TestData\Components\Indirect Gear.vtlm";
public const string DirectLossMap = @"TestData\Components\Direct Gear.vtlm";
public const string GearboxShiftPolygonFile = @"TestData\Components\ShiftPolygons.vgbs";
public const string GearboxFullLoadCurveFile = @"TestData\Components\Gearbox.vfld";
......@@ -47,7 +48,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
Tuple.Create((uint)i,
new GearData {
FullLoadCurve = FullLoadCurve.ReadFromFile(GearboxFullLoadCurveFile),
LossMap = TransmissionLossMap.ReadFromFile(GearboxLossMap, ratio),
LossMap = TransmissionLossMap.ReadFromFile((i != 6) ? IndirectLossMap : DirectLossMap, ratio),
Ratio = ratio,
ShiftPolygon = ShiftPolygon.ReadFromFile(GearboxShiftPolygonFile)
}))
......@@ -198,26 +199,26 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
// the first element 0.0 is just a placeholder for axlegear, not used in this test
var expected = new[] {
new { gear = 1, t = -1000, n = 800, loss = 29.108, responseType = typeof(ResponseSuccess) },
new { gear = 2, t = -1000, n = 800, loss = 29.108, responseType = typeof(ResponseSuccess) },
new { gear = 7, t = -1000, n = 1200, loss = 16.132, responseType = typeof(ResponseSuccess) },
new { gear = 7, t = 850, n = 1200, loss = 15.382, responseType = typeof(ResponseSuccess) },
new { gear = 7, t = 2450, n = 1200, loss = 23.382, responseType = typeof(ResponseSuccess) },
new { gear = 1, t = 50, n = 800, loss = 10.108, responseType = typeof(ResponseSuccess) },
new { gear = 1, t = 2450, n = 800, loss = 58.11, responseType = typeof(ResponseSuccess) },
new { gear = 1, t = -1000, n = 800, loss = 29.11, responseType = typeof(ResponseSuccess) },
new { gear = 1, t = 850, n = 800, loss = 26.11, responseType = typeof(ResponseSuccess) },
new { gear = 1, t = 850, n = 0, loss = 22.06, responseType = typeof(ResponseSuccess) },
new { gear = 1, t = 850, n = 200, loss = 23.07, responseType = typeof(ResponseSuccess) },
new { gear = 2, t = 50, n = 800, loss = 10.108, responseType = typeof(ResponseSuccess) },
new { gear = 2, t = 2450, n = 800, loss = 58.11, responseType = typeof(ResponseGearShift) },
new { gear = 2, t = -1000, n = 800, loss = 29.11, responseType = typeof(ResponseSuccess) },
new { gear = 2, t = 850, n = 800, loss = 26.11, responseType = typeof(ResponseSuccess) },
new { gear = 2, t = 850, n = 0, loss = 22.06, responseType = typeof(ResponseGearShift) },
new { gear = 2, t = 850, n = 400, loss = 11.334, responseType = typeof(ResponseGearShift) },
new { gear = 2, t = 850, n = 2000, loss = 32.18, responseType = typeof(ResponseGearShift) },
new { gear = 7, t = -1000, n = 0, loss = 10.06, responseType = typeof(ResponseGearShift) },
new { gear = 7, t = -1000, n = 1200, loss = 16.132, responseType = typeof(ResponseSuccess) },
new { gear = 7, t = 850, n = 0, loss = 9.31, responseType = typeof(ResponseGearShift) },
new { gear = 7, t = 850, n = 1200, loss = 15.382, responseType = typeof(ResponseSuccess) },
new { gear = 7, t = 850, n = 2000, loss = 19.43, responseType = typeof(ResponseGearShift) },
new { gear = 7, t = 2450, n = 0, loss = 17.31, responseType = typeof(ResponseGearShift) },
new { gear = 7, t = 2450, n = 1200, loss = 23.382, responseType = typeof(ResponseSuccess) }
};
var absTime = 0.SI<Second>();
......
......@@ -39,13 +39,13 @@ namespace TUGraz.VectoCore.Tests.Utils
string.Format("Moddata: Columns differ:\nExpected: {0}\nActual: {1}", string.Join(", ", expectedCols),
string.Join(", ", actualCols)));
for (var i = 0; i < expected.Rows.Count; i++) {
for (var i = 0; testRowcount && i < expected.Rows.Count; i++) {
var expectedRow = expected.Rows[i];
var actualRow = actual.Rows[i];
foreach (var field in testColumns ?? new string[0]) {
Assert.AreEqual(expectedRow.ParseDoubleOrGetDefault(field), actualRow.ParseDoubleOrGetDefault(field),
DoubleExtensionMethods.Tolerance, string.Format("t: {0} field: {1}", i, field));
Assert.AreEqual(expectedRow.ParseDoubleOrGetDefault(field), actualRow.ParseDoubleOrGetDefault(field), 1e-4,
string.Format("t: {0} field: {1}", i, field));
}
}
}
......
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