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

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

change stepTime in cycleStep to double, change aggregation variables to...

change stepTime in cycleStep to double, change aggregation variables to double, adapt precision of testcase for m9
parent c4f726ee
No related branches found
No related tags found
No related merge requests found
......@@ -22,7 +22,7 @@ Namespace DownstreamModules
'Interpolated FC between points 2-3-1 Representing smart Pneumatics = Fuel consumption with smart Pneumatics and average electrical power demand
ReadOnly Property FuelConsumptionSmartPneumaticsAndAverageElectricalPowerDemand As Single
Sub CycleStep(Optional stepTimeInSeconds As Single = 0.0)
Sub CycleStep(Optional stepTimeInSeconds As Double = 0.0)
'Added for diagnostic inspection purposes only, does not materially affect the class function.
ReadOnly Property P1X As Single
......
......@@ -14,86 +14,76 @@ Imports VectoAuxiliaries.Pneumatics
Imports VectoAuxiliaries.Hvac
Namespace DownstreamModules
Public Interface IM11
''' <summary>
''' Smart Electrical Total Cycle Electrical Energy Generated During Overrun Only(J)
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
ReadOnly Property SmartElectricalTotalCycleElectricalEnergyGeneratedDuringOverrunOnly As Single
''' <summary>
''' Smart Electrical Total Cycle Eletrical EnergyGenerated (J)
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
ReadOnly Property SmartElectricalTotalCycleEletricalEnergyGenerated As Single
''' <summary>
''' Total Cycle Electrical Demand (J)
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
ReadOnly Property TotalCycleElectricalDemand As Single
''' <summary>
''' Total Cycle Fuel Consumption: Smart Electrical Load (g)
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
ReadOnly Property TotalCycleFuelConsumptionSmartElectricalLoad As Single
''' <summary>
''' Total Cycle Fuel Consumption: Zero Electrical Load (g)
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
ReadOnly Property TotalCycleFuelConsumptionZeroElectricalLoad As Single
''' <summary>
''' Stop Start Sensitive: Total Cycle Electrical Demand (J)
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
ReadOnly Property StopStartSensitiveTotalCycleElectricalDemand As Single
''' <summary>
''' Total Cycle Fuel Consuption : Average Loads (g)
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
ReadOnly Property TotalCycleFuelConsuptionAverageLoads As Single
''' <summary>
''' Clears aggregated values ( Sets them to zero ).
''' </summary>
''' <remarks></remarks>
Sub ClearAggregates()
''' <summary>
''' Increments all aggregated outputs
''' </summary>
''' <param name="stepTimeInSeconds">Single : Mutiplies the values to be aggregated by number of seconds</param>
''' <remarks></remarks>
Sub CycleStep(Optional stepTimeInSeconds As Single = 0.0)
End Interface
Public Interface IM11
''' <summary>
''' Smart Electrical Total Cycle Electrical Energy Generated During Overrun Only(J)
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
ReadOnly Property SmartElectricalTotalCycleElectricalEnergyGeneratedDuringOverrunOnly As Single
''' <summary>
''' Smart Electrical Total Cycle Eletrical EnergyGenerated (J)
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
ReadOnly Property SmartElectricalTotalCycleEletricalEnergyGenerated As Single
''' <summary>
''' Total Cycle Electrical Demand (J)
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
ReadOnly Property TotalCycleElectricalDemand As Single
''' <summary>
''' Total Cycle Fuel Consumption: Smart Electrical Load (g)
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
ReadOnly Property TotalCycleFuelConsumptionSmartElectricalLoad As Single
''' <summary>
''' Total Cycle Fuel Consumption: Zero Electrical Load (g)
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
ReadOnly Property TotalCycleFuelConsumptionZeroElectricalLoad As Single
''' <summary>
''' Stop Start Sensitive: Total Cycle Electrical Demand (J)
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
ReadOnly Property StopStartSensitiveTotalCycleElectricalDemand As Single
''' <summary>
''' Total Cycle Fuel Consuption : Average Loads (g)
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
ReadOnly Property TotalCycleFuelConsuptionAverageLoads As Single
''' <summary>
''' Clears aggregated values ( Sets them to zero ).
''' </summary>
''' <remarks></remarks>
Sub ClearAggregates()
''' <summary>
''' Increments all aggregated outputs
''' </summary>
''' <param name="stepTimeInSeconds">Single : Mutiplies the values to be aggregated by number of seconds</param>
''' <remarks></remarks>
Sub CycleStep(Optional stepTimeInSeconds As Double = 0.0)
End Interface
End Namespace
......@@ -30,7 +30,7 @@ Inherits IAuxiliaryEvent
''' </summary>
''' <param name="stepTimeInSeconds">Single : Mutiplies the values to be aggregated by number of seconds</param>
''' <remarks></remarks>
Sub CycleStep(Optional stepTimeInSeconds As Single = 0.0)
Sub CycleStep(Optional stepTimeInSeconds As Double = 0.0)
''' <summary>
''' Litres Of Air: Compressor On Continually (L)
......
......@@ -15,169 +15,166 @@ Imports VectoAuxiliaries.Hvac
Imports VectoAuxiliaries.DownstreamModules
Namespace DownstreamModules
Public Class M10
Implements IM10
'Aggregators
Private _AverageAirConsumedPerSecondLitre As Double
'Diagnostics
Private x1, y1, x2, y2, x3, y3, xTA, interp1, interp2 As Single
Public ReadOnly Property P1X As Single Implements IM10.P1X
Get
Return x1
End Get
End Property
Public ReadOnly Property P1Y As Single Implements IM10.P1Y
Get
Return y1
End Get
End Property
Public ReadOnly Property P2X As Single Implements IM10.P2X
Get
Return x2
End Get
End Property
Public ReadOnly Property P2Y As Single Implements IM10.P2Y
Get
Return y2
End Get
End Property
Public ReadOnly Property P3X As Single Implements IM10.P3X
Get
Return x3
End Get
End Property
Public ReadOnly Property P3Y As Single Implements IM10.P3Y
Get
Return y3
End Get
End Property
Public ReadOnly Property XTAIN As Single Implements IM10.XTAIN
Get
Return xTA
End Get
End Property
Public ReadOnly Property INTRP1 As Single Implements IM10.INTRP1
Get
Return interp1
End Get
End Property
Public ReadOnly Property INTRP2 As Single Implements IM10.INTRP2
Get
Return interp2
End Get
End Property
'Private
Public Class M10
Implements IM10
'Aggregators
Private _AverageAirConsumedPerSecondLitre As Single
'Diagnostics
Private x1, y1, x2, y2, x3, y3, xTA, interp1, interp2 As Single
Public ReadOnly Property P1X As Single Implements IM10.P1X
Get
Return x1
End Get
End Property
Public ReadOnly Property P1Y As Single Implements IM10.P1Y
Get
Return y1
End Get
End Property
Public ReadOnly Property P2X As Single Implements IM10.P2X
Get
Return x2
End Get
End Property
Public ReadOnly Property P2Y As Single Implements IM10.P2Y
Get
Return y2
End Get
End Property
Public ReadOnly Property P3X As Single Implements IM10.P3X
Get
Return x3
End Get
End Property
Public ReadOnly Property P3Y As Single Implements IM10.P3Y
Get
Return y3
End Get
End Property
Public ReadOnly Property XTAIN As Single Implements IM10.XTAIN
Get
Return xTA
End Get
End Property
Public ReadOnly Property INTRP1 As Single Implements IM10.INTRP1
Get
Return interp1
End Get
End Property
Public ReadOnly Property INTRP2 As Single Implements IM10.INTRP2
Get
Return interp2
End Get
End Property
'Private
#Region "Private Fields = > Constructor Requirements"
Private m3 As IM3_AveragePneumaticLoadDemand
Private m9 As IM9
'Not Currently used but there for ease of refactoring in future.
Private signals As ISignals
Private m3 As IM3_AveragePneumaticLoadDemand
Private m9 As IM9
'Not Currently used but there for ease of refactoring in future.
Private signals As ISignals
#End Region
Private Enum InterpolationType
NonSmartPneumtaics
SmartPneumtaics
End Enum
Private Function Interpolate(interpType As InterpolationType) As Single
Private Enum InterpolationType
NonSmartPneumtaics
SmartPneumtaics
End Enum
Dim returnValue As Single
' Dim x1,y1,x2,y2,x3,y3, xTA As Single
Private Function Interpolate(interpType As InterpolationType) As Single
x1 = m9.LitresOfAirCompressorOnContinually
y1 = m9.TotalCycleFuelConsumptionCompressorOnContinuously
x2 = 0
y2 = m9.TotalCycleFuelConsumptionCompressorOffContinuously
x3 = m9.LitresOfAirCompressorOnOnlyInOverrun
y3 = m9.TotalCycleFuelConsumptionCompressorOffContinuously
Dim returnValue As Single
' Dim x1,y1,x2,y2,x3,y3, xTA As Single
x1 = m9.LitresOfAirCompressorOnContinually
y1 = m9.TotalCycleFuelConsumptionCompressorOnContinuously
x2 = 0
y2 = m9.TotalCycleFuelConsumptionCompressorOffContinuously
x3 = m9.LitresOfAirCompressorOnOnlyInOverrun
y3 = m9.TotalCycleFuelConsumptionCompressorOffContinuously
xTA = _AverageAirConsumedPerSecondLitre 'm3.AverageAirConsumedPerSecondLitre
xTA = _AverageAirConsumedPerSecondLitre 'm3.AverageAirConsumedPerSecondLitre
Select Case interpType
'Non-Smart Pneumatics ( OUT 1 )
Case InterpolationType.NonSmartPneumtaics
returnValue = y2 + (((y1 - y2) * xTA) / x1)
interp1 = returnValue
Select Case interpType
'Smart Pneumatics ( OUT 2 )
Case InterpolationType.SmartPneumtaics
ReturnValue = y3 + (((y1 - y3) / (x1 - x3)) * (xTA - x3))
interp2 = returnValue
'Non-Smart Pneumatics ( OUT 1 )
Case InterpolationType.NonSmartPneumtaics
returnValue = y2 + (((y1 - y2) * xTA) / x1)
interp1 = returnValue
'Smart Pneumatics ( OUT 2 )
Case InterpolationType.SmartPneumtaics
ReturnValue = y3 + (((y1 - y3) / (x1 - x3)) * (xTA - x3))
interp2 = returnValue
End Select
Return returnValue
End Function
End Select
'Public
Return returnValue
End Function
'Public
#Region "Public Properties"
Public ReadOnly Property AverageLoadsFuelConsumptionInterpolatedForPneumatics As Single Implements IM10.AverageLoadsFuelConsumptionInterpolatedForPneumatics
Get
'SCHM 3_02
Dim intrp1 As Single = Interpolate(InterpolationType.NonSmartPneumtaics)
'intrp1 = If(Not Single.IsNaN(intrp1), intrp1, 0)
Return intrp1
Public ReadOnly Property AverageLoadsFuelConsumptionInterpolatedForPneumatics As Single _
Implements IM10.AverageLoadsFuelConsumptionInterpolatedForPneumatics
Get
End Get
End Property
Public ReadOnly Property FuelConsumptionSmartPneumaticsAndAverageElectricalPowerDemand As Single Implements IM10.FuelConsumptionSmartPneumaticsAndAverageElectricalPowerDemand
Get
'SCHM 3_02
Dim intrp1 As Single = Interpolate(InterpolationType.NonSmartPneumtaics)
'intrp1 = If(Not Single.IsNaN(intrp1), intrp1, 0)
Return intrp1
End Get
End Property
'SCHM 3_02
Dim intrp2 As Single = Interpolate(InterpolationType.SmartPneumtaics)
'intrp2 = If(Not Single.IsNaN(intrp2), intrp2, 0)
Return intrp2
Public ReadOnly Property FuelConsumptionSmartPneumaticsAndAverageElectricalPowerDemand As Single _
Implements IM10.FuelConsumptionSmartPneumaticsAndAverageElectricalPowerDemand
Get
End Get
End Property
'SCHM 3_02
Dim intrp2 As Single = Interpolate(InterpolationType.SmartPneumtaics)
'intrp2 = If(Not Single.IsNaN(intrp2), intrp2, 0)
Return intrp2
End Get
End Property
#End Region
#Region "Contructors"
Public Sub New(m3 As IM3_AveragePneumaticLoadDemand, m9 As IM9, signals As ISignals)
#Region "Contructors"
Me.m3 = m3
Me.m9 = m9
Me.signals = signals
Public Sub New(m3 As IM3_AveragePneumaticLoadDemand, m9 As IM9, signals As ISignals)
End Sub
Me.m3 = m3
Me.m9 = m9
Me.signals = signals
End Sub
#End Region
Public Sub CycleStep(Optional stepTimeInSeconds As Single = 0.0) Implements IM10.CycleStep
_AverageAirConsumedPerSecondLitre += If(Single.IsNaN(m3.AverageAirConsumedPerSecondLitre), 0, m3.AverageAirConsumedPerSecondLitre)
End Sub
End Class
Public Sub CycleStep(Optional stepTimeInSeconds As Double = 0.0) Implements IM10.CycleStep
_AverageAirConsumedPerSecondLitre +=
If(Single.IsNaN(m3.AverageAirConsumedPerSecondLitre), 0, m3.AverageAirConsumedPerSecondLitre)
End Sub
End Class
End Namespace
......@@ -21,13 +21,13 @@ Namespace DownstreamModules
#Region "Private Aggregates"
'Private Aggregations
Private AG1 As Single
Private AG2 As Single
Private AG3 As Single
Private AG4 As Single
Private AG5 As Single
Private AG6 As Single
Private AG7 As Single
Private AG1 As Double
Private AG2 As Double
Private AG3 As Double
Private AG4 As Double
Private AG5 As Double
Private AG6 As Double
Private AG7 As Double
#End Region
......@@ -205,22 +205,22 @@ Namespace DownstreamModules
End Sub
'Add to Aggregates dependent on cycle step time.
Sub CycleStep(Optional stepTimeInSeconds As Single = 0.0) Implements IM11.CycleStep
Sub CycleStep(Optional stepTimeInSeconds As Double = 0.0) Implements IM11.CycleStep
'S/S Insensitive
AG3 += (stepTimeInSeconds * m6.AvgPowerDemandAtCrankFromElectricsIncHVAC)
AG3 += (stepTimeInSeconds * M6.AvgPowerDemandAtCrankFromElectricsIncHVAC)
If Signals.EngineStopped Then Return
If signals.EngineStopped Then Return
'S/S Sensitive
AG1 += (stepTimeInSeconds * sum1 * SW1)
AG1 += (stepTimeInSeconds * Sum1 * SW1)
AG2 += (stepTimeInSeconds * M8.SmartElectricalAlternatorPowerGenAtCrank * SW1)
AG6 += (stepTimeInSeconds * m6.AvgPowerDemandAtCrankFromElectricsIncHVAC * SW1)
AG6 += (stepTimeInSeconds * M6.AvgPowerDemandAtCrankFromElectricsIncHVAC * SW1)
'These need to be divided by 3600 as the Fuel Map output is in Grams/Second.
AG4 += (stepTimeInSeconds * sum7 / 3600 * SW1)
AG4 += (stepTimeInSeconds * Sum7 / 3600 * SW1)
AG5 += (stepTimeInSeconds * Sum8 / 3600 * SW1)
AG7 += (stepTimeInSeconds * Sum12 / 3600 * SW1)
End Sub
......
......@@ -16,18 +16,18 @@ Imports VectoAuxiliaries.Hvac
Namespace DownstreamModules
Public Class M9
Implements IM9
Private Const RPM_TO_RADS_PER_SECOND As Single = 9.55F
Private Const RPM_TO_RADS_PER_SECOND As Single = 60 / (2 * Math.PI) '9.55F
#Region "Aggregates"
'AG1
Private _LitresOfAirCompressorOnContinuallyAggregate As Single
Private _LitresOfAirCompressorOnContinuallyAggregate As Double
'AG2
Private _LitresOfAirCompressorOnOnlyInOverrunAggregate As Single
Private _LitresOfAirCompressorOnOnlyInOverrunAggregate As Double
'AG3
Private _TotalCycleFuelConsumptionCompressorOffContinuouslyAggregate As Single
Private _TotalCycleFuelConsumptionCompressorOffContinuouslyAggregate As Double
'AG4
Private _TotalCycleFuelConsumptionCompressorOnContinuouslyAggregate As Single
Private _TotalCycleFuelConsumptionCompressorOnContinuouslyAggregate As Double
#End Region
......@@ -173,8 +173,7 @@ Namespace DownstreamModules
Private ReadOnly Property S13 As Single
Get
Return (Signals.ClutchEngaged *
Not (Signals.InNeutral)) * S9
Return If(Signals.ClutchEngaged AndAlso Not (Signals.InNeutral), S9, 0)
End Get
End Property
......@@ -200,7 +199,7 @@ Namespace DownstreamModules
_TotalCycleFuelConsumptionCompressorOnContinuouslyAggregate = 0
End Sub
Public Sub CycleStep(Optional stepTimeInSeconds As Single = 0.0) Implements IM9.CycleStep
Public Sub CycleStep(Optional stepTimeInSeconds As Double = 0.0) Implements IM9.CycleStep
If Signals.EngineStopped Then Return
......
......@@ -59,8 +59,8 @@ Namespace UnitTests
Assert.AreEqual(target.LitresOfAirCompressorOnContinually, AG1)
Assert.AreEqual(target.LitresOfAirCompressorOnOnlyInOverrun, AG2)
Assert.AreEqual(target.TotalCycleFuelConsumptionCompressorOnContinuously, CType(Math.Round(AG3, 7), Single))
Assert.AreEqual(target.TotalCycleFuelConsumptionCompressorOffContinuously, AG4)
Assert.AreEqual(target.TotalCycleFuelConsumptionCompressorOnContinuously, AG3, 0.000001)
Assert.AreEqual(target.TotalCycleFuelConsumptionCompressorOffContinuously, AG4, 0.000001)
End Sub
......
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