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 6d93f68a authored by Harald Martini's avatar Harald Martini
Browse files

implemented vehicle operation lookup tables

parent b66c17b0
Branches
Tags
No related merge requests found
Showing
with 272 additions and 28 deletions
......@@ -45,6 +45,7 @@ using TUGraz.VectoCore.InputData.FileIO.JSON;
using TUGraz.VectoCore.InputData.Reader.ComponentData;
using TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electrics;
using TUGraz.VectoCore.Models.Declaration.Auxiliaries;
using TUGraz.VectoCore.Models.Declaration.VehicleOperation;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.Models.SimulationComponent.Data.ElectricMotor;
using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine;
......@@ -96,6 +97,8 @@ namespace TUGraz.VectoCore.Models.Declaration
public static readonly HEVStrategyParameters HEVStrategyParameters = new HEVStrategyParametersLorry();
//public static readonly HEVStrategyParameters InitEquivalenceFactorsBus = new HEVStrategyParametersBus();
public static readonly VehicleOperationLookup VehicleOperation = new VehicleOperationLookup();
public static readonly double ElectricMachineDefaultMechanicalTransmissionEfficiency = 1;
//public static MeterPerSecond CycleSpeedLimit;
public const double LossMapExtrapolationFactor = 6;
......
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.Declaration.VehicleOperation
{
public class MileageLookup : LookupData<string, MissionType, MileageLookup.MileageEntry>
{
#region Overrides of LookupData
protected override string ResourceId => "TUGraz.VectoCore.Resources.Declaration.VehicleOperation.AnnualMileage.csv";
protected override string ErrorMessage => "Error looking up mileage";
protected override void ParseData(DataTable table)
{
foreach (DataRow tableRow in table.Rows) {
var group = tableRow.Field<string>("vehiclegroup");
var workingDays = tableRow.ParseDouble("workingdaysperyear");
foreach (DataColumn col in table.Columns.Cast<DataColumn>().Skip(table.Columns.IndexOf("workingdaysperyear") + 1)) {
MissionType mission = col.Caption.ParseEnum<MissionType>();
if (tableRow.Field<string>(col) == "---") {
continue;
}
var annualMileage = tableRow.ParseDouble(col).SI(Unit.SI.Kilo.Meter).Cast<Meter>();
Data.Add(Tuple.Create<string, MissionType>(group, mission),
new MileageEntry() {
annualMileage = annualMileage,
workingDaysPerYear = workingDays,
dailyMileage = annualMileage / workingDays,
});
}
}
}
#endregion
public struct MileageEntry
{
public Meter annualMileage;
public double workingDaysPerYear;
public Meter dailyMileage;
}
}
}
using System;
using System.Data;
using System.Linq;
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.Declaration.VehicleOperation
{
public abstract class StationaryChargingLookup : LookupData<string, MissionType, double>
{
protected override void ParseData(DataTable table)
{
foreach (DataRow tableRow in table.Rows) {
var group = tableRow.Field<string>("vehiclegroup");
foreach (DataColumn col in table.Columns.Cast<DataColumn>().Skip(table.Columns.IndexOf("longhaul"))) {
MissionType mission = col.Caption.ParseEnum<MissionType>();
if (tableRow.Field<string>(col) == "---") {
continue;
}
double val = tableRow.ParseDouble(col);
Data.Add(Tuple.Create<string, MissionType>(group, mission), val);
}
}
}
public double Lookup(VehicleClass hdvClass, MissionType mission)
{
return Lookup(hdvClass.GetClassNumber(), mission);
}
}
public class StationaryChargingDurationPerEventLookup : StationaryChargingLookup
{
#region Overrides of LookupData
protected override string ResourceId =>
"TUGraz.VectoCore.Resources.Declaration.VehicleOperation.StationaryChargingDuration.csv";
protected override string ErrorMessage => "Error looking up stationary charging duration per event";
#endregion
}
public class StationaryChargingFromInfrastructureLookup : StationaryChargingLookup
{
#region Overrides of LookupData
protected override string ResourceId =>
"TUGraz.VectoCore.Resources.Declaration.VehicleOperation.StationaryChargingPower.csv";
protected override string ErrorMessage => "Error looking up stationary charging power from infrastructure";
#endregion
}
public class StationaryChargingEventsPerDayLookup : StationaryChargingLookup
{
#region Overrides of LookupData
protected override string ResourceId =>
"TUGraz.VectoCore.Resources.Declaration.VehicleOperation.ChargingEventDuringMission.csv";
protected override string ErrorMessage => "Error looking up Number of charging events during mission";
#endregion
}
}
\ No newline at end of file
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Utils;
namespace TUGraz.VectoCore.Models.Declaration.VehicleOperation
{
public class VehicleOperationLookup
{
private MileageLookup _mileageLookup = new MileageLookup();
private StationaryChargingDurationPerEventLookup _chargingDurationLookup =
new StationaryChargingDurationPerEventLookup();
private StationaryChargingFromInfrastructureLookup _chargingFromInfrastructureLookup =
new StationaryChargingFromInfrastructureLookup();
private StationaryChargingEventsPerDayLookup _numberOfChargingEventsLookup =
new StationaryChargingEventsPerDayLookup();
public MileageLookup.MileageEntry LookupMileage(VehicleClass hdvClass, MissionType mission)
{
return _mileageLookup.Lookup(hdvClass.GetClassNumber(), mission);
}
public Second LookupChargingDurationPerEvent(VehicleClass hdvClass, MissionType mission)
{
return _chargingDurationLookup.Lookup(hdvClass, mission).SI(Unit.SI.Hour).Cast<Second>();
}
public Watt LookupMaxChargingPower(VehicleClass hdvClass, MissionType mission)
{
return _chargingFromInfrastructureLookup.Lookup(hdvClass, mission).SI(Unit.SI.Kilo.Watt).Cast<Watt>();
}
public double LookupChargingEventsPerDay(VehicleClass hdvClass, MissionType mission)
{
return _numberOfChargingEventsLookup.Lookup(hdvClass, mission);
}
}
}
\ No newline at end of file
Vehicle Group ,WorkingDaysPerYear ,Long haul ,Regional delivery ,Urban delivery ,Municipal delivery ,Con-struction ,Heavy Urban ,Urban ,Suburban ,Interurban ,Coach
Vehicle Group ,WorkingDaysPerYear ,Long haul ,Regional delivery ,Urban delivery ,Municipal utility ,Construction ,Heavy Urban ,Urban ,Suburban ,Interurban ,Coach
53 , 250 ,--- ,80000 ,60000 ,--- ,--- ,--- ,--- ,--- ,--- ,---
54 , 250 ,--- ,80000 ,60000 ,--- ,--- ,--- ,--- ,--- ,--- ,---
1s , 250 ,--- ,80000 ,60000 ,--- ,--- ,--- ,--- ,--- ,--- ,---
......
Vehicle Group ,Long haul ,Regional delivery ,Urban delivery ,Municipal delivery ,Con-struction ,Heavy Urban ,Urban ,Suburban ,Interurban ,Coach
Vehicle Group ,Long haul ,Regional delivery ,Urban delivery ,Municipal utility ,Construction ,Heavy Urban ,Urban ,Suburban ,Interurban ,Coach
53 ,--- ,2 ,4 ,--- ,--- ,--- ,--- ,--- ,--- ,---
54 ,--- ,2 ,4 ,--- ,--- ,--- ,--- ,--- ,--- ,---
1s ,--- ,2 ,4 ,--- ,--- ,--- ,--- ,--- ,--- ,---
......
Vehicle Group ,Long haul ,Regional delivery ,Urban delivery ,Municipal delivery ,Con-struction ,Heavy Urban ,Urban ,Suburban ,Interurban ,Coach
Vehicle Group ,Long haul ,Regional delivery ,Urban delivery ,Municipal utility ,Construction ,Heavy Urban ,Urban ,Suburban ,Interurban ,Coach
53 ,--- ,0.50 ,0.50 ,--- ,--- ,--- ,--- ,--- ,--- ,---
54 ,--- ,0.50 ,0.50 ,--- ,--- ,--- ,--- ,--- ,--- ,---
1s ,--- ,0.50 ,0.50 ,--- ,--- ,--- ,--- ,--- ,--- ,---
......
Vehicle Group ,Long haul ,Regional delivery ,Urban delivery ,Municipal delivery ,Con-struction ,Heavy Urban ,Urban ,Suburban ,Interurban ,Coach
Vehicle Group ,Long haul ,Regional delivery ,Urban delivery ,Municipal utility ,Construction ,Heavy Urban ,Urban ,Suburban ,Interurban ,Coach
53 ,--- ,250 ,250 ,--- ,--- ,--- ,--- ,--- ,--- ,---
54 ,--- ,250 ,250 ,--- ,--- ,--- ,--- ,--- ,--- ,---
1s ,--- ,250 ,250 ,--- ,--- ,--- ,--- ,--- ,--- ,---
......
......@@ -2392,5 +2392,70 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration
//Assert.IsTrue(expectedClass.Equals(tyreClass, StringComparison.InvariantCultureIgnoreCase));
Assert.AreEqual(expectedClass, tyreClass);
}
[TestCase(VehicleClass.Class1s, MissionType.RegionalDelivery, 2)]
[TestCase(VehicleClass.Class1, MissionType.RegionalDelivery, 2)]
[TestCase(VehicleClass.Class16, MissionType.Construction, 2)]
[TestCase(VehicleClass.Class53, MissionType.UrbanDelivery, 4)]
public void VehicleOperationLookupChargingEventsLorry(VehicleClass hdvClass, MissionType mission, double expected)
{
var val = DeclarationData.VehicleOperation.LookupChargingEventsPerDay(hdvClass, mission);
Assert.AreEqual(expected, val);
}
[TestCase(VehicleClass.Class1s, MissionType.RegionalDelivery, 0.5)]
[TestCase(VehicleClass.Class1, MissionType.RegionalDelivery, 0.5)]
[TestCase(VehicleClass.Class16, MissionType.Construction, 0.5)]
[TestCase(VehicleClass.Class53, MissionType.UrbanDelivery, 0.5)]
public void VehicleOperationLookupChargingDurationLorry(VehicleClass hdvClass, MissionType mission, double expected)
{
var val = DeclarationData.VehicleOperation.LookupChargingDurationPerEvent(hdvClass, mission);
Assert.AreEqual(expected * 3600, val.Value()); //stored in seconds
}
[TestCase(VehicleClass.Class1s, MissionType.RegionalDelivery, 250)]
[TestCase(VehicleClass.Class1, MissionType.RegionalDelivery, 250)]
[TestCase(VehicleClass.Class16, MissionType.Construction, 100)]
[TestCase(VehicleClass.Class53, MissionType.UrbanDelivery, 250)]
public void VehicleOperationLookupMaxChargingPowerLorry(VehicleClass hdvClass, MissionType mission, double expected)
{
var val = DeclarationData.VehicleOperation.LookupMaxChargingPower(hdvClass, mission);
Assert.AreEqual(expected * 1000, val.Value()); //stored in watt
}
[TestCase(VehicleClass.Class1s, MissionType.RegionalDelivery, 80000, 320)]
[TestCase(VehicleClass.Class1, MissionType.RegionalDelivery, 80000, 320)]
[TestCase(VehicleClass.Class16, MissionType.Construction, 60000, 240)]
[TestCase(VehicleClass.Class53, MissionType.UrbanDelivery, 60000, 240)]
public void VehicleOperationLookupMileageLorry(VehicleClass hdvClass, MissionType mission, double expectedAnnual, double expectedDaily)
{
var val = DeclarationData.VehicleOperation.LookupMileage(hdvClass, mission);
Assert.AreEqual(expectedAnnual * 1000, val.annualMileage.Value()); //stored in meter
Assert.AreEqual(expectedDaily * 1000, val.dailyMileage.Value()); //stored in meter
}
[TestCase(VehicleClass.Class53, MissionType.LongHaul)]
[TestCase(VehicleClass.Class16, MissionType.UrbanDelivery)]
[TestCase(VehicleClass.Class1s, MissionType.Coach)]
public void VehicleOperationHeavyLorryFail(VehicleClass hdvClass, MissionType mission)
{
Assert.Throws<VectoException>(() => {
DeclarationData.VehicleOperation.LookupChargingDurationPerEvent(hdvClass, mission);
});
Assert.Throws<VectoException>(() => {
DeclarationData.VehicleOperation.LookupChargingEventsPerDay(hdvClass, mission);
});
Assert.Throws<VectoException>(() => {
DeclarationData.VehicleOperation.LookupMaxChargingPower(hdvClass, mission);
});
Assert.Throws<VectoException>(() => {
DeclarationData.VehicleOperation.LookupMileage(hdvClass, mission);
});
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment