diff --git a/Generic Vehicles/Engineering Mode/AT-TC Demo Vehicle/TorqueConverter.vtcc b/Generic Vehicles/Engineering Mode/AT-TC Demo Vehicle/TorqueConverter.vtcc index 1a329800c28c33ac0448bd4263935f75a63e454c..550030f28fec43b91a9c960f716e61aa48453511 100644 --- a/Generic Vehicles/Engineering Mode/AT-TC Demo Vehicle/TorqueConverter.vtcc +++ b/Generic Vehicles/Engineering Mode/AT-TC Demo Vehicle/TorqueConverter.vtcc @@ -1,9 +1,22 @@ Speed Ratio, Torque Ratio,MP1000 -0,3.935741,563.6598 -0.1,3.296827,534.1364 -0.2,2.701476,504.6129 -0.3,2.265852,472.1372 -0.4,1.931875,421.9474 -0.5,1.554335,354.0435 -0.6,1.249399,268.4255 -0.7,1.075149,114.9037 +0.0,1.80,377.80 +0.1,1.71,365.21 +0.2,1.61,352.62 +0.3,1.52,340.02 +0.4,1.42,327.43 +0.5,1.33,314.84 +0.6,1.23,302.24 +0.7,1.14,264.46 +0.8,1.04,226.68 +0.9,0.95,188.90 +1.0,0.95,0.00 +1.005,1.000,0.00 +1.100,1.000,-40.34 +1.222,1.000,-80.34 +1.375,1.000,-136.11 +1.571,1.000,-216.52 +1.833,1.000,-335.19 +2.200,1.000,-528.77 +2.750,1.000,-883.40 +4.400,1.000,-2462.17 +11.000,1.000,-16540.98 \ No newline at end of file diff --git a/Tools/VectoLegacyTests/TorqueConverterTest.cs b/Tools/VectoLegacyTests/TorqueConverterTest.cs index cbc5b3e0afdcb4bc84af9e31efdacca53e527e8a..c06fe136a0063c3ab944cbb2184cbc2bd9958472 100644 --- a/Tools/VectoLegacyTests/TorqueConverterTest.cs +++ b/Tools/VectoLegacyTests/TorqueConverterTest.cs @@ -19,7 +19,7 @@ namespace VectoLegacyTests try { Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); - } catch (Exception ex) {} + } catch (Exception) {} } [TestMethod] diff --git a/VECTO/GUI/F_GBX.Designer.vb b/VECTO/GUI/F_GBX.Designer.vb index 2ed99dd9f454bc4e1bf15ad72fc445cd7f7a4b30..897c3179f8dbf5957e3be193cf2370d85c05b0b4 100644 --- a/VECTO/GUI/F_GBX.Designer.vb +++ b/VECTO/GUI/F_GBX.Designer.vb @@ -1005,7 +1005,7 @@ Partial Class F_GBX Friend WithEvents PnTC As System.Windows.Forms.Panel Friend WithEvents PnTorqRes As System.Windows.Forms.Panel Friend WithEvents BtAddGear As System.Windows.Forms.Button - Friend WithEvents ColumnHeader4 As System.Windows.Forms.ColumnHeader + Friend WithEvents ColumnHeader4 As System.Windows.Forms.ColumnHeader Friend WithEvents GroupBox4 As System.Windows.Forms.GroupBox Friend WithEvents Label32 As System.Windows.Forms.Label Friend WithEvents PnInertiaTI As System.Windows.Forms.Panel diff --git a/VECTO/GUI/F_GBX.vb b/VECTO/GUI/F_GBX.vb index a0ae69a103f26aadb5842a1dfdb625e0047b3662..8a56a6fa456fd438df6d652220a49b443eb2b508 100644 --- a/VECTO/GUI/F_GBX.vb +++ b/VECTO/GUI/F_GBX.vb @@ -55,7 +55,8 @@ Public Class F_GBX Me.CbGStype.Items.Add("Manual Transmission (MT)") Me.CbGStype.Items.Add("Automated Manual Transmission (AMT)") If Not Cfg.DeclMode Then - Me.CbGStype.Items.Add("Automatic Transmission (AT)") + Me.CbGStype.Items.Add("Automatic Transmission - Serial (AT-S)") + Me.CbGStype.Items.Add("Automatic Transmission - PowerSplit (AT-P)") Me.CbGStype.Items.Add("Custom") End If @@ -243,15 +244,15 @@ Public Class F_GBX lv0 = New ListViewItem(i.ToString("00")) End If - If Me.ChTCon.Checked And i > 0 Then - If GBX0.IsTCgear(i) Then - lv0.SubItems.Add("on") - Else - lv0.SubItems.Add("off") - End If - Else - lv0.SubItems.Add("-") - End If + 'If Me.ChTCon.Checked And i > 0 Then + ' If False Then ' GBX0.IsTCgear(i) Then + ' lv0.SubItems.Add("on") + ' Else + ' lv0.SubItems.Add("off") + ' End If + 'Else + lv0.SubItems.Add("-") + 'End If lv0.SubItems.Add(GBX0.Igetr(i)) lv0.SubItems.Add(GBX0.GetrMap(i, True)) lv0.SubItems.Add(GBX0.gsFile(i, True)) @@ -322,7 +323,7 @@ Public Class F_GBX GBX0.GbxInertia = fTextboxToNumString(Me.TBI_getr.Text) For i = 0 To Me.LvGears.Items.Count - 1 - GBX0.IsTCgear.Add(Me.LvGears.Items(i).SubItems(1).Text = "on" And i > 0) + 'GBX0.IsTCgear.Add(Me.LvGears.Items(i).SubItems(1).Text = "on" And i > 0) GBX0.Igetr.Add(CSng(Me.LvGears.Items(i).SubItems(2).Text)) GBX0.GetrMaps.Add(New cSubPath) GBX0.GetrMap(i) = Me.LvGears.Items(i).SubItems(3).Text @@ -497,7 +498,7 @@ Public Class F_GBX If GStype <> tGearbox.Custom Then Me.ChShiftInside.Checked = cDeclaration.ShiftInside(GStype) Me.ChSkipGears.Checked = cDeclaration.SkipGears(GStype) - Me.ChTCon.Checked = (GStype = tGearbox.Automatic) + Me.ChTCon.Checked = (GStype = tGearbox.AutomaticSerial OrElse GStype = tGearbox.AutomaticPowerSplit) End If End Sub @@ -542,7 +543,7 @@ Public Class F_GBX Do - GearDia.ChIsTCgear.Enabled = (Me.ChTCon.Checked And Me.LvGears.SelectedIndices(0) > 0) + 'GearDia.ChIsTCgear.Enabled = (Me.ChTCon.Checked And Me.LvGears.SelectedIndices(0) > 0) GearDia.PnShiftPoly.Enabled = (Not Cfg.DeclMode And Me.LvGears.SelectedIndices(0) > 0) GearDia.PnFld.Enabled = (Me.LvGears.SelectedIndices(0) > 0) GearDia.GbxPath = fPATH(GbxFile) @@ -567,15 +568,15 @@ Public Class F_GBX If GearDia.ShowDialog = Windows.Forms.DialogResult.OK Then - If GearDia.ChIsTCgear.Checked Then - Me.LvGears.SelectedItems(0).SubItems(1).Text = "on" - Else - If Me.ChTCon.Checked Then - Me.LvGears.SelectedItems(0).SubItems(1).Text = "off" - Else - Me.LvGears.SelectedItems(0).SubItems(1).Text = "-" - End If - End If + 'If GearDia.ChIsTCgear.Checked Then + ' Me.LvGears.SelectedItems(0).SubItems(1).Text = "on" + 'Else + ' If Me.ChTCon.Checked Then + ' Me.LvGears.SelectedItems(0).SubItems(1).Text = "off" + ' Else + Me.LvGears.SelectedItems(0).SubItems(1).Text = "-" + ' End If + 'End If Me.LvGears.SelectedItems(0).SubItems(2).Text = GearDia.TbRatio.Text Me.LvGears.SelectedItems(0).SubItems(3).Text = GearDia.TbMapPath.Text @@ -609,11 +610,11 @@ Public Class F_GBX Dim lvi As ListViewItem lvi = New ListViewItem(Me.LvGears.Items.Count.ToString("00")) - If Me.ChTCon.Checked Then - lvi.SubItems.Add("off") - Else - lvi.SubItems.Add("-") - End If + 'If Me.ChTCon.Checked Then + ' lvi.SubItems.Add("off") + 'Else + lvi.SubItems.Add("-") + 'End If lvi.SubItems.Add("") lvi.SubItems.Add("") lvi.SubItems.Add("") @@ -977,15 +978,15 @@ Public Class F_GBX If lv0.SubItems(0).Text = "Axle" Then Continue For - If Me.ChTCon.Checked Then - If lv0.Index = 1 Then - lv0.SubItems(1).Text = "on" - Else - lv0.SubItems(1).Text = "off" - End If - Else - lv0.SubItems(1).Text = "-" - End If + 'If Me.ChTCon.Checked Then + ' If lv0.Index = 1 Then + ' lv0.SubItems(1).Text = "on" + ' Else + ' lv0.SubItems(1).Text = "off" + ' End If + 'Else + lv0.SubItems(1).Text = "-" + 'End If Next End Sub diff --git a/VECTO/GUI/F_VEH.Designer.vb b/VECTO/GUI/F_VEH.Designer.vb index 30a394f5715164456545a8d368e2fc5b6473c78a..c7ee84b1f602f55958607854f168ff7ea9ec3a33 100644 --- a/VECTO/GUI/F_VEH.Designer.vb +++ b/VECTO/GUI/F_VEH.Designer.vb @@ -108,6 +108,11 @@ Partial Class F_VEH Me.OpenWithToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.ShowInFolderToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.PnAll = New System.Windows.Forms.Panel() + Me.gbPTO = New System.Windows.Forms.GroupBox() + Me.btPTOLossMapBrowse = New System.Windows.Forms.Button() + Me.cbPTOType = New System.Windows.Forms.ComboBox() + Me.tbPTOLossMap = New System.Windows.Forms.TextBox() + Me.Label7 = New System.Windows.Forms.Label() Me.GroupBox3 = New System.Windows.Forms.GroupBox() Me.GroupBox2 = New System.Windows.Forms.GroupBox() Me.pnAngularGearFields = New System.Windows.Forms.Panel() @@ -121,11 +126,6 @@ Partial Class F_VEH Me.PicVehicle = New System.Windows.Forms.PictureBox() Me.Label8 = New System.Windows.Forms.Label() Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components) - Me.gbPTO = New System.Windows.Forms.GroupBox() - Me.Label7 = New System.Windows.Forms.Label() - Me.btPTOLossMapBrowse = New System.Windows.Forms.Button() - Me.tbPTOLossMap = New System.Windows.Forms.TextBox() - Me.cbPTOType = New System.Windows.Forms.ComboBox() Me.GroupBox6.SuspendLayout() Me.ToolStrip1.SuspendLayout() Me.GroupBox7.SuspendLayout() @@ -140,11 +140,11 @@ Partial Class F_VEH CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit() Me.CmOpenFile.SuspendLayout() Me.PnAll.SuspendLayout() + Me.gbPTO.SuspendLayout() Me.GroupBox3.SuspendLayout() Me.GroupBox2.SuspendLayout() Me.pnAngularGearFields.SuspendLayout() CType(Me.PicVehicle, System.ComponentModel.ISupportInitialize).BeginInit() - Me.gbPTO.SuspendLayout() Me.SuspendLayout() ' 'Label1 @@ -820,6 +820,58 @@ Partial Class F_VEH Me.PnAll.Size = New System.Drawing.Size(575, 503) Me.PnAll.TabIndex = 4 ' + 'gbPTO + ' + Me.gbPTO.Controls.Add(Me.btPTOLossMapBrowse) + Me.gbPTO.Controls.Add(Me.cbPTOType) + Me.gbPTO.Controls.Add(Me.tbPTOLossMap) + Me.gbPTO.Controls.Add(Me.Label7) + Me.gbPTO.Location = New System.Drawing.Point(6, 412) + Me.gbPTO.Name = "gbPTO" + Me.gbPTO.Size = New System.Drawing.Size(564, 86) + Me.gbPTO.TabIndex = 4 + Me.gbPTO.TabStop = False + Me.gbPTO.Text = "PTO Transmission" + ' + 'btPTOLossMapBrowse + ' + Me.btPTOLossMapBrowse.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles) + Me.btPTOLossMapBrowse.Image = Global.VECTO.My.Resources.Resources.Open_icon + Me.btPTOLossMapBrowse.Location = New System.Drawing.Point(532, 55) + Me.btPTOLossMapBrowse.Name = "btPTOLossMapBrowse" + Me.btPTOLossMapBrowse.Size = New System.Drawing.Size(24, 24) + Me.btPTOLossMapBrowse.TabIndex = 14 + Me.btPTOLossMapBrowse.UseVisualStyleBackColor = True + ' + 'cbPTOType + ' + Me.cbPTOType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList + Me.cbPTOType.FormattingEnabled = True + Me.cbPTOType.Items.AddRange(New Object() {"None", "only the drive shaft of the PTO - shift claw, synchronizer, Schieberad", "only the drive shaft of the PTO - multi-disc clutch", "only the drive shaft of the PTO - multi-disc clutch, oil pump", "drive shaft and/or up to 2 gear wheels - shift claw, synchronizer, Schieberad", "drive shaft and/or up to 2 gear wheels - multi-disc clutch", "drive shaft and/or up to 2 gear wheels - multi-disc clutch, oil pump", "drive shaft and/or more than 2 gear wheels - shift claw, synchronizer, Schieberad" & _ + "", "drive shaft and/or more than 2 gear wheels - multi-disc clutch", "drive shaft and/or more than 2 gear wheels - multi-disc clutch, oil pump"}) + Me.cbPTOType.Location = New System.Drawing.Point(6, 19) + Me.cbPTOType.Name = "cbPTOType" + Me.cbPTOType.Size = New System.Drawing.Size(550, 21) + Me.cbPTOType.TabIndex = 0 + ' + 'tbPTOLossMap + ' + Me.tbPTOLossMap.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles) + Me.tbPTOLossMap.Location = New System.Drawing.Point(9, 58) + Me.tbPTOLossMap.Name = "tbPTOLossMap" + Me.tbPTOLossMap.Size = New System.Drawing.Size(523, 20) + Me.tbPTOLossMap.TabIndex = 13 + ' + 'Label7 + ' + Me.Label7.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles) + Me.Label7.Location = New System.Drawing.Point(6, 41) + Me.Label7.Name = "Label7" + Me.Label7.Size = New System.Drawing.Size(201, 16) + Me.Label7.TabIndex = 15 + Me.Label7.Text = "PTO Loss Map" + Me.Label7.TextAlign = System.Drawing.ContentAlignment.BottomLeft + ' 'GroupBox3 ' Me.GroupBox3.Controls.Add(Me.PnWheelDiam) @@ -894,7 +946,7 @@ Partial Class F_VEH ' Me.btAngularGearLossMapBrowse.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles) Me.btAngularGearLossMapBrowse.Image = Global.VECTO.My.Resources.Resources.Open_icon - Me.btAngularGearLossMapBrowse.Location = New System.Drawing.Point(244, 39) + Me.btAngularGearLossMapBrowse.Location = New System.Drawing.Point(245, 39) Me.btAngularGearLossMapBrowse.Name = "btAngularGearLossMapBrowse" Me.btAngularGearLossMapBrowse.Size = New System.Drawing.Size(24, 24) Me.btAngularGearLossMapBrowse.TabIndex = 14 @@ -905,7 +957,7 @@ Partial Class F_VEH Me.tbAngularGearLossMapPath.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles) Me.tbAngularGearLossMapPath.Location = New System.Drawing.Point(6, 41) Me.tbAngularGearLossMapPath.Name = "tbAngularGearLossMapPath" - Me.tbAngularGearLossMapPath.Size = New System.Drawing.Size(238, 20) + Me.tbAngularGearLossMapPath.Size = New System.Drawing.Size(239, 20) Me.tbAngularGearLossMapPath.TabIndex = 13 ' 'cbAngularGearType @@ -937,58 +989,6 @@ Partial Class F_VEH Me.Label8.TabIndex = 10 Me.Label8.Text = "HDV Class" ' - 'gbPTO - ' - Me.gbPTO.Controls.Add(Me.btPTOLossMapBrowse) - Me.gbPTO.Controls.Add(Me.cbPTOType) - Me.gbPTO.Controls.Add(Me.tbPTOLossMap) - Me.gbPTO.Controls.Add(Me.Label7) - Me.gbPTO.Location = New System.Drawing.Point(6, 412) - Me.gbPTO.Name = "gbPTO" - Me.gbPTO.Size = New System.Drawing.Size(564, 86) - Me.gbPTO.TabIndex = 4 - Me.gbPTO.TabStop = False - Me.gbPTO.Text = "PTO Transmission" - ' - 'Label7 - ' - Me.Label7.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles) - Me.Label7.Location = New System.Drawing.Point(6, 41) - Me.Label7.Name = "Label7" - Me.Label7.Size = New System.Drawing.Size(201, 16) - Me.Label7.TabIndex = 15 - Me.Label7.Text = "PTO Loss Map" - Me.Label7.TextAlign = System.Drawing.ContentAlignment.BottomLeft - ' - 'btPTOLossMapBrowse - ' - Me.btPTOLossMapBrowse.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles) - Me.btPTOLossMapBrowse.Image = Global.VECTO.My.Resources.Resources.Open_icon - Me.btPTOLossMapBrowse.Location = New System.Drawing.Point(531, 56) - Me.btPTOLossMapBrowse.Name = "btPTOLossMapBrowse" - Me.btPTOLossMapBrowse.Size = New System.Drawing.Size(24, 24) - Me.btPTOLossMapBrowse.TabIndex = 14 - Me.btPTOLossMapBrowse.UseVisualStyleBackColor = True - ' - 'tbPTOLossMap - ' - Me.tbPTOLossMap.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles) - Me.tbPTOLossMap.Location = New System.Drawing.Point(9, 58) - Me.tbPTOLossMap.Name = "tbPTOLossMap" - Me.tbPTOLossMap.Size = New System.Drawing.Size(522, 20) - Me.tbPTOLossMap.TabIndex = 13 - ' - 'cbPTOType - ' - Me.cbPTOType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList - Me.cbPTOType.FormattingEnabled = True - Me.cbPTOType.Items.AddRange(New Object() {"None", "only the drive shaft of the PTO - shift claw, synchronizer, Schieberad", "only the drive shaft of the PTO - multi-disc clutch", "only the drive shaft of the PTO - multi-disc clutch, oil pump", "drive shaft and/or up to 2 gear wheels - shift claw, synchronizer, Schieberad", "drive shaft and/or up to 2 gear wheels - multi-disc clutch", "drive shaft and/or up to 2 gear wheels - multi-disc clutch, oil pump", "drive shaft and/or more than 2 gear wheels - shift claw, synchronizer, Schieberad" & _ - "", "drive shaft and/or more than 2 gear wheels - multi-disc clutch", "drive shaft and/or more than 2 gear wheels - multi-disc clutch, oil pump"}) - Me.cbPTOType.Location = New System.Drawing.Point(6, 19) - Me.cbPTOType.Name = "cbPTOType" - Me.cbPTOType.Size = New System.Drawing.Size(548, 21) - Me.cbPTOType.TabIndex = 0 - ' 'F_VEH ' Me.AcceptButton = Me.ButOK @@ -1039,13 +1039,13 @@ Partial Class F_VEH CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit() Me.CmOpenFile.ResumeLayout(False) Me.PnAll.ResumeLayout(False) + Me.gbPTO.ResumeLayout(False) + Me.gbPTO.PerformLayout() Me.GroupBox3.ResumeLayout(False) Me.GroupBox2.ResumeLayout(False) Me.pnAngularGearFields.ResumeLayout(False) Me.pnAngularGearFields.PerformLayout() CType(Me.PicVehicle, System.ComponentModel.ISupportInitialize).EndInit() - Me.gbPTO.ResumeLayout(False) - Me.gbPTO.PerformLayout() Me.ResumeLayout(False) Me.PerformLayout() diff --git a/VECTO/Input Files/cGBX.vb b/VECTO/Input Files/cGBX.vb index 6b6518593db6b12ee33526e0224cfe3007bd445c..41f2cf929faab3513712562f3c3252b6d70e9f93 100644 --- a/VECTO/Input Files/cGBX.vb +++ b/VECTO/Input Files/cGBX.vb @@ -11,7 +11,7 @@ Imports System.Collections.Generic Public Class cGBX - Private Const FormatVersion As Short = 5 + Private Const FormatVersion As Short = 6 Private FileVersion As Short Private MyPath As String @@ -23,7 +23,7 @@ Public Class cGBX Public Igetr As List(Of Single) Public GetrMaps As List(Of cSubPath) - Public IsTCgear As List(Of Boolean) + 'Public IsTCgear As List(Of Boolean) Private MyGBmaps As List(Of cDelaunayMap) Private GetrEffDef As List(Of Boolean) @@ -117,7 +117,7 @@ Public Class cGBX TracIntrSi = 0 Igetr = New List(Of Single) - IsTCgear = New List(Of Boolean) + 'IsTCgear = New List(Of Boolean) GetrMaps = New List(Of cSubPath) gs_files = New List(Of cSubPath) FldFiles = New List(Of cSubPath) @@ -183,7 +183,7 @@ Public Class cGBX dic0.Add("LossMap", GetrMaps(i).PathOrDummy) End If If i > 0 Then - dic0.Add("TCactive", IsTCgear(i)) + 'dic0.Add("TCactive", IsTCgear(i)) dic0.Add("ShiftPolygon", gs_files(i).PathOrDummy) dic0.Add("FullLoadCurve", FldFiles(i).PathOrDummy) End If @@ -263,11 +263,11 @@ Public Class cGBX FldFiles.Add(New cSubPath) If i = 0 Then - IsTCgear.Add(False) + 'IsTCgear.Add(False) gs_files(i).Init(MyPath, sKey.NoFile) FldFiles(i).Init(MyPath, sKey.NoFile) Else - IsTCgear.Add(dic("TCactive")) + 'IsTCgear.Add(dic("TCactive")) If FileVersion < 2 Then gs_files(i).Init(MyPath, JSON.Content("Body")("ShiftPolygons")) Else @@ -333,7 +333,7 @@ Public Class cGBX MsgSrc = "GBX/DeclInit" - If gs_Type = tGearbox.Custom Or gs_Type = tGearbox.Automatic Then + If gs_Type = tGearbox.Custom Or tGearboxExtension.AutomaticTransmission(gs_Type) Then WorkerMsg(tMsgID.Err, "Invalid gearbox type for Declaration Mode!", MsgSrc) Return False End If @@ -352,7 +352,7 @@ Public Class cGBX DownshiftAfterUpshift = 10 UpshiftMinAcceleration = 0.1 - TCon = (gs_Type = tGearbox.Automatic) + TCon = (AutomaticTransmission(gs_Type)) For i = 1 To GearCount() Shiftpolygons(i).SetGenericShiftPoly(FLD(i), ENG.Nidle) @@ -773,7 +773,7 @@ lbInt: If gs_Type <> tGearbox.Custom Then gs_ShiftInside = cDeclaration.ShiftInside(gs_Type) - TCon = (gs_Type = tGearbox.Automatic) + TCon = AutomaticTransmission(gs_Type) gs_SkipGears = cDeclaration.SkipGears(gs_Type) End If @@ -926,71 +926,71 @@ lbInt: 'Calculate average efficiency for fast approx. calculation If i > 0 Then - If GBX.IsTCgear(i) Then + 'If GBX.IsTCgear(i) Then - GetrEff(i) = -1 + ' GetrEff(i) = -1 - Else - - EffSum = 0 - Anz = 0 + 'Else - dnU = (2 / 3) * (ENG.Nrated - ENG.Nidle) / 10 - nU = ENG.Nidle + dnU + EffSum = 0 + Anz = 0 - Do While nU <= ENG.Nrated + dnU = (2 / 3) * (ENG.Nrated - ENG.Nidle) / 10 + nU = ENG.Nidle + dnU - dM = nPeToM(nU, (2 / 3) * FLD(i).Pfull(nU) / 10) - M_in = nPeToM(nU, (1 / 3) * FLD(i).Pfull(nU)) + Do While nU <= ENG.Nrated - Do While M_in <= nPeToM(nU, FLD(i).Pfull(nU)) + dM = nPeToM(nU, (2 / 3) * FLD(i).Pfull(nU) / 10) + M_in = nPeToM(nU, (1 / 3) * FLD(i).Pfull(nU)) - P_In = nMtoPe(nU, M_in) + Do While M_in <= nPeToM(nU, FLD(i).Pfull(nU)) - P_Loss = IntpolPeLossFwd(i, nU, P_In, False) + P_In = nMtoPe(nU, M_in) - EffSum += (P_In - P_Loss) / P_In - Anz += 1 + P_Loss = IntpolPeLossFwd(i, nU, P_In, False) + EffSum += (P_In - P_Loss) / P_In + Anz += 1 - plossG = P_Loss - MinG = M_in + plossG = P_Loss + MinG = M_in - 'Axle - P_In -= P_Loss - P_Loss = IntpolPeLossFwd(0, nU / GBX.Igetr(i), P_In, False) - EffDiffSum += (P_In - P_Loss) / P_In - AnzDiff += 1 - If MODdata.ModErrors.TrLossMapExtr <> "" Then - WorkerMsg(tMsgID.Err, "Transmission loss map does not cover full engine operating range!", MsgSrc) - WorkerMsg(tMsgID.Err, MODdata.ModErrors.TrLossMapExtr, MsgSrc) - WorkerMsg(tMsgID.Err, "nU_In(GB)=" & nU & " [1/min]", MsgSrc) - WorkerMsg(tMsgID.Err, "M_In(GB)=" & MinG & " [Nm]", MsgSrc) - WorkerMsg(tMsgID.Err, "P_Loss(GB)=" & plossG & " [kW]", MsgSrc) - WorkerMsg(tMsgID.Err, "nU_In(axle)=" & CStr(nU / Igetr(i)) & " [1/min]", MsgSrc) - WorkerMsg(tMsgID.Err, "M_In(axle)=" & CStr(nPeToM(nU / Igetr(i), P_In)) & " [Nm]", MsgSrc) - WorkerMsg(tMsgID.Err, "P_Loss(axle)=" & P_Loss & " [kW]", MsgSrc) - Return False - End If - - M_in += dM - Loop + 'Axle + P_In -= P_Loss + P_Loss = IntpolPeLossFwd(0, nU / GBX.Igetr(i), P_In, False) + EffDiffSum += (P_In - P_Loss) / P_In + AnzDiff += 1 + If MODdata.ModErrors.TrLossMapExtr <> "" Then + WorkerMsg(tMsgID.Err, "Transmission loss map does not cover full engine operating range!", MsgSrc) + WorkerMsg(tMsgID.Err, MODdata.ModErrors.TrLossMapExtr, MsgSrc) + WorkerMsg(tMsgID.Err, "nU_In(GB)=" & nU & " [1/min]", MsgSrc) + WorkerMsg(tMsgID.Err, "M_In(GB)=" & MinG & " [Nm]", MsgSrc) + WorkerMsg(tMsgID.Err, "P_Loss(GB)=" & plossG & " [kW]", MsgSrc) + WorkerMsg(tMsgID.Err, "nU_In(axle)=" & CStr(nU / Igetr(i)) & " [1/min]", MsgSrc) + WorkerMsg(tMsgID.Err, "M_In(axle)=" & CStr(nPeToM(nU / Igetr(i), P_In)) & " [Nm]", MsgSrc) + WorkerMsg(tMsgID.Err, "P_Loss(axle)=" & P_Loss & " [kW]", MsgSrc) + Return False + End If - nU += dnU + M_in += dM Loop - If Anz = 0 Then - WorkerMsg(tMsgID.Err, "Failed to calculate approx. transmission losses!", MsgSrc) - Return False - End If - GetrEff(i) = EffSum / Anz + nU += dnU + Loop + If Anz = 0 Then + WorkerMsg(tMsgID.Err, "Failed to calculate approx. transmission losses!", MsgSrc) + Return False End If + GetrEff(i) = EffSum / Anz + + ' End If + End If diff --git a/VECTO/MODcalc/cPower.vb b/VECTO/MODcalc/cPower.vb index eeec3eb9ebc4a16fa33eff2a858e7a6d7f3eb8ee..ee712ba7ffbc03a5dc87c0538d8df11d2c2d5a42 100644 --- a/VECTO/MODcalc/cPower.vb +++ b/VECTO/MODcalc/cPower.vb @@ -989,7 +989,7 @@ lbCheck: Else - If GBX.TCon And GBX.IsTCgear(Gear) Then + If GBX.TCon And False Then 'GBX.IsTCgear(Gear) Then PlossGB = fPlossGB(Pwheel, Vact, Gear, False) PlossDiff = fPlossDiff(Pwheel, Vact, False) @@ -1121,7 +1121,7 @@ lb_nOK: PaGbx = 0 Case tEngClutch.Closed - If GBX.TCon And GBX.IsTCgear(Gear) Then + If GBX.TCon And False Then ' GBX.IsTCgear(Gear) Then Pclutch = nMtoPe(nU, GBX.TCMin) @@ -1258,7 +1258,9 @@ lb_nOK: If EngState0 = tEngState.Load Then Pbrake = 0 - If GBX.TCon And GBX.IsTCgear(Gear) Then Pbrake = GBX.TC_PeBrake + If GBX.TCon And False Then 'GBX.IsTCgear(Gear) Then + Pbrake = GBX.TC_PeBrake + End If If Math.Abs(P / Pmax - 1) < 0.02 Then EngState0 = tEngState.FullLoad Else ' tEngState.Drag (tEngState.Idle, tEngState.Stopped kann's hier nicht geben weil Clutch <> Closed) If P < Pmin Then @@ -1450,7 +1452,7 @@ lb_nOK: 'Torque Converter output If GBX.TCon Then - If GBX.IsTCgear(Gear) Then + If False Then 'GBX.IsTCgear(Gear) Then If nU = 0 Then MODdata.TCnu.Add(0) Else @@ -2201,19 +2203,19 @@ lb_nOK: If LastGear = 0 Then Return 1 If LastGear < GBX.GearCount Then - PlusGearLockUp = Not GBX.IsTCgear(LastGear + 1) + PlusGearLockUp = True 'Not GBX.IsTCgear(LastGear + 1) Else PlusGearLockUp = False End If If LastGear > 1 Then - MinusGearTC = GBX.IsTCgear(LastGear - 1) + MinusGearTC = False 'GBX.IsTCgear(LastGear - 1) Else MinusGearTC = False End If '2C-to-1C - If MinusGearTC And GBX.IsTCgear(LastGear) Then + If MinusGearTC And False Then ' GBX.IsTCgear(LastGear) Then If fnUout(Vact, LastGear) <= ENG.Nidle Then Return LastGear - 1 End If @@ -2226,7 +2228,7 @@ lb_nOK: End If 'nU - If GBX.IsTCgear(LastGear) Then + If False Then 'GBX.IsTCgear(LastGear) Then n = MODdata.TCnu(t - 1) nU = (Vact * 60.0 * GBX.Igetr(0) * GBX.Igetr(LastGear) / (2 * VEH.rdyn * Math.PI / 1000)) / n Else diff --git a/VECTO/VECTO_Global.vb b/VECTO/VECTO_Global.vb index da0443713bf78622fd66d3bbf7f4f109c7875223..0f08bf71e00386cc4e455c7177dbedbc8c19dbab 100644 --- a/VECTO/VECTO_Global.vb +++ b/VECTO/VECTO_Global.vb @@ -85,8 +85,10 @@ Public Module VECTO_Global Select Case Gearbox Case tGearbox.Manual Return "MT" - Case tGearbox.Automatic - Return "AT" + Case tGearbox.AutomaticSerial + Return "ATSerial" + Case tGearbox.AutomaticPowerSplit + Return "ATPowerSplit" Case tGearbox.SemiAutomatic Return "AMT" Case Else 'tGearbox.Custom @@ -99,7 +101,11 @@ Public Module VECTO_Global Case "MT" Return tGearbox.Manual Case "AT" - Return tGearbox.Automatic + Return tGearbox.AutomaticSerial + Case "ATSERIAL" + Return tGearbox.AutomaticSerial + Case "ATPOWERSPLIT" + Return tGearbox.AutomaticPowerSplit Case "AMT" Return tGearbox.SemiAutomatic Case Else '"Custom" diff --git a/VECTO/VECTO_Types.vb b/VECTO/VECTO_Types.vb index e9e8b68d66453f78707c16e05a38309963e1ed37..bc848ef2b4444c664fae04091743bcd4c78e5eba 100644 --- a/VECTO/VECTO_Types.vb +++ b/VECTO/VECTO_Types.vb @@ -8,6 +8,7 @@ ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports System.Runtime.CompilerServices ''' <summary> ''' Determines how file extensions are set in the File Browser @@ -114,10 +115,23 @@ End Enum Public Enum tGearbox Manual = 0 SemiAutomatic = 1 - Automatic = 2 - Custom = 3 + AutomaticSerial = 2 + AutomaticPowerSplit = 3 + Custom = 4 End Enum +<Extension> +Module tGearboxExtension + Public Function AutomaticTransmission(type As tGearbox) As Boolean + Return type = tGearbox.AutomaticPowerSplit OrElse type = tGearbox.AutomaticSerial + End Function + + + Public Function ManualTransmission(type As tGearbox) As Boolean + Return type = tGearbox.Manual OrElse type = tGearbox.SemiAutomatic + End Function +End Module + Public Enum tVehCat As Integer Undef = 0 RigidTruck = 1 diff --git a/VECTO/cDeclaration.vb b/VECTO/cDeclaration.vb index e416f5cc3d2c88fd77d90a15f7c53740e6b94466..2293ea8d29928eb47005c7a6fc7ffcbaa145e791 100644 --- a/VECTO/cDeclaration.vb +++ b/VECTO/cDeclaration.vb @@ -641,7 +641,7 @@ Public Class cDeclaration End Function Public Shared Function SkipGears(gearbox As tGearbox) As Boolean - If gearbox = tGearbox.Automatic Then + If AutomaticTransmission(Gearbox) Then Return False Else Return True diff --git a/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs b/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs index ad9bdc4e2200f7fff038df103a014b5c8a1655af..7820aa09230cd7d82924e8a1745d928af7141a40 100644 --- a/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs +++ b/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs @@ -199,6 +199,7 @@ namespace TUGraz.VectoCommon.InputData IList<ITransmissionInputData> Gears { get; } } + public interface ITransmissionInputData { int Gear { get; } @@ -240,11 +241,11 @@ namespace TUGraz.VectoCommon.InputData /// </summary> DataTable ShiftPolygon { get; } - /// <summary> - /// P077 - /// cf. VECTO Input Parameters.xlsx - /// </summary> - bool TorqueConverterActive { get; } + ///// <summary> + ///// P077 + ///// cf. VECTO Input Parameters.xlsx + ///// </summary> + //bool HasTorqueConverter { get; } // DEPRECATED } public interface IAxleGearInputData : IComponentInputData @@ -387,6 +388,4 @@ namespace TUGraz.VectoCommon.InputData /// </summary> IList<string> Technology { get; } } - - } \ No newline at end of file diff --git a/VectoCommon/VectoCommon/Models/GearboxType.cs b/VectoCommon/VectoCommon/Models/GearboxType.cs index d35b4e5f3644c744bb524a603cc13e12cb49ec36..dd896dc087e6f229058838711771e375d6df1290 100644 --- a/VectoCommon/VectoCommon/Models/GearboxType.cs +++ b/VectoCommon/VectoCommon/Models/GearboxType.cs @@ -39,13 +39,24 @@ namespace TUGraz.VectoCommon.Models { MT, // Manual Transmission AMT, // Automated Manual Transmission - AT, // Automatic Transmission - Custom, + ATSerial, // Automatic Transmission + ATPowerSplit, + //Custom, DrivingCycle } public static class GearBoxTypeExtension { + public static bool AutomaticTransmission(this GearboxType type) + { + return type == GearboxType.ATPowerSplit || type == GearboxType.ATSerial; + } + + public static bool ManualTransmission(this GearboxType type) + { + return type == GearboxType.MT || type == GearboxType.AMT; + } + public static bool EarlyShiftGears(this GearboxType type) { switch (type) { @@ -53,7 +64,8 @@ namespace TUGraz.VectoCommon.Models return false; case GearboxType.AMT: return true; - case GearboxType.AT: + case GearboxType.ATSerial: + case GearboxType.ATPowerSplit: return false; } return false; @@ -66,7 +78,8 @@ namespace TUGraz.VectoCommon.Models return true; case GearboxType.AMT: return true; - case GearboxType.AT: + case GearboxType.ATSerial: + case GearboxType.ATPowerSplit: return false; } return false; @@ -79,7 +92,8 @@ namespace TUGraz.VectoCommon.Models return 2.SI<Second>(); case GearboxType.AMT: return 1.SI<Second>(); - case GearboxType.AT: + case GearboxType.ATSerial: + case GearboxType.ATPowerSplit: return 0.8.SI<Second>(); } return 0.SI<Second>(); diff --git a/VectoCore/VectoCore/Configuration/Constants.cs b/VectoCore/VectoCore/Configuration/Constants.cs index 51389efcaa97b612838947bd50f089c9d2375e3d..150b39398b0faec56f498fb2f9edc78f43c99893 100644 --- a/VectoCore/VectoCore/Configuration/Constants.cs +++ b/VectoCore/VectoCore/Configuration/Constants.cs @@ -102,7 +102,7 @@ namespace TUGraz.VectoCore.Configuration /// </summary> public static readonly Meter DriveOffDistance = 1.SI<Meter>(); - public static readonly Meter BrakeNextTargetDistance = 5.SI<Meter>(); + public static readonly Meter BrakeNextTargetDistance = 2.5.SI<Meter>(); public static readonly MeterPerSecond MinVelocityForCoast = 5.KMPHtoMeterPerSecond(); @@ -127,8 +127,11 @@ namespace TUGraz.VectoCore.Configuration public const double InterpolateSearchTolerance = 1e-3; public const double ClutchClosingSpeedNorm = 0.03; + public static readonly MeterPerSecond ClutchDisengageWhenHaltingSpeed = 15.KMPHtoMeterPerSecond(); + public static readonly MeterPerSecond ATGearboxDisengageWhenHaltingSpeed = 5.KMPHtoMeterPerSecond(); + public static readonly MeterPerSquareSecond MinimumAcceleration = 0.1.SI<MeterPerSquareSecond>(); public static Meter DriverActionDistanceTolerance = 0.25.SI<Meter>(); diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONGearboxData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONGearboxData.cs index 692ab39d2edb7bb06c497bab775ad82e1f45f5bf..d76f25bf7338e7b934b7fbe1a6fbf45e85eec6b5 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONGearboxData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONGearboxData.cs @@ -29,19 +29,47 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ +using System; using System.Collections.Generic; using System.Data; using System.Linq; using Newtonsoft.Json.Linq; +using Org.BouncyCastle.Asn1.Mozilla; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.InputData.Impl; using TUGraz.VectoCore.Models.Declaration; +using TUGraz.VectoCore.Models.Simulation.Data; namespace TUGraz.VectoCore.InputData.FileIO.JSON { + public class JSONGearboxDataV6 : JSONGearboxDataV5 + { + public JSONGearboxDataV6(JObject data, string filename) : base(data, filename) {} + + public override GearboxType Type + { + get { return Body.GetEx<string>(JsonKeys.Gearbox_GearboxType).ParseEnum<GearboxType>(); } + } + + public override IList<ITransmissionInputData> Gears + { + get + { + var resultGears = new List<ITransmissionInputData>(); + var gears = Body.GetEx(JsonKeys.Gearbox_Gears); + for (var i = 1; i < gears.Count(); i++) { + var gear = gears[i]; + + resultGears.Add(CreateGear(i, gear)); + } + return resultGears; + } + } + } + /// <summary> /// Represents the Data containing all parameters of the gearbox /// </summary> @@ -125,7 +153,20 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public virtual GearboxType Type { - get { return Body.GetEx<string>(JsonKeys.Gearbox_GearboxType).ParseEnum<GearboxType>(); } + get + { + //return Body.GetEx<string>(JsonKeys.Gearbox_GearboxType).ParseEnum<GearboxType>(); + var typeString = Body.GetEx<string>(JsonKeys.Gearbox_GearboxType); + if (!"AT".Equals(typeString)) { + return typeString.ParseEnum<GearboxType>(); + } + var gearRatio = Body.GetEx(JsonKeys.Gearbox_Gears)[1].GetEx<double>(JsonKeys.Gearbox_Gear_Ratio); + var gearEfficiency = Body.GetEx(JsonKeys.Gearbox_Gears)[1][JsonKeys.Gearbox_Gear_Efficiency].Value<double>(); + if (gearRatio.IsEqual(1) && gearEfficiency.IsEqual(1)) { + return GearboxType.ATPowerSplit; + } + return GearboxType.ATSerial; + } } public virtual KilogramSquareMeter Inertia @@ -144,31 +185,73 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON { var resultGears = new List<ITransmissionInputData>(); var gears = Body.GetEx(JsonKeys.Gearbox_Gears); - for (var i = 1; i < gears.Count(); i++) { + var gearNr = 1; + for (var i = 1; i < gears.Count(); i++, gearNr++) { var gear = gears[i]; - var inputData = new TransmissionInputData { - Gear = i, - Ratio = gear.GetEx<double>(JsonKeys.Gearbox_Gear_Ratio), - MaxTorque = gear["MaxTorque"] != null ? gear["MaxTorque"].Value<double>().SI<NewtonMeter>() : null, - LossMap = - gear[JsonKeys.Gearbox_Gear_LossMapFile] != null - ? ReadTableData(gear.GetEx<string>(JsonKeys.Gearbox_Gear_LossMapFile), string.Format("Gear {0} LossMap", i)) - : null, - Efficiency = - gear[JsonKeys.Gearbox_Gear_Efficiency] != null - ? gear[JsonKeys.Gearbox_Gear_Efficiency].Value<double>() - : double.NaN, - ShiftPolygon = - ReadTableData(gear.GetEx<string>(JsonKeys.Gearbox_Gear_ShiftPolygonFile), - string.Format("Gear {0} shiftPolygon", i), false), - TorqueConverterActive = gear.GetEx<bool>(JsonKeys.Gearbox_Gear_TCactive) - }; - resultGears.Add(inputData); + var torqueConverter = gear.GetEx<bool>(JsonKeys.Gearbox_Gear_TCactive); + + if (torqueConverter) { + if (gears[i + 1].GetEx<bool>(JsonKeys.Gearbox_Gear_TCactive)) { + resultGears.Add(CreateGear(gearNr, gear)); + } else { + resultGears.Add(CreateTorqueConverterGear(gearNr, gear, gears[++i])); + } + } else { + resultGears.Add(CreateGear(gearNr, gear)); + } } return resultGears; } } + private TransmissionInputData CreateTorqueConverterGear(int gearNr, JToken gear, JToken nextGear) + { + var ratio = gear.GetEx<double>(JsonKeys.Gearbox_Gear_Ratio); + var efficiency = gear[JsonKeys.Gearbox_Gear_Efficiency] != null + ? gear[JsonKeys.Gearbox_Gear_Efficiency].Value<double>() + : double.NaN; + var nextEfficiency = nextGear[JsonKeys.Gearbox_Gear_Efficiency] != null + ? nextGear[JsonKeys.Gearbox_Gear_Efficiency].Value<double>() + : double.NaN; + var nextRatio = nextGear.GetEx<double>(JsonKeys.Gearbox_Gear_Ratio); + + if (!((ratio.IsEqual(1) && efficiency.IsEqual(1)) || (!ratio.IsEqual(1) && ratio.IsEqual(nextRatio)))) { + throw new VectoException( + "TorqueConverter gear either has to have a ratio of 1 and efficiency of 1, or the ratios of the torque converter gear and the locked gear have to be the same"); + } + return new TransmissionInputData { + Gear = gearNr, + Ratio = nextRatio, + LossMap = nextGear[JsonKeys.Gearbox_Gear_LossMapFile] != null + ? ReadTableData(nextGear.GetEx<string>(JsonKeys.Gearbox_Gear_LossMapFile), + string.Format("Gear {0} LossMap", gearNr)) + : null, + Efficiency = nextEfficiency, + MaxTorque = gear["MaxTorque"] != null ? gear["MaxTorque"].Value<double>().SI<NewtonMeter>() : null, + ShiftPolygon = ReadTableData(gear.GetEx<string>(JsonKeys.Gearbox_Gear_ShiftPolygonFile), + string.Format("Gear {0} shiftPolygon", gearNr), false), + }; + } + + protected TransmissionInputData CreateGear(int gearNumber, JToken gear) + { + return new TransmissionInputData { + Gear = gearNumber, + Ratio = gear.GetEx<double>(JsonKeys.Gearbox_Gear_Ratio), + MaxTorque = gear["MaxTorque"] != null ? gear["MaxTorque"].Value<double>().SI<NewtonMeter>() : null, + LossMap = + gear[JsonKeys.Gearbox_Gear_LossMapFile] != null + ? ReadTableData(gear.GetEx<string>(JsonKeys.Gearbox_Gear_LossMapFile), + string.Format("Gear {0} LossMap", gearNumber)) + : null, + Efficiency = gear[JsonKeys.Gearbox_Gear_Efficiency] != null + ? gear[JsonKeys.Gearbox_Gear_Efficiency].Value<double>() + : double.NaN, + ShiftPolygon = ReadTableData(gear.GetEx<string>(JsonKeys.Gearbox_Gear_ShiftPolygonFile), + string.Format("Gear {0} shiftPolygon", gearNumber), false), + }; + } + public virtual bool SkipGears { get { return Body.GetEx<bool>(JsonKeys.Gearbox_SkipGears); } diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputDataFactory.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputDataFactory.cs index c5bfc3d12a13085a2163d3c05da8eb3b830fc098..bbe30049c62d65b3b805d04dab6dae20cab20574 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputDataFactory.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputDataFactory.cs @@ -83,6 +83,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON switch (version) { case 5: return new JSONGearboxDataV5(json, filename); + case 6: + return new JSONGearboxDataV6(json, filename); default: throw new VectoException("Gearbox-File: Unsupported FileVersion. Got {0}", version); } diff --git a/VectoCore/VectoCore/InputData/Impl/InputData.cs b/VectoCore/VectoCore/InputData/Impl/InputData.cs index 7f065d5a4bf733e92482f20c99f9610d69ff1fdb..0810c78ddcc07b7e13b6d764f3de63093b871077 100644 --- a/VectoCore/VectoCore/InputData/Impl/InputData.cs +++ b/VectoCore/VectoCore/InputData/Impl/InputData.cs @@ -94,8 +94,6 @@ namespace TUGraz.VectoCore.InputData.Impl public NewtonMeter MaxTorque { get; internal set; } public DataTable ShiftPolygon { get; internal set; } - - public bool TorqueConverterActive { get; internal set; } } public class AxleInputData : IAxleEngineeringInputData diff --git a/VectoCore/VectoCore/InputData/Reader/ComponentData/AuxiliaryDataReader.cs b/VectoCore/VectoCore/InputData/Reader/ComponentData/AuxiliaryDataReader.cs index 60541a651f4fa6df57cd4fd137a5036e36ab77e6..47ba95d989897ddc8ed9804e754225ddcb23a88a 100644 --- a/VectoCore/VectoCore/InputData/Reader/ComponentData/AuxiliaryDataReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/ComponentData/AuxiliaryDataReader.cs @@ -34,6 +34,7 @@ namespace TUGraz.VectoCore.InputData.Reader.ComponentData var map = ReadAuxMap(id, table); return new AuxiliaryData(transmissionRatio, efficiencyToEngine, efficiencyToSupply, map); + } catch (FileNotFoundException e) { throw new VectoException("Auxiliary file not found: " + fileName, e); } diff --git a/VectoCore/VectoCore/InputData/Reader/ComponentData/TorqueConverterDataReader.cs b/VectoCore/VectoCore/InputData/Reader/ComponentData/TorqueConverterDataReader.cs index ae2cf4d19212bba5f423c0ea61ab7eb5f134f31d..2d628d8d3e8c30b7207be37f38ec09846591689e 100644 --- a/VectoCore/VectoCore/InputData/Reader/ComponentData/TorqueConverterDataReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/ComponentData/TorqueConverterDataReader.cs @@ -11,17 +11,17 @@ namespace TUGraz.VectoCore.InputData.Reader.ComponentData { public class TorqueConverterDataReader { - public static TorqueConverterData ReadFromFile(string filename) + public static TorqueConverterData ReadFromFile(string filename, PerSecond referenceRpm, PerSecond maxRpm) { - return Create(VectoCSVFile.Read(filename)); + return Create(VectoCSVFile.Read(filename), referenceRpm, maxRpm); } - public static TorqueConverterData ReadFromStream(Stream stream) + public static TorqueConverterData ReadFromStream(Stream stream, PerSecond referenceRpm, PerSecond maxRpm) { - return Create(VectoCSVFile.ReadStream(stream)); + return Create(VectoCSVFile.ReadStream(stream), referenceRpm, maxRpm); } - public static TorqueConverterData Create(DataTable data) + public static TorqueConverterData Create(DataTable data, PerSecond referenceRpm, PerSecond maxRpm) { if (data.Columns.Count != 3) { throw new VectoException("TorqueConverter Characteristics data must consist of 3 columns"); @@ -48,7 +48,7 @@ namespace TUGraz.VectoCore.InputData.Reader.ComponentData TorqueRatio = row.ParseDouble(1) }).ToList(); } - return new TorqueConverterData(characteristicTorque); + return new TorqueConverterData(characteristicTorque, referenceRpm, maxRpm); } private static bool HeaderIsValid(DataColumnCollection columns) diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs index a397415d8860d511619202b041a173a9b2c6bc02..d4bcd9f7b9f67334c351ffee854aa80e2719ca8c 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs @@ -159,7 +159,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter TypeId = data.TypeId, DigestValue = data.DigestValue, IntegrityStatus = data.IntegrityStatus, - AxleGear = new GearData { LossMap = axleLossMap, Ratio = data.Ratio, TorqueConverterActive = false } + AxleGear = new GearData { LossMap = axleLossMap, Ratio = data.Ratio } }; } diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs index 7ff918b66b28b0b1ecc5017652d8087bc87fe7bf..49be92b05ad11f740c2ae76d78472d498807399f 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs @@ -140,7 +140,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter return retVal; } - internal CombustionEngineData CreateEngineData(IEngineDeclarationInputData engine) + internal CombustionEngineData CreateEngineData(IEngineDeclarationInputData engine, GearboxType gearboxType) { if (!engine.SavedInDeclarationMode) { WarnDeclarationMode("EngineData"); @@ -150,7 +150,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter retVal.WHTCUrban = engine.WHTCUrban; retVal.WHTCMotorway = engine.WHTCMotorway; retVal.WHTCRural = engine.WHTCRural; - retVal.Inertia = DeclarationData.Engine.EngineInertia(retVal.Displacement); + retVal.Inertia = DeclarationData.Engine.EngineInertia(retVal.Displacement, gearboxType); retVal.FullLoadCurve = EngineFullLoadCurve.Create(engine.FullLoadCurve, true); retVal.FullLoadCurve.EngineData = retVal; return retVal; @@ -164,11 +164,12 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter } var retVal = SetCommonGearboxData(gearbox); switch (retVal.Type) { - case GearboxType.AT: + case GearboxType.ATPowerSplit: + case GearboxType.ATSerial: throw new VectoSimulationException( "Automatic Transmission currently not supported in DeclarationMode!"); - case GearboxType.Custom: - throw new VectoSimulationException("Custom Transmission not supported in DeclarationMode!"); + //case GearboxType.Custom: + // throw new VectoSimulationException("Custom Transmission not supported in DeclarationMode!"); } var gears = gearbox.Gears; if (gears.Count < 1) { @@ -212,7 +213,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter ShiftPolygon = shiftPolygon, MaxTorque = gear.MaxTorque, Ratio = gear.Ratio, - TorqueConverterActive = false + }); }).ToDictionary(kv => kv.Key, kv => kv.Value); diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs index 0233ef9301aea59c95096e2c03110f880fd682b0..79e2bbf343c2f2539f6af87a46f82f4ffea5dda5 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs @@ -36,6 +36,7 @@ using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.InputData.Reader.ComponentData; using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Models.Simulation.Data; @@ -102,14 +103,15 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter Log.Error("{0} is in Declaration Mode but is used for Engineering Mode!", msg); } - internal CombustionEngineData CreateEngineData(IEngineEngineeringInputData engine) + internal CombustionEngineData CreateEngineData(IEngineEngineeringInputData engine, IGearboxEngineeringInputData gbx) { if (engine.SavedInDeclarationMode) { WarnEngineeringMode("EngineData"); } var retVal = SetCommonCombustionEngineData(engine); - retVal.Inertia = engine.Inertia; + retVal.Inertia = engine.Inertia + + (gbx != null && gbx.Type.AutomaticTransmission() ? gbx.TorqueConverter.Inertia : 0.SI<KilogramSquareMeter>()); retVal.FullLoadCurve = EngineFullLoadCurve.Create(engine.FullLoadCurve); retVal.FullLoadCurve.EngineData = retVal; retVal.WHTCCorrectionFactor = engine.WHTCEngineering; @@ -125,8 +127,8 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter var retVal = SetCommonGearboxData(gearbox); - var gears = gearbox.Gears; - if (gears.Count < 1) { + //var gears = gearbox.Gears; + if (gearbox.Gears.Count < 1) { throw new VectoSimulationException( "At least one Gear-Entry must be defined in Gearbox!"); } @@ -141,7 +143,12 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter retVal.StartSpeed = gearbox.StartSpeed; retVal.StartAcceleration = gearbox.StartAcceleration; - retVal.Gears = gears.Select((gear, i) => { + var gearDifferenceRatio = gearbox.Gears[0].Ratio / gearbox.Gears[1].Ratio; + + var gears = new Dictionary<uint, GearData>(); + + for (uint i = 0; i < gearbox.Gears.Count; i++) { + var gear = gearbox.Gears[(int)i]; TransmissionLossMap lossMap; if (gear.LossMap != null) { lossMap = TransmissionLossMapReader.Create(gear.LossMap, gear.Ratio, string.Format("Gear {0}", i + 1)); @@ -154,16 +161,53 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter var fullLoadCurve = IntersectFullLoadCurves(engineData.FullLoadCurve, gear.MaxTorque); var shiftPolygon = gear.ShiftPolygon != null ? ShiftPolygonReader.Create(gear.ShiftPolygon) - : DeclarationData.Gearbox.ComputeShiftPolygon(i, fullLoadCurve, gears, engineData, axlegearRatio, dynamicTyreRadius); - - return new KeyValuePair<uint, GearData>((uint)(i + 1), new GearData { - LossMap = lossMap, + : DeclarationData.Gearbox.ComputeShiftPolygon((int)i, fullLoadCurve, gearbox.Gears, engineData, axlegearRatio, + dynamicTyreRadius); + var gearData = new GearData { ShiftPolygon = shiftPolygon, MaxTorque = gear.MaxTorque, Ratio = gear.Ratio, - TorqueConverterActive = gear.TorqueConverterActive - }); - }).ToDictionary(kv => kv.Key, kv => kv.Value); + LossMap = lossMap, + }; + + if (gearbox.Type == GearboxType.ATPowerSplit) { + if (i == 0) { + // powersplit transmission: torque converter already contains ratio and losses + gearData.TorqueConverterRatio = 1; + gearData.TorqueConverterGearLossMap = TransmissionLossMapReader.Create(1, 1, string.Format("TCGear {0}", i + 1)); + } + } + if (gearbox.Type == GearboxType.ATSerial) { + if (i == 0) { + // torqueconverter is active in first gear - duplicate ratio and lossmap for torque converter mode + gearData.TorqueConverterRatio = gearData.Ratio; + gearData.TorqueConverterGearLossMap = gearData.LossMap; + } + if (i == 1 && gearDifferenceRatio >= DeclarationData.Gearbox.TorqueConverterSecondGearThreshold) { + // ratio between first and second gear is above threshold, torqueconverter is active in second gear as well + // -> duplicate ratio and lossmap for torque converter mode, remove locked transmission for previous gear + gearData.TorqueConverterRatio = gearData.Ratio; + gearData.TorqueConverterGearLossMap = gearData.LossMap; + // NOTE: the lower gear in 'gears' dictionary has index i !! + gears[i].Ratio = double.NaN; + gears[i].LossMap = null; + } + } + gears.Add(i + 1, gearData); + } + retVal.Gears = gears; + + if (retVal.Gears.Any(g => g.Value.HasTorqueConverter)) { + if (!retVal.Type.AutomaticTransmission()) { + throw new VectoException("Torque Converter can only be used with AT gearbox model"); + } + retVal.TorqueConverterData = TorqueConverterDataReader.Create(gearbox.TorqueConverter.TCData, + gearbox.TorqueConverter.ReferenceRPM, DeclarationData.Gearbox.TorqueConverterSpeedLimit); + } else { + if (retVal.Type.AutomaticTransmission()) { + throw new VectoException("AT gearbox model requires torque converter"); + } + } retVal.DownshiftAfterUpshiftDelay = gearbox.DownshiftAferUpshiftDelay; retVal.UpshiftAfterDownshiftDelay = gearbox.UpshiftAfterDownshiftDelay; diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeVectoRunDataFactory.cs index a14ddc6b9315b95feaec4a9bf82895bbcfd46f2a..f8bfff7cd58b5d448d1b9dd9901fd20610a5ea41 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeVectoRunDataFactory.cs @@ -70,7 +70,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl var tempVehicle = dao.CreateVehicleData(InputDataProvider.VehicleInputData, segment.Missions.First(), segment.Missions.First().Loadings.First().Value); - var engineData = dao.CreateEngineData(InputDataProvider.EngineInputData); + var engineData = dao.CreateEngineData(InputDataProvider.EngineInputData, InputDataProvider.GearboxInputData.Type); var axlegearData = dao.CreateAxleGearData(InputDataProvider.AxleGearInputData, false); var angularGearData = dao.CreateAngularGearData(InputDataProvider.AngularGearInputData, false); var gearboxData = dao.CreateGearboxData(InputDataProvider.GearboxInputData, engineData, axlegearData.AxleGear.Ratio, diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/EngineOnlyVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/EngineOnlyVectoRunDataFactory.cs index 2d17c6f02a38d7a8c7553d64c76aa87421462ecc..2fdaf732bb9976c59219ad8bc9dbeb7252c4404d 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/EngineOnlyVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/EngineOnlyVectoRunDataFactory.cs @@ -52,7 +52,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl foreach (var cycle in InputDataProvider.JobInputData().Cycles) { var simulationRunData = new VectoRunData { JobName = InputDataProvider.JobInputData().JobName, - EngineData = dao.CreateEngineData(InputDataProvider.EngineInputData), + EngineData = dao.CreateEngineData(InputDataProvider.EngineInputData, null), Cycle = DrivingCycleDataReader.ReadFromDataTable(cycle.CycleData, CycleType.EngineOnly, cycle.Name, false), ExecutionMode = ExecutionMode.Engineering }; diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringModeVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringModeVectoRunDataFactory.cs index a90d4ef8086e28476ccac4a9020b261612818c77..597e1775d70610bf16d617d7710bfece2cd9986b 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringModeVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringModeVectoRunDataFactory.cs @@ -61,7 +61,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl { var dao = new EngineeringDataAdapter(); var driver = dao.CreateDriverData(InputDataProvider.DriverInputData); - var engineData = dao.CreateEngineData(InputDataProvider.EngineInputData); + var engineData = dao.CreateEngineData(InputDataProvider.EngineInputData, InputDataProvider.GearboxInputData); var tempVehicle = dao.CreateVehicleData(InputDataProvider.VehicleInputData); diff --git a/VectoCore/VectoCore/Models/Connector/Ports/ITnPort.cs b/VectoCore/VectoCore/Models/Connector/Ports/ITnPort.cs index 644c450c3932772ab551a629caef60acb38e98e2..d01b8ad59877f78f773ebb6167be30b0b1e65c1d 100644 --- a/VectoCore/VectoCore/Models/Connector/Ports/ITnPort.cs +++ b/VectoCore/VectoCore/Models/Connector/Ports/ITnPort.cs @@ -75,8 +75,8 @@ namespace TUGraz.VectoCore.Models.Connector.Ports /// <summary> /// Requests the Outport with the given torque [Nm] and angularVelocity [rad/s]. /// </summary> - IResponse Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity, bool dryRun = false); + IResponse Request(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, bool dryRun = false); - IResponse Initialize(NewtonMeter torque, PerSecond angularVelocity); + IResponse Initialize(NewtonMeter outTorque, PerSecond outAngularVelocity); } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/Connector/Ports/Impl/Response.cs b/VectoCore/VectoCore/Models/Connector/Ports/Impl/Response.cs index 963e7d005936c67bdc5df3798107bc45cd076a0c..7a42e99a468de9ba05e78010e737b6e6c95010ed 100644 --- a/VectoCore/VectoCore/Models/Connector/Ports/Impl/Response.cs +++ b/VectoCore/VectoCore/Models/Connector/Ports/Impl/Response.cs @@ -32,6 +32,8 @@ using System.Linq; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; +using TUGraz.VectoCore.Models.SimulationComponent.Impl; namespace TUGraz.VectoCore.Models.Connector.Ports.Impl { @@ -56,6 +58,8 @@ namespace TUGraz.VectoCore.Models.Connector.Ports.Impl public Watt BrakePower { get; set; } public Watt AuxiliariesPowerDemand { get; set; } + public TorqueConverterOperatingPoint TorqueConverterOperatingPoint { get; set; } + public override string ToString() { var t = GetType(); @@ -114,6 +118,8 @@ namespace TUGraz.VectoCore.Models.Connector.Ports.Impl { public Watt DeltaFullLoad { get; set; } public Watt DeltaDragLoad { get; set; } + public NewtonMeter EngineMaxTorqueOut { get; set; } + public NewtonMeter EngineDragTorque { get; set; } } internal class ResponseGearShift : AbstractResponse {} diff --git a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs index b07512e737f9c911db5fa6ef68003f6177e85703..a1a3c65ec84c1e01c0b106639571c0bc0ad90bc3 100644 --- a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs +++ b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs @@ -203,13 +203,16 @@ namespace TUGraz.VectoCore.Models.Declaration public static class Engine { public static readonly KilogramSquareMeter ClutchInertia = 1.3.SI<KilogramSquareMeter>(); + public static readonly KilogramSquareMeter TorqueConverterInertia = 1.2.SI<KilogramSquareMeter>(); + public static readonly KilogramSquareMeter EngineBaseInertia = 0.41.SI<KilogramSquareMeter>(); public static readonly SI EngineDisplacementInertia = (0.27 * 1000).SI().Kilo.Gramm.Per.Meter; // [kg/m] - public static KilogramSquareMeter EngineInertia(SI displacement) + public static KilogramSquareMeter EngineInertia(SI displacement, GearboxType gbxType) { // VB Code: Return 1.3 + 0.41 + 0.27 * (Displ / 1000) - return ClutchInertia + EngineBaseInertia + EngineDisplacementInertia * displacement; + return (gbxType.AutomaticTransmission() ? TorqueConverterInertia : ClutchInertia) + EngineBaseInertia + + EngineDisplacementInertia * displacement; } } @@ -229,6 +232,8 @@ namespace TUGraz.VectoCore.Models.Declaration public static readonly Second DownshiftAfterUpshiftDelay = 10.SI<Second>(); public static readonly Second UpshiftAfterDownshiftDelay = 10.SI<Second>(); public static readonly MeterPerSquareSecond UpshiftMinAcceleration = 0.1.SI<MeterPerSquareSecond>(); + public static readonly PerSecond TorqueConverterSpeedLimit = 1600.RPMtoRad(); + public static readonly double TorqueConverterSecondGearThreshold = 1.8; /// <summary> /// computes the shift polygons for a single gear according to the whitebook 2016 @@ -283,7 +288,7 @@ namespace TUGraz.VectoCore.Models.Declaration return new ShiftPolygon(downShift, upShift); } - var gearRatio = gears[gear].Ratio / gears[gear + 1].Ratio; + var gearRatio = gears[(int)gear].Ratio / gears[(int)(gear + 1)].Ratio; var rpmMarginFactor = 1 + ShiftPolygonRPMMargin / 100.0; // ReSharper disable InconsistentNaming diff --git a/VectoCore/VectoCore/Models/Simulation/Data/ModalResult.cs b/VectoCore/VectoCore/Models/Simulation/Data/ModalResult.cs index ec2dafecd6a1122826383f119aae110ce19d83f8..429ba2493a139399f279ac0c7da8a37cb23677b8 100644 --- a/VectoCore/VectoCore/Models/Simulation/Data/ModalResult.cs +++ b/VectoCore/VectoCore/Models/Simulation/Data/ModalResult.cs @@ -313,25 +313,43 @@ namespace TUGraz.VectoCore.Models.Simulation.Data /// </summary> [ModalResultField(typeof(SI), outputFactor: 1e-3)] P_aux_, + /// <summary> + /// [-] true/false indicate whether torque converter is locked or not (only applicable for gears with TC) + /// </summary> + [ModalResultField(typeof(int), caption: "TC locked")] TC_Locked, + /// <summary> /// [-] Torque converter speed ratio /// </summary> - [ModalResultField(typeof(SI), name: "TCnu")] TCv, + [ModalResultField(typeof(double), name: "TCnu")] TorqueConverterSpeedRatio, /// <summary> /// [-] Torque converter torque ratio /// </summary> - [ModalResultField(typeof(SI), name: "TCmu")] TCmu, + [ModalResultField(typeof(double), name: "TCmu")] TorqueConverterTorqueRatio, + + [ModalResultField(typeof(SI), "P_TC_out [kW]", outputFactor: 1e-3)] P_TC_out, + [ModalResultField(typeof(SI), "P_TC_loss [kW]", outputFactor: 1e-3)] P_TC_loss, + + /// <summary> + /// [Nm] Torque converter output torque + /// </summary> + [ModalResultField(typeof(SI), "T_TC_out")] TC_TorqueOut, + + /// <summary> + /// [1/min] Torque converter output speed + /// </summary> + [ModalResultField(typeof(SI), "n_TC_out")] TC_angularSpeedOut, /// <summary> /// [Nm] Torque converter output torque /// </summary> - [ModalResultField(typeof(SI))] TC_M_Out, + [ModalResultField(typeof(SI), "T_TC_in")] TC_TorqueIn, /// <summary> /// [1/min] Torque converter output speed /// </summary> - [ModalResultField(typeof(SI))] TC_n_Out, + [ModalResultField(typeof(SI), "n_TC_in")] TC_angularSpeedIn, /// <summary> /// [kW] Power loss at the torque converter. diff --git a/VectoCore/VectoCore/Models/Simulation/DataBus/IDataBus.cs b/VectoCore/VectoCore/Models/Simulation/DataBus/IDataBus.cs index d388216f1d38c77a35ee95855299e591f6d98432..6b68a67eecaf45500613c33e49eed4cf2d181cc3 100644 --- a/VectoCore/VectoCore/Models/Simulation/DataBus/IDataBus.cs +++ b/VectoCore/VectoCore/Models/Simulation/DataBus/IDataBus.cs @@ -30,7 +30,6 @@ */ using TUGraz.VectoCommon.Models; -using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Models.SimulationComponent; namespace TUGraz.VectoCore.Models.Simulation.DataBus diff --git a/VectoCore/VectoCore/Models/Simulation/DataBus/IDriverInfo.cs b/VectoCore/VectoCore/Models/Simulation/DataBus/IDriverInfo.cs index 8b93a251faf9ef221165ea76b27ad8af00511e4a..74b952668c1e683cd3fad489c11609d0809f1b90 100644 --- a/VectoCore/VectoCore/Models/Simulation/DataBus/IDriverInfo.cs +++ b/VectoCore/VectoCore/Models/Simulation/DataBus/IDriverInfo.cs @@ -29,6 +29,8 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ +using TUGraz.VectoCommon.Utils; + namespace TUGraz.VectoCore.Models.Simulation.DataBus { public enum DrivingBehavior @@ -43,5 +45,6 @@ namespace TUGraz.VectoCore.Models.Simulation.DataBus public interface IDriverInfo { DrivingBehavior DriverBehavior { get; } + MeterPerSquareSecond DriverAcceleration { get; } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/Simulation/DataBus/IGearboxInfo.cs b/VectoCore/VectoCore/Models/Simulation/DataBus/IGearboxInfo.cs index 3de4244ed297c935526a9027278016fee838be2f..c03e24c1ca8a3b3c33140a60c74ca9da94061e4f 100644 --- a/VectoCore/VectoCore/Models/Simulation/DataBus/IGearboxInfo.cs +++ b/VectoCore/VectoCore/Models/Simulation/DataBus/IGearboxInfo.cs @@ -29,6 +29,7 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ +using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Models.SimulationComponent.Data; @@ -39,6 +40,8 @@ namespace TUGraz.VectoCore.Models.Simulation.DataBus /// </summary> public interface IGearboxInfo { + GearboxType GearboxType { get; } + /// <summary> /// Returns the current gear. /// </summary> @@ -49,7 +52,7 @@ namespace TUGraz.VectoCore.Models.Simulation.DataBus MeterPerSquareSecond StartAcceleration { get; } - FullLoadCurve GearFullLoadCurve { get; } + NewtonMeter GearMaxTorque { get; } Watt GearboxLoss(); } diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs b/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs index 6212824e207010f9fca8e65660489959f9ce9170..b6022d683b73c3f04dd189ddfe4d74e1577eadef 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs @@ -52,6 +52,9 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public PowertrainBuilder(IModalDataContainer modData, WriteSumData sumWriter = null) { + if (modData == null) { + throw new VectoException("Modal Data Container can't be null"); + } _modData = modData; _sumWriter = sumWriter; } @@ -73,9 +76,10 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl private VehicleContainer BuildEngineOnly(VectoRunData data) { - if (data.Cycle.CycleType != CycleType.EngineOnly) + if (data.Cycle.CycleType != CycleType.EngineOnly) { throw new VectoException("CycleType must be EngineOnly."); - + } + var container = new VehicleContainer(ExecutionMode.Engineering, _modData, _sumWriter) { RunData = data }; var cycle = new PowertrainDrivingCycle(container, data.Cycle); @@ -91,8 +95,9 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl private VehicleContainer BuildPWheel(VectoRunData data) { - if (data.Cycle.CycleType != CycleType.PWheel) + if (data.Cycle.CycleType != CycleType.PWheel) { throw new VectoException("CycleType must be PWheel."); + } var container = new VehicleContainer(ExecutionMode.Engineering, _modData, _sumWriter) { RunData = data }; var gearbox = new CycleGearbox(container, data.GearboxData); @@ -112,32 +117,36 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl private VehicleContainer BuildMeasuredSpeed(VectoRunData data) { - if (data.Cycle.CycleType != CycleType.MeasuredSpeed) + if (data.Cycle.CycleType != CycleType.MeasuredSpeed) { throw new VectoException("CycleType must be MeasuredSpeed."); + } var container = new VehicleContainer(ExecutionMode.Engineering, _modData, _sumWriter) { RunData = data }; - var engine = new CombustionEngine(container, data.EngineData); // MeasuredSpeedDrivingCycle --> vehicle --> wheels --> brakes // --> axleGear --> (retarder) --> CycleGearBox --> (retarder) --> CycleClutch --> engine <-- Aux - new MeasuredSpeedDrivingCycle(container, data.Cycle) + var powertrain = new MeasuredSpeedDrivingCycle(container, data.Cycle) .AddComponent(new Vehicle(container, data.VehicleData)) .AddComponent(new Wheels(container, data.VehicleData.DynamicTyreRadius, data.VehicleData.WheelsInertia)) .AddComponent(new Brakes(container)) .AddComponent(new AxleGear(container, data.AxleGearData)) .AddComponent(data.AngularGearData != null ? new AngularGear(container, data.AngularGearData) : null) - .AddComponent(GetGearbox(container, data.GearboxData), data.Retarder, data.PTOTransmission, container) - .AddComponent(new Clutch(container, data.EngineData, engine.IdleController)) - .AddComponent(engine) + .AddComponent(GetGearbox(container, data.GearboxData), data.Retarder, data.PTOTransmission, container); + if (data.GearboxData.Type.ManualTransmission()) { + powertrain = powertrain.AddComponent(new Clutch(container, data.EngineData)); + } + powertrain.AddComponent(new CombustionEngine(container, data.EngineData)) .AddAuxiliaries(container, data); + _modData.HasTorqueConverter = data.GearboxData.Type.AutomaticTransmission(); return container; } private VehicleContainer BuildMeasuredSpeedGear(VectoRunData data) { - if (data.Cycle.CycleType != CycleType.MeasuredSpeedGear) + if (data.Cycle.CycleType != CycleType.MeasuredSpeedGear) { throw new VectoException("CycleType must be MeasuredSpeed with Gear."); + } var container = new VehicleContainer(ExecutionMode.Engineering, _modData, _sumWriter) { RunData = data }; @@ -165,22 +174,24 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl var container = new VehicleContainer(data.ExecutionMode, _modData, _sumWriter) { RunData = data }; - var engine = new CombustionEngine(container, data.EngineData); - // DistanceBasedDrivingCycle --> driver --> vehicle --> wheels // --> axleGear --> (retarder) --> gearBox --> (retarder) --> clutch --> engine <-- Aux - new DistanceBasedDrivingCycle(container, data.Cycle) + var powertrain = new DistanceBasedDrivingCycle(container, data.Cycle) .AddComponent(new Driver(container, data.DriverData, new DefaultDriverStrategy())) .AddComponent(new Vehicle(container, data.VehicleData)) .AddComponent(new Wheels(container, data.VehicleData.DynamicTyreRadius, data.VehicleData.WheelsInertia)) .AddComponent(new Brakes(container)) .AddComponent(new AxleGear(container, data.AxleGearData)) .AddComponent(data.AngularGearData != null ? new AngularGear(container, data.AngularGearData) : null) - .AddComponent(GetGearbox(container, data.GearboxData), data.Retarder, data.PTOTransmission, container) - .AddComponent(new Clutch(container, data.EngineData, engine.IdleController)) - .AddComponent(engine) + .AddComponent(GetGearbox(container, data.GearboxData), data.Retarder, data.PTOTransmission, container); + if (data.GearboxData.Type.ManualTransmission()) { + powertrain = powertrain.AddComponent(new Clutch(container, data.EngineData)); + } + powertrain.AddComponent(new CombustionEngine(container, data.EngineData)) .AddAuxiliaries(container, data); + _modData.HasTorqueConverter = data.GearboxData.Type.AutomaticTransmission(); + return container; } @@ -227,6 +238,10 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl case GearboxType.MT: strategy = new MTShiftStrategy(data, container); break; + case GearboxType.ATPowerSplit: + case GearboxType.ATSerial: + strategy = new ATShiftStrategy(data, container); + return new ATGearbox(container, data, strategy); default: throw new VectoSimulationException("Unknown Gearbox Type: {0}", data.Type); } diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs b/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs index 2974e10c576a6ea9ece28dbc5ce0d774fdfcdefb..db8744b4c095771924e7ab10dcf762b73c2ab72f 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs @@ -73,6 +73,11 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl #region IGearCockpit + public GearboxType GearboxType + { + get { return Gearbox.GearboxType; } + } + public uint Gear { [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", @@ -112,9 +117,9 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl } } - public FullLoadCurve GearFullLoadCurve + public NewtonMeter GearMaxTorque { - get { return Gearbox != null ? Gearbox.GearFullLoadCurve : null; } + get { return Gearbox != null ? Gearbox.GearMaxTorque : null; } } public Watt GearboxLoss() @@ -266,7 +271,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public void CommitSimulationStep(Second time, Second simulationInterval) { Log.Info("VehicleContainer committing simulation. time: {0}, dist: {1}, speed: {2}", time, - Distance, VehicleSpeed); + Distance, VehicleSpeed); foreach (var component in _components) { component.Item2.CommitSimulationStep(ModData); @@ -343,6 +348,11 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl get { return Driver.DriverBehavior; } } + public MeterPerSquareSecond DriverAcceleration + { + get { return Driver.DriverAcceleration; } + } + public Meter CycleStartDistance { get { return DrivingCycle == null ? 0.SI<Meter>() : DrivingCycle.CycleStartDistance; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/GearData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/GearData.cs index c6eea8806a7b34b36fe1ed22da8c5d2dae487dc8..2edf6ed42e49d70c45dfeb8faf9d8caeea858a5e 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/GearData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/GearData.cs @@ -45,13 +45,27 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox public class GearData : TransmissionData { + public GearData() + { + TorqueConverterRatio = double.NaN; + } + + public bool HasTorqueConverter + { + get { return !double.IsNaN(TorqueConverterRatio) && TorqueConverterGearLossMap != null; } + } + + public bool HasLockedGear + { + get { return !double.IsNaN(Ratio) && LossMap != null; } + } + [ValidateObject] public ShiftPolygon ShiftPolygon { get; internal set; } - [ValidateObject] - public FullLoadCurve FullLoadCurve { get; internal set; } + public double TorqueConverterRatio { get; internal set; } - public bool TorqueConverterActive { get; internal set; } + public TransmissionLossMap TorqueConverterGearLossMap { get; internal set; } public NewtonMeter MaxTorque { get; internal set; } } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/ShiftPolygon.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/ShiftPolygon.cs index 5c50170cc42919bfc0baa5becd15939e798afcaa..e427d65f315ec4f607a1a561684bb4faa0b87d1d 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/ShiftPolygon.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/ShiftPolygon.cs @@ -65,6 +65,25 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox get { return _downShiftPolygon.AsReadOnly(); } } + public bool IsBelowDownshiftCurve(NewtonMeter inTorque, PerSecond inAngularVelocity) + { + var section = Downshift.GetSection(entry => entry.AngularSpeed < inAngularVelocity); + if (section.Item2.AngularSpeed < inAngularVelocity) { + return false; + } + return IsLeftOf(inAngularVelocity, inTorque, section); + } + + public bool IsAboveUpshiftCurve(NewtonMeter inTorque, PerSecond inAngularVelocity) + { + var section = Upshift.GetSection(entry => entry.AngularSpeed < inAngularVelocity); + + if (section.Item2.AngularSpeed < inAngularVelocity) { + return true; + } + return IsRightOf(inAngularVelocity, inTorque, section); + } + /// <summary> /// Tests if current power request is on the left side of the shiftpolygon segment /// </summary> @@ -74,13 +93,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox /// <returns><c>true</c> if current power request is on the left side of the shiftpolygon segment; otherwise, <c>false</c>.</returns> /// <remarks>Computes a simplified cross product for the vectors: from--X, from--to and checks /// if the z-component is positive (which means that X was on the right side of from--to).</remarks> - public static bool IsLeftOf(PerSecond angularSpeed, NewtonMeter torque, + protected static bool IsLeftOf(PerSecond angularSpeed, NewtonMeter torque, Tuple<ShiftPolygonEntry, ShiftPolygonEntry> segment) { - var abX = segment.Item2.AngularSpeed - segment.Item1.AngularSpeed; - var abY = segment.Item2.Torque - segment.Item1.Torque; - var acX = angularSpeed - segment.Item1.AngularSpeed; - var acY = torque - segment.Item1.Torque; + var abX = segment.Item2.AngularSpeed.Value() - segment.Item1.AngularSpeed.Value(); + var abY = segment.Item2.Torque.Value() - segment.Item1.Torque.Value(); + var acX = angularSpeed.Value() - segment.Item1.AngularSpeed.Value(); + var acY = torque.Value() - segment.Item1.Torque.Value(); var z = abX * acY - abY * acX; return z.IsGreater(0); } @@ -94,13 +113,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox /// <returns><c>true</c> if current power request is on the left side of the shiftpolygon segment; otherwise, <c>false</c>.</returns> /// <remarks>Computes a simplified cross product for the vectors: from--X, from--to and checks /// if the z-component is negative (which means that X was on the left side of from--to).</remarks> - public static bool IsRightOf(PerSecond angularSpeed, NewtonMeter torque, + protected static bool IsRightOf(PerSecond angularSpeed, NewtonMeter torque, Tuple<ShiftPolygonEntry, ShiftPolygonEntry> segment) { - var abX = segment.Item2.AngularSpeed - segment.Item1.AngularSpeed; - var abY = segment.Item2.Torque - segment.Item1.Torque; - var acX = angularSpeed - segment.Item1.AngularSpeed; - var acY = torque - segment.Item1.Torque; + var abX = segment.Item2.AngularSpeed.Value() - segment.Item1.AngularSpeed.Value(); + var abY = segment.Item2.Torque.Value() - segment.Item1.Torque.Value(); + var acX = angularSpeed.Value() - segment.Item1.AngularSpeed.Value(); + var acY = torque.Value() - segment.Item1.Torque.Value(); var z = abX * acY - abY * acX; return z.IsSmaller(0); } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/TorqueConverterData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/TorqueConverterData.cs index 1bbcf718f5c1a3fc4e074d644e2a138b61d4e80b..557e3ef5116017fb1ab137f5eed05df8dfd60bd2 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/TorqueConverterData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/TorqueConverterData.cs @@ -31,30 +31,36 @@ using System; using System.Collections.Generic; -using System.Data; -using System.IO; using System.Linq; -using iTextSharp.text.pdf.codec; +using iTextSharp.text.pdf.parser.clipper; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Utils; -using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox { public class TorqueConverterData { - public List<TorqueConverterEntry> TorqueConverterEntries; + protected List<TorqueConverterEntry> TorqueConverterEntries; - protected internal TorqueConverterData(List<TorqueConverterEntry> torqueConverterEntries) + public PerSecond ReferenceSpeed { get; protected internal set; } + + public KilogramSquareMeter Inertia { get; protected internal set; } + + public PerSecond TorqueConverterSpeedLimit { get; protected internal set; } + + protected internal TorqueConverterData(List<TorqueConverterEntry> torqueConverterEntries, PerSecond referenceSpeed, + PerSecond maxRpm) { TorqueConverterEntries = torqueConverterEntries; + ReferenceSpeed = referenceSpeed; + TorqueConverterSpeedLimit = maxRpm; } - public void GetInputTorqueAndAngularSpeed(NewtonMeter torqueOut, PerSecond angularSpeedOut, out NewtonMeter torqueIn, - out PerSecond angularSpeedIn) + + public TorqueConverterOperatingPoint FindOperatingPoint(NewtonMeter torqueOut, PerSecond angularSpeedOut) { var solutions = new List<double>(); - var mpNorm = 1000.RPMtoRad().Value(); + var mpNorm = ReferenceSpeed.Value(); // Find analytic solution for torque converter operating point // mu = f(nu) = f(n_out / n_in) = T_out / T_in @@ -82,24 +88,112 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox solutions.AddRange(selected); } if (solutions.Count == 0) { - throw new VectoException("No solution for input torque/input speed found! n_out: {0}, tq_out: {1}", angularSpeedOut, torqueOut); + throw new VectoException("No solution for input torque/input speed found! n_out: {0}, tq_out: {1}", angularSpeedOut, + torqueOut); } - angularSpeedIn = solutions.Min().SI<PerSecond>(); - var mu = MuLookup(angularSpeedOut / angularSpeedIn); - torqueIn = torqueOut / mu; + var retVal = new TorqueConverterOperatingPoint { + OutTorque = torqueOut, + OutAngularVelocity = angularSpeedOut, + InAngularVelocity = solutions.Min().SI<PerSecond>() + }; + retVal.SpeedRatio = angularSpeedOut / retVal.InAngularVelocity; + retVal.TorqueRatio = MuLookup(angularSpeedOut / retVal.InAngularVelocity); + retVal.InTorque = torqueOut / retVal.TorqueRatio; + + return retVal; } - private double MuLookup(double nu) + private double MuLookup(double speedRatio) { int index; - TorqueConverterEntries.GetSection(x => x.SpeedRatio > nu, out index); - var muEdge = Edge.Create(new Point(TorqueConverterEntries[index].SpeedRatio, TorqueConverterEntries[index].TorqueRatio), - new Point(TorqueConverterEntries[index + 1].SpeedRatio, TorqueConverterEntries[index + 1].TorqueRatio)); - return muEdge.SlopeXY * nu + muEdge.OffsetXY; + TorqueConverterEntries.GetSection(x => x.SpeedRatio < speedRatio, out index); + var retVal = VectoMath.Interpolate(TorqueConverterEntries[index].SpeedRatio, + TorqueConverterEntries[index + 1].SpeedRatio, TorqueConverterEntries[index].TorqueRatio, + TorqueConverterEntries[index + 1].TorqueRatio, speedRatio); + return retVal; + } + + + private NewtonMeter ReferenceTorqueLookup(double speedRatio) + { + int index; + TorqueConverterEntries.GetSection(x => x.SpeedRatio < speedRatio, out index); + var retVal = VectoMath.Interpolate(TorqueConverterEntries[index].SpeedRatio, + TorqueConverterEntries[index + 1].SpeedRatio, TorqueConverterEntries[index].Torque, + TorqueConverterEntries[index + 1].Torque, speedRatio); + return retVal; + } + + public TorqueConverterOperatingPoint GetOutTorque(PerSecond inAngularVelocity, PerSecond outAngularVelocity) + { + var retVal = new TorqueConverterOperatingPoint { + InAngularVelocity = inAngularVelocity, + OutAngularVelocity = outAngularVelocity, + SpeedRatio = outAngularVelocity.Value() / inAngularVelocity.Value(), + }; + foreach (var segment in TorqueConverterEntries.Pairwise(Tuple.Create)) { + if (!(retVal.SpeedRatio >= segment.Item1.SpeedRatio) || !(retVal.SpeedRatio < segment.Item2.SpeedRatio)) { + continue; + } + var mpTorque = VectoMath.Interpolate(segment.Item1.SpeedRatio, segment.Item2.SpeedRatio, segment.Item1.Torque, + segment.Item2.Torque, retVal.SpeedRatio); + retVal.TorqueRatio = VectoMath.Interpolate(segment.Item1.SpeedRatio, segment.Item2.SpeedRatio, + segment.Item1.TorqueRatio, segment.Item2.TorqueRatio, retVal.SpeedRatio); + retVal.InTorque = mpTorque * (inAngularVelocity * inAngularVelocity / ReferenceSpeed / ReferenceSpeed).Value(); + retVal.OutTorque = retVal.InTorque * retVal.TorqueRatio; + return retVal; + } + throw new VectoException("No solution for output speed/input speed found! n_out: {0}, n_in: {1}", outAngularVelocity, + inAngularVelocity); + } + + public TorqueConverterOperatingPoint GetOutTorqueAndSpeed(NewtonMeter inTorque, PerSecond inAngularVelocity, + PerSecond outAngularSpeedEstimated) + { + var referenceTorque = inTorque.Value() / inAngularVelocity.Value() / inAngularVelocity.Value() * + ReferenceSpeed.Value() * ReferenceSpeed.Value(); + var maxTorque = TorqueConverterEntries.Max(x => x.Torque.Value()); + if (referenceTorque.IsGreaterOrEqual(maxTorque)) { + referenceTorque = outAngularSpeedEstimated != null + ? ReferenceTorqueLookup(outAngularSpeedEstimated / inAngularVelocity).Value() + : 0.9 * maxTorque; + } + + var solutions = new List<double>(); + foreach (var edge in TorqueConverterEntries.Pairwise( + (p1, p2) => Edge.Create(new Point(p1.SpeedRatio, p1.Torque.Value()), new Point(p2.SpeedRatio, p2.Torque.Value())))) { + var x = (referenceTorque - edge.OffsetXY) / edge.SlopeXY; + if (x >= edge.P1.X && x < edge.P2.X) { + solutions.Add(x * inAngularVelocity.Value()); + } + } + if (solutions.Count == 0) { + throw new VectoSimulationException( + "Failed to find torque converter Operating Point for inputTorque/inputSpeed! n_in: {0}, tq_in: {1}", + inAngularVelocity, inTorque); + } + return GetOutTorque(inAngularVelocity, solutions.Max().SI<PerSecond>()); } } + public class TorqueConverterOperatingPoint + { + public PerSecond OutAngularVelocity; + public NewtonMeter OutTorque; + + public PerSecond InAngularVelocity; + public NewtonMeter InTorque; + + public double SpeedRatio; + public double TorqueRatio; + + public override string ToString() + { + return string.Format("n_out: {0}, n_in: {1}, tq_out: {2}, tq_in {3}, nu: {4}, my: {5}", OutAngularVelocity, + InAngularVelocity, OutTorque, InTorque, SpeedRatio, TorqueRatio); + } + } public class TorqueConverterEntry { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/GearboxData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/GearboxData.cs index be064b524225f3b1b2dee07345b2b615c0622cd7..5c4160abecc0e3d3e9522a25f31fea8f6d1a49c5 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/GearboxData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/GearboxData.cs @@ -32,6 +32,7 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; +using Newtonsoft.Json; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; @@ -45,12 +46,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data [DataContract] public class GearboxData : SimulationComponentData { + public GearboxType Type { get; internal set; } + /// <summary> /// The gear data. /// </summary> [Required, ValidateObject] public Dictionary<uint, GearData> Gears = new Dictionary<uint, GearData>(); - public GearboxType Type { get; internal set; } + public TorqueConverterData TorqueConverterData { get; internal set; } [Required, SIRange(0, 10)] public KilogramSquareMeter Inertia { get; internal set; } @@ -86,9 +89,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data [Required, Range(0, 0.5)] public double StartTorqueReserve { get; internal set; } + // MQ: TODO: move to Driver Data ? [Required, SIRange(double.Epsilon, 5)] public MeterPerSecond StartSpeed { get; internal set; } + // MQ: TODO: move to Driver Data ? [Required, SIRange(double.Epsilon, 2)] public MeterPerSquareSecond StartAcceleration { get; internal set; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/IClutch.cs b/VectoCore/VectoCore/Models/SimulationComponent/IClutch.cs index 5c41fc0e460efbff67374221a6b80f21b101e75f..7b38571e55eb7a9071b54282f76d050565e55855 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/IClutch.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/IClutch.cs @@ -42,6 +42,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent public interface IClutch : IPowerTrainComponent { - ITnOutPort IdleControlPort { get; } + //ITnOutPort IdleControlPort { get; } + ICombustionEngineIdleController IdleController { get; set; } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/IShiftStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/IShiftStrategy.cs index 2c3cbde209aec529719f5b80b53cd9db08699485..2cb77d1e63c06d60e7da957ef2b7c2ee369b7649 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/IShiftStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/IShiftStrategy.cs @@ -70,9 +70,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent /// <param name="absTime">The abs time.</param> /// <param name="dt">The dt.</param> /// <param name="outTorque">The out torque.</param> - /// <param name="outEngineSpeed">The out engine speed.</param> + /// <param name="outAngularVelocity">The out engine speed.</param> /// <returns>The gear to take.</returns> - uint Engage(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outEngineSpeed); + uint Engage(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity); /// <summary> /// Disengages a gear. @@ -89,6 +89,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent /// <value> /// The gearbox. /// </value> - Gearbox Gearbox { get; set; } + IGearbox Gearbox { get; set; } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategy.cs index 3c30b7274508c8865bde7b69e26e5279364a4d60..76b97e56b9957f243473fd8a4915c57b215d63db 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategy.cs @@ -93,14 +93,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl for (var gear = (uint)Data.Gears.Count; gear > 1; gear--) { var inAngularSpeed = outAngularVelocity * Data.Gears[gear].Ratio; - var ratedSpeed = Data.Gears[gear].FullLoadCurve != null - ? Data.Gears[gear].FullLoadCurve.RatedSpeed - : DataBus.EngineRatedSpeed; + var ratedSpeed = DataBus.EngineRatedSpeed; if (inAngularSpeed > ratedSpeed || inAngularSpeed.IsEqual(0)) { continue; } - var response = Gearbox.Initialize(gear, outTorque, outAngularVelocity); + var response = _gearbox.Initialize(gear, outTorque, outAngularVelocity); var fullLoadPower = response.EnginePowerRequest - response.DeltaFullLoad; var reserve = 1 - response.EnginePowerRequest / fullLoadPower; @@ -115,7 +113,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return 1; } for (var gear = (uint)Data.Gears.Count; gear > 1; gear--) { - var response = Gearbox.Initialize(gear, outTorque, outAngularVelocity); + var response = _gearbox.Initialize(gear, outTorque, outAngularVelocity); var inAngularSpeed = outAngularVelocity * Data.Gears[gear].Ratio; var fullLoadPower = response.EnginePowerRequest - response.DeltaFullLoad; @@ -192,7 +190,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (DataBus.DriverBehavior != DrivingBehavior.Accelerating && DataBus.DriverBehavior != DrivingBehavior.Driving) { return currentGear; } - if ((absTime - Gearbox.LastDownshift).IsSmaller(Gearbox.ModelData.UpshiftAfterDownshiftDelay)) { + if ((absTime - _gearbox.LastDownshift).IsSmaller(_gearbox.ModelData.UpshiftAfterDownshiftDelay)) { return currentGear; } var nextGear = DoCheckUpshift(absTime, dt, outTorque, outAngularVelocity, inTorque, inAngularVelocity, currentGear); @@ -201,7 +199,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } // estimate acceleration for selected gear - if (EstimateAccelerationForGear(nextGear, outAngularVelocity).IsSmaller(Gearbox.ModelData.UpshiftMinAcceleration)) { + if (EstimateAccelerationForGear(nextGear, outAngularVelocity).IsSmaller(_gearbox.ModelData.UpshiftMinAcceleration)) { // if less than 0.1 for next gear, don't shift if (nextGear - currentGear == 1) { return currentGear; @@ -209,7 +207,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl // if a gear is skipped but acceleration is less than 0.1, try for next gear. if acceleration is still below 0.1 don't shift! if (nextGear > currentGear && EstimateAccelerationForGear(currentGear + 1, outAngularVelocity) - .IsSmaller(Gearbox.ModelData.UpshiftMinAcceleration)) { + .IsSmaller(_gearbox.ModelData.UpshiftMinAcceleration)) { return currentGear; } nextGear = currentGear + 1; @@ -221,7 +219,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected virtual uint CheckDownshift(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, NewtonMeter inTorque, PerSecond inAngularVelocity, uint currentGear) { - if ((absTime - Gearbox.LastUpshift).IsSmaller(Gearbox.ModelData.DownshiftAfterUpshiftDelay)) { + if ((absTime - _gearbox.LastUpshift).IsSmaller(_gearbox.ModelData.DownshiftAfterUpshiftDelay)) { return currentGear; } return DoCheckDownshift(absTime, dt, outTorque, outAngularVelocity, inTorque, inAngularVelocity, currentGear); @@ -238,9 +236,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } var tmpGear = Gearbox.Gear; - Gearbox.Gear = currentGear; - var response = (ResponseDryRun)Gearbox.Request(absTime, dt, outTorque, outAngularVelocity, true); - Gearbox.Gear = tmpGear; + _gearbox.Gear = currentGear; + var response = (ResponseDryRun)_gearbox.Request(absTime, dt, outTorque, outAngularVelocity, true); + _gearbox.Gear = tmpGear; inAngularVelocity = Data.Gears[currentGear].Ratio * outAngularVelocity; inTorque = response.ClutchPowerRequest / inAngularVelocity; @@ -251,9 +249,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl // try if next gear would provide enough torque reserve var tryNextGear = currentGear + 1; var tmpGear = Gearbox.Gear; - Gearbox.Gear = tryNextGear; - var response = (ResponseDryRun)Gearbox.Request(absTime, dt, outTorque, outAngularVelocity, true); - Gearbox.Gear = tmpGear; + _gearbox.Gear = tryNextGear; + var response = (ResponseDryRun)_gearbox.Request(absTime, dt, outTorque, outAngularVelocity, true); + _gearbox.Gear = tmpGear; inAngularVelocity = Data.Gears[tryNextGear].Ratio * outAngularVelocity; inTorque = response.ClutchPowerRequest / inAngularVelocity; @@ -282,9 +280,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl break; } var tmpGear = Gearbox.Gear; - Gearbox.Gear = currentGear; - var response = (ResponseDryRun)Gearbox.Request(absTime, dt, outTorque, outAngularVelocity, true); - Gearbox.Gear = tmpGear; + _gearbox.Gear = currentGear; + var response = (ResponseDryRun)_gearbox.Request(absTime, dt, outTorque, outAngularVelocity, true); + _gearbox.Gear = tmpGear; inAngularVelocity = Data.Gears[currentGear].Ratio * outAngularVelocity; inTorque = response.ClutchPowerRequest / inAngularVelocity; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs new file mode 100644 index 0000000000000000000000000000000000000000..f797e4f1e5ea964319cecda2263beaa2ea65fb9d --- /dev/null +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs @@ -0,0 +1,317 @@ +using TUGraz.VectoCommon.Exceptions; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Configuration; +using TUGraz.VectoCore.Models.Connector.Ports; +using TUGraz.VectoCore.Models.Connector.Ports.Impl; +using TUGraz.VectoCore.Models.Simulation; +using TUGraz.VectoCore.Models.Simulation.Data; +using TUGraz.VectoCore.Models.Simulation.DataBus; +using TUGraz.VectoCore.Models.SimulationComponent.Data; +using TUGraz.VectoCore.OutputData; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.Models.SimulationComponent.Impl +{ + public class ATGearbox : AbstractGearbox<ATGearbox.ATGearboxState> + { + protected internal bool Disengaged = true; + + protected internal readonly IShiftStrategy Strategy; + + protected readonly TorqueConverter TorqueConverter; + + public Second LastShift { get; private set; } + + public ATGearbox(IVehicleContainer container, GearboxData gearboxModelData, IShiftStrategy strategy) + : base(container, gearboxModelData) + { + Strategy = strategy; + Strategy.Gearbox = this; + LastShift = -double.MaxValue.SI<Second>(); + TorqueConverter = new TorqueConverter(this, Strategy, container, gearboxModelData.TorqueConverterData); + } + + private ICombustionEngineIdleController _idleController; + + public bool TorqueConverterLocked { get; protected internal set; } + + public ICombustionEngineIdleController IdleController + { + get { return _idleController; } + set + { + _idleController = value; + _idleController.RequestPort = NextComponent; + } + } + + public new void Connect(ITnOutPort other) + { + NextComponent = other; + TorqueConverter.NextComponent = NextComponent; + } + + public override IResponse Initialize(NewtonMeter outTorque, PerSecond outAngularVelocity) + { + if (Disengaged) { + Gear = Strategy.InitGear(0.SI<Second>(), Constants.SimulationSettings.TargetTimeInterval, outTorque, + outAngularVelocity); + } + var inAngularVelocity = 0.SI<PerSecond>(); + var inTorque = 0.SI<NewtonMeter>(); + var effectiveRatio = ModelData.Gears[Gear].Ratio; + var effectiveLossMap = ModelData.Gears[Gear].LossMap; + if (!TorqueConverterLocked) { + effectiveRatio = ModelData.Gears[Gear].TorqueConverterRatio; + effectiveLossMap = ModelData.Gears[Gear].TorqueConverterGearLossMap; + } + if (!DataBus.VehicleStopped) { + inAngularVelocity = outAngularVelocity * effectiveRatio; + var torqueLossResult = effectiveLossMap.GetTorqueLoss(outAngularVelocity, outTorque); + CurrentState.TorqueLossResult = torqueLossResult; + + //todo mk-2016-08-22: aux loss from out-direction or in-direction of the gearbox? + var auxTorqueLoss = Auxiliary == null ? 0.SI<NewtonMeter>() : Auxiliary.Initialize(outTorque, outAngularVelocity); + + inTorque = outTorque / effectiveRatio + torqueLossResult.Value + auxTorqueLoss; + } + if (Disengaged) { + return NextComponent.Initialize(0.SI<NewtonMeter>(), null); + } + + if (!TorqueConverterLocked && !ModelData.Gears[Gear].HasTorqueConverter) { + throw new VectoSimulationException("Torque converter requested by strategy for gear without torque converter!"); + } + var response = TorqueConverterLocked + ? NextComponent.Initialize(inTorque, inAngularVelocity) + : TorqueConverter.Initialize(inTorque, inAngularVelocity); + + PreviousState.SetState(inTorque, inAngularVelocity, outTorque, outAngularVelocity); + PreviousState.Gear = Gear; + PreviousState.TorqueConverterLocked = TorqueConverterLocked; + return response; + } + + internal ResponseDryRun Initialize(uint gear, bool torqueConverterLocked, NewtonMeter outTorque, + PerSecond outAngularVelocity) + { + var effectiveRatio = torqueConverterLocked ? ModelData.Gears[gear].Ratio : ModelData.Gears[gear].TorqueConverterRatio; + + var inAngularVelocity = outAngularVelocity * effectiveRatio; + var torqueLossResult = torqueConverterLocked + ? ModelData.Gears[gear].LossMap.GetTorqueLoss(outAngularVelocity, outTorque) + : ModelData.Gears[Gear].TorqueConverterGearLossMap.GetTorqueLoss(outAngularVelocity, outTorque); + + //todo mk-2016-08-22: aux loss from out-direction or in-direction of the gearbox? + var auxTorqueLoss = Auxiliary == null ? 0.SI<NewtonMeter>() : Auxiliary.Initialize(outTorque, outAngularVelocity); + + var inTorque = outTorque / effectiveRatio + torqueLossResult.Value + auxTorqueLoss; + + IResponse response; + if (torqueConverterLocked) { + response = NextComponent.Initialize(inTorque, inAngularVelocity); + } else { + if (!ModelData.Gears[gear].HasTorqueConverter) { + throw new VectoSimulationException("Torque converter requested by strategy for gear without torque converter!"); + } + response = TorqueConverter.Initialize(inTorque, inAngularVelocity); + } + + response.Switch(). + Case<ResponseSuccess>(). + Case<ResponseUnderload>(). + Case<ResponseOverload>(). + Default(r => { throw new UnexpectedResponseException("AT-Gearbox.Initialize", r); }); + + return new ResponseDryRun() { + Source = this, + EngineSpeed = response.EngineSpeed, + EnginePowerRequest = response.EnginePowerRequest, + GearboxPowerRequest = outTorque * outAngularVelocity, + }; + } + + public override IResponse Request(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, + bool dryRun = false) + { + IterationStatistics.Increment(this, "Requests"); + + Log.Debug("AT-Gearbox Power Request: torque: {0}, angularVelocity: {1}", outTorque, outAngularVelocity); + + if (DataBus.VehicleStopped && outAngularVelocity > 0) { + Gear = Strategy.InitGear(absTime, dt, outTorque, outAngularVelocity); + LastShift = absTime; + Disengaged = false; + } + + IResponse retVal; + var count = 0; + var loop = false; + do { + if (Disengaged || (DataBus.DriverBehavior == DrivingBehavior.Halted)) { + // only when vehicle is halted or close before halting + retVal = RequestDisengaged(absTime, dt, outTorque, outAngularVelocity, dryRun); + } else { + Disengaged = false; + retVal = RequestEngaged(absTime, dt, outTorque, outAngularVelocity, dryRun); + IdleController.Reset(); + } + retVal.Switch() + .Case<ResponseGearShift>(r => { + loop = true; + Gear = Strategy.Engage(absTime, dt, outTorque, outAngularVelocity); + LastShift = absTime; + }); + } while (loop && ++count < 2); + + retVal.GearboxPowerRequest = outTorque * (PreviousState.OutAngularVelocity + outAngularVelocity) / 2.0; + return retVal; + } + + private IResponse RequestEngaged(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, + bool dryRun) + { + var effectiveRatio = ModelData.Gears[Gear].Ratio; + var effectiveLossMap = ModelData.Gears[Gear].LossMap; + if (!TorqueConverterLocked) { + effectiveRatio = ModelData.Gears[Gear].TorqueConverterRatio; + effectiveLossMap = ModelData.Gears[Gear].TorqueConverterGearLossMap; + } + + var avgOutAngularVelocity = (PreviousState.OutAngularVelocity + outAngularVelocity) / 2.0; + + var inTorqueLossResult = effectiveLossMap.GetTorqueLoss(avgOutAngularVelocity, outTorque); + + CurrentState.TorqueLossResult = inTorqueLossResult; + + var inTorque = outTorque / effectiveRatio + inTorqueLossResult.Value; + + if (Auxiliary != null) { + //todo mk-2016-08-22: aux loss from out-direction or in-direction of the gearbox? + inTorque += Auxiliary.PowerDemand(absTime, dt, outTorque, inTorque, outAngularVelocity, dryRun); + } + + if (!TorqueConverterLocked && !ModelData.Gears[Gear].HasTorqueConverter) { + throw new VectoSimulationException("Torque converter requested by strategy for gear without torque converter!"); + } + var inAngularVelocity = outAngularVelocity * effectiveRatio; + + CurrentState.InertiaTorqueLossOut = !inAngularVelocity.IsEqual(0) + ? Formulas.InertiaPower(outAngularVelocity, PreviousState.OutAngularVelocity, ModelData.Inertia, dt) / + avgOutAngularVelocity + : 0.SI<NewtonMeter>(); + inTorque += CurrentState.InertiaTorqueLossOut / effectiveRatio; + + CurrentState.SetState(inTorque, inAngularVelocity, outTorque, outAngularVelocity); + CurrentState.Gear = Gear; + CurrentState.TorqueConverterLocked = TorqueConverterLocked; + CurrentState.TransmissionTorqueLoss = inTorque - outTorque / effectiveRatio; + + if (!TorqueConverterLocked) { + return TorqueConverter.Request(absTime, dt, inTorque, inAngularVelocity, dryRun); + } + if (!dryRun && + Strategy.ShiftRequired(absTime, dt, outTorque, outAngularVelocity, inTorque, inAngularVelocity, Gear, LastShift)) { + return new ResponseGearShift() { + Source = this + }; + } + + TorqueConverter.Locked(CurrentState.InTorque, CurrentState.InAngularVelocity); + return NextComponent.Request(absTime, dt, inTorque, inAngularVelocity, dryRun); + } + + private IResponse RequestDisengaged(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, + bool dryRun) + { + var avgAngularVelocity = (PreviousState.OutAngularVelocity + outAngularVelocity) / 2.0; + if (dryRun) { + // if gearbox is disengaged the 0[W]-line is the limit for drag and full load. + return new ResponseDryRun { + Source = this, + GearboxPowerRequest = outTorque * avgAngularVelocity, + DeltaDragLoad = outTorque * avgAngularVelocity, + DeltaFullLoad = outTorque * avgAngularVelocity, + }; + } + if ((outTorque * avgAngularVelocity).IsGreater(0.SI<Watt>(), Constants.SimulationSettings.LineSearchTolerance)) { + return new ResponseOverload { + Source = this, + Delta = outTorque * avgAngularVelocity, + GearboxPowerRequest = outTorque * avgAngularVelocity + }; + } + + if ((outTorque * avgAngularVelocity).IsSmaller(0.SI<Watt>(), Constants.SimulationSettings.LineSearchTolerance)) { + return new ResponseUnderload { + Source = this, + Delta = outTorque * avgAngularVelocity, + GearboxPowerRequest = outTorque * avgAngularVelocity + }; + } + + Log.Debug("Invoking IdleController..."); + + var retval = IdleController.Request(absTime, dt, 0.SI<NewtonMeter>(), null); + retval.ClutchPowerRequest = 0.SI<Watt>(); + CurrentState.SetState(0.SI<NewtonMeter>(), retval.EngineSpeed, outTorque, outAngularVelocity); + + TorqueConverter.Locked(CurrentState.InTorque, CurrentState.InAngularVelocity); + + CurrentState.Gear = 0; + return retval; + } + + protected override void DoWriteModalResults(IModalDataContainer container) + { + var avgInAngularSpeed = (PreviousState.OutAngularVelocity + + CurrentState.OutAngularVelocity) / 2.0 * ModelData.Gears[Gear].Ratio; + + container[ModalResultField.Gear] = Disengaged || DataBus.VehicleStopped ? 0 : Gear; + container[ModalResultField.TC_Locked] = TorqueConverterLocked; + + container[ModalResultField.P_gbx_loss] = CurrentState.TransmissionTorqueLoss * avgInAngularSpeed; + container[ModalResultField.P_gbx_inertia] = CurrentState.InertiaTorqueLossOut * avgInAngularSpeed; + container[ModalResultField.P_gbx_in] = CurrentState.InTorque * avgInAngularSpeed; + } + + protected override void DoCommitSimulationStep() + { + if (!Disengaged) { + if (CurrentState.TorqueLossResult != null && CurrentState.TorqueLossResult.Extrapolated) { + Log.Warn( + "Gear {0} LossMap data was extrapolated: range for loss map is not sufficient: n:{1}, torque:{2}, ratio:{3}", + Gear, CurrentState.OutAngularVelocity.ConvertTo().Rounds.Per.Minute, CurrentState.OutTorque, + ModelData.Gears[Gear].Ratio); + if (DataBus.ExecutionMode == ExecutionMode.Declaration) { + throw new VectoException( + "Gear {0} LossMap data was extrapolated in Declaration Mode: range for loss map is not sufficient: n:{1}, torque:{2}, ratio:{3}", + Gear, CurrentState.InAngularVelocity.ConvertTo().Rounds.Per.Minute, CurrentState.InTorque, + ModelData.Gears[Gear].Ratio); + } + } + } + if (DataBus.VehicleStopped) { + Disengaged = true; + } + AdvanceState(); + } + + public override bool ClutchClosed(Second absTime) + { + return true; + } + + public class ATGearboxState : GearboxState + { + public bool TorqueConverterLocked; + + //public PerSecond TorqueConverterTorqueOut; + //public PerSecond TorqueConverterAngularSpeedOut; + + //public double TorqueConverterSpeedRatio; + //public double TorqueConverterTorqueRatio; + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATShiftStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATShiftStrategy.cs new file mode 100644 index 0000000000000000000000000000000000000000..c74ac61420d8f77b4eeac0e51b2c0bb9e9e35870 --- /dev/null +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATShiftStrategy.cs @@ -0,0 +1,267 @@ +using System.Linq; +using TUGraz.VectoCommon.Exceptions; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Configuration; +using TUGraz.VectoCore.Models.Simulation.DataBus; +using TUGraz.VectoCore.Models.SimulationComponent.Data; +using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; + +namespace TUGraz.VectoCore.Models.SimulationComponent.Impl +{ + public class ATShiftStrategy : LoggingObject, IShiftStrategy + { + protected GearboxData Data; + + protected IDataBus DataBus; + private ATGearbox _gearbox; + + protected NextGearState NextGear; + + public ATShiftStrategy(GearboxData data, IDataBus dataBus) + { + Data = data; + DataBus = dataBus; + NextGear = new NextGearState(); + } + + //public ATGearbox Gearbox { get; protected internal set; } + + public uint InitGear(Second absTime, Second dt, NewtonMeter torque, PerSecond outAngularVelocity) + { + if (DataBus.VehicleSpeed.IsEqual(0)) { + _gearbox.TorqueConverterLocked = false; + _gearbox.Disengaged = true; + return 1; // AT always starts in first gear! + } + var torqueConverterLocked = true; + for (var gear = Data.Gears.Keys.Max(); gear > 1; gear--) { + if (_gearbox.ModelData.Gears[gear].HasTorqueConverter) { + torqueConverterLocked = false; + } + var response = _gearbox.Initialize(gear, torqueConverterLocked, torque, outAngularVelocity); + + if (response.EngineSpeed > DataBus.EngineRatedSpeed || response.EngineSpeed < DataBus.EngineIdleSpeed) { + continue; + } + + if (!IsBelowDownShiftCurve(gear, response.EnginePowerRequest / response.EngineSpeed, response.EngineSpeed)) { + _gearbox.TorqueConverterLocked = torqueConverterLocked; + _gearbox.Disengaged = false; + return gear; + } + } + // fallback: start with first gear; + _gearbox.TorqueConverterLocked = false; + _gearbox.Disengaged = false; + return 1; + } + + public bool ShiftRequired(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, + NewtonMeter inTorque, PerSecond inAngularVelocity, uint gear, Second lastShiftTime) + { + if (_gearbox.Disengaged && outAngularVelocity.IsGreater(0.SI<PerSecond>())) { + // drive off after stop - engage first gear + Log.Debug("shift requried: drive off after vehicle stopped"); + NextGear.SetState(absTime, false, 1, false); + return true; + } + if (DataBus.DriverBehavior == DrivingBehavior.Braking && + DataBus.VehicleSpeed.IsSmaller(Constants.SimulationSettings.ATGearboxDisengageWhenHaltingSpeed) && + outTorque.IsSmaller(0.SI<NewtonMeter>())) { + // disengage before halting + NextGear.SetState(absTime, true, 1, false); + return true; + } + + if (inAngularVelocity != null) { + // emergency shift to not stall the engine ------------------------ + if (_gearbox.TorqueConverterLocked && inAngularVelocity.IsEqual(0.SI<PerSecond>())) { + NextGear.SetState(absTime, false, 1, false); + return true; + } + if (inAngularVelocity.IsSmaller(DataBus.EngineIdleSpeed)) { + if (_gearbox.TorqueConverterLocked) { + // downshift L -> L / C + if (Data.Gears[gear].HasTorqueConverter) { + NextGear.SetState(absTime, false, gear, false); + return true; + } + if (Data.Gears.ContainsKey(gear - 1) && Data.Gears[gear - 1].HasLockedGear) { + NextGear.SetState(absTime, false, gear - 1, true); + return true; + } + } else { + // downshift C -> C / 0 + if (Data.Gears.ContainsKey(gear - 1) && Data.Gears[gear - 1].HasTorqueConverter) { + // C -> C + NextGear.SetState(absTime, false, gear - 1, false); + return true; + } + // C -> 0 + NextGear.SetState(absTime, true, 1, false); + return true; + } + NextGear.SetState(absTime, false, gear - 1, !Data.Gears[gear - 1].HasTorqueConverter); + Log.Debug("engine speed would fall below idle speed - shift down"); + return true; + } + if (inAngularVelocity.IsGreater(DataBus.EngineRatedSpeed)) { + NextGear.SetState(absTime, false, gear + 1, Data.Gears[gear + 1].HasLockedGear); + Log.Debug("engine speed would be above rated speed - shift up"); + return true; + } + } + + if ((absTime - lastShiftTime).IsSmaller(Data.ShiftTime)) { + return false; + } + + if (CheckDownshift(absTime, dt, outTorque, outAngularVelocity, inTorque, inAngularVelocity, gear, lastShiftTime)) { + return true; + } + if (CheckUpshift(absTime, dt, outTorque, outAngularVelocity, inTorque, inAngularVelocity, gear, lastShiftTime)) { + return true; + } + + return false; + } + + private bool CheckUpshift(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, + NewtonMeter inTorque, PerSecond inAngularVelocity, uint gear, Second lastShiftTime) + { + if (gear == Data.Gears.Keys.Max()) { + return false; + } + if ((!_gearbox.TorqueConverterLocked && Data.Gears[gear].HasLockedGear) || _gearbox.TorqueConverterLocked) { + // C -> L , or L -> L upshift + var nextGear = gear; + if (_gearbox.TorqueConverterLocked) { + nextGear = gear + 1; + } + var nextEngineSpeed = outAngularVelocity * Data.Gears[nextGear].Ratio; + var enginePower = inAngularVelocity * inTorque; + if (nextEngineSpeed.IsEqual(0)) { + return false; + } + if (IsAboveUpShiftCurve(gear, enginePower / nextEngineSpeed, nextEngineSpeed) && + enginePower.IsSmallerOrEqual(DataBus.EngineStationaryFullPower(nextEngineSpeed))) { + NextGear.SetState(absTime, false, nextGear, true); + return true; + } + } + if (!_gearbox.TorqueConverterLocked && Data.Gears.ContainsKey(gear + 1) && Data.Gears[gear + 1].HasTorqueConverter) { + // C -> C upshift + // TODO! + } + return false; + } + + private bool CheckDownshift(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, + NewtonMeter inTorque, PerSecond inAngularVelocity, uint gear, Second lastShiftTime) + { + if (_gearbox.TorqueConverterLocked) { + if (inAngularVelocity != null && inAngularVelocity.IsSmaller(DataBus.EngineIdleSpeed)) { + // n_eng < n_eng_idle + if (Data.Gears[gear].HasTorqueConverter) { + // L -> C shift + NextGear.SetState(absTime, false, gear, false); + } else if (Data.Gears.ContainsKey(gear - 1) && Data.Gears[gear - 1].HasLockedGear) { + // L -> L shift + NextGear.SetState(absTime, false, gear - 1, true); + } else { + throw new VectoSimulationException("Downshift required, but failed to select gear!"); + } + } + } else { + // already in converter mode + if (!Data.Gears.ContainsKey(gear - 1)) { + // downshift not possible + return false; + } + if (inAngularVelocity != null && inAngularVelocity.IsSmaller(DataBus.EngineIdleSpeed)) { + NextGear.SetState(absTime, false, gear - 1, false); + return true; + } + } + + return false; + } + + public uint Engage(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity) + { + if (NextGear.AbsTime != null && NextGear.AbsTime.IsEqual(absTime)) { + _gearbox.TorqueConverterLocked = NextGear.TorqueConverterLocked; + _gearbox.Disengaged = NextGear.Disengaged; + NextGear.AbsTime = null; + return NextGear.Gear; + } + NextGear.AbsTime = null; + return _gearbox.Gear; + } + + public void Disengage(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outEngineSpeed) + { + throw new System.NotImplementedException(); + } + + public IGearbox Gearbox + { + get { return _gearbox; } + set + { + var myGearbox = value as ATGearbox; + if (myGearbox == null) { + throw new VectoException("AT Shift strategy can only handle AT gearboxes, given: {0}", value.GetType()); + } + _gearbox = myGearbox; + } + } + + /// <summary> + /// Tests if the operating point is below the down-shift curve (=outside of shift curve). + /// </summary> + /// <param name="gear">The gear.</param> + /// <param name="inTorque">The in torque.</param> + /// <param name="inEngineSpeed">The in engine speed.</param> + /// <returns><c>true</c> if the operating point is below the down-shift curv; otherwise, <c>false</c>.</returns> + protected virtual bool IsBelowDownShiftCurve(uint gear, NewtonMeter inTorque, PerSecond inEngineSpeed) + { + if (gear <= 1) { + return false; + } + return Data.Gears[gear].ShiftPolygon.IsBelowDownshiftCurve(inTorque, inEngineSpeed); + } + + /// <summary> + /// Tests if the operating point is above the up-shift curve (=outside of shift curve). + /// </summary> + /// <param name="gear">The gear.</param> + /// <param name="inTorque">The in torque.</param> + /// <param name="inEngineSpeed">The in engine speed.</param> + /// <returns><c>true</c> if the operating point is above the up-shift curve; otherwise, <c>false</c>.</returns> + protected virtual bool IsAboveUpShiftCurve(uint gear, NewtonMeter inTorque, PerSecond inEngineSpeed) + { + if (gear >= Data.Gears.Count) { + return false; + } + return Data.Gears[gear].ShiftPolygon.IsAboveUpshiftCurve(inTorque, inEngineSpeed); + } + + protected class NextGearState + { + public Second AbsTime; + public bool Disengaged; + public uint Gear; + public bool TorqueConverterLocked; + + public void SetState(Second absTime, bool disengaged, uint gear, bool tcLocked) + { + AbsTime = absTime; + Disengaged = disengaged; + Gear = gear; + TorqueConverterLocked = tcLocked; + } + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AbstractGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AbstractGearbox.cs new file mode 100644 index 0000000000000000000000000000000000000000..d3b438c429617756af5f772b10ea4fae43bb5a32 --- /dev/null +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AbstractGearbox.cs @@ -0,0 +1,99 @@ +using System.ComponentModel.DataAnnotations; +using System.Diagnostics; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Models.Connector.Ports; +using TUGraz.VectoCore.Models.Simulation; +using TUGraz.VectoCore.Models.Simulation.DataBus; +using TUGraz.VectoCore.Models.SimulationComponent.Data; +using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; + +namespace TUGraz.VectoCore.Models.SimulationComponent.Impl +{ + public abstract class AbstractGearbox<TStateType> : + StatefulProviderComponent<TStateType, ITnOutPort, ITnInPort, ITnOutPort>, ITnOutPort, ITnInPort, IGearbox, IClutchInfo + where TStateType : GearboxState, new() + { + /// <summary> + /// The data and settings for the gearbox. + /// </summary> + [Required, ValidateObject] internal readonly GearboxData ModelData; + + protected IAuxPort Auxiliary; + + protected AbstractGearbox(IVehicleContainer container, GearboxData gearboxModelData) : base(container) + { + ModelData = gearboxModelData; + } + + #region ITnOutPort + + public abstract IResponse Request(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, + bool dryRun = false); + + public abstract IResponse Initialize(NewtonMeter outTorque, PerSecond outAngularVelocity); + + #endregion + + #region IGearboxCockpit + + public GearboxType GearboxType + { + get { return ModelData.Type; } + } + + /// <summary> + /// The current gear. + /// </summary> + public uint Gear { get; protected internal set; } + + [DebuggerHidden] + public MeterPerSecond StartSpeed + { + get { return ModelData.StartSpeed; } + } + + [DebuggerHidden] + public MeterPerSquareSecond StartAcceleration + { + get { return ModelData.StartAcceleration; } + } + + public NewtonMeter GearMaxTorque + { + get { return Gear == 0 || !ModelData.Gears.ContainsKey(Gear) ? null : ModelData.Gears[Gear].MaxTorque; } + } + + public Watt GearboxLoss() + { + //var outTorque = ModelData.Gears[Gear].LossMap.GetOutTorque(inAngularVelocity, inTorque, true); + //var torqueLoss = inTorque - outTorque * ModelData.Gears[Gear].Ratio; + + //return torqueLoss * inAngularVelocity; + + return (PreviousState.TransmissionTorqueLoss + + PreviousState.InertiaTorqueLossOut / ModelData.Gears[PreviousState.Gear].Ratio) * PreviousState.InAngularVelocity; + } + + #endregion + + #region IAuxPortProvider + + public void Connect(IAuxPort aux) + { + Auxiliary = aux; + } + + #endregion + + public abstract bool ClutchClosed(Second absTime); + } + + public class GearboxState : SimpleComponentState + { + public NewtonMeter InertiaTorqueLossOut = 0.SI<NewtonMeter>(); + public NewtonMeter TransmissionTorqueLoss = 0.SI<NewtonMeter>(); + public uint Gear; + public TransmissionLossMap.LossMapResult TorqueLossResult; + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AngularGear.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AngularGear.cs index e91b0e2269d40a3a66999f29dddb526504db4d02..e43c65d55ba01d86a20ad5d0482e29c2373a07cf 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AngularGear.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AngularGear.cs @@ -42,11 +42,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { public AngularGear(IVehicleContainer container, AngularGearData modelData) : base(container, modelData.AngularGear) {} - public override IResponse Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity, + public override IResponse Request(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, bool dryRun = false) { - var retVal = base.Request(absTime, dt, torque, angularVelocity, dryRun); - retVal.AngularGearPowerRequest = torque * (PreviousState.OutAngularVelocity + CurrentState.OutAngularVelocity) / 2.0; + var retVal = base.Request(absTime, dt, outTorque, outAngularVelocity, dryRun); + retVal.AngularGearPowerRequest = outTorque * (PreviousState.OutAngularVelocity + CurrentState.OutAngularVelocity) / 2.0; return retVal; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AxleGear.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AxleGear.cs index 1a6f2e3d8a61aadc98b4317ccfd610fadc772032..a169a68106f9bd7522e07b6a618c46fcaa53773e 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AxleGear.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AxleGear.cs @@ -42,11 +42,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { public AxleGear(IVehicleContainer container, AxleGearData modelData) : base(container, modelData.AxleGear) {} - public override IResponse Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity, + public override IResponse Request(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, bool dryRun = false) { - var retVal = base.Request(absTime, dt, torque, angularVelocity, dryRun); - retVal.AxlegearPowerRequest = torque * (PreviousState.OutAngularVelocity + CurrentState.OutAngularVelocity) / 2.0; + var retVal = base.Request(absTime, dt, outTorque, outAngularVelocity, dryRun); + retVal.AxlegearPowerRequest = outTorque * (PreviousState.OutAngularVelocity + CurrentState.OutAngularVelocity) / 2.0; return retVal; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Brakes.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Brakes.cs index a08e3ab4bbb175956267f94489c251cd19dde245..b2d3f197f1582c8f5307f3435a0f96e1c17bf807 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Brakes.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Brakes.cs @@ -57,14 +57,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl : NextComponent.Initialize(torque, angularVelocity); } - public IResponse Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity, bool dryRun = false) + public IResponse Request(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, bool dryRun = false) { var brakeTorque = 0.SI<NewtonMeter>(); - var avgAngularSpeed = (PreviousState.OutAngularVelocity + angularVelocity) / 2.0; + var avgAngularSpeed = (PreviousState.OutAngularVelocity + outAngularVelocity) / 2.0; if (!BrakePower.IsEqual(0)) { if (avgAngularSpeed.IsEqual(0)) { - brakeTorque = torque; + brakeTorque = outTorque; } else { brakeTorque = BrakePower / avgAngularSpeed; } @@ -73,9 +73,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (!dryRun && BrakePower < 0) { throw new VectoSimulationException("Negative Braking Power is not allowed!"); } - CurrentState.SetState(torque + brakeTorque, angularVelocity, torque, angularVelocity); + CurrentState.SetState(outTorque + brakeTorque, outAngularVelocity, outTorque, outAngularVelocity); - var retVal = NextComponent.Request(absTime, dt, torque + brakeTorque, angularVelocity, dryRun); + var retVal = NextComponent.Request(absTime, dt, outTorque + brakeTorque, outAngularVelocity, dryRun); retVal.BrakePower = brakeTorque * avgAngularSpeed; return retVal; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Clutch.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Clutch.cs index e5715462930140503ccd880c73d46e5d9f85b635..3af177aabb8a955c1aad93a00002986feb9ebddb 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Clutch.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Clutch.cs @@ -50,19 +50,27 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl private const double ClutchEff = 1; private ClutchState _clutchState = ClutchState.ClutchSlipping; - protected ICombustionEngineIdleController IdleController; + public ICombustionEngineIdleController IdleController + { + get { return _idleController; } + set + { + _idleController = value; + _idleController.RequestPort = NextComponent; + } + } + private readonly SI _clutchSpeedSlippingFactor; + private ICombustionEngineIdleController _idleController; protected Clutch(IVehicleContainer container) : base(container) {} - public Clutch(IVehicleContainer container, CombustionEngineData engineData, - ICombustionEngineIdleController idleController) : base(container) + public Clutch(IVehicleContainer container, CombustionEngineData engineData) : base(container) { _idleSpeed = engineData.IdleSpeed; _ratedSpeed = engineData.FullLoadCurve.RatedSpeed; _clutchSpeedSlippingFactor = Constants.SimulationSettings.ClutchClosingSpeedNorm * (_ratedSpeed - _idleSpeed) / (_idleSpeed + Constants.SimulationSettings.ClutchClosingSpeedNorm * (_ratedSpeed - _idleSpeed)); - IdleController = idleController; } public ClutchState State() @@ -70,12 +78,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return _clutchState; } - public ITnOutPort IdleControlPort - { - get { return NextComponent; } - } + //public ITnOutPort IdleControlPort + //{ + // get { return NextComponent; } + //} - public virtual IResponse Initialize(NewtonMeter torque, PerSecond angularVelocity) + public virtual IResponse Initialize(NewtonMeter outTorque, PerSecond outAngularVelocity) { NewtonMeter torqueIn; PerSecond engineSpeedIn; @@ -84,32 +92,32 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl engineSpeedIn = _idleSpeed; torqueIn = 0.SI<NewtonMeter>(); } else { - AddClutchLoss(torque, angularVelocity, out torqueIn, out engineSpeedIn); + AddClutchLoss(outTorque, outAngularVelocity, out torqueIn, out engineSpeedIn); } - PreviousState.SetState(torqueIn, angularVelocity, torque, angularVelocity); + PreviousState.SetState(torqueIn, outAngularVelocity, outTorque, outAngularVelocity); var retVal = NextComponent.Initialize(torqueIn, engineSpeedIn); - retVal.ClutchPowerRequest = torque * angularVelocity; + retVal.ClutchPowerRequest = outTorque * outAngularVelocity; return retVal; } - public virtual IResponse Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity, + public virtual IResponse Request(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, bool dryRun = false) { - if (angularVelocity == null) { + if (outAngularVelocity == null) { Log.Debug("Invoking IdleController..."); - var retval = IdleController.Request(absTime, dt, torque, null, dryRun); + var retval = IdleController.Request(absTime, dt, outTorque, null, dryRun); retval.ClutchPowerRequest = 0.SI<Watt>(); - CurrentState.SetState(0.SI<NewtonMeter>(), retval.EngineSpeed, torque, retval.EngineSpeed); + CurrentState.SetState(0.SI<NewtonMeter>(), retval.EngineSpeed, outTorque, retval.EngineSpeed); return retval; } if (IdleController != null) { IdleController.Reset(); } - Log.Debug("from Wheels: torque: {0}, angularVelocity: {1}, power {2}", torque, angularVelocity, - Formulas.TorqueToPower(torque, angularVelocity)); + Log.Debug("from Wheels: torque: {0}, angularVelocity: {1}, power {2}", outTorque, outAngularVelocity, + Formulas.TorqueToPower(outTorque, outAngularVelocity)); NewtonMeter torqueIn; PerSecond angularVelocityIn; @@ -118,15 +126,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl angularVelocityIn = _idleSpeed; torqueIn = 0.SI<NewtonMeter>(); } else { - AddClutchLoss(torque, angularVelocity, out torqueIn, out angularVelocityIn); + AddClutchLoss(outTorque, outAngularVelocity, out torqueIn, out angularVelocityIn); } Log.Debug("to Engine: torque: {0}, angularVelocity: {1}, power {2}", torqueIn, angularVelocityIn, Formulas.TorqueToPower(torqueIn, angularVelocityIn)); - CurrentState.SetState(torqueIn, angularVelocityIn, torque, angularVelocity); + CurrentState.SetState(torqueIn, angularVelocityIn, outTorque, outAngularVelocity); var retVal = NextComponent.Request(absTime, dt, torqueIn, angularVelocityIn, dryRun); - retVal.ClutchPowerRequest = torque * + retVal.ClutchPowerRequest = outTorque * ((PreviousState.OutAngularVelocity ?? 0.SI<PerSecond>()) + CurrentState.OutAngularVelocity) / 2.0; return retVal; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs index 1c5f892fd142ba7df356fb1e210ffa2216a07381..aa7381653a2292e5a923f604bcbcb274a7f8666e 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs @@ -153,14 +153,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #region ITnOutPort - public IResponse Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity, bool dryRun) + public IResponse Request(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, bool dryRun) { IterationStatistics.Increment(this, "Requests"); - Log.Debug("Engine Powertrain Power Request: torque: {0}, angularVelocity: {1}, power: {2}", torque, angularVelocity, - torque * angularVelocity); + Log.Debug("Engine Powertrain Power Request: torque: {0}, angularVelocity: {1}, power: {2}", outTorque, + outAngularVelocity, + outTorque * outAngularVelocity); - return DoHandleRequest(absTime, dt, torque, angularVelocity, dryRun); + return DoHandleRequest(absTime, dt, outTorque, outAngularVelocity, dryRun); } protected virtual IResponse DoHandleRequest(Second absTime, Second dt, NewtonMeter torqueOut, @@ -201,13 +202,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ValidatePowerDemand(totalTorqueDemand); // requires CurrentState.FullDragTorque and DynamicfullLoad to be set! // get max. torque as limited by gearbox. gearbox only limits torqueOut! - NewtonMeter gearboxFullLoad = null; - var curve = DataBus.GearFullLoadCurve; - if (curve != null) { - // if the current gear has a full-load curve, limit the max. torque to the - // gbx. full-load and continue (remmber the delta for further below) - gearboxFullLoad = curve.FullLoadStationaryTorque(avgEngineSpeed); - } + var gearboxFullLoad = DataBus.GearMaxTorque; var deltaFull = ComputeDelta(torqueOut, totalTorqueDemand, CurrentState.DynamicFullLoadTorque, gearboxFullLoad, true); var deltaDrag = ComputeDelta(torqueOut, totalTorqueDemand, CurrentState.FullDragTorque, @@ -220,6 +215,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl EnginePowerRequest = torqueOut * avgEngineSpeed, AuxiliariesPowerDemand = auxTorqueDemand * avgEngineSpeed, EngineSpeed = angularVelocity, + EngineMaxTorqueOut = + VectoMath.Max(CurrentState.DynamicFullLoadTorque - auxTorqueDemand - CurrentState.InertiaTorqueLoss, + gearboxFullLoad ?? 0.SI<NewtonMeter>()), + EngineDragTorque = CurrentState.FullDragTorque - auxTorqueDemand - CurrentState.InertiaTorqueLoss, Source = this, }; } @@ -291,21 +290,28 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return motoring ? VectoMath.Max(deltaGbx, deltaEngine) : VectoMath.Min(deltaGbx, deltaEngine); } - public IResponse Initialize(NewtonMeter torque, PerSecond angularSpeed) + public IResponse Initialize(NewtonMeter outTorque, PerSecond outAngularVelocity) { - var auxDemand = EngineAux == null ? 0.SI<NewtonMeter>() : EngineAux.Initialize(torque, angularSpeed); + if (outAngularVelocity == null) { + outAngularVelocity = EngineIdleSpeed; + } + var auxDemand = EngineAux == null ? 0.SI<NewtonMeter>() : EngineAux.Initialize(outTorque, outAngularVelocity); PreviousState = new EngineState { - EngineSpeed = angularSpeed, + EngineSpeed = outAngularVelocity, dt = 1.SI<Second>(), InertiaTorqueLoss = 0.SI<NewtonMeter>(), - StationaryFullLoadTorque = ModelData.FullLoadCurve.FullLoadStationaryTorque(angularSpeed), - FullDragTorque = ModelData.FullLoadCurve.DragLoadStationaryTorque(angularSpeed), - EngineTorque = torque + auxDemand, - EnginePower = (torque + auxDemand) * angularSpeed, + StationaryFullLoadTorque = ModelData.FullLoadCurve.FullLoadStationaryTorque(outAngularVelocity), + FullDragTorque = ModelData.FullLoadCurve.DragLoadStationaryTorque(outAngularVelocity), + EngineTorque = outTorque + auxDemand, + EnginePower = (outTorque + auxDemand) * outAngularVelocity, }; PreviousState.DynamicFullLoadTorque = PreviousState.StationaryFullLoadTorque; - return new ResponseSuccess { Source = this, EnginePowerRequest = PreviousState.EnginePower }; + return new ResponseSuccess { + Source = this, + EnginePowerRequest = PreviousState.EnginePower, + EngineSpeed = outAngularVelocity + }; } /// <summary> @@ -497,13 +503,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl IdleStart = null; } - public IResponse Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity, + public IResponse Request(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, bool dryRun = false) { - if (angularVelocity != null) { + if (outAngularVelocity != null) { throw new VectoException("IdleController can only handle idle requests, i.e. angularVelocity == null!"); } - if (!torque.IsEqual(0)) { + if (!outTorque.IsEqual(0)) { throw new VectoException("Torque has to be 0 for idle requests!"); } if (IdleStart == null) { @@ -519,7 +525,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var nextEnginePower = (LastEnginePower - dragLoad) * VectoMath.Max(idleTime.Value() * PeDropSlope + PeDropOffset, 0) + dragLoad; - var auxDemandResponse = RequestPort.Request(absTime, dt, torque, prevEngineSpeed, true); + var auxDemandResponse = RequestPort.Request(absTime, dt, outTorque, prevEngineSpeed, true); var deltaEnginePower = nextEnginePower - (auxDemandResponse.AuxiliariesPowerDemand ?? 0.SI<Watt>()); var deltaTorque = deltaEnginePower / prevEngineSpeed; @@ -527,7 +533,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var nextAngularSpeed = prevEngineSpeed; if (deltaAngularSpeed > 0) { - retVal = RequestPort.Request(absTime, dt, torque, nextAngularSpeed); + retVal = RequestPort.Request(absTime, dt, outTorque, nextAngularSpeed); return retVal; } @@ -536,25 +542,25 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl nextAngularSpeed = Engine.ModelData.IdleSpeed; } - retVal = RequestPort.Request(absTime, dt, torque, nextAngularSpeed); + retVal = RequestPort.Request(absTime, dt, outTorque, nextAngularSpeed); retVal.Switch(). Case<ResponseSuccess>(). Case<ResponseUnderload>(r => { var angularSpeed = SearchAlgorithm.Search(nextAngularSpeed, r.Delta, Constants.SimulationSettings.EngineIdlingSearchInterval, getYValue: result => ((ResponseDryRun)result).DeltaDragLoad, - evaluateFunction: n => RequestPort.Request(absTime, dt, torque, n, true), + evaluateFunction: n => RequestPort.Request(absTime, dt, outTorque, n, true), criterion: result => ((ResponseDryRun)result).DeltaDragLoad.Value()); Log.Debug("Found operating point for idling. absTime: {0}, dt: {1}, torque: {2}, angularSpeed: {3}", absTime, dt, - torque, angularSpeed); - retVal = RequestPort.Request(absTime, dt, torque, angularSpeed); + outTorque, angularSpeed); + retVal = RequestPort.Request(absTime, dt, outTorque, angularSpeed); }). Default(r => { throw new UnexpectedResponseException("searching Idling point", r); }); return retVal; } - public IResponse Initialize(NewtonMeter torque, PerSecond angularVelocity) + public IResponse Initialize(NewtonMeter outTorque, PerSecond outAngularVelocity) { return new ResponseSuccess() { Source = this }; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleClutch.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleClutch.cs index ddba7094e08208e0d3b7fed29808c1b30baeb4d5..1a674c3138b9ee0a4f26d9b45ff03baa5913d5ac 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleClutch.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleClutch.cs @@ -43,33 +43,33 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { public CycleClutch(IVehicleContainer container) : base(container) {} - public override IResponse Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity, + public override IResponse Request(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, bool dryRun = false) { var angularVelocityIn = DataBus.CycleData.LeftSample.AngularVelocity; - if (angularVelocity != null) { + if (outAngularVelocity != null) { // engaged - act like transmission torque converter (convert torque for angularVelocity to torque for angularVelocityIn) // convert requested power to equivalent torque with angularVelocityIn - var torqueIn = torque * angularVelocity / angularVelocityIn; + var torqueIn = outTorque * outAngularVelocity / angularVelocityIn; var retVal = NextComponent.Request(absTime, dt, torqueIn, angularVelocityIn, dryRun); - retVal.ClutchPowerRequest = torque * angularVelocity; + retVal.ClutchPowerRequest = outTorque * outAngularVelocity; return retVal; } else { // disengaged -> clutch open - var retVal = NextComponent.Request(absTime, dt, torque, angularVelocityIn, dryRun); + var retVal = NextComponent.Request(absTime, dt, outTorque, angularVelocityIn, dryRun); return retVal; } } - public override IResponse Initialize(NewtonMeter torque, PerSecond angularVelocity) + public override IResponse Initialize(NewtonMeter outTorque, PerSecond outAngularVelocity) { var angularVelocityIn = DataBus.CycleData.LeftSample.AngularVelocity; - var torqueIn = torque * angularVelocity / angularVelocityIn; + var torqueIn = outTorque * outAngularVelocity / angularVelocityIn; var retVal = NextComponent.Initialize(torqueIn, angularVelocityIn); - retVal.ClutchPowerRequest = torque * angularVelocity; + retVal.ClutchPowerRequest = outTorque * outAngularVelocity; return retVal; } } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs index 58651bc81dd0679bf92422b6d13a37be2144929a..d4c3268ce9be4196fc76e7a67be2450a41b5a643 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs @@ -29,12 +29,10 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ -using System.Diagnostics; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Configuration; -using TUGraz.VectoCore.Models.Connector.Ports; using TUGraz.VectoCore.Models.Connector.Ports.Impl; using TUGraz.VectoCore.Models.Simulation; using TUGraz.VectoCore.Models.Simulation.Data; @@ -45,18 +43,12 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { - public class CycleGearbox : StatefulProviderComponent<Gearbox.GearboxState, ITnOutPort, ITnInPort, ITnOutPort>, - IGearbox, ITnOutPort, ITnInPort, IClutchInfo + public class CycleGearbox : AbstractGearbox<GearboxState> { - internal readonly GearboxData ModelData; - private IAuxPort _auxiliary; + public CycleGearbox(IVehicleContainer container, GearboxData gearboxModelData) + : base(container, gearboxModelData) {} - public CycleGearbox(IVehicleContainer container, GearboxData gearboxModelData) : base(container) - { - ModelData = gearboxModelData; - } - - public IResponse Initialize(NewtonMeter outTorque, PerSecond outAngularVelocity) + public override IResponse Initialize(NewtonMeter outTorque, PerSecond outAngularVelocity) { var dt = Constants.SimulationSettings.TargetTimeInterval; @@ -78,9 +70,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl inTorque += torqueLossInertia; - if (_auxiliary != null) + if (Auxiliary != null) { //todo mk-2016-08-17: aux loss from out-direction or in-direction of the gearbox? - inTorque += _auxiliary.Initialize(outTorque, outAngularVelocity); + inTorque += Auxiliary.Initialize(outTorque, outAngularVelocity); + } } else { inTorque = 0.SI<NewtonMeter>(); inAngularVelocity = 0.RPMtoRad(); @@ -118,8 +111,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl inTorque += inertiaPowerLoss / inAngularVelocity; //todo mk-2016-08-17: aux loss from out-direction or in-direction of the gearbox? - if (_auxiliary != null) - inTorque += _auxiliary.Initialize(outTorque, outAngularVelocity); + if (Auxiliary != null) + inTorque += Auxiliary.Initialize(outTorque, outAngularVelocity); } var response = NextComponent.Initialize(inTorque, inAngularVelocity); @@ -129,8 +122,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Case<ResponseUnderload>(). Default(r => { throw new UnexpectedResponseException("Gearbox.Initialize", r); }); - var fullLoadGearbox = ModelData.Gears[gear].FullLoadCurve.FullLoadStationaryTorque(inAngularVelocity) * - inAngularVelocity; + var fullLoadGearbox = ModelData.Gears[gear].MaxTorque * inAngularVelocity; var fullLoadEngine = DataBus.EngineStationaryFullPower(inAngularVelocity); var fullLoad = VectoMath.Min(fullLoadGearbox, fullLoadEngine); @@ -154,7 +146,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// <item><description>ResponseGearshift</description></item> /// </list> /// </returns> - public IResponse Request(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, bool dryRun) + public override IResponse Request(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, + bool dryRun = false) { Log.Debug("Gearbox Power Request: torque: {0}, angularVelocity: {1}", outTorque, outAngularVelocity); Gear = DataBus.DriverBehavior == DrivingBehavior.Braking @@ -208,8 +201,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var inAngularVelocity = outAngularVelocity * ModelData.Gears[Gear].Ratio; //todo mk-2016-08-17: aux loss from out-direction or in-direction of the gearbox? - if (_auxiliary != null) - inTorque += _auxiliary.PowerDemand(absTime, dt, outTorque, inTorque, outAngularVelocity, dryRun); + if (Auxiliary != null) + inTorque += Auxiliary.PowerDemand(absTime, dt, outTorque, inTorque, outAngularVelocity, dryRun); if (dryRun) { var dryRunResponse = NextComponent.Request(absTime, dt, inTorque, inAngularVelocity, true); @@ -269,50 +262,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl base.DoCommitSimulationStep(); } - #region IGearboxCockpit - - /// <summary> - /// The current gear. - /// </summary> - public uint Gear { get; private set; } - - [DebuggerHidden] - public MeterPerSecond StartSpeed - { - get { return ModelData.StartSpeed; } - } - - [DebuggerHidden] - public MeterPerSquareSecond StartAcceleration - { - get { return ModelData.StartAcceleration; } - } - - public FullLoadCurve GearFullLoadCurve - { - get { return Gear == 0 ? null : ModelData.Gears[Gear].FullLoadCurve; } - } - - public Watt GearboxLoss() - { - return (PreviousState.TransmissionTorqueLoss + - PreviousState.InertiaTorqueLossOut / ModelData.Gears[PreviousState.Gear].Ratio) * PreviousState.InAngularVelocity; - } - - #endregion - #region ICluchInfo - public bool ClutchClosed(Second absTime) + public override bool ClutchClosed(Second absTime) { return DataBus.CycleData.LeftSample.Gear != 0; } #endregion - - public void Connect(IAuxPort aux) - { - _auxiliary = aux; - } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs index b7bdbece7b45bd81079751c5f259a7652f40def3..b9e04b3fa791e2cbd348769cf50b361756c23a54 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs @@ -195,10 +195,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl entry.Distance - brakingDistance, brakingDistance, entry.Distance, nextTargetSpeed); } else { //var coastingDistance = ComputeCoastingDistance(currentSpeed, nextTargetSpeed); - action = DrivingBehavior.Coasting; - Log.Debug( - "adding 'Coasting' starting at distance {0}. coastingDistance: {1}, triggerDistance: {2}, nextTargetSpeed: {3}", - entry.Distance - coastingDistance, coastingDistance, entry.Distance, nextTargetSpeed); + if (currentSpeed > 50.KMPHtoMeterPerSecond()) { + action = DrivingBehavior.Coasting; + + Log.Debug( + "adding 'Coasting' starting at distance {0}. coastingDistance: {1}, triggerDistance: {2}, nextTargetSpeed: {3}", + entry.Distance - coastingDistance, coastingDistance, entry.Distance, nextTargetSpeed); + } else { + coastingDistance = -1.SI<Meter>(); + } } nextActions.Add( new DrivingBehaviorEntry { @@ -570,7 +575,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl // coast would decelerate more than driver's max deceleration => issue brakes to decelerate with driver's max deceleration response = Driver.DrivingActionBrake(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient, r); - Phase = BrakingPhase.Brake; + if ((DriverStrategy.BrakeTrigger.BrakingStartDistance - currentDistance).IsSmallerOrEqual( + Constants.SimulationSettings.DriverActionDistanceTolerance)) { + Phase = BrakingPhase.Brake; + } }). Case<ResponseOverload>(r => { // limiting deceleration while coast may result in an overload => issue brakes to decelerate with driver's max deceleration diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs index fbb2929d6882802e7f9c043aefb5c953786a9a59..a27a5eb60453556dbf14444ff18d6e12f95a167f 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs @@ -30,6 +30,7 @@ */ using System; +using System.Windows.Forms.VisualStyles; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; @@ -59,6 +60,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl DriverData = driverData; DriverStrategy = strategy; strategy.Driver = this; + DriverAcceleration = 0.SI<MeterPerSquareSecond>(); } public IResponse Initialize(MeterPerSecond vehicleSpeed, Radian roadGradient) @@ -128,11 +130,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public IResponse DrivingActionAccelerate(Second absTime, Meter ds, MeterPerSecond targetVelocity, Radian gradient, IResponse previousResponse = null) { + CurrentAction = "ACCELERATE"; IterationStatistics.Increment(this, "Accelerate"); Log.Debug("DrivingAction Accelerate"); var operatingPoint = ComputeAcceleration(ds, targetVelocity); IResponse retVal = null; + DriverAcceleration = operatingPoint.Acceleration; var response = previousResponse ?? NextComponent.Request(absTime, operatingPoint.SimulationInterval, operatingPoint.Acceleration, gradient); @@ -164,6 +168,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Log.Debug("Found operating point for Drive/Accelerate. dt: {0}, acceleration: {1}", limitedOperatingPoint.SimulationInterval, limitedOperatingPoint.Acceleration); + DriverAcceleration = limitedOperatingPoint.Acceleration; retVal = NextComponent.Request(absTime, limitedOperatingPoint.SimulationInterval, limitedOperatingPoint.Acceleration, gradient); retVal.Switch(). @@ -172,11 +177,23 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Case<ResponseOverload>(() => { // deceleration is limited by driver model, operating point moves above full load (e.g., steep uphill) // the vehicle/driver can't achieve an acceleration higher than deceleration curve, try again with higher deceleration - Log.Info( - "Operating point with limited acceleration resulted in an overload! trying again with original acceleration {0}", - nextOperatingPoint.Acceleration); - retVal = NextComponent.Request(absTime, nextOperatingPoint.SimulationInterval, nextOperatingPoint.Acceleration, - gradient); + if (DataBus.GearboxType.AutomaticTransmission()) { + Log.Info("AT Gearbox - Operating point resulted in an overload, searching again..."); + // search again for operating point, transmission may have shifted inbetween + nextOperatingPoint = SearchOperatingPoint(absTime, ds, gradient, operatingPoint.Acceleration, response); + limitedOperatingPoint = LimitAccelerationByDriverModel(nextOperatingPoint, LimitationMode.LimitDecelerationDriver); + DriverAcceleration = limitedOperatingPoint.Acceleration; + retVal = NextComponent.Request(absTime, limitedOperatingPoint.SimulationInterval, + limitedOperatingPoint.Acceleration, + gradient); + } else { + Log.Info( + "Operating point with limited acceleration resulted in an overload! trying again with original acceleration {0}", + nextOperatingPoint.Acceleration); + DriverAcceleration = nextOperatingPoint.Acceleration; + retVal = NextComponent.Request(absTime, nextOperatingPoint.SimulationInterval, nextOperatingPoint.Acceleration, + gradient); + } retVal.Switch(). Case<ResponseSuccess>(() => operatingPoint = nextOperatingPoint). Case<ResponseGearShift>(() => operatingPoint = nextOperatingPoint). @@ -207,6 +224,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// <returns></returns> public IResponse DrivingActionCoast(Second absTime, Meter ds, MeterPerSecond maxVelocity, Radian gradient) { + CurrentAction = "COAST"; IterationStatistics.Increment(this, "Coast"); Log.Debug("DrivingAction Coast"); @@ -223,6 +241,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// <returns></returns> public IResponse DrivingActionRoll(Second absTime, Meter ds, MeterPerSecond maxVelocity, Radian gradient) { + CurrentAction = "ROLL"; IterationStatistics.Increment(this, "Roll"); Log.Debug("DrivingAction Roll"); @@ -254,6 +273,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl bool rollAction) { var requestedOperatingPoint = ComputeAcceleration(ds, DataBus.VehicleSpeed); + DriverAcceleration = requestedOperatingPoint.Acceleration; var initialResponse = NextComponent.Request(absTime, requestedOperatingPoint.SimulationInterval, requestedOperatingPoint.Acceleration, gradient, dryRun: true); @@ -294,6 +314,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return new ResponseSpeedLimitExceeded() { Source = this }; } + DriverAcceleration = limitedOperatingPoint.Acceleration; var response = NextComponent.Request(absTime, limitedOperatingPoint.SimulationInterval, limitedOperatingPoint.Acceleration, gradient); @@ -327,6 +348,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public IResponse DrivingActionBrake(Second absTime, Meter ds, MeterPerSecond nextTargetSpeed, Radian gradient, IResponse previousResponse = null, Meter targetDistance = null) { + CurrentAction = "BRAKE"; IterationStatistics.Increment(this, "Brake"); Log.Debug("DrivingAction Brake"); @@ -364,6 +386,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } } + DriverAcceleration = operatingPoint.Acceleration; var response = previousResponse ?? NextComponent.Request(absTime, operatingPoint.SimulationInterval, operatingPoint.Acceleration, gradient); @@ -412,6 +435,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return new ResponseOverload { Source = this }; } + DriverAcceleration = operatingPoint.Acceleration; retVal = NextComponent.Request(absTime, operatingPoint.SimulationInterval, operatingPoint.Acceleration, gradient); retVal.Switch(). @@ -422,6 +446,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Source = this, MaxDistance = DataBus.VehicleSpeed * r.DeltaT + operatingPoint.Acceleration / 2 * r.DeltaT * r.DeltaT }). + Case<ResponseUnderload>(r => { + if (DataBus.GearboxType.AutomaticTransmission()) { + operatingPoint = SearchBrakingPower(absTime, operatingPoint.SimulationDistance, gradient, + operatingPoint.Acceleration, response); + DriverAcceleration = operatingPoint.Acceleration; + retVal = NextComponent.Request(absTime, operatingPoint.SimulationInterval, operatingPoint.Acceleration, gradient); + } + }). Default( r => { throw new UnexpectedResponseException("DrivingAction Brake: request failed after braking power was found.", r); @@ -489,6 +521,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl initialResponse.Switch(). Case<ResponseGearShift>(r => { IterationStatistics.Increment(this, "SearchBrakingPower"); + DriverAcceleration = operatingPoint.Acceleration; var nextResp = NextComponent.Request(absTime, operatingPoint.SimulationInterval, operatingPoint.Acceleration, gradient, true); deltaPower = nextResp.GearboxPowerRequest; @@ -508,6 +541,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl operatingPoint = ComputeTimeInterval(operatingPoint.Acceleration, ds); IterationStatistics.Increment(this, "SearchBrakingPower"); + DriverAcceleration = operatingPoint.Acceleration; return NextComponent.Request(absTime, operatingPoint.SimulationInterval, operatingPoint.Acceleration, gradient, true); }, @@ -568,6 +602,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl retVal.SimulationDistance = tmp.SimulationDistance; } IterationStatistics.Increment(this, "SearchOperatingPoint"); + DriverAcceleration = acc; var response = NextComponent.Request(absTime, retVal.SimulationInterval, acc, gradient, true); response.OperatingPoint = retVal; return response; @@ -682,6 +717,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// <returns></returns> public IResponse DrivingActionHalt(Second absTime, Second dt, MeterPerSecond targetVelocity, Radian gradient) { + CurrentAction = "HALT"; if (!targetVelocity.IsEqual(0) || !DataBus.VehicleStopped) { Log.Error("TargetVelocity ({0}) and VehicleVelocity ({1}) must be zero when vehicle is halting!", targetVelocity, DataBus.VehicleSpeed); @@ -690,11 +726,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl DataBus.VehicleSpeed); } + DriverAcceleration = 0.SI<MeterPerSquareSecond>(); var retVal = NextComponent.Request(absTime, dt, 0.SI<MeterPerSquareSecond>(), gradient); retVal.Switch(). - Case<ResponseGearShift>( - r => { retVal = NextComponent.Request(absTime, dt, 0.SI<MeterPerSquareSecond>(), gradient); }); + Case<ResponseGearShift>(r => { + DriverAcceleration = 0.SI<MeterPerSquareSecond>(); + retVal = NextComponent.Request(absTime, dt, 0.SI<MeterPerSquareSecond>(), gradient); + }); CurrentState.dt = dt; CurrentState.Acceleration = 0.SI<MeterPerSquareSecond>(); return retVal; @@ -703,6 +742,25 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected override void DoWriteModalResults(IModalDataContainer container) { container[ModalResultField.acc] = CurrentState.Acceleration; + container.SetDataValue("DriverAction", ActionToNumber(CurrentAction)); + } + + private int ActionToNumber(string currentAction) + { + switch (currentAction.ToUpper()) { + case "HALT": + return 0; + case "ROLL": + return 2; + case "COAST": + return 4; + case "ACCELERATE": + return 6; + case "BRAKE": + return -5; + default: + return -10; + } } protected override void DoCommitSimulationStep() @@ -730,5 +788,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } public DrivingBehavior DriverBehavior { get; set; } + + public MeterPerSquareSecond DriverAcceleration { get; protected set; } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DummyRetarder.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DummyRetarder.cs index 11c80be8909b34081cf0231983c6dded921d8527..670ad8033f4cc2194cae9f4c5194c4cc5f5418ef 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DummyRetarder.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DummyRetarder.cs @@ -49,10 +49,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return NextComponent.Initialize(torque, angularVelocity); } - public IResponse Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity, bool dryRun = false) + public IResponse Request(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, bool dryRun = false) { - CurrentState.SetState(torque, angularVelocity, torque, angularVelocity); - return NextComponent.Request(absTime, dt, torque, angularVelocity, dryRun); + CurrentState.SetState(outTorque, outAngularVelocity, outTorque, outAngularVelocity); + return NextComponent.Request(absTime, dt, outTorque, outAngularVelocity, dryRun); } protected override void DoWriteModalResults(IModalDataContainer container) diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineAuxiliary.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineAuxiliary.cs index 365c1851078a02df466a3972609f4a9483553b13..a7e20c3a8b9bd36ce0ff622871288a99dc59adb3 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineAuxiliary.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineAuxiliary.cs @@ -88,6 +88,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl _auxiliaries[auxId] = powerLoss; } + public NewtonMeter Initialize(NewtonMeter torque, PerSecond angularSpeed) + { + PreviousState.AngularSpeed = angularSpeed; + return ComputePowerDemand(angularSpeed) / angularSpeed; + } + public NewtonMeter PowerDemand(Second absTime, Second dt, NewtonMeter torquePowerTrain, NewtonMeter torqueEngine, PerSecond angularSpeed, bool dryRun = false) { @@ -96,16 +102,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return ComputePowerDemand(avgAngularSpeed) / avgAngularSpeed; } - public NewtonMeter Initialize(NewtonMeter torque, PerSecond angularSpeed) - { - PreviousState.AngularSpeed = angularSpeed; - return ComputePowerDemand(angularSpeed) / angularSpeed; - } - private Watt ComputePowerDemand(PerSecond engineSpeed) { - CurrentState.PowerDemands = _auxiliaries.ToDictionary(kv => kv.Key, kv => kv.Value(engineSpeed)); - return CurrentState.PowerDemands.Values.Sum(p => p); + CurrentState.PowerDemands = new Dictionary<string, Watt>(_auxiliaries.Count); + CurrentState.TotalPowerDemand = 0.SI<Watt>(); + foreach (var item in _auxiliaries) { + var value = item.Value(engineSpeed); + CurrentState.PowerDemands[item.Key] = value; + CurrentState.TotalPowerDemand += value; + } + return CurrentState.TotalPowerDemand; } protected override void DoWriteModalResults(IModalDataContainer container) @@ -114,8 +120,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl container[kv.Key] = kv.Value; } if (container[ModalResultField.P_aux] == null || container[ModalResultField.P_aux] == DBNull.Value) { - // don't overwrite if someone else already wrote the total aux power - container[ModalResultField.P_aux] = CurrentState.PowerDemands.Values.Sum(p => p); + // only overwrite if nobody else already wrote the total aux power + container[ModalResultField.P_aux] = CurrentState.TotalPowerDemand; } } @@ -128,6 +134,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { public PerSecond AngularSpeed; public Dictionary<string, Watt> PowerDemands; + public Watt TotalPowerDemand; } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs index 99ba374d6c4131e94f12008ea0a8c0436a4985d4..f0b7a8418181c8f5e13e9791d24a2cfb49059434 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs @@ -29,32 +29,22 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ -using System.ComponentModel.DataAnnotations; -using System.Diagnostics; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Configuration; -using TUGraz.VectoCore.Models.Connector.Ports; using TUGraz.VectoCore.Models.Connector.Ports.Impl; using TUGraz.VectoCore.Models.Simulation; using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.Simulation.DataBus; using TUGraz.VectoCore.Models.SimulationComponent.Data; -using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; using TUGraz.VectoCore.OutputData; using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { - public class Gearbox : StatefulProviderComponent<Gearbox.GearboxState, ITnOutPort, ITnInPort, ITnOutPort>, IGearbox, - ITnOutPort, ITnInPort, IClutchInfo + public class Gearbox : AbstractGearbox<GearboxState> { - /// <summary> - /// The data and settings for the gearbox. - /// </summary> - [Required, ValidateObject] internal readonly GearboxData ModelData; - /// <summary> /// The shift strategy. /// </summary> @@ -70,20 +60,18 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// </summary> protected internal bool Disengaged = true; - private IAuxPort _auxiliary; - public Second LastUpshift { get; private set; } public Second LastDownshift { get; private set; } - public bool ClutchClosed(Second absTime) + public override bool ClutchClosed(Second absTime) { return _engageTime.IsSmallerOrEqual(absTime); } - public Gearbox(IVehicleContainer container, GearboxData gearboxModelData, IShiftStrategy strategy) : base(container) + public Gearbox(IVehicleContainer container, GearboxData gearboxModelData, IShiftStrategy strategy) + : base(container, gearboxModelData) { - ModelData = gearboxModelData; _strategy = strategy; _strategy.Gearbox = this; @@ -91,7 +79,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl LastUpshift = -double.MaxValue.SI<Second>(); } - public IResponse Initialize(NewtonMeter outTorque, PerSecond outAngularVelocity) + public override IResponse Initialize(NewtonMeter outTorque, PerSecond outAngularVelocity) { var absTime = 0.SI<Second>(); var dt = Constants.SimulationSettings.TargetTimeInterval; @@ -108,17 +96,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl CurrentState.TorqueLossResult = gearboxTorqueLoss; //todo mk-2016-08-17: aux loss from out-direction or in-direction of the gearbox? - var auxTorqueLoss = _auxiliary == null ? 0.SI<NewtonMeter>() : _auxiliary.Initialize(outTorque, outAngularVelocity); - - var inertiaTorqueLoss = outAngularVelocity.IsEqual(0) - ? 0.SI<NewtonMeter>() - : Formulas.InertiaPower(inAngularVelocity, PreviousState.InAngularVelocity, ModelData.Inertia, dt) / - inAngularVelocity; + var auxTorqueLoss = Auxiliary == null ? 0.SI<NewtonMeter>() : Auxiliary.Initialize(outTorque, outAngularVelocity); var inTorque = outTorque / ModelData.Gears[Gear].Ratio + gearboxTorqueLoss.Value - + auxTorqueLoss - + inertiaTorqueLoss; + + auxTorqueLoss; PreviousState.SetState(inTorque, inAngularVelocity, outTorque, outAngularVelocity); PreviousState.InertiaTorqueLossOut = 0.SI<NewtonMeter>(); @@ -147,8 +129,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl inTorque += inertiaPowerLoss / inAngularVelocity; //todo mk-2016-08-17: aux loss from out-direction or in-direction of the gearbox? - if (_auxiliary != null) - inTorque += _auxiliary.Initialize(outTorque, outAngularVelocity); + if (Auxiliary != null) + inTorque += Auxiliary.Initialize(outTorque, outAngularVelocity); } var response = NextComponent.Initialize(inTorque, inAngularVelocity); @@ -159,9 +141,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Default(r => { throw new UnexpectedResponseException("Gearbox.Initialize", r); }); var fullLoad = DataBus.EngineStationaryFullPower(inAngularVelocity); - if (ModelData.Gears[gear].FullLoadCurve != null) { - var fullLoadGearbox = ModelData.Gears[gear].FullLoadCurve.FullLoadStationaryTorque(inAngularVelocity) * - inAngularVelocity; + if (ModelData.Gears[gear].MaxTorque != null) { + var fullLoadGearbox = ModelData.Gears[gear].MaxTorque * inAngularVelocity; fullLoad = VectoMath.Min(fullLoadGearbox, fullLoad); } @@ -184,11 +165,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// <item><description>ResponseGearshift</description></item> /// </list> /// </returns> - public IResponse Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity, bool dryRun) + public override IResponse Request(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, + bool dryRun = false) { IterationStatistics.Increment(this, "Requests"); - Log.Debug("Gearbox Power Request: torque: {0}, angularVelocity: {1}", torque, angularVelocity); + Log.Debug("Gearbox Power Request: torque: {0}, angularVelocity: {1}", outTorque, outAngularVelocity); if (DataBus.VehicleStopped) { _engageTime = absTime; } @@ -196,22 +178,22 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl _engageTime = absTime + dt; } - var engineSpeedNorm = (angularVelocity - DataBus.EngineIdleSpeed) / + var engineSpeedNorm = (outAngularVelocity - DataBus.EngineIdleSpeed) / (DataBus.EngineRatedSpeed - DataBus.EngineIdleSpeed); if (DataBus.DriverBehavior == DrivingBehavior.Braking && DataBus.BrakePower.IsGreater(0.SI<Watt>()) && engineSpeedNorm < Constants.SimulationSettings.ClutchClosingSpeedNorm && DataBus.VehicleSpeed.IsSmaller(Constants.SimulationSettings.ClutchDisengageWhenHaltingSpeed)) { _engageTime = absTime + dt; Disengaged = true; - return RequestGearDisengaged(absTime, dt, torque, angularVelocity, dryRun); + return RequestGearDisengaged(absTime, dt, outTorque, outAngularVelocity, dryRun); } IResponse retVal; // TODO MQ 2016/03/10: investigate further the effects of having the condition angularvelocity != 0 if (ClutchClosed(absTime) /* && !angularVelocity.IsEqual(0) */) { - retVal = RequestGearEngaged(absTime, dt, torque, angularVelocity, dryRun); + retVal = RequestGearEngaged(absTime, dt, outTorque, outAngularVelocity, dryRun); } else { - retVal = RequestGearDisengaged(absTime, dt, torque, angularVelocity, dryRun); + retVal = RequestGearDisengaged(absTime, dt, outTorque, outAngularVelocity, dryRun); } return retVal; @@ -247,7 +229,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } var shiftTimeExceeded = absTime.IsSmaller(_engageTime) && - _engageTime.IsSmaller(absTime + dt, ModelData.TractionInterruption / 20.0); // allow 5% tolerance of shift time + _engageTime.IsSmaller(absTime + dt, Constants.SimulationSettings.LowerBoundTimeInterval); + // allow 5% tolerance of shift time if (shiftTimeExceeded) { return new ResponseFailTimeInterval { Source = this, @@ -319,9 +302,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var inTorqueLossResult = ModelData.Gears[Gear].LossMap.GetTorqueLoss(avgOutAngularVelocity, outTorque); var inTorque = outTorque / ModelData.Gears[Gear].Ratio + inTorqueLossResult.Value; - if (_auxiliary != null) + if (Auxiliary != null) { //todo mk-2016-08-17: aux loss from out-direction or in-direction of the gearbox? - inTorque += _auxiliary.PowerDemand(absTime, dt, outTorque, inTorque, outAngularVelocity, dryRun); + inTorque += Auxiliary.PowerDemand(absTime, dt, outTorque, inTorque, outAngularVelocity, dryRun); + } var inAngularVelocity = outAngularVelocity * ModelData.Gears[Gear].Ratio; @@ -425,54 +409,5 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } base.DoCommitSimulationStep(); } - - #region IGearboxCockpit - - /// <summary> - /// The current gear. - /// </summary> - public uint Gear { get; set; } - - [DebuggerHidden] - public MeterPerSecond StartSpeed - { - get { return ModelData.StartSpeed; } - } - - [DebuggerHidden] - public MeterPerSquareSecond StartAcceleration - { - get { return ModelData.StartAcceleration; } - } - - public FullLoadCurve GearFullLoadCurve - { - get { return Gear == 0 ? null : ModelData.Gears[Gear].FullLoadCurve; } - } - - public Watt GearboxLoss() - { - //var outTorque = ModelData.Gears[Gear].LossMap.GetOutTorque(inAngularVelocity, inTorque, true); - //var torqueLoss = inTorque - outTorque * ModelData.Gears[Gear].Ratio; - - //return torqueLoss * inAngularVelocity; - return (PreviousState.TransmissionTorqueLoss + - PreviousState.InertiaTorqueLossOut / ModelData.Gears[PreviousState.Gear].Ratio) * PreviousState.InAngularVelocity; - } - - #endregion - - public class GearboxState : SimpleComponentState - { - public NewtonMeter InertiaTorqueLossOut = 0.SI<NewtonMeter>(); - public NewtonMeter TransmissionTorqueLoss = 0.SI<NewtonMeter>(); - public uint Gear; - public TransmissionLossMap.LossMapResult TorqueLossResult; - } - - public void Connect(IAuxPort aux) - { - _auxiliary = aux; - } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs index 6dfaafcbbcaa9e5165d981e8063fdb89738a8272..1c22fff8ad2fd6e334009189992532f262f19059 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs @@ -313,6 +313,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl get { return DrivingBehavior.Driving; } } + public MeterPerSquareSecond DriverAcceleration + { + get { return 0.SI<MeterPerSquareSecond>(); } + } + #endregion } @@ -420,6 +425,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var deltaT = RightSample.Current.Time - LeftSample.Current.Time; var acceleration = deltaV / deltaT; var gradient = LeftSample.Current.RoadGradient; + DriverAcceleration = acceleration; DriverBehavior = acceleration < 0 ? DriverBehavior = DrivingBehavior.Braking : DriverBehavior = DrivingBehavior.Driving; @@ -558,6 +564,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public DrivingBehavior DriverBehavior { get; internal set; } + public MeterPerSquareSecond DriverAcceleration { get; protected set; } + public Meter Distance { get { return CurrentState.Distance; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs index 9a1aad7709fd9fb81741e118d189397305ef74e4..261a7d10273ebe206c6c92c730dcdffa6d48020b 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs @@ -48,6 +48,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected IDataBus DataBus; protected GearboxData Data; + protected Gearbox _gearbox; protected ShiftStrategy(GearboxData data, IDataBus dataBus) { @@ -55,7 +56,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Data = data; } - public abstract uint Engage(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outEngineSpeed); + public abstract uint Engage(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity); public abstract void Disengage(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outEngineSpeed); @@ -64,17 +65,28 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public abstract uint InitGear(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity); - public Gearbox Gearbox { get; set; } + public IGearbox Gearbox + { + get { return _gearbox; } + set + { + var myGearbox = value as Gearbox; + if (myGearbox == null) { + throw new VectoException("This shift strategy can't handle gearbox of type {0}", value.GetType()); + } + _gearbox = myGearbox; + } + } protected MeterPerSquareSecond EstimateAccelerationForGear(uint gear, PerSecond gbxAngularVelocityOut) { - if (gear == 0 || gear > Gearbox.ModelData.Gears.Count) { + if (gear == 0 || gear > _gearbox.ModelData.Gears.Count) { throw new VectoSimulationException("invalid gear: {0}", gear); } var vehicleSpeed = DataBus.VehicleSpeed; - var nextEngineSpeed = gbxAngularVelocityOut * Gearbox.ModelData.Gears[gear].Ratio; + var nextEngineSpeed = gbxAngularVelocityOut * _gearbox.ModelData.Gears[gear].Ratio; var maxEnginePower = DataBus.EngineStationaryFullPower(nextEngineSpeed); var avgSlope = @@ -83,8 +95,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var airDragLoss = DataBus.AirDragResistance(vehicleSpeed, vehicleSpeed) * DataBus.VehicleSpeed; var rollResistanceLoss = DataBus.RollingResistance(avgSlope) * DataBus.VehicleSpeed; - var gearboxLoss = Gearbox.ModelData.Gears[gear].LossMap.GetTorqueLoss(gbxAngularVelocityOut, - maxEnginePower / nextEngineSpeed * Gearbox.ModelData.Gears[gear].Ratio).Value * nextEngineSpeed; + var gearboxLoss = _gearbox.ModelData.Gears[gear].LossMap.GetTorqueLoss(gbxAngularVelocityOut, + maxEnginePower / nextEngineSpeed * _gearbox.ModelData.Gears[gear].Ratio).Value * nextEngineSpeed; //DataBus.GearboxLoss(); var slopeLoss = DataBus.SlopeResistance(avgSlope) * DataBus.VehicleSpeed; var axleLoss = DataBus.AxlegearLoss(); @@ -109,13 +121,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (gear <= 1) { return false; } - - var downSection = Data.Gears[gear].ShiftPolygon.Downshift.GetSection(entry => entry.AngularSpeed < inEngineSpeed); - if (downSection.Item2.AngularSpeed < inEngineSpeed) { - return false; - } - - return ShiftPolygon.IsLeftOf(inEngineSpeed, inTorque, downSection); + return Data.Gears[gear].ShiftPolygon.IsBelowDownshiftCurve(inTorque, inEngineSpeed); } /// <summary> @@ -130,14 +136,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (gear >= Data.Gears.Count) { return false; } - - var upSection = Data.Gears[gear].ShiftPolygon.Upshift.GetSection(entry => entry.AngularSpeed < inEngineSpeed); - - if (upSection.Item2.AngularSpeed < inEngineSpeed) { - return true; - } - - return ShiftPolygon.IsRightOf(inEngineSpeed, inTorque, upSection); + return Data.Gears[gear].ShiftPolygon.IsAboveUpshiftCurve(inTorque, inEngineSpeed); } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/TorqueConverter.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/TorqueConverter.cs index 278dc446517fdebfccac9d1154c4c6de675ecbd7..049b07ec2d7e7ad9b073b72bea71c8641b2d1078 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/TorqueConverter.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/TorqueConverter.cs @@ -1,26 +1,171 @@ -using TUGraz.VectoCommon.Models; +using System; +using TUGraz.VectoCommon.Exceptions; +using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.Models.Connector.Ports; +using TUGraz.VectoCore.Models.Connector.Ports.Impl; +using TUGraz.VectoCore.Models.Simulation; +using TUGraz.VectoCore.Models.Simulation.Data; +using TUGraz.VectoCore.Models.Simulation.DataBus; +using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; +using TUGraz.VectoCore.OutputData; namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { - public class TorqueConverter : ITnInPort, ITnOutPort + public class TorqueConverter : StatefulVectoSimulationComponent<TorqueConverter.TorqueConverterComponentState>, + ITnInPort, ITnOutPort { - protected internal ITnOutPort NextComponent; + protected ATGearbox Gearbox; + + protected IShiftStrategy ShiftStrategy; + + protected TorqueConverterData ModelData; + + //protected bool SearchingTcOperatingPoint; + + public ITnOutPort NextComponent { protected internal get; set; } + + public TorqueConverter(ATGearbox gearbox, IShiftStrategy shiftStrategy, IVehicleContainer container, + TorqueConverterData tcData) : base(container) + { + Gearbox = gearbox; + ShiftStrategy = shiftStrategy; + ModelData = tcData; + } public void Connect(ITnOutPort other) { NextComponent = other; } - public IResponse Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity, bool dryRun = false) + public IResponse Initialize(NewtonMeter outTorque, PerSecond outAngularVelocity) + { + var operatingPoint = ModelData.FindOperatingPoint(outTorque, outAngularVelocity); + + var retVal = NextComponent.Initialize(operatingPoint.InTorque, operatingPoint.InAngularVelocity); + PreviousState.SetState(operatingPoint.InTorque, operatingPoint.InAngularVelocity, operatingPoint.OutTorque, + operatingPoint.OutAngularVelocity); + return retVal; + } + + public IResponse Request(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, + bool dryRun = false) + { + if (dryRun) { + var dryOperatingPoint = FindOperatingPoint(outTorque, outAngularVelocity); + var deltaTorqueConverter = (outTorque - dryOperatingPoint.OutTorque) * + (PreviousState.OutAngularVelocity + dryOperatingPoint.OutAngularVelocity) / 2.0; + // operatingPoint.inAngularVelocity is for sure between engine idle speed and max TC speed + var engineResponse = + (ResponseDryRun)NextComponent.Request(absTime, dt, dryOperatingPoint.InTorque, dryOperatingPoint.InAngularVelocity, + true); + var deltaEngine = (engineResponse.DeltaFullLoad > 0 ? engineResponse.DeltaFullLoad : 0.SI<Watt>()) + + (engineResponse.DeltaDragLoad < 0 ? -engineResponse.DeltaDragLoad : 0.SI<Watt>()); + if (deltaTorqueConverter.IsEqual(0) && deltaEngine.IsEqual(0)) { + return new ResponseDryRun { + Source = this, + DeltaFullLoad = 0.SI<Watt>(), + DeltaDragLoad = 0.SI<Watt>(), + TorqueConverterOperatingPoint = dryOperatingPoint + }; + } + if (engineResponse.DeltaFullLoad > 0 || engineResponse.DeltaDragLoad < 0) { + // engine is overloaded with current operating point, reduce torque... + dryOperatingPoint = + ModelData.GetOutTorqueAndSpeed( + outTorque > 0 ? engineResponse.EngineMaxTorqueOut : engineResponse.EngineDragTorque, + dryOperatingPoint.InAngularVelocity, null); + } + + + var delta = (outTorque - dryOperatingPoint.OutTorque) * + (PreviousState.OutAngularVelocity + dryOperatingPoint.OutAngularVelocity) / 2.0; + //deltaTorqueConverter.Value() * (deltaEngine.IsEqual(0) ? 1 : deltaEngine.Value()); + return new ResponseDryRun() { + Source = this, + DeltaFullLoad = delta, + DeltaDragLoad = delta, + TorqueConverterOperatingPoint = dryOperatingPoint + }; + } + var operatingPoint = FindOperatingPoint(outTorque, outAngularVelocity); + if (!outAngularVelocity.IsEqual(operatingPoint.OutAngularVelocity) || !outTorque.IsEqual(operatingPoint.OutTorque)) { + // a different operating point was found... + var delta = (outTorque - operatingPoint.OutTorque) * + (PreviousState.OutAngularVelocity + operatingPoint.OutAngularVelocity) / 2.0; + if (!delta.IsEqual(0, Constants.SimulationSettings.LineSearchTolerance)) { + if (delta > 0) { + return new ResponseOverload { Source = this, Delta = delta, TorqueConverterOperatingPoint = operatingPoint }; + } + return new ResponseUnderload { Source = this, Delta = delta, TorqueConverterOperatingPoint = operatingPoint }; + } + } + var ratio = Gearbox.ModelData.Gears[Gearbox.Gear].TorqueConverterRatio; + if (ShiftStrategy.ShiftRequired(absTime, dt, outTorque * ratio, outAngularVelocity / ratio, operatingPoint.InTorque, + operatingPoint.InAngularVelocity, Gearbox.Gear, Gearbox.LastShift)) { + return new ResponseGearShift() { Source = this }; + } + CurrentState.SetState(operatingPoint.InTorque, operatingPoint.InAngularVelocity, outTorque, outAngularVelocity); + CurrentState.OperatingPoint = operatingPoint; + var retVal = NextComponent.Request(absTime, dt, operatingPoint.InTorque, operatingPoint.InAngularVelocity, dryRun); + return retVal; + } + + protected TorqueConverterOperatingPoint FindOperatingPoint(NewtonMeter outTorque, PerSecond outAngularVelocity) + { + try { + var operatingPoint = ModelData.FindOperatingPoint(outTorque, outAngularVelocity); + if (operatingPoint.InAngularVelocity.IsSmaller(DataBus.EngineIdleSpeed)) { + throw new VectoException("Invalid operating point, inAngularVelocity below engine's idle speed: {0}", + operatingPoint.InAngularVelocity); + } + if (operatingPoint.InAngularVelocity.IsGreater(ModelData.TorqueConverterSpeedLimit)) { + operatingPoint = ModelData.GetOutTorque(ModelData.TorqueConverterSpeedLimit, outAngularVelocity); + } + return operatingPoint; + } catch (VectoException ve) { + Log.Debug(ve, "failed to find torque converter operating point, fallback: creeping"); + var tqOperatingPoint = ModelData.GetOutTorque(DataBus.EngineIdleSpeed, outAngularVelocity); + return tqOperatingPoint; + } + } + + protected override void DoWriteModalResults(IModalDataContainer container) + { + if (CurrentState.OperatingPoint == null) { + container[ModalResultField.TorqueConverterTorqueRatio] = 1.0; + container[ModalResultField.TorqueConverterSpeedRatio] = 1.0; + } else { + container[ModalResultField.TorqueConverterTorqueRatio] = CurrentState.OperatingPoint.TorqueRatio; + container[ModalResultField.TorqueConverterSpeedRatio] = CurrentState.OperatingPoint.SpeedRatio; + } + container[ModalResultField.TC_TorqueIn] = CurrentState.InTorque; + container[ModalResultField.TC_TorqueOut] = CurrentState.OutTorque; + container[ModalResultField.TC_angularSpeedIn] = CurrentState.InAngularVelocity; + container[ModalResultField.TC_angularSpeedOut] = CurrentState.OutAngularVelocity; + + var avgOutVelocity = (PreviousState.OutAngularVelocity + CurrentState.OutAngularVelocity) / 2.0; + var avgInVelocity = (PreviousState.InAngularVelocity + CurrentState.InAngularVelocity) / 2.0; + container[ModalResultField.P_TC_out] = CurrentState.OutTorque * avgOutVelocity; + container[ModalResultField.P_TC_loss] = CurrentState.InTorque * avgInVelocity - + CurrentState.OutTorque * avgOutVelocity; + } + + protected override void DoCommitSimulationStep() + { + //SearchingTcOperatingPoint = false; + AdvanceState(); + } + + public void Locked(NewtonMeter outTorque, PerSecond outAngularVelocity) { - throw new System.NotImplementedException(); + CurrentState.SetState(outTorque, outAngularVelocity, outTorque, outAngularVelocity); } - public IResponse Initialize(NewtonMeter torque, PerSecond angularVelocity) + public class TorqueConverterComponentState : SimpleComponentState { - throw new System.NotImplementedException(); + public TorqueConverterOperatingPoint OperatingPoint; } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/TransmissionComponent.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/TransmissionComponent.cs index 1927cb602f2de825ab2e9ab5d027ee359a928942..4053d8c0ee5958fc90606c7c7cfc843dfb6d87a1 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/TransmissionComponent.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/TransmissionComponent.cs @@ -71,31 +71,31 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl NextComponent = other; } - public virtual IResponse Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity, + public virtual IResponse Request(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, bool dryRun = false) { - Log.Debug("request: torque: {0}, angularVelocity: {1}", torque, angularVelocity); + Log.Debug("request: torque: {0}, angularVelocity: {1}", outTorque, outAngularVelocity); - var inAngularVelocity = angularVelocity * ModelData.Ratio; - var avgOutAngularVelocity = (PreviousState.OutAngularVelocity + angularVelocity) / 2.0; + var inAngularVelocity = outAngularVelocity * ModelData.Ratio; + var avgOutAngularVelocity = (PreviousState.OutAngularVelocity + outAngularVelocity) / 2.0; - var torqueLossResult = ModelData.LossMap.GetTorqueLoss(avgOutAngularVelocity, torque); - var inTorque = torque / ModelData.Ratio + torqueLossResult.Value; + var torqueLossResult = ModelData.LossMap.GetTorqueLoss(avgOutAngularVelocity, outTorque); + var inTorque = outTorque / ModelData.Ratio + torqueLossResult.Value; - CurrentState.SetState(inTorque, inAngularVelocity, torque, angularVelocity); + CurrentState.SetState(inTorque, inAngularVelocity, outTorque, outAngularVelocity); CurrentState.TorqueLossResult = torqueLossResult; var retVal = NextComponent.Request(absTime, dt, inTorque, inAngularVelocity, dryRun); return retVal; } - public virtual IResponse Initialize(NewtonMeter torque, PerSecond angularVelocity) + public virtual IResponse Initialize(NewtonMeter outTorque, PerSecond outAngularVelocity) { - var inAngularVelocity = angularVelocity * ModelData.Ratio; - var torqueLossResult = ModelData.LossMap.GetTorqueLoss(angularVelocity, torque); - var inTorque = torque / ModelData.Ratio + torqueLossResult.Value; + var inAngularVelocity = outAngularVelocity * ModelData.Ratio; + var torqueLossResult = ModelData.LossMap.GetTorqueLoss(outAngularVelocity, outTorque); + var inTorque = outTorque / ModelData.Ratio + torqueLossResult.Value; - PreviousState.SetState(inTorque, inAngularVelocity, torque, angularVelocity); + PreviousState.SetState(inTorque, inAngularVelocity, outTorque, outAngularVelocity); PreviousState.TorqueLossResult = torqueLossResult; return NextComponent.Initialize(inTorque, inAngularVelocity); diff --git a/VectoCore/VectoCore/OutputData/ModalDataContainer.cs b/VectoCore/VectoCore/OutputData/ModalDataContainer.cs index 4898d109c0b7582539877ac683a50d267902fd3e..b7fc496636c002614ae8481fab4c151ad2b26b2b 100644 --- a/VectoCore/VectoCore/OutputData/ModalDataContainer.cs +++ b/VectoCore/VectoCore/OutputData/ModalDataContainer.cs @@ -117,6 +117,9 @@ namespace TUGraz.VectoCore.OutputData dataColumns.AddRange(new[] { ModalResultField.Gear, }); + if (HasTorqueConverter) { + dataColumns.AddRange(new[] { ModalResultField.TC_Locked }); + } } dataColumns.AddRange(new[] { ModalResultField.n_eng_avg, @@ -128,8 +131,19 @@ namespace TUGraz.VectoCore.OutputData ModalResultField.P_eng_drag, ModalResultField.P_eng_inertia, ModalResultField.P_eng_out, - ModalResultField.P_clutch_loss, - ModalResultField.P_clutch_out, + }); + if (HasTorqueConverter) { + dataColumns.AddRange(new[] { + ModalResultField.P_TC_loss, + ModalResultField.P_TC_out, + }); + } else { + dataColumns.AddRange(new[] { + ModalResultField.P_clutch_loss, + ModalResultField.P_clutch_out, + }); + } + dataColumns.AddRange(new[] { ModalResultField.P_aux }); @@ -157,11 +171,12 @@ namespace TUGraz.VectoCore.OutputData if (HasTorqueConverter) { dataColumns.AddRange(new[] { - ModalResultField.TCv, - ModalResultField.P_tc_loss, - ModalResultField.TCmu, - ModalResultField.TC_M_Out, - ModalResultField.TC_n_Out + ModalResultField.TorqueConverterSpeedRatio, + ModalResultField.TorqueConverterTorqueRatio, + ModalResultField.TC_TorqueOut, + ModalResultField.TC_angularSpeedOut, + ModalResultField.TC_TorqueIn, + ModalResultField.TC_angularSpeedIn, }); } } @@ -189,6 +204,7 @@ namespace TUGraz.VectoCore.OutputData }); } + var strCols = dataColumns.Select(x => x.GetName()) .Concat(Auxiliaries.Values.Select(c => c.ColumnName)) .Concat( @@ -196,7 +212,9 @@ namespace TUGraz.VectoCore.OutputData ModalResultField.FCMap, ModalResultField.FCAUXc, ModalResultField.FCWHTCc, ModalResultField.FCAAUX, ModalResultField.FCFinal }.Select(x => x.GetName())); - +#if TRACE + strCols = strCols.Concat(_additionalColumns); +#endif if (WriteModalResults) { var filteredData = Data; foreach (var filter in _filters) { diff --git a/VectoCore/VectoCore/Resources/Declaration/DefaultTC.vtcc b/VectoCore/VectoCore/Resources/Declaration/DefaultTC.vtcc deleted file mode 100644 index 3676a37ec28628517e45e6567f4d9bc516766ca2..0000000000000000000000000000000000000000 --- a/VectoCore/VectoCore/Resources/Declaration/DefaultTC.vtcc +++ /dev/null @@ -1,12 +0,0 @@ -nue,mue,MP1000 (1000/rpm)^2*Nm -1.000,1.000,0.00 -1.005,1.000,0.00 -1.100,1.000,-40.34 -1.222,1.000,-80.34 -1.375,1.000,-136.11 -1.571,1.000,-216.52 -1.833,1.000,-335.19 -2.200,1.000,-528.77 -2.750,1.000,-883.40 -4.400,1.000,-2462.17 -11.000,1.000,-16540.98 diff --git a/VectoCore/VectoCore/Utils/AuxiliaryTypeHelper.cs b/VectoCore/VectoCore/Utils/AuxiliaryTypeHelper.cs new file mode 100644 index 0000000000000000000000000000000000000000..ff1104b9e2ded3589cc23ff66d37bd352fe66fe6 --- /dev/null +++ b/VectoCore/VectoCore/Utils/AuxiliaryTypeHelper.cs @@ -0,0 +1,47 @@ +using System; +using System.Text.RegularExpressions; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCore.Configuration; + +namespace TUGraz.VectoCore.Utils +{ + public static class AuxiliaryTypeHelper + { + public static AuxiliaryType Parse(string s) + { + + switch (Regex.Replace(s, @"\s+", "")){ + case Constants.Auxiliaries.Names.Fan: + return AuxiliaryType.Fan; + case Constants.Auxiliaries.Names.SteeringPump: + return AuxiliaryType.SteeringPump; + case Constants.Auxiliaries.Names.HeatingVentilationAirCondition: + return AuxiliaryType.HVAC; + case Constants.Auxiliaries.Names.ElectricSystem: + return AuxiliaryType.ElectricSystem; + case Constants.Auxiliaries.Names.PneumaticSystem: + return AuxiliaryType.PneumaticSystem; + default: + throw new ArgumentOutOfRangeException("s", s, "Could not parse auxiliary type string."); + } + } + + public static string ToString(AuxiliaryType t) + { + switch (t) { + case AuxiliaryType.Fan: + return Constants.Auxiliaries.Names.Fan; + case AuxiliaryType.SteeringPump: + return Constants.Auxiliaries.Names.SteeringPump; + case AuxiliaryType.HVAC: + return Constants.Auxiliaries.Names.HeatingVentilationAirCondition; + case AuxiliaryType.PneumaticSystem: + return Constants.Auxiliaries.Names.PneumaticSystem; + case AuxiliaryType.ElectricSystem: + return Constants.Auxiliaries.Names.ElectricSystem; + default: + throw new ArgumentOutOfRangeException(); + } + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/Utils/ProviderExtensions.cs b/VectoCore/VectoCore/Utils/ProviderExtensions.cs index 08e5343d565a945f36b0915dcb57cffde8d226e9..b640bb8d7041bc4a066d6c40505b54d309a45b86 100644 --- a/VectoCore/VectoCore/Utils/ProviderExtensions.cs +++ b/VectoCore/VectoCore/Utils/ProviderExtensions.cs @@ -98,7 +98,11 @@ namespace TUGraz.VectoCore.Utils var clutch = prev as IClutch; if (clutch != null) { - next.IdleController.RequestPort = clutch.IdleControlPort; + clutch.IdleController = next.IdleController; + } + var atGbx = prev as ATGearbox; + if (atGbx != null) { + atGbx.IdleController = next.IdleController; } return next; } diff --git a/VectoCore/VectoCore/VectoCore.csproj b/VectoCore/VectoCore/VectoCore.csproj index e667db5498ed01caf08a589dcc377db2912517e9..ea67bf8d1e1b0de354bb3b58e3802aa1369e7b16 100644 --- a/VectoCore/VectoCore/VectoCore.csproj +++ b/VectoCore/VectoCore/VectoCore.csproj @@ -146,6 +146,10 @@ <Compile Include="Models\SimulationComponent\ILossMap.cs" /> <Compile Include="Models\SimulationComponent\Data\PTOLossMap.cs" /> <Compile Include="Models\SimulationComponent\Impl\GearboxAuxiliary.cs" /> + <Compile Include="Models\SimulationComponent\Impl\AbstractGearbox.cs" /> + <Compile Include="Models\SimulationComponent\Impl\ATGearbox.cs" /> + <Compile Include="Models\SimulationComponent\Impl\ATShiftStrategy.cs" /> + <Compile Include="Models\SimulationComponent\Impl\TorqueConverter.cs" /> <Compile Include="Utils\ProviderExtensions.cs" /> <Compile Include="Models\Declaration\AirDrag.cs" /> <Compile Include="Models\Declaration\Fan.cs" /> @@ -317,7 +321,6 @@ <EmbeddedResource Include="Resources\Declaration\VAUX\PS-Table.csv" /> <EmbeddedResource Include="Resources\Declaration\VAUX\SP-Table.csv" /> <EmbeddedResource Include="Resources\Declaration\VAUX\SP-Tech.csv" /> - <EmbeddedResource Include="Resources\Declaration\DefaultTC.vtcc" /> <EmbeddedResource Include="Resources\Declaration\VCDV\parameters.csv" /> <EmbeddedResource Include="Resources\Declaration\WHTC-Weighting-Factors.csv" /> <EmbeddedResource Include="Resources\Declaration\VAUX\ALT-Tech.csv" /> diff --git a/VectoCore/VectoCoreTest/FileIO/JsonTest.cs b/VectoCore/VectoCoreTest/FileIO/JsonTest.cs index 69d2075f311267cf909028ce0166f4fca8fe9a74..766788df7b2e698160a01ff8f13f8f477a96dd25 100644 --- a/VectoCore/VectoCoreTest/FileIO/JsonTest.cs +++ b/VectoCore/VectoCoreTest/FileIO/JsonTest.cs @@ -38,6 +38,7 @@ using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.InputData.FileIO.JSON; +using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter; using TUGraz.VectoCore.Tests.Utils; namespace TUGraz.VectoCore.Tests.FileIO @@ -94,9 +95,7 @@ namespace TUGraz.VectoCore.Tests.FileIO ((JObject)json["Body"]).Property("Cycles").Remove(); AssertHelper.Exception<InvalidFileFormatException>( - () => { - var tmp = new JSONInputDataV2(json, TestJobFile).Cycles; - }, "Key Cycles not found"); + () => { var tmp = new JSONInputDataV2(json, TestJobFile).Cycles; }, "Key Cycles not found"); } [TestMethod] @@ -153,12 +152,112 @@ namespace TUGraz.VectoCore.Tests.FileIO ((JObject)json["Body"]).Property("OverSpeedEcoRoll").Remove(); AssertHelper.Exception<VectoException>( - () => { - var tmp = new JSONInputDataV2(json, TestJobFile).DriverInputData.OverSpeedEcoRoll; - }, + () => { var tmp = new JSONInputDataV2(json, TestJobFile).DriverInputData.OverSpeedEcoRoll; }, "Key OverSpeedEcoRoll not found"); } + [TestMethod] + public void ReadGearboxV5() + { + var inputProvider = JSONInputDataFactory.ReadGearbox(@"TestData\Components\AT_GBX\Gearbox_v5.vgbx"); + + var ratios = new[] { 3.0, 1.0, 0.8 }; + Assert.AreEqual(ratios.Length, inputProvider.Gears.Count); + for (int i = 0; i < ratios.Length; i++) { + Assert.AreEqual(ratios[i], inputProvider.Gears[i].Ratio); + } + var gbxData = new EngineeringDataAdapter().CreateGearboxData(inputProvider, + MockSimulationDataFactory.CreateEngineDataFromFile(@"TestData\Components\AT_GBX\Engine.veng"), 2.1, 0.5.SI<Meter>(), + true); + Assert.AreEqual(ratios.Length, gbxData.Gears.Count); + + // interpreted as gearbox with first and second gear using TC (due to gear ratios) + Assert.IsFalse(gbxData.Gears[1].HasLockedGear); + Assert.IsTrue(gbxData.Gears[1].HasTorqueConverter); + Assert.IsTrue(gbxData.Gears[2].HasLockedGear); + Assert.IsTrue(gbxData.Gears[2].HasTorqueConverter); + Assert.IsTrue(gbxData.Gears[3].HasLockedGear); + Assert.IsFalse(gbxData.Gears[3].HasTorqueConverter); + } + + [TestMethod] + public void ReadGearboxSerialTC() + { + var inputProvider = JSONInputDataFactory.ReadGearbox(@"TestData\Components\AT_GBX\GearboxSerial.vgbx"); + + var ratios = new[] { 3.4, 1.9, 1.42, 1.0, 0.7, 0.62 }; + Assert.AreEqual(ratios.Length, inputProvider.Gears.Count); + for (int i = 0; i < ratios.Length; i++) { + Assert.AreEqual(ratios[i], inputProvider.Gears[i].Ratio); + } + var gbxData = new EngineeringDataAdapter().CreateGearboxData(inputProvider, + MockSimulationDataFactory.CreateEngineDataFromFile(@"TestData\Components\AT_GBX\Engine.veng"), 2.1, 0.5.SI<Meter>(), + true); + Assert.AreEqual(ratios.Length, gbxData.Gears.Count); + + Assert.IsTrue(gbxData.Gears[1].HasLockedGear); + Assert.IsTrue(gbxData.Gears[1].HasTorqueConverter); + Assert.IsTrue(gbxData.Gears[2].HasLockedGear); + Assert.IsFalse(gbxData.Gears[2].HasTorqueConverter); + Assert.IsTrue(gbxData.Gears[3].HasLockedGear); + Assert.IsFalse(gbxData.Gears[3].HasTorqueConverter); + + var gear = gbxData.Gears[1]; + Assert.AreEqual(gear.Ratio, gear.TorqueConverterRatio); + } + + [TestMethod] + public void ReadGearboxPowersplitTC() + { + var inputProvider = JSONInputDataFactory.ReadGearbox(@"TestData\Components\AT_GBX\GearboxPowerSplit.vgbx"); + + var ratios = new[] { 1.35, 1.0, 0.73 }; + Assert.AreEqual(ratios.Length, inputProvider.Gears.Count); + for (int i = 0; i < ratios.Length; i++) { + Assert.AreEqual(ratios[i], inputProvider.Gears[i].Ratio); + } + var gbxData = new EngineeringDataAdapter().CreateGearboxData(inputProvider, + MockSimulationDataFactory.CreateEngineDataFromFile(@"TestData\Components\AT_GBX\Engine.veng"), 2.1, 0.5.SI<Meter>(), + true); + Assert.AreEqual(ratios.Length, gbxData.Gears.Count); + + Assert.IsTrue(gbxData.Gears[1].HasLockedGear); + Assert.IsTrue(gbxData.Gears[1].HasTorqueConverter); + Assert.IsTrue(gbxData.Gears[2].HasLockedGear); + Assert.IsFalse(gbxData.Gears[2].HasTorqueConverter); + Assert.IsTrue(gbxData.Gears[3].HasLockedGear); + Assert.IsFalse(gbxData.Gears[3].HasTorqueConverter); + + Assert.AreEqual(1, gbxData.Gears[1].TorqueConverterRatio); + } + + [TestMethod] + public void ReadGearboxDualTC() + { + var inputProvider = JSONInputDataFactory.ReadGearbox(@"TestData\Components\AT_GBX\GearboxSerialDualTC.vgbx"); + + var ratios = new[] { 4.35, 2.4, 1.8, 1.3, 1.0 }; + Assert.AreEqual(ratios.Length, inputProvider.Gears.Count); + for (int i = 0; i < ratios.Length; i++) { + Assert.AreEqual(ratios[i], inputProvider.Gears[i].Ratio); + } + var gbxData = new EngineeringDataAdapter().CreateGearboxData(inputProvider, + MockSimulationDataFactory.CreateEngineDataFromFile(@"TestData\Components\AT_GBX\Engine.veng"), 2.1, 0.5.SI<Meter>(), + true); + Assert.AreEqual(ratios.Length, gbxData.Gears.Count); + + Assert.IsFalse(gbxData.Gears[1].HasLockedGear); + Assert.IsTrue(gbxData.Gears[1].HasTorqueConverter); + Assert.IsTrue(gbxData.Gears[2].HasLockedGear); + Assert.IsTrue(gbxData.Gears[2].HasTorqueConverter); + Assert.IsTrue(gbxData.Gears[3].HasLockedGear); + Assert.IsFalse(gbxData.Gears[3].HasTorqueConverter); + + + var gear = gbxData.Gears[2]; + Assert.AreEqual(gear.Ratio, gear.TorqueConverterRatio); + } + //[TestMethod] //public void TestReadingElectricTechlist() //{ diff --git a/VectoCore/VectoCoreTest/FileIO/SimulationDataReaderTest.cs b/VectoCore/VectoCoreTest/FileIO/SimulationDataReaderTest.cs index d950221af21865df59987d5148d7bbac165d989a..df0a95bb978e5b1c93a2ba01e034ff628505311d 100644 --- a/VectoCore/VectoCoreTest/FileIO/SimulationDataReaderTest.cs +++ b/VectoCore/VectoCoreTest/FileIO/SimulationDataReaderTest.cs @@ -36,6 +36,7 @@ using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.InputData.FileIO.JSON; using TUGraz.VectoCore.InputData.Reader.Impl; using TUGraz.VectoCore.Models.Declaration; @@ -100,8 +101,8 @@ namespace TUGraz.VectoCore.Tests.FileIO Assert.AreEqual(3.7890, runData.EngineData.Inertia.Value()); - var downshiftSpeeds = new[] { 660, 660, 1750.70139 }; - var downshiftTorque = new[] { -163.9, 208.116856, 988.9 }; + var downshiftSpeeds = new[] { 660, 660, 1750.5456 }; + var downshiftTorque = new[] { -163.9, 207.4205, 988.9 }; Assert.AreEqual(downshiftSpeeds.Length, runData.GearboxData.Gears[2].ShiftPolygon.Downshift.Count); for (var i = 0; i < downshiftSpeeds.Length; i++) { @@ -110,8 +111,8 @@ namespace TUGraz.VectoCore.Tests.FileIO Assert.AreEqual(downshiftTorque[i], runData.GearboxData.Gears[2].ShiftPolygon.Downshift[i].Torque.Value(), Tolerance); } - var upshiftSpeed = new[] { 1891.2419, 1891.2419, 5798.4116 }; - var upshiftTorque = new[] { -163.9, 245.3663, 988.9 }; + var upshiftSpeed = new[] { 1889.6633, 1889.6633, 606.64575 / Constants.RPMToRad }; + var upshiftTorque = new[] { -163.9, 245.31958, 988.9 }; Assert.AreEqual(upshiftSpeed.Length, runData.GearboxData.Gears[2].ShiftPolygon.Downshift.Count); for (var i = 0; i < downshiftSpeeds.Length; i++) { diff --git a/VectoCore/VectoCoreTest/Integration/ATPowerTrain.cs b/VectoCore/VectoCoreTest/Integration/ATPowerTrain.cs new file mode 100644 index 0000000000000000000000000000000000000000..2c2db8674cffacceb1e9eb161ce2222faaa628cf --- /dev/null +++ b/VectoCore/VectoCoreTest/Integration/ATPowerTrain.cs @@ -0,0 +1,198 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Configuration; +using TUGraz.VectoCore.InputData.Reader; +using TUGraz.VectoCore.InputData.Reader.ComponentData; +using TUGraz.VectoCore.Models.Declaration; +using TUGraz.VectoCore.Models.Simulation.Data; +using TUGraz.VectoCore.Models.Simulation.Impl; +using TUGraz.VectoCore.Models.SimulationComponent.Data; +using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; +using TUGraz.VectoCore.Models.SimulationComponent.Impl; +using TUGraz.VectoCore.OutputData; +using TUGraz.VectoCore.OutputData.FileIO; +using TUGraz.VectoCore.Tests.Utils; +using TUGraz.VectoCore.Utils; +using Wheels = TUGraz.VectoCore.Models.SimulationComponent.Impl.Wheels; + +namespace TUGraz.VectoCore.Tests.Integration +{ + public class ATPowerTrain + { + public const string AccelerationFile = @"TestData\Components\Truck.vacc"; + public const string EngineFile = @"TestData\Components\AT_GBX\Engine.veng"; + //public const string AxleGearLossMap = @"TestData\Components\AT_GBX\Axle.vtlm"; + //public const string GearboxIndirectLoss = @"TestData\Components\AT_GBX\Indirect Gear.vtlm"; + //public const string GearboxDirectLoss = @"TestData\Components\AT_GBX\Direct Gear.vtlm"; + public const string TorqueConverterGenericFile = @"TestData\Components\AT_GBX\TorqueConverter.vtcc"; + public const string TorqueConverterPowerSplitFile = @"TestData\Components\AT_GBX\TorqueConverterPowerSplit.vtcc"; + public const string GearboxShiftPolygonFile = @"TestData\Components\AT_GBX\AT-Shift.vgbs"; + + + public static VectoRun CreateEngineeringRun(DrivingCycleData cycleData, GearboxType gbxType, string modFileName, + bool overspeed = false, KilogramSquareMeter gearBoxInertia = null) + { + var container = CreatePowerTrain(cycleData, gbxType, Path.GetFileNameWithoutExtension(modFileName), overspeed, + gearBoxInertia); + return new DistanceRun(container); + } + + public static VehicleContainer CreatePowerTrain(DrivingCycleData cycleData, GearboxType gbxType, string modFileName, + bool overspeed = false, KilogramSquareMeter gearBoxInertia = null) + { + var fileWriter = new FileOutputWriter(modFileName); + var modData = new ModalDataContainer(modFileName, fileWriter) { + WriteModalResults = true, + HasTorqueConverter = true + }; + var container = new VehicleContainer(ExecutionMode.Engineering, modData) { + RunData = new VectoRunData { JobName = modFileName, Cycle = cycleData }, + }; + var engineData = MockSimulationDataFactory.CreateEngineDataFromFile(EngineFile); + var axleGearData = CreateAxleGearData(gbxType); + var gearboxData = CreateGearboxData(gbxType); + if (gearBoxInertia != null) { + gearboxData.Inertia = gearBoxInertia; + } + + var vehicleData = CreateVehicleData(3300.SI<Kilogram>()); + var driverData = CreateDriverData(AccelerationFile, overspeed); + + var cycle = new DistanceBasedDrivingCycle(container, cycleData); + var engine = new CombustionEngine(container, engineData); + + var tmp = cycle.AddComponent(new Driver(container, driverData, new DefaultDriverStrategy())) + .AddComponent(new Vehicle(container, vehicleData)) + .AddComponent(new Wheels(container, vehicleData.DynamicTyreRadius, vehicleData.WheelsInertia)) + .AddComponent(new Brakes(container)) + .AddComponent(new AxleGear(container, axleGearData)) + .AddComponent(new DummyRetarder(container)) + .AddComponent(new ATGearbox(container, gearboxData, new ATShiftStrategy(gearboxData, container))) + .AddComponent(engine); + + var aux = new EngineAuxiliary(container); + aux.AddConstant("", 0.SI<Watt>()); + + engine.Connect(aux.Port()); + + return container; + } + + private static GearboxData CreateGearboxData(GearboxType gbxType) + { + var ratios = gbxType == GearboxType.ATSerial + ? new[] { 3.4, 1.9, 1.42, 1.0, 0.7, 0.62 } + : new[] { 1.35, 1.0, 0.73 }; + var torqueConverterFile = gbxType == GearboxType.ATSerial + ? TorqueConverterGenericFile + : TorqueConverterPowerSplitFile; + return new GearboxData { + Type = gbxType == GearboxType.ATSerial ? GearboxType.ATSerial : GearboxType.ATPowerSplit, + Gears = ratios.Select((ratio, i) => + Tuple.Create((uint)i, + new GearData { + //MaxTorque = 2300.SI<NewtonMeter>(), + LossMap = ratio.IsEqual(1) + ? TransmissionLossMapReader.Create(0.96, ratio, string.Format("Gear {0}", i)) + : TransmissionLossMapReader.Create(0.98, ratio, string.Format("Gear {0}", i)), + Ratio = ratio, + ShiftPolygon = ShiftPolygonReader.ReadFromFile(GearboxShiftPolygonFile), + TorqueConverterRatio = i == 0 ? (gbxType == GearboxType.ATPowerSplit ? 1.0 : ratio) : double.NaN, + TorqueConverterGearLossMap = i == 0 + ? TransmissionLossMapReader.Create(gbxType == GearboxType.ATPowerSplit ? 1.0 : 0.98, ratio, + string.Format("Gear {0}", i)) + : null, + })) + .ToDictionary(k => k.Item1 + 1, v => v.Item2), + ShiftTime = 1.SI<Second>(), + Inertia = 0.SI<KilogramSquareMeter>(), + TractionInterruption = 0.SI<Second>(), + StartSpeed = 2.SI<MeterPerSecond>(), + StartAcceleration = 0.6.SI<MeterPerSquareSecond>(), + StartTorqueReserve = 0.2, + SkipGears = false, + TorqueReserve = 0.2, + DownshiftAfterUpshiftDelay = DeclarationData.Gearbox.DownshiftAfterUpshiftDelay, + UpshiftAfterDownshiftDelay = DeclarationData.Gearbox.UpshiftAfterDownshiftDelay, + UpshiftMinAcceleration = DeclarationData.Gearbox.UpshiftMinAcceleration, + TorqueConverterData = + TorqueConverterDataReader.ReadFromFile(torqueConverterFile, 1000.RPMtoRad(), + DeclarationData.Gearbox.TorqueConverterSpeedLimit) + }; + } + + private static AxleGearData CreateAxleGearData(GearboxType gbxType) + { + var ratio = gbxType == GearboxType.ATSerial ? 6.2 : 5.8; + return new AxleGearData { + AxleGear = new GearData { + Ratio = ratio, + LossMap = TransmissionLossMapReader.Create(0.95, ratio, "Axlegear"), + } + }; + } + + private static VehicleData CreateVehicleData(Kilogram loading) + { + var axles = new List<Axle> { + new Axle { + AxleWeightShare = 0.38, + Inertia = 20.SI<KilogramSquareMeter>(), + RollResistanceCoefficient = 0.007, + TwinTyres = false, + TyreTestLoad = 30436.0.SI<Newton>() + }, + new Axle { + AxleWeightShare = 0.62, + Inertia = 18.SI<KilogramSquareMeter>(), + RollResistanceCoefficient = 0.007, + TwinTyres = true, + TyreTestLoad = 30436.SI<Newton>() + }, + }; + return new VehicleData { + AxleConfiguration = AxleConfiguration.AxleConfig_4x2, + //AerodynamicDragAera = 3.2634.SI<SquareMeter>(), + //CrossWindCorrectionMode = CrossWindCorrectionMode.NoCorrection, + CrossWindCorrectionCurve = + new CrosswindCorrectionCdxALookup(CrossWindCorrectionCurveReader.GetNoCorrectionCurve(3.2634.SI<SquareMeter>()), + CrossWindCorrectionMode.NoCorrection), + CurbWeight = 11500.SI<Kilogram>(), + Loading = loading, + DynamicTyreRadius = 0.465.SI<Meter>(), + AxleData = axles, + SavedInDeclarationMode = false + }; + } + + private static DriverData CreateDriverData(string accelerationFile, bool overspeed = false) + { + return new DriverData { + AccelerationCurve = AccelerationCurveReader.ReadFromFile(accelerationFile), + LookAheadCoasting = new DriverData.LACData { + Enabled = true, + //MinSpeed = 50.KMPHtoMeterPerSecond(), + //Deceleration = -0.5.SI<MeterPerSquareSecond>() + LookAheadDistanceFactor = DeclarationData.Driver.LookAhead.LookAheadDistanceFactor, + LookAheadDecisionFactor = new LACDecisionFactor() + }, + OverSpeedEcoRoll = overspeed + ? new DriverData.OverSpeedEcoRollData { + Mode = DriverMode.Overspeed, + MinSpeed = 50.KMPHtoMeterPerSecond(), + OverSpeed = 5.KMPHtoMeterPerSecond() + } + : new DriverData.OverSpeedEcoRollData { + Mode = DriverMode.Off + }, + StartStop = new VectoRunData.StartStopData { + Enabled = false + } + }; + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs b/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs index f08757e55b0edf7482cf2c5f737212185106c9a0..bc4a4b808f05bba1ffa6041bad8903d66800b8cf 100644 --- a/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs +++ b/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs @@ -44,6 +44,7 @@ using TUGraz.VectoCore.Models.SimulationComponent.Impl; using TUGraz.VectoCore.OutputData; using TUGraz.VectoCore.OutputData.FileIO; using TUGraz.VectoCore.Tests.Utils; +using TUGraz.VectoCore.Utils; using Wheels = TUGraz.VectoCore.Models.SimulationComponent.Impl.Wheels; namespace TUGraz.VectoCore.Tests.Integration @@ -56,7 +57,7 @@ namespace TUGraz.VectoCore.Tests.Integration public const string GearboxIndirectLoss = @"TestData\Components\Indirect Gear.vtlm"; public const string GearboxDirectLoss = @"TestData\Components\Direct Gear.vtlm"; public const string GearboxShiftPolygonFile = @"TestData\Components\ShiftPolygons.vgbs"; - public const string GearboxFullLoadCurveFile = @"TestData\Components\Gearbox.vfld"; + //public const string GearboxFullLoadCurveFile = @"TestData\Components\Gearbox.vfld"; public const string AdvancedAuxFile = @"Testdata\Integration\BusAuxiliaries\AdvAuxTest.aaux"; @@ -85,27 +86,22 @@ namespace TUGraz.VectoCore.Tests.Integration var cycle = new DistanceBasedDrivingCycle(container, cycleData); var engine = new CombustionEngine(container, engineData); - var clutch = new Clutch(container, engineData, engine.IdleController); - - dynamic tmp = Port.AddComponent(cycle, new Driver(container, driverData, new DefaultDriverStrategy())); - tmp = Port.AddComponent(tmp, new Vehicle(container, vehicleData)); - tmp = Port.AddComponent(tmp, new Wheels(container, vehicleData.DynamicTyreRadius, vehicleData.WheelsInertia)); - tmp = Port.AddComponent(tmp, new Brakes(container)); - tmp = Port.AddComponent(tmp, new AxleGear(container, axleGearData)); - tmp = Port.AddComponent(tmp, new DummyRetarder(container)); - tmp = Port.AddComponent(tmp, - new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container))); - tmp = Port.AddComponent(tmp, clutch); + + cycle.AddComponent(new Driver(container, driverData, new DefaultDriverStrategy())) + .AddComponent(new Vehicle(container, vehicleData)) + .AddComponent(new Wheels(container, vehicleData.DynamicTyreRadius, vehicleData.WheelsInertia)) + .AddComponent(new Brakes(container)) + .AddComponent(new AxleGear(container, axleGearData)) + .AddComponent(new DummyRetarder(container)) + .AddComponent(new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container))) + .AddComponent(new Clutch(container, engineData)) + .AddComponent(engine); var aux = new BusAuxiliariesAdapter(container, AdvancedAuxFile, "Coach", vehicleData.TotalVehicleWeight(), engineData.ConsumptionMap, engineData.IdleSpeed); engine.Connect(aux.Port()); - Port.AddComponent(tmp, engine); - - engine.IdleController.RequestPort = clutch.IdleControlPort; - return container; } @@ -117,7 +113,7 @@ namespace TUGraz.VectoCore.Tests.Integration Gears = ratios.Select((ratio, i) => Tuple.Create((uint)i, new GearData { - FullLoadCurve = FullLoadCurveReader.ReadFromFile(GearboxFullLoadCurveFile), + //MaxTorque = 2300.SI<NewtonMeter>(), LossMap = ratio.IsEqual(1) ? TransmissionLossMapReader.ReadFromFile(GearboxIndirectLoss, ratio, string.Format("Gear {0}", i)) : TransmissionLossMapReader.ReadFromFile(GearboxDirectLoss, ratio, string.Format("Gear {0}", i)), diff --git a/VectoCore/VectoCoreTest/Integration/CoachPowerTrain.cs b/VectoCore/VectoCoreTest/Integration/CoachPowerTrain.cs index 07e47ed28cc4fd84f053a56b04f077c0b3c1b898..b832d2801c6e6cb1f76dc3b58d024b4519e42c42 100644 --- a/VectoCore/VectoCoreTest/Integration/CoachPowerTrain.cs +++ b/VectoCore/VectoCoreTest/Integration/CoachPowerTrain.cs @@ -45,6 +45,7 @@ using TUGraz.VectoCore.Models.SimulationComponent.Impl; using TUGraz.VectoCore.OutputData; using TUGraz.VectoCore.OutputData.FileIO; using TUGraz.VectoCore.Tests.Utils; +using TUGraz.VectoCore.Utils; using Wheels = TUGraz.VectoCore.Models.SimulationComponent.Impl.Wheels; namespace TUGraz.VectoCore.Tests.Integration @@ -57,7 +58,7 @@ namespace TUGraz.VectoCore.Tests.Integration public const string GearboxIndirectLoss = @"TestData\Components\Indirect Gear.vtlm"; public const string GearboxDirectLoss = @"TestData\Components\Direct Gear.vtlm"; public const string GearboxShiftPolygonFile = @"TestData\Components\ShiftPolygons.vgbs"; - public const string GearboxFullLoadCurveFile = @"TestData\Components\Gearbox.vfld"; + //public const string GearboxFullLoadCurveFile = @"TestData\Components\Gearbox.vfld"; public static VectoRun CreateEngineeringRun(DrivingCycleData cycleData, string modFileName, bool overspeed = false, KilogramSquareMeter gearBoxInertia = null) @@ -87,27 +88,23 @@ namespace TUGraz.VectoCore.Tests.Integration var cycle = new DistanceBasedDrivingCycle(container, cycleData); var engine = new CombustionEngine(container, engineData); - var clutch = new Clutch(container, engineData, engine.IdleController); - - dynamic tmp = Port.AddComponent(cycle, new Driver(container, driverData, new DefaultDriverStrategy())); - tmp = Port.AddComponent(tmp, new Vehicle(container, vehicleData)); - tmp = Port.AddComponent(tmp, new Wheels(container, vehicleData.DynamicTyreRadius, vehicleData.WheelsInertia)); - tmp = Port.AddComponent(tmp, new Brakes(container)); - tmp = Port.AddComponent(tmp, new AxleGear(container, axleGearData)); - tmp = Port.AddComponent(tmp, new DummyRetarder(container)); - tmp = Port.AddComponent(tmp, - new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container))); - tmp = Port.AddComponent(tmp, clutch); + var clutch = new Clutch(container, engineData); + + var tmp = cycle.AddComponent(new Driver(container, driverData, new DefaultDriverStrategy())) + .AddComponent(new Vehicle(container, vehicleData)) + .AddComponent(new Wheels(container, vehicleData.DynamicTyreRadius, vehicleData.WheelsInertia)) + .AddComponent(new Brakes(container)) + .AddComponent(new AxleGear(container, axleGearData)) + .AddComponent(new DummyRetarder(container)) + .AddComponent(new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container))) + .AddComponent(clutch) + .AddComponent(engine); var aux = new EngineAuxiliary(container); aux.AddConstant("", 0.SI<Watt>()); engine.Connect(aux.Port()); - Port.AddComponent(tmp, engine); - - engine.IdleController.RequestPort = clutch.IdleControlPort; - return container; } @@ -119,7 +116,7 @@ namespace TUGraz.VectoCore.Tests.Integration Gears = ratios.Select((ratio, i) => Tuple.Create((uint)i, new GearData { - FullLoadCurve = FullLoadCurveReader.ReadFromFile(GearboxFullLoadCurveFile), + //MaxTorque = 2300.SI<NewtonMeter>(), LossMap = ratio.IsEqual(1) ? TransmissionLossMapReader.ReadFromFile(GearboxIndirectLoss, ratio, string.Format("Gear {0}", i)) : TransmissionLossMapReader.ReadFromFile(GearboxDirectLoss, ratio, string.Format("Gear {0}", i)), diff --git a/VectoCore/VectoCoreTest/Integration/DriverStrategy/SimpleCycles.cs b/VectoCore/VectoCoreTest/Integration/DriverStrategy/SimpleCycles.cs index a371b8a0035cb75a50a7ba64a233c59677873af1..73fde551ede8df1f8e15b8ae3b3a0d5463abf466 100644 --- a/VectoCore/VectoCoreTest/Integration/DriverStrategy/SimpleCycles.cs +++ b/VectoCore/VectoCoreTest/Integration/DriverStrategy/SimpleCycles.cs @@ -194,31 +194,44 @@ namespace TUGraz.VectoCore.Tests.Integration.DriverStrategy [Category("ComparisonV2"), TestCase(SimpleDrivingCycles.CycleDrive_80_Increasing_Slope, - "40t_Long_Haul_Truck_Cycle_Drive_80_Increasing_Slope.vmod", GearboxType.AMT, TestName = "TruckSpecial CycleDrive_80_Increasing_Slope"), + "40t_Long_Haul_Truck_Cycle_Drive_80_Increasing_Slope.vmod", GearboxType.AMT, + TestName = "TruckSpecial CycleDrive_80_Increasing_Slope"), TestCase(SimpleDrivingCycles.CycleDrive_50_Increasing_Slope, - "40t_Long_Haul_Truck_Cycle_Drive_50_Increasing_Slope.vmod", GearboxType.AMT, TestName = "TruckSpecial CycleDrive_50_Increasing_Slope"), + "40t_Long_Haul_Truck_Cycle_Drive_50_Increasing_Slope.vmod", GearboxType.AMT, + TestName = "TruckSpecial CycleDrive_50_Increasing_Slope"), TestCase(SimpleDrivingCycles.CycleDrive_30_Increasing_Slope, - "40t_Long_Haul_Truck_Cycle_Drive_30_Increasing_Slope.vmod", GearboxType.AMT, TestName = "TruckSpecial CycleDrive_30_Increasing_Slope"), + "40t_Long_Haul_Truck_Cycle_Drive_30_Increasing_Slope.vmod", GearboxType.AMT, + TestName = "TruckSpecial CycleDrive_30_Increasing_Slope"), TestCase(SimpleDrivingCycles.CycleDrive_80_Decreasing_Slope, - "40t_Long_Haul_Truck_Cycle_Drive_80_Decreasing_Slope.vmod", GearboxType.AMT, TestName = "TruckSpecial CycleDrive_80_Decreasing_Slope"), + "40t_Long_Haul_Truck_Cycle_Drive_80_Decreasing_Slope.vmod", GearboxType.AMT, + TestName = "TruckSpecial CycleDrive_80_Decreasing_Slope"), TestCase(SimpleDrivingCycles.CycleDrive_50_Decreasing_Slope, - "40t_Long_Haul_Truck_Cycle_Drive_50_Decreasing_Slope.vmod", GearboxType.AMT, TestName = "TruckSpecial CycleDrive_50_Decreasing_Slope"), + "40t_Long_Haul_Truck_Cycle_Drive_50_Decreasing_Slope.vmod", GearboxType.AMT, + TestName = "TruckSpecial CycleDrive_50_Decreasing_Slope"), TestCase(SimpleDrivingCycles.CycleDrive_30_Decreasing_Slope, - "40t_Long_Haul_Truck_Cycle_Drive_30_Decreasing_Slope.vmod", GearboxType.AMT, TestName = "TruckSpecial CycleDrive_30_Decreasing_Slope"), + "40t_Long_Haul_Truck_Cycle_Drive_30_Decreasing_Slope.vmod", GearboxType.AMT, + TestName = "TruckSpecial CycleDrive_30_Decreasing_Slope"), TestCase(SimpleDrivingCycles.CycleDrive_80_Dec_Increasing_Slope, - "40t_Long_Haul_Truck_Cycle_Drive_80_Dec_Increasing_Slope.vmod", GearboxType.AMT, TestName = "TruckSpecial CycleDrive_80_Dec_Increasing_Slope"), + "40t_Long_Haul_Truck_Cycle_Drive_80_Dec_Increasing_Slope.vmod", GearboxType.AMT, + TestName = "TruckSpecial CycleDrive_80_Dec_Increasing_Slope"), TestCase(SimpleDrivingCycles.CycleDrive_50_Dec_Increasing_Slope, - "40t_Long_Haul_Truck_Cycle_Drive_50_Dec_Increasing_Slope.vmod", GearboxType.AMT, TestName = "TruckSpecial CycleDrive_50_Dec_Increasing_Slope"), + "40t_Long_Haul_Truck_Cycle_Drive_50_Dec_Increasing_Slope.vmod", GearboxType.AMT, + TestName = "TruckSpecial CycleDrive_50_Dec_Increasing_Slope"), TestCase(SimpleDrivingCycles.CycleDrive_30_Dec_Increasing_Slope, - "40t_Long_Haul_Truck_Cycle_Drive_30_Dec_Increasing_Slope.vmod", GearboxType.AMT, TestName = "TruckSpecial CycleDrive_30_Dec_Increasing_Slope"), + "40t_Long_Haul_Truck_Cycle_Drive_30_Dec_Increasing_Slope.vmod", GearboxType.AMT, + TestName = "TruckSpecial CycleDrive_30_Dec_Increasing_Slope"), TestCase(SimpleDrivingCycles.CycleDecelerateWhileBrake_80_0_level, - "40t_Long_Haul_Truck_Cycle_DecelerateWhileBrake_80_0_level.vmod", GearboxType.AMT, TestName = "TruckSpecial CycleDecelerateWhileBrake_80_0_level"), + "40t_Long_Haul_Truck_Cycle_DecelerateWhileBrake_80_0_level.vmod", GearboxType.AMT, + TestName = "TruckSpecial CycleDecelerateWhileBrake_80_0_level"), TestCase(SimpleDrivingCycles.CycleAccelerateWhileBrake_80_0_level, - "40t_Long_Haul_Truck_Cycle_AccelerateWhileBrake_80_0_level.vmod", GearboxType.AMT, TestName = "TruckSpecial CycleAccelerateWhileBrake_80_0_level"), + "40t_Long_Haul_Truck_Cycle_AccelerateWhileBrake_80_0_level.vmod", GearboxType.AMT, + TestName = "TruckSpecial CycleAccelerateWhileBrake_80_0_level"), TestCase(SimpleDrivingCycles.CycleAccelerateAtBrake_80_0_level, - "40t_Long_Haul_Truck_Cycle_AccelerateAtBrake_80_0_level.vmod", GearboxType.AMT, TestName = "TruckSpecial CycleAccelerateAtBrake_80_0_level"), + "40t_Long_Haul_Truck_Cycle_AccelerateAtBrake_80_0_level.vmod", GearboxType.AMT, + TestName = "TruckSpecial CycleAccelerateAtBrake_80_0_level"), TestCase(SimpleDrivingCycles.CycleAccelerateBeforeBrake_80_0_level, - "40t_Long_Haul_Truck_Cycle_AccelerateBeforeBrake_80_0_level.vmod", GearboxType.AMT, TestName = "TruckSpecial CycleAccelerateBeforeBrake_80_0_level"), + "40t_Long_Haul_Truck_Cycle_AccelerateBeforeBrake_80_0_level.vmod", GearboxType.AMT, + TestName = "TruckSpecial CycleAccelerateBeforeBrake_80_0_level"), TestCase(SimpleDrivingCycles.CycleDrive_stop_85_stop_85_level, "24t Truck_Cycle_Drive_stop_85_stop_85_level.vmod", GearboxType.AMT, TestName = "TruckSpecial CycleDrive_stop_85_stop_85_level"), TestCase(SimpleDrivingCycles.CycleDrive_SlopeChangeBeforeStop, "Truck_DriverStrategy_SlopeChangeBeforeStop.vmod", @@ -293,9 +306,8 @@ namespace TUGraz.VectoCore.Tests.Integration.DriverStrategy var cycle = string.Format(CultureInfo.InvariantCulture, "0, {0}, {1}, {2}\n1000, {3}, {4}, {5}", v1, slope, v1.IsEqual(0) ? 2 : 0, v2, slope, v2.IsEqual(0) ? 2 : 0); - Coach_Special(cycle, - string.Format(CultureInfo.InvariantCulture, "24t Coach_Cycle_Accelerate_{0}_{1}_{2}.vmod", - v1, v2, GetSlopeString(slope))); + Coach_Special(cycle, string.Format(CultureInfo.InvariantCulture, "24t Coach_Cycle_Accelerate_{0}_{1}_{2}.vmod", + v1, v2, GetSlopeString(slope))); } [Category("ComparisonV2"), @@ -431,5 +443,142 @@ namespace TUGraz.VectoCore.Tests.Integration.DriverStrategy GraphWriter.Write(modFileName, @"..\..\TestData\Integration\DriverStrategy\Vecto2.2\Coach_Overspeed\" + modFileName); } + + // #################################################### + + [Category("AT Gearbox"), + TestCase(0, 20, -5), + TestCase(0, 20, 0), + TestCase(0, 85, -15), + TestCase(0, 85, -25), + TestCase(0, 85, -5), + TestCase(0, 85, 0), + TestCase(0, 85, 1), + TestCase(0, 85, 10), + TestCase(0, 85, 2), + //TestCase(0, 85, 25), + TestCase(0, 85, 5), + TestCase(20, 22, 5), + TestCase(20, 60, -15), + TestCase(20, 60, -25), + TestCase(20, 60, -5), + TestCase(20, 60, 0), + TestCase(20, 60, 15), + //TestCase(20, 60, 25), + TestCase(20, 60, 5), + ] + public void AT_Gearbox_Accelerate(double v1, double v2, double slope) + { + var cycle = string.Format(CultureInfo.InvariantCulture, "0, {0}, {1}, {2}\n1000, {3}, {4}, {5}", v1, slope, + v1.IsEqual(0) ? 2 : 0, v2, slope, v2.IsEqual(0) ? 2 : 0); + + AT_Gearbox_Special(cycle, + string.Format(CultureInfo.InvariantCulture, "AT-Gbx Accelerate_{0}_{1}_{2}.vmod", + v1, v2, GetSlopeString(slope))); + } + + [Category("AT Gearbox"), + TestCase(22, 20, -5), + TestCase(45, 0, -5), + TestCase(45, 0, 0), + TestCase(45, 0, 5), + TestCase(60, 20, -15), + TestCase(60, 20, -25), + TestCase(60, 20, -5), + TestCase(60, 20, 0), + //TestCase(60, 20, 15), + TestCase(60, 20, 5), + TestCase(80, 0, -15), + TestCase(80, 0, -25), + TestCase(80, 0, -5), + TestCase(80, 0, 0), + //TestCase(80, 0, 20), + //TestCase(80, 0, 15), + TestCase(80, 0, 3), + TestCase(80, 0, 5), + ] + public void AT_Gearbox_Decelerate(double v1, double v2, double slope) + { + var cycle = string.Format(CultureInfo.InvariantCulture, "0, {0}, {1}, {2}\n1000, {3}, {4}, {5}", v1, slope, + v1.IsEqual(0) ? 2 : 0, v2, slope, v2.IsEqual(0) ? 2 : 0); + + AT_Gearbox_Special(cycle, + string.Format(CultureInfo.InvariantCulture, "AT-Gbx Decelerate_{0}_{1}_{2}.vmod", + v1, v2, GetSlopeString(slope))); + } + + [Category("AT Gearbox"), + TestCase(10, 10, -15), + TestCase(10, 10, -25), + TestCase(10, 10, -5), + TestCase(10, 10, 0), + TestCase(10, 10, 15), + TestCase(10, 10, 25), + TestCase(10, 10, 5), + TestCase(20, 20, -15), + TestCase(30, 30, -15), + TestCase(50, 50, -15), + TestCase(80, 80, -15), + TestCase(80, 80, -5), + TestCase(80, 80, 0), + //TestCase(80, 80, 15), + TestCase(80, 80, 5), + ] + public void AT_Gearbox_Drive(double v1, double v2, double slope) + { + var cycle = string.Format(CultureInfo.InvariantCulture, "0, {0}, {1}, {2}\n1000, {3}, {4}, {5}", v1, slope, + v1.IsEqual(0) ? 2 : 0, v2, slope, v2.IsEqual(0) ? 2 : 0); + + AT_Gearbox_Special(cycle, string.Format(CultureInfo.InvariantCulture, "AT-Gbx Drive_{0}_{1}_{2}.vmod", + v1, v2, GetSlopeString(slope))); + } + + [Category("AT Gearbox"), + TestCase(SimpleDrivingCycles.CycleDrive_80_Increasing_Slope, + "AT-Gbx Drive_80_Increasing_Slope.vmod", TestName = "AT-Gearbox CycleDrive_80_Increasing_Slope"), + TestCase(SimpleDrivingCycles.CycleDrive_50_Increasing_Slope, + "AT-Gbx Drive_50_Increasing_Slope.vmod", TestName = "AT-Gearbox CycleDrive_50_Increasing_Slope"), + TestCase(SimpleDrivingCycles.CycleDrive_30_Increasing_Slope, + "AT-Gbx Drive_30_Increasing_Slope.vmod", TestName = "AT-Gearbox CycleDrive_30_Increasing_Slope"), + TestCase(SimpleDrivingCycles.CycleDrive_80_Decreasing_Slope, + "AT-Gbx Drive_80_Decreasing_Slope.vmod", TestName = "AT-Gearbox CycleDrive_80_Decreasing_Slope"), + TestCase(SimpleDrivingCycles.CycleDrive_50_Decreasing_Slope, + "AT-Gbx Drive_50_Decreasing_Slope.vmod", TestName = "AT-Gearbox CycleDrive_50_Decreasing_Slope"), + TestCase(SimpleDrivingCycles.CycleDrive_30_Decreasing_Slope, + "AT-Gbx Drive_30_Decreasing_Slope.vmod", TestName = "AT-Gearbox CycleDrive_30_Decreasing_Slope"), + TestCase(SimpleDrivingCycles.CycleDrive_80_Dec_Increasing_Slope, + "AT-Gbx Drive_80_Dec_Increasing_Slope.vmod", TestName = "AT-Gearbox CycleDrive_80_Dec_Increasing_Slope"), + TestCase(SimpleDrivingCycles.CycleDrive_50_Dec_Increasing_Slope, + "AT-Gbx Drive_50_Dec_Increasing_Slope.vmod", TestName = "AT-Gearbox CycleDrive_50_Dec_Increasing_Slope"), + TestCase(SimpleDrivingCycles.CycleDrive_30_Dec_Increasing_Slope, + "AT-Gbx Drive_30_Dec_Increasing_Slope.vmod", TestName = "AT-GearboxCycleDrive_30_Dec_Increasing_Slope "), + TestCase(SimpleDrivingCycles.CycleDecelerateWhileBrake_80_0_level, + "AT-Gbx DecelerateWhileBrake_80_0_level.vmod", + TestName = "AT-Gearbox CycleDecelerateWhileBrake_80_0_level"), + TestCase(SimpleDrivingCycles.CycleAccelerateWhileBrake_80_0_level, + "AT-Gbx AccelerateWhileBrake_80_0_level.vmod", + TestName = "AT-Gearbox CycleAccelerateWhileBrake_80_0_level"), + TestCase(SimpleDrivingCycles.CycleAccelerateAtBrake_80_0_level, + "AT-Gbx AccelerateAtBrake_80_0_level.vmod", TestName = "AT-Gearbox CycleAccelerateAtBrake_80_0_level"), + TestCase(SimpleDrivingCycles.CycleAccelerateBeforeBrake_80_0_level, + "AT-Gbx AccelerateBeforeBrake_80_0_level.vmod", + TestName = "AT-Gearbox CycleAccelerateBeforeBrake_80_0_level"), + TestCase(SimpleDrivingCycles.CycleDrive_stop_85_stop_85_level, "AT-Gbx Drive_stop_85_stop_85_level.vmod", + TestName = "AT-Gearbox CycleDrive_stop_85_stop_85_level"), + TestCase(SimpleDrivingCycles.CycleDrive_SlopeChangeBeforeStop, "24t Coach_DriverStrategy_SlopeChangeBeforeStop.vmod", + TestName = "AT-Gearbox CycleDrive_SlopeChangeBeforeStop"), + TestCase(SimpleDrivingCycles.CycleDriver_FrequentSlopChange, "24t Coach_DriverStrategy_SlopeChangeBeforeStop.vmod", + TestName = "AT-Gearbox CycleDriver_FrequentSlopChange"), + ] + public void AT_Gearbox_Special(string cycleData, string modFileName) + { + var cycle = SimpleDrivingCycles.CreateCycleData(cycleData); + var run = ATPowerTrain.CreateEngineeringRun(cycle, GearboxType.ATSerial, modFileName); + + run.Run(); + Assert.IsTrue(run.FinishedWithoutErrors); + + //GraphWriter.Write(modFileName, @"..\..\TestData\Integration\DriverStrategy\Vecto2.2\Coach\" + modFileName); + } } } \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/Integration/FullCycleDeclarationTest.cs b/VectoCore/VectoCoreTest/Integration/FullCycleDeclarationTest.cs index efe613a3d1817aa2ed2c90204d96bc0c213a497b..c8c4ab8527c33b7d55bfbcafce5feb6c8ee2c343 100644 --- a/VectoCore/VectoCoreTest/Integration/FullCycleDeclarationTest.cs +++ b/VectoCore/VectoCoreTest/Integration/FullCycleDeclarationTest.cs @@ -186,11 +186,13 @@ namespace TUGraz.VectoCore.Tests.Integration var modFileName = "40t_Long_Haul_Truck_RegionalDeliveryFullLoading.vmod"; var modFileName1Hz = "40t_Long_Haul_Truck_RegionalDeliveryFullLoading_1Hz.vmod"; - if (File.Exists(modFileName)) + if (File.Exists(modFileName)) { File.Delete(modFileName); + } - if (File.Exists(modFileName1Hz)) + if (File.Exists(modFileName1Hz)) { File.Delete(modFileName1Hz); + } var inputData = JSONInputDataFactory.ReadJsonJob(LongHaulTruckDeclarationJob); var fileWriter = new FileOutputWriter("Truck40t_Mod1Hz_Test.vecto"); @@ -286,7 +288,7 @@ namespace TUGraz.VectoCore.Tests.Integration var jobContainer = new JobContainer(sumData); jobContainer.AddRuns(factory); - //var i = 7; + //var i = 2; //jobContainer.Runs[i].Run.Run(); //Assert.IsTrue(jobContainer.Runs[i].Run.FinishedWithoutErrors); @@ -299,7 +301,10 @@ namespace TUGraz.VectoCore.Tests.Integration jobContainer.Execute(); jobContainer.WaitFinished(); - Assert.IsTrue(jobContainer.Runs.All(r => r.Success), string.Concat(jobContainer.Runs.Select(r => r.ExecException))); + Assert.IsTrue(jobContainer.Runs.All(r => r.Success), + string.Format("folowing runs failed: {0}\n{1}", + string.Concat(jobContainer.Runs.Where(r => !r.Success).Select(r => r.Run.RunName + " - " + r.Run.CycleName)), + string.Concat(jobContainer.Runs.Select(r => r.ExecException)))); } [TestMethod, TestCategory("LongRunning")] diff --git a/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs b/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs index cf5529dab582b016e1d0d3680c431e0eab87800d..3baaded391ea484826385b6185dc0f7b589a6a8a 100644 --- a/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs +++ b/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs @@ -63,7 +63,7 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns public const string GearboxLossMap = @"TestData\Components\Indirect Gear.vtlm"; public const string AxleLossMap = @"TestData\Components\Axle.vtlm"; public const string GearboxShiftPolygonFile = @"TestData\Components\ShiftPolygons.vgbs"; - public const string GearboxFullLoadCurveFile = @"TestData\Components\Gearbox.vfld"; + //public const string GearboxFullLoadCurveFile = @"TestData\Components\Gearbox.vfld"; private static readonly LoggingObject Log = LogManager.GetLogger(typeof(FullPowerTrain).ToString()); [TestMethod, TestCategory("LongRunning")] @@ -82,18 +82,16 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns var cycle = new DistanceBasedDrivingCycle(container, cycleData); var cyclePort = cycle.OutPort(); - dynamic tmp = Port.AddComponent(cycle, new Driver(container, driverData, new DefaultDriverStrategy())); - tmp = Port.AddComponent(tmp, new Vehicle(container, vehicleData)); - tmp = Port.AddComponent(tmp, new Wheels(container, vehicleData.DynamicTyreRadius, vehicleData.WheelsInertia)); - tmp = Port.AddComponent(tmp, new Brakes(container)); - tmp = Port.AddComponent(tmp, new AxleGear(container, axleGearData)); - var gbx = new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container)); - tmp = Port.AddComponent(tmp, gbx); - var engine = new CombustionEngine(container, engineData); - var clutch = new Clutch(container, engineData, engine.IdleController); - tmp = Port.AddComponent(tmp, clutch); - Port.AddComponent(tmp, engine); - engine.IdleController.RequestPort = clutch.IdleControlPort; + + cycle.AddComponent(new Driver(container, driverData, new DefaultDriverStrategy())) + .AddComponent(new Vehicle(container, vehicleData)) + .AddComponent(new Wheels(container, vehicleData.DynamicTyreRadius, vehicleData.WheelsInertia)) + .AddComponent(new Brakes(container)) + .AddComponent(new AxleGear(container, axleGearData)) + .AddComponent(new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container))) + .AddComponent(new Clutch(container, engineData)) + .AddComponent(new CombustionEngine(container, engineData)); + cyclePort.Initialize(); @@ -140,19 +138,16 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns var driverData = CreateDriverData(AccelerationFile); var cycle = new DistanceBasedDrivingCycle(container, cycleData); + var cyclePort = cycle.OutPort(); - dynamic tmp = Port.AddComponent(cycle, new Driver(container, driverData, new DefaultDriverStrategy())); - tmp = Port.AddComponent(tmp, new Vehicle(container, vehicleData)); - tmp = Port.AddComponent(tmp, new Wheels(container, vehicleData.DynamicTyreRadius, vehicleData.WheelsInertia)); - tmp = Port.AddComponent(tmp, new Brakes(container)); - tmp = Port.AddComponent(tmp, new AxleGear(container, axleGearData)); - var gbx = new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container)); - tmp = Port.AddComponent(tmp, gbx); - var engine = new CombustionEngine(container, engineData); - var clutch = new Clutch(container, engineData, engine.IdleController); - tmp = Port.AddComponent(tmp, clutch); - Port.AddComponent(tmp, engine); - engine.IdleController.RequestPort = clutch.IdleControlPort; + cycle.AddComponent(new Driver(container, driverData, new DefaultDriverStrategy())) + .AddComponent(new Vehicle(container, vehicleData)) + .AddComponent(new Wheels(container, vehicleData.DynamicTyreRadius, vehicleData.WheelsInertia)) + .AddComponent(new Brakes(container)) + .AddComponent(new AxleGear(container, axleGearData)) + .AddComponent(new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container))) + .AddComponent(new Clutch(container, engineData)) + .AddComponent(new CombustionEngine(container, engineData)); cyclePort.Initialize(); @@ -215,18 +210,14 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns var cycle = new DistanceBasedDrivingCycle(container, cycleData); var cyclePort = cycle.OutPort(); - dynamic tmp = Port.AddComponent(cycle, new Driver(container, driverData, new DefaultDriverStrategy())); - tmp = Port.AddComponent(tmp, new Vehicle(container, vehicleData)); - tmp = Port.AddComponent(tmp, new Wheels(container, vehicleData.DynamicTyreRadius, vehicleData.WheelsInertia)); - tmp = Port.AddComponent(tmp, new Brakes(container)); - tmp = Port.AddComponent(tmp, new AxleGear(container, axleGearData)); - tmp = Port.AddComponent(tmp, - new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container))); - var engine = new CombustionEngine(container, engineData); - var clutch = new Clutch(container, engineData, engine.IdleController); - tmp = Port.AddComponent(tmp, clutch); - Port.AddComponent(tmp, engine); - engine.IdleController.RequestPort = clutch.IdleControlPort; + cycle.AddComponent(new Driver(container, driverData, new DefaultDriverStrategy())) + .AddComponent(new Vehicle(container, vehicleData)) + .AddComponent(new Wheels(container, vehicleData.DynamicTyreRadius, vehicleData.WheelsInertia)) + .AddComponent(new Brakes(container)) + .AddComponent(new AxleGear(container, axleGearData)) + .AddComponent(new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container))) + .AddComponent(new Clutch(container, engineData)) + .AddComponent(new CombustionEngine(container, engineData)); cyclePort.Initialize(); @@ -304,8 +295,7 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns Gears = ratios.Select((ratio, i) => Tuple.Create((uint)i, new GearData { - // TODO mk-2016-05-09: add realistic FullLoadCurve for gearbox - gearbox will have only 1 constant value as full load - FullLoadCurve = FullLoadCurveReader.ReadFromFile(GearboxFullLoadCurveFile), + MaxTorque = ratio > 5 ? 2300.SI<NewtonMeter>() : null, LossMap = TransmissionLossMapReader.ReadFromFile(GearboxLossMap, ratio, string.Format("Gear {0}", i)), Ratio = ratio, ShiftPolygon = ShiftPolygonReader.ReadFromFile(GearboxShiftPolygonFile) @@ -342,7 +332,7 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns Gears = new Dictionary<uint, GearData> { { 1, new GearData { - FullLoadCurve = null, + MaxTorque = null, LossMap = TransmissionLossMapReader.ReadFromFile(GearboxLossMap, ratio, "Gear 1"), Ratio = ratio, ShiftPolygon = ShiftPolygonReader.ReadFromFile(GearboxShiftPolygonFile) diff --git a/VectoCore/VectoCoreTest/Integration/SimulationRuns/MinimalPowertrain.cs b/VectoCore/VectoCoreTest/Integration/SimulationRuns/MinimalPowertrain.cs index a24ab0bced905e0e1ee8797a8d7820cf3d3a000f..2eff2b8a78db57646d476f9506062348026a9ca2 100644 --- a/VectoCore/VectoCoreTest/Integration/SimulationRuns/MinimalPowertrain.cs +++ b/VectoCore/VectoCoreTest/Integration/SimulationRuns/MinimalPowertrain.cs @@ -78,15 +78,12 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns var vehicleContainer = new VehicleContainer(ExecutionMode.Engineering, modData); var driver = new Driver(vehicleContainer, driverData, new DefaultDriverStrategy()); - dynamic tmp = Port.AddComponent(driver, new Vehicle(vehicleContainer, vehicleData)); - tmp = Port.AddComponent(tmp, new Wheels(vehicleContainer, vehicleData.DynamicTyreRadius, vehicleData.WheelsInertia)); - tmp = Port.AddComponent(tmp, new AxleGear(vehicleContainer, axleGearData)); - var engine = new CombustionEngine(vehicleContainer, engineData); - var clutch = new Clutch(vehicleContainer, engineData, engine.IdleController); - tmp = Port.AddComponent(tmp, clutch); - Port.AddComponent(tmp, engine); - engine.IdleController.RequestPort = clutch.IdleControlPort; + driver.AddComponent(new Vehicle(vehicleContainer, vehicleData)) + .AddComponent(new Wheels(vehicleContainer, vehicleData.DynamicTyreRadius, vehicleData.WheelsInertia)) + .AddComponent(new AxleGear(vehicleContainer, axleGearData)) + .AddComponent(new Clutch(vehicleContainer, engineData)) + .AddComponent(engine); var gbx = new MockGearbox(vehicleContainer); @@ -128,16 +125,14 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns var cycle = new DistanceBasedDrivingCycle(vehicleContainer, cycleData); - dynamic tmp = Port.AddComponent(cycle, new Driver(vehicleContainer, driverData, new DefaultDriverStrategy())); - tmp = Port.AddComponent(tmp, new Vehicle(vehicleContainer, vehicleData)); - tmp = Port.AddComponent(tmp, new Wheels(vehicleContainer, vehicleData.DynamicTyreRadius, vehicleData.WheelsInertia)); - tmp = Port.AddComponent(tmp, new Brakes(vehicleContainer)); - tmp = Port.AddComponent(tmp, new AxleGear(vehicleContainer, axleGearData)); - var engine = new CombustionEngine(vehicleContainer, engineData); - var clutch = new Clutch(vehicleContainer, engineData, engine.IdleController); - tmp = Port.AddComponent(tmp, clutch); - Port.AddComponent(tmp, engine); - engine.IdleController.RequestPort = clutch.IdleControlPort; + cycle.AddComponent(new Driver(vehicleContainer, driverData, new DefaultDriverStrategy())) + .AddComponent(new Vehicle(vehicleContainer, vehicleData)) + .AddComponent(new Wheels(vehicleContainer, vehicleData.DynamicTyreRadius, vehicleData.WheelsInertia)) + .AddComponent(new Brakes(vehicleContainer)) + .AddComponent(new AxleGear(vehicleContainer, axleGearData)) + .AddComponent(new Clutch(vehicleContainer, engineData)) + .AddComponent(new CombustionEngine(vehicleContainer, engineData)); + //engine.IdleController.RequestPort = clutch.IdleControlPort; var gbx = new MockGearbox(vehicleContainer); @@ -201,17 +196,14 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns var vehicleContainer = new VehicleContainer(ExecutionMode.Engineering, modData); var cycle = new DistanceBasedDrivingCycle(vehicleContainer, cycleData); - - dynamic tmp = Port.AddComponent(cycle, new Driver(vehicleContainer, driverData, new DefaultDriverStrategy())); - tmp = Port.AddComponent(tmp, new Vehicle(vehicleContainer, vehicleData)); - tmp = Port.AddComponent(tmp, new Wheels(vehicleContainer, vehicleData.DynamicTyreRadius, vehicleData.WheelsInertia)); - tmp = Port.AddComponent(tmp, new Brakes(vehicleContainer)); - tmp = Port.AddComponent(tmp, new AxleGear(vehicleContainer, axleGearData)); - var engine = new CombustionEngine(vehicleContainer, engineData); - var clutch = new Clutch(vehicleContainer, engineData, engine.IdleController); - tmp = Port.AddComponent(tmp, clutch); - Port.AddComponent(tmp, engine); - engine.IdleController.RequestPort = clutch.IdleControlPort; + cycle.AddComponent(new Driver(vehicleContainer, driverData, new DefaultDriverStrategy())) + .AddComponent(new Vehicle(vehicleContainer, vehicleData)) + .AddComponent(new Wheels(vehicleContainer, vehicleData.DynamicTyreRadius, vehicleData.WheelsInertia)) + .AddComponent(new Brakes(vehicleContainer)) + .AddComponent(new AxleGear(vehicleContainer, axleGearData)) + .AddComponent(new Clutch(vehicleContainer, engineData)) + .AddComponent(new CombustionEngine(vehicleContainer, engineData)); + //engine.IdleController.RequestPort = clutch.IdleControlPort; var gbx = new MockGearbox(vehicleContainer); diff --git a/VectoCore/VectoCoreTest/Integration/Truck40tPowerTrain.cs b/VectoCore/VectoCoreTest/Integration/Truck40tPowerTrain.cs index c9fb1ecaa341981d79cc14ac459ba00e5a297a4b..83d65c1a60c0f76486f3e68145a1db42343d28c9 100644 --- a/VectoCore/VectoCoreTest/Integration/Truck40tPowerTrain.cs +++ b/VectoCore/VectoCoreTest/Integration/Truck40tPowerTrain.cs @@ -46,6 +46,7 @@ using TUGraz.VectoCore.Models.SimulationComponent.Impl; using TUGraz.VectoCore.OutputData; using TUGraz.VectoCore.OutputData.FileIO; using TUGraz.VectoCore.Tests.Utils; +using TUGraz.VectoCore.Utils; using Wheels = TUGraz.VectoCore.Models.SimulationComponent.Impl.Wheels; namespace TUGraz.VectoCore.Tests.Integration @@ -60,7 +61,7 @@ namespace TUGraz.VectoCore.Tests.Integration public const string GearboxIndirectLoss = @"TestData\Components\Indirect Gear.vtlm"; public const string GearboxDirectLoss = @"TestData\Components\Direct Gear.vtlm"; public const string GearboxShiftPolygonFile = @"TestData\Components\ShiftPolygons.vgbs"; - public const string GearboxFullLoadCurveFile = @"TestData\Components\Gearbox.vfld"; + //public const string GearboxFullLoadCurveFile = @"TestData\Components\Gearbox.vfld"; public static VectoRun CreateEngineeringRun(DrivingCycleData cycleData, string modFileName, bool overspeed = false, GearboxType gbxType = GearboxType.AMT) @@ -96,7 +97,7 @@ namespace TUGraz.VectoCore.Tests.Integration var cycle = new DistanceBasedDrivingCycle(container, cycleData); var engine = new CombustionEngine(container, engineData); - var clutch = new Clutch(container, engineData, engine.IdleController); + var clutch = new Clutch(container, engineData); IShiftStrategy gbxStrategy; switch (gbxType) { @@ -110,22 +111,20 @@ namespace TUGraz.VectoCore.Tests.Integration throw new ArgumentOutOfRangeException("gbxType", gbxType, null); } - dynamic tmp = Port.AddComponent(cycle, new Driver(container, driverData, new DefaultDriverStrategy())); - tmp = Port.AddComponent(tmp, new Vehicle(container, vehicleData)); - tmp = Port.AddComponent(tmp, new Wheels(container, vehicleData.DynamicTyreRadius, vehicleData.WheelsInertia)); - tmp = Port.AddComponent(tmp, new Brakes(container)); - tmp = Port.AddComponent(tmp, new AxleGear(container, axleGearData)); - tmp = Port.AddComponent(tmp, new DummyRetarder(container)); - tmp = Port.AddComponent(tmp, new Gearbox(container, gearboxData, gbxStrategy)); - tmp = Port.AddComponent(tmp, clutch); + dynamic tmp = cycle.AddComponent(new Driver(container, driverData, new DefaultDriverStrategy())) + .AddComponent(new Vehicle(container, vehicleData)) + .AddComponent(new Wheels(container, vehicleData.DynamicTyreRadius, vehicleData.WheelsInertia)) + .AddComponent(new Brakes(container)) + .AddComponent(new AxleGear(container, axleGearData)) + .AddComponent(new DummyRetarder(container)) + .AddComponent(new Gearbox(container, gearboxData, gbxStrategy)) + .AddComponent(clutch) + .AddComponent(engine); var aux = new EngineAuxiliary(container); aux.AddConstant("", 0.SI<Watt>()); engine.Connect(aux.Port()); - Port.AddComponent(tmp, engine); - engine.IdleController.RequestPort = clutch.IdleControlPort; - return container; } @@ -135,7 +134,7 @@ namespace TUGraz.VectoCore.Tests.Integration return new GearboxData { Gears = ratios.Select((ratio, i) => Tuple.Create((uint)i, new GearData { - FullLoadCurve = FullLoadCurveReader.ReadFromFile(GearboxFullLoadCurveFile), + //MaxTorque = 2300.SI<NewtonMeter>(), LossMap = TransmissionLossMapReader.ReadFromFile(ratio.IsEqual(1) ? GearboxIndirectLoss : GearboxDirectLoss, ratio, string.Format("Gear {0}", i)), diff --git a/VectoCore/VectoCoreTest/Models/Declaration/ShiftPolygonTest.cs b/VectoCore/VectoCoreTest/Models/Declaration/ShiftPolygonTest.cs index c1c167cd38b60aa3e78dcc2b7531a018afddf7a4..4d27acea0be018ec2404ee430b1af5796bdc21b0 100644 --- a/VectoCore/VectoCoreTest/Models/Declaration/ShiftPolygonTest.cs +++ b/VectoCore/VectoCoreTest/Models/Declaration/ShiftPolygonTest.cs @@ -35,6 +35,7 @@ using System.IO; using System.Linq; using NUnit.Framework; using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.InputData.FileIO.JSON; using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter; @@ -341,7 +342,8 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration }; var dao = new DeclarationDataAdapter(); - var engineData = dao.CreateEngineData(new JSONEngineDataV3(JSONInputDataFactory.ReadFile(engineFile), engineFile)); + var engineData = dao.CreateEngineData(new JSONEngineDataV3(JSONInputDataFactory.ReadFile(engineFile), engineFile), + GearboxType.AMT); var gearboxData = new JSONGearboxDataV5(JSONInputDataFactory.ReadFile(gearboxFile), gearboxFile); diff --git a/VectoCore/VectoCoreTest/Models/Simulation/AuxTests.cs b/VectoCore/VectoCoreTest/Models/Simulation/AuxTests.cs index 6f692a27289556179026869196911c51b47694ec..43d3d91a0a90041583478109266ce3b58fa03193 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/AuxTests.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/AuxTests.cs @@ -58,7 +58,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation { var fileWriter = new FileOutputWriter("AuxWriteModFileSumFile"); - var modData = new ModalDataContainer("AuxWriteModFileSumFile", fileWriter); + var modData = new ModalDataContainer("AuxWriteModFileSumFile", fileWriter) { WriteModalResults = true }; modData.AddAuxiliary("FAN"); modData.AddAuxiliary("PS"); modData.AddAuxiliary("STP"); diff --git a/VectoCore/VectoCoreTest/Models/Simulation/FactoryTest.cs b/VectoCore/VectoCoreTest/Models/Simulation/FactoryTest.cs index 4265702f3489ff29338d30307004f1b2881458b5..29f26b091b4ebb002bf57dae0d2237f5e071a525 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/FactoryTest.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/FactoryTest.cs @@ -78,7 +78,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation Assert.AreEqual(660.RPMtoRad().Value(), gearbox.ModelData.Gears[2].ShiftPolygon.Downshift[1].AngularSpeed.Value(), 0.0001); - Assert.AreEqual(208.116856, gearbox.ModelData.Gears[2].ShiftPolygon.Downshift[1].Torque.Value(), 0.1); + Assert.AreEqual(207.4205, gearbox.ModelData.Gears[2].ShiftPolygon.Downshift[1].Torque.Value(), 0.1); Assert.AreEqual(1750.70139.RPMtoRad().Value(), gearbox.ModelData.Gears[2].ShiftPolygon.Downshift[2].AngularSpeed.Value(), @@ -87,15 +87,17 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation // -- shiftpolygon upshift - Assert.AreEqual(1891.2419.RPMtoRad().Value(), gearbox.ModelData.Gears[1].ShiftPolygon.Upshift[0].AngularSpeed.Value(), + Assert.AreEqual(1889.66433.RPMtoRad().Value(), + gearbox.ModelData.Gears[1].ShiftPolygon.Upshift[0].AngularSpeed.Value(), 0.1); Assert.AreEqual(-163.9, gearbox.ModelData.Gears[1].ShiftPolygon.Upshift[0].Torque.Value(), 0.0001); - Assert.AreEqual(1891.2419.RPMtoRad().Value(), gearbox.ModelData.Gears[1].ShiftPolygon.Upshift[1].AngularSpeed.Value(), + Assert.AreEqual(1889.66433.RPMtoRad().Value(), + gearbox.ModelData.Gears[1].ShiftPolygon.Upshift[1].AngularSpeed.Value(), 0.1); Assert.AreEqual(245.3663, gearbox.ModelData.Gears[1].ShiftPolygon.Upshift[1].Torque.Value(), 0.1); - Assert.AreEqual(5798.4116.RPMtoRad().Value(), gearbox.ModelData.Gears[1].ShiftPolygon.Upshift[2].AngularSpeed.Value(), + Assert.AreEqual(5793.0409.RPMtoRad().Value(), gearbox.ModelData.Gears[1].ShiftPolygon.Upshift[2].AngularSpeed.Value(), 0.1); Assert.AreEqual(988.9, gearbox.ModelData.Gears[1].ShiftPolygon.Upshift[2].Torque.Value(), 0.1); } diff --git a/VectoCore/VectoCoreTest/Models/Simulation/LossMapRangeValidationTest.cs b/VectoCore/VectoCoreTest/Models/Simulation/LossMapRangeValidationTest.cs index 38f859b658ba3abd0302b10ca4bff15a5b219dbe..8d23f7038bc7b89b9ab78c73391511f22449f297 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/LossMapRangeValidationTest.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/LossMapRangeValidationTest.cs @@ -60,7 +60,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation public const string GearboxDirectLoss = @"TestData\Components\Direct Gear.vtlm"; public const string GearboxLimited = @"TestData\Components\limited.vtlm"; public const string GearboxShiftPolygonFile = @"TestData\Components\ShiftPolygons.vgbs"; - public const string GearboxFullLoadCurveFile = @"TestData\Components\Gearbox.vfld"; + //public const string GearboxFullLoadCurveFile = @"TestData\Components\Gearbox.vfld"; /// <summary> /// VECTO-173 @@ -176,7 +176,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation Gears = ratios.Select((ratio, i) => Tuple.Create((uint)i, new GearData { - FullLoadCurve = FullLoadCurveReader.ReadFromFile(GearboxFullLoadCurveFile), + MaxTorque = 2300.SI<NewtonMeter>(), LossMap = TransmissionLossMapReader.ReadFromFile(!ratio.IsEqual(1.0) ? directlossMap : indirectLossMap, ratio, string.Format("Gear {0}", i)), Ratio = ratio, diff --git a/VectoCore/VectoCoreTest/Models/Simulation/MeasuredSpeedModeTest.cs b/VectoCore/VectoCoreTest/Models/Simulation/MeasuredSpeedModeTest.cs index 20c3df20358d0ef065c5b9c9664bba0345b6b9e6..b076d54fe87bbe20574d66b3256f11ed6a2c8f45 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/MeasuredSpeedModeTest.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/MeasuredSpeedModeTest.cs @@ -248,7 +248,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation }; // call builder (actual test) - var builder = new PowertrainBuilder(null); + var builder = new PowertrainBuilder(new MockModalDataContainer()); builder.Build(data); } @@ -310,7 +310,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation }; // call builder (actual test) - var builder = new PowertrainBuilder(null); + var builder = new PowertrainBuilder(new MockModalDataContainer()); var jobContainer = builder.Build(data); } diff --git a/VectoCore/VectoCoreTest/Models/Simulation/PwheelModeTests.cs b/VectoCore/VectoCoreTest/Models/Simulation/PwheelModeTests.cs index dca4f533a713c5996a015971a8f487eb427a6d1e..8cf5160bf56efc47a213838bfbcace89318a4e47 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/PwheelModeTests.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/PwheelModeTests.cs @@ -137,7 +137,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation }; // call builder (actual test) - var builder = new PowertrainBuilder(null); + var builder = new PowertrainBuilder(new MockModalDataContainer()); var jobContainer = builder.Build(data); } diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/ATGearboxTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/ATGearboxTest.cs new file mode 100644 index 0000000000000000000000000000000000000000..32533e33e92d5531e93729ef5876465b26fb87be --- /dev/null +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/ATGearboxTest.cs @@ -0,0 +1,135 @@ +using NUnit.Framework; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Configuration; +using TUGraz.VectoCore.Models.Connector.Ports.Impl; +using TUGraz.VectoCore.Models.Simulation.Impl; +using TUGraz.VectoCore.Models.SimulationComponent.Data; +using TUGraz.VectoCore.Models.SimulationComponent.Impl; +using TUGraz.VectoCore.OutputData; +using TUGraz.VectoCore.OutputData.FileIO; +using TUGraz.VectoCore.Tests.Integration; +using TUGraz.VectoCore.Tests.Utils; + +namespace TUGraz.VectoCore.Tests.Models.SimulationComponent +{ + [TestFixture] + public class ATGearboxTest + { + public const string EngineDataFile = @"TestData\Components\AT_GBX\Engine.veng"; + public const string GearboxDataFile = @"TestData\Components\AT_GBX\GearboxSerial.vgbx"; + + [Test, + TestCase(0, 100, 1), + TestCase(0, 200, 1), + TestCase(5, 100, 1), + TestCase(5, 300, 1), + TestCase(5, 600, 1), + TestCase(15, 100, 3), + TestCase(15, 300, 3), + TestCase(15, 600, 2), + TestCase(40, 100, 6), + TestCase(40, 300, 5), + TestCase(40, 600, 4), + TestCase(70, 100, 6), + TestCase(70, 300, 6), + TestCase(70, 600, 6), + ] + public void TestATGearInitialize(double vehicleSpeed, double torque, int expectedGear) + { + var vehicleContainer = new MockVehicleContainer(); //(ExecutionMode.Engineering); + vehicleContainer.Engine = new CombustionEngine(vehicleContainer, + MockSimulationDataFactory.CreateEngineDataFromFile(EngineDataFile)); + var gearboxData = MockSimulationDataFactory.CreateGearboxDataFromFile(GearboxDataFile, EngineDataFile, false); + var gearbox = new ATGearbox(vehicleContainer, gearboxData, new ATShiftStrategy(gearboxData, vehicleContainer)); + + vehicleContainer.VehicleSpeed = vehicleSpeed.KMPHtoMeterPerSecond(); + + var tnPort = new MockTnOutPort(); + gearbox.Connect(tnPort); + + // r_dyn = 0.465m, i_axle = 6.2 + var angularVelocity = vehicleSpeed.KMPHtoMeterPerSecond() / 0.465.SI<Meter>() * 6.2; + var response = gearbox.Initialize(torque.SI<NewtonMeter>(), angularVelocity); + + Assert.IsInstanceOf(typeof(ResponseSuccess), response); + Assert.AreEqual(expectedGear, gearbox.Gear); + Assert.AreEqual(vehicleSpeed.IsEqual(0), gearbox.Disengaged); + } + + [Test, + TestCase(GearboxType.ATSerial, TestName = "Drive TorqueConverter - Serial"), + TestCase(GearboxType.ATPowerSplit, TestName = "Drive TorqueConverter - PowerSplit")] + public void TestATGearboxDriveTorqueConverter(GearboxType gbxType) + { + var cycleData = @" 0, 0, 0, 2 + 20, 8, 0, 0 + 200, 0, 0, 2"; + var cycle = SimpleDrivingCycles.CreateCycleData(cycleData); + var run = ATPowerTrain.CreateEngineeringRun(cycle, gbxType, + string.Format("AT_Vehicle_Drive-TC-{0}.vmod", gbxType==GearboxType.ATSerial ? "ser" : "ps")); + + run.Run(); + Assert.IsTrue(run.FinishedWithoutErrors); + } + + [Test, + TestCase(GearboxType.ATSerial, TestName = "ShiftUp TorqueConverter - Serial"), + TestCase(GearboxType.ATPowerSplit, TestName = "ShiftUp TorqueConverter - PowerSplit")] + public void TestATGearboxShiftUp(GearboxType gbxType) + { + var cycleData = @" 0, 0, 0, 2 + 500, 40, 0, 0"; + var cycle = SimpleDrivingCycles.CreateCycleData(cycleData); + var run = ATPowerTrain.CreateEngineeringRun(cycle, gbxType, + string.Format("AT_Vehicle_Drive-TC_shiftup-{0}.vmod", gbxType==GearboxType.ATSerial ? "ser" : "ps")); + + run.Run(); + Assert.IsTrue(run.FinishedWithoutErrors); + } + + [Test, + TestCase(GearboxType.ATSerial, TestName = "ShiftDown TorqueConverter - Serial"), + TestCase(GearboxType.ATPowerSplit, TestName = "ShiftDown TorqueConverter - PowerSplit")] + public void TestATGearboxShiftDown(GearboxType gbxType) + { + var cycleData = @" 0, 70, 0, 0 + 500, 0, 0, 2"; + var cycle = SimpleDrivingCycles.CreateCycleData(cycleData); + var run = ATPowerTrain.CreateEngineeringRun(cycle, gbxType, + string.Format("AT_Vehicle_Drive-TC_shiftdown-{0}.vmod", gbxType==GearboxType.ATSerial ? "ser" : "ps")); + + run.Run(); + Assert.IsTrue(run.FinishedWithoutErrors); + } + + + [Test, + TestCase("Urban", GearboxType.ATSerial), + TestCase("Suburban", GearboxType.ATSerial), + TestCase("Interurban", GearboxType.ATSerial), + TestCase("HeavyUrban", GearboxType.ATSerial), + TestCase("Urban", GearboxType.ATPowerSplit), + TestCase("Suburban", GearboxType.ATPowerSplit), + TestCase("Interurban", GearboxType.ATPowerSplit), + TestCase("HeavyUrban", GearboxType.ATPowerSplit) + ] + public void TestATGearboxDriveCycle(string cycleName, GearboxType gbxType) + { + Assert.IsTrue(gbxType.AutomaticTransmission()); + var cycle = SimpleDrivingCycles.ReadDeclarationCycle(cycleName); + var run = ATPowerTrain.CreateEngineeringRun(cycle, gbxType, + string.Format("AT_Vehicle_Drive-TC_{0}-{1}.vmod", cycleName, gbxType==GearboxType.ATSerial ? "ser" : "ps")); + + var sumWriter = + new SummaryDataContainer( + new FileOutputWriter(string.Format("AT_Vehicle_Drive-TC_{0}-{1}", cycleName, gbxType == GearboxType.ATSerial ? "ser" : "ps"))); + ((VehicleContainer)run.GetContainer()).WriteSumData = (writer, mass, loading) => + sumWriter.Write(run.GetContainer().ModalData, cycleName, string.Format("{0}-{1}", 0, 0), + cycleName + Constants.FileExtensions.CycleFile, mass, loading); + run.Run(); + sumWriter.Finish(); + Assert.IsTrue(run.FinishedWithoutErrors); + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/ClutchTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/ClutchTest.cs index 14aeca10e17bdb59a38210142619e759b29936f9..ee0802a6b8afcd21a44b9dd6a759f3d557f3da47 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/ClutchTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/ClutchTest.cs @@ -70,8 +70,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var container = new VehicleContainer(ExecutionMode.Engineering); var engineData = MockSimulationDataFactory.CreateEngineDataFromFile(CoachEngine); var gearbox = new MockGearbox(container); - var idleController = new MockIdleController(); - var clutch = new Clutch(container, engineData, idleController); + var clutch = new Clutch(container, engineData) { IdleController = new MockIdleController() }; var inPort = clutch.InPort(); var outPort = new MockTnOutPort(); @@ -97,8 +96,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var engineData = MockSimulationDataFactory.CreateEngineDataFromFile(CoachEngine); var gearbox = new MockGearbox(container); var engine = new MockEngine(container); - var idleController = new MockIdleController(); - var clutch = new Clutch(container, engineData, idleController); + var clutch = new Clutch(container, engineData) { IdleController = new MockIdleController() }; var inPort = clutch.InPort(); var outPort = new MockTnOutPort(); diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/CombustionEngineTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/CombustionEngineTest.cs index eaf3bf38d361a89e34ef0c8e6fb01925b2f3df69..28ea6c3644e19c2af26f5fe3ede1d1e9834cbbb4 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/CombustionEngineTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/CombustionEngineTest.cs @@ -269,7 +269,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var engineData = MockSimulationDataFactory.CreateEngineDataFromFile(CoachEngine); var engine = new CombustionEngine(container, engineData); - var clutch = new Clutch(container, engineData, engine.IdleController); + var clutch = new Clutch(container, engineData); var d = new MockDriver(container); @@ -282,7 +282,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent gearbox.InPort().Connect(clutch.OutPort()); clutch.InPort().Connect(engine.OutPort()); engine.Connect(aux.Port()); - engine.IdleController.RequestPort = clutch.IdleControlPort; + clutch.IdleController = engine.IdleController; // var expectedResults = VectoCSVFile.Read(TestContext.DataRow["ResultFile"].ToString()); @@ -528,7 +528,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var engineData = MockSimulationDataFactory.CreateEngineDataFromFile(engineFile); engine = new CombustionEngine(container, engineData); - var clutch = new Clutch(container, engineData, engine.IdleController); + var clutch = new Clutch(container, engineData); var d = new MockDriver(container); @@ -543,7 +543,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent engine.Connect(aux.Port()); // has to be done after connecting components! - engine.IdleController.RequestPort = clutch.IdleControlPort; + clutch.IdleController = engine.IdleController; requestPort = gearbox.OutPort(); diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/DistanceBasedDrivingCycleTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/DistanceBasedDrivingCycleTest.cs index 21369b83b464e39fbba34c0a0841a5af29b6aa6b..34505febccb80167fe473c54c217625176a71900 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/DistanceBasedDrivingCycleTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/DistanceBasedDrivingCycleTest.cs @@ -33,6 +33,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.InputData.Reader; using TUGraz.VectoCore.Models.Connector.Ports.Impl; using TUGraz.VectoCore.Models.Simulation.Impl; @@ -129,7 +130,8 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent // request with 1m (18 -> 19m) => response exceeded, drive up to next sample point (at least 5m) response = cycle.OutPort().Request(absTime, 1.SI<Meter>()); Assert.IsInstanceOfType(response, typeof(ResponseDrivingCycleDistanceExceeded)); - Assert.AreEqual(5, ((ResponseDrivingCycleDistanceExceeded)response).MaxDistance.Value()); + Assert.AreEqual(Constants.SimulationSettings.BrakeNextTargetDistance.Value(), + ((ResponseDrivingCycleDistanceExceeded)response).MaxDistance.Value(), 1e-6); // next request with 5m, as suggested => distance exceeded. maxDistance == 2m (next speed change).... response = cycle.OutPort().Request(absTime, ((ResponseDrivingCycleDistanceExceeded)response).MaxDistance); diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/DriverTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/DriverTest.cs index 06ba84cd14024c4588167337121c8c928749b466..11b4389ef1c66a7112dcf36058e14dc16e9834ad 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/DriverTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/DriverTest.cs @@ -75,12 +75,12 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var driver = new Driver(vehicleContainer, driverData, new DefaultDriverStrategy()); var engine = new CombustionEngine(vehicleContainer, engineData); - var clutch = new Clutch(vehicleContainer, engineData, engine.IdleController); + var clutch = new Clutch(vehicleContainer, engineData); dynamic tmp = AddComponent(driver, new Vehicle(vehicleContainer, vehicleData)); tmp = AddComponent(tmp, new Wheels(vehicleContainer, vehicleData.DynamicTyreRadius, vehicleData.WheelsInertia)); tmp = AddComponent(tmp, clutch); AddComponent(tmp, engine); - engine.IdleController.RequestPort = clutch.IdleControlPort; + clutch.IdleController = engine.IdleController; var gbx = new MockGearbox(vehicleContainer) { Gear = 1 }; @@ -131,13 +131,13 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var driver = new Driver(vehicleContainer, driverData, new DefaultDriverStrategy()); var engine = new CombustionEngine(vehicleContainer, engineData); - var clutch = new Clutch(vehicleContainer, engineData, engine.IdleController); + var clutch = new Clutch(vehicleContainer, engineData); dynamic tmp = AddComponent(driver, new Vehicle(vehicleContainer, vehicleData)); tmp = AddComponent(tmp, new Wheels(vehicleContainer, vehicleData.DynamicTyreRadius, vehicleData.WheelsInertia)); tmp = AddComponent(tmp, clutch); AddComponent(tmp, engine); - engine.IdleController.RequestPort = clutch.IdleControlPort; + clutch.IdleController = engine.IdleController; var gbx = new MockGearbox(vehicleContainer); gbx.Gear = 1; @@ -194,8 +194,8 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent dynamic tmp = AddComponent(driver, new Vehicle(vehicleContainer, vehicleData)); tmp = AddComponent(tmp, new Wheels(vehicleContainer, vehicleData.DynamicTyreRadius, vehicleData.WheelsInertia)); var engine = new CombustionEngine(vehicleContainer, engineData); - var clutch = new Clutch(vehicleContainer, engineData, engine.IdleController); - engine.IdleController.RequestPort = clutch.IdleControlPort; + var clutch = new Clutch(vehicleContainer, engineData); + clutch.IdleController = engine.IdleController; tmp = AddComponent(tmp, clutch); AddComponent(tmp, engine); diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxPowertrainTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxPowertrainTest.cs index 27d13fc0f29cf531f3ce1e810ad303053b40c6a2..ff09734f44ba1bcd7413b6936b86134d9b1359fd 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxPowertrainTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxPowertrainTest.cs @@ -67,8 +67,8 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent container.Cycle.Request(absTime, ds); container.CommitSimulationStep(absTime, retVal.SimulationInterval); - Assert.AreEqual(5u, container.Gear); - AssertHelper.AreRelativeEqual(593.202.RPMtoRad(), container.EngineSpeed); + Assert.AreEqual(3u, container.Gear); + AssertHelper.AreRelativeEqual(67.6649, container.EngineSpeed); } [TestMethod] @@ -99,7 +99,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent container.Cycle.Request(absTime, ds); container.CommitSimulationStep(absTime, retVal.SimulationInterval); - AssertHelper.AreRelativeEqual(593.202.RPMtoRad(), container.EngineSpeed); + AssertHelper.AreRelativeEqual(87.3192, container.EngineSpeed); } [TestMethod] diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxTest.cs index 657419790742744a24a75fd9f5a970cbc50b852a..b8ad832394f5554711de0db6215a7bc8b832b3fc 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxTest.cs @@ -68,7 +68,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent public const string IndirectLossMap = @"TestData\Components\Indirect Gear.vtlm"; public const string DirectLossMap = @"TestData\Components\Direct Gear.vtlm"; public const string GearboxShiftPolygonFile = @"TestData\Components\ShiftPolygons.vgbs"; - public const string GearboxFullLoadCurveFile = @"TestData\Components\Gearbox.vfld"; + //public const string GearboxFullLoadCurveFile = @"TestData\Components\Gearbox.vfld"; public const string AxleGearValidRangeDataFile = @"TestData\Components\AxleGearValidRange.vgbx"; public const string AxleGearInvalidRangeDataFile = @"TestData\Components\AxleGearInvalidRange.vgbx"; @@ -83,7 +83,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent Gears = ratios.Select((ratio, i) => Tuple.Create((uint)i, new GearData { - FullLoadCurve = FullLoadCurveReader.ReadFromFile(GearboxFullLoadCurveFile), + MaxTorque = 2300.SI<NewtonMeter>(), LossMap = TransmissionLossMapReader.ReadFromFile(i != 6 ? IndirectLossMap : DirectLossMap, ratio, string.Format("Gear {0}", i)), Ratio = ratio, diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponentData/TorqueConverterDataTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponentData/TorqueConverterDataTest.cs index 4e29db8b1aa55f486f2719e381351babad461b6c..96190a875f4ee2b95a9f8b9e38f2a1a54d9f06f2 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponentData/TorqueConverterDataTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponentData/TorqueConverterDataTest.cs @@ -1,5 +1,9 @@ -using NUnit.Framework; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using NUnit.Framework; using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.InputData.Reader.ComponentData; using TUGraz.VectoCore.Tests.Utils; @@ -9,51 +13,131 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData public class TorqueConverterDataTest { [Test, - TestCase(30, 10, 1230.7, 842.8317), - TestCase(40, 10, 1081.028, 645.9384), - TestCase(50, 10, 981.7928, 528.8284), - TestCase(60, 10, 912.2327, 452.9006), - TestCase(70, 10, 860.6045, 399.6834), - TestCase(70, 30, 1433.893, 1129.279), - TestCase(90, 10, 789.4108, 330.28), - TestCase(90, 30, 1295.913, 912.1714), - TestCase(170, 30, 1055.424, 574.8998), - TestCase(170, 50, 1308.974, 900.0845), - TestCase(190, 30, 1029.455, 539.6072), - TestCase(190, 50, 1269.513, 837.2174), - TestCase(190, 70, 1465.33, 1128.088),] + TestCase(30, 10, 227.8707, 1780.6630), + TestCase(40, 10, 197.9536, 1340.4737), + TestCase(50, 10, 177.6759, 1076.9007), + TestCase(60, 10, 162.8219, 901.5900), + TestCase(70, 10, 151.3747, 776.6864), + TestCase(70, 30, 259.9515, 2306.1578), + TestCase(90, 10, 134.7344, 610.8267), + TestCase(90, 30, 230.4896, 1805.2978), + TestCase(170, 30, 172.2875, 987.4020), + TestCase(170, 50, 220.2397, 1626.0613), + TestCase(190, 30, 164.3260, 892.7507), + TestCase(190, 50, 209.6016, 1465.6611), + TestCase(190, 70, 246.4829, 2036.7399), + TestCase(530.517, 1.930, 59.1449, 36.5684), + ] public void TestTorqueConverterOperatingPoint(double nOut, double Pout, double nInExpected, double tqInExpected) { var tqLimit = 1600; - Assert.IsTrue(nInExpected < tqLimit); + //Assert.IsTrue(nInExpected < tqLimit); var tqInput = new[] { - "0,3.935741,563.6598 ", - "0.1,3.296827,534.1364", - "0.2,2.701476,504.6129", - "0.3,2.265852,472.1372", - "0.4,1.931875,421.9474", - "0.5,1.554335,354.0435", - "0.6,1.249399,268.4255", - "0.7,1.075149,114.9037", + "0.0,1.80,377.80", + "0.1,1.71,365.21", + "0.2,1.61,352.62", + "0.3,1.52,340.02", + "0.4,1.42,327.43", + "0.5,1.33,314.84", + "0.6,1.23,302.24", + "0.7,1.14,264.46", + "0.8,1.04,226.68", + "0.9,0.95,188.90", + "1.0,0.95,0.00", }; var tqData = TorqueConverterDataReader.ReadFromStream(InputDataHelper.InputDataAsStream("Speed Ratio, Torque Ratio,MP1000", - tqInput)); - - PerSecond inAngularSpeed; - NewtonMeter inTorque; - + tqInput), 1000.RPMtoRad(), tqLimit.RPMtoRad()); var outAngularSpeed = nOut.RPMtoRad(); var outTorque = (Pout * 1000).SI<Watt>() / outAngularSpeed; - tqData.GetInputTorqueAndAngularSpeed(outTorque, outAngularSpeed, out inTorque, out inAngularSpeed); + var result = tqData.FindOperatingPoint(outTorque, outAngularSpeed); - Assert.IsTrue(inAngularSpeed.Value() < 1600.RPMtoRad().Value()); - Assert.AreEqual(nInExpected.RPMtoRad().Value(), inAngularSpeed.Value(), 5); - Assert.AreEqual(tqInExpected, inTorque.Value(), 10); + Assert.AreEqual(outAngularSpeed.Value(), result.OutAngularVelocity.Value(), 1e-3); + Assert.AreEqual(outTorque.Value(), result.OutTorque.Value(), 1e-3); + + Debug.WriteLine("n_in: {0}, tq_in: {1}", result.InAngularVelocity.AsRPM, result.InTorque.Value()); + //Assert.IsTrue(result.InAngularVelocity.Value() < 1600.RPMtoRad().Value()); + Assert.AreEqual(nInExpected, result.InAngularVelocity.Value(), 1e-3); + Assert.AreEqual(tqInExpected, result.InTorque.Value(), 1e-3); } + [Test, + TestCase(898, 463)] + public void TestTorqueConverterOperatingPointForward(double nIn, double tqIn) + { + var tqLimit = 1600; + + var tqInput = new[] { + "0.0, 4.5, 700", + "0.1, 3.5, 640 ", + "0.2, 2.7, 560 ", + "0.3, 2.2, 460 ", + "0.4, 1.6, 350 ", + "0.5, 1.2, 250 ", + "0.6, 0.9, 160 ", + "0.74, 0.9, 1", + }; + + var tqData = + TorqueConverterDataReader.ReadFromStream(InputDataHelper.InputDataAsStream("Speed Ratio, Torque Ratio,MP1000", + tqInput), 1000.RPMtoRad(), tqLimit.RPMtoRad()); + + + var operatingPoint = tqData.GetOutTorqueAndSpeed(tqIn.SI<NewtonMeter>(), nIn.RPMtoRad(), null); + + Assert.AreEqual(operatingPoint.InTorque.Value(), tqIn, 1e-6); + Assert.AreEqual(operatingPoint.InAngularVelocity.Value(), nIn.RPMtoRad().Value(), 1e-6); + + + var reverseOP = tqData.FindOperatingPoint(operatingPoint.OutTorque, operatingPoint.OutAngularVelocity); + + Assert.AreEqual(operatingPoint.InTorque.Value(), reverseOP.InTorque.Value(), 1e-6); + Assert.AreEqual(operatingPoint.OutTorque.Value(), reverseOP.OutTorque.Value(), 1e-6); + Assert.AreEqual(operatingPoint.InAngularVelocity.Value(), reverseOP.InAngularVelocity.Value(), 1e-6); + Assert.AreEqual(operatingPoint.OutAngularVelocity.Value(), reverseOP.OutAngularVelocity.Value(), 1e-6); + } + + [Test] + public void TestTorqueConverterComparisonV2() + { + var tqLimit = 1600; + + var tqInput = new[] { + "0.0,1.80,377.80", + "0.1,1.71,365.21", + "0.2,1.61,352.62", + "0.3,1.52,340.02", + "0.4,1.42,327.43", + "0.5,1.33,314.84", + "0.6,1.23,302.24", + "0.7,1.14,264.46", + "0.8,1.04,226.68", + "0.9,0.95,188.90", + "1.0,0.95,0.00", + }; + var testData = new List<Tuple<double, double>>() { + Tuple.Create(139.4087374, 72.74847642), + Tuple.Create(2275.286998, 453.9413043), + Tuple.Create(1507.256216, 1012.44118), + Tuple.Create(26.58522419, 29.25312925), + Tuple.Create(1752.83589, 328.6386397), + }; + var tqData = + TorqueConverterDataReader.ReadFromStream(InputDataHelper.InputDataAsStream("Speed Ratio, Torque Ratio,MP1000", + tqInput), 1000.RPMtoRad(), tqLimit.RPMtoRad()); + + foreach (var entry in testData) { + var torqueTCOut = entry.Item1.SI<NewtonMeter>(); + var angularSpeedOut = entry.Item2.RPMtoRad(); + var result = tqData.FindOperatingPoint(torqueTCOut, angularSpeedOut); + Debug.WriteLine("n_out: {0}, tq_out: {1}, n_in: {2}, Tq_in: {3}", angularSpeedOut.Value() / Constants.RPMToRad, + torqueTCOut.Value(), result.InAngularVelocity.Value() / Constants.RPMToRad, result.InTorque.Value()); + } + } + + [Test, TestCase(10, 110), TestCase(20, 130), @@ -88,17 +172,13 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData var tqData = TorqueConverterDataReader.ReadFromStream(InputDataHelper.InputDataAsStream("Speed Ratio, Torque Ratio,MP1000", - tqInput)); - - PerSecond inAngularSpeed; - NewtonMeter inTorque; - + tqInput), 1000.RPMtoRad(), tqLimit); var outAngularSpeed = nOut.RPMtoRad(); var outTorque = (Pout * 1000).SI<Watt>() / outAngularSpeed; - tqData.GetInputTorqueAndAngularSpeed(outTorque, outAngularSpeed, out inTorque, out inAngularSpeed); + var result = tqData.FindOperatingPoint(outTorque, outAngularSpeed); - Assert.IsTrue(inAngularSpeed.Value() > tqLimit.Value()); + Assert.IsTrue(result.InAngularVelocity.Value() > tqLimit.Value()); } } } \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponentData/ValidationTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponentData/ValidationTest.cs index f1513ef86e9744d8f1fb45c6a489e7dbadb77b75..acef3487d4afd8ac6a2e2f40948c267771476796 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponentData/ValidationTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponentData/ValidationTest.cs @@ -125,7 +125,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData }; var dao = new EngineeringDataAdapter(); - var engineData = dao.CreateEngineData(data); + var engineData = dao.CreateEngineData(data, null); var results = engineData.Validate(ExecutionMode.Declaration); Assert.IsFalse(results.Any(), "Validation failed: " + "; ".Join(results.Select(r => r.ErrorMessage))); @@ -163,7 +163,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData }; var dao = new DeclarationDataAdapter(); - var engineData = dao.CreateEngineData(data); + var engineData = dao.CreateEngineData(data, GearboxType.AMT); var results = engineData.Validate(ExecutionMode.Declaration); Assert.IsFalse(results.Any(), "Validation failed: " + "; ".Join(results.Select(r => r.ErrorMessage))); diff --git a/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/AT-Shift.vgbs b/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/AT-Shift.vgbs new file mode 100644 index 0000000000000000000000000000000000000000..91acd23a7a0e04d26fe81b57a3b972cf0975d976 --- /dev/null +++ b/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/AT-Shift.vgbs @@ -0,0 +1,4 @@ +M_shift in Nm,n_down in rpm,n_up in rpm +-200,600,800 +0,600,800 +3000,600,800 diff --git a/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/Engine.veng b/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/Engine.veng new file mode 100644 index 0000000000000000000000000000000000000000..87cae4ef3a6a803d0f4577b1a86c42f981ce7094 --- /dev/null +++ b/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/Engine.veng @@ -0,0 +1,20 @@ +{ + "Header": { + "CreatedBy": "Raphael Luz IVT TU-Graz (14fea510-e457-4bf6-860f-a9514dc327f1)", + "Date": "25.06.2015 11:23:46", + "AppVersion": "2.2 beta", + "FileVersion": 3 + }, + "Body": { + "SavedInDeclMode": false, + "ModelName": "Demo Engine", + "Displacement": 7700.0, + "IdlingSpeed": 600.0, + "Inertia": 3.8, + "FullLoadCurve": "FullLoad.vfld", + "FuelMap": "FCMap.vmap", + "WHTC-Urban": 0.0, + "WHTC-Rural": 0.0, + "WHTC-Motorway": 0.0 + } +} \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/FCMap.vmap b/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/FCMap.vmap new file mode 100644 index 0000000000000000000000000000000000000000..48be004d6800456f2f22cdfc4972f2204845f66f --- /dev/null +++ b/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/FCMap.vmap @@ -0,0 +1,212 @@ +n in rpm,M in Nm,FC in g/h, +600,-45,0, +600,0,767, +600,100,1759, +600,200,2890, +600,300,4185, +600,400,5404, +600,500,6535, +600,600,7578, +800,-55,0, +800,0,951, +800,100,2346, +800,200,3653, +800,300,5328, +800,400,6903, +800,500,8503, +800,600,10003, +800,700,11641, +800,836,13867, +1000,-63,0, +1000,0,1006, +1000,100,2932, +1000,200,4503, +1000,300,6472, +1000,400,8503, +1000,500,10472, +1000,600,12504, +1000,700,14514, +1000,800,16546, +1000,900,18567, +1000,1000,20577, +1000,1070,21962, +1100,-69,0, +1100,0,1235, +1200,-75,0, +1200,0,1467, +1200,100,3063, +1200,200,5359, +1200,300,7701, +1200,400,10082, +1200,500,12504, +1200,600,14902, +1200,700,17182, +1200,800,19569, +1200,900,21989, +1200,1000,24411, +1200,1100,26819, +1200,1200,29601, +1300,-81,0, +1300,0,1684, +1300,100,3302, +1300,200,5828, +1300,300,8367, +1300,400,10926, +1300,500,13533, +1300,600,16046, +1300,700,18591, +1300,800,21172, +1300,900,23733, +1300,1000,26321, +1300,1100,28756, +1300,1200,31288, +1400,-88,0, +1400,0,1943, +1400,100,3660, +1400,200,6304, +1400,300,9031, +1400,400,11783, +1400,500,14466, +1400,600,17180, +1400,700,20015, +1400,800,22828, +1400,900,25498, +1400,1000,28127, +1400,1100,30815, +1400,1200,33609, +1500,-93,0, +1500,0,2167, +1500,100,3963, +1500,200,6793, +1500,300,9721, +1500,400,12670, +1500,500,15534, +1500,600,18413, +1500,700,21467, +1500,800,24495, +1500,900,27363, +1500,1000,30056, +1500,1100,33082, +1500,1200,36100, +1600,-98,0, +1600,0,2391, +1600,100,4272, +1600,200,7257, +1600,300,10398, +1600,400,13535, +1600,500,16711, +1600,600,19835, +1600,700,22965, +1600,800,26115, +1600,900,29164, +1600,1000,32057, +1600,1100,35231, +1600,1200,38423, +1700,-101,0, +1700,0,2641, +1700,100,4578, +1700,200,7768, +1700,300,11114, +1700,400,14439, +1700,500,17759, +1700,600,21069, +1700,700,24380, +1700,800,27739, +1700,900,31000, +1700,1000,34205, +1700,1100,37738, +1700,1165,40006, +1800,-104,0, +1800,0,2890, +1800,100,4965, +1800,200,8233, +1800,300,11783, +1800,400,15307, +1800,500,18849, +1800,600,22267, +1800,700,25749, +1800,800,29389, +1800,900,32951, +1800,1000,36568, +1800,1124,41263, +1900,-108,0, +1900,0,3192, +1900,100,5416, +1900,200,8777, +1900,300,12531, +1900,400,16204, +1900,500,19993, +1900,600,23620, +1900,700,27255, +1900,800,31168, +1900,900,35024, +1900,1000,38907, +1900,1080,41993, +2000,-112,0, +2000,0,3496, +2000,100,5853, +2000,200,9345, +2000,300,13315, +2000,400,17188, +2000,500,21137, +2000,600,25058, +2000,700,28927, +2000,800,33026, +2000,900,37178, +2000,1038,42689, +2100,-119,0, +2100,0,3873, +2100,100,6296, +2100,200,9929, +2100,300,14095, +2100,400,18157, +2100,500,22233, +2100,600,26479, +2100,700,30774, +2100,800,35001, +2100,900,39377, +2100,997,43557, +2200,-126,0, +2200,0,4247, +2200,100,6689, +2200,200,10535, +2200,300,14855, +2200,400,19151, +2200,500,23395, +2200,600,27834, +2200,700,32507, +2200,800,37130, +2200,900,41619, +2200,954,44014, +2300,-131,0, +2300,0,4523, +2300,100,7178, +2300,200,11221, +2300,300,15658, +2300,400,20237, +2300,500,24761, +2300,600,29476, +2300,700,34611, +2300,800,39599, +2300,898,44083, +2400,-136,0, +2400,0,4945, +2400,100,7525, +2400,200,11830, +2400,300,16443, +2400,400,21307, +2400,500,26324, +2400,600,31334, +2400,700,36714, +2400,815,42842, +2500,-141,0, +2500,0,5338, +2500,100,7731, +2500,200,12385, +2500,300,17231, +2500,400,22333, +2500,500,27940, +2500,600,33195, +2500,711,39440, +2600,-149,0, +2600,0,5700, diff --git a/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/FullLoad.vfld b/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/FullLoad.vfld new file mode 100644 index 0000000000000000000000000000000000000000..e45108378b88404ecc399fcefcd77a621a3422d2 --- /dev/null +++ b/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/FullLoad.vfld @@ -0,0 +1,14 @@ +n in rpm,M_FL in Nm,M_frict in Nm,PT1 in s +575,570,-12,0.21 +800,834,-16,0.47 +1000,1068,-24,0.58 +1200,1198,-33,0.53 +1400,1198,-44,0.46 +1600,1198,-56,0.35 +1800,1122,-67,0.20 +2000,1036,-82,0.11 +2100,995,-89,0.11 +2200,952,-97,0.11 +2400,813,-119,0.11 +2500,709,-134,0.11 +2600,0,-148,0.11 diff --git a/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/Gearbox.vgbx b/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/Gearbox.vgbx new file mode 100644 index 0000000000000000000000000000000000000000..840f6b81ca177624f28548445fa0ca87d78fac9c --- /dev/null +++ b/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/Gearbox.vgbx @@ -0,0 +1,62 @@ +{ + "Header": { + "CreatedBy": "Raphael Luz IVT TU-Graz (14fea510-e457-4bf6-860f-a9514dc327f1)", + "Date": "25.06.2015 11:23:52", + "AppVersion": "2.2 beta", + "FileVersion": 5 + }, + "Body": { + "SavedInDeclMode": false, + "ModelName": "Gearbox", + "Inertia": 0.0, + "TracInt": 0.0, + "Gears": [ + { + "Ratio": 6.2, + "Efficiency": "0.95" + }, + { + "Ratio": 3.0, + "Efficiency": "0.96", + "TCactive": true, + "ShiftPolygon": "AT-Shift.vgbs", + "FullLoadCurve": "<NOFILE>" + }, + { + "Ratio": 3.0, + "Efficiency": "0.96", + "TCactive": false, + "ShiftPolygon": "AT-Shift.vgbs", + "FullLoadCurve": "<NOFILE>" + }, + { + "Ratio": 1.0, + "Efficiency": "0.98", + "TCactive": false, + "ShiftPolygon": "AT-Shift.vgbs", + "FullLoadCurve": "<NOFILE>" + }, + { + "Ratio": 0.8, + "Efficiency": "0.96", + "TCactive": false, + "ShiftPolygon": "AT-Shift.vgbs", + "FullLoadCurve": "<NOFILE>" + } + ], + "TqReserve": 5.0, + "SkipGears": false, + "ShiftTime": 1, + "EaryShiftUp": false, + "StartTqReserve": 40.0, + "StartSpeed": 4.0, + "StartAcc": 0.8, + "GearboxType": "AT", + "TorqueConverter": { + "Enabled": true, + "File": "W410_6_TP2_575_mue232.vtcc", + "RefRPM": 1000.0, + "Inertia": 0.5 + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/GearboxPowerSplit.vgbx b/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/GearboxPowerSplit.vgbx new file mode 100644 index 0000000000000000000000000000000000000000..c9f9715f9027e5bf754bbf7a9862c4c389dc6386 --- /dev/null +++ b/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/GearboxPowerSplit.vgbx @@ -0,0 +1,55 @@ +{ + "Header": { + "CreatedBy": " ()", + "Date": "03.08.2016 14:21:23", + "AppVersion": "2.2", + "FileVersion": 6 + }, + "Body": { + "SavedInDeclMode": false, + "ModelName": "AT Serial", + "Inertia": 0.0, + "TracInt": 0.0, + "Gears": [ + { + "Ratio": 5.8, + "Efficiency": "0.98" + }, + { + "Ratio": 1.35, + "Efficiency": "0.98", + "ShiftPolygon": "<NOFILE>", + "FullLoadCurve": "<NOFILE>" + }, + { + "Ratio": 1.0, + "Efficiency": "0.98", + "ShiftPolygon": "<NOFILE>", + "FullLoadCurve": "<NOFILE>" + }, + { + "Ratio": 0.73, + "Efficiency": "0.98", + "ShiftPolygon": "<NOFILE>", + "FullLoadCurve": "<NOFILE>" + }, + ], + "TqReserve": 0.0, + "SkipGears": false, + "ShiftTime": 0, + "EaryShiftUp": false, + "StartTqReserve": 0.0, + "StartSpeed": 0.0, + "StartAcc": 0.0, + "GearboxType": "ATPowerSplit", + "TorqueConverter": { + "Enabled": true, + "File": "TorqueConverterPowerSplit.vtcc", + "RefRPM": 1000.0, + "Inertia": 0.0 + }, + "DownshiftAferUpshiftDelay": 0.0, + "UpshiftAfterDownshiftDelay": 0.0, + "UpshiftMinAcceleration": 0.0 + } +} \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/GearboxSerial.vgbx b/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/GearboxSerial.vgbx new file mode 100644 index 0000000000000000000000000000000000000000..b42e6c26b583f4eec138759dc1efa347b63e1e8d --- /dev/null +++ b/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/GearboxSerial.vgbx @@ -0,0 +1,73 @@ +{ + "Header": { + "CreatedBy": " ()", + "Date": "03.08.2016 14:16:58", + "AppVersion": "2.2", + "FileVersion": 6 + }, + "Body": { + "SavedInDeclMode": false, + "ModelName": "AT Serial", + "Inertia": 0.0, + "TracInt": 0.0, + "Gears": [ + { + "Ratio": 6.2, + "Efficiency": "0.98" + }, + { + "Ratio": 3.4, + "Efficiency": "0.98", + "ShiftPolygon": "<NOFILE>", + "FullLoadCurve": "<NOFILE>" + }, + { + "Ratio": 1.9, + "Efficiency": "0.98", + "ShiftPolygon": "<NOFILE>", + "FullLoadCurve": "<NOFILE>" + }, + { + "Ratio": 1.42, + "Efficiency": "0.98", + "ShiftPolygon": "<NOFILE>", + "FullLoadCurve": "<NOFILE>" + }, + { + "Ratio": 1.0, + "Efficiency": "0.98", + "ShiftPolygon": "<NOFILE>", + "FullLoadCurve": "<NOFILE>" + }, + { + "Ratio": 0.7, + "Efficiency": "0.98", + "ShiftPolygon": "<NOFILE>", + "FullLoadCurve": "<NOFILE>" + }, + { + "Ratio": 0.62, + "Efficiency": "0.98", + "ShiftPolygon": "<NOFILE>", + "FullLoadCurve": "<NOFILE>" + } + ], + "TqReserve": 0.0, + "SkipGears": false, + "ShiftTime": 0, + "EaryShiftUp": false, + "StartTqReserve": 0.0, + "StartSpeed": 0.0, + "StartAcc": 0.0, + "GearboxType": "ATSerial", + "TorqueConverter": { + "Enabled": true, + "File": "TorqueConverter.vtcc", + "RefRPM": 1000.0, + "Inertia": 0.0 + }, + "DownshiftAferUpshiftDelay": 0.0, + "UpshiftAfterDownshiftDelay": 0.0, + "UpshiftMinAcceleration": 0.0 + } +} \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/GearboxSerialDualTC.vgbx b/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/GearboxSerialDualTC.vgbx new file mode 100644 index 0000000000000000000000000000000000000000..bc75d4a29bb2fc061fb91354db454a26a127bc4a --- /dev/null +++ b/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/GearboxSerialDualTC.vgbx @@ -0,0 +1,67 @@ +{ + "Header": { + "CreatedBy": " ()", + "Date": "03.08.2016 14:22:48", + "AppVersion": "2.2", + "FileVersion": 6 + }, + "Body": { + "SavedInDeclMode": false, + "ModelName": "AT Serial", + "Inertia": 0.0, + "TracInt": 0.0, + "Gears": [ + { + "Ratio": 2.1, + "Efficiency": "0.98" + }, + { + "Ratio": 4.35, + "Efficiency": "0.98", + "ShiftPolygon": "<NOFILE>", + "FullLoadCurve": "<NOFILE>" + }, + { + "Ratio": 2.4, + "Efficiency": "0.98", + "ShiftPolygon": "<NOFILE>", + "FullLoadCurve": "<NOFILE>" + }, + { + "Ratio": 1.8, + "Efficiency": "0.98", + "ShiftPolygon": "<NOFILE>", + "FullLoadCurve": "<NOFILE>" + }, + { + "Ratio": 1.3, + "Efficiency": "0.98", + "ShiftPolygon": "<NOFILE>", + "FullLoadCurve": "<NOFILE>" + }, + { + "Ratio": 1.0, + "Efficiency": "0.98", + "ShiftPolygon": "<NOFILE>", + "FullLoadCurve": "<NOFILE>" + } + ], + "TqReserve": 0.0, + "SkipGears": false, + "ShiftTime": 0, + "EaryShiftUp": false, + "StartTqReserve": 0.0, + "StartSpeed": 0.0, + "StartAcc": 0.0, + "GearboxType": "ATSerial", + "TorqueConverter": { + "Enabled": true, + "File": "TorqueConverter.vtcc", + "RefRPM": 1000.0, + "Inertia": 0.0 + }, + "DownshiftAferUpshiftDelay": 0.0, + "UpshiftAfterDownshiftDelay": 0.0, + "UpshiftMinAcceleration": 0.0 + } +} \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/Gearbox_v5.vgbx b/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/Gearbox_v5.vgbx new file mode 100644 index 0000000000000000000000000000000000000000..acac788219306ad4928220866b6f7878227a5a16 --- /dev/null +++ b/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/Gearbox_v5.vgbx @@ -0,0 +1,62 @@ +{ + "Header": { + "CreatedBy": "Raphael Luz IVT TU-Graz (14fea510-e457-4bf6-860f-a9514dc327f1)", + "Date": "25.06.2015 11:23:52", + "AppVersion": "2.2 beta", + "FileVersion": 5 + }, + "Body": { + "SavedInDeclMode": false, + "ModelName": "Gearbox", + "Inertia": 0.0, + "TracInt": 0.0, + "Gears": [ + { + "Ratio": 6.2, + "Efficiency": "0.95" + }, + { + "Ratio": 3.0, + "Efficiency": "0.96", + "TCactive": true, + "ShiftPolygon": "AT-Shift.vgbs", + "FullLoadCurve": "<NOFILE>" + }, + { + "Ratio": 3.0, + "Efficiency": "0.96", + "TCactive": false, + "ShiftPolygon": "AT-Shift.vgbs", + "FullLoadCurve": "<NOFILE>" + }, + { + "Ratio": 1.0, + "Efficiency": "0.98", + "TCactive": false, + "ShiftPolygon": "AT-Shift.vgbs", + "FullLoadCurve": "<NOFILE>" + }, + { + "Ratio": 0.8, + "Efficiency": "0.96", + "TCactive": false, + "ShiftPolygon": "AT-Shift.vgbs", + "FullLoadCurve": "<NOFILE>" + } + ], + "TqReserve": 5.0, + "SkipGears": false, + "ShiftTime": 1, + "EaryShiftUp": false, + "StartTqReserve": 40.0, + "StartSpeed": 4.0, + "StartAcc": 0.8, + "GearboxType": "AT", + "TorqueConverter": { + "Enabled": true, + "File": "TorqueConverter.vtcc", + "RefRPM": 1000.0, + "Inertia": 0.5 + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/TorqueConverter.vtcc b/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/TorqueConverter.vtcc new file mode 100644 index 0000000000000000000000000000000000000000..669c44f98ee5f46bb31b3f811c157ddf80883e2e --- /dev/null +++ b/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/TorqueConverter.vtcc @@ -0,0 +1,21 @@ +Speed Ratio, Torque Ratio,MP1000 +0.0,1.80,377.80 +0.1,1.71,365.21 +0.2,1.61,352.62 +0.3,1.52,340.02 +0.4,1.42,327.43 +0.5,1.33,314.84 +0.6,1.23,302.24 +0.7,1.14,264.46 +0.8,1.04,226.68 +0.9,0.95,188.90 +1.0,0.95,0.00 +1.100,1.000,-40.34 +1.222,1.000,-80.34 +1.375,1.000,-136.11 +1.571,1.000,-216.52 +1.833,1.000,-335.19 +2.200,1.000,-528.77 +2.750,1.000,-883.40 +4.400,1.000,-2462.17 +11.000,1.000,-16540.98 \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/TorqueConverterPowerSplit.vtcc b/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/TorqueConverterPowerSplit.vtcc new file mode 100644 index 0000000000000000000000000000000000000000..7a208e8924ac99043fa4dfe5444e7dba5b25a33f --- /dev/null +++ b/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/TorqueConverterPowerSplit.vtcc @@ -0,0 +1,18 @@ +Speed Ratio, Torque Ratio,MP1000 +0.0, 4.5, 700 +0.1, 3.5, 640 +0.2, 2.7, 560 +0.3, 2.2, 460 +0.4, 1.6, 350 +0.5, 1.2, 250 +0.6, 0.9, 160 +0.74, 0.9, 1 +0.81,1.000,-40.34 +0.91,1.000,-80.34 +1.02,1.000,-136.11 +1.16,1.000,-216.52 +1.36,1.000,-335.19 +1.63,1.000,-528.77 +2.04,1.000,-883.40 +3.26,1.000,-2462.17 +8.15,1.000,-16540.98 \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/TestData/Integration/DeclarationMode/12t Truck/12t Delivery Truck.vecto b/VectoCore/VectoCoreTest/TestData/Integration/DeclarationMode/12t Truck/12t Delivery Truck.vecto index 92c360e6589c62c96aeca7e9b085484ddb2237d4..98a0b4567ca37e2278cd7c8bc5739bc591beb7de 100644 --- a/VectoCore/VectoCoreTest/TestData/Integration/DeclarationMode/12t Truck/12t Delivery Truck.vecto +++ b/VectoCore/VectoCoreTest/TestData/Integration/DeclarationMode/12t Truck/12t Delivery Truck.vecto @@ -1,9 +1,9 @@ { "Header": { - "CreatedBy": "Raphael Luz IVT TU-Graz (14fea510-e457-4bf6-860f-a9514dc327f1)", - "Date": "24.06.2015 12:03:58", - "AppVersion": "2.2 beta", - "FileVersion": 2 + "CreatedBy": "Michael Krisper, IVT, Graz University of Technology", + "Date": "2016-08-10T14:14:07.6435917Z", + "AppVersion": "2.2", + "FileVersion": 3 }, "Body": { "SavedInDeclMode": true, @@ -15,43 +15,53 @@ "Regional Delivery", "Urban Delivery" ], + "AuxiliaryAssembly": "CLASSIC", + "AuxiliaryVersion": "CLASSIC", + "AdvancedAuxiliaryFilePath": "", "Aux": [ { "ID": "FAN", "Type": "Fan", "Path": "<NOFILE>", - "Technology": "Belt driven or driven via transm. - Discrete step clutch" + "Technology": [ + "Crankshaft mounted - Discrete step clutch" + ] }, { "ID": "STP", "Type": "Steering pump", "Path": "<NOFILE>", - "Technology": "Variable displacement" + "Technology": [ + "Fixed displacement" + ] }, { "ID": "AC", "Type": "HVAC", "Path": "<NOFILE>", - "Technology": "Default" + "Technology": [] }, { "ID": "ES", "Type": "Electric System", "Path": "<NOFILE>", - "Technology": "Custom Technology List", - "TechList": [] + "Technology": [ + "Standard technology" + ] }, { "ID": "PS", "Type": "Pneumatic System", "Path": "<NOFILE>", - "Technology": "Default" + "Technology": [ + "Medium Supply 1-stage" + ] } ], "VACC": "<NOFILE>", "EngineOnlyMode": false, "StartStop": { - "Enabled": false, + "Enabled": true, "MaxSpeed": 5.0, "MinTime": 5.0, "Delay": 5 @@ -59,7 +69,12 @@ "LAC": { "Enabled": true, "Dec": -0.5, - "MinSpeed": 50.0 + "MinSpeed": 50.0, + "PreviewDistanceFactor": 10.0, + "DF_offset": 2.5, + "DF_scaling": 1.5, + "DF_targetSpeedLookup": "", + "Df_velocityDropLookup": "" }, "OverSpeedEcoRoll": { "Mode": "OverSpeed", diff --git a/VectoCore/VectoCoreTest/TestData/Integration/DeclarationMode/12t Truck/12t Delivery Truck_8gear.vecto b/VectoCore/VectoCoreTest/TestData/Integration/DeclarationMode/12t Truck/12t Delivery Truck_8gear.vecto index 12d66a1b5e1f1db9d743b93c2517ddb17a7c2ffe..077d7671cb00ff8472b734e1ba1b3f26cce8a2ea 100644 --- a/VectoCore/VectoCoreTest/TestData/Integration/DeclarationMode/12t Truck/12t Delivery Truck_8gear.vecto +++ b/VectoCore/VectoCoreTest/TestData/Integration/DeclarationMode/12t Truck/12t Delivery Truck_8gear.vecto @@ -3,7 +3,7 @@ "CreatedBy": " ()", "Date": "03.05.2016 17:05:59", "AppVersion": "2.2", - "FileVersion": 2 + "FileVersion": 3 }, "Body": { "SavedInDeclMode": true, @@ -19,36 +19,43 @@ "AuxiliaryVersion": "CLASSIC", "AdvancedAuxiliaryFilePath": "", "Aux": [ - { +{ "ID": "FAN", "Type": "Fan", "Path": "<NOFILE>", - "Technology": "Crankshaft mounted - Discrete step clutch" + "Technology": [ + "Crankshaft mounted - Discrete step clutch" + ] }, { "ID": "STP", "Type": "Steering pump", "Path": "<NOFILE>", - "Technology": "Fixed displacement" + "Technology": [ + "Fixed displacement" + ] }, { "ID": "AC", "Type": "HVAC", "Path": "<NOFILE>", - "Technology": "" + "Technology": [] }, { "ID": "ES", "Type": "Electric System", "Path": "<NOFILE>", - "Technology": "", - "TechList": [] + "Technology": [ + "Standard technology" + ] }, { "ID": "PS", "Type": "Pneumatic System", "Path": "<NOFILE>", - "Technology": "" + "Technology": [ + "Medium Supply 1-stage" + ] } ], "VACC": "<NOFILE>", diff --git a/VectoCore/VectoCoreTest/TestData/Integration/DeclarationMode/12t Truck/Axle.vtlm b/VectoCore/VectoCoreTest/TestData/Integration/DeclarationMode/12t Truck/Axle.vtlm index 43304b2042f5dc8327298a07fb4ae45c4b2786f9..47a86befe8b13daf315be18f09a466b00866224b 100644 --- a/VectoCore/VectoCoreTest/TestData/Integration/DeclarationMode/12t Truck/Axle.vtlm +++ b/VectoCore/VectoCoreTest/TestData/Integration/DeclarationMode/12t Truck/Axle.vtlm @@ -152,3 +152,5 @@ Input Speed [rpm],Input Torque [Nm],Torque Loss [Nm],Eff [-] 3200,4500,107.5 3200,5500,122.5 3200,6500,137.5 +0, -10000, 300 +3200,-10000, 175 \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/TestData/Integration/DeclarationMode/40t Truck/40t_Long_Haul_Truck.vecto b/VectoCore/VectoCoreTest/TestData/Integration/DeclarationMode/40t Truck/40t_Long_Haul_Truck.vecto index 4533c8fd2cdcf3710ede7926bbc2427dbb2d1dc2..8f3b4121026022d6b19b0b56e69d30172b71c1f4 100644 --- a/VectoCore/VectoCoreTest/TestData/Integration/DeclarationMode/40t Truck/40t_Long_Haul_Truck.vecto +++ b/VectoCore/VectoCoreTest/TestData/Integration/DeclarationMode/40t Truck/40t_Long_Haul_Truck.vecto @@ -1,9 +1,9 @@ { "Header": { - "CreatedBy": " ()", - "Date": "10/6/2015 3:19:54 PM", + "CreatedBy": "Michael Krisper, IVT, Graz University of Technology", + "Date": "2016-08-10T15:11:16.3665917Z", "AppVersion": "2.2", - "FileVersion": 2 + "FileVersion": 3 }, "Body": { "SavedInDeclMode": true, @@ -14,37 +14,47 @@ "Long Haul", "Regional Delivery" ], + "AuxiliaryAssembly": "CLASSIC", + "AuxiliaryVersion": "CLASSIC", + "AdvancedAuxiliaryFilePath": "", "Aux": [ { "ID": "FAN", "Type": "Fan", "Path": "<NOFILE>", - "Technology": "Hydraulic driven - Constant displacement pump" + "Technology": [ + "Hydraulic driven - Constant displacement pump" + ] }, { "ID": "STP", "Type": "Steering pump", "Path": "<NOFILE>", - "Technology": "Variable displacement" + "Technology": [ + "Fixed displacement" + ] }, { "ID": "AC", "Type": "HVAC", "Path": "<NOFILE>", - "Technology": "Default" + "Technology": [] }, { "ID": "ES", "Type": "Electric System", "Path": "<NOFILE>", - "Technology": "Custom Technology List", - "TechList": [] + "Technology": [ + "Standard technology" + ] }, { "ID": "PS", "Type": "Pneumatic System", "Path": "<NOFILE>", - "Technology": "Default" + "Technology": [ + "Medium Supply 1-stage" + ] } ], "VACC": "<NOFILE>", @@ -58,7 +68,12 @@ "LAC": { "Enabled": true, "Dec": -0.5, - "MinSpeed": 50.0 + "MinSpeed": 50.0, + "PreviewDistanceFactor": 10.0, + "DF_offset": 2.5, + "DF_scaling": 1.5, + "DF_targetSpeedLookup": "", + "Df_velocityDropLookup": "" }, "OverSpeedEcoRoll": { "Mode": "OverSpeed", diff --git a/VectoCore/VectoCoreTest/TestData/Results/EngineOnlyCycles/AuxWriteModFileSumFile.vmod b/VectoCore/VectoCoreTest/TestData/Results/EngineOnlyCycles/AuxWriteModFileSumFile.vmod index 1f3cc737e4b6571979ea7452d6b3920552ca60a7..ab1cd05e851861fc5591d2d5b63c5cc6a43ea2de 100644 --- a/VectoCore/VectoCoreTest/TestData/Results/EngineOnlyCycles/AuxWriteModFileSumFile.vmod +++ b/VectoCore/VectoCoreTest/TestData/Results/EngineOnlyCycles/AuxWriteModFileSumFile.vmod @@ -1,12 +1,12 @@ time [s],dt [s],dist [m],v_act [km/h],v_targ [km/h],acc [m/s^2],grad [%],Gear [-],n_eng_avg [1/min],T_eng_fcmap [Nm],Tq_full [Nm],Tq_drag [Nm],P_eng_fcmap [kW],P_eng_full [kW],P_eng_drag [kW],P_eng_inertia [kW],P_eng_out [kW],P_clutch_loss [kW],P_clutch_out [kW],P_aux [kW],P_gbx_in [kW],P_gbx_loss [kW],P_gbx_inertia [kW],P_ret_in [kW],P_ret_loss [kW],P_angle_in [kW],P_angle_loss [kW],P_axle_in [kW],P_axle_loss [kW],P_brake_in [kW],P_brake_loss [kW],P_wheel_in [kW],P_wheel_inertia [kW],P_trac [kW],P_slope [kW],P_air [kW],P_roll [kW],P_veh_inertia [kW],P_aux_FAN,P_aux_PS,P_aux_STP,P_aux_ES,P_aux_AC,FC-Map [g/h],FC-AUXc [g/h],FC-WHTCc [g/h],FC-AAUX [g/h],FC-Final [g/h] -0.5000,1.0000,0.0000,,0.0000,0.0000,0.0000,,,,,,,,,,0.0000,,,4.8934,,,,,,,,,,,,,,,,,,,1.0000,1.3400,0.4320,1.7714,0.3500,,,,, -1.5000,1.0000,0.0000,,0.0000,0.0000,0.0000,,,,,,,,,,0.0000,,,4.8934,,,,,,,,,,,,,,,,,,,1.0000,1.3400,0.4320,1.7714,0.3500,,,,, -2.5000,1.0000,0.0000,,0.0000,0.0000,0.0000,,,,,,,,,,0.0000,,,4.8934,,,,,,,,,,,,,,,,,,,1.0000,1.3400,0.4320,1.7714,0.3500,,,,, -3.5000,1.0000,0.0000,,0.0000,0.0000,0.0000,,,,,,,,,,0.0000,,,4.8934,,,,,,,,,,,,,,,,,,,1.0000,1.3400,0.4320,1.7714,0.3500,,,,, -4.5000,1.0000,0.0000,,0.0000,0.0000,0.0000,,,,,,,,,,0.0000,,,4.8934,,,,,,,,,,,,,,,,,,,1.0000,1.3400,0.4320,1.7714,0.3500,,,,, -5.5000,1.0000,0.0000,,0.0000,0.0000,0.0000,,,,,,,,,,0.0000,,,4.8934,,,,,,,,,,,,,,,,,,,1.0000,1.3400,0.4320,1.7714,0.3500,,,,, -6.5000,1.0000,0.0000,,0.0000,0.0000,0.0000,,,,,,,,,,0.0000,,,4.8934,,,,,,,,,,,,,,,,,,,1.0000,1.3400,0.4320,1.7714,0.3500,,,,, -7.5000,1.0000,0.0000,,0.0000,0.0000,0.0000,,,,,,,,,,0.0000,,,4.8934,,,,,,,,,,,,,,,,,,,1.0000,1.3400,0.4320,1.7714,0.3500,,,,, -8.5000,1.0000,0.0000,,0.0000,0.0000,0.0000,,,,,,,,,,0.0000,,,4.8934,,,,,,,,,,,,,,,,,,,1.0000,1.3400,0.4320,1.7714,0.3500,,,,, -9.5000,1.0000,0.0000,,0.0000,0.0000,0.0000,,,,,,,,,,0.0000,,,4.8934,,,,,,,,,,,,,,,,,,,1.0000,1.3400,0.4320,1.7714,0.3500,,,,, -10.5000,1.0000,0.0000,,0.0000,0.0000,0.0000,,,,,,,,,,0.0000,,,4.8934,,,,,,,,,,,,,,,,,,,1.0000,1.3400,0.4320,1.7714,0.3500,,,,, +0.5000,1.0000,0.0000,,0.0000,0.0000,0.0000,,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,,,5.4043,,,,,,,,,,,,,,,,,,,1.2000,1.6000,0.5400,1.7143,0.3500,0.0000,0.0000,0.0000,0.0000,0.0000 +1.5000,1.0000,0.0000,,0.0000,0.0000,0.0000,,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,,,5.4043,,,,,,,,,,,,,,,,,,,1.2000,1.6000,0.5400,1.7143,0.3500,0.0000,0.0000,0.0000,0.0000,0.0000 +2.5000,1.0000,0.0000,,0.0000,0.0000,0.0000,,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,,,5.4043,,,,,,,,,,,,,,,,,,,1.2000,1.6000,0.5400,1.7143,0.3500,0.0000,0.0000,0.0000,0.0000,0.0000 +3.5000,1.0000,0.0000,,0.0000,0.0000,0.0000,,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,,,5.4043,,,,,,,,,,,,,,,,,,,1.2000,1.6000,0.5400,1.7143,0.3500,0.0000,0.0000,0.0000,0.0000,0.0000 +4.5000,1.0000,0.0000,,0.0000,0.0000,0.0000,,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,,,5.4043,,,,,,,,,,,,,,,,,,,1.2000,1.6000,0.5400,1.7143,0.3500,0.0000,0.0000,0.0000,0.0000,0.0000 +5.5000,1.0000,0.0000,,0.0000,0.0000,0.0000,,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,,,5.4043,,,,,,,,,,,,,,,,,,,1.2000,1.6000,0.5400,1.7143,0.3500,0.0000,0.0000,0.0000,0.0000,0.0000 +6.5000,1.0000,0.0000,,0.0000,0.0000,0.0000,,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,,,5.4043,,,,,,,,,,,,,,,,,,,1.2000,1.6000,0.5400,1.7143,0.3500,0.0000,0.0000,0.0000,0.0000,0.0000 +7.5000,1.0000,0.0000,,0.0000,0.0000,0.0000,,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,,,5.4043,,,,,,,,,,,,,,,,,,,1.2000,1.6000,0.5400,1.7143,0.3500,0.0000,0.0000,0.0000,0.0000,0.0000 +8.5000,1.0000,0.0000,,0.0000,0.0000,0.0000,,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,,,5.4043,,,,,,,,,,,,,,,,,,,1.2000,1.6000,0.5400,1.7143,0.3500,0.0000,0.0000,0.0000,0.0000,0.0000 +9.5000,1.0000,0.0000,,0.0000,0.0000,0.0000,,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,,,5.4043,,,,,,,,,,,,,,,,,,,1.2000,1.6000,0.5400,1.7143,0.3500,0.0000,0.0000,0.0000,0.0000,0.0000 +10.5000,1.0000,0.0000,,0.0000,0.0000,0.0000,,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,,,5.4043,,,,,,,,,,,,,,,,,,,1.2000,1.6000,0.5400,1.7143,0.3500,0.0000,0.0000,0.0000,0.0000,0.0000 diff --git a/VectoCore/VectoCoreTest/Utils/MockDriver.cs b/VectoCore/VectoCoreTest/Utils/MockDriver.cs index d0a0d1a76f8dc5a81fbc75b28fbb6467a78d9f9d..7315419a5d7d19092983f24c9fce9fa3961840be 100644 --- a/VectoCore/VectoCoreTest/Utils/MockDriver.cs +++ b/VectoCore/VectoCoreTest/Utils/MockDriver.cs @@ -117,5 +117,6 @@ namespace TUGraz.VectoCore.Tests.Utils public bool VehicleStopped { get; set; } public DrivingBehavior DriverBehavior { get; set; } + public MeterPerSquareSecond DriverAcceleration { get; set; } } } \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/Utils/MockGearbox.cs b/VectoCore/VectoCoreTest/Utils/MockGearbox.cs index 6cbcfb20186bed2c727688a78699aa388d010d4a..5f69f9afdde62bcd0976e6d9db04866a73fedc6d 100644 --- a/VectoCore/VectoCoreTest/Utils/MockGearbox.cs +++ b/VectoCore/VectoCoreTest/Utils/MockGearbox.cs @@ -57,6 +57,7 @@ namespace TUGraz.VectoCore.Tests.Utils return this; } + public GearboxType GearboxType { get; set; } public uint Gear { get; set; } public MeterPerSecond StartSpeed @@ -69,7 +70,7 @@ namespace TUGraz.VectoCore.Tests.Utils get { return 0.6.SI<MeterPerSquareSecond>(); } } - public FullLoadCurve GearFullLoadCurve + public NewtonMeter GearMaxTorque { get { return null; } } @@ -84,21 +85,22 @@ namespace TUGraz.VectoCore.Tests.Utils _outPort = other; } - public IResponse Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity, bool dryRun = false) + public IResponse Request(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, + bool dryRun = false) { if (_outPort != null) { if (Gear > 0) { - return _outPort.Request(absTime, dt, torque, angularVelocity, dryRun); + return _outPort.Request(absTime, dt, outTorque, outAngularVelocity, dryRun); } return _outPort.Request(absTime, dt, 0.SI<NewtonMeter>(), null, dryRun); } throw new NotImplementedException(); } - public IResponse Initialize(NewtonMeter torque, PerSecond angularVelocity) + public IResponse Initialize(NewtonMeter outTorque, PerSecond outAngularVelocity) { if (_outPort != null) { - return _outPort.Initialize(torque, angularVelocity); + return _outPort.Initialize(outTorque, outAngularVelocity); } throw new NotImplementedException(); } diff --git a/VectoCore/VectoCoreTest/Utils/MockIdleController.cs b/VectoCore/VectoCoreTest/Utils/MockIdleController.cs index 0031353c962ce6e46a9f9a736373caef393268f5..a592aa8d80f332233fb4f562cc57cc6bcfa38efe 100644 --- a/VectoCore/VectoCoreTest/Utils/MockIdleController.cs +++ b/VectoCore/VectoCoreTest/Utils/MockIdleController.cs @@ -39,13 +39,13 @@ namespace TUGraz.VectoCore.Tests.Utils { public class MockIdleController : ICombustionEngineIdleController { - public IResponse Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity, bool dryRun = false) + public IResponse Request(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, bool dryRun = false) { //throw new System.NotImplementedException(); return new ResponseSuccess(); } - public IResponse Initialize(NewtonMeter torque, PerSecond angularVelocity) + public IResponse Initialize(NewtonMeter outTorque, PerSecond outAngularVelocity) { //throw new System.NotImplementedException(); return new ResponseSuccess(); diff --git a/VectoCore/VectoCoreTest/Utils/MockPorts.cs b/VectoCore/VectoCoreTest/Utils/MockPorts.cs index 94c0e79f1f066a178b74cb7fc9cd220ea2114a7b..2ab63efb9c8f1bfd49ba6304a72d3b9aa72ec5b1 100644 --- a/VectoCore/VectoCoreTest/Utils/MockPorts.cs +++ b/VectoCore/VectoCoreTest/Utils/MockPorts.cs @@ -47,39 +47,42 @@ namespace TUGraz.VectoCore.Tests.Utils public NewtonMeter Torque; public PerSecond AngularVelocity; - public IResponse Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity, bool dryRun = false) + public IResponse Request(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, + bool dryRun = false) { AbsTime = absTime; Dt = dt; - Torque = torque; - AngularVelocity = angularVelocity; - Log.Debug("Request: absTime: {0}, dt: {1}, torque: {2}, angularVelocity: {3}", absTime, dt, torque, angularVelocity); + Torque = outTorque; + AngularVelocity = outAngularVelocity; + Log.Debug("Request: absTime: {0}, dt: {1}, torque: {2}, angularVelocity: {3}", absTime, dt, outTorque, + outAngularVelocity); if (dryRun) { return new ResponseDryRun { Source = this, - GearboxPowerRequest = torque * angularVelocity, - EnginePowerRequest = torque * angularVelocity, - ClutchPowerRequest = torque * angularVelocity, - DeltaFullLoad = (torque - 2300.SI<NewtonMeter>()) * angularVelocity, - DeltaDragLoad = (torque - -100.SI<NewtonMeter>()) * angularVelocity + GearboxPowerRequest = outTorque * outAngularVelocity, + EnginePowerRequest = outTorque * outAngularVelocity, + ClutchPowerRequest = outTorque * outAngularVelocity, + DeltaFullLoad = (outTorque - 2300.SI<NewtonMeter>()) * outAngularVelocity, + DeltaDragLoad = (outTorque - -100.SI<NewtonMeter>()) * outAngularVelocity }; } return new ResponseSuccess { Source = this, - GearboxPowerRequest = torque * angularVelocity, - EnginePowerRequest = torque * angularVelocity, - ClutchPowerRequest = torque * angularVelocity, + GearboxPowerRequest = outTorque * outAngularVelocity, + EnginePowerRequest = outTorque * outAngularVelocity, + ClutchPowerRequest = outTorque * outAngularVelocity, }; } - public IResponse Initialize(NewtonMeter torque, PerSecond angularVelocity) + public IResponse Initialize(NewtonMeter outTorque, PerSecond outAngularVelocity) { return new ResponseSuccess { Source = this, - EnginePowerRequest = torque * angularVelocity, - ClutchPowerRequest = torque * angularVelocity, + EnginePowerRequest = outTorque * (outAngularVelocity ?? 0.SI<PerSecond>()), + ClutchPowerRequest = outTorque * (outAngularVelocity ?? 0.SI<PerSecond>()), + EngineSpeed = outAngularVelocity, }; } diff --git a/VectoCore/VectoCoreTest/Utils/MockSimulationDataFactory.cs b/VectoCore/VectoCoreTest/Utils/MockSimulationDataFactory.cs index 422b40d4e1d867ea0c146466904dd2dfd1fa1254..71717c378cab24e7e8bb98c2e527283292bddd5e 100644 --- a/VectoCore/VectoCoreTest/Utils/MockSimulationDataFactory.cs +++ b/VectoCore/VectoCoreTest/Utils/MockSimulationDataFactory.cs @@ -53,14 +53,14 @@ namespace TUGraz.VectoCore.Tests.Utils var engineInput = JSONInputDataFactory.ReadEngine(engineFile); if (declarationMode) { var dao = new DeclarationDataAdapter(); - var engineData = dao.CreateEngineData(engineInput); + var engineData = dao.CreateEngineData(engineInput, gearboxInput.Type); return dao.CreateGearboxData(gearboxInput, engineData, ((IAxleGearInputData)gearboxInput).Ratio, 0.5.SI<Meter>(), false); } else { var dao = new EngineeringDataAdapter(); - var engineData = dao.CreateEngineData(engineInput); + var engineData = dao.CreateEngineData(engineInput, gearboxInput); return dao.CreateGearboxData(gearboxInput, engineData, ((IAxleGearInputData)gearboxInput).Ratio, 0.5.SI<Meter>(), - false); + true); } } @@ -75,7 +75,7 @@ namespace TUGraz.VectoCore.Tests.Utils { var dao = new EngineeringDataAdapter(); var engineInput = JSONInputDataFactory.ReadEngine(engineFile); - return dao.CreateEngineData(engineInput); + return dao.CreateEngineData(engineInput, null); } public static VehicleData CreateVehicleDataFromFile(string vehicleDataFile) diff --git a/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs b/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs index 42d15b53f9da434d066f30cfae469fc0f63cbd66..f980c9ab65c980ebcac4daa7d6181b75c93e7fed 100644 --- a/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs +++ b/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs @@ -53,10 +53,11 @@ namespace TUGraz.VectoCore.Tests.Utils public IEngineInfo Engine { get; set; } + public GearboxType GearboxType { get; set; } public uint Gear { get; set; } public MeterPerSecond StartSpeed { get; set; } public MeterPerSquareSecond StartAcceleration { get; set; } - public FullLoadCurve GearFullLoadCurve { get; set; } + public NewtonMeter GearMaxTorque { get; set; } public Watt GearboxLoss() { @@ -137,7 +138,10 @@ namespace TUGraz.VectoCore.Tests.Utils } public bool VehicleStopped { get; set; } + public DrivingBehavior DriverBehavior { get; set; } + public MeterPerSquareSecond DriverAcceleration { get; set; } + public CycleData CycleData { get; set; } public DrivingCycleData.DrivingCycleEntry CycleLookAhead(Meter distance) diff --git a/VectoCore/VectoCoreTest/Utils/Port.cs b/VectoCore/VectoCoreTest/Utils/Port.cs deleted file mode 100644 index c4253beaa5a2aecf63049e1fcf6503e7da43a29d..0000000000000000000000000000000000000000 --- a/VectoCore/VectoCoreTest/Utils/Port.cs +++ /dev/null @@ -1,75 +0,0 @@ -/* -* This file is part of VECTO. -* -* Copyright © 2012-2016 European Union -* -* Developed by Graz University of Technology, -* Institute of Internal Combustion Engines and Thermodynamics, -* Institute of Technical Informatics -* -* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved -* by the European Commission - subsequent versions of the EUPL (the "Licence"); -* You may not use VECTO except in compliance with the Licence. -* You may obtain a copy of the Licence at: -* -* https://joinup.ec.europa.eu/community/eupl/og_page/eupl -* -* Unless required by applicable law or agreed to in writing, VECTO -* distributed under the Licence is distributed on an "AS IS" basis, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the Licence for the specific language governing permissions and -* limitations under the Licence. -* -* Authors: -* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology -* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology -* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology -* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology -* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology -* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology -*/ - -using TUGraz.VectoCore.Models.Connector.Ports; -using TUGraz.VectoCore.Models.SimulationComponent; - -namespace TUGraz.VectoCore.Tests.Utils -{ - public static class Port - { - public static IDriver AddComponent(IDrivingCycle prev, IDriver next) - { - prev.InPort().Connect(next.OutPort()); - return next; - } - - public static IVehicle AddComponent(IDriver prev, IVehicle next) - { - prev.InPort().Connect(next.OutPort()); - return next; - } - - public static IWheels AddComponent(IFvInProvider prev, IWheels next) - { - prev.InPort().Connect(next.OutPort()); - return next; - } - - - public static ITnOutProvider AddComponent(IWheels prev, ITnOutProvider next) - { - prev.InPort().Connect(next.OutPort()); - return next; - } - - public static IPowerTrainComponent AddComponent(IPowerTrainComponent prev, IPowerTrainComponent next) - { - prev.InPort().Connect(next.OutPort()); - return next; - } - - public static void AddComponent(IPowerTrainComponent prev, ITnOutProvider next) - { - prev.InPort().Connect(next.OutPort()); - } - } -} \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/VectoCoreTest.csproj b/VectoCore/VectoCoreTest/VectoCoreTest.csproj index 3da97b99b063edaa41f14ec071890b92cc7110d6..47bfbd6eae81af42ee61751b002c5f580494ce74 100644 --- a/VectoCore/VectoCoreTest/VectoCoreTest.csproj +++ b/VectoCore/VectoCoreTest/VectoCoreTest.csproj @@ -81,6 +81,7 @@ <Compile Include="FileIO\JsonTest.cs" /> <Compile Include="FileIO\SimulationDataReaderTest.cs" /> <Compile Include="GraphProgram.cs" /> + <Compile Include="Integration\ATPowerTrain.cs" /> <Compile Include="Integration\BusAuxiliaries\AuxDemandTest.cs" /> <Compile Include="Integration\BusAuxiliaries\BusAdapterTest.cs" /> <Compile Include="Integration\BusAuxiliaries\AAuxTests.cs" /> @@ -95,6 +96,7 @@ <Compile Include="Models\Declaration\ShiftPolygonTest.cs" /> <Compile Include="Models\SimulationComponentData\TorqueConverterDataTest.cs" /> <Compile Include="Models\SimulationComponentData\ValidationTest.cs" /> + <Compile Include="Models\SimulationComponent\ATGearboxTest.cs" /> <Compile Include="Models\Simulation\FactoryTest.cs" /> <Compile Include="Models\Simulation\PTOIdleLossTest.cs" /> <Compile Include="Models\Simulation\LossMapRangeValidationTest.cs" /> @@ -118,7 +120,6 @@ <Compile Include="Utils\MockIdleController.cs" /> <Compile Include="Utils\MockSimulationDataFactory.cs" /> <Compile Include="Utils\MockVehicleContainer.cs" /> - <Compile Include="Utils\Port.cs" /> <Compile Include="Models\SimulationComponentData\AuxiliaryTypeHelperTest.cs" /> <Compile Include="Models\Simulation\AuxTests.cs" /> <Compile Include="Utils\MockAuxiliaryDemand.cs" /> @@ -217,6 +218,39 @@ <None Include="TestData\Components\40t_Long_Haul_Truck_NoAng.vveh"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> + <None Include="TestData\Components\AT_GBX\AT-Shift.vgbs"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="TestData\Components\AT_GBX\Engine.veng"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="TestData\Components\AT_GBX\FCMap.vmap"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="TestData\Components\AT_GBX\FullLoad.vfld"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="TestData\Components\AT_GBX\Gearbox.vgbx"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="TestData\Components\AT_GBX\GearboxPowerSplit.vgbx"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="TestData\Components\AT_GBX\GearboxSerial.vgbx"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="TestData\Components\AT_GBX\GearboxSerialDualTC.vgbx"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="TestData\Components\AT_GBX\Gearbox_v5.vgbx"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="TestData\Components\AT_GBX\TorqueConverterPowerSplit.vtcc"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="TestData\Components\AT_GBX\TorqueConverter.vtcc"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> <None Include="TestData\Components\Class4_40t_Long_Haul_Truck.vveh"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None>