From 4ea5c582fd8b4901e0d811afd96ff5db7cb5ad07 Mon Sep 17 00:00:00 2001 From: Markus Quaritsch <markus.quaritsch@tugraz.at> Date: Tue, 17 Sep 2019 14:42:28 +0200 Subject: [PATCH] refactoring whr system to include both, mechanical and electrical whr systems --- VECTO/GUI/EngineForm.Designer.vb | 690 ++++++++++++------ VECTO/GUI/EngineForm.vb | 154 +++- VECTO/Input Files/Engine.vb | 79 +- VECTO/OutputData/JSONFileWriter.vb | 90 ++- VECTO/install.ini | 8 + .../InputData/DeclarationInputData.cs | 6 +- VectoCommon/VectoCommon/Models/WHRType.cs | 38 +- .../Resources/XMLNames.Designer.cs | 27 + .../VectoCommon/Resources/XMLNames.resx | 9 + .../InputData/FileIO/JSON/JSONEngineData.cs | 132 ++-- .../XMLDeclarationEngineDataProvider.cs | 178 +++-- .../XMLEngineeringEngineDataProvider.cs | 30 +- .../Reader/ComponentData/WHRPowerReader.cs | 69 +- .../DeclarationDataAdapter.cs | 25 +- .../EngineeringDataAdapter.cs | 17 +- .../Simulation/Data/ModalResultField.cs | 4 +- .../Data/CombustionEngineData.cs | 4 +- .../Data/Engine/FuelConsumptionMap.cs | 2 +- .../Data/Engine/WHRPowerMap.cs | 6 +- .../Impl/CombustionEngine.cs | 51 +- .../Impl/StopStartCombustionEngine.cs | 12 +- .../OutputData/ModalDataContainer.cs | 2 +- .../OutputData/SummaryDataContainer.cs | 8 +- .../OutputData/XML/AttributeMappings.cs | 3 +- .../OutputData/XML/XMLDeclarationReport.cs | 9 +- VectoCore/VectoCore/Utils/DelaunayMap.cs | 2 + VectoCore/VectoCore/Utils/XMLDefinitions.cs | 3 +- VectoCore/VectoCore/VectoCore.csproj | 11 + .../VectoCoreTest/Models/WHRMapReaderTest.cs | 68 +- .../Utils/MockEngineDataProvider.cs | 4 +- 30 files changed, 1200 insertions(+), 541 deletions(-) create mode 100644 VECTO/install.ini diff --git a/VECTO/GUI/EngineForm.Designer.vb b/VECTO/GUI/EngineForm.Designer.vb index 9f2df7b39a..93a63de6c4 100644 --- a/VECTO/GUI/EngineForm.Designer.vb +++ b/VECTO/GUI/EngineForm.Designer.vb @@ -103,24 +103,6 @@ Partial Class EngineForm Me.Label18 = New System.Windows.Forms.Label() Me.cbFuelType = New System.Windows.Forms.ComboBox() Me.lblEngineCharacteristics = New System.Windows.Forms.Label() - Me.gbWHR = New System.Windows.Forms.GroupBox() - Me.Label36 = New System.Windows.Forms.Label() - Me.pnWHRDeclaration = New System.Windows.Forms.Panel() - Me.tbWHRRegPer = New System.Windows.Forms.TextBox() - Me.Label21 = New System.Windows.Forms.Label() - Me.tbWHRColdHot = New System.Windows.Forms.TextBox() - Me.Label22 = New System.Windows.Forms.Label() - Me.Label23 = New System.Windows.Forms.Label() - Me.Label24 = New System.Windows.Forms.Label() - Me.Label25 = New System.Windows.Forms.Label() - Me.tbWHRMotorway = New System.Windows.Forms.TextBox() - Me.tbWHRUrban = New System.Windows.Forms.TextBox() - Me.tbWHRRural = New System.Windows.Forms.TextBox() - Me.pnWhrEngineering = New System.Windows.Forms.Panel() - Me.tbWHREngineering = New System.Windows.Forms.TextBox() - Me.Label26 = New System.Windows.Forms.Label() - Me.Label19 = New System.Windows.Forms.Label() - Me.cbWHRType = New System.Windows.Forms.ComboBox() Me.tbDualFuel = New System.Windows.Forms.TabControl() Me.tpPrimaryfuel = New System.Windows.Forms.TabPage() Me.tpSecondaryFuel = New System.Windows.Forms.TabPage() @@ -147,7 +129,45 @@ Partial Class EngineForm Me.cbFuelType2 = New System.Windows.Forms.ComboBox() Me.Label35 = New System.Windows.Forms.Label() Me.cbDualFuel = New System.Windows.Forms.CheckBox() + Me.tbWHR = New System.Windows.Forms.TabControl() + Me.tbElectricalWHR = New System.Windows.Forms.TabPage() + Me.tbMechanicalWHR = New System.Windows.Forms.TabPage() + Me.Label36 = New System.Windows.Forms.Label() + Me.pnElWHRDeclaration = New System.Windows.Forms.Panel() Me.lblWHRRegPer = New System.Windows.Forms.Label() + Me.tbElWHRRegPer = New System.Windows.Forms.TextBox() + Me.Label21 = New System.Windows.Forms.Label() + Me.tbElWHRColdHot = New System.Windows.Forms.TextBox() + Me.Label22 = New System.Windows.Forms.Label() + Me.Label23 = New System.Windows.Forms.Label() + Me.Label24 = New System.Windows.Forms.Label() + Me.Label25 = New System.Windows.Forms.Label() + Me.tbElWHRMotorway = New System.Windows.Forms.TextBox() + Me.tbElWHRUrban = New System.Windows.Forms.TextBox() + Me.tbElWHRRural = New System.Windows.Forms.TextBox() + Me.pnElWhrEngineering = New System.Windows.Forms.Panel() + Me.tbElWHREngineering = New System.Windows.Forms.TextBox() + Me.Label26 = New System.Windows.Forms.Label() + Me.Label37 = New System.Windows.Forms.Label() + Me.pnMechWhrDeclaration = New System.Windows.Forms.Panel() + Me.Label38 = New System.Windows.Forms.Label() + Me.tbMechWHRRegPerCF = New System.Windows.Forms.TextBox() + Me.Label39 = New System.Windows.Forms.Label() + Me.tbMechWHRBFColdHot = New System.Windows.Forms.TextBox() + Me.Label42 = New System.Windows.Forms.Label() + Me.Label43 = New System.Windows.Forms.Label() + Me.Label44 = New System.Windows.Forms.Label() + Me.Label45 = New System.Windows.Forms.Label() + Me.tbMechWHRMotorway = New System.Windows.Forms.TextBox() + Me.tbMechWHRUrban = New System.Windows.Forms.TextBox() + Me.tbMechWHRRural = New System.Windows.Forms.TextBox() + Me.pnMechWhrEngineering = New System.Windows.Forms.Panel() + Me.tbMechWHREngineering = New System.Windows.Forms.TextBox() + Me.Label46 = New System.Windows.Forms.Label() + Me.TabPage1 = New System.Windows.Forms.TabPage() + Me.cbMechWHRInMap = New System.Windows.Forms.CheckBox() + Me.cbMechWHRNotConnectedCrankshaft = New System.Windows.Forms.CheckBox() + Me.cbElWHR = New System.Windows.Forms.CheckBox() Me.ToolStrip1.SuspendLayout Me.StatusStrip1.SuspendLayout CType(Me.PictureBox1,System.ComponentModel.ISupportInitialize).BeginInit @@ -157,15 +177,20 @@ Partial Class EngineForm Me.PnWhtcDeclaration.SuspendLayout Me.PnWhtcEngineering.SuspendLayout CType(Me.PicBox,System.ComponentModel.ISupportInitialize).BeginInit - Me.gbWHR.SuspendLayout - Me.pnWHRDeclaration.SuspendLayout - Me.pnWhrEngineering.SuspendLayout Me.tbDualFuel.SuspendLayout Me.tpPrimaryfuel.SuspendLayout Me.tpSecondaryFuel.SuspendLayout Me.GroupBox1.SuspendLayout Me.pnWhtcFuel2.SuspendLayout Me.pnEngCFFuel2.SuspendLayout + Me.tbWHR.SuspendLayout + Me.tbElectricalWHR.SuspendLayout + Me.tbMechanicalWHR.SuspendLayout + Me.pnElWHRDeclaration.SuspendLayout + Me.pnElWhrEngineering.SuspendLayout + Me.pnMechWhrDeclaration.SuspendLayout + Me.pnMechWhrEngineering.SuspendLayout + Me.TabPage1.SuspendLayout Me.SuspendLayout ' 'TbIdleSpeed @@ -222,7 +247,7 @@ Partial Class EngineForm ' Me.ButCancel.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right),System.Windows.Forms.AnchorStyles) Me.ButCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel - Me.ButCancel.Location = New System.Drawing.Point(916, 586) + Me.ButCancel.Location = New System.Drawing.Point(916, 552) Me.ButCancel.Name = "ButCancel" Me.ButCancel.Size = New System.Drawing.Size(75, 23) Me.ButCancel.TabIndex = 13 @@ -232,7 +257,7 @@ Partial Class EngineForm 'ButOK ' Me.ButOK.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right),System.Windows.Forms.AnchorStyles) - Me.ButOK.Location = New System.Drawing.Point(835, 586) + Me.ButOK.Location = New System.Drawing.Point(835, 552) Me.ButOK.Name = "ButOK" Me.ButOK.Size = New System.Drawing.Size(75, 23) Me.ButOK.TabIndex = 12 @@ -321,7 +346,7 @@ Partial Class EngineForm 'StatusStrip1 ' Me.StatusStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.LbStatus}) - Me.StatusStrip1.Location = New System.Drawing.Point(0, 612) + Me.StatusStrip1.Location = New System.Drawing.Point(0, 578) Me.StatusStrip1.Name = "StatusStrip1" Me.StatusStrip1.Size = New System.Drawing.Size(1003, 22) Me.StatusStrip1.SizingGrip = false @@ -599,13 +624,13 @@ Partial Class EngineForm Me.PicBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle Me.PicBox.Location = New System.Drawing.Point(503, 28) Me.PicBox.Name = "PicBox" - Me.PicBox.Size = New System.Drawing.Size(482, 336) + Me.PicBox.Size = New System.Drawing.Size(482, 323) Me.PicBox.TabIndex = 40 Me.PicBox.TabStop = false ' 'TbFLD ' - Me.TbFLD.Location = New System.Drawing.Point(12, 239) + Me.TbFLD.Location = New System.Drawing.Point(12, 241) Me.TbFLD.Name = "TbFLD" Me.TbFLD.Size = New System.Drawing.Size(434, 20) Me.TbFLD.TabIndex = 5 @@ -613,7 +638,7 @@ Partial Class EngineForm 'Label14 ' Me.Label14.AutoSize = true - Me.Label14.Location = New System.Drawing.Point(12, 223) + Me.Label14.Location = New System.Drawing.Point(12, 225) Me.Label14.Name = "Label14" Me.Label14.Size = New System.Drawing.Size(128, 13) Me.Label14.TabIndex = 38 @@ -622,7 +647,7 @@ Partial Class EngineForm 'BtFLD ' Me.BtFLD.Image = Global.TUGraz.VECTO.My.Resources.Resources.Open_icon - Me.BtFLD.Location = New System.Drawing.Point(446, 237) + Me.BtFLD.Location = New System.Drawing.Point(446, 239) Me.BtFLD.Name = "BtFLD" Me.BtFLD.Size = New System.Drawing.Size(24, 24) Me.BtFLD.TabIndex = 6 @@ -632,7 +657,7 @@ Partial Class EngineForm 'BtFLDopen ' Me.BtFLDopen.Image = Global.TUGraz.VECTO.My.Resources.Resources.application_export_icon_small - Me.BtFLDopen.Location = New System.Drawing.Point(469, 237) + Me.BtFLDopen.Location = New System.Drawing.Point(469, 239) Me.BtFLDopen.Name = "BtFLDopen" Me.BtFLDopen.Size = New System.Drawing.Size(24, 24) Me.BtFLDopen.TabIndex = 7 @@ -734,174 +759,11 @@ Partial Class EngineForm 'lblEngineCharacteristics ' Me.lblEngineCharacteristics.AutoSize = true - Me.lblEngineCharacteristics.Location = New System.Drawing.Point(505, 370) + Me.lblEngineCharacteristics.Location = New System.Drawing.Point(506, 354) Me.lblEngineCharacteristics.Name = "lblEngineCharacteristics" Me.lblEngineCharacteristics.Size = New System.Drawing.Size(0, 13) Me.lblEngineCharacteristics.TabIndex = 52 ' - 'gbWHR - ' - Me.gbWHR.Controls.Add(Me.Label36) - Me.gbWHR.Controls.Add(Me.pnWHRDeclaration) - Me.gbWHR.Controls.Add(Me.pnWhrEngineering) - Me.gbWHR.Location = New System.Drawing.Point(504, 392) - Me.gbWHR.Name = "gbWHR" - Me.gbWHR.Size = New System.Drawing.Size(481, 155) - Me.gbWHR.TabIndex = 53 - Me.gbWHR.TabStop = false - Me.gbWHR.Text = "WHR Correction Factors" - ' - 'Label36 - ' - Me.Label36.AutoSize = true - Me.Label36.Location = New System.Drawing.Point(5, 132) - Me.Label36.Name = "Label36" - Me.Label36.Size = New System.Drawing.Size(408, 13) - Me.Label36.TabIndex = 11 - Me.Label36.Text = "Note: Electric power generated by WHR has to be provided in FC-Map of primary fue"& _ - "l" - ' - 'pnWHRDeclaration - ' - Me.pnWHRDeclaration.Controls.Add(Me.lblWHRRegPer) - Me.pnWHRDeclaration.Controls.Add(Me.tbWHRRegPer) - Me.pnWHRDeclaration.Controls.Add(Me.Label21) - Me.pnWHRDeclaration.Controls.Add(Me.tbWHRColdHot) - Me.pnWHRDeclaration.Controls.Add(Me.Label22) - Me.pnWHRDeclaration.Controls.Add(Me.Label23) - Me.pnWHRDeclaration.Controls.Add(Me.Label24) - Me.pnWHRDeclaration.Controls.Add(Me.Label25) - Me.pnWHRDeclaration.Controls.Add(Me.tbWHRMotorway) - Me.pnWHRDeclaration.Controls.Add(Me.tbWHRUrban) - Me.pnWHRDeclaration.Controls.Add(Me.tbWHRRural) - Me.pnWHRDeclaration.Location = New System.Drawing.Point(4, 19) - Me.pnWHRDeclaration.Name = "pnWHRDeclaration" - Me.pnWHRDeclaration.Size = New System.Drawing.Size(472, 74) - Me.pnWHRDeclaration.TabIndex = 10 - ' - 'tbWHRRegPer - ' - Me.tbWHRRegPer.Location = New System.Drawing.Point(402, 46) - Me.tbWHRRegPer.Name = "tbWHRRegPer" - Me.tbWHRRegPer.Size = New System.Drawing.Size(57, 20) - Me.tbWHRRegPer.TabIndex = 10 - ' - 'Label21 - ' - Me.Label21.AutoSize = true - Me.Label21.Location = New System.Drawing.Point(47, 49) - Me.Label21.Name = "Label21" - Me.Label21.Size = New System.Drawing.Size(177, 13) - Me.Label21.TabIndex = 5 - Me.Label21.Text = "Cold/Hot Emission Balancing Factor" - ' - 'tbWHRColdHot - ' - Me.tbWHRColdHot.Location = New System.Drawing.Point(230, 46) - Me.tbWHRColdHot.Name = "tbWHRColdHot" - Me.tbWHRColdHot.Size = New System.Drawing.Size(57, 20) - Me.tbWHRColdHot.TabIndex = 6 - ' - 'Label22 - ' - Me.Label22.AutoSize = true - Me.Label22.Location = New System.Drawing.Point(38, 23) - Me.Label22.Name = "Label22" - Me.Label22.Size = New System.Drawing.Size(36, 13) - Me.Label22.TabIndex = 0 - Me.Label22.Text = "Urban" - ' - 'Label23 - ' - Me.Label23.AutoSize = true - Me.Label23.Location = New System.Drawing.Point(191, 27) - Me.Label23.Name = "Label23" - Me.Label23.Size = New System.Drawing.Size(32, 13) - Me.Label23.TabIndex = 0 - Me.Label23.Text = "Rural" - ' - 'Label24 - ' - Me.Label24.AutoSize = true - Me.Label24.Location = New System.Drawing.Point(1, 1) - Me.Label24.Name = "Label24" - Me.Label24.Size = New System.Drawing.Size(242, 13) - Me.Label24.TabIndex = 3 - Me.Label24.Text = "Correction Factors calculated with VECTO-Engine" - ' - 'Label25 - ' - Me.Label25.AutoSize = true - Me.Label25.Location = New System.Drawing.Point(342, 23) - Me.Label25.Name = "Label25" - Me.Label25.Size = New System.Drawing.Size(53, 13) - Me.Label25.TabIndex = 0 - Me.Label25.Text = "Motorway" - Me.Label25.TextAlign = System.Drawing.ContentAlignment.TopRight - ' - 'tbWHRMotorway - ' - Me.tbWHRMotorway.Location = New System.Drawing.Point(402, 20) - Me.tbWHRMotorway.Name = "tbWHRMotorway" - Me.tbWHRMotorway.Size = New System.Drawing.Size(57, 20) - Me.tbWHRMotorway.TabIndex = 2 - ' - 'tbWHRUrban - ' - Me.tbWHRUrban.Location = New System.Drawing.Point(81, 20) - Me.tbWHRUrban.Name = "tbWHRUrban" - Me.tbWHRUrban.Size = New System.Drawing.Size(57, 20) - Me.tbWHRUrban.TabIndex = 0 - ' - 'tbWHRRural - ' - Me.tbWHRRural.Location = New System.Drawing.Point(230, 20) - Me.tbWHRRural.Name = "tbWHRRural" - Me.tbWHRRural.Size = New System.Drawing.Size(57, 20) - Me.tbWHRRural.TabIndex = 1 - ' - 'pnWhrEngineering - ' - Me.pnWhrEngineering.Controls.Add(Me.tbWHREngineering) - Me.pnWhrEngineering.Controls.Add(Me.Label26) - Me.pnWhrEngineering.Location = New System.Drawing.Point(4, 99) - Me.pnWhrEngineering.Name = "pnWhrEngineering" - Me.pnWhrEngineering.Size = New System.Drawing.Size(472, 30) - Me.pnWhrEngineering.TabIndex = 9 - ' - 'tbWHREngineering - ' - Me.tbWHREngineering.Location = New System.Drawing.Point(194, 3) - Me.tbWHREngineering.Name = "tbWHREngineering" - Me.tbWHREngineering.Size = New System.Drawing.Size(57, 20) - Me.tbWHREngineering.TabIndex = 5 - ' - 'Label26 - ' - Me.Label26.AutoSize = true - Me.Label26.Location = New System.Drawing.Point(125, 6) - Me.Label26.Name = "Label26" - Me.Label26.Size = New System.Drawing.Size(63, 13) - Me.Label26.TabIndex = 6 - Me.Label26.Text = "Engineering" - ' - 'Label19 - ' - Me.Label19.AutoSize = true - Me.Label19.Location = New System.Drawing.Point(57, 160) - Me.Label19.Name = "Label19" - Me.Label19.Size = New System.Drawing.Size(61, 13) - Me.Label19.TabIndex = 54 - Me.Label19.Text = "WHR Type" - ' - 'cbWHRType - ' - Me.cbWHRType.FormattingEnabled = true - Me.cbWHRType.Location = New System.Drawing.Point(123, 157) - Me.cbWHRType.Name = "cbWHRType" - Me.cbWHRType.Size = New System.Drawing.Size(129, 21) - Me.cbWHRType.TabIndex = 55 - ' 'tbDualFuel ' Me.tbDualFuel.Controls.Add(Me.tpPrimaryfuel) @@ -1146,34 +1008,389 @@ Partial Class EngineForm 'cbDualFuel ' Me.cbDualFuel.AutoSize = true - Me.cbDualFuel.Location = New System.Drawing.Point(123, 191) + Me.cbDualFuel.CheckAlign = System.Drawing.ContentAlignment.MiddleRight + Me.cbDualFuel.Location = New System.Drawing.Point(30, 160) Me.cbDualFuel.Name = "cbDualFuel" Me.cbDualFuel.Size = New System.Drawing.Size(107, 17) Me.cbDualFuel.TabIndex = 58 Me.cbDualFuel.Text = "Dual Fuel Engine" Me.cbDualFuel.UseVisualStyleBackColor = true ' + 'tbWHR + ' + Me.tbWHR.Controls.Add(Me.TabPage1) + Me.tbWHR.Controls.Add(Me.tbElectricalWHR) + Me.tbWHR.Controls.Add(Me.tbMechanicalWHR) + Me.tbWHR.Location = New System.Drawing.Point(503, 376) + Me.tbWHR.Name = "tbWHR" + Me.tbWHR.SelectedIndex = 0 + Me.tbWHR.Size = New System.Drawing.Size(482, 171) + Me.tbWHR.TabIndex = 59 + ' + 'tbElectricalWHR + ' + Me.tbElectricalWHR.Controls.Add(Me.Label36) + Me.tbElectricalWHR.Controls.Add(Me.pnElWHRDeclaration) + Me.tbElectricalWHR.Controls.Add(Me.pnElWhrEngineering) + Me.tbElectricalWHR.Location = New System.Drawing.Point(4, 22) + Me.tbElectricalWHR.Name = "tbElectricalWHR" + Me.tbElectricalWHR.Padding = New System.Windows.Forms.Padding(3) + Me.tbElectricalWHR.Size = New System.Drawing.Size(474, 145) + Me.tbElectricalWHR.TabIndex = 0 + Me.tbElectricalWHR.Text = "Correction Factors Electrical WHR" + Me.tbElectricalWHR.UseVisualStyleBackColor = true + ' + 'tbMechanicalWHR + ' + Me.tbMechanicalWHR.Controls.Add(Me.Label37) + Me.tbMechanicalWHR.Controls.Add(Me.pnMechWhrDeclaration) + Me.tbMechanicalWHR.Controls.Add(Me.pnMechWhrEngineering) + Me.tbMechanicalWHR.Location = New System.Drawing.Point(4, 22) + Me.tbMechanicalWHR.Name = "tbMechanicalWHR" + Me.tbMechanicalWHR.Padding = New System.Windows.Forms.Padding(3) + Me.tbMechanicalWHR.Size = New System.Drawing.Size(474, 145) + Me.tbMechanicalWHR.TabIndex = 1 + Me.tbMechanicalWHR.Text = "Correction Factors Mechanical WHR" + Me.tbMechanicalWHR.UseVisualStyleBackColor = true + ' + 'Label36 + ' + Me.Label36.AutoSize = true + Me.Label36.Location = New System.Drawing.Point(7, 119) + Me.Label36.Name = "Label36" + Me.Label36.Size = New System.Drawing.Size(408, 13) + Me.Label36.TabIndex = 14 + Me.Label36.Text = "Note: Electric power generated by WHR has to be provided in FC-Map of primary fue"& _ + "l" + ' + 'pnElWHRDeclaration + ' + Me.pnElWHRDeclaration.Controls.Add(Me.lblWHRRegPer) + Me.pnElWHRDeclaration.Controls.Add(Me.tbElWHRRegPer) + Me.pnElWHRDeclaration.Controls.Add(Me.Label21) + Me.pnElWHRDeclaration.Controls.Add(Me.tbElWHRColdHot) + Me.pnElWHRDeclaration.Controls.Add(Me.Label22) + Me.pnElWHRDeclaration.Controls.Add(Me.Label23) + Me.pnElWHRDeclaration.Controls.Add(Me.Label24) + Me.pnElWHRDeclaration.Controls.Add(Me.Label25) + Me.pnElWHRDeclaration.Controls.Add(Me.tbElWHRMotorway) + Me.pnElWHRDeclaration.Controls.Add(Me.tbElWHRUrban) + Me.pnElWHRDeclaration.Controls.Add(Me.tbElWHRRural) + Me.pnElWHRDeclaration.Location = New System.Drawing.Point(6, 6) + Me.pnElWHRDeclaration.Name = "pnElWHRDeclaration" + Me.pnElWHRDeclaration.Size = New System.Drawing.Size(458, 74) + Me.pnElWHRDeclaration.TabIndex = 13 + ' 'lblWHRRegPer ' Me.lblWHRRegPer.AutoSize = true - Me.lblWHRRegPer.Location = New System.Drawing.Point(306, 49) + Me.lblWHRRegPer.Location = New System.Drawing.Point(280, 49) Me.lblWHRRegPer.Name = "lblWHRRegPer" Me.lblWHRRegPer.Size = New System.Drawing.Size(89, 13) Me.lblWHRRegPer.TabIndex = 11 Me.lblWHRRegPer.Text = "Reg. Per. Corr. F." ' + 'tbElWHRRegPer + ' + Me.tbElWHRRegPer.Location = New System.Drawing.Point(376, 46) + Me.tbElWHRRegPer.Name = "tbElWHRRegPer" + Me.tbElWHRRegPer.Size = New System.Drawing.Size(57, 20) + Me.tbElWHRRegPer.TabIndex = 10 + ' + 'Label21 + ' + Me.Label21.AutoSize = true + Me.Label21.Location = New System.Drawing.Point(11, 49) + Me.Label21.Name = "Label21" + Me.Label21.Size = New System.Drawing.Size(177, 13) + Me.Label21.TabIndex = 5 + Me.Label21.Text = "Cold/Hot Emission Balancing Factor" + ' + 'tbElWHRColdHot + ' + Me.tbElWHRColdHot.Location = New System.Drawing.Point(194, 46) + Me.tbElWHRColdHot.Name = "tbElWHRColdHot" + Me.tbElWHRColdHot.Size = New System.Drawing.Size(57, 20) + Me.tbElWHRColdHot.TabIndex = 6 + ' + 'Label22 + ' + Me.Label22.AutoSize = true + Me.Label22.Location = New System.Drawing.Point(21, 23) + Me.Label22.Name = "Label22" + Me.Label22.Size = New System.Drawing.Size(36, 13) + Me.Label22.TabIndex = 0 + Me.Label22.Text = "Urban" + ' + 'Label23 + ' + Me.Label23.AutoSize = true + Me.Label23.Location = New System.Drawing.Point(155, 27) + Me.Label23.Name = "Label23" + Me.Label23.Size = New System.Drawing.Size(32, 13) + Me.Label23.TabIndex = 0 + Me.Label23.Text = "Rural" + ' + 'Label24 + ' + Me.Label24.AutoSize = true + Me.Label24.Location = New System.Drawing.Point(1, 1) + Me.Label24.Name = "Label24" + Me.Label24.Size = New System.Drawing.Size(242, 13) + Me.Label24.TabIndex = 3 + Me.Label24.Text = "Correction Factors calculated with VECTO-Engine" + ' + 'Label25 + ' + Me.Label25.AutoSize = true + Me.Label25.Location = New System.Drawing.Point(316, 23) + Me.Label25.Name = "Label25" + Me.Label25.Size = New System.Drawing.Size(53, 13) + Me.Label25.TabIndex = 0 + Me.Label25.Text = "Motorway" + Me.Label25.TextAlign = System.Drawing.ContentAlignment.TopRight + ' + 'tbElWHRMotorway + ' + Me.tbElWHRMotorway.Location = New System.Drawing.Point(376, 20) + Me.tbElWHRMotorway.Name = "tbElWHRMotorway" + Me.tbElWHRMotorway.Size = New System.Drawing.Size(57, 20) + Me.tbElWHRMotorway.TabIndex = 2 + ' + 'tbElWHRUrban + ' + Me.tbElWHRUrban.Location = New System.Drawing.Point(64, 20) + Me.tbElWHRUrban.Name = "tbElWHRUrban" + Me.tbElWHRUrban.Size = New System.Drawing.Size(57, 20) + Me.tbElWHRUrban.TabIndex = 0 + ' + 'tbElWHRRural + ' + Me.tbElWHRRural.Location = New System.Drawing.Point(194, 20) + Me.tbElWHRRural.Name = "tbElWHRRural" + Me.tbElWHRRural.Size = New System.Drawing.Size(57, 20) + Me.tbElWHRRural.TabIndex = 1 + ' + 'pnElWhrEngineering + ' + Me.pnElWhrEngineering.Controls.Add(Me.tbElWHREngineering) + Me.pnElWhrEngineering.Controls.Add(Me.Label26) + Me.pnElWhrEngineering.Location = New System.Drawing.Point(6, 86) + Me.pnElWhrEngineering.Name = "pnElWhrEngineering" + Me.pnElWhrEngineering.Size = New System.Drawing.Size(458, 30) + Me.pnElWhrEngineering.TabIndex = 12 + ' + 'tbElWHREngineering + ' + Me.tbElWHREngineering.Location = New System.Drawing.Point(194, 3) + Me.tbElWHREngineering.Name = "tbElWHREngineering" + Me.tbElWHREngineering.Size = New System.Drawing.Size(57, 20) + Me.tbElWHREngineering.TabIndex = 5 + ' + 'Label26 + ' + Me.Label26.AutoSize = true + Me.Label26.Location = New System.Drawing.Point(125, 6) + Me.Label26.Name = "Label26" + Me.Label26.Size = New System.Drawing.Size(63, 13) + Me.Label26.TabIndex = 6 + Me.Label26.Text = "Engineering" + ' + 'Label37 + ' + Me.Label37.AutoSize = true + Me.Label37.Location = New System.Drawing.Point(7, 119) + Me.Label37.Name = "Label37" + Me.Label37.Size = New System.Drawing.Size(426, 13) + Me.Label37.TabIndex = 14 + Me.Label37.Text = "Note: Mechanica power generated by WHR has to be provided in FC-Map of primary fu"& _ + "el" + ' + 'pnMechWhrDeclaration + ' + Me.pnMechWhrDeclaration.Controls.Add(Me.Label38) + Me.pnMechWhrDeclaration.Controls.Add(Me.tbMechWHRRegPerCF) + Me.pnMechWhrDeclaration.Controls.Add(Me.Label39) + Me.pnMechWhrDeclaration.Controls.Add(Me.tbMechWHRBFColdHot) + Me.pnMechWhrDeclaration.Controls.Add(Me.Label42) + Me.pnMechWhrDeclaration.Controls.Add(Me.Label43) + Me.pnMechWhrDeclaration.Controls.Add(Me.Label44) + Me.pnMechWhrDeclaration.Controls.Add(Me.Label45) + Me.pnMechWhrDeclaration.Controls.Add(Me.tbMechWHRMotorway) + Me.pnMechWhrDeclaration.Controls.Add(Me.tbMechWHRUrban) + Me.pnMechWhrDeclaration.Controls.Add(Me.tbMechWHRRural) + Me.pnMechWhrDeclaration.Location = New System.Drawing.Point(6, 6) + Me.pnMechWhrDeclaration.Name = "pnMechWhrDeclaration" + Me.pnMechWhrDeclaration.Size = New System.Drawing.Size(458, 74) + Me.pnMechWhrDeclaration.TabIndex = 13 + ' + 'Label38 + ' + Me.Label38.AutoSize = true + Me.Label38.Location = New System.Drawing.Point(280, 49) + Me.Label38.Name = "Label38" + Me.Label38.Size = New System.Drawing.Size(89, 13) + Me.Label38.TabIndex = 11 + Me.Label38.Text = "Reg. Per. Corr. F." + ' + 'tbMechWHRRegPerCF + ' + Me.tbMechWHRRegPerCF.Location = New System.Drawing.Point(376, 46) + Me.tbMechWHRRegPerCF.Name = "tbMechWHRRegPerCF" + Me.tbMechWHRRegPerCF.Size = New System.Drawing.Size(57, 20) + Me.tbMechWHRRegPerCF.TabIndex = 10 + ' + 'Label39 + ' + Me.Label39.AutoSize = true + Me.Label39.Location = New System.Drawing.Point(11, 49) + Me.Label39.Name = "Label39" + Me.Label39.Size = New System.Drawing.Size(177, 13) + Me.Label39.TabIndex = 5 + Me.Label39.Text = "Cold/Hot Emission Balancing Factor" + ' + 'tbMechWHRBFColdHot + ' + Me.tbMechWHRBFColdHot.Location = New System.Drawing.Point(194, 46) + Me.tbMechWHRBFColdHot.Name = "tbMechWHRBFColdHot" + Me.tbMechWHRBFColdHot.Size = New System.Drawing.Size(57, 20) + Me.tbMechWHRBFColdHot.TabIndex = 6 + ' + 'Label42 + ' + Me.Label42.AutoSize = true + Me.Label42.Location = New System.Drawing.Point(21, 23) + Me.Label42.Name = "Label42" + Me.Label42.Size = New System.Drawing.Size(36, 13) + Me.Label42.TabIndex = 0 + Me.Label42.Text = "Urban" + ' + 'Label43 + ' + Me.Label43.AutoSize = true + Me.Label43.Location = New System.Drawing.Point(155, 27) + Me.Label43.Name = "Label43" + Me.Label43.Size = New System.Drawing.Size(32, 13) + Me.Label43.TabIndex = 0 + Me.Label43.Text = "Rural" + ' + 'Label44 + ' + Me.Label44.AutoSize = true + Me.Label44.Location = New System.Drawing.Point(1, 1) + Me.Label44.Name = "Label44" + Me.Label44.Size = New System.Drawing.Size(242, 13) + Me.Label44.TabIndex = 3 + Me.Label44.Text = "Correction Factors calculated with VECTO-Engine" + ' + 'Label45 + ' + Me.Label45.AutoSize = true + Me.Label45.Location = New System.Drawing.Point(316, 23) + Me.Label45.Name = "Label45" + Me.Label45.Size = New System.Drawing.Size(53, 13) + Me.Label45.TabIndex = 0 + Me.Label45.Text = "Motorway" + Me.Label45.TextAlign = System.Drawing.ContentAlignment.TopRight + ' + 'tbMechWHRMotorway + ' + Me.tbMechWHRMotorway.Location = New System.Drawing.Point(376, 20) + Me.tbMechWHRMotorway.Name = "tbMechWHRMotorway" + Me.tbMechWHRMotorway.Size = New System.Drawing.Size(57, 20) + Me.tbMechWHRMotorway.TabIndex = 2 + ' + 'tbMechWHRUrban + ' + Me.tbMechWHRUrban.Location = New System.Drawing.Point(64, 20) + Me.tbMechWHRUrban.Name = "tbMechWHRUrban" + Me.tbMechWHRUrban.Size = New System.Drawing.Size(57, 20) + Me.tbMechWHRUrban.TabIndex = 0 + ' + 'tbMechWHRRural + ' + Me.tbMechWHRRural.Location = New System.Drawing.Point(194, 20) + Me.tbMechWHRRural.Name = "tbMechWHRRural" + Me.tbMechWHRRural.Size = New System.Drawing.Size(57, 20) + Me.tbMechWHRRural.TabIndex = 1 + ' + 'pnMechWhrEngineering + ' + Me.pnMechWhrEngineering.Controls.Add(Me.tbMechWHREngineering) + Me.pnMechWhrEngineering.Controls.Add(Me.Label46) + Me.pnMechWhrEngineering.Location = New System.Drawing.Point(6, 86) + Me.pnMechWhrEngineering.Name = "pnMechWhrEngineering" + Me.pnMechWhrEngineering.Size = New System.Drawing.Size(458, 30) + Me.pnMechWhrEngineering.TabIndex = 12 + ' + 'tbMechWHREngineering + ' + Me.tbMechWHREngineering.Location = New System.Drawing.Point(194, 3) + Me.tbMechWHREngineering.Name = "tbMechWHREngineering" + Me.tbMechWHREngineering.Size = New System.Drawing.Size(57, 20) + Me.tbMechWHREngineering.TabIndex = 5 + ' + 'Label46 + ' + Me.Label46.AutoSize = true + Me.Label46.Location = New System.Drawing.Point(125, 6) + Me.Label46.Name = "Label46" + Me.Label46.Size = New System.Drawing.Size(63, 13) + Me.Label46.TabIndex = 6 + Me.Label46.Text = "Engineering" + ' + 'TabPage1 + ' + Me.TabPage1.Controls.Add(Me.cbElWHR) + Me.TabPage1.Controls.Add(Me.cbMechWHRNotConnectedCrankshaft) + Me.TabPage1.Controls.Add(Me.cbMechWHRInMap) + Me.TabPage1.Location = New System.Drawing.Point(4, 22) + Me.TabPage1.Name = "TabPage1" + Me.TabPage1.Size = New System.Drawing.Size(474, 145) + Me.TabPage1.TabIndex = 2 + Me.TabPage1.Text = "tbWHRType" + Me.TabPage1.UseVisualStyleBackColor = true + ' + 'cbMechWHRInMap + ' + Me.cbMechWHRInMap.AutoSize = true + Me.cbMechWHRInMap.Location = New System.Drawing.Point(17, 12) + Me.cbMechWHRInMap.Name = "cbMechWHRInMap" + Me.cbMechWHRInMap.Size = New System.Drawing.Size(287, 17) + Me.cbMechWHRInMap.TabIndex = 0 + Me.cbMechWHRInMap.Text = "Mechanical WHR System incuded in FC measurements" + Me.cbMechWHRInMap.UseVisualStyleBackColor = true + ' + 'cbMechWHRNotConnectedCrankshaft + ' + Me.cbMechWHRNotConnectedCrankshaft.AutoSize = true + Me.cbMechWHRNotConnectedCrankshaft.Location = New System.Drawing.Point(17, 35) + Me.cbMechWHRNotConnectedCrankshaft.Name = "cbMechWHRNotConnectedCrankshaft" + Me.cbMechWHRNotConnectedCrankshaft.Size = New System.Drawing.Size(303, 17) + Me.cbMechWHRNotConnectedCrankshaft.TabIndex = 1 + Me.cbMechWHRNotConnectedCrankshaft.Text = "Mechanical WHR System not connected to the crankshaft" + Me.cbMechWHRNotConnectedCrankshaft.UseVisualStyleBackColor = true + ' + 'cbElWHR + ' + Me.cbElWHR.AutoSize = true + Me.cbElWHR.Location = New System.Drawing.Point(17, 58) + Me.cbElWHR.Name = "cbElWHR" + Me.cbElWHR.Size = New System.Drawing.Size(136, 17) + Me.cbElWHR.TabIndex = 2 + Me.cbElWHR.Text = "Electrical WHR System" + Me.cbElWHR.UseVisualStyleBackColor = true + ' 'EngineForm ' Me.AcceptButton = Me.ButOK Me.AutoScaleDimensions = New System.Drawing.SizeF(6!, 13!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.CancelButton = Me.ButCancel - Me.ClientSize = New System.Drawing.Size(1003, 634) + Me.ClientSize = New System.Drawing.Size(1003, 600) + Me.Controls.Add(Me.tbWHR) Me.Controls.Add(Me.cbDualFuel) Me.Controls.Add(Me.tbDualFuel) - Me.Controls.Add(Me.cbWHRType) - Me.Controls.Add(Me.Label19) - Me.Controls.Add(Me.gbWHR) Me.Controls.Add(Me.lblEngineCharacteristics) Me.Controls.Add(Me.tbMaxTorque) Me.Controls.Add(Me.Label16) @@ -1224,12 +1441,6 @@ Partial Class EngineForm Me.PnWhtcEngineering.ResumeLayout(false) Me.PnWhtcEngineering.PerformLayout CType(Me.PicBox,System.ComponentModel.ISupportInitialize).EndInit - Me.gbWHR.ResumeLayout(false) - Me.gbWHR.PerformLayout - Me.pnWHRDeclaration.ResumeLayout(false) - Me.pnWHRDeclaration.PerformLayout - Me.pnWhrEngineering.ResumeLayout(false) - Me.pnWhrEngineering.PerformLayout Me.tbDualFuel.ResumeLayout(false) Me.tpPrimaryfuel.ResumeLayout(false) Me.tpPrimaryfuel.PerformLayout @@ -1240,6 +1451,21 @@ Partial Class EngineForm Me.pnWhtcFuel2.PerformLayout Me.pnEngCFFuel2.ResumeLayout(false) Me.pnEngCFFuel2.PerformLayout + Me.tbWHR.ResumeLayout(false) + Me.tbElectricalWHR.ResumeLayout(false) + Me.tbElectricalWHR.PerformLayout + Me.tbMechanicalWHR.ResumeLayout(false) + Me.tbMechanicalWHR.PerformLayout + Me.pnElWHRDeclaration.ResumeLayout(false) + Me.pnElWHRDeclaration.PerformLayout + Me.pnElWhrEngineering.ResumeLayout(false) + Me.pnElWhrEngineering.PerformLayout + Me.pnMechWhrDeclaration.ResumeLayout(false) + Me.pnMechWhrDeclaration.PerformLayout + Me.pnMechWhrEngineering.ResumeLayout(false) + Me.pnMechWhrEngineering.PerformLayout + Me.TabPage1.ResumeLayout(false) + Me.TabPage1.PerformLayout Me.ResumeLayout(false) Me.PerformLayout @@ -1310,23 +1536,6 @@ End Sub Friend WithEvents Label18 As System.Windows.Forms.Label Friend WithEvents cbFuelType As System.Windows.Forms.ComboBox Friend WithEvents lblEngineCharacteristics As System.Windows.Forms.Label - Friend WithEvents gbWHR As GroupBox - Friend WithEvents pnWHRDeclaration As Panel - Friend WithEvents tbWHRRegPer As TextBox - Friend WithEvents Label21 As Label - Friend WithEvents tbWHRColdHot As TextBox - Friend WithEvents Label22 As Label - Friend WithEvents Label23 As Label - Friend WithEvents Label24 As Label - Friend WithEvents Label25 As Label - Friend WithEvents tbWHRMotorway As TextBox - Friend WithEvents tbWHRUrban As TextBox - Friend WithEvents tbWHRRural As TextBox - Friend WithEvents pnWhrEngineering As Panel - Friend WithEvents tbWHREngineering As TextBox - Friend WithEvents Label26 As Label - Friend WithEvents Label19 As Label - Friend WithEvents cbWHRType As ComboBox Friend WithEvents tbDualFuel As TabControl Friend WithEvents tpPrimaryfuel As TabPage Friend WithEvents tpSecondaryFuel As TabPage @@ -1353,6 +1562,43 @@ End Sub Friend WithEvents cbFuelType2 As ComboBox Friend WithEvents Label35 As Label Friend WithEvents cbDualFuel As CheckBox + Friend WithEvents tbWHR As TabControl + Friend WithEvents tbElectricalWHR As TabPage + Friend WithEvents tbMechanicalWHR As TabPage Friend WithEvents Label36 As Label + Friend WithEvents pnElWHRDeclaration As Panel Friend WithEvents lblWHRRegPer As Label + Friend WithEvents tbElWHRRegPer As TextBox + Friend WithEvents Label21 As Label + Friend WithEvents tbElWHRColdHot As TextBox + Friend WithEvents Label22 As Label + Friend WithEvents Label23 As Label + Friend WithEvents Label24 As Label + Friend WithEvents Label25 As Label + Friend WithEvents tbElWHRMotorway As TextBox + Friend WithEvents tbElWHRUrban As TextBox + Friend WithEvents tbElWHRRural As TextBox + Friend WithEvents pnElWhrEngineering As Panel + Friend WithEvents tbElWHREngineering As TextBox + Friend WithEvents Label26 As Label + Friend WithEvents Label37 As Label + Friend WithEvents pnMechWhrDeclaration As Panel + Friend WithEvents Label38 As Label + Friend WithEvents tbMechWHRRegPerCF As TextBox + Friend WithEvents Label39 As Label + Friend WithEvents tbMechWHRBFColdHot As TextBox + Friend WithEvents Label42 As Label + Friend WithEvents Label43 As Label + Friend WithEvents Label44 As Label + Friend WithEvents Label45 As Label + Friend WithEvents tbMechWHRMotorway As TextBox + Friend WithEvents tbMechWHRUrban As TextBox + Friend WithEvents tbMechWHRRural As TextBox + Friend WithEvents pnMechWhrEngineering As Panel + Friend WithEvents tbMechWHREngineering As TextBox + Friend WithEvents Label46 As Label + Friend WithEvents TabPage1 As TabPage + Friend WithEvents cbElWHR As CheckBox + Friend WithEvents cbMechWHRNotConnectedCrankshaft As CheckBox + Friend WithEvents cbMechWHRInMap As CheckBox End Class diff --git a/VECTO/GUI/EngineForm.vb b/VECTO/GUI/EngineForm.vb index c3e757f688..387e035f17 100644 --- a/VECTO/GUI/EngineForm.vb +++ b/VECTO/GUI/EngineForm.vb @@ -39,6 +39,8 @@ Public Class EngineForm Private _contextMenuFiles As String() Private SecondFuelTab As TabPage + private MechanicalWhrTab as TabPage + private ElectricalWhrTab as TabPage @@ -56,12 +58,20 @@ Public Class EngineForm PnWhtcDeclaration.Enabled = Cfg.DeclMode PnWhtcEngineering.Enabled = Not Cfg.DeclMode - pnWHRDeclaration.Enabled = Cfg.DeclMode - pnWhrEngineering.Enabled = Not Cfg.DeclMode + pnElWHRDeclaration.Enabled = Cfg.DeclMode + pnElWhrEngineering.Enabled = Not Cfg.DeclMode + + pnMechWHRDeclaration.Enabled = Cfg.DeclMode + pnMechWhrEngineering.Enabled = Not Cfg.DeclMode pnWhtcFuel2.Enabled = cfg.DeclMode pnEngCFFuel2.Enabled = not cfg.DeclMode + ElectricalWhrTab = tbWHR.TabPages(0) + MechanicalWhrTab = tbWHR.TabPages(1) + tbWHR.TabPages.Remove(ElectricalWhrTab) + tbWHR.TabPages.Remove(MechanicalWhrTab) + cbFuelType.Items.Clear() cbFuelType.ValueMember = "Value" cbFuelType.DisplayMember = "Label" @@ -76,16 +86,13 @@ Public Class EngineForm [Enum].GetValues(GetType(FuelType)).Cast (Of FuelType).Select( Function(type) New With {Key .Value = type, .Label = type.GetLabel()}).ToList() - cbWHRType.Items.Clear() - cbWHRType.ValueMember = "Value" - cbWHRType.DisplayMember = "Label" - cbWHRType.DataSource = [Enum].GetValues(GetType(WHRType)).cast(Of WHRType).select(Function(type) new With {Key .Value = type, .Label = type.GetLabel()}).ToList() - _changed = False SecondFuelTab = tbDualFuel.TabPages(1) tbDualFuel.TabPages.Remove(SecondFuelTab) + + NewEngine() End Sub @@ -186,13 +193,19 @@ Public Class EngineForm TbWHTCrural.Text = "" TbWHTCmw.Text = "" - tbWHREngineering.Text = "" - tbWHRColdHot.Text = "" - tbWHRRegPer.Text = "" - tbWHRRural.Text = "" - tbWHRUrban.Text = "" - tbWHRMotorway.Text = "" - + tbElWHREngineering.Text = "" + tbElWHRColdHot.Text = "" + tbElWHRRegPer.Text = "" + tbElWHRRural.Text = "" + tbElWHRUrban.Text = "" + tbElWHRMotorway.Text = "" + + tbMechWHREngineering.Text = "" + tbMechWHRBFColdHot.Text = "" + tbMechWHRRegPerCF.Text = "" + tbMechWHRRural.Text = "" + tbMechWHRUrban.Text = "" + tbMechWHRMotorway.Text = "" DeclInit() _engFile = "" @@ -276,22 +289,40 @@ Public Class EngineForm End If End If - - cbWHRType.SelectedValue = engine.WHRType - gbWHR.Enabled = engine.WHRType.IsElectrical() + cbMechWHRInMap.Checked = (engine.WHRType and WHRType.MechanicalOutputICE) <> 0 + cbMechWHRNotConnectedCrankshaft.Checked = (engine.WHRType and WHRType.MechanicalOutputDrivetrain) <> 0 + cbElWHR.Checked = (engine.WHRType and WHRType.ElectricalOutput) <> 0 + If (engine.WHRType.IsElectrical()) Then - Dim whr As IWHRData = enginemode.Wasteheatrecoverydata + Dim whr As IWHRData = enginemode.WasteHeatRecoveryDataElectrical If (Cfg.DeclMode) then - tbWHRRural.Text = whr.RuralCorrectionFactor.ToGUIFormat() - tbWHRUrban.Text = whr.UrbanCorrectionFactor.ToGUIFormat() - tbWHRMotorway.Text = whr.MotorwayCorrectionFactor.ToGUIFormat() - tbWHRColdHot.Text = whr.BFColdHot.ToGUIFormat() - tbWHRRegPer.Text = whr.CFRegPer.ToGUIFormat() + tbElWHRRural.Text = whr.RuralCorrectionFactor.ToGUIFormat() + tbElWHRUrban.Text = whr.UrbanCorrectionFactor.ToGUIFormat() + tbElWHRMotorway.Text = whr.MotorwayCorrectionFactor.ToGUIFormat() + tbElWHRColdHot.Text = whr.BFColdHot.ToGUIFormat() + tbElWHRRegPer.Text = whr.CFRegPer.ToGUIFormat() Else - tbWHREngineering.Text = whr.EngineeringCorrectionFactor.ToGUIFormat() + tbElWHREngineering.Text = whr.EngineeringCorrectionFactor.ToGUIFormat() end if End If + If (engine.WHRType and WHRType.MechanicalOutputDrivetrain) <> 0 Then + Dim whr As IWHRData = enginemode.WasteHeatRecoveryDataMechanical + If (Cfg.DeclMode) then + tbMechWHRRural.Text = whr.RuralCorrectionFactor.ToGUIFormat() + tbMechWHRUrban.Text = whr.UrbanCorrectionFactor.ToGUIFormat() + tbMechWHRMotorway.Text = whr.MotorwayCorrectionFactor.ToGUIFormat() + tbMechWHRBFColdHot.Text = whr.BFColdHot.ToGUIFormat() + tbMechWHRRegPerCF.Text = whr.CFRegPer.ToGUIFormat() + Else + tbMechWHREngineering.Text = whr.EngineeringCorrectionFactor.ToGUIFormat() + end if + Else + if (tbWHR.TabPages.Count > 1) then + tbWHR.TabPages.Remove(tbMechanicalWHR) + End If + End If + DeclInit() EngineFileBrowser.UpdateHistory(file) @@ -352,13 +383,26 @@ Public Class EngineForm engine.SecondaryEngineFuel.FuelTypeInput = CType(cbFuelType2.SelectedValue, FuelType) End If - engine.WHRTypeInput = CType(cbWHRType.SelectedValue, WHRType) - engine.WHRUrbanInput = tbWHRUrban.Text.ToDouble(0) - engine.WHRRuralInput = tbWHRRural.Text.ToDouble(0) - engine.WHRMotorwayInput = tbWHRMotorway.Text.ToDouble(0) - engine.WHRColdHotInput = tbWHRColdHot.Text.ToDouble(0) - engine.WHRRegPerInput = tbWHRRegPer.Text.ToDouble(0) - engine.WHREngineeringInput = tbWHREngineering.Text.ToDouble(0) + engine.WHRTypeInput = GetWHRSelection() + if (engine.WHRType.IsElectrical()) then + engine.ElectricalWHRData = new WHRData(engine) + engine.ElectricalWHRData.WHRUrbanInput = tbElWHRUrban.Text.ToDouble(0) + engine.ElectricalWHRData.WHRRuralInput = tbElWHRRural.Text.ToDouble(0) + engine.ElectricalWHRData.WHRMotorwayInput = tbElWHRMotorway.Text.ToDouble(0) + engine.ElectricalWHRData.WHRColdHotInput = tbElWHRColdHot.Text.ToDouble(0) + engine.ElectricalWHRData.WHRRegPerInput = tbElWHRRegPer.Text.ToDouble(0) + engine.ElectricalWHRData.WHREngineeringInput = tbElWHREngineering.Text.ToDouble(0) + End If + + if (engine.WHRType and WHRType.MechanicalOutputDrivetrain) <> 0 + engine.MechanicalWHRData = new WHRData(engine) + engine.MechanicalWHRData.WHRUrbanInput = tbMechWHRUrban.Text.ToDouble(0) + engine.MechanicalWHRData.WHRRuralInput = tbMechWHRRural.Text.ToDouble(0) + engine.MechanicalWHRData.WHRMotorwayInput = tbMechWHRMotorway.Text.ToDouble(0) + engine.MechanicalWHRData.WHRColdHotInput = tbMechWHRBFColdHot.Text.ToDouble(0) + engine.MechanicalWHRData.WHRRegPerInput = tbMechWHRRegPerCF.Text.ToDouble(0) + engine.MechanicalWHRData.WHREngineeringInput = tbMechWHREngineering.Text.ToDouble(0) + End If engine.ratedPowerInput = (tbRatedPower.Text.ToDouble(0)*1000).SI (Of Watt)() engine.ratedSpeedInput = tbRatedSpeed.Text.ToDouble(0).RPMtoRad() @@ -665,10 +709,6 @@ Public Class EngineForm End If End Sub - Private Sub cbWHRType_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cbWHRType.SelectedIndexChanged - gbWHR.Enabled = CType(CType(sender, ComboBox).SelectedValue, WHRType).IsElectrical() - End Sub - Private Sub btMapFuel2_Click(sender As Object, e As EventArgs) Handles btMapFuel2.Click If FuelConsumptionMapFileBrowser.OpenDialog(FileRepl(tbMapFuel2.Text, GetPath(_engFile))) Then _ tbMapFuel2.Text = GetFilenameWithoutDirectory(FuelConsumptionMapFileBrowser.Files(0), GetPath(_engFile)) @@ -689,13 +729,53 @@ Public Class EngineForm Private Sub cbDuaFuel_CheckedChanged(sender As Object, e As EventArgs) Handles cbDualFuel.CheckedChanged If (cbDualFuel.Checked) Then - If (tbDualFuel.TabPages.Count < 2) then + If (not tbDualFuel.TabPages.Contains(SecondFuelTab)) then tbDualFuel.TabPages.Add(SecondFuelTab) End If Else - If (tbDualFuel.TabPages.Count > 1) then + If (tbDualFuel.TabPages.Contains(SecondFuelTab)) then tbDualFuel.TabPages.Remove(SecondFuelTab) End If End If End Sub + + Private Sub cbMechWHRNotConnectedCrankshaft_CheckedChanged(sender As Object, e As EventArgs) Handles cbMechWHRNotConnectedCrankshaft.CheckedChanged + UpdateWHRTabs() + End Sub + + Private Sub cbElWHR_CheckedChanged(sender As Object, e As EventArgs) Handles cbElWHR.CheckedChanged + + End Sub + + Private Sub UpdateWHRTabs() + dim whrType as WHRType = GetWHRSelection() + + + tbWHR.TabPages.Remove(tbElectricalWHR) + tbWHR.TabPages.Remove(tbMechanicalWHR) + If (whrtype and WHRType.ElectricalOutput) <> 0 Then + if (Not tbWHR.TabPages.Contains(tbElectricalWHR)) then + tbWHR.TabPages.Add(ElectricalWhrTab) + End If + End If + if ( whrtype and WHRType.MechanicalOutputDrivetrain) <> 0 Then + if (not tbWHR.TabPages.Contains(tbMechanicalWHR)) then + tbWHR.TabPages.Add(MechanicalWhrTab) + End If + End If + End Sub + + private Function GetWHRSelection() As WHRType + dim whrType as WHRType = WHRType.None + if (cbMechWHRInMap.Checked) + whrType = whrType or whrType.MechanicalOutputICE + End If + if (cbMechWHRNotConnectedCrankshaft.Checked) + whrType = whrType or whrType.MechanicalOutputDrivetrain + End If + if (cbElWHR.Checked) + whrType = whrType or whrType.ElectricalOutput + End If + return whrType + End Function End Class diff --git a/VECTO/Input Files/Engine.vb b/VECTO/Input Files/Engine.vb index 533191a9f5..1a6ed49a3d 100644 --- a/VECTO/Input Files/Engine.vb +++ b/VECTO/Input Files/Engine.vb @@ -29,7 +29,7 @@ Imports TUGraz.VectoCore.Utils ''' <remarks></remarks> <CustomValidation(GetType(Engine), "ValidateEngine")> Public Class Engine - Implements IEngineEngineeringInputData, IEngineDeclarationInputData, IEngineModeDeclarationInputData, IWHRData, IEngineModeEngineeringInputData + Implements IEngineEngineeringInputData, IEngineDeclarationInputData, IEngineModeDeclarationInputData, IEngineModeEngineeringInputData ''' <summary> ''' Current format version @@ -88,16 +88,14 @@ Public Class Engine Public maxTorqueInput As NewtonMeter public WHRTypeInput As WHRType - Public WHRUrbanInput as Double - public WHRRuralInput As Double - public WHRMotorwayInput As Double - public WHRColdHotInput As Double - public WHRRegPerInput As Double - public WHREngineeringInput As Double + Public PrimaryEngineFuel As EngineFuel Public SecondaryEngineFuel as EngineFuel + public ElectricalWHRData As WHRData + public MechanicalWHRData As WHRData + public DualFuelInput As Boolean @@ -341,12 +339,18 @@ Public Class Engine End Get End Property - Public ReadOnly Property WasteHeatRecoveryData As IWHRData Implements IEngineModeDeclarationInputData.WasteHeatRecoveryData + Public ReadOnly Property WasteHeatRecoveryDataElectrical As IWHRData Implements IEngineModeDeclarationInputData.WasteHeatRecoveryDataElectrical Get - Return Me + Return ElectricalWHRData End Get End Property + Public ReadOnly Property WasteHeatRecoveryDataMechanical As IWHRData Implements IEngineModeDeclarationInputData.WasteHeatRecoveryDataMechanical + Get + Return MechanicalWHRData + End Get + End Property + Public ReadOnly Property RatedPowerDeclared As Watt Implements IEngineDeclarationInputData.RatedPowerDeclared Get Return ratedPowerInput @@ -398,45 +402,66 @@ Public Class Engine #End Region + +End Class + +Public Class WHRData + + Implements IWHRData + + Public WHRUrbanInput as Double + public WHRRuralInput As Double + public WHRMotorwayInput As Double + public WHRColdHotInput As Double + public WHRRegPerInput As Double + public WHREngineeringInput As Double + + protected EngineData As Engine + + public Sub New(engineDatar As Engine) + EngineData = engineDatar + End Sub + Public ReadOnly Property UrbanCorrectionFactor As Double Implements IWHRData.UrbanCorrectionFactor - Get + Get Return WHRUrbanInput - End Get + End Get End Property Public ReadOnly Property RuralCorrectionFactor As Double Implements IWHRData.RuralCorrectionFactor - Get + Get Return WHRRuralInput - End Get + End Get End Property Public ReadOnly Property MotorwayCorrectionFactor As Double Implements IWHRData.MotorwayCorrectionFactor - get + get Return WHRMotorwayInput - End Get + End Get End Property Public ReadOnly Property BFColdHot As Double Implements IWHRData.BFColdHot - Get + Get Return WHRColdHotInput - End Get + End Get End Property Public ReadOnly Property CFRegPer As Double Implements IWHRData.CFRegPer - get + get Return WHRRegPerInput - End Get + End Get End Property Public ReadOnly Property EngineeringCorrectionFactor As Double Implements IWHRData.EngineeringCorrectionFactor - Get + Get Return WHREngineeringInput - End Get + End Get End Property - Public ReadOnly Property GeneratedElectricPower As TableData Implements IWHRData.GeneratedElectricPower - get - If Not File.Exists(PrimaryEngineFuel._fuelConsumptionMapPath.FullPath) Then _ - Throw New VectoException("FuelConsumptionMap is missing or invalid") - Return VectoCSVFile.Read(PrimaryEngineFuel._fuelConsumptionMapPath.FullPath) - End Get + Public ReadOnly Property GeneratedPower As TableData Implements IWHRData.GeneratedPower + get + If Not File.Exists(EngineData.PrimaryEngineFuel._fuelConsumptionMapPath.FullPath) Then _ + Throw New VectoException("FuelConsumptionMap is missing or invalid") + Return VectoCSVFile.Read(EngineData.PrimaryEngineFuel._fuelConsumptionMapPath.FullPath) + End Get End Property + End Class Public Class EngineFuel diff --git a/VECTO/OutputData/JSONFileWriter.vb b/VECTO/OutputData/JSONFileWriter.vb index 6fd6a51e3b..0a59aa67c5 100644 --- a/VECTO/OutputData/JSONFileWriter.vb +++ b/VECTO/OutputData/JSONFileWriter.vb @@ -46,23 +46,23 @@ Public Class JSONFileWriter body.Add("IdlingSpeed", eng.EngineModes.First().IdleSpeed.AsRPM) body.Add("Inertia", eng.Inertia.Value()) - Dim fuels As List(Of Object) = New List(Of Object)() - - For Each fuel As IEngineFuelEngineeringInputData In eng.EngineModes.First().Fuels - Dim entry as Dictionary(Of string, object) = New Dictionary(Of String,Object)() - entry.Add("WHTC-Urban", fuel.WHTCUrban) - entry.Add("WHTC-Rural", fuel.WHTCRural) - entry.Add("WHTC-Motorway", fuel.WHTCMotorway) - entry.Add("WHTC-Engineering", fuel.WHTCEngineering) - entry.Add("ColdHotBalancingFactor", fuel.ColdHotBalancingFactor) - entry.Add("CFRegPer", fuel.CorrectionFactorRegPer) - entry.Add("FuelMap", GetRelativePath(fuel.FuelConsumptionMap.Source, Path.GetDirectoryName(filename))) - entry.Add("FuelType", fuel.FuelType.ToString()) - - fuels.Add(entry) - Next - - body.Add("Fuels", fuels) + Dim fuels As List(Of Object) = New List(Of Object)() + + For Each fuel As IEngineFuelEngineeringInputData In eng.EngineModes.First().Fuels + Dim entry as Dictionary(Of string, object) = New Dictionary(Of String,Object)() + entry.Add("WHTC-Urban", fuel.WHTCUrban) + entry.Add("WHTC-Rural", fuel.WHTCRural) + entry.Add("WHTC-Motorway", fuel.WHTCMotorway) + entry.Add("WHTC-Engineering", fuel.WHTCEngineering) + entry.Add("ColdHotBalancingFactor", fuel.ColdHotBalancingFactor) + entry.Add("CFRegPer", fuel.CorrectionFactorRegPer) + entry.Add("FuelMap", GetRelativePath(fuel.FuelConsumptionMap.Source, Path.GetDirectoryName(filename))) + entry.Add("FuelType", fuel.FuelType.ToString()) + + fuels.Add(entry) + Next + + body.Add("Fuels", fuels) body.Add("RatedPower", eng.RatedPowerDeclared.Value()) body.Add("RatedSpeed", eng.RatedSpeedDeclared.AsRPM) @@ -72,24 +72,42 @@ Public Class JSONFileWriter body.Add("FullLoadCurve", GetRelativePath(eng.EngineModes.First().FullLoadCurve.Source, Path.GetDirectoryName(filename))) - body.add("WHRType", eng.WHRType.ToString()) + body.add("WHRType", eng.WHRType.ToString()) - If (eng.WHRType.IsElectrical()) then - Dim whr As Dictionary(Of String, Object) = New Dictionary(Of String,Object) - Dim whrInput As IWHRData = eng.EngineModes.First().WasteHeatRecoveryData - whr.Add("Urban", whrInput.UrbanCorrectionFactor) - whr.Add("Rural", whrInput.RuralCorrectionFactor) - whr.Add("Motorway", whrInput.MotorwayCorrectionFactor) - whr.Add("ColdHotBalancingFactor", whrInput.BFColdHot) - whr.Add("CFRegPer", whrInput.CFRegPer) - whr.Add("EngineeringCorrectionFactor", whrInput.EngineeringCorrectionFactor) - body.Add("WHRCorrectionFactors", whr) + If (eng.WHRType.IsElectrical()) then + Dim whr As Dictionary(Of String,Object) = GetWhr(eng.EngineModes.First().WasteHeatRecoveryDataElectrical) + dim elWhr as Dictionary(Of String, Object) = New Dictionary(Of String,Object)() + elWhr.Add("Electrical", whr) + if (body.ContainsKey("WHRCorrectionFactors")) then + body.Add("WHRCorrectionFactors", elWhr) + End If + End If + + if (eng.WHRType.IsMechanical()) Then + Dim whr As Dictionary(Of String,Object) = GetWhr(eng.EngineModes.First().WasteHeatRecoveryDataMechanical) + dim mechWhr as Dictionary(Of String, Object) = New Dictionary(Of String,Object)() + mechWhr.Add("Mechanical", whr) + if (body.ContainsKey("WHRCorrectionFactors")) then + body.Add("WHRCorrectionFactors", mechWhr) + End If End If - WriteFile(header, body, filename) + WriteFile(header, body, filename) End Sub - Protected Function GetHeader(fileVersion As Integer) As Dictionary(Of String, Object) + Private Function GetWhr(whrInput As IWHRData) As Dictionary(Of String,Object) + + Dim whr As Dictionary(Of String, Object) = New Dictionary(Of String,Object) + whr.Add("Urban", whrInput.UrbanCorrectionFactor) + whr.Add("Rural", whrInput.RuralCorrectionFactor) + whr.Add("Motorway", whrInput.MotorwayCorrectionFactor) + whr.Add("ColdHotBalancingFactor", whrInput.BFColdHot) + whr.Add("CFRegPer", whrInput.CFRegPer) + whr.Add("EngineeringCorrectionFactor", whrInput.EngineeringCorrectionFactor) + Return whr + End Function + + Protected Function GetHeader(fileVersion As Integer) As Dictionary(Of String, Object) Dim header As Dictionary(Of String, Object) = New Dictionary(Of String, Object) header.Add("CreatedBy", "") @@ -341,13 +359,13 @@ Public Class JSONFileWriter If Not job.SavedInDeclarationMode Then body.Add("VACC", GetRelativePath(driver.AccelerationCurve.AccelerationCurve.Source, basePath)) - body.Add("EngineStopStartAtVehicleStopThreshold", driver.EngineStopStartData.ActivationDelay.Value()) - body.Add("EngineStopStartMaxOffTimespan", driver.EngineStopStartData.MaxEngineOffTimespan.Value()) - body.Add("EngineStopStartUtilityFactor", driver.EngineStopStartData.UtilityFactor) + body.Add("EngineStopStartAtVehicleStopThreshold", driver.EngineStopStartData.ActivationDelay.Value()) + body.Add("EngineStopStartMaxOffTimespan", driver.EngineStopStartData.MaxEngineOffTimespan.Value()) + body.Add("EngineStopStartUtilityFactor", driver.EngineStopStartData.UtilityFactor) - body.Add("EcoRollMinSpeed", driver.EcoRollData.MinSpeed) - body.Add("EcoRollActivationDelay", driver.EcoRollData.ActivationDelay) - body.Add("EcoRollUnderspeedThreshold", driver.EcoRollData.UnderspeedThreshold) + body.Add("EcoRollMinSpeed", driver.EcoRollData.MinSpeed) + body.Add("EcoRollActivationDelay", driver.EcoRollData.ActivationDelay) + body.Add("EcoRollUnderspeedThreshold", driver.EcoRollData.UnderspeedThreshold) End If 'body.Add("StartStop", New Dictionary(Of String, Object) From { diff --git a/VECTO/install.ini b/VECTO/install.ini new file mode 100644 index 0000000000..889ebb30c2 --- /dev/null +++ b/VECTO/install.ini @@ -0,0 +1,8 @@ +### +### In case you want to run VECTO as 'installed' Application +### remove the comment character (#) at the beginning of the line +### starting with 'ExecutionMode'. +### As installed Application VECTO will not write configuration files +### nor log files to the application's folder. +### +#ExecutionMode = install \ No newline at end of file diff --git a/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs b/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs index 710b0ad52f..7969a85c65 100644 --- a/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs +++ b/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs @@ -520,7 +520,9 @@ namespace TUGraz.VectoCommon.InputData IList<IEngineFuelDelcarationInputData> Fuels { get; } - IWHRData WasteHeatRecoveryData { get; } + IWHRData WasteHeatRecoveryDataElectrical { get; } + + IWHRData WasteHeatRecoveryDataMechanical { get; } } @@ -538,7 +540,7 @@ namespace TUGraz.VectoCommon.InputData double EngineeringCorrectionFactor { get; } - TableData GeneratedElectricPower { get; } + TableData GeneratedPower { get; } } diff --git a/VectoCommon/VectoCommon/Models/WHRType.cs b/VectoCommon/VectoCommon/Models/WHRType.cs index 0f5bbe58d6..2c637f9500 100644 --- a/VectoCommon/VectoCommon/Models/WHRType.cs +++ b/VectoCommon/VectoCommon/Models/WHRType.cs @@ -1,35 +1,43 @@ using System; +using System.Collections.Generic; namespace TUGraz.VectoCore.Models.Declaration { + + [Flags] public enum WHRType { - None, - MechanicalOnly, - ElectricalOnly, - MechanicalAndElectrical + None = 0, + MechanicalOutputICE = 1, + MechanicalOutputDrivetrain = 2, + ElectricalOutput = 4, } public static class WHRTypeHelper { public static string ToXMLFormat(this WHRType whrType) { - switch (whrType) { - case WHRType.None: return "none"; - case WHRType.MechanicalOnly: return "mechanical only"; - case WHRType.ElectricalOnly: return "electrical only"; - case WHRType.MechanicalAndElectrical: return "mechanical and electrical"; - default: throw new ArgumentOutOfRangeException(nameof(whrType), whrType, null); + var options = new List<string>(); + if ((whrType & WHRType.MechanicalOutputICE) != 0) { + options.Add("mechanical output to ICE"); + } + if ((whrType & WHRType.MechanicalOutputDrivetrain) != 0) { + options.Add("mechanical output to drivetrain"); + } + if ((whrType & WHRType.ElectricalOutput) != 0) { + options.Add("electrical output"); } - } - public static string GetLabel(this WHRType whrType) + return options.Count == 0 ? "none" : string.Join(", ", options); + } + + public static bool IsElectrical(this WHRType whrType) { - return ToXMLFormat(whrType); + return (whrType & WHRType.ElectricalOutput) != 0; } - public static bool IsElectrical(this WHRType whrType) + public static bool IsMechanical(this WHRType whrType) { - return whrType == WHRType.ElectricalOnly || whrType == WHRType.MechanicalAndElectrical; + return (whrType & WHRType.MechanicalOutputICE) != 0 || (whrType & WHRType.MechanicalOutputDrivetrain) != 0; } } } \ No newline at end of file diff --git a/VectoCommon/VectoCommon/Resources/XMLNames.Designer.cs b/VectoCommon/VectoCommon/Resources/XMLNames.Designer.cs index 9ed931ed64..d3bb397750 100644 --- a/VectoCommon/VectoCommon/Resources/XMLNames.Designer.cs +++ b/VectoCommon/VectoCommon/Resources/XMLNames.Designer.cs @@ -1086,6 +1086,15 @@ namespace TUGraz.VectoCommon.Resources { } } + /// <summary> + /// Looks up a localized string similar to mechanicalPower. + /// </summary> + public static string Engine_FuelConsumptionMap_WHRMechPower_Attr { + get { + return ResourceManager.GetString("Engine_FuelConsumptionMap_WHRMechPower_Attr", resourceCulture); + } + } + /// <summary> /// Looks up a localized string similar to Mode. /// </summary> @@ -1230,6 +1239,24 @@ namespace TUGraz.VectoCommon.Resources { } } + /// <summary> + /// Looks up a localized string similar to Electrical. + /// </summary> + public static string Engine_WHRCorrectionFactors_Electrical { + get { + return ResourceManager.GetString("Engine_WHRCorrectionFactors_Electrical", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to Mechanical. + /// </summary> + public static string Engine_WHRCorrectionFactors_Mechanical { + get { + return ResourceManager.GetString("Engine_WHRCorrectionFactors_Mechanical", resourceCulture); + } + } + /// <summary> /// Looks up a localized string similar to Motorway. /// </summary> diff --git a/VectoCommon/VectoCommon/Resources/XMLNames.resx b/VectoCommon/VectoCommon/Resources/XMLNames.resx index c11ef150ed..676ea8381d 100644 --- a/VectoCommon/VectoCommon/Resources/XMLNames.resx +++ b/VectoCommon/VectoCommon/Resources/XMLNames.resx @@ -1128,4 +1128,13 @@ <data name="DriverModel_EngineStopStartParameters" xml:space="preserve"> <value>EngineStopStartParameters</value> </data> + <data name="Engine_WHRCorrectionFactors_Electrical" xml:space="preserve"> + <value>Electrical</value> + </data> + <data name="Engine_WHRCorrectionFactors_Mechanical" xml:space="preserve"> + <value>Mechanical</value> + </data> + <data name="Engine_FuelConsumptionMap_WHRMechPower_Attr" xml:space="preserve"> + <value>mechanicalPower</value> + </data> </root> \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONEngineData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONEngineData.cs index fdfb46e656..0ace6c6d52 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONEngineData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONEngineData.cs @@ -72,30 +72,33 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON /// } /// } /// </code> - public class JSONEngineDataV5 : JSONEngineDataV4, IWHRData, IEngineModeEngineeringInputData + public class JSONEngineDataV5 : JSONEngineDataV4, IEngineModeEngineeringInputData { + protected IWHRData _elWHRData; + protected IWHRData _mechWHRData; + + public JSONEngineDataV5(JObject data, string fileName, bool tolerateMissing = false) : base( + data, fileName, tolerateMissing) { } #region Overrides of JSONEngineDataV3 - public override IWHRData WasteHeatRecoveryData + public override IWHRData WasteHeatRecoveryDataElectrical { - get { return this; } + get { return _elWHRData ?? (_elWHRData = ReadWHRData(Body["WHRCorrectionFactors"]?["Electrical"])); } } + public override IWHRData WasteHeatRecoveryDataMechanical + { + get { return _mechWHRData ?? (_mechWHRData = ReadWHRData(Body["WHRCorrectionFactors"]?["Mechanical"])); } + } + public override WHRType WHRType { get { return Body.GetEx<string>("WHRType").ParseEnum<WHRType>(); } } - #endregion - - public JSONEngineDataV5(JObject data, string fileName, bool tolerateMissing = false) : base( - data, fileName, tolerateMissing) { } - - #region Overrides of JSONEngineDataV3 - protected override IList<IEngineFuelEngineeringInputData> ReadFuels() { var retVal = new List<IEngineFuelEngineeringInputData>(); @@ -130,6 +133,26 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON #endregion + private IWHRData ReadWHRData(JToken correctionFactors) + { + TableData whrMap = null; + try { + whrMap = ReadTableData(Body["Fuels"][0].GetEx<string>(JsonKeys.Engine_FuelConsumptionMap), "FuelConsumptionMap"); + } catch (Exception) { + if (!TolerateMissing) { + throw; + } + + whrMap = + new TableData( + Path.Combine(BasePath, Body[JsonKeys.Engine_FuelConsumptionMap].ToString()) + MissingFileSuffix, + DataSourceType.Missing); + } + + var retVal = new JSonWHRData(correctionFactors, whrMap); + return retVal; + } + public class JSONFuelInputData : IEngineFuelEngineeringInputData { #region Implementation of IEngineFuelDelcarationInputData @@ -150,59 +173,59 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON #endregion } - + private class JSonWHRData : IWHRData + { + protected JToken CorrectionFactors; + protected TableData WHRMap; - #region Implementation of IWHRData + public JSonWHRData(JToken correctionFactors, TableData whrMap) + { + CorrectionFactors = correctionFactors; + WHRMap = whrMap; + } - public double UrbanCorrectionFactor - { - get { return Body["WHRCorrectionFactors"]?["Urban"]?.ToString().ToDouble() ?? 1.0; } - } + #region Implementation of IWHRData - public double RuralCorrectionFactor - { - get { return Body["WHRCorrectionFactors"]?["Rural"]?.ToString().ToDouble() ?? 1.0; } - } + public double UrbanCorrectionFactor + { + get { return CorrectionFactors?["Urban"]?.ToString().ToDouble() ?? 1.0; } + } - public double MotorwayCorrectionFactor - { - get { return Body["WHRCorrectionFactors"]?["Motorway"]?.ToString().ToDouble() ?? 1.0; } - } + public double RuralCorrectionFactor + { + get { return CorrectionFactors?["Rural"]?.ToString().ToDouble() ?? 1.0; } + } - public double BFColdHot - { - get { return Body["WHRCorrectionFactors"]?["ColdHotBalancingFactor"]?.ToString().ToDouble() ?? 1.0; } - } + public double MotorwayCorrectionFactor + { + get { return CorrectionFactors?["Motorway"]?.ToString().ToDouble() ?? 1.0; } + } - public double CFRegPer - { - get { return Body["WHRCorrectionFactors"]?["CFRegPer"]?.ToString().ToDouble() ?? 1.0; } - } + public double BFColdHot + { + get { return CorrectionFactors?["ColdHotBalancingFactor"]?.ToString().ToDouble() ?? 1.0; } + } - public double EngineeringCorrectionFactor - { - get { return Body["WHRCorrectionFactors"]?["EngineeringCorrectionFactor"]?.ToString().ToDouble() ?? 1.0; } - } + public double CFRegPer + { + get { return CorrectionFactors?["CFRegPer"]?.ToString().ToDouble() ?? 1.0; } + } - public TableData GeneratedElectricPower - { - get { - try { - return ReadTableData(Body["Fuels"][0].GetEx<string>(JsonKeys.Engine_FuelConsumptionMap), "FuelConsumptionMap"); - } catch (Exception) { - if (!TolerateMissing) { - throw; - } + public double EngineeringCorrectionFactor + { + get { return CorrectionFactors?["EngineeringCorrectionFactor"]?.ToString().ToDouble() ?? 1.0; } + } - return - new TableData( - Path.Combine(BasePath, Body[JsonKeys.Engine_FuelConsumptionMap].ToString()) + MissingFileSuffix, - DataSourceType.Missing); - } + public TableData GeneratedPower + { + get { return WHRMap; } } + + #endregion } - #endregion + + } @@ -315,7 +338,12 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON return new IEngineFuelEngineeringInputData[] { this }; } - public virtual IWHRData WasteHeatRecoveryData + public virtual IWHRData WasteHeatRecoveryDataElectrical + { + get { return null; } + } + + public virtual IWHRData WasteHeatRecoveryDataMechanical { get { return null; } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationEngineDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationEngineDataProvider.cs index bf16b86ef3..2bcc03d7f2 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationEngineDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationEngineDataProvider.cs @@ -63,16 +63,17 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider } } - public virtual WHRType WHRType { get { return WHRType.None; } } + public virtual WHRType WHRType + { + get { return WHRType.None; } + } public class XMLSingleFuelEngineMode : AbstractXMLType, IEngineModeDeclarationInputData { protected IList<IEngineFuelDelcarationInputData> FuelsList; - public XMLSingleFuelEngineMode(XmlNode baseNode) : base(baseNode) - { - } + public XMLSingleFuelEngineMode(XmlNode baseNode) : base(baseNode) { } public virtual PerSecond IdleSpeed { @@ -88,14 +89,23 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider } } - public virtual IList<IEngineFuelDelcarationInputData> Fuels { + public virtual IList<IEngineFuelDelcarationInputData> Fuels + { get { - return FuelsList ?? (FuelsList = new List<IEngineFuelDelcarationInputData>() { new XMLSingleFuelEngineFuel(BaseNode) }); + return FuelsList ?? + (FuelsList = new List<IEngineFuelDelcarationInputData>() { new XMLSingleFuelEngineFuel(BaseNode) }); } - } - public virtual IWHRData WasteHeatRecoveryData { get { return null; } } + public virtual IWHRData WasteHeatRecoveryDataElectrical + { + get { return null; } + } + + public virtual IWHRData WasteHeatRecoveryDataMechanical + { + get { return null; } + } } public class XMLSingleFuelEngineFuel : AbstractXMLType, IEngineFuelDelcarationInputData @@ -152,7 +162,6 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider } } - #endregion #region Overrides of AbstractXMLResource @@ -250,10 +259,21 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider public override WHRType WHRType { - get { return GetString(XMLNames.Engine_WHRType).ParseEnum<WHRType>(); } - } - + get { + var retVal = WHRType.None; + if (XmlConvert.ToBoolean(GetString("MechanicalOutputICE"))) { + retVal |= WHRType.MechanicalOutputICE; + } + if (XmlConvert.ToBoolean(GetString("MechanicalOutputDrivetrain"))) { + retVal |= WHRType.MechanicalOutputDrivetrain; + } + if (XmlConvert.ToBoolean(GetString("ElectricalOutput"))) { + retVal |= WHRType.ElectricalOutput; + } + return retVal; + } + } #endregion @@ -268,39 +288,64 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider public override IList<IEngineFuelDelcarationInputData> Fuels { get { - return FuelsList ?? (FuelsList = GetNodes(XMLNames.Engine_FuelModes_Fuel).Cast<XmlNode>().Select(x => new XMLDualFuelEngineFuel(x)) - .Cast<IEngineFuelDelcarationInputData>().ToList()); + return FuelsList ?? (FuelsList = GetNodes(XMLNames.Engine_FuelModes_Fuel) + .Cast<XmlNode>().Select(x => new XMLDualFuelEngineFuel(x)) + .Cast<IEngineFuelDelcarationInputData>().ToList()); + } + } + + public override IWHRData WasteHeatRecoveryDataElectrical + { + get { + return WHRData ?? (WHRData = ReadWHRData( + GetNodes( + new[] { + XMLNames.Engine_FuelModes_Fuel, XMLNames.Engine_WHRCorrectionFactors, + XMLNames.Engine_WHRCorrectionFactors_Electrical + }), + XMLNames.Engine_FuelConsumptionMap_WHRElPower_Attr) + ); } } - public override IWHRData WasteHeatRecoveryData + public override IWHRData WasteHeatRecoveryDataMechanical { - get { return WHRData ?? (WHRData = ReadWHRData()); } + get { + return WHRData ?? (WHRData = ReadWHRData( + GetNodes( + new[] { + XMLNames.Engine_FuelModes_Fuel, XMLNames.Engine_WHRCorrectionFactors, + XMLNames.Engine_WHRCorrectionFactors_Mechanical + }), + XMLNames.Engine_FuelConsumptionMap_WHRMechPower_Attr)); + } } #endregion - protected virtual IWHRData ReadWHRData() + protected virtual IWHRData ReadWHRData(XmlNodeList correctionFactorNodes, string fcMapAttr) { - var correctionFactorNodes = GetNodes(new[] { XMLNames.Engine_FuelModes_Fuel, XMLNames.Engine_WHRCorrectionFactors }); - var whrPwrNodes = GetNodes(new[] { XMLNames.Engine_FuelModes_Fuel, XMLNames.Engine_FuelConsumptionMap, XMLNames.Engine_FuelConsumptionMap_Entry + var whrPwrNodes = GetNodes( + new[] { + XMLNames.Engine_FuelModes_Fuel, XMLNames.Engine_FuelConsumptionMap, XMLNames.Engine_FuelConsumptionMap_Entry }) - .Cast<XmlNode>().All(x => x.Attributes?[XMLNames.Engine_FuelConsumptionMap_WHRElPower_Attr] == null); + .Cast<XmlNode>().All(x => x.Attributes?[fcMapAttr] == null); if (correctionFactorNodes.Count == 0) { if (whrPwrNodes) { - Warn("WHR correction factors provided but no electric power defined - ignoring WHR."); + Warn("WHR correction factors provided but no {0} power defined - ignoring WHR.", fcMapAttr); } - return new XMLWHRData(); + return new XMLDeclarationWHRData(); } + if (correctionFactorNodes.Count > 1) { throw new VectoException("WHRData (correction factors) can only be defined for one fuel!"); } if (whrPwrNodes) { - if (correctionFactorNodes.Count == 1) { + if (correctionFactorNodes.Count == 0) { Warn("WHR electric power provided but no correction factors found - ignoring WHR."); } - return new XMLWHRData(); + return new XMLDeclarationWHRData(); } var fuelNodes = GetNodes(XMLNames.Engine_FuelModes_Fuel); @@ -308,9 +353,10 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider if (fuelNodes.Count > 1) { for (var i = 0; i < fuelNodes.Count; i++) { var fuel = fuelNodes[i]; - if (GetNodes("Entry", fuel).Cast<XmlNode>().Any(x => x.Attributes?[XMLNames.Engine_FuelConsumptionMap_WHRElPower_Attr] != null)) { + if (GetNodes(XMLNames.Engine_FuelConsumptionMap_Entry, fuel).Cast<XmlNode>() + .Any(x => x.Attributes?[fcMapAttr] != null)) { if (whrFuelNode != null) { - throw new VectoException("WHRData (electric power) can only be defined for one fuel!"); + throw new VectoException("WHRData ({0}) can only be defined for one fuel!", fcMapAttr); } whrFuelNode = fuel; @@ -320,26 +366,27 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider whrFuelNode = fuelNodes[0]; } - if (GetNodes(new [] { XMLNames.Engine_FuelConsumptionMap, XMLNames.Engine_FuelConsumptionMap_Entry}, whrFuelNode) - .Cast<XmlNode>().Any(x => x.Attributes?[XMLNames.Engine_FuelConsumptionMap_WHRElPower_Attr] == null)) { - var missing = GetNodes(new[] { XMLNames.Engine_FuelConsumptionMap, XMLNames.Engine_FuelConsumptionMap_Entry }, whrFuelNode) - .Cast<XmlNode>().Where(x => x.Attributes?[XMLNames.Engine_FuelConsumptionMap_WHRElPower_Attr] == null); + if (GetNodes(new[] { XMLNames.Engine_FuelConsumptionMap, XMLNames.Engine_FuelConsumptionMap_Entry }, whrFuelNode) + .Cast<XmlNode>().Any(x => x.Attributes?[fcMapAttr] == null)) { + var missing = GetNodes( + new[] { XMLNames.Engine_FuelConsumptionMap, XMLNames.Engine_FuelConsumptionMap_Entry }, whrFuelNode) + .Cast<XmlNode>().Where(x => x.Attributes?[fcMapAttr] == null); throw new VectoException( "WHRData has to be provided for every entry in the FC-Map! {0}", - string.Join("; ", + string.Join( + "; ", missing.Select( x => string.Format( "n: {0}, T: {1}", x.Attributes?[XMLNames.Engine_FuelConsumptionMap_EngineSpeed_Attr]?.Value, x.Attributes?[XMLNames.Engine_FuelConsumptionMap_Torque_Attr]?.Value)))); } - if (correctionFactorNodes[0].ParentNode != whrFuelNode) { + if (correctionFactorNodes[0].ParentNode.ParentNode != whrFuelNode) { throw new VectoException("Correction Factors and WHR-Map have to be defined for the same fuel!"); } - return new XMLWHRData(whrFuelNode); + return new XMLDeclarationWHRData(whrFuelNode, correctionFactorNodes[0]); } - } public class XMLDualFuelEngineFuel : XMLSingleFuelEngineFuel @@ -356,31 +403,68 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #endregion } - public class XMLWHRData : AbstractXMLType, IWHRData + public class XMLDeclarationWHRData : AbstractXMLType, IWHRData { protected TableData WHRPower; + protected XmlNode CorrectionFactorNode; - public XMLWHRData(XmlNode whrFuelNode) : base(whrFuelNode) { } + public XMLDeclarationWHRData(XmlNode whrFuelNode, XmlNode correctionFactorNode) : base(whrFuelNode) + { + CorrectionFactorNode = correctionFactorNode; + } - public XMLWHRData() :base(null) { } + public XMLDeclarationWHRData() : base(null) { } #region Implementation of IWHRData - public double UrbanCorrectionFactor { get { return GetDouble(new[] { XMLNames.Engine_WHRCorrectionFactors, XMLNames.Engine_WHRCorrectionFactors_Urban}, 1); } } - public double RuralCorrectionFactor { get { return GetDouble(new[] { XMLNames.Engine_WHRCorrectionFactors, XMLNames.Engine_WHRCorrectionFactors_Rural}, 1); } } - public double MotorwayCorrectionFactor { get { return GetDouble(new[] { XMLNames.Engine_WHRCorrectionFactors, XMLNames.Engine_WHRCorrectionFactors_Motorway}, 1); } } - public double BFColdHot { get { return GetDouble(new[] { XMLNames.Engine_WHRCorrectionFactors, XMLNames.Engine_WHRCorrectionFactors_BFColdHot}, 1); } } - public double CFRegPer { get { return GetDouble(new[] { XMLNames.Engine_WHRCorrectionFactors, XMLNames.Engine_WHRCorrectionFactors_CFRegPer}, 1); } } - public double EngineeringCorrectionFactor { get { return 1.0; } } + public double UrbanCorrectionFactor + { + get { return GetNode(XMLNames.Engine_WHRCorrectionFactors_Urban, CorrectionFactorNode)?.InnerText.ToDouble() ?? 1; } + } + + public double RuralCorrectionFactor + { + get { return GetNode(XMLNames.Engine_WHRCorrectionFactors_Rural, CorrectionFactorNode)?.InnerText.ToDouble() ?? 1; } + } + + public double MotorwayCorrectionFactor + { + get { + return GetNode(XMLNames.Engine_WHRCorrectionFactors_Motorway, CorrectionFactorNode)?.InnerText.ToDouble() ?? 1; + } + } - public TableData GeneratedElectricPower + public double BFColdHot { - get { return WHRPower ?? (WHRPower = BaseNode == null ? null : ReadTableData(XMLNames.Engine_FuelConsumptionMap, XMLNames.Engine_FuelConsumptionMap_Entry, AttributeMappings.WHRPowerMapMapping)); } + get { + return GetNode(XMLNames.Engine_WHRCorrectionFactors_BFColdHot, CorrectionFactorNode)?.InnerText.ToDouble() ?? 1; + } + } + + public double CFRegPer + { + get { + return GetNode(XMLNames.Engine_WHRCorrectionFactors_CFRegPer, CorrectionFactorNode)?.InnerText.ToDouble() ?? 1; + } + } + + public double EngineeringCorrectionFactor + { + get { return 1.0; } + } + + public TableData GeneratedPower + { + get { + return WHRPower ?? (WHRPower = BaseNode == null + ? null + : ReadTableData( + XMLNames.Engine_FuelConsumptionMap, XMLNames.Engine_FuelConsumptionMap_Entry, + AttributeMappings.WHRPowerMapMapping)); + } } #endregion } } - - } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringEngineDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringEngineDataProvider.cs index 107a5f47ca..4ca8e834a0 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringEngineDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringEngineDataProvider.cs @@ -166,11 +166,18 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider get { return new[] { this }.Cast<IEngineFuelDelcarationInputData>().ToList(); } } - public virtual IWHRData WasteHeatRecoveryData + public virtual IWHRData WasteHeatRecoveryDataElectrical { get { return null; } } + + public virtual IWHRData WasteHeatRecoveryDataMechanical + { + get { return null; } + } + + public virtual Watt RatedPowerDeclared { get { @@ -348,9 +355,14 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider get { return (_fuels ?? (_fuels = ReadFuels())).Cast<IEngineFuelDelcarationInputData>().ToList(); } } - public virtual IWHRData WasteHeatRecoveryData + public virtual IWHRData WasteHeatRecoveryDataElectrical + { + get { return WHRData ?? (WHRData = ReadWHRData("Electrical")); } + } + + public virtual IWHRData WasteHeatRecoveryDataMechanical { - get { return WHRData ?? (WHRData = ReadWHRData()); } + get { return WHRData ?? (WHRData = ReadWHRData("Mechanical")); } } #endregion @@ -360,11 +372,11 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider return GetNodes(XMLNames.Engine_FuelModes_Fuel).Cast<XmlNode>().Select(x => new XMLEngineFuel(x, Source)).Cast<IEngineFuelEngineeringInputData>().ToList(); } - protected virtual IWHRData ReadWHRData() + protected virtual IWHRData ReadWHRData(string typeNode) { var fuelNode = GetNodes(XMLNames.Engine_FuelModes_Fuel).Cast<XmlNode>().First(); - var whrNode = GetNode("WasteHeatRecovery", fuelNode); - return new XMLWHRData(whrNode, Source); + var whrNode = GetNode(new [] { "WasteHeatRecovery", typeNode}, fuelNode); + return new XMLEngineeringWHRData(whrNode, Source); } } @@ -421,11 +433,11 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider #endregion } - internal class XMLWHRData : AbstractXMLType, IWHRData + internal class XMLEngineeringWHRData : AbstractXMLType, IWHRData { protected DataSource Source; - public XMLWHRData(XmlNode baseNode, DataSource source) : base (baseNode) + public XMLEngineeringWHRData(XmlNode baseNode, DataSource source) : base (baseNode) { Source = source; } @@ -440,7 +452,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider public virtual double CFRegPer { get { return 1; } } public virtual double EngineeringCorrectionFactor { get { return GetDouble(XMLNames.Engine_WHRCorrectionFactor); } } - public virtual TableData GeneratedElectricPower + public virtual TableData GeneratedPower { get { return XMLHelper.ReadEntriesOrResource( diff --git a/VectoCore/VectoCore/InputData/Reader/ComponentData/WHRPowerReader.cs b/VectoCore/VectoCore/InputData/Reader/ComponentData/WHRPowerReader.cs index a9a6487f3d..a0d9d38690 100644 --- a/VectoCore/VectoCore/InputData/Reader/ComponentData/WHRPowerReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/ComponentData/WHRPowerReader.cs @@ -5,66 +5,90 @@ using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine; using TUGraz.VectoCore.Utils; -namespace TUGraz.VectoCore.InputData.Reader.ComponentData { +namespace TUGraz.VectoCore.InputData.Reader.ComponentData +{ public static class WHRPowerReader { - public static WHRPowerMap ReadFromFile(string fileName) + public static WHRPowerMap ReadFromFile(string fileName, WHRType type) { try { var data = VectoCSVFile.Read(fileName); - return Create(data); + return Create(data, type); } catch (Exception e) { throw new VectoException(string.Format("File {0}: {1}", fileName, e.Message), e); } } - public static WHRPowerMap Create(TableData data) + public static WHRPowerMap Create(TableData data, WHRType type) { - var headerValid = HeaderIsValid(data.Columns); + string whrColumn = null; + type = type & (WHRType.ElectricalOutput | WHRType.MechanicalOutputDrivetrain); + switch (type) { + case WHRType.MechanicalOutputDrivetrain: + whrColumn = Fields.MechanicalPower; + break; + case WHRType.ElectricalOutput: + whrColumn = Fields.ElectricPower; + break; + default: throw new ArgumentOutOfRangeException(nameof(type), type, null); + } + + var headerValid = HeaderIsValid(data.Columns, whrColumn); if (!headerValid) { LoggingObject.Logger<FuelConsumptionMap>().Warn( "WHRMap: Header Line is not valid. Expected: '{0}, {1}, {2}', Got: {3}", Fields.EngineSpeed, Fields.Torque, Fields.ElectricPower, string.Join(", ", data.Columns.Cast<DataColumn>().Select(c => c.ColumnName))); } - var delaunayMap = new DelaunayMap("WHRMap"); if (!headerValid) { if (data.SourceType == DataSourceType.CSVFile && data.Columns.Count < 4) { throw new VectoException("FC-Map has to contain at least 4 columns when WHR is used"); } + data.Columns[0].ColumnName = Fields.EngineSpeed; data.Columns[1].ColumnName = Fields.Torque; + // column with idx==2 is fuel consumption in csv files - data.Columns[3].ColumnName = Fields.ElectricPower; + if (type == WHRType.ElectricalOutput) { + data.Columns[3].ColumnName = Fields.ElectricPower; + } + if (type == WHRType.MechanicalOutputDrivetrain) { + if (data.Columns.Count > 3) { + data.Columns[4].ColumnName = Fields.MechanicalPower; + } else { + data.Columns[3].ColumnName = Fields.MechanicalPower; + } + } } + var delaunayMap = new DelaunayMap(type.IsElectrical() ? "WHRMapEl" : "WHRMapMech"); + foreach (DataRow row in data.Rows) { try { - var entry = new WHRPowerMap.Entry ( - engineSpeed: row.ParseDouble(Fields.EngineSpeed).RPMtoRad(), - torque: row.ParseDouble(Fields.Torque).SI<NewtonMeter>(), - electricPower:row.ParseDouble(Fields.ElectricPower).SI<Watt>() - ); - delaunayMap.AddPoint(entry.Torque.Value(), - (headerValid ? row.ParseDouble(Fields.EngineSpeed) : row.ParseDouble(0)).RPMtoRad().Value(), - entry.ElectricPower.Value()); + var engineSpeed = row.ParseDouble(Fields.EngineSpeed).RPMtoRad(); + var torque = row.ParseDouble(Fields.Torque).SI<NewtonMeter>(); + var electricPower = row.ParseDouble(whrColumn).SI<Watt>(); + + delaunayMap?.AddPoint(torque.Value(),engineSpeed.Value(),electricPower.Value()); } catch (Exception e) { throw new VectoException(string.Format("WHR Map - Line {0}: {1}", data.Rows.IndexOf(row), e.Message), e); } } delaunayMap.Triangulate(); + return new WHRPowerMap(delaunayMap); } - private static bool HeaderIsValid(DataColumnCollection columns) + private static bool HeaderIsValid(DataColumnCollection columns, string whrColumn) { return columns.Contains(Fields.EngineSpeed) && columns.Contains(Fields.Torque) && - columns.Contains(Fields.ElectricPower); + columns.Contains(whrColumn); } public static class Fields @@ -80,9 +104,14 @@ namespace TUGraz.VectoCore.InputData.Reader.ComponentData { public const string Torque = "torque"; /// <summary> - /// [g/h] + /// [W] + /// </summary> + public const string ElectricPower = "whr power electric"; + + /// <summary> + /// [W] /// </summary> - public const string ElectricPower = "whr power"; + public const string MechanicalPower = "whr power mechanical"; } } -} \ No newline at end of file +} diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs index 4de0eeaffb..0a381c4a9a 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs @@ -233,31 +233,36 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter retVal.FullLoadCurves = fullLoadCurves; - var whr = CreateWHRData(mode.WasteHeatRecoveryData); - if (whr != null) { - whr.WHRCorrectionFactor = DeclarationData.WHTCCorrection.Lookup( - mission.MissionType.GetNonEMSMissionType(), whr.CFRural, whr.CFUrban, - whr.CFMotorway) * whr.CFColdHot * whr.CFRegPer; + if ((retVal.WHRType & WHRType.ElectricalOutput) != 0) { + retVal.ElectricalWHR = CreateWHRData( + mode.WasteHeatRecoveryDataElectrical, mission.MissionType, WHRType.ElectricalOutput); + } + if ((retVal.WHRType & WHRType.MechanicalOutputDrivetrain) != 0) { + retVal.MechanicalWHR = CreateWHRData( + mode.WasteHeatRecoveryDataMechanical, mission.MissionType, WHRType.MechanicalOutputDrivetrain); } - retVal.WHRData = whr; return retVal; } - private static WHRData CreateWHRData(IWHRData whrInputData) + private static WHRData CreateWHRData(IWHRData whrInputData, MissionType missionType, WHRType type) { - if (whrInputData == null || whrInputData.GeneratedElectricPower == null) { + if (whrInputData == null || whrInputData.GeneratedPower == null) { return null; } - return new WHRData() { + var whr = new WHRData() { CFUrban = whrInputData.UrbanCorrectionFactor, CFRural = whrInputData.RuralCorrectionFactor, CFMotorway = whrInputData.MotorwayCorrectionFactor, CFColdHot = whrInputData.BFColdHot, CFRegPer = whrInputData.CFRegPer, - WHRMap = WHRPowerReader.Create(whrInputData.GeneratedElectricPower) + WHRMap = WHRPowerReader.Create(whrInputData.GeneratedPower, type) }; + whr.WHRCorrectionFactor = DeclarationData.WHTCCorrection.Lookup( + missionType.GetNonEMSMissionType(), whr.CFRural, whr.CFUrban, + whr.CFMotorway) * whr.CFColdHot * whr.CFRegPer; + return whr; } private static NewtonMeter VehMaxTorque( diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs index 51d4709f7d..7aa7e0f2b4 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs @@ -201,22 +201,16 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter retVal.FullLoadCurves = fullLoadCurves; - var whr = CreateWHRData(engineMode.WasteHeatRecoveryData); - if (whr != null) { - whr.WHRCorrectionFactor = engineMode.WasteHeatRecoveryData.EngineeringCorrectionFactor; - } - retVal.WHRType = engine.WHRType; - retVal.WHRData = whr; - //foreach (var fuelEntry in retVal.Fuels) { + retVal.ElectricalWHR = CreateWHRData(engineMode.WasteHeatRecoveryDataElectrical, WHRType.ElectricalOutput); + retVal.MechanicalWHR = CreateWHRData(engineMode.WasteHeatRecoveryDataMechanical, WHRType.MechanicalOutputDrivetrain); - //retVal.Fuels[0].FuelConsumptionCorrectionFactor = engine.WHTCEngineering; return retVal; } - private WHRData CreateWHRData(IWHRData whrInputData) + private WHRData CreateWHRData(IWHRData whrInputData, WHRType whrType) { - if (whrInputData == null || whrInputData.GeneratedElectricPower == null) { + if (whrInputData == null || whrInputData.GeneratedPower == null) { return null; } @@ -226,7 +220,8 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter CFMotorway = 1, CFColdHot = 1, CFRegPer = 1, - WHRMap = WHRPowerReader.Create(whrInputData.GeneratedElectricPower) + WHRMap = WHRPowerReader.Create(whrInputData.GeneratedPower, whrType), + WHRCorrectionFactor = whrInputData.EngineeringCorrectionFactor, }; } diff --git a/VectoCore/VectoCore/Models/Simulation/Data/ModalResultField.cs b/VectoCore/VectoCore/Models/Simulation/Data/ModalResultField.cs index 7c4896b44d..3fc99a352c 100644 --- a/VectoCore/VectoCore/Models/Simulation/Data/ModalResultField.cs +++ b/VectoCore/VectoCore/Models/Simulation/Data/ModalResultField.cs @@ -333,7 +333,9 @@ namespace TUGraz.VectoCore.Models.Simulation.Data [ModalResultField(typeof(SI), caption: "AA_TotalCycleFuelConsumptionCompressorOn [g]", outputFactor: 1000)] AA_TotalCycleFuelConsumptionCompressorOn, [ModalResultField(typeof(SI), "P_WHR_el [kW]", outputFactor:1e-3)] P_WHR_el_map, - [ModalResultField(typeof(SI), "P_WHR_el_corr [kW]", outputFactor: 1e-3)] P_WHR_el_corr + [ModalResultField(typeof(SI), "P_WHR_el_corr [kW]", outputFactor: 1e-3)] P_WHR_el_corr, + [ModalResultField(typeof(SI), "P_WHR_mech [kW]", outputFactor: 1e-3)] P_WHR_mech_map, + [ModalResultField(typeof(SI), "P_WHR_mech_corr [kW]", outputFactor: 1e-3)] P_WHR_mech_corr } [AttributeUsage(AttributeTargets.Field)] diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs index 8097184063..23b50eeb10 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs @@ -71,7 +71,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data [Required, ValidateObject] public List<CombustionEngineFuelData> Fuels { get; internal set; } - public WHRData WHRData; + public WHRData ElectricalWHR; + + public WHRData MechanicalWHR; public WHRType WHRType; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/FuelConsumptionMap.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/FuelConsumptionMap.cs index be913101ac..079f427d35 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/FuelConsumptionMap.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/FuelConsumptionMap.cs @@ -55,7 +55,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine bool allowExtrapolation = false) { var result = new FuelConsumptionResult(); - // delaunay map needs is initialised with rpm, therefore the angularVelocity has to be converted. + var value = _fuelMap.Interpolate(torque, angularVelocity); if (value.HasValue) { result.Value = value.Value.SI(Unit.SI.Kilo.Gramm.Per.Second).Cast<KilogramPerSecond>(); diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/WHRPowerMap.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/WHRPowerMap.cs index 5838b89c18..64e0ab7080 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/WHRPowerMap.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/WHRPowerMap.cs @@ -36,12 +36,12 @@ namespace TUGraz.VectoCore.InputData.Reader.ComponentData // delaunay map needs is initialised with rpm, therefore the angularVelocity has to be converted. var value = WHRMap.Interpolate(torque, engineSpeed); if (value.HasValue) { - result.ElectricPower = value.Value.SI<Watt>(); + result.GeneratedPower = value.Value.SI<Watt>(); return result; } if (allowExtrapolation) { - result.ElectricPower = + result.GeneratedPower = WHRMap.Extrapolate(torque, engineSpeed).SI<Watt>(); result.Extrapolated = true; return result; @@ -54,7 +54,7 @@ namespace TUGraz.VectoCore.InputData.Reader.ComponentData public class WHRPowerResult { - public Watt ElectricPower; + public Watt GeneratedPower; public bool Extrapolated; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs index 18b479edad..1098e31791 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs @@ -35,6 +35,7 @@ using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Configuration; +using TUGraz.VectoCore.InputData.Reader.ComponentData; using TUGraz.VectoCore.Models.Connector.Ports; using TUGraz.VectoCore.Models.Connector.Ports.Impl; using TUGraz.VectoCore.Models.Declaration; @@ -374,22 +375,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl container[ModalResultField.Tq_drag] = CurrentState.FullDragTorque; container[ModalResultField.IgnitionOn] = CurrentState.IgnitionOn; - var pWHRelMap = 0.SI<Watt>(); - var pWHRelCorr = 0.SI<Watt>(); - if (ModelData.WHRData != null) { - var whrPwr = ModelData.WHRData.WHRMap.GetWHRPower( - CurrentState.EngineTorque, avgEngineSpeed, DataBus.ExecutionMode != ExecutionMode.Declaration); - if (DataBus.ExecutionMode != ExecutionMode.Declaration && whrPwr.Extrapolated) { - Log.Warn( - "Electric WHR power was extrapolated: range for WHR-Map is not sufficient: n: {0}, torque: {1}", - avgEngineSpeed.Value(), CurrentState.EngineTorque.Value()); - } - pWHRelMap = whrPwr.ElectricPower; - pWHRelCorr = pWHRelMap * ModelData.WHRData.WHRCorrectionFactor; - } - - container[ModalResultField.P_WHR_el_map] = pWHRelMap; - container[ModalResultField.P_WHR_el_corr] = pWHRelCorr; + WriteWHRPower(container, avgEngineSpeed, CurrentState.EngineTorque); foreach (var fuel in ModelData.Fuels) { var result = fuel.ConsumptionMap.GetFuelConsumption( @@ -428,6 +414,39 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } } + protected virtual void WriteWHRPower(IModalDataContainer container, PerSecond engineSpeed, NewtonMeter engineTorque) + { + var pWHRelMap = 0.SI<Watt>(); + var pWHRelCorr = 0.SI<Watt>(); + var pWHRmechMap = 0.SI<Watt>(); + var pWHRmechCorr = 0.SI<Watt>(); + GetWHRPower(ModelData.ElectricalWHR, engineSpeed, engineTorque, ref pWHRelMap, ref pWHRelCorr); + GetWHRPower(ModelData.MechanicalWHR, engineSpeed, engineTorque, ref pWHRmechMap, ref pWHRmechCorr); + + container[ModalResultField.P_WHR_el_map] = pWHRelMap; + container[ModalResultField.P_WHR_el_corr] = pWHRelCorr; + + container[ModalResultField.P_WHR_mech_map] = pWHRmechMap; + container[ModalResultField.P_WHR_mech_corr] = pWHRmechCorr; + } + + protected virtual void GetWHRPower(WHRData whr, PerSecond engineSpeed, NewtonMeter engineTorque, ref Watt pWHRelMap, ref Watt pWHRelCorr) + { + if (whr != null) { + var whrPwrEl = whr.WHRMap.GetWHRPower( + engineTorque, engineSpeed, DataBus.ExecutionMode != ExecutionMode.Declaration); + if (DataBus.ExecutionMode != ExecutionMode.Declaration && whrPwrEl.Extrapolated) { + Log.Warn( + "Electric WHR power was extrapolated: range for WHR-Map is not sufficient: n: {0}, torque: {1}", + engineSpeed.Value(), engineTorque.Value()); + } + if (whrPwrEl.GeneratedPower != null) { + pWHRelMap = whrPwrEl.GeneratedPower; + pWHRelCorr = pWHRelMap * whr.WHRCorrectionFactor; + } + } + } + protected virtual double WHTCCorrectionFactor(FuelData.Entry fuel) { return ModelData.Fuels.First(x=> x.FuelData.FuelType == fuel.FuelType).FuelConsumptionCorrectionFactor; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/StopStartCombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/StopStartCombustionEngine.cs index a4ffebcf46..80518689a3 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/StopStartCombustionEngine.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/StopStartCombustionEngine.cs @@ -113,17 +113,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { var auxDemand = EngineAux.PowerDemandEngineOn(ModelData.IdleSpeed) / ModelData.IdleSpeed; - var pWHRelMap = 0.SI<Watt>(); - var pWHRelCorr = 0.SI<Watt>(); - - if (ModelData.WHRData != null) { - var whrPwr = ModelData.WHRData.WHRMap.GetWHRPower(auxDemand, ModelData.IdleSpeed, DataBus.ExecutionMode != ExecutionMode.Declaration); - - pWHRelMap = whrPwr.ElectricPower * (1 - EngineStopStartUtilityFactor); - pWHRelCorr = pWHRelMap * ModelData.WHRData.WHRCorrectionFactor; - } - container[ModalResultField.P_WHR_el_map] = pWHRelMap; - container[ModalResultField.P_WHR_el_corr] = pWHRelCorr; + WriteWHRPower(container, ModelData.IdleSpeed, auxDemand); foreach (var fuel in ModelData.Fuels) { var fc = 0.SI<KilogramPerSecond>(); diff --git a/VectoCore/VectoCore/OutputData/ModalDataContainer.cs b/VectoCore/VectoCore/OutputData/ModalDataContainer.cs index 10992efbd6..63378e8d2f 100644 --- a/VectoCore/VectoCore/OutputData/ModalDataContainer.cs +++ b/VectoCore/VectoCore/OutputData/ModalDataContainer.cs @@ -166,7 +166,7 @@ namespace TUGraz.VectoCore.OutputData .Concat(Auxiliaries.Values.Select(c => c.ColumnName)) .Concat( new[] { - ModalResultField.P_WHR_el_map, ModalResultField.P_WHR_el_corr, ModalResultField.P_aux_ice_off, + ModalResultField.P_WHR_el_map, ModalResultField.P_WHR_el_corr, ModalResultField.P_WHR_mech_map, ModalResultField.P_WHR_mech_corr, ModalResultField.P_aux_ice_off, ModalResultField.P_ice_start }.Select(x => x.GetName())) .Concat(FuelColumns.SelectMany(kv => kv.Value.Select(kv2 => kv2.Value.ColumnName))); diff --git a/VectoCore/VectoCore/OutputData/SummaryDataContainer.cs b/VectoCore/VectoCore/OutputData/SummaryDataContainer.cs index b0dd779eb3..797616819d 100644 --- a/VectoCore/VectoCore/OutputData/SummaryDataContainer.cs +++ b/VectoCore/VectoCore/OutputData/SummaryDataContainer.cs @@ -527,7 +527,11 @@ namespace TUGraz.VectoCore.OutputData modData.WorkEngineStart(); var workWHREl = modData.TimeIntegral<WattSecond>(ModalResultField.P_WHR_el_corr); - var workWhrMech = - workWHREl / DeclarationData.AlternaterEfficiency; + var workWhrElMech = - workWHREl / DeclarationData.AlternaterEfficiency; + + var workWHRMech = -modData.TimeIntegral<WattSecond>(ModalResultField.P_WHR_mech_corr); + + var workWhr = workWhrElMech + workWHRMech; var distance = modData.Distance(); var duration = modData.Duration(); @@ -580,7 +584,7 @@ namespace TUGraz.VectoCore.OutputData row[FcCol(K_VEHLINE, suffix)] = correction.ConvertToGramPerKiloWattHour(); - var fcWHRCorr = fcModSum + correction * workWhrMech; + var fcWHRCorr = fcModSum + correction * workWhr; row[FcCol(FCWHR_H_CORR, suffix)] = duration != null ? (fcWHRCorr / duration).ConvertToGrammPerHour() : null; var fcEssCorr = fcWHRCorr + correction * workESS; diff --git a/VectoCore/VectoCore/OutputData/XML/AttributeMappings.cs b/VectoCore/VectoCore/OutputData/XML/AttributeMappings.cs index a8ca35ccb2..fd484a355f 100644 --- a/VectoCore/VectoCore/OutputData/XML/AttributeMappings.cs +++ b/VectoCore/VectoCore/OutputData/XML/AttributeMappings.cs @@ -49,7 +49,8 @@ namespace TUGraz.IVT.VectoXML public static readonly Dictionary<string, string> WHRPowerMapMapping = new Dictionary<string, string> { { WHRPowerReader.Fields.EngineSpeed, XMLNames.Engine_FuelConsumptionMap_EngineSpeed_Attr }, { WHRPowerReader.Fields.Torque, XMLNames.Engine_FuelConsumptionMap_Torque_Attr }, - { WHRPowerReader.Fields.ElectricPower, XMLNames.Engine_FuelConsumptionMap_WHRElPower_Attr } + { WHRPowerReader.Fields.ElectricPower, XMLNames.Engine_FuelConsumptionMap_WHRElPower_Attr }, + { WHRPowerReader.Fields.MechanicalPower, XMLNames.Engine_FuelConsumptionMap_WHRMechPower_Attr } }; public static readonly Dictionary<string, string> EngineFullLoadCurveMapping = new Dictionary<string, string> { diff --git a/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReport.cs b/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReport.cs index 9ccb650719..cf30c9b2ec 100644 --- a/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReport.cs +++ b/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReport.cs @@ -34,6 +34,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Data; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Xml; using System.Xml.Linq; @@ -144,7 +145,11 @@ namespace TUGraz.VectoCore.OutputData.XML var workESS = data.WorkAuxiliariesDuringEngineStop() + data.WorkEngineStart(); var workWHRel = data.TimeIntegral<WattSecond>(ModalResultField.P_WHR_el_corr); - var workWhrMech = -workWHRel / DeclarationData.AlternaterEfficiency; + var workWHRelMech = -workWHRel / DeclarationData.AlternaterEfficiency; + + var workWHRmech = -data.TimeIntegral<WattSecond>(ModalResultField.P_WHR_mech_corr); + + var workWHR = workWHRelMech + workWHRmech; FuelConsumptionFinal = new Dictionary<FuelType, Kilogram>(); CO2Total = 0.SI<Kilogram>(); @@ -161,7 +166,7 @@ namespace TUGraz.VectoCore.OutputData.XML x.Field<SI>(ModalResultField.P_eng_fcmap.GetName()).Value(), x.Field<SI>(data.GetColumnName(entry, ModalResultField.FCFinal)).Value()) : null).Where(x => x != null && x.Y > 0), out k, out d, out s); var correction = k.SI<KilogramPerWattSecond>(); - var fcTotalcorr = fcSum + correction * (workESS + workWhrMech); + var fcTotalcorr = fcSum + correction * (workESS + workWHR); FuelConsumptionFinal[entry.FuelType] = fcTotalcorr; CO2Total += fcTotalcorr * entry.CO2PerFuelWeight; EnergyConsumptionTotal += fcTotalcorr * entry.LowerHeatingValueVecto; diff --git a/VectoCore/VectoCore/Utils/DelaunayMap.cs b/VectoCore/VectoCore/Utils/DelaunayMap.cs index d147ce127b..19562944aa 100644 --- a/VectoCore/VectoCore/Utils/DelaunayMap.cs +++ b/VectoCore/VectoCore/Utils/DelaunayMap.cs @@ -61,6 +61,8 @@ namespace TUGraz.VectoCore.Utils _mapName = name; } + public string Name { get { return _mapName; } } + public void AddPoint(double x, double y, double z) { _points.Add(new Point(x, y, z)); diff --git a/VectoCore/VectoCore/Utils/XMLDefinitions.cs b/VectoCore/VectoCore/Utils/XMLDefinitions.cs index 7a5b6b6782..65ec0dfbd2 100644 --- a/VectoCore/VectoCore/Utils/XMLDefinitions.cs +++ b/VectoCore/VectoCore/Utils/XMLDefinitions.cs @@ -23,6 +23,7 @@ namespace TUGraz.VectoCore.Utils //public const string SchemaBaseURL = "file:///E:/QUAM/Workspace/VECTO_quam/VectoCore/VectoCore/Resources/XSD/"; public const string SCHEMA_BASE_LOCATION = "https://webgate.ec.europa.eu/CITnet/svn/VECTO/trunk/Share/XML/XSD/"; + public const string DEV = ":DEV"; public const string ENGINEERING_NAMESPACE = "urn:tugraz:ivt:VectoAPI:EngineeringDefinitions"; @@ -49,7 +50,7 @@ namespace TUGraz.VectoCore.Utils public const string DECLARATION_DEFINITIONS_NAMESPACE_URI_V22 = DECLARATION_NAMESPACE + ":v2.2"; - public const string DECLARATION_DEFINITIONS_NAMESPACE_URI_V23 = DECLARATION_NAMESPACE + ":v2.3_DF"; + public const string DECLARATION_DEFINITIONS_NAMESPACE_URI_V23 = DECLARATION_NAMESPACE + DEV +":v2.3_DF"; public const string DECLARATION_INPUT_NAMESPACE = "urn:tugraz:ivt:VectoAPI:DeclarationInput"; diff --git a/VectoCore/VectoCore/VectoCore.csproj b/VectoCore/VectoCore/VectoCore.csproj index 2c1299b072..c962349568 100644 --- a/VectoCore/VectoCore/VectoCore.csproj +++ b/VectoCore/VectoCore/VectoCore.csproj @@ -522,6 +522,11 @@ <Compile Include="Utils\XMLValidator.cs" /> <Compile Include="Utils\XPathHelper.cs" /> <Compile Include="Ninject\VectoNinjectModule.cs" /> + <Compile Include="VersionNumber1.cs"> + <AutoGen>True</AutoGen> + <DesignTime>True</DesignTime> + <DependentUpon>VersionNumber.t4</DependentUpon> + </Compile> </ItemGroup> <ItemGroup> <None Include="app.config" /> @@ -697,6 +702,12 @@ <EmbeddedResource Include="Resources\XSD\VectoEngineeringDefinitions.1.1.xsd"> <SubType>Designer</SubType> </EmbeddedResource> + <EmbeddedResource Include="Resources\XSD\VectoDeclarationDefinitions.2.4_Tyre.xsd"> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Resources\XSD\VectoDeclarationDefinitions.2.5_Gearbox.xsd"> + <SubType>Designer</SubType> + </EmbeddedResource> <None Include="Utils\VectoVersionCore.tt"> <Generator>TextTemplatingFileGenerator</Generator> <LastGenOutput>VectoVersionCore.cs</LastGenOutput> diff --git a/VectoCore/VectoCoreTest/Models/WHRMapReaderTest.cs b/VectoCore/VectoCoreTest/Models/WHRMapReaderTest.cs index c44e15800f..7d0619d4d3 100644 --- a/VectoCore/VectoCoreTest/Models/WHRMapReaderTest.cs +++ b/VectoCore/VectoCoreTest/Models/WHRMapReaderTest.cs @@ -11,6 +11,7 @@ using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.InputData.FileIO.XML; using TUGraz.VectoCore.InputData.Reader.ComponentData; using TUGraz.VectoCore.InputData.Reader.Impl; +using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Models.Simulation; using TUGraz.VectoCore.Tests.Utils; using TUGraz.VectoCore.Utils; @@ -39,22 +40,65 @@ namespace TUGraz.VectoCore.Tests.Models } [TestCase] - public void TestWHRMapCSVData() + public void TestWHRMapCSVDataElectric() { - var data = "engine speed, torque, fuel consumption, whr power \n" + + var data = "engine speed, torque, fuel consumption, whr power electric\n" + "600, -100, 0, 100\n" + "600, 500, 200, 400\n" + "2400, -100, 0, 100\n" + "2400, 500, 200, 400"; - var whrMap = WHRPowerReader.Create(VectoCSVFile.ReadStream(data.ToStream())); + var whrMap = WHRPowerReader.Create(VectoCSVFile.ReadStream(data.ToStream()), WHRType.ElectricalOutput); var result = whrMap.GetWHRPower(500.SI<NewtonMeter>(), 600.RPMtoRad(), true); Assert.IsFalse(result.Extrapolated); - Assert.AreEqual(400, result.ElectricPower.Value()); + Assert.AreEqual(400, result.GeneratedPower.Value()); } + [TestCase] + public void TestWHRMapCSVDataMechanical() + { + + var data = "engine speed, torque, fuel consumption, whr power mechanical\n" + + "600, -100, 0, 100\n" + + "600, 500, 200, 400\n" + + "2400, -100, 0, 100\n" + + "2400, 500, 200, 400"; + + var whrMap = WHRPowerReader.Create(VectoCSVFile.ReadStream(data.ToStream()), WHRType.MechanicalOutputDrivetrain); + var result = whrMap.GetWHRPower(500.SI<NewtonMeter>(), 600.RPMtoRad(), true); + + Assert.IsFalse(result.Extrapolated); + Assert.AreEqual(400, result.GeneratedPower.Value()); + } + + + [TestCase] + public void TestWHRMapCSVDataElectricAndMechanical() + { + + var data = "engine speed, torque, fuel consumption, whr power electric, whr power mechanical\n" + + " 600, -100, 0, 50, 100\n" + + " 600, 500, 200, 200, 400\n" + + "2400, -100, 0, 100, 100\n" + + "2400, 500, 200, 200, 400"; + + var whrMapEl = WHRPowerReader.Create(VectoCSVFile.ReadStream(data.ToStream()), WHRType.ElectricalOutput); + var resultEl = whrMapEl.GetWHRPower(500.SI<NewtonMeter>(), 600.RPMtoRad(), true); + + Assert.IsFalse(resultEl.Extrapolated); + Assert.AreEqual(200, resultEl.GeneratedPower.Value()); + + var whrMapMech = WHRPowerReader.Create(VectoCSVFile.ReadStream(data.ToStream()), WHRType.MechanicalOutputDrivetrain); + var resultMech = whrMapMech.GetWHRPower(500.SI<NewtonMeter>(), 600.RPMtoRad(), true); + + Assert.IsFalse(resultMech.Extrapolated); + Assert.AreEqual(400, resultMech.GeneratedPower.Value()); + + } + + [TestCase()] public void ReadXMLSingleFuelEngWithWHR() { @@ -65,7 +109,7 @@ namespace TUGraz.VectoCore.Tests.Models var runs = dao.NextRun().ToArray(); Assert.AreEqual(10, runs.Length); - Assert.IsTrue(runs.All(x => x.EngineData.WHRData?.WHRMap != null)); + Assert.IsTrue(runs.All(x => x.EngineData.ElectricalWHR?.WHRMap != null)); } @@ -87,7 +131,7 @@ namespace TUGraz.VectoCore.Tests.Models var dao = new DeclarationModeVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); var runs = dao.NextRun().ToArray(); - Assert.IsTrue(runs.All(x => x.EngineData.WHRData == null)); + Assert.IsTrue(runs.All(x => x.EngineData.ElectricalWHR == null)); } [TestCase()] @@ -110,7 +154,7 @@ namespace TUGraz.VectoCore.Tests.Models var dao = new DeclarationModeVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); var runs = dao.NextRun().ToArray(); - Assert.IsTrue(runs.All(x => x.EngineData.WHRData == null)); + Assert.IsTrue(runs.All(x => x.EngineData.ElectricalWHR == null)); } [TestCase()] @@ -148,7 +192,7 @@ namespace TUGraz.VectoCore.Tests.Models var runs = dao.NextRun().ToArray(); Assert.AreEqual(10, runs.Length); - Assert.IsTrue(runs.All(x => x.EngineData.WHRData?.WHRMap != null)); + Assert.IsTrue(runs.All(x => x.EngineData.ElectricalWHR?.WHRMap != null)); } [TestCase()] @@ -193,7 +237,7 @@ namespace TUGraz.VectoCore.Tests.Models AssertHelper.Exception<VectoException>( () => { var runs = dao.NextRun().ToArray(); - }, "WHRData (electric power) can only be defined for one fuel!"); + }, "WHRData (electricPower) can only be defined for one fuel!"); } [TestCase()] @@ -266,7 +310,7 @@ namespace TUGraz.VectoCore.Tests.Models var dao = new DeclarationModeVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); var runs = dao.NextRun().ToArray(); - Assert.IsTrue(runs.All(x => x.EngineData.WHRData == null)); + Assert.IsTrue(runs.All(x => x.EngineData.ElectricalWHR == null)); } [TestCase()] @@ -289,7 +333,7 @@ namespace TUGraz.VectoCore.Tests.Models var dao = new DeclarationModeVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); var runs = dao.NextRun().ToArray(); - Assert.IsTrue(runs.All(x => x.EngineData.WHRData == null)); + Assert.IsTrue(runs.All(x => x.EngineData.ElectricalWHR == null)); } @@ -302,7 +346,7 @@ namespace TUGraz.VectoCore.Tests.Models var runs = dao.NextRun().ToArray(); Assert.AreEqual(1, runs.Length); - Assert.IsTrue(runs.All(x => x.EngineData.WHRData?.WHRMap != null)); + Assert.IsTrue(runs.All(x => x.EngineData.ElectricalWHR?.WHRMap != null)); } } } diff --git a/VectoCore/VectoCoreTest/Utils/MockEngineDataProvider.cs b/VectoCore/VectoCoreTest/Utils/MockEngineDataProvider.cs index 0495bebbb2..c562914143 100644 --- a/VectoCore/VectoCoreTest/Utils/MockEngineDataProvider.cs +++ b/VectoCore/VectoCoreTest/Utils/MockEngineDataProvider.cs @@ -75,7 +75,9 @@ namespace TUGraz.VectoCore.Tests.Utils get { return new[] { this }.Cast<IEngineFuelDelcarationInputData>().ToList(); } } - public IWHRData WasteHeatRecoveryData { get; } + public IWHRData WasteHeatRecoveryDataElectrical { get; } + + public IWHRData WasteHeatRecoveryDataMechanical { get; } public Watt RatedPowerDeclared { get; set; } public PerSecond RatedSpeedDeclared { get; set; } -- GitLab