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 ee2bb22c authored by Stefanos Doumpoulakis's avatar Stefanos Doumpoulakis
Browse files

a)bugfix in reading NCVs, b)added check: fuel types match cycle data

parent 18266577
Branches
Tags
No related merge requests found
...@@ -908,13 +908,16 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON ...@@ -908,13 +908,16 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
fuelNCVs.Add(new FuelNCVData() { Type = matches.First(), NCV = (ncv * Constants.Mega).SI<JoulePerKilogramm>() }); fuelNCVs.Add(new FuelNCVData() { Type = matches.First(), NCV = (ncv * Constants.Mega).SI<JoulePerKilogramm>() });
} }
var fuels = JobInputData.Vehicle.Components.EngineInputData.EngineModes.First().Fuels; var fuelsPerMode = JobInputData.Vehicle.Components.EngineInputData.EngineModes.Select(
x => x.Fuels.Select(f => DeclarationData.FuelData.Lookup(f.FuelType, JobInputData.Vehicle.TankSystem)));
foreach (var fuels in fuelsPerMode) {
foreach (var fuel in fuels) { foreach (var fuel in fuels) {
if (fuelNCVs.Count(x => x.Type == fuel.FuelType) == 0) { if (fuelNCVs.Count(x => x.Type == fuel.FuelType) == 0) {
throw new Exception($"Job input data: {JsonKeys.Job_FuelNCVs}: missing {JsonKeys.Job_FuelNCV_Type}: {fuel.FuelType.GetLabel()}"); throw new Exception($"Job input data: {JsonKeys.Job_FuelNCVs}: missing {JsonKeys.Job_FuelNCV_Type}: {fuel.FuelType.GetLabel()}");
} }
} }
}
return fuelNCVs; return fuelNCVs;
} }
......
...@@ -42,6 +42,7 @@ using TUGraz.VectoCore.InputData.Reader.ComponentData; ...@@ -42,6 +42,7 @@ using TUGraz.VectoCore.InputData.Reader.ComponentData;
using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter; using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter;
using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Models.Declaration;
using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.Simulation.Data;
using TUGraz.VectoCore.Models.SimulationComponent;
using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.OutputData; using TUGraz.VectoCore.OutputData;
...@@ -208,8 +209,8 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl ...@@ -208,8 +209,8 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl
throw new VectoException("no VTP-Cycle provided!"); throw new VectoException("no VTP-Cycle provided!");
} }
var drivingCycle = DrivingCycleDataReader.ReadFromDataTable(vtpCycle.CycleData, vtpCycle.Name, false); var drivingCycle = DrivingCycleDataReader.ReadFromDataTable(vtpCycle.CycleData, vtpCycle.Name, false);
ValidateFanTypeMatchesCycleData(drivingCycle);
ValidateFanTypeMatchesInputData(drivingCycle); ValidateFuelTypesMatchCycleData(drivingCycle);
// Loading is not relevant as we use P_wheel // Loading is not relevant as we use P_wheel
var vtpRunData = CreateVectoRunData(Segment, Segment.Missions.First(), 0.SI<Kilogram>()); var vtpRunData = CreateVectoRunData(Segment, Segment.Missions.First(), 0.SI<Kilogram>());
...@@ -243,14 +244,30 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl ...@@ -243,14 +244,30 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl
yield return vtpRunData; yield return vtpRunData;
} }
protected void ValidateFanTypeMatchesInputData(DrivingCycleData cycle) protected void ValidateFuelTypesMatchCycleData(DrivingCycleData drivingCycle)
{
var fuelsPerMode = JobInputData.Vehicle.Components.EngineInputData.EngineModes.Select(
x => x.Fuels.Select(f => DeclarationData.FuelData.Lookup(f.FuelType, JobInputData.Vehicle.TankSystem)));
foreach (var fuels in fuelsPerMode) {
foreach (var fuel in fuels) {
if ((drivingCycle.Entries.First().Fuelconsumption != null)
&& !drivingCycle.Entries.First().Fuelconsumption.ContainsKey(fuel.FuelType)) {
throw new VectoException($"Cycle {drivingCycle.Name} is missing {fuel.FuelType} input data.");
}
}
}
}
protected void ValidateFanTypeMatchesCycleData(DrivingCycleData drivingCycle)
{ {
var fan = JobInputData.Vehicle.Components.AuxiliaryInputData.Auxiliaries.First(x => x.Type == AuxiliaryType.Fan); var fan = JobInputData.Vehicle.Components.AuxiliaryInputData.Auxiliaries.First(x => x.Type == AuxiliaryType.Fan);
var fanFullyElectric = DeclarationData.Fan.FullyElectricTechnologies().Contains(fan.Technology.First()); var fanFullyElectric = DeclarationData.Fan.FullyElectricTechnologies().Contains(fan.Technology.First());
var cycleHasFanElectricalPower = cycle.Entries.First().FanElectricalPower != null; var cycleHasFanElectricalPower = drivingCycle.Entries.First().FanElectricalPower != null;
if (fanFullyElectric ^ cycleHasFanElectricalPower) { if (fanFullyElectric ^ cycleHasFanElectricalPower) {
throw new VectoException($"Fan is{(fanFullyElectric ? "" : " not")} electric, while cycle has{(cycleHasFanElectricalPower ? "" : " no")} input for fan electrical power"); throw new VectoException($"Fan is{(fanFullyElectric ? "" : " not")} electric, while cycle has{(cycleHasFanElectricalPower ? "" : " no")} input for fan electrical power.");
} }
} }
......
...@@ -61,7 +61,9 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl ...@@ -61,7 +61,9 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl
return JobInputData.Cycles.Select( return JobInputData.Cycles.Select(
cycle => { cycle => {
var drivingCycle = DrivingCycleDataReader.ReadFromDataTable(cycle.CycleData, cycle.Name, false); var drivingCycle = DrivingCycleDataReader.ReadFromDataTable(cycle.CycleData, cycle.Name, false);
ValidateFanTypeMatchesInputData(drivingCycle); ValidateFanTypeMatchesCycleData(drivingCycle);
ValidateFuelTypesMatchCycleData(drivingCycle);
// loading is not relevant as we use P_wheel // loading is not relevant as we use P_wheel
var runData = CreateVectoRunData(Segment, Segment.Missions.First(), 0.SI<Kilogram>()); var runData = CreateVectoRunData(Segment, Segment.Missions.First(), 0.SI<Kilogram>());
runData.Cycle = new DrivingCycleProxy(drivingCycle, cycle.Name); runData.Cycle = new DrivingCycleProxy(drivingCycle, cycle.Name);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment