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

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

adding tests for coasting

parent 51627fe7
No related branches found
No related tags found
No related merge requests found
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.Models.Simulation.Data;
using TUGraz.VectoCore.Tests.Utils;
using Assert = Microsoft.VisualStudio.TestTools.UnitTesting.Assert;
namespace TUGraz.VectoCore.Tests.Integration.DriverStrategy
{
[TestFixture]
public class CoastingTests
{
[TestFixtureSetUp]
public void DisableLogging()
{
//LogManager.DisableLogging();
//#if TRACE
GraphWriter.Enable();
//#else
// GraphWriter.Disable();
//#endif
GraphWriter.Xfields = new[] { ModalResultField.dist };
GraphWriter.Yfields = new[] {
ModalResultField.v_act, ModalResultField.acc, ModalResultField.n_eng_avg, ModalResultField.Gear,
ModalResultField.P_eng_out, /*ModalResultField.T_eng_fcmap, */ ModalResultField.FCMap,
};
GraphWriter.PlotDrivingMode = true;
GraphWriter.Series1Label = "Vecto 3";
}
[Test,
TestCase(60, 20, 0),
TestCase(60, 20, 0.6),
TestCase(60, 20, 1.4),
TestCase(60, 20, 2.7),
TestCase(60, 20, 3.3),
TestCase(60, 20, 3.7),
TestCase(60, 35, 5.3),
]
public void Truck_Coasting_Test(double v1, double v2, double slope)
{
Assert.IsTrue(v1 > v2);
var cycle = new[] {
// <s>,<v>,<grad>,<stop>
string.Format(" 0, {0}, {2}, 0", v1, v2, slope),
string.Format("1000, {1}, {2}, 0", v1, v2, slope),
string.Format("1100, {1}, 0, 0", v1, v2, slope)
};
System.IO.Directory.CreateDirectory(string.Format(@"Coast_{0}_{1}", v1, v2, slope));
var slopePrefix = "";
if (!slope.IsEqual(0)) {
slopePrefix = slope > 0 ? "uh_" : "dh_";
}
var modFile = string.Format(@"Coast_{0}_{1}\Truck_Coast_{0}_{1}_{3}{2:0.0}.vmod", v1, v2, Math.Abs(slope),
slopePrefix);
var cycleData = SimpleDrivingCycles.CreateCycleData(cycle);
var run = Truck40tPowerTrain.CreateEngineeringRun(cycleData, modFile);
run.Run();
Assert.IsTrue(run.FinishedWithoutErrors);
GraphWriter.Write(modFile);
}
[Test,
TestCase(40),
TestCase(45),
TestCase(50),
TestCase(55),
TestCase(60),
TestCase(65),
TestCase(70),
TestCase(75),
TestCase(80),
]
public void Truck_Coasting_Variability_Test(double v1)
{
const double vStep = 2.5;
const double vMin = 40;
Assert.IsTrue(vMin - vStep > 0);
for (var v2 = vMin; v2 <= v1 - vStep; v2 += vStep) {
for (var slope = -6.0; slope <= 6; slope += 0.1) {
Truck_Coasting_Test(v1, v2, slope);
}
}
}
}
}
\ No newline at end of file
......@@ -31,6 +31,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Utils;
......@@ -78,12 +79,13 @@ namespace TUGraz.VectoCore.Tests.Integration
}
public static VehicleContainer CreatePowerTrain(DrivingCycleData cycleData, string modFileName,
Kilogram massExtra,
Kilogram loading, bool overspeed = false)
Kilogram massExtra, Kilogram loading, bool overspeed = false)
{
var fileWriter = new FileOutputWriter(modFileName);
var modData = new ModalDataContainer(modFileName, fileWriter);
var container = new VehicleContainer(executionMode: ExecutionMode.Engineering, modData: modData) { RunData = new VectoRunData{ JobName = modFileName, Cycle = cycleData}};
var modData = new ModalDataContainer(Path.GetFileName(modFileName), fileWriter);
var container = new VehicleContainer(executionMode: ExecutionMode.Engineering, modData: modData) {
RunData = new VectoRunData { JobName = modFileName, Cycle = cycleData }
};
var engineData = MockSimulationDataFactory.CreateEngineDataFromFile(EngineFile);
var axleGearData = CreateAxleGearData();
......
......@@ -85,6 +85,7 @@
<Compile Include="Integration\BusAuxiliaries\SimpleCycleTest.cs" />
<Compile Include="Integration\CoachAdvancedAuxPowertrain.cs" />
<Compile Include="Integration\CoachPowerTrain.cs" />
<Compile Include="Integration\DriverStrategy\CoastingTests.cs" />
<Compile Include="Integration\DriverStrategy\DriverStrategyTestCoach.cs" />
<Compile Include="Integration\DriverStrategy\DriverStrategyTestTruck.cs" />
<Compile Include="Integration\FullCycleDeclarationTest.cs">
......
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