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

Skip to content
Snippets Groups Projects
Commit 4308c87f authored by Michael KRISPER's avatar Michael KRISPER
Browse files

auxiliary tests, adjusted electrical system (included mapping for alternator efficiency)

parent 9c165e27
No related branches found
No related tags found
No related merge requests found
Showing
with 163 additions and 291 deletions
Technology ,Long haul,Regional delivery,Urban delivery,Municipal utility,Construction,Heavy Urban,Urban,Suburban,Interurban,Coach
Standard alternator,0.7 ,0.7 ,0.7 ,0.7 ,0.7 ,1 ,1 ,1 ,1 ,1
\ No newline at end of file
......@@ -7,6 +7,8 @@ namespace TUGraz.VectoCore.Models.Declaration
{
public class ElectricSystem : LookupData<MissionType, string[], Watt>
{
private readonly Alternator _alternator = new Alternator();
private const string BaseLine = "Baseline electric power consumption";
private readonly Dictionary<Tuple<MissionType, string>, Watt> _data =
......@@ -26,7 +28,7 @@ namespace TUGraz.VectoCore.Models.Declaration
foreach (DataRow row in table.Rows) {
var name = row.Field<string>("Technology");
foreach (MissionType mission in Enum.GetValues(typeof (MissionType))) {
foreach (MissionType mission in Enum.GetValues(typeof(MissionType))) {
_data[Tuple.Create(mission, name)] = row.ParseDouble(mission.ToString().ToLower()).SI<Watt>();
}
}
......@@ -36,15 +38,54 @@ namespace TUGraz.VectoCore.Models.Declaration
{
var sum = _data[Tuple.Create(missionType, BaseLine)];
foreach (var s in technologies) {
Watt w;
if (_data.TryGetValue(Tuple.Create(missionType, s), out w)) {
sum += w;
} else {
Log.Error(string.Format("electric system technology not found: {0}", s));
if (technologies != null) {
foreach (var s in technologies) {
Watt w;
if (_data.TryGetValue(Tuple.Create(missionType, s), out w)) {
sum += w;
} else {
Log.Error(string.Format("electric system technology not found: {0}", s));
}
}
}
return sum;
return sum / _alternator.Lookup(missionType, null);
}
private class Alternator : LookupData<MissionType, string, double>
{
private const string Default = "Standard alternator";
private readonly Dictionary<Tuple<MissionType, string>, double> _data =
new Dictionary<Tuple<MissionType, string>, double>();
protected string ResourceId = "TUGraz.VectoCore.Resources.Declaration.VAUX.ALT-Tech.csv";
public Alternator()
{
ParseData(ReadCsvResource(ResourceId));
}
protected override void ParseData(DataTable table)
{
NormalizeTable(table);
foreach (DataRow row in table.Rows) {
var name = row.Field<string>("Technology");
foreach (MissionType mission in Enum.GetValues(typeof(MissionType))) {
_data[Tuple.Create(mission, name)] = row.ParseDouble(mission.ToString().ToLower());
}
}
}
public override double Lookup(MissionType missionType, string technology)
{
if (string.IsNullOrWhiteSpace(technology)) {
technology = Default;
}
return _data[Tuple.Create(missionType, technology)];
}
}
}
}
\ No newline at end of file
using System;
using TUGraz.VectoCore.Exceptions;
using TUGraz.VectoCore.Models.Connector.Ports;
using TUGraz.VectoCore.Models.Simulation;
using TUGraz.VectoCore.Models.Simulation.Data;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
{
public class DirectAuxiliary : VectoSimulationComponent, IAuxiliary, ITnInPort, ITnOutPort
{
private readonly IAuxiliaryCycleData _demand;
private ITnOutPort _outPort;
private Watt _powerDemand;
public DirectAuxiliary(IVehicleContainer container, IAuxiliaryCycleData demand)
: base(container)
{
_demand = demand;
}
#region ITnInProvider
public ITnInPort InPort()
{
return this;
}
#endregion
#region ITnOutProvider
public ITnOutPort OutPort()
{
return this;
}
#endregion
#region ITnInPort
void ITnInPort.Connect(ITnOutPort other)
{
_outPort = other;
}
#endregion
#region ITnOutPort
IResponse ITnOutPort.Request(Second absTime, Second dt, NewtonMeter torque, PerSecond engineSpeed, bool dryRun)
{
if (_outPort == null) {
Log.ErrorFormat("{0} cannot handle incoming request - no outport available", absTime);
throw new VectoSimulationException(
string.Format("{0} cannot handle incoming request - no outport available",
absTime));
}
_powerDemand = _demand.GetPowerDemand(absTime, dt);
var tq = Formulas.PowerToTorque(_powerDemand, engineSpeed);
return _outPort.Request(absTime, dt, torque + tq, engineSpeed, dryRun);
}
public IResponse Initialize(NewtonMeter torque, PerSecond engineSpeed)
{
_powerDemand = _demand.GetPowerDemand(0.SI<Second>(), 0.SI<Second>());
var tq = Formulas.PowerToTorque(_powerDemand, engineSpeed);
return _outPort.Initialize(torque + tq, engineSpeed);
}
#endregion
#region VectoSimulationComponent
protected override void DoWriteModalResults(IModalDataWriter writer)
{
writer[ModalResultField.Paux] = _powerDemand;
}
protected override void DoCommitSimulationStep() {}
#endregion
}
}
\ No newline at end of file
using System;
using TUGraz.VectoCore.Exceptions;
using TUGraz.VectoCore.Models.Connector.Ports;
using TUGraz.VectoCore.Models.Simulation;
using TUGraz.VectoCore.Models.Simulation.Data;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
{
public class AuxiliaryData
{
public double EfficiencyToSupply { get; set; }
public double TransitionRatio { get; set; }
public double EfficiencyToEngine { get; set; }
public Watt GetPowerDemand(PerSecond nAuxiliary, Watt powerAuxOut)
{
throw new NotImplementedException();
}
public static AuxiliaryData ReadFromFile(string filePath)
{
throw new NotImplementedException();
}
}
public class MappingAuxiliary : VectoSimulationComponent, IAuxiliary, ITnInPort, ITnOutPort
{
private readonly IAuxiliaryCycleData _demand;
private AuxiliaryData _data;
private ITnOutPort _outPort;
private Watt _powerDemand;
public MappingAuxiliary(IVehicleContainer container, IAuxiliaryCycleData demand, AuxiliaryData data)
: base(container)
{
_demand = demand;
_data = data;
}
#region ITnInProvider
public ITnInPort InPort()
{
return this;
}
#endregion
#region ITnOutProvider
public ITnOutPort OutPort()
{
return this;
}
#endregion
#region ITnInPort
void ITnInPort.Connect(ITnOutPort other)
{
_outPort = other;
}
#endregion
#region ITnOutPort
IResponse ITnOutPort.Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity, bool dryRun)
{
if (_outPort == null) {
Log.ErrorFormat("{0} cannot handle incoming request - no outport available", absTime);
throw new VectoSimulationException(
string.Format("{0} cannot handle incoming request - no outport available",
absTime));
}
var torqueAux = GetPowerDemand(absTime, dt, angularVelocity);
return _outPort.Request(absTime, dt, torque + torqueAux, angularVelocity);
}
private NewtonMeter GetPowerDemand(Second absTime, Second dt, PerSecond angularVelocity)
{
var powerSupply = _demand.GetPowerDemand(absTime, dt);
var powerAuxOut = powerSupply / _data.EfficiencyToSupply;
var nAuxiliary = angularVelocity * _data.TransitionRatio;
var powerAuxIn = _data.GetPowerDemand(nAuxiliary, powerAuxOut);
var powerAux = powerAuxIn / _data.EfficiencyToEngine;
_powerDemand = powerAux;
var torqueAux = Formulas.PowerToTorque(powerAux, angularVelocity);
return torqueAux;
}
public IResponse Initialize(NewtonMeter torque, PerSecond angularVelocity)
{
var torqueAux = GetPowerDemand(0.SI<Second>(), 0.SI<Second>(), angularVelocity);
return _outPort.Initialize(torque + torqueAux, angularVelocity);
}
#endregion
#region VectoSimulationComponent
protected override void DoWriteModalResults(IModalDataWriter writer)
{
writer[ModalResultField.Paux_xxx] = _powerDemand;
}
protected override void DoCommitSimulationStep() {}
#endregion
}
}
\ No newline at end of file
Technology ,Long haul,Regional delivery,Urban delivery,Municipal utility,Construction,Heavy Urban,Urban,Suburban,Interurban,Coach
Standard alternator,0.7 ,0.7 ,0.7 ,0.7 ,0.7 ,1 ,1 ,1 ,1 ,1
\ No newline at end of file
......@@ -35,12 +35,13 @@ namespace TUGraz.VectoCore.Utils
/// </summary>
/// <param name="fileName"></param>
/// <param name="ignoreEmptyColumns"></param>
/// <param name="fullHeader"></param>
/// <exception cref="FileIOException"></exception>
/// <returns>A DataTable which represents the CSV File.</returns>
public static DataTable Read(string fileName, bool ignoreEmptyColumns = false)
public static DataTable Read(string fileName, bool ignoreEmptyColumns = false, bool fullHeader = false)
{
try {
return ReadData(File.ReadAllLines(fileName), ignoreEmptyColumns);
return ReadData(File.ReadAllLines(fileName), ignoreEmptyColumns, fullHeader);
} catch (Exception e) {
throw new VectoException(string.Format("File {0}: {1}", fileName, e.Message));
}
......@@ -68,11 +69,11 @@ namespace TUGraz.VectoCore.Utils
}
}
private static DataTable ReadData(string[] data, bool ignoreEmptyColumns = false)
private static DataTable ReadData(string[] data, bool ignoreEmptyColumns = false, bool fullHeader = false)
{
var lines = RemoveComments(data);
var validColumns = GetValidHeaderColumns(lines.First());
var validColumns = GetValidHeaderColumns(lines.First(), fullHeader).ToArray();
if (validColumns.Length > 0) {
// Valid Columns found => header was valid => skip header line
......@@ -108,22 +109,24 @@ namespace TUGraz.VectoCore.Utils
return table;
}
private static string[] GetValidHeaderColumns(string line)
private static IEnumerable<string> GetValidHeaderColumns(string line, bool fullHeader = false)
{
Contract.Requires(line != null);
double test;
var validColumns = GetColumns(line).
var validColumns = GetColumns(line, fullHeader).
Where(col => !double.TryParse(col, NumberStyles.Any, CultureInfo.InvariantCulture, out test));
return validColumns.ToArray();
}
private static IEnumerable<string> GetColumns(string line)
private static IEnumerable<string> GetColumns(string line, bool fullHeader = false)
{
Contract.Requires(line != null);
line = Regex.Replace(line, @"\[.*?\]", "");
line = line.Replace("<", "");
line = line.Replace(">", "");
if (!fullHeader) {
line = Regex.Replace(line, @"\[.*?\]", "");
line = line.Replace("<", "");
line = line.Replace(">", "");
}
return line.Split(Delimiter).Select(col => col.Trim());
}
......
......@@ -272,6 +272,7 @@
<EmbeddedResource Include="Resources\Declaration\DefaultTC.vtcc" />
<EmbeddedResource Include="Resources\Declaration\VCDV\parameters.csv" />
<EmbeddedResource Include="Resources\Declaration\WHTC-Weighting-Factors.csv" />
<EmbeddedResource Include="Resources\Declaration\VAUX\ALT-Tech.csv" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
......
......@@ -172,7 +172,8 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration
var angularSpeed = r.Next(1000).SI<PerSecond>();
var torque = tc.LookupTorque(exp.nu, angularSpeed, referenceSpeed);
AssertHelper.AreRelativeEqual(exp.torque * Math.Pow(angularSpeed.Value() / referenceSpeed.Value(), 2), torque.Value());
AssertHelper.AreRelativeEqual(exp.torque * Math.Pow(angularSpeed.Value() / referenceSpeed.Value(), 2),
torque.Value());
}
}
......@@ -182,25 +183,25 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration
var es = DeclarationData.ElectricSystem;
var expected = new[] {
new { Mission = MissionType.LongHaul, Base = 1240, LED = 1190 },
new { Mission = MissionType.RegionalDelivery, Base = 1055, LED = 1005 },
new { Mission = MissionType.UrbanDelivery, Base = 974, LED = 924 },
new { Mission = MissionType.MunicipalUtility, Base = 974, LED = 924 },
new { Mission = MissionType.Construction, Base = 975, LED = 925 },
new { Mission = MissionType.HeavyUrban, Base = 0, LED = 0 },
new { Mission = MissionType.Urban, Base = 0, LED = 0 },
new { Mission = MissionType.Suburban, Base = 0, LED = 0 },
new { Mission = MissionType.Interurban, Base = 0, LED = 0 },
new { Mission = MissionType.Coach, Base = 0, LED = 0 }
new { Mission = MissionType.LongHaul, Base = 1240.SI<Watt>(), LED = 1190.SI<Watt>(), Efficiency = 0.7 },
new { Mission = MissionType.RegionalDelivery, Base = 1055.SI<Watt>(), LED = 1005.SI<Watt>(), Efficiency = 0.7 },
new { Mission = MissionType.UrbanDelivery, Base = 974.SI<Watt>(), LED = 924.SI<Watt>(), Efficiency = 0.7 },
new { Mission = MissionType.MunicipalUtility, Base = 974.SI<Watt>(), LED = 924.SI<Watt>(), Efficiency = 0.7 },
new { Mission = MissionType.Construction, Base = 975.SI<Watt>(), LED = 925.SI<Watt>(), Efficiency = 0.7 },
new { Mission = MissionType.HeavyUrban, Base = 0.SI<Watt>(), LED = 0.SI<Watt>(), Efficiency = 1.0 },
new { Mission = MissionType.Urban, Base = 0.SI<Watt>(), LED = 0.SI<Watt>(), Efficiency = 1.0 },
new { Mission = MissionType.Suburban, Base = 0.SI<Watt>(), LED = 0.SI<Watt>(), Efficiency = 1.0 },
new { Mission = MissionType.Interurban, Base = 0.SI<Watt>(), LED = 0.SI<Watt>(), Efficiency = 1.0 },
new { Mission = MissionType.Coach, Base = 0.SI<Watt>(), LED = 0.SI<Watt>(), Efficiency = 1.0 }
};
Assert.AreEqual(expected.Length, Enum.GetValues(typeof(MissionType)).Length);
foreach (var expectation in expected) {
var baseConsumption = es.Lookup(expectation.Mission, technologies: new string[] { });
var baseConsumption = es.Lookup(expectation.Mission, technologies: null);
var leds = es.Lookup(expectation.Mission, technologies: new[] { "LED lights" });
Assert.AreEqual(expectation.Base, baseConsumption.Value(), Tolerance);
Assert.AreEqual(expectation.LED, leds.Value(), Tolerance);
AssertHelper.AreRelativeEqual(expectation.Base / expectation.Efficiency, baseConsumption);
AssertHelper.AreRelativeEqual(expectation.LED / expectation.Efficiency, leds);
}
}
......
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TUGraz.VectoCore.Utils;
using TUGraz.VectoCore.Exceptions;
using TUGraz.VectoCore.Tests.Utils;
using TUGraz.VectoCore.FileIO.Reader;
using TUGraz.VectoCore.Models.Declaration;
using TUGraz.VectoCore.Models.Simulation.Data;
using TUGraz.VectoCore.Models.Simulation.Impl;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TUGraz.VectoCore.Models.SimulationComponent.Impl;
using TUGraz.VectoCore.Tests.Utils;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Tests.Models.Simulation
{
......@@ -18,31 +16,35 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
[TestMethod]
public void AuxWriteModFileSumFile()
{
var dataWriter = new ModalDataWriter(@"TestData\Results\24t Coach AUX.vmod", false);
var dataWriter = new ModalDataWriter(@"40t_Long_Haul_Truck_Long_Haul_Empty Loading.vmod", false);
dataWriter.AddAuxiliary("FAN");
dataWriter.AddAuxiliary("PS");
dataWriter.AddAuxiliary("STP");
dataWriter.AddAuxiliary("ES");
dataWriter.AddAuxiliary("AC");
var sumWriter = new SummaryFileWriter(@"TestData\Results\24t Coach AUX.vsum");
var sumWriter = new SummaryFileWriter(@"40t_Long_Haul_Truck.vsum");
var deco = new SumWriterDecoratorFullPowertrain(sumWriter, "", "", "");
var container = new VehicleContainer(dataWriter, deco);
var data = DrivingCycleDataReader.ReadFromFileTimeBased(@"TestData\Cycles\Coach time based short.vdri");
var data = DrivingCycleDataReader.ReadFromFileDistanceBased(@"TestData\Cycles\LongHaul_short.vdri");
var port = new MockTnOutPort();
var aux = new Auxiliary(container);
aux.InPort().Connect(port);
aux.AddConstant("FAN", DeclarationData.Fan.Lookup(MissionType.LongHaul, ""));
aux.AddConstant("PS", DeclarationData.PneumaticSystem.Lookup(MissionType.LongHaul, VehicleClass.Class3));
var hdvClass = VehicleClass.Class5;
var mission = MissionType.LongHaul;
aux.AddConstant("FAN",
DeclarationData.Fan.Lookup(MissionType.LongHaul, "Hydraulic driven - Constant displacement pump"));
aux.AddConstant("PS", DeclarationData.PneumaticSystem.Lookup(mission, hdvClass));
aux.AddConstant("STP",
DeclarationData.SteeringPump.Lookup(MissionType.LongHaul, VehicleClass.Class3, "Fixed displacement"));
aux.AddConstant("ES", DeclarationData.ElectricSystem.Lookup(MissionType.LongHaul, new string[0]));
DeclarationData.SteeringPump.Lookup(MissionType.LongHaul, hdvClass, "Variable displacement"));
aux.AddConstant("ES", DeclarationData.ElectricSystem.Lookup(mission, null));
aux.AddConstant("AC",
DeclarationData.HeatingVentilationAirConditioning.Lookup(MissionType.LongHaul, VehicleClass.Class3));
DeclarationData.HeatingVentilationAirConditioning.Lookup(mission, hdvClass));
var speed = 1400.RPMtoRad();
var torque = 500.SI<NewtonMeter>();
......@@ -50,7 +52,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
var dt = 1.SI<Second>();
for (var i = 0; i < data.Entries.Count; i++) {
aux.OutPort().Request(t, t, torque, speed);
aux.OutPort().Request(t, dt, torque, speed);
container.CommitSimulationStep(t, dt);
t += dt;
}
......@@ -58,10 +60,14 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
container.FinishSimulation();
sumWriter.Finish();
ResultFileHelper.TestModFile(@"TestData\Results\Auxiliaries.vmod", @"TestData\Results\24t Coach AUX.vmod");
ResultFileHelper.TestSumFile(@"TestData\Results\Auxiliaries.vsum", @"TestData\Results\24t Coach AUX.vsum");
}
//todo: add aux columns to test
var testColumns = new[] { "Paux_FAN", "Paux_STP", "Paux_AC", "Paux_ES", "Paux_PS", "Paux" };
ResultFileHelper.TestModFile(@"TestData\Results\EngineOnlyCycles\40t_Long_Haul_Truck_Long_Haul_Empty Loading.vmod",
@"40t_Long_Haul_Truck_Long_Haul_Empty Loading.vmod", testColumns);
ResultFileHelper.TestSumFile(@"40t_Long_Haul_Truck.vsum",
@"TestData\Results\EngineOnlyCycles\40t_Long_Haul_Truck.vsum");
}
[TestMethod]
public void AuxConstant()
......
<s>,<v>,<grad>,<stop>
0,0,2.95016969027809,2
1,60,2.95016969027809,0
2,60,2.95016969027809,0
3,60,2.95016969027809,0
4,60,2.95016969027809,0
5,60,2.95016969027809,0
6,60,2.95016969027809,0
7,60,2.95016969027809,0
8,60,2.95016969027809,0
9,60,3.06801369027809,0
10,60,3.06801369027809,0
\ No newline at end of file
time [s],dt [s], dist [m],v_act [km/h],v_targ [km/h],acc [m/s²],grad [%],n [1/min],Tq_eng [Nm],Tq_clutch [Nm],Tq_full [Nm],Tq_drag [Nm],Pe_eng [kW],Pe_full [kW],Pe_drag [kW],Pe_clutch [kW],Pa Eng [kW],Paux [kW],Gear [-],Ploss GB [kW],Ploss Diff [kW],Ploss Retarder [kW],Pa GB [kW],Pa Veh [kW],Proll [kW],Pair [kW],Pgrad [kW],Pwheel [kW],Pbrake [kW],Paux_FAN [kW],Paux_STP [kW],Paux_AC [kW],Paux_ES [kW],Paux_PS [kW],FC-Map [g/h],FC-AUXc [g/h],FC-WHTCc [g/h]
1.5,1,0,0,0,0,-0.0007722848,600,62.55471,0,586,-44,3.930429,36.81947,-2.764601,0,0,3.930429,0,0,0,0,0,0,0,0,0,0,0,0.883,0.186,0.15,1.391429,1.32,1387.543,-,1374.777
2.5,1,0,0,0,0,-0.0007722848,600,62.55471,0,586,-44,3.930429,36.81947,-2.764601,0,0,3.930429,0,0,0,0,0,0,0,0,0,0,0,0.883,0.186,0.15,1.391429,1.32,1387.543,-,1374.777
3.5,1,0.5,1.8,5.99999985694885,1,-0.0007722848,644.4445,180.6473,105.3896,623.5555,-46.22222,12.19117,42.08131,-3.119356,7.112333,1.148414,3.930429,1,0.2287433,0.2998479,0,0,6.058701,0.5250318,0.0004589302,-0.0004507788,6.583741,0,0.883,0.186,0.15,1.391429,1.32,2806.615,-,2780.795
4.5,1,2,5.4,11.9999997138977,1,-0.0007722848,950.4012,357.0731,215.7814,851.2568,-60.01605,35.53798,84.72199,-5.973144,21.47582,10.13173,3.930429,1,0.8138651,0.8997127,0,0,18.1761,1.575095,0.01239111,-0.001352336,19.76224,0,0.883,0.186,0.15,1.391429,1.32,7234.365,-,7167.809
5.5,1,3.95612859725952,7.04206295013428,11.9999997138977,-0.08774281,-0.0007722848,950.4012,39.49156,0,851.2568,-60.01605,3.930429,84.72199,-5.973144,0,0,3.930429,0,0,0,0,0,-2.079785,2.05406,0.02748076,-0.001763563,-8.086558E-06,0,0.883,0.186,0.15,1.391429,1.32,1621.283,-,1606.367
6.5,1,5.82456469535828,6.72636995315552,40.0000019073486,-0.08764219,-0.0007722848,844.9327,-0.01361027,0,783.757,-55.79731,-0.001204252,69.34772,-4.93701,0,-3.931633,3.930429,0,0,0,0,0,-1.984271,1.961977,0.02394811,-0.001684503,-3.083143E-05,-3.083143E-05,0.883,0.186,0.15,1.391429,1.32,963.1212,-,954.2604
7.5,1,8.14917969703674,8.36861400604248,68.0000015258789,1,-0.0007722848,785.5349,424.4827,401.148,742.777,-53.27674,34.91838,61.10159,-4.382599,32.99884,-2.01089,3.930429,2,0.9507985,1.394731,0,0,28.16829,2.440994,0.04612004,-0.002095774,30.65331,0,0.883,0.186,0.15,1.391429,1.32,7152.386,-,7086.584
8.5,1,11.4737946987152,11.9686140060425,68.0000015258789,1,-0.0007722848,1123.455,549.6978,402.4379,892.8764,-69.40732,64.67083,105.0451,-8.165629,47.346,13.3944,3.930429,2,1.441564,1.995763,0,0,40.2857,3.491057,0.1349151,-0.002997332,43.90867,0,0.883,0.186,0.15,1.391429,1.32,12777.98,-,12660.43
9.5,1,15.7984097003937,15.5686140060425,68.0000015258789,1,-0.0007722848,1461.376,548.1378,403.9429,899,-90.06879,83.88422,137.5784,-13.78367,61.81736,18.13643,3.930429,2,1.982165,2.597918,0,0,52.4031,4.541121,0.296947,-0.003898889,57.23727,0,0.883,0.186,0.15,1.391429,1.32,16443.65,-,16292.37
10.5,1,20.5762746334076,17.2003137588501,68.0000015258789,-0.09350014,-0.0007722848,1461.376,25.68322,0,899,-90.06879,3.930429,137.5784,-13.78367,0,0,3.930429,0,0,0,0,0,-5.41322,5.017062,0.4004407,-0.00430752,-2.456876E-05,-2.456876E-05,0.883,0.186,0.15,1.391429,1.32,2521.462,-,2498.265
11.5,1,25.260773897171,16.8641973495483,68.0000015258789,-0.0932312,-0.0007722848,1308.973,-35.28123,0,899,-80.62812,-4.836187,123.2307,-11.05213,0,-8.766616,3.930429,0,0,0,0,0,-5.292172,4.919023,0.3774211,-0.004223346,4.768465E-05,0,0.883,0.186,0.15,1.391429,1.32,973.7392,-,964.7808
Job [-],Input File [-],Cycle [-],time [s],distance [km],speed [km/h],∆altitude [m],Eaux_FAN [kWh],Eaux_PS [kWh],Eaux_STP [kWh],Eaux_ES [kWh],Eaux_AC [kWh],Ppos [kW],Pneg [kW],FC-Map [g/h],FC-Map [g/km],FC-AUXc [g/h],FC-AUXc [g/km],FC-WHTCc [g/h],FC-WHTCc [g/km],CO2 [g/km],CO2 [g/tkm],FC-Final [g/km],FC-Final [l/100tkm],FC-Final [l/100km],PwheelPos [kW],Pbrake [kW],EposICE [kWh],EnegICE [kWh],Eair [kWh],Eroll [kWh],Egrad [kWh],Eacc [kWh],Eaux [kWh],Ebrake [kWh],Etransm [kWh],Eretarder [kWh],Etorqueconv [kWh],Mass [kg],Loading [kg],a [m/s^2],a_pos [m/s^2],a_neg [m/s^2],Acc.Noise [m/s^2],pAcc [%],pDec [%],pCruise [%],pStop [%]
1,12t Delivery Truck.vecto,Long_Haul.vdri,5245,108.1818,74.25249,0.4157933,1.36807084861729,1.71919436802467,0.323441670835018,2.58087303572231,0.291388893230922,68.828245691688,-0.295060687814728,13939.92,187.7368,-,-,14048.65,189.2011,597.8755,-,189.2011,-,22.74052,53.3331431698079,-0.951296060530201,100.278930181362,-0.429887029885625,-53.7217975638455,-21.602133366182,-0.00594433389811052,8.54700596796142E-08,-6.28296870787938,-1.38598551041136,-16.8502154708157,0,0,7750,0,-4.545636E-10,0.432781,-0.5312394,0.2062322,0.0528122,0.04080076,0.8602479,0.04613918
\ No newline at end of file
1,40t_Long_Haul_Truck.vecto,Long_Haul.vdri,5188,108.1817,75.06826,0.4176572,1.44111111111111,1.93108893699116,0.62256001614862,2.55282541645898,0.504388880299197,84.2005492982813,-1.38841319755122,16373.51,218.1149,-,-,16610.92,221.2776,699.2371,-,221.2776,-,26.59586,71.9230417326127,-2.65873198913168,121.342347155412,-2.00085768580437,-68.5272798927924,-27.4112346063885,-0.000913775395601988,6.82509400778347E-08,-7.05197461869982,-3.8315282110042,-10.5097224537532,-2.00511476749089,0,14600,0,-4.595578E-10,0.4826669,-0.5824779,0.194878,0.04471858,0.03797225,0.870663,0.04664611
\ No newline at end of file
time [s],dt,dist [m] ,v_act [km/h] ,v_targ [km/h] ,acc [m/s²],grad [%],n [1/min],Tq_eng [Nm],Tq_clutch [Nm],Tq_full [Nm],Tq_drag [Nm],Pe_eng [kW],Pe_full [kW],Pe_drag [kW],Pe_clutch [kW],Pa Eng [kW],Paux [kW],Gear [-],Ploss GB [kW],Ploss Diff [kW],Ploss Retarder [kW],Pa GB [kW],Pa Veh [kW],Proll [kW],Pair [kW] ,Pgrad [kW],Pwheel [kW] ,Pbrake [kW] ,Paux_FAN [kW],Paux_STP [kW],Paux_AC [kW],Paux_ES [kW],Paux_PS [kW],FC-Map [g/h],FC-AUXc [g/h],FC-WHTCc [g/h]
1.5 ,1 ,0 ,0 ,0 ,0 ,2.95017 ,560 ,83.44429 ,0 ,1180 ,-149 ,4.893429 ,69.19881 ,-8.737817 ,0 ,0 ,4.893429 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,1 ,0.432 ,0.35 ,1.771429 ,1.34 ,2065.827 ,- ,2095.781
2.5 ,1 ,0 ,0 ,0 ,0 ,2.95017 ,560 ,83.44429 ,0 ,1180 ,-149 ,4.893429 ,69.19881 ,-8.737817 ,0 ,0 ,4.893429 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,1 ,0.432 ,0.35 ,1.771429 ,1.34 ,2065.827 ,- ,2095.781
3.5 ,1 ,0.5 ,1.8 ,29.9999988555908,1 ,2.95017 ,593.1891 ,271.5101 ,175.3559 ,1264.632 ,-148.1703 ,16.86583 ,78.55721 ,-9.204132 ,10.89286 ,1.079541 ,4.893429 ,5 ,0.3043601 ,0.2645191 ,0.02653578 ,0 ,7.729102 ,0.4559692 ,0.0005906814,2.111786 ,10.29745 ,0 ,1 ,0.432 ,0.35 ,1.771429 ,1.34 ,4088.593 ,- ,4147.877
4.5 ,1 ,2 ,5.4 ,59.9999977111816,1 ,2.95017 ,593.1891 ,606.1465 ,527.3709 ,1264.632 ,-148.1703 ,37.65298 ,78.55721 ,-9.204132 ,32.75955 ,0 ,4.893429 ,5 ,0.9795703 ,0.7937708 ,0.07968796 ,0 ,23.18731 ,1.367908 ,0.0159484 ,6.335359 ,30.90652 ,0 ,1 ,0.432 ,0.35 ,1.771429 ,1.34 ,8072.336 ,- ,8189.384
5.5 ,1 ,4.5 ,9 ,59.9999977111816,1 ,2.95017 ,714.2208 ,857.2393 ,732.1379 ,1572.692 ,-148.5711 ,64.11552 ,117.6264 ,-11.11208 ,54.75881 ,4.463279 ,4.893429 ,5 ,1.743929 ,1.323674 ,0.1330889 ,0 ,38.64551 ,2.279846 ,0.07383517 ,10.55893 ,51.55812 ,0 ,1 ,0.432 ,0.35 ,1.771429 ,1.34 ,12357.14 ,- ,12536.31
6.5 ,1 ,7.33266353607178,10.1975887298584,59.9999977111816,-0.3346729,2.95017 ,714.2208 ,65.42628 ,0 ,1572.692 ,-148.5711 ,4.893429 ,117.6264 ,-11.11208 ,0 ,0 ,4.893429 ,0 ,0 ,0 ,0 ,0 ,-14.65462 ,2.583215 ,0.1074059 ,11.96396 ,-4.005432E-05,-4.005432E-05,1 ,0.432 ,0.35 ,1.771429 ,1.34 ,2320.086 ,- ,2353.727
7.5 ,1 ,10.4979906082153,11.3951774597168,59.9999977111816,1 ,3.068014,705.4799 ,1005.703 ,944.2035 ,1550.446 ,-148.5274 ,74.29897 ,114.5434 ,-10.97286 ,69.75556 ,-0.3500228 ,4.893429 ,6 ,2.032654 ,1.684928 ,0.1688475 ,0 ,48.93027 ,2.886481 ,0.1498646 ,13.90252 ,65.86913 ,0 ,1 ,0.432 ,0.35 ,1.771429 ,1.34 ,14211.79 ,- ,14417.86
8.5 ,1 ,14.6633176803589,14.9951774597168,59.9999977111816,1 ,3.068014,928.3573 ,1102.886 ,946.8998 ,2117.669 ,-156.0596 ,107.2196 ,205.8742 ,-15.17171 ,92.05508 ,10.27113 ,4.893429 ,6 ,2.789697 ,2.219431 ,0.2229589 ,0 ,64.38847 ,3.798387 ,0.3414999 ,18.29464 ,86.823 ,0 ,1 ,0.432 ,0.35 ,1.771429 ,1.34 ,20212.8 ,- ,20505.89
9.5 ,1 ,19.1540021896362,16.1664642333984,59.9999977111816,-0.3492851,3.068014,928.3573 ,50.33493 ,0 ,2117.669 ,-156.0596 ,4.893429 ,205.8742 ,-15.17171 ,0 ,0 ,4.893429 ,0 ,0 ,0 ,0 ,0 ,-24.24664 ,4.095083 ,0.427938 ,19.72366 ,3.051758E-05 ,0 ,1 ,0.432 ,0.35 ,1.771429 ,1.34 ,3117.583 ,- ,3162.787
10.5 ,1 ,23.9700441360474,17.3377510070801,59.9999977111816,1 ,3.068014,826.9958 ,1225.68 ,1227.125 ,1859.704 ,-150.4848 ,106.1474 ,161.0556 ,-13.0324 ,106.2725 ,-5.018576 ,4.893429 ,7 ,2.926056 ,2.56818 ,0.258632 ,0 ,74.44735 ,4.391778 ,0.5278543 ,21.15267 ,100.5196 ,0 ,1 ,0.432 ,0.35 ,1.771429 ,1.34 ,20227.41 ,- ,20520.71
11.5 ,1 ,29.7860860824585,20.9377510070801,59.9999977111816,1 ,3.068014,998.7128 ,1362.262 ,1230.922 ,2296.724 ,-159.9292 ,142.4721 ,240.2028 ,-16.72619 ,128.7359 ,8.842758 ,4.893429 ,7 ,3.632432 ,3.105886 ,0.313897 ,0 ,89.90556 ,5.303684 ,0.9296637 ,25.54479 ,121.6837 ,0 ,1 ,0.432 ,0.35 ,1.771429 ,1.34 ,26478.39 ,- ,26862.32
\ No newline at end of file
using System;
using System.Diagnostics;
using System.Globalization;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TUGraz.VectoCore.Utils;
......@@ -10,6 +11,7 @@ namespace TUGraz.VectoCore.Tests.Utils
/// <summary>
/// Assert an expected Exception.
/// </summary>
[DebuggerHidden]
public static void Exception<T>(Action func, string message = null) where T : Exception
{
try {
......@@ -23,6 +25,7 @@ namespace TUGraz.VectoCore.Tests.Utils
}
}
[DebuggerHidden]
public static void AreRelativeEqual(SI expected, SI actual)
{
Assert.IsTrue(actual.HasEqualUnit(expected),
......@@ -46,16 +49,10 @@ namespace TUGraz.VectoCore.Tests.Utils
return;
}
if (expected.IsEqual(0.0)) {
Assert.AreEqual(expected, actual, DoubleExtensionMethods.Tolerance,
string.Format("Actual value is different. Difference: {3} Expected: {0}, Actual: {1}, Tolerance: {2}{4}",
expected, actual, toleranceFactor, expected - actual, message));
return;
}
Assert.IsTrue(Math.Abs(actual / expected - 1) < toleranceFactor,
string.Format("Actual value is different. Difference: {3} Expected: {0}, Actual: {1}, Tolerance: {2}{4}",
expected, actual, toleranceFactor, expected - actual, message));
var ratio = expected == 0 ? Math.Abs(actual) : Math.Abs(actual / expected - 1);
Assert.IsTrue(ratio < toleranceFactor, string.Format(CultureInfo.InvariantCulture,
"Given values are not equal. Expected: {0}, Actual: {1}, Difference: {3} (Tolerance: {2}){4}",
expected, actual, toleranceFactor * (expected == 0 ? 1 : expected), expected - actual, message));
}
}
}
\ No newline at end of file
......@@ -36,7 +36,6 @@ namespace TUGraz.VectoCore.Tests.Utils
string.Format("Moddata: Columns differ:\nExpected: {0}\nActual: {1}", string.Join(", ", expectedCols),
string.Join(", ", actualCols)));
//todo initial state
for (var i = 0; i < expected.Rows.Count; i++) {
var expectedRow = expected.Rows[i];
var actualRow = actual.Rows[i];
......@@ -49,21 +48,33 @@ namespace TUGraz.VectoCore.Tests.Utils
}
}
public static void TestSumFile(string expectedFile, string actualFile)
public static void TestSumFile(string expectedFile, string actualFile, string[] testColumns = null)
{
Assert.IsTrue(File.Exists(actualFile), "SUM File is missing: " + actualFile);
var expected = File.ReadAllLines(expectedFile);
var actual = File.ReadAllLines(actualFile);
var expected = VectoCSVFile.Read(expectedFile, fullHeader: true);
var actual = VectoCSVFile.Read(actualFile, fullHeader: true);
Assert.AreEqual(expected.Length, actual.Length,
string.Format("SUM File row count differs.\nExpected {0} Rows in {1}\nGot {2} Rows in {3}", expected.Length,
expectedFile, actual.Length, actualFile));
Assert.AreEqual(expected.Rows.Count, actual.Rows.Count,
string.Format("SUM File row count differs.\nExpected {0} Rows in {1}\nGot {2} Rows in {3}", expected.Rows.Count,
expectedFile, actual.Rows.Count, actualFile));
Assert.AreEqual(expected.First(), actual.First(),
string.Format("SUM File Header differs:\nExpected: '{0}'\nActual : '{1}'", expected.First(), actual.First()));
var actualCols = actual.Columns.Cast<DataColumn>().Select(x => x.ColumnName).OrderBy(x => x).ToList();
var expectedCols = expected.Columns.Cast<DataColumn>().Select(x => x.ColumnName).OrderBy(x => x).ToList();
// todo: test contents of sum file
Assert.IsTrue(expectedCols.SequenceEqual(actualCols),
string.Format("Moddata: Columns differ:\nExpected: {0}\nActual: {1}", string.Join(", ", expectedCols),
string.Join(", ", actualCols)));
for (var i = 0; i < expected.Rows.Count; i++) {
var expectedRow = expected.Rows[i];
var actualRow = actual.Rows[i];
foreach (var field in testColumns ?? new string[0]) {
AssertHelper.AreRelativeEqual(expectedRow.ParseDoubleOrGetDefault(field), actualRow.ParseDoubleOrGetDefault(field),
string.Format("t: {0} field: {1}", i, field));
}
}
}
}
}
\ No newline at end of file
......@@ -192,6 +192,9 @@
<None Include="TestData\Cycles\Coach_24t_xshort.vdri">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestData\Cycles\LongHaul_short.vdri">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestData\Cycles\LOT2_rural Engine Only.vmod">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
......@@ -306,10 +309,10 @@
<None Include="TestData\Jobs\EngineOnlyJob.vecto">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestData\Results\Auxiliaries.vmod">
<None Include="TestData\Results\EngineOnlyCycles\40t_Long_Haul_Truck.vsum">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestData\Results\Auxiliaries.vsum">
<None Include="TestData\Results\EngineOnlyCycles\40t_Long_Haul_Truck_Long_Haul_Empty Loading.vmod">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestData\Results\EngineFullLoadJumps\EngineFLJ_1000rpm_10Hz.csv">
......
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