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

a)fixed engine work deviation warning, b)did refactoring

parent 506b7dbf
Branches
Tags
No related merge requests found
...@@ -49,6 +49,8 @@ Public Class VectoVTPJobForm ...@@ -49,6 +49,8 @@ Public Class VectoVTPJobForm
Dim _vectoJob As IVTPEngineeringJobInputData Dim _vectoJob As IVTPEngineeringJobInputData
Private Const Mega As Integer = 1000000
Enum AuxViewColumns Enum AuxViewColumns
AuxID = 0 AuxID = 0
AuxType = 1 AuxType = 1
...@@ -370,7 +372,7 @@ Public Class VectoVTPJobForm ...@@ -370,7 +372,7 @@ Public Class VectoVTPJobForm
End If End If
Next Next
vectoJob.FuelNCVs.Add(New FuelNCVData With {.Type = ftype, .NCV = (ncv * 1000000).SI(Of JoulePerKilogramm)}) vectoJob.FuelNCVs.Add(New FuelNCVData With {.Type = ftype, .NCV = (ncv * Mega).SI(Of JoulePerKilogramm)})
End Sub End Sub
'New file 'New file
...@@ -465,14 +467,14 @@ Public Class VectoVTPJobForm ...@@ -465,14 +467,14 @@ Public Class VectoVTPJobForm
_ncvFuel1Lbl.Text = entry.FuelType.GetLabel() _ncvFuel1Lbl.Text = entry.FuelType.GetLabel()
_ncvFuel1Lbl.Visible = True _ncvFuel1Lbl.Visible = True
_ncvFuel1Txtbox.Text = (fueldata.LowerHeatingValueVecto.Value / 1000000).ToString() _ncvFuel1Txtbox.Text = (fueldata.LowerHeatingValueVecto.Value / Mega).ToString()
_ncvFuel1Txtbox.Visible = True _ncvFuel1Txtbox.Visible = True
_ncvFuel1UnitLbl.Visible = True _ncvFuel1UnitLbl.Visible = True
ElseIf (Not _ncvFuel2Lbl.Visible) Then ElseIf (Not _ncvFuel2Lbl.Visible) Then
_ncvFuel2Lbl.Text = entry.FuelType.GetLabel() _ncvFuel2Lbl.Text = entry.FuelType.GetLabel()
_ncvFuel2Lbl.Visible = True _ncvFuel2Lbl.Visible = True
_ncvFuel2Txtbox.Text = (fueldata.LowerHeatingValueVecto.Value / 1000000).ToString() _ncvFuel2Txtbox.Text = (fueldata.LowerHeatingValueVecto.Value / Mega).ToString()
_ncvFuel2Txtbox.Visible = True _ncvFuel2Txtbox.Visible = True
_ncvFuel2UnitLbl.Visible = True _ncvFuel2UnitLbl.Visible = True
End If End If
......
...@@ -42,6 +42,8 @@ namespace TUGraz.VectoCore.Configuration ...@@ -42,6 +42,8 @@ namespace TUGraz.VectoCore.Configuration
public const double RPMToRad = 2 * Math.PI / 60; public const double RPMToRad = 2 * Math.PI / 60;
public const double Kilo = 1000; public const double Kilo = 1000;
public const double MeterPerSecondToKMH = 3.6; public const double MeterPerSecondToKMH = 3.6;
public const int GramsToMilligrams = 1000;
public const int Mega = 1000000;
public static class Auxiliaries public static class Auxiliaries
{ {
...@@ -325,6 +327,12 @@ namespace TUGraz.VectoCore.Configuration ...@@ -325,6 +327,12 @@ namespace TUGraz.VectoCore.Configuration
public static readonly MeterPerSecond HighwaySpeedThreshold = 70.KMPHtoMeterPerSecond(); public static readonly MeterPerSecond HighwaySpeedThreshold = 70.KMPHtoMeterPerSecond();
public static readonly MeterPerSecond RuralSpeedThreshold = 50.KMPHtoMeterPerSecond(); public static readonly MeterPerSecond RuralSpeedThreshold = 50.KMPHtoMeterPerSecond();
/// <summary>
/// When the simulated (in VTP) positive engine work deviates more than this threshold
/// from the measured positive energy of the vdri, a warning is issued.
/// </summary>
public const double VTPEngineWorkDeviationThreshold = 0.005;
} }
public static class XML public static class XML
......
...@@ -905,7 +905,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON ...@@ -905,7 +905,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
throw new Exception($"Job input data: {JsonKeys.Job_FuelNCVs}: invalid {JsonKeys.Job_FuelNCV_Type}: {type}"); throw new Exception($"Job input data: {JsonKeys.Job_FuelNCVs}: invalid {JsonKeys.Job_FuelNCV_Type}: {type}");
} }
fuelNCVs.Add(new FuelNCVData() { Type = matches.First(), NCV = (ncv * 1000000).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 fuels = JobInputData.Vehicle.Components.EngineInputData.EngineModes.First().Fuels;
......
...@@ -824,8 +824,6 @@ namespace TUGraz.VectoCore.InputData.Reader ...@@ -824,8 +824,6 @@ namespace TUGraz.VectoCore.InputData.Reader
{ {
ValidateHeader(table.Columns); ValidateHeader(table.Columns);
const uint GRAMS_PER_KILO = 1000;
var fuels = table.Columns.Cast<DataColumn>().Where(x => x.ColumnName.StartsWith("fc_")) var fuels = table.Columns.Cast<DataColumn>().Where(x => x.ColumnName.StartsWith("fc_"))
.Select(x => x.ColumnName.Replace("fc_", "").ParseEnum<FuelType>()).ToArray(); .Select(x => x.ColumnName.Replace("fc_", "").ParseEnum<FuelType>()).ToArray();
var entries = table.Rows.Cast<DataRow>().Select( var entries = table.Rows.Cast<DataRow>().Select(
...@@ -852,7 +850,6 @@ namespace TUGraz.VectoCore.InputData.Reader ...@@ -852,7 +850,6 @@ namespace TUGraz.VectoCore.InputData.Reader
: null, : null,
Gear = (uint)row.ParseDoubleOrGetDefault(Fields.Gear), Gear = (uint)row.ParseDoubleOrGetDefault(Fields.Gear),
VTPFuelconsumption = fc, VTPFuelconsumption = fc,
VTPPSCompressorActive = row.ParseBooleanOrGetDefault(Fields.VTPPSCompressorActive) ?? false,
TorqueConverterActive = row.ParseBooleanOrGetDefault(Fields.TorqueConverterActive), TorqueConverterActive = row.ParseBooleanOrGetDefault(Fields.TorqueConverterActive),
TorqueWheelLeft = tqLeft, TorqueWheelLeft = tqLeft,
TorqueWheelRight = tqRight, TorqueWheelRight = tqRight,
...@@ -863,15 +860,15 @@ namespace TUGraz.VectoCore.InputData.Reader ...@@ -863,15 +860,15 @@ namespace TUGraz.VectoCore.InputData.Reader
: null, : null,
CombustionEngineTorque = row.ParseDouble(Fields.CombustionEngineTorque).SI<NewtonMeter>(), CombustionEngineTorque = row.ParseDouble(Fields.CombustionEngineTorque).SI<NewtonMeter>(),
CH4MassFlow = table.Columns.Contains(Fields.CH4MassFlow) CH4MassFlow = table.Columns.Contains(Fields.CH4MassFlow)
? (row.ParseDouble(Fields.CH4MassFlow) / GRAMS_PER_KILO).SI<KilogramPerSecond>() ? (row.ParseDouble(Fields.CH4MassFlow) / Constants.Kilo).SI<KilogramPerSecond>()
: null, : null,
COMassFlow = (row.ParseDouble(Fields.COMassFlow) / GRAMS_PER_KILO).SI<KilogramPerSecond>(), COMassFlow = (row.ParseDouble(Fields.COMassFlow) / Constants.Kilo).SI<KilogramPerSecond>(),
NMHCMassFlow = table.Columns.Contains(Fields.NMHCMassFlow) NMHCMassFlow = table.Columns.Contains(Fields.NMHCMassFlow)
? (row.ParseDouble(Fields.NMHCMassFlow) / GRAMS_PER_KILO).SI<KilogramPerSecond>() ? (row.ParseDouble(Fields.NMHCMassFlow) / Constants.Kilo).SI<KilogramPerSecond>()
: null, : null,
NOxMassFlow = (row.ParseDouble(Fields.NOxMassFlow) / GRAMS_PER_KILO).SI<KilogramPerSecond>(), NOxMassFlow = (row.ParseDouble(Fields.NOxMassFlow) / Constants.Kilo).SI<KilogramPerSecond>(),
THCMassFlow = (row.ParseDouble(Fields.THCMassFlow) / GRAMS_PER_KILO).SI<KilogramPerSecond>(), THCMassFlow = (row.ParseDouble(Fields.THCMassFlow) / Constants.Kilo).SI<KilogramPerSecond>(),
CO2MassFlow = (row.ParseDouble(Fields.CO2MassFlow) / GRAMS_PER_KILO).SI<KilogramPerSecond>(), CO2MassFlow = (row.ParseDouble(Fields.CO2MassFlow) / Constants.Kilo).SI<KilogramPerSecond>(),
PMNumberFlow = row.ParseDouble(Fields.PMNumberFlow).SI<PerSecond>() PMNumberFlow = row.ParseDouble(Fields.PMNumberFlow).SI<PerSecond>()
}; };
}).ToArray(); }).ToArray();
......
...@@ -287,8 +287,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data ...@@ -287,8 +287,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
public PerSecond WheelSpeedRight; public PerSecond WheelSpeedRight;
public bool VTPPSCompressorActive;
// road sweeper application // road sweeper application
public Watt PTOPowerDemandDuringDrive; public Watt PTOPowerDemandDuringDrive;
} }
......
...@@ -62,8 +62,6 @@ namespace TUGraz.VectoCore.OutputData.XML ...@@ -62,8 +62,6 @@ namespace TUGraz.VectoCore.OutputData.XML
{ {
public const string CURRENT_SCHEMA_VERSION = "0.1"; public const string CURRENT_SCHEMA_VERSION = "0.1";
private const double ENERGY_THRESHOLD_RANGE = 0.005;
private const string VTPReportTartetName = "VTPReportTarget"; private const string VTPReportTartetName = "VTPReportTarget";
protected XElement VehiclePart; protected XElement VehiclePart;
...@@ -91,7 +89,6 @@ namespace TUGraz.VectoCore.OutputData.XML ...@@ -91,7 +89,6 @@ namespace TUGraz.VectoCore.OutputData.XML
public WattSecond VTPWorPWheelSimPos; public WattSecond VTPWorPWheelSimPos;
public TankSystem? TankSystem; public TankSystem? TankSystem;
private const int MILLIGRAMS_PER_GRAM = 1000;
public Scalar CH4Emissions { protected set; get; } = null; public Scalar CH4Emissions { protected set; get; } = null;
public Scalar COEmissions { protected set; get; } = null; public Scalar COEmissions { protected set; get; } = null;
public Scalar NMHCEmissions { protected set; get; } = null; public Scalar NMHCEmissions { protected set; get; } = null;
...@@ -99,7 +96,7 @@ namespace TUGraz.VectoCore.OutputData.XML ...@@ -99,7 +96,7 @@ namespace TUGraz.VectoCore.OutputData.XML
public Scalar THCEmissions { protected set; get; } = null; public Scalar THCEmissions { protected set; get; } = null;
public Scalar CO2Emissions { protected set; get; } = null; public Scalar CO2Emissions { protected set; get; } = null;
public Scalar PMFlow { protected set; get; } = null; public Scalar PMFlow { protected set; get; } = null;
public Scalar ICEEnergyRatio { protected set; get; } = null; public Scalar PositiveEngineWorkDeviation { protected set; get; } = null;
#region Overrides of ResultEntry #region Overrides of ResultEntry
...@@ -136,42 +133,56 @@ namespace TUGraz.VectoCore.OutputData.XML ...@@ -136,42 +133,56 @@ namespace TUGraz.VectoCore.OutputData.XML
//VTPFcFinalSimulated = data.TimeIntegral<Kilogram>(ModalResultField.FCFinal); //VTPFcFinalSimulated = data.TimeIntegral<Kilogram>(ModalResultField.FCFinal);
VTPFcCorrectionFactors = runData.VTPData.CorrectionFactors; VTPFcCorrectionFactors = runData.VTPData.CorrectionFactors;
CalculateEmissions(runData, data); var measuredPositiveEngineWork = CalculateMeasuredPositiveEngineWork(runData);
CalculateEmissions(runData, measuredPositiveEngineWork);
CalculatePositiveEngineWorkDeviation(data, measuredPositiveEngineWork);
} }
private void CalculateEmissions(VectoRunData runData, IModalDataContainer data) private ConvertedSI CalculateMeasuredPositiveEngineWork(VectoRunData runData)
{ {
var energy = runData.Cycle.Entries.Pairwise() return runData.Cycle.Entries.Pairwise()
.Where(x => x.Item1.CombustionEngineTorque.IsGreaterOrEqual(0)) .Where(x => x.Item1.CombustionEngineTorque.IsGreaterOrEqual(0))
.Sum(x => (x.Item1.EngineSpeed * x.Item1.CombustionEngineTorque) * (x.Item2.Time - x.Item1.Time)).ConvertToKiloWattHour(); .Sum(x => (x.Item1.EngineSpeed * x.Item1.CombustionEngineTorque) * (x.Item2.Time - x.Item1.Time))
.ConvertToKiloWattHour();
}
if (runData.Cycle.Entries.First().CH4MassFlow != null) { private void CalculatePositiveEngineWorkDeviation(IModalDataContainer data, ConvertedSI measuredWork)
var CH4 = runData.Cycle.Entries.Pairwise().Sum(x => (x.Item1.CH4MassFlow) * (x.Item2.Time - x.Item1.Time)).ConvertToGramm(); {
CH4Emissions = ((CH4 / energy) * MILLIGRAMS_PER_GRAM).SI<Scalar>(); var simulatedWork = data.TotalEngineWorkPositive().ConvertToKiloWattHour();
PositiveEngineWorkDeviation = ((measuredWork - simulatedWork) / measuredWork).SI<Scalar>();
} }
var CO = runData.Cycle.Entries.Pairwise().Sum(x => x.Item1.COMassFlow * (x.Item2.Time - x.Item1.Time)).ConvertToGramm(); private void CalculateEmissions(VectoRunData runData, ConvertedSI measuredPositiveEngineWork)
COEmissions = ((CO / energy) * MILLIGRAMS_PER_GRAM).SI<Scalar>(); {
var entries = runData.Cycle.Entries;
if (runData.Cycle.Entries.First().NMHCMassFlow != null) { if (runData.Cycle.Entries.First().CH4MassFlow != null) {
var NMHC = runData.Cycle.Entries.Pairwise().Sum(x => x.Item1.NMHCMassFlow * (x.Item2.Time - x.Item1.Time)).ConvertToGramm(); var CH4 = entries.Pairwise().Sum(x => (x.Item1.CH4MassFlow) * (x.Item2.Time - x.Item1.Time)).ConvertToGramm();
NMHCEmissions = ((NMHC / energy) * MILLIGRAMS_PER_GRAM).SI<Scalar>(); CH4Emissions = ((CH4 / measuredPositiveEngineWork) * Constants.GramsToMilligrams).SI<Scalar>();
} }
var NOx = runData.Cycle.Entries.Pairwise().Sum(x => x.Item1.NOxMassFlow * (x.Item2.Time - x.Item1.Time)).ConvertToGramm(); var CO = entries.Pairwise().Sum(x => x.Item1.COMassFlow * (x.Item2.Time - x.Item1.Time)).ConvertToGramm();
NOxEmissions = ((NOx / energy) * MILLIGRAMS_PER_GRAM).SI<Scalar>(); COEmissions = ((CO / measuredPositiveEngineWork) * Constants.GramsToMilligrams).SI<Scalar>();
var THC = runData.Cycle.Entries.Pairwise().Sum(x => x.Item1.THCMassFlow * (x.Item2.Time - x.Item1.Time)).ConvertToGramm(); if (entries.First().NMHCMassFlow != null) {
THCEmissions = ((THC / energy) * MILLIGRAMS_PER_GRAM).SI<Scalar>(); var NMHC = entries.Pairwise().Sum(x => x.Item1.NMHCMassFlow * (x.Item2.Time - x.Item1.Time)).ConvertToGramm();
NMHCEmissions = ((NMHC / measuredPositiveEngineWork) * Constants.GramsToMilligrams).SI<Scalar>();
}
var NOx = entries.Pairwise().Sum(x => x.Item1.NOxMassFlow * (x.Item2.Time - x.Item1.Time)).ConvertToGramm();
NOxEmissions = ((NOx / measuredPositiveEngineWork) * Constants.GramsToMilligrams).SI<Scalar>();
var CO2 = runData.Cycle.Entries.Pairwise().Sum(x => x.Item1.CO2MassFlow * (x.Item2.Time - x.Item1.Time)).ConvertToGramm(); if (entries.First().THCMassFlow != null) {
CO2Emissions = ((CO2 / energy) * MILLIGRAMS_PER_GRAM).SI<Scalar>(); var THC = entries.Pairwise().Sum(x => x.Item1.THCMassFlow * (x.Item2.Time - x.Item1.Time)).ConvertToGramm();
THCEmissions = ((THC / measuredPositiveEngineWork) * Constants.GramsToMilligrams).SI<Scalar>();
}
var PN = runData.Cycle.Entries.Pairwise().Sum(x => (x.Item1.PMNumberFlow * (x.Item2.Time - x.Item1.Time)).Value()).SI<Scalar>(); var CO2 = entries.Pairwise().Sum(x => x.Item1.CO2MassFlow * (x.Item2.Time - x.Item1.Time)).ConvertToGramm();
PMFlow = PN / energy; CO2Emissions = ((CO2 / measuredPositiveEngineWork) * Constants.GramsToMilligrams).SI<Scalar>();
var simulatedEnergy = data.TotalEngineWorkPositive().ConvertToKiloWattHour(); var PN = entries.Pairwise().Sum(x => (x.Item1.PMNumberFlow * (x.Item2.Time - x.Item1.Time)).Value()).SI<Scalar>();
ICEEnergyRatio = (energy / simulatedEnergy).SI<Scalar>(); PMFlow = PN / measuredPositiveEngineWork;
} }
#endregion #endregion
...@@ -312,8 +323,12 @@ namespace TUGraz.VectoCore.OutputData.XML ...@@ -312,8 +323,12 @@ namespace TUGraz.VectoCore.OutputData.XML
new XElement(tns + "C_VTP", cVtp.ToXMLFormat(4)), new XElement(tns + "C_VTP", cVtp.ToXMLFormat(4)),
CreatePollutantsElement(vtpResult)); CreatePollutantsElement(vtpResult));
if ((vtpResult.ICEEnergyRatio > 1 + ENERGY_THRESHOLD_RANGE) || (vtpResult.ICEEnergyRatio < 1 - ENERGY_THRESHOLD_RANGE)) { var threshold = Constants.SimulationSettings.VTPEngineWorkDeviationThreshold;
LogList.Add($"Positive energy work differs too much from VECTO. ratio = {vtpResult.ICEEnergyRatio}");
if (Math.Abs(vtpResult.PositiveEngineWorkDeviation) > threshold) {
LogList.Add($@"Simulated positive engine work is deviating more than {threshold * 100}%
from measured positive engine work through the vdri.
Deviation = {(vtpResult.PositiveEngineWorkDeviation * 100).ToXMLFormat(2)}%");
} }
if (LogList.Any()) { if (LogList.Any()) {
...@@ -331,35 +346,36 @@ namespace TUGraz.VectoCore.OutputData.XML ...@@ -331,35 +346,36 @@ namespace TUGraz.VectoCore.OutputData.XML
new XElement(tns + "NOx", new XAttribute(XMLNames.Report_Results_Unit_Attr, "mg/kWh"), new XElement(tns + "NOx", new XAttribute(XMLNames.Report_Results_Unit_Attr, "mg/kWh"),
vtpResult.NOxEmissions.ToXMLFormat(3) vtpResult.NOxEmissions.ToXMLFormat(3)
), ),
new XElement(tns + "THC", new XAttribute(XMLNames.Report_Results_Unit_Attr, "mg/kWh"),
vtpResult.THCEmissions.ToXMLFormat(3)
),
new XElement(tns + "CO2", new XAttribute(XMLNames.Report_Results_Unit_Attr, "mg/kWh"), new XElement(tns + "CO2", new XAttribute(XMLNames.Report_Results_Unit_Attr, "mg/kWh"),
vtpResult.CO2Emissions.ToXMLFormat(3) vtpResult.CO2Emissions.ToXMLFormat(3)
) )
); );
if (vtpResult.THCEmissions != null) {
pollutantsElement.Add(
new XElement(tns + "THC", new XAttribute(XMLNames.Report_Results_Unit_Attr, "mg/kWh"),
vtpResult.THCEmissions.ToXMLFormat(3)
));
}
if (vtpResult.CH4Emissions != null) { if (vtpResult.CH4Emissions != null) {
pollutantsElement.Add( pollutantsElement.Add(
new XElement(tns + "CH4", new XAttribute(XMLNames.Report_Results_Unit_Attr, "mg/kWh"), new XElement(tns + "CH4", new XAttribute(XMLNames.Report_Results_Unit_Attr, "mg/kWh"),
vtpResult.CH4Emissions.ToXMLFormat(3) vtpResult.CH4Emissions.ToXMLFormat(3)
) ));
);
} }
if (vtpResult.NMHCEmissions != null) { if (vtpResult.NMHCEmissions != null) {
pollutantsElement.Add( pollutantsElement.Add(
new XElement(tns + "NMHC", new XAttribute(XMLNames.Report_Results_Unit_Attr, "mg/kWh"), new XElement(tns + "NMHC", new XAttribute(XMLNames.Report_Results_Unit_Attr, "mg/kWh"),
vtpResult.NMHCEmissions.ToXMLFormat(3) vtpResult.NMHCEmissions.ToXMLFormat(3)
) ));
);
} }
pollutantsElement.Add( pollutantsElement.Add(
new XElement(tns + "PM", new XAttribute(XMLNames.Report_Results_Unit_Attr, "#/kWh"), new XElement(tns + "PM", new XAttribute(XMLNames.Report_Results_Unit_Attr, "#/kWh"),
vtpResult.PMFlow.ToXMLFormat(3) vtpResult.PMFlow.ToXMLFormat(3)
) ));
);
return pollutantsElement; return pollutantsElement;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment