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 303be47e authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

Merge branch 'develop' of...

parents e9656195 2f6bb4d4
Branches
Tags
No related merge requests found
No preview for this file type
No preview for this file type
...@@ -92,6 +92,9 @@ Public Class Form1 ...@@ -92,6 +92,9 @@ Public Class Form1
End If End If
Job.OutPath = Me.TbOutputFolder.Text & "\" Job.OutPath = Me.TbOutputFolder.Text & "\"
Job.SwitchFuelsFlag = False
End Function End Function
......
...@@ -123,6 +123,9 @@ Public Class cJob ...@@ -123,6 +123,9 @@ Public Class cJob
Public PT1 As cPT1 Public PT1 As cPT1
Public SwitchFuelsFlag As Boolean
Public Sub New() Public Sub New()
End Sub End Sub
...@@ -251,18 +254,7 @@ Public Class cJob ...@@ -251,18 +254,7 @@ Public Class cJob
If Not WHTCsim.CalcFC() Then Return False If Not WHTCsim.CalcFC() Then Return False
If Not WHTCsim.CalcResults(False) Then Return False If Not WHTCsim.CalcResults(False) Then Return False
'Calculation of WHTC-Correction and Cold-Hot-Balancing-Factor WHTC_CorrFactorsAndOutput()
WHTCurbanFactor = FCspecMeas_HotUrb/Math.Round(WHTCsim.Urban, 2)
If WHTCurbanFactor < 1 Then WHTCurbanFactor = 1
WHTCruralFactor = FCspecMeas_HotRur/Math.Round(WHTCsim.Rural, 2)
If WHTCruralFactor < 1 Then WHTCruralFactor = 1
WHTCmotorwayFactor = FCspecMeas_HotMw/Math.Round(WHTCsim.Motorway, 2)
If WHTCmotorwayFactor < 1 Then WHTCmotorwayFactor = 1
ColdHotBalancingFactor = 1 + 0.1*(FCspecMeas_ColdTot - FCspecMeas_HotTot)/FCspecMeas_HotTot
If ColdHotBalancingFactor < 1 Then ColdHotBalancingFactor = 1
CalculateDualFuel()
CalculateWHRMech() CalculateWHRMech()
CalculateWHREl() CalculateWHREl()
...@@ -301,9 +293,9 @@ Public Class cJob ...@@ -301,9 +293,9 @@ Public Class cJob
Dim componentXmlGenerated As Boolean Dim componentXmlGenerated As Boolean
If DualFuel = True Or If DualFuel = True OrElse
WHR_ICE = True Or WHR_ICE = True OrElse
WHR_Mech = True Or WHR_Mech = True OrElse
WHR_El = True Then WHR_El = True Then
componentXmlGenerated = MAP.WriteXmlComponentFileV23( componentXmlGenerated = MAP.WriteXmlComponentFileV23(
...@@ -335,16 +327,70 @@ Public Class cJob ...@@ -335,16 +327,70 @@ Public Class cJob
Return componentXmlGenerated Return componentXmlGenerated
End Function End Function
Private Sub CalculateDualFuel() Private Sub WHTC_CorrFactorsAndOutput()
Dim HelpEnergyShareFuel1 As Double
If DualFuel Then If DualFuel Then
'Calculation of WHTC-Correction and Cold-Hot-Balancing-Factor
WHTCurbanFactor = FCspecMeas_HotUrb / Math.Round(WHTCsim.Urban, 2)
WHTCruralFactor = FCspecMeas_HotRur / Math.Round(WHTCsim.Rural, 2)
WHTCmotorwayFactor = FCspecMeas_HotMw / Math.Round(WHTCsim.Motorway, 2)
ColdHotBalancingFactor = 1 + 0.1 * (FCspecMeas_ColdTot - FCspecMeas_HotTot) / FCspecMeas_HotTot
'Calculation of WHTC-Correction and Cold-Hot-Balancing-Factor for second fuel 'Calculation of WHTC-Correction and Cold-Hot-Balancing-Factor for second fuel
WHTCurbanFactor2 = FCspecMeas_HotUrb2 / Math.Round(WHTCsim.UrbanFC2, 2) WHTCurbanFactor2 = FCspecMeas_HotUrb2 / Math.Round(WHTCsim.UrbanFC2, 2)
If WHTCurbanFactor2 < 1 Then WHTCurbanFactor2 = 1
WHTCruralFactor2 = FCspecMeas_HotRur2 / Math.Round(WHTCsim.RuralFC2, 2) WHTCruralFactor2 = FCspecMeas_HotRur2 / Math.Round(WHTCsim.RuralFC2, 2)
If WHTCruralFactor2 < 1 Then WHTCruralFactor2 = 1
WHTCmotorwayFactor2 = FCspecMeas_HotMw2 / Math.Round(WHTCsim.MotorwayFC2, 2) WHTCmotorwayFactor2 = FCspecMeas_HotMw2 / Math.Round(WHTCsim.MotorwayFC2, 2)
If WHTCmotorwayFactor2 < 1 Then WHTCmotorwayFactor2 = 1 ColdHotBalancingFactor2 = 1 + 0.1 * (FCspecMeas_ColdTot2 - FCspecMeas_HotTot2) / FCspecMeas_HotTot2
'Calculation of energy share per fuel in case of dual fuel
' WHTCsim.EnergyFuel value is at this point an intermediate result in unit of total [g] over cycle
' --> intermediate result is converted to final energy
WHTCsim.EnergyShareFuel1 = WHTCsim.EnergyShareFuel1 * NCVfuel
WHTCsim.EnergyShareFuel2 = WHTCsim.EnergyShareFuel2 * NCVfuel2
HelpEnergyShareFuel1 = WHTCsim.EnergyShareFuel1 / (WHTCsim.EnergyShareFuel1 + WHTCsim.EnergyShareFuel2)
WHTCsim.EnergyShareFuel2 = WHTCsim.EnergyShareFuel2 / (WHTCsim.EnergyShareFuel1 + WHTCsim.EnergyShareFuel2)
WHTCsim.EnergyShareFuel1 = HelpEnergyShareFuel1
' Check if fuel1 and fuel2 need to be switched due to main energy share
If WHTCsim.EnergyShareFuel2 > WHTCsim.EnergyShareFuel1 Then SwitchFuelsFlag = True
' Special rules for limitation of combined correction factors weighted with specific fuel energy share
' ATTENTION: Only allow calculation of new value for fuel with higher energy share otherwise negative correction factors could occur for fuel with very low energy share
If WHTCurbanFactor < 1 AndAlso WHTCurbanFactor2 < 1 Then
WHTCurbanFactor = 1
WHTCurbanFactor2 = 1
ElseIf WHTCurbanFactor >= 1 AndAlso WHTCurbanFactor2 < 1 AndAlso WHTCsim.EnergyShareFuel2 > 0.5 Then
WHTCurbanFactor2 = (1 - Math.Round(WHTCurbanFactor, 4) * WHTCsim.EnergyShareFuel1) / WHTCsim.EnergyShareFuel2
ElseIf WHTCurbanFactor < 1 AndAlso WHTCurbanFactor2 >= 1 AndAlso WHTCsim.EnergyShareFuel1 > 0.5 Then
WHTCurbanFactor = (1 - Math.Round(WHTCurbanFactor2, 4) * WHTCsim.EnergyShareFuel2) / WHTCsim.EnergyShareFuel1
End If
If WHTCruralFactor < 1 AndAlso WHTCruralFactor2 < 1 Then
WHTCruralFactor = 1
WHTCruralFactor2 = 1
ElseIf WHTCruralFactor >= 1 AndAlso WHTCruralFactor2 < 1 AndAlso WHTCsim.EnergyShareFuel2 > 0.5 Then
WHTCruralFactor2 = (1 - Math.Round(WHTCruralFactor, 4) * WHTCsim.EnergyShareFuel1) / WHTCsim.EnergyShareFuel2
ElseIf WHTCruralFactor < 1 AndAlso WHTCruralFactor2 >= 1 AndAlso WHTCsim.EnergyShareFuel1 > 0.5 Then
WHTCruralFactor = (1 - Math.Round(WHTCruralFactor2, 4) * WHTCsim.EnergyShareFuel2) / WHTCsim.EnergyShareFuel1
End If
If WHTCmotorwayFactor < 1 AndAlso WHTCmotorwayFactor2 < 1 Then
WHTCmotorwayFactor = 1
WHTCmotorwayFactor2 = 1
ElseIf WHTCmotorwayFactor >= 1 AndAlso WHTCmotorwayFactor2 < 1 AndAlso WHTCsim.EnergyShareFuel2 > 0.5 Then
WHTCmotorwayFactor2 = (1 - Math.Round(WHTCmotorwayFactor, 4) * WHTCsim.EnergyShareFuel1) / WHTCsim.EnergyShareFuel2
ElseIf WHTCmotorwayFactor < 1 AndAlso WHTCmotorwayFactor2 >= 1 AndAlso WHTCsim.EnergyShareFuel1 > 0.5 Then
WHTCmotorwayFactor = (1 - Math.Round(WHTCmotorwayFactor2, 4) * WHTCsim.EnergyShareFuel2) / WHTCsim.EnergyShareFuel1
End If
If ColdHotBalancingFactor < 1 AndAlso ColdHotBalancingFactor2 < 1 Then
ColdHotBalancingFactor = 1
ColdHotBalancingFactor2 = 1
ElseIf ColdHotBalancingFactor >= 1 AndAlso ColdHotBalancingFactor2 < 1 AndAlso WHTCsim.EnergyShareFuel2 > 0.5 Then
ColdHotBalancingFactor2 = (1 - Math.Round(ColdHotBalancingFactor, 4) * WHTCsim.EnergyShareFuel1) / WHTCsim.EnergyShareFuel2
ElseIf ColdHotBalancingFactor < 1 AndAlso ColdHotBalancingFactor2 >= 1 AndAlso WHTCsim.EnergyShareFuel1 > 0.5 Then
ColdHotBalancingFactor = (1 - Math.Round(ColdHotBalancingFactor2, 4) * WHTCsim.EnergyShareFuel2) / WHTCsim.EnergyShareFuel1
End If
WorkerMsg(tMsgID.Normal, "WHTC Simulation Results - " & (FuelType).ToString & ":") WorkerMsg(tMsgID.Normal, "WHTC Simulation Results - " & (FuelType).ToString & ":")
WorkerMsg(tMsgID.Normal, " Urban: " & (WHTCsim.Urban).ToString("f2") & " [g/kWh].") WorkerMsg(tMsgID.Normal, " Urban: " & (WHTCsim.Urban).ToString("f2") & " [g/kWh].")
...@@ -357,15 +403,25 @@ Public Class cJob ...@@ -357,15 +403,25 @@ Public Class cJob
WorkerMsg(tMsgID.Normal, " Motorway: " & (WHTCsim.MotorwayFC2).ToString("f2") & " [g/kWh].") WorkerMsg(tMsgID.Normal, " Motorway: " & (WHTCsim.MotorwayFC2).ToString("f2") & " [g/kWh].")
WorkerMsg(tMsgID.Normal, " Total: " & (WHTCsim.TotFCspec2).ToString("f2") & " [g/kWh].") WorkerMsg(tMsgID.Normal, " Total: " & (WHTCsim.TotFCspec2).ToString("f2") & " [g/kWh].")
ColdHotBalancingFactor2 = 1 + 0.1 * (FCspecMeas_ColdTot2 - FCspecMeas_HotTot2) / FCspecMeas_HotTot2
If ColdHotBalancingFactor2 < 1 Then ColdHotBalancingFactor2 = 1
Else Else
'Calculation of WHTC-Correction and Cold-Hot-Balancing-Factor
WHTCurbanFactor = FCspecMeas_HotUrb / Math.Round(WHTCsim.Urban, 2)
If WHTCurbanFactor < 1 Then WHTCurbanFactor = 1
WHTCruralFactor = FCspecMeas_HotRur / Math.Round(WHTCsim.Rural, 2)
If WHTCruralFactor < 1 Then WHTCruralFactor = 1
WHTCmotorwayFactor = FCspecMeas_HotMw / Math.Round(WHTCsim.Motorway, 2)
If WHTCmotorwayFactor < 1 Then WHTCmotorwayFactor = 1
ColdHotBalancingFactor = 1 + 0.1 * (FCspecMeas_ColdTot - FCspecMeas_HotTot) / FCspecMeas_HotTot
If ColdHotBalancingFactor < 1 Then ColdHotBalancingFactor = 1
WorkerMsg(tMsgID.Normal, "WHTC Simulation Results:") WorkerMsg(tMsgID.Normal, "WHTC Simulation Results:")
WorkerMsg(tMsgID.Normal, " Urban: " & (WHTCsim.Urban).ToString("f2") & " [g/kWh].") WorkerMsg(tMsgID.Normal, " Urban: " & (WHTCsim.Urban).ToString("f2") & " [g/kWh].")
WorkerMsg(tMsgID.Normal, " Rural: " & (WHTCsim.Rural).ToString("f2") & " [g/kWh].") WorkerMsg(tMsgID.Normal, " Rural: " & (WHTCsim.Rural).ToString("f2") & " [g/kWh].")
WorkerMsg(tMsgID.Normal, " Motorway: " & (WHTCsim.Motorway).ToString("f2") & " [g/kWh].") WorkerMsg(tMsgID.Normal, " Motorway: " & (WHTCsim.Motorway).ToString("f2") & " [g/kWh].")
WorkerMsg(tMsgID.Normal, " Total: " & (WHTCsim.TotFCspec).ToString("f2") & " [g/kWh].") WorkerMsg(tMsgID.Normal, " Total: " & (WHTCsim.TotFCspec).ToString("f2") & " [g/kWh].")
End If End If
End Sub End Sub
......
...@@ -1145,7 +1145,7 @@ Public Class cMAP0 ...@@ -1145,7 +1145,7 @@ Public Class cMAP0
whtcMotorway, bfColdHot, cfRegPer, cfncv) whtcMotorway, bfColdHot, cfRegPer, cfncv)
Select fuelTypeCommonField), Select fuelTypeCommonField),
New XElement(v10 + XMLNames.Engine_FuelType, GetXMLFuelTypeString(fuelType)), New XElement(v10 + XMLNames.Engine_FuelType, GetXMLFuelTypeString(fuelType)),
GetFuelConsumptionMapElement(v10, job, fuelType, True), GetFuelConsumptionMapElement(v10, job, fuelType, True, False),
GetFullLoadAndDragCurveElement(v10) GetFullLoadAndDragCurveElement(v10)
) )
) )
...@@ -1209,9 +1209,9 @@ Public Class cMAP0 ...@@ -1209,9 +1209,9 @@ Public Class cMAP0
Dim modes = New XElement(xmlNamespace + XMLNames.Engine_Mode, Dim modes = New XElement(xmlNamespace + XMLNames.Engine_Mode,
New XElement(xmlNamespace + XMLNames.Engine_IdlingSpeed, job.Idle), New XElement(xmlNamespace + XMLNames.Engine_IdlingSpeed, job.Idle),
GetFullLoadAndDragCurveElement(xmlNamespace), GetFullLoadAndDragCurveElement(xmlNamespace),
GetFuelTypeElement(xmlNamespace, job, true)) GetFuelTypeElement(xmlNamespace, job, Not (job.SwitchFuelsFlag), True))
If job.DualFuel Then If job.DualFuel Then
modes.Add(GetFuelTypeElement(xmlNamespace, job, false)) modes.Add(GetFuelTypeElement(xmlNamespace, job, job.SwitchFuelsFlag, False))
End If End If
Return modes Return modes
...@@ -1238,9 +1238,10 @@ Public Class cMAP0 ...@@ -1238,9 +1238,10 @@ Public Class cMAP0
End Function End Function
Private Function GetFuelTypeElement(xmlNamespace As XNamespace, job As cJob, mainFuel As Boolean) As XElement Private Function GetFuelTypeElement(xmlNamespace As XNamespace, job As cJob, WriteFirstFuel As Boolean, WriteWHRData As Boolean) As XElement
Dim whrCorrectionFactors = If(WriteWHRData, GetWHRCorrectionFactorElements(xmlNamespace, job), Nothing)
Dim whrCorrectionFactors = If(mainFuel, GetWHRCorrectionFactorElements(xmlNamespace, job), nothing)
Dim fuelType = job.FuelType Dim fuelType = job.FuelType
Dim whtcUrban = job.WHTCurbanFactor.ToString("f4") Dim whtcUrban = job.WHTCurbanFactor.ToString("f4")
Dim whtcRural = job.WHTCruralFactor.ToString("f4") Dim whtcRural = job.WHTCruralFactor.ToString("f4")
...@@ -1249,7 +1250,7 @@ Public Class cMAP0 ...@@ -1249,7 +1250,7 @@ Public Class cMAP0
Dim cfRegPer = job.CF_RegPer.ToString("f4") Dim cfRegPer = job.CF_RegPer.ToString("f4")
Dim cfncv = NCV_CorrectionFactor.ToString("f4") Dim cfncv = NCV_CorrectionFactor.ToString("f4")
If(mainFuel = False) If (WriteFirstFuel = False) Then
fuelType = job.FuelType2 fuelType = job.FuelType2
whtcUrban = job.WHTCurbanFactor2.ToString("f4") whtcUrban = job.WHTCurbanFactor2.ToString("f4")
whtcRural = job.WHTCruralFactor2.ToString("f4") whtcRural = job.WHTCruralFactor2.ToString("f4")
...@@ -1264,8 +1265,8 @@ Public Class cMAP0 ...@@ -1264,8 +1265,8 @@ Public Class cMAP0
(From commonFuelType In GetFuelTypeCommonElements(xmlNamespace, whtcUrban, whtcRural, (From commonFuelType In GetFuelTypeCommonElements(xmlNamespace, whtcUrban, whtcRural,
whtcMotorway, bfColdHot, cfRegPer, cfncv) whtcMotorway, bfColdHot, cfRegPer, cfncv)
Select commonFuelType), Select commonFuelType),
If(whrcorrectionfactors?.HasElements, whrcorrectionFactors, Nothing), If(whrCorrectionFactors?.HasElements, whrCorrectionFactors, Nothing),
GetFuelConsumptionMapElement(xmlNamespace, job, fuelType, mainFuel)) GetFuelConsumptionMapElement(xmlNamespace, job, fuelType, WriteFirstFuel, WriteWHRData))
End Function End Function
...@@ -1320,7 +1321,7 @@ Public Class cMAP0 ...@@ -1320,7 +1321,7 @@ Public Class cMAP0
End Function End Function
Private Function GetFuelConsumptionMapElement(xmlNamespace As XNamespace, job As cJob, fuelType As String, mainFuelType As Boolean) As XElement Private Function GetFuelConsumptionMapElement(xmlNamespace As XNamespace, job As cJob, fuelType As String, FirstFuel As Boolean, IncludeWHRData As Boolean) As XElement
Dim fcMap = New XElement(xmlNamespace + XMLNames.Engine_FuelConsumptionMap) Dim fcMap = New XElement(xmlNamespace + XMLNames.Engine_FuelConsumptionMap)
...@@ -1329,16 +1330,14 @@ Public Class cMAP0 ...@@ -1329,16 +1330,14 @@ Public Class cMAP0
Dim fcCorr As Double Dim fcCorr As Double
If fuelType = "Diesel / CI" Then If fuelType = "Diesel / CI" Then
If(mainFuelType)
fcCorr = mp.FC1 fcCorr = mp.FC1
Else If (FirstFuel = False) Then
fcCorr = mp.FC2 fcCorr = mp.FC2
End If End If
Else Else
If(mainFuelType)
fcCorr = mp.FC1 * NCV_CorrectionFactor fcCorr = mp.FC1 * NCV_CorrectionFactor
Else If (FirstFuel = False) Then
fcCorr = mp.FC2* NCV_CorrectionFactor fcCorr = mp.FC2 * NCV_CorrectionFactor2
End If End If
End If End If
...@@ -1346,12 +1345,12 @@ Public Class cMAP0 ...@@ -1346,12 +1345,12 @@ Public Class cMAP0
New XAttribute(XMLNames.Engine_FuelConsumptionMap_EngineSpeed_Attr, mp.nU.ToString("f2")), New XAttribute(XMLNames.Engine_FuelConsumptionMap_EngineSpeed_Attr, mp.nU.ToString("f2")),
New XAttribute(XMLNames.Engine_FuelConsumptionMap_Torque_Attr, mp.Tq.ToString("f2")), New XAttribute(XMLNames.Engine_FuelConsumptionMap_Torque_Attr, mp.Tq.ToString("f2")),
New XAttribute(XMLNames.Engine_FuelConsumptionMap_FuelConsumption_Attr, fcCorr.ToString("f2")), New XAttribute(XMLNames.Engine_FuelConsumptionMap_FuelConsumption_Attr, fcCorr.ToString("f2")),
If(mainFuelType, If(IncludeWHRData,
if _ If _
(job.whr_El, New XAttribute(XMLNames.Engine_FuelConsumptionMap_ElectricPower_Attr, (job.WHR_El, New XAttribute(XMLNames.Engine_FuelConsumptionMap_ElectricPower_Attr,
mp.WHRElectrical.ToString("f2")), Nothing), Nothing), mp.WHRElectrical.ToString("f2")), Nothing), Nothing),
If(mainFuelType, If(IncludeWHRData,
if _ If _
(job.WHR_Mech, New XAttribute(XMLNames.Engine_FuelConsumptionMap_MechanicalPower_Attr, (job.WHR_Mech, New XAttribute(XMLNames.Engine_FuelConsumptionMap_MechanicalPower_Attr,
mp.WHRMechanical.ToString("f2")), Nothing), Nothing))) mp.WHRMechanical.ToString("f2")), Nothing), Nothing)))
Next Next
......
...@@ -74,6 +74,10 @@ Public Class cWHTC ...@@ -74,6 +74,10 @@ Public Class cWHTC
Public WHTC_n_hi As Double Public WHTC_n_hi As Double
Public WHTC_n_pref As Double Public WHTC_n_pref As Double
Public EnergyShareFuel1 As Double
Public EnergyShareFuel2 As Double
Public Function InitCycle(Measurement As Boolean) As Boolean Public Function InitCycle(Measurement As Boolean) As Boolean
...@@ -421,6 +425,10 @@ Public Class cWHTC ...@@ -421,6 +425,10 @@ Public Class cWHTC
TotWHRMechSpec = TotalWHRMech / TotalWork '[kJ/kWh] TotWHRMechSpec = TotalWHRMech / TotalWork '[kJ/kWh]
TotWork = TotalWork TotWork = TotalWork
' Actual energy values per fuel are calculated outside of this class in "cJob"
EnergyShareFuel1 = TotalFC
EnergyShareFuel2 = TotalFC2
'If WriteTotalResults Then 'If WriteTotalResults Then
' TotalFCspec = TotalFC / TotalWork ' TotalFCspec = TotalFC / TotalWork
' WorkerMsg(tMsgID.Normal, "Total FC = " & TotalFCspec.ToString("0.00") & " [g/kWh]") ' WorkerMsg(tMsgID.Normal, "Total FC = " & TotalFCspec.ToString("0.00") & " [g/kWh]")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment