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 d0c1813c authored by Michael KRISPER's avatar Michael KRISPER
Browse files

bugfix: measured speed when halting and gear=0 but vehicle still has a remaining velocity.

parent 13b18ca1
No related branches found
No related tags found
No related merge requests found
...@@ -281,7 +281,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -281,7 +281,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
} }
/// <summary> /// <summary>
/// Handles Requests when no gear is engaged /// Handles Requests when no gear is disengaged
/// </summary> /// </summary>
/// <param name="absTime"></param> /// <param name="absTime"></param>
/// <param name="dt"></param> /// <param name="dt"></param>
...@@ -303,8 +303,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -303,8 +303,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
}; };
} }
if ((outTorque * avgOutAngularVelocity).IsGreater(0.SI<Watt>(), if ((outTorque * avgOutAngularVelocity).IsGreater(0.SI<Watt>(), Constants.SimulationSettings.LineSearchTolerance) &&
Constants.SimulationSettings.LineSearchTolerance)) { !outAngularVelocity.IsEqual(0)) {
return new ResponseOverload { return new ResponseOverload {
Source = this, Source = this,
Delta = outTorque * avgOutAngularVelocity, Delta = outTorque * avgOutAngularVelocity,
...@@ -312,8 +312,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -312,8 +312,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
}; };
} }
if ((outTorque * avgOutAngularVelocity).IsSmaller(0.SI<Watt>(), if ((outTorque * avgOutAngularVelocity).IsSmaller(0.SI<Watt>(), Constants.SimulationSettings.LineSearchTolerance)) {
Constants.SimulationSettings.LineSearchTolerance)) {
return new ResponseUnderload { return new ResponseUnderload {
Source = this, Source = this,
Delta = outTorque * avgOutAngularVelocity, Delta = outTorque * avgOutAngularVelocity,
...@@ -321,13 +320,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -321,13 +320,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
}; };
} }
CurrentState.SetState(0.SI<NewtonMeter>(), 0.RPMtoRad(), outTorque, outAngularVelocity); CurrentState.SetState(0.SI<NewtonMeter>(), 0.SI<PerSecond>(), outTorque, outAngularVelocity);
CurrentState.Gear = Gear; CurrentState.Gear = Gear;
var disengagedResponse = NextComponent.Request(absTime, dt, 0.SI<NewtonMeter>(), DataBus.EngineIdleSpeed); var disengagedResponse = NextComponent.Request(absTime, dt, 0.SI<NewtonMeter>(), DataBus.EngineIdleSpeed);
disengagedResponse.GearboxPowerRequest = outTorque * avgOutAngularVelocity; disengagedResponse.GearboxPowerRequest = outTorque * avgOutAngularVelocity;
return disengagedResponse; return disengagedResponse;
//todo mk-2016-08-17: minus inTorqueLoss?? Why not plus?
} }
private TorqueConverterOperatingPoint FindOperatingPoint(NewtonMeter outTorque, private TorqueConverterOperatingPoint FindOperatingPoint(NewtonMeter outTorque,
...@@ -359,7 +357,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -359,7 +357,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
(x.InTorque * x.InAngularVelocity).IsGreaterOrEqual(DataBus.EngineDragPower(x.InAngularVelocity), (x.InTorque * x.InAngularVelocity).IsGreaterOrEqual(DataBus.EngineDragPower(x.InAngularVelocity),
Constants.SimulationSettings.LineSearchTolerance.SI<Watt>()) Constants.SimulationSettings.LineSearchTolerance.SI<Watt>())
).ToArray(); ).ToArray();
if (filtered.Count() == 1) { if (filtered.Length == 1) {
return filtered.First(); return filtered.First();
} }
return operatingPointList[0]; return operatingPointList[0];
......
...@@ -196,6 +196,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -196,6 +196,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
debug.Add(response); debug.Add(response);
CurrentState.SimulationDistance = acceleration / 2 * dt * dt + DataBus.VehicleSpeed * dt; CurrentState.SimulationDistance = acceleration / 2 * dt * dt + DataBus.VehicleSpeed * dt;
if (CurrentState.SimulationDistance.IsSmaller(0))
throw new VectoSimulationException(
"MeasuredSpeed: Simulation Distance must not be negative. Driving Backward is not allowed.");
CurrentState.Distance = CurrentState.SimulationDistance + PreviousState.Distance; CurrentState.Distance = CurrentState.SimulationDistance + PreviousState.Distance;
CurrentState.Acceleration = acceleration; CurrentState.Acceleration = acceleration;
......
...@@ -104,7 +104,7 @@ namespace TUGraz.VectoCore.Tests.Integration.EngineOnlyCycle ...@@ -104,7 +104,7 @@ namespace TUGraz.VectoCore.Tests.Integration.EngineOnlyCycle
} }
modData.Finish(VectoRun.Status.Success); modData.Finish(VectoRun.Status.Success);
ResultFileHelper.TestModFile(modalResultFile, modFile + Constants.FileExtensions.ModDataFile, testVelocity: false); ResultFileHelper.TestModFile(modalResultFile, modFile + Constants.FileExtensions.ModDataFile);
} }
[TestCase] [TestCase]
......
...@@ -109,7 +109,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation ...@@ -109,7 +109,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
var testColumns = new[] { "P_aux_FAN", "P_aux_STP", "P_aux_AC", "P_aux_ES", "P_aux_PS", "P_aux" }; var testColumns = new[] { "P_aux_FAN", "P_aux_STP", "P_aux_AC", "P_aux_ES", "P_aux_PS", "P_aux" };
ResultFileHelper.TestModFile(@"TestData\Results\EngineOnlyCycles\AuxWriteModFileSumFile.vmod", ResultFileHelper.TestModFile(@"TestData\Results\EngineOnlyCycles\AuxWriteModFileSumFile.vmod",
@"AuxWriteModFileSumFile.vmod", testColumns, testVelocity: false); @"AuxWriteModFileSumFile.vmod", testColumns);
ResultFileHelper.TestSumFile(@"TestData\Results\EngineOnlyCycles\AuxWriteModFileSumFile.vsum", ResultFileHelper.TestSumFile(@"TestData\Results\EngineOnlyCycles\AuxWriteModFileSumFile.vsum",
@"AuxWriteModFileSumFile.vsum"); @"AuxWriteModFileSumFile.vsum");
} }
......
...@@ -166,7 +166,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation ...@@ -166,7 +166,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
ResultFileHelper.TestSumFile(@"TestData\Pwheel\Results\Pwheel.vsum", @"TestData\Pwheel\Pwheel.vsum"); ResultFileHelper.TestSumFile(@"TestData\Pwheel\Results\Pwheel.vsum", @"TestData\Pwheel\Pwheel.vsum");
ResultFileHelper.TestModFile(@"TestData\Pwheel\Results\Pwheel_Gear2_pt1_rep1_actual.vmod", ResultFileHelper.TestModFile(@"TestData\Pwheel\Results\Pwheel_Gear2_pt1_rep1_actual.vmod",
@"TestData\Pwheel\Pwheel_Gear2_pt1_rep1_actual.vmod", testVelocity: false); @"TestData\Pwheel\Pwheel_Gear2_pt1_rep1_actual.vmod");
} }
/// <summary> /// <summary>
...@@ -194,7 +194,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation ...@@ -194,7 +194,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
ResultFileHelper.TestSumFile(@"TestData\Pwheel\Results\Pwheel_ultimate.vsum", @"TestData\Pwheel\Pwheel_ultimate.vsum"); ResultFileHelper.TestSumFile(@"TestData\Pwheel\Results\Pwheel_ultimate.vsum", @"TestData\Pwheel\Pwheel_ultimate.vsum");
ResultFileHelper.TestModFile(@"TestData\Pwheel\Results\Pwheel_ultimate_RD_#1_Pwheel_AuxStd.vmod", ResultFileHelper.TestModFile(@"TestData\Pwheel\Results\Pwheel_ultimate_RD_#1_Pwheel_AuxStd.vmod",
@"TestData\Pwheel\Pwheel_ultimate_RD_#1_Pwheel_AuxStd.vmod", testVelocity: false); @"TestData\Pwheel\Pwheel_ultimate_RD_#1_Pwheel_AuxStd.vmod");
} }
} }
} }
\ No newline at end of file
...@@ -69,7 +69,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation ...@@ -69,7 +69,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
Assert.IsTrue(job.FinishedWithoutErrors); Assert.IsTrue(job.FinishedWithoutErrors);
ResultFileHelper.TestModFile(expected, actual, testVelocity: false); ResultFileHelper.TestModFile(expected, actual);
} }
[TestMethod] [TestMethod]
...@@ -89,7 +89,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation ...@@ -89,7 +89,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
Assert.IsTrue(r.Run.FinishedWithoutErrors, string.Format("{0}", r.ExecException)); Assert.IsTrue(r.Run.FinishedWithoutErrors, string.Format("{0}", r.ExecException));
} }
ResultFileHelper.TestModFile(expected, actual, testVelocity: false); ResultFileHelper.TestModFile(expected, actual);
} }
public IVectoRun CreateRun(string resultFileName) public IVectoRun CreateRun(string resultFileName)
...@@ -136,7 +136,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation ...@@ -136,7 +136,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
@"TestData\Jobs\24t Coach EngineOnly_Engine Only1.vmod", @"TestData\Jobs\24t Coach EngineOnly_Engine Only1.vmod",
@"TestData\Jobs\24t Coach EngineOnly_Engine Only2.vmod", @"TestData\Jobs\24t Coach EngineOnly_Engine Only2.vmod",
@"TestData\Jobs\24t Coach EngineOnly_Engine Only3.vmod" @"TestData\Jobs\24t Coach EngineOnly_Engine Only3.vmod"
}, testVelocity: false) })
; ;
} }
} }
......
...@@ -43,13 +43,13 @@ namespace TUGraz.VectoCore.Tests.Utils ...@@ -43,13 +43,13 @@ namespace TUGraz.VectoCore.Tests.Utils
public static class ResultFileHelper public static class ResultFileHelper
{ {
public static void TestModFile(string expectedFile, string actualFile, string[] testColumns = null, public static void TestModFile(string expectedFile, string actualFile, string[] testColumns = null,
bool testRowCount = true, bool testVelocity = true) bool testRowCount = true)
{ {
TestModFiles(new[] { expectedFile }, new[] { actualFile }, testColumns, testRowCount, testVelocity); TestModFiles(new[] { expectedFile }, new[] { actualFile }, testColumns, testRowCount);
} }
public static void TestModFiles(IEnumerable<string> expectedFiles, IEnumerable<string> actualFiles, public static void TestModFiles(IEnumerable<string> expectedFiles, IEnumerable<string> actualFiles,
string[] testColumns = null, bool testRowcount = true, bool testVelocity = true) string[] testColumns = null, bool testRowcount = true)
{ {
var resultFiles = expectedFiles.ZipAll(actualFiles, (expectedFile, actualFile) => new { expectedFile, actualFile }); var resultFiles = expectedFiles.ZipAll(actualFiles, (expectedFile, actualFile) => new { expectedFile, actualFile });
foreach (var result in resultFiles) { foreach (var result in resultFiles) {
...@@ -59,17 +59,31 @@ namespace TUGraz.VectoCore.Tests.Utils ...@@ -59,17 +59,31 @@ namespace TUGraz.VectoCore.Tests.Utils
var expected = VectoCSVFile.Read(result.expectedFile); var expected = VectoCSVFile.Read(result.expectedFile);
var actual = VectoCSVFile.Read(result.actualFile); var actual = VectoCSVFile.Read(result.actualFile);
if (testVelocity) { if (actual.Columns.Contains(ModalResultField.v_act.GetShortCaption()) &&
Assert.IsTrue( !double.IsNaN(actual.Rows[0].Field<string>(ModalResultField.v_act.GetShortCaption()).ToDouble(double.NaN))) {
actual.Rows.Cast<DataRow>() // test v_act >= 0
Assert.IsTrue(actual.Rows.Cast<DataRow>()
.All(r => r.ParseDouble(ModalResultField.v_act.GetShortCaption()).IsGreaterOrEqual(0)), .All(r => r.ParseDouble(ModalResultField.v_act.GetShortCaption()).IsGreaterOrEqual(0)),
"v_act must not be negative."); "v_act must not be negative.");
Assert.IsTrue(
actual.Rows.Cast<DataRow>() // test v_targ >= 0
Assert.IsTrue(actual.Rows.Cast<DataRow>()
.All(r => r.ParseDouble(ModalResultField.v_targ.GetShortCaption()).IsGreaterOrEqual(0)), .All(r => r.ParseDouble(ModalResultField.v_targ.GetShortCaption()).IsGreaterOrEqual(0)),
"v_targ must not be negative."); "v_targ must not be negative.");
} }
if (actual.Columns.Contains(ModalResultField.dist.GetShortCaption()) &&
!double.IsNaN(actual.Rows[0].Field<string>(ModalResultField.dist.GetShortCaption()).ToDouble(double.NaN))) {
// test distance monotonous increasing
var distPrev = actual.Rows[0].ParseDouble(ModalResultField.dist.GetShortCaption());
for (var i = 1; i < actual.Rows.Count; i++) {
var dist = actual.Rows[i].ParseDouble(ModalResultField.dist.GetShortCaption());
Assert.IsTrue(distPrev.IsSmallerOrEqual(dist), "distance must not decrease.");
distPrev = dist;
}
}
if (testRowcount) { if (testRowcount) {
Assert.AreEqual(expected.Rows.Count, actual.Rows.Count, Assert.AreEqual(expected.Rows.Count, actual.Rows.Count,
string.Format("Moddata: Row count differs.\nExpected {0} Rows in {1}\nGot {2} Rows in {3}", expected.Rows.Count, string.Format("Moddata: Row count differs.\nExpected {0} Rows in {1}\nGot {2} Rows in {3}", expected.Rows.Count,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment