diff --git a/VECTO/GUI/MainForm.vb b/VECTO/GUI/MainForm.vb index 57879211bbf75bc316787681377b3c3fd0406db0..cccfd32417de084c68259ce1f69f80224e7002a4 100644 --- a/VECTO/GUI/MainForm.vb +++ b/VECTO/GUI/MainForm.vb @@ -50,13 +50,14 @@ Imports TUGraz.VectoCore.InputData.FileIO.XML.Declaration Imports TUGraz.VectoCore.InputData.FileIO.XML.Engineering Imports TUGraz.VectoCore.OutputData Imports TUGraz.VectoCore.OutputData.FileIO +Imports TUGraz.VectoCore.Utils ''' <summary> ''' Main application form. Loads at application start. Closing form ends application. ''' </summary> ''' <remarks></remarks> - Public Class MainForm +Public Class MainForm Private _jobListView As FileListView Private _cycleListView As FileListView @@ -74,7 +75,7 @@ Imports TUGraz.VectoCore.OutputData.FileIO #Region "SLEEP Control - Prevent sleep while VECTO is running" - Private Declare Function SetThreadExecutionState Lib "kernel32"(esFlags As Long) As Long + Private Declare Function SetThreadExecutionState Lib "kernel32" (esFlags As Long) As Long Private Shared Sub AllowSleepOff() #If Not PLATFORM = "x86" Then @@ -236,8 +237,8 @@ Imports TUGraz.VectoCore.OutputData.FileIO LoadOptions() 'Resize columns ... after Loading the @file-lists - LvGEN.Columns(1).Width = - 2 - LvMsg.Columns(2).Width = - 2 + LvGEN.Columns(1).Width = -2 + LvMsg.Columns(2).Width = -2 'Initialize BackgroundWorker @@ -494,7 +495,7 @@ Imports TUGraz.VectoCore.OutputData.FileIO lastindx = LvGEN.SelectedIndices(LvGEN.SelectedItems.Count - 1) - For i = UBound(selIx) To 0 Step - 1 + For i = UBound(selIx) To 0 Step -1 LvGEN.Items.RemoveAt(selIx(i)) Next @@ -562,7 +563,7 @@ Imports TUGraz.VectoCore.OutputData.FileIO Dim p As Integer Dim f As Integer Dim fList As String() - Dim fListDim As Integer = - 1 + Dim fListDim As Integer = -1 Dim listViewItem As ListViewItem 'If VECTO runs: Cancel operation (because Mode-change during calculation is not very clever) @@ -617,7 +618,7 @@ Imports TUGraz.VectoCore.OutputData.FileIO listViewItem.Selected = True LvGEN.Items.Add(listViewItem) listViewItem.EnsureVisible() - lbFound: +lbFound: Next LvGEN.EndUpdate() @@ -889,7 +890,7 @@ Imports TUGraz.VectoCore.OutputData.FileIO Status("Launching VECTO ...") JobFileList.Clear() JobFileList.AddRange( - From listViewItem As ListViewItem In LvGEN.CheckedItems.Cast (Of ListViewItem)() + From listViewItem As ListViewItem In LvGEN.CheckedItems.Cast(Of ListViewItem)() Select fFileRepl = FileRepl(listViewItem.SubItems(0).Text)) SetOptions() @@ -930,6 +931,7 @@ Imports TUGraz.VectoCore.OutputData.FileIO mode = ExecutionMode.Declaration Else mode = ExecutionMode.Engineering + Physics.AirDensity = Cfg.AirDensity.SI(Of KilogramPerCubicMeter)() End If 'dictionary of run-identifiers to fileWriters (used for output directory of modfile) @@ -1013,10 +1015,10 @@ Imports TUGraz.VectoCore.OutputData.FileIO Dim sumProgress As Double = progress.Sum(Function(pair) pair.Value.Progress) Dim duration As Double = (DateTime.Now() - start).TotalSeconds - sender.ReportProgress(Convert.ToInt32((sumProgress*100.0)/progress.Count), + sender.ReportProgress(Convert.ToInt32((sumProgress * 100.0) / progress.Count), New VectoProgress With {.Target = "Status", .Message = _ - String.Format("Duration: {0:0}s, Current Progress: {1:P} ({2})", duration, sumProgress/progress.Count, + String.Format("Duration: {0:0}s, Current Progress: {1:P} ({2})", duration, sumProgress / progress.Count, String.Join(", ", progress.Select(Function(pair) String.Format("{0,4:P}", pair.Value.Progress))))}) Dim justFinished As Dictionary(Of Integer, JobContainer.ProgressEntry) = @@ -1040,7 +1042,7 @@ Imports TUGraz.VectoCore.OutputData.FileIO .Message = String.Format("{0,-60} {1,8:P} {2,10:F2}s - {3}", String.Format("{0} {1} {2}", progressEntry.Value.RunName, progressEntry.Value.CycleName, progressEntry.Value.RunSuffix), - progressEntry.Value.Progress, progressEntry.Value.ExecTime/1000.0, + progressEntry.Value.Progress, progressEntry.Value.ExecTime / 1000.0, IIf(progressEntry.Value.Success, "Success", "Aborted"))}) If (Not progressEntry.Value.Success) Then sender.ReportProgress(100, @@ -1328,9 +1330,9 @@ Imports TUGraz.VectoCore.OutputData.FileIO ToolStripProgBarJob.Value = .ProgJobInt - If .ProgOverallStartInt > - 1 Then + If .ProgOverallStartInt > -1 Then ToolStripProgBarOverall.Value = - CInt(.ProgOverallStartInt + (.PgroOverallEndInt - .ProgOverallStartInt)*.ProgJobInt/100) + CInt(.ProgOverallStartInt + (.PgroOverallEndInt - .ProgOverallStartInt) * .ProgJobInt / 100) End If End With @@ -1651,7 +1653,7 @@ Imports TUGraz.VectoCore.OutputData.FileIO _mainForm.LvMsg.Items.Insert(RowLim - 4, Space(ColLim - 30) & " " & Space(10) & "*| |*") End Select Exit Sub - LbRace: +LbRace: _pRbAlt = Not _pRbAlt @@ -1679,17 +1681,17 @@ Imports TUGraz.VectoCore.OutputData.FileIO Abort() Exit Sub End If - _scr += 5*_diffLvl + _scr += 5 * _diffLvl End If _scr += _diffLvl _diffC += 1 'Erhöhe Schwierigkeitsgrad - If _diffC = (_diffLvl + 3)*4 Then + If _diffC = (_diffLvl + 3) * 4 Then _diffC = 0 _diffLvl += 1 - If _diffLvl > 2 And _diffLvl < 7 Then _mainForm.TmProgSec.Interval = 300 - (_diffLvl)*30 + If _diffLvl > 2 And _diffLvl < 7 Then _mainForm.TmProgSec.Interval = 300 - (_diffLvl) * 30 _scr += 100 Select Case _diffLvl Case 3 @@ -1773,10 +1775,10 @@ Imports TUGraz.VectoCore.OutputData.FileIO _ctrls(RowLim + 1) = 0 _ctrlC += 1 If _ctrlC < _ctrlCl Then Exit Sub - Select Case CInt(Int((_ctrlRnd*Rnd()) + 1)) + Select Case CInt(Int((_ctrlRnd * Rnd()) + 1)) Case 1, 2 _ctrlC = 0 - x = CInt(Int((7*Rnd()) + 1)) + x = CInt(Int((7 * Rnd()) + 1)) _ctrls(RowLim + 1) = x End Select End Sub @@ -1819,7 +1821,7 @@ Imports TUGraz.VectoCore.OutputData.FileIO s = s.Insert(_ctrls(RowLim + 1) + 1, "X") End If Select Case _xPanel - _pnls(RowLim) - Case - 1 + Case -1 s = Replace(s, "|", "\") Case 1 s = Replace(s, "|", "/") @@ -1831,15 +1833,15 @@ Imports TUGraz.VectoCore.OutputData.FileIO _pnDirC += 1 If _pnDirC < _pnDirCl Then GoTo Lb1 _pnDirC = 0 - Select Case CInt(Int((_pnDirRnd*Rnd()) + 1)) + Select Case CInt(Int((_pnDirRnd * Rnd()) + 1)) Case 1 _pnDir = 1 Case 2 - _pnDir = - 1 + _pnDir = -1 Case Else _pnDir = 0 End Select - Lb1: +Lb1: _xPanel += _pnDir If _xPanel > ColLim Then _xPanel = ColLim @@ -1890,7 +1892,7 @@ Imports TUGraz.VectoCore.OutputData.FileIO Dim builder As StringBuilder = New StringBuilder() For Each selectedItem As ListViewItem In LvMsg.SelectedItems builder.AppendLine(String.Join(", ", - selectedItem.SubItems.Cast (Of ListViewItem.ListViewSubItem).Select( + selectedItem.SubItems.Cast(Of ListViewItem.ListViewSubItem).Select( Function(item) item.Text))) Next Clipboard.SetText(builder.ToString()) diff --git a/VECTO/GUI/Settings.Designer.vb b/VECTO/GUI/Settings.Designer.vb index 4f608afb081f05291e02ca786b63e355d778567d..c524bbe19000e429d379e179aa79f91d0dbc4dc9 100644 --- a/VECTO/GUI/Settings.Designer.vb +++ b/VECTO/GUI/Settings.Designer.vb @@ -50,6 +50,7 @@ Partial Class Settings Me.Label2 = New System.Windows.Forms.Label() Me.ButReset = New System.Windows.Forms.Button() Me.BtHelp = New System.Windows.Forms.Button() + Me.Label1 = New System.Windows.Forms.Label() Me.GroupBox3.SuspendLayout() Me.GroupBox5.SuspendLayout() Me.TabControl1.SuspendLayout() @@ -177,6 +178,7 @@ Partial Class Settings ' 'GrCalc ' + Me.GrCalc.Controls.Add(Me.Label1) Me.GrCalc.Controls.Add(Me.Label11) Me.GrCalc.Controls.Add(Me.Label9) Me.GrCalc.Controls.Add(Me.Label3) @@ -192,7 +194,6 @@ Partial Class Settings Me.GrCalc.TabIndex = 1 Me.GrCalc.TabStop = False Me.GrCalc.Text = "Calculation" - Me.GrCalc.Visible = False ' 'Label11 ' @@ -202,6 +203,7 @@ Partial Class Settings Me.Label11.Size = New System.Drawing.Size(77, 13) Me.Label11.TabIndex = 16 Me.Label11.Text = "[kgCO2/KgFC]" + Me.Label11.Visible = False ' 'Label9 ' @@ -211,6 +213,7 @@ Partial Class Settings Me.Label9.Size = New System.Drawing.Size(41, 13) Me.Label9.TabIndex = 16 Me.Label9.Text = "[kg/m³]" + Me.Label9.Visible = False ' 'Label3 ' @@ -227,6 +230,7 @@ Partial Class Settings Me.TbCO2toFC.Name = "TbCO2toFC" Me.TbCO2toFC.Size = New System.Drawing.Size(50, 20) Me.TbCO2toFC.TabIndex = 2 + Me.TbCO2toFC.Visible = False ' 'Label10 ' @@ -236,6 +240,7 @@ Partial Class Settings Me.Label10.Size = New System.Drawing.Size(91, 13) Me.Label10.TabIndex = 14 Me.Label10.Text = "CO2-to-Fuel Ratio" + Me.Label10.Visible = False ' 'TbFuelDens ' @@ -243,6 +248,7 @@ Partial Class Settings Me.TbFuelDens.Name = "TbFuelDens" Me.TbFuelDens.Size = New System.Drawing.Size(50, 20) Me.TbFuelDens.TabIndex = 1 + Me.TbFuelDens.Visible = False ' 'Label8 ' @@ -252,6 +258,7 @@ Partial Class Settings Me.Label8.Size = New System.Drawing.Size(63, 13) Me.Label8.TabIndex = 14 Me.Label8.Text = "Fuel density" + Me.Label8.Visible = False ' 'TbAirDensity ' @@ -289,6 +296,15 @@ Partial Class Settings Me.BtHelp.TabIndex = 0 Me.BtHelp.UseVisualStyleBackColor = True ' + 'Label1 + ' + Me.Label1.AutoSize = True + Me.Label1.Location = New System.Drawing.Point(206, 25) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(65, 13) + Me.Label1.TabIndex = 17 + Me.Label1.Text = "(Eng, Mode)" + ' 'Settings ' Me.AcceptButton = Me.ButtonOK @@ -342,4 +358,5 @@ Partial Class Settings Friend WithEvents GroupBox5 As GroupBox Friend WithEvents TbOpenCmdName As TextBox Friend WithEvents Label12 As Label + Friend WithEvents Label1 As System.Windows.Forms.Label End Class diff --git a/VECTO/GUI/Settings.vb b/VECTO/GUI/Settings.vb index 67a4cfbe192ea38eb288fa940694ed82140d2939..d406259c075e3e7d9e9e39c8c9eb25011a6f1906 100644 --- a/VECTO/GUI/Settings.vb +++ b/VECTO/GUI/Settings.vb @@ -32,7 +32,7 @@ Public Class Settings TbFuelDens.Text = Cfg.FuelDens.ToString TbCO2toFC.Text = Cfg.CO2perFC.ToString - GrCalc.Enabled = Not Cfg.DeclMode + 'GrCalc.Enabled = Not Cfg.DeclMode End Sub diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs index edf3a2f26af5344b3bfc634c08d7cea4a75c4201..4fc3667293e9a01405ef9aac857a1f6ef0d566d2 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs @@ -29,310 +29,312 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ -using System; -using System.Collections.Generic; -using System.Linq; -using TUGraz.VectoCommon.Exceptions; -using TUGraz.VectoCommon.InputData; -using TUGraz.VectoCommon.Models; -using TUGraz.VectoCommon.Utils; -using TUGraz.VectoCore.InputData.Reader.ComponentData; -using TUGraz.VectoCore.Models.SimulationComponent.Data; -using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine; -using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; - -namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter -{ - public abstract class AbstractSimulationDataAdapter : LoggingObject - { - // ========================= - - internal VehicleData SetCommonVehicleData(IVehicleDeclarationInputData data) - { - var retVal = new VehicleData { - SavedInDeclarationMode = data.SavedInDeclarationMode, - Manufacturer = data.Manufacturer, - ModelName = data.Model, - Date = data.Date, +using System; +using System.Collections.Generic; +using System.Linq; +using TUGraz.VectoCommon.Exceptions; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.InputData.Reader.ComponentData; +using TUGraz.VectoCore.Models.SimulationComponent.Data; +using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine; +using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter +{ + public abstract class AbstractSimulationDataAdapter : LoggingObject + { + // ========================= + + internal VehicleData SetCommonVehicleData(IVehicleDeclarationInputData data) + { + var retVal = new VehicleData { + SavedInDeclarationMode = data.SavedInDeclarationMode, + Manufacturer = data.Manufacturer, + ModelName = data.Model, + Date = data.Date, //CertificationNumber = data.CertificationNumber, - DigestValueInput = data.DigestValue, - VehicleCategory = data.VehicleCategory, - AxleConfiguration = data.AxleConfiguration, - CurbWeight = data.CurbMassChassis, - GrossVehicleWeight = data.GrossVehicleMassRating, - }; - - return retVal; - } - - internal AirdragData SetCommonAirdragData(IAirdragDeclarationInputData data) - { - var retVal = new AirdragData() { - SavedInDeclarationMode = data.SavedInDeclarationMode, - Manufacturer = data.Manufacturer, - ModelName = data.Model, - Date = data.Date, - CertificationMethod = data.CertificationMethod, - CertificationNumber = data.CertificationNumber, - DigestValueInput = data.DigestValue, - }; - return retVal; - } - - internal RetarderData SetCommonRetarderData(IRetarderInputData data) - { - try { - var retarder = new RetarderData { Type = data.Type }; - - switch (retarder.Type) { - //case RetarderType.EngineRetarder: - case RetarderType.TransmissionInputRetarder: - case RetarderType.TransmissionOutputRetarder: - retarder.LossMap = RetarderLossMapReader.Create(data.LossMap); - retarder.Ratio = data.Ratio; - break; - case RetarderType.None: - case RetarderType.LossesIncludedInTransmission: - retarder.Ratio = 1; - break; - default: - // ReSharper disable once NotResolvedInText - // ReSharper disable once LocalizableElement - throw new ArgumentOutOfRangeException("retarder.Type", "RetarderType unknown"); - } - - if (!retarder.Type.IsDedicatedComponent()) { - return retarder; - } - retarder.SavedInDeclarationMode = data.SavedInDeclarationMode; - retarder.Manufacturer = data.Manufacturer; - retarder.ModelName = data.Model; - retarder.Date = data.Date; - retarder.CertificationMethod = data.CertificationMethod; - retarder.CertificationNumber = data.CertificationNumber; - retarder.DigestValueInput = data.DigestValue; - - return retarder; - } catch (Exception e) { - throw new VectoException("Error while Reading Retarder Data: {0}", e.Message); - } - } - - internal CombustionEngineData SetCommonCombustionEngineData(IEngineDeclarationInputData data) - { - var retVal = new CombustionEngineData { - SavedInDeclarationMode = data.SavedInDeclarationMode, - Manufacturer = data.Manufacturer, - ModelName = data.Model, - Date = data.Date, - CertificationNumber = data.CertificationNumber, - DigestValueInput = data.DigestValue, - Displacement = data.Displacement, - IdleSpeed = data.IdleSpeed, - ConsumptionMap = FuelConsumptionMapReader.Create(data.FuelConsumptionMap), - RatedPowerDeclared = data.RatedPowerDeclared, - RatedSpeedDeclared = data.RatedSpeedDeclared, - MaxTorqueDeclared = data.MaxTorqueDeclared, - FuelType = data.FuelType - }; - return retVal; - } - - internal GearboxData SetCommonGearboxData(IGearboxDeclarationInputData data) - { - return new GearboxData { - SavedInDeclarationMode = data.SavedInDeclarationMode, - Manufacturer = data.Manufacturer, - ModelName = data.Model, - Date = data.Date, - CertificationMethod = data.CertificationMethod, - CertificationNumber = data.CertificationNumber, - DigestValueInput = data.DigestValue, - Type = data.Type - }; - } - - protected TransmissionLossMap CreateGearLossMap(ITransmissionInputData gear, uint i, bool useEfficiencyFallback, - bool extendLossMap) - { - if (gear.LossMap != null) { - return TransmissionLossMapReader.Create(gear.LossMap, gear.Ratio, string.Format("Gear {0}", i + 1), extendLossMap); - } - if (useEfficiencyFallback) { - return TransmissionLossMapReader.Create(gear.Efficiency, gear.Ratio, string.Format("Gear {0}", i + 1)); - } - throw new InvalidFileFormatException("Gear {0} LossMap missing.", i + 1); - } - - protected static void CreateTCSecondGearATSerial(GearData gearData, - ShiftPolygon shiftPolygon) - { - gearData.TorqueConverterRatio = gearData.Ratio; - gearData.TorqueConverterGearLossMap = gearData.LossMap; - gearData.TorqueConverterShiftPolygon = shiftPolygon; - } - - protected static void CreateTCFirstGearATSerial(GearData gearData, - ShiftPolygon shiftPolygon) - { - gearData.TorqueConverterRatio = gearData.Ratio; - gearData.TorqueConverterGearLossMap = gearData.LossMap; - gearData.TorqueConverterShiftPolygon = shiftPolygon; - } - - protected static void CretateTCFirstGearATPowerSplit(GearData gearData, uint i, ShiftPolygon shiftPolygon) - { - gearData.TorqueConverterRatio = 1; - gearData.TorqueConverterGearLossMap = TransmissionLossMapReader.Create(1, 1, string.Format("TCGear {0}", i + 1)); - gearData.TorqueConverterShiftPolygon = shiftPolygon; - } - - public AxleGearData CreateAxleGearData(IAxleGearInputData data, bool useEfficiencyFallback) - { - var retVal = SetCommonAxleGearData(data); - retVal.AxleGear.LossMap = ReadAxleLossMap(data, useEfficiencyFallback); - return retVal; - } - - internal TransmissionLossMap ReadAxleLossMap(IAxleGearInputData data, bool useEfficiencyFallback) - { - TransmissionLossMap axleLossMap; - if (data.LossMap == null && useEfficiencyFallback) { - axleLossMap = TransmissionLossMapReader.Create(data.Efficiency, data.Ratio, "Axlegear"); - } else { - if (data.LossMap == null) { - throw new InvalidFileFormatException("LossMap for Axlegear is missing."); - } - axleLossMap = TransmissionLossMapReader.Create(data.LossMap, data.Ratio, "Axlegear"); - } - if (axleLossMap == null) { - throw new InvalidFileFormatException("LossMap for Axlegear is missing."); - } - return axleLossMap; - } - - internal AxleGearData SetCommonAxleGearData(IAxleGearInputData data) - { - return new AxleGearData { - SavedInDeclarationMode = data.SavedInDeclarationMode, - Manufacturer = data.Manufacturer, - ModelName = data.Model, - LineType = data.LineType, - Date = data.Date, - CertificationMethod = data.CertificationMethod, - CertificationNumber = data.CertificationNumber, - DigestValueInput = data.DigestValue, - AxleGear = new GearData { Ratio = data.Ratio } - }; - } - - /// <summary> - /// Creates an AngledriveData or returns null if there is no anglegear. - /// </summary> - /// <param name="data"></param> - /// <param name="useEfficiencyFallback">if true, the Efficiency value is used if no LossMap is found.</param> - /// <returns></returns> - internal AngledriveData CreateAngledriveData(IAngledriveInputData data, bool useEfficiencyFallback) - { - try { - var type = data.Type; - - switch (type) { - case AngledriveType.LossesIncludedInGearbox: - case AngledriveType.None: - return null; - case AngledriveType.SeparateAngledrive: - var angledriveData = new AngledriveData { - SavedInDeclarationMode = data.SavedInDeclarationMode, - Manufacturer = data.Manufacturer, - ModelName = data.Model, - Date = data.Date, - CertificationMethod = data.CertificationMethod, - CertificationNumber = data.CertificationNumber, - DigestValueInput = data.DigestValue, - Type = type, - Angledrive = new TransmissionData { Ratio = data.Ratio } - }; - try { - angledriveData.Angledrive.LossMap = TransmissionLossMapReader.Create(data.LossMap, - data.Ratio, "Angledrive"); - } catch (VectoException ex) { - Log.Info("Angledrive Loss Map not found."); - if (useEfficiencyFallback) { - Log.Info("Angledrive Trying with Efficiency instead of Loss Map."); - angledriveData.Angledrive.LossMap = TransmissionLossMapReader.Create(data.Efficiency, - data.Ratio, "Angledrive"); - } else { - throw new VectoException("Angledrive: LossMap not found.", ex); - } - } - return angledriveData; - default: - throw new ArgumentOutOfRangeException("data", "Unknown Angledrive Type."); - } - } catch (Exception e) { - throw new VectoException("Error while reading Angledrive data: {0}", e.Message, e); - } - } - - /// <summary> - /// Intersects full load curves. - /// </summary> - /// <param name="engineCurve"></param> - /// <param name="maxTorque"></param> - /// <returns>A combined EngineFullLoadCurve with the minimum full load torque over all inputs curves.</returns> - internal static EngineFullLoadCurve IntersectFullLoadCurves(EngineFullLoadCurve engineCurve, NewtonMeter maxTorque) - { - if (maxTorque == null) { - return engineCurve; - } - - var entries = new List<EngineFullLoadCurve.FullLoadCurveEntry>(); - var firstEntry = engineCurve.FullLoadEntries.First(); - if (firstEntry.TorqueFullLoad < maxTorque) { - entries.Add(engineCurve.FullLoadEntries.First()); - } else { - entries.Add(new EngineFullLoadCurve.FullLoadCurveEntry { - EngineSpeed = firstEntry.EngineSpeed, - TorqueFullLoad = maxTorque, - TorqueDrag = firstEntry.TorqueDrag - }); - } - foreach (var entry in engineCurve.FullLoadEntries.Pairwise(Tuple.Create)) { - if (entry.Item1.TorqueFullLoad <= maxTorque && entry.Item2.TorqueFullLoad <= maxTorque) { - // segment is below maxTorque line -> use directly - entries.Add(entry.Item2); - } else if (entry.Item1.TorqueFullLoad > maxTorque && entry.Item2.TorqueFullLoad > maxTorque) { - // segment is above maxTorque line -> add limited entry - entries.Add(new EngineFullLoadCurve.FullLoadCurveEntry { - EngineSpeed = entry.Item2.EngineSpeed, - TorqueFullLoad = maxTorque, - TorqueDrag = entry.Item2.TorqueDrag - }); - } else { - // segment intersects maxTorque line -> add new entry at intersection - var edgeFull = Edge.Create(new Point(entry.Item1.EngineSpeed.Value(), entry.Item1.TorqueFullLoad.Value()), - new Point(entry.Item2.EngineSpeed.Value(), entry.Item2.TorqueFullLoad.Value())); - var edgeDrag = Edge.Create(new Point(entry.Item1.EngineSpeed.Value(), entry.Item1.TorqueDrag.Value()), - new Point(entry.Item2.EngineSpeed.Value(), entry.Item2.TorqueDrag.Value())); - var intersectionX = (maxTorque.Value() - edgeFull.OffsetXY) / edgeFull.SlopeXY; - entries.Add(new EngineFullLoadCurve.FullLoadCurveEntry { - EngineSpeed = intersectionX.SI<PerSecond>(), - TorqueFullLoad = maxTorque, - TorqueDrag = VectoMath.Interpolate(edgeDrag.P1, edgeDrag.P2, intersectionX).SI<NewtonMeter>() - }); - entries.Add(new EngineFullLoadCurve.FullLoadCurveEntry { - EngineSpeed = entry.Item2.EngineSpeed, - TorqueFullLoad = entry.Item2.TorqueFullLoad > maxTorque ? maxTorque : entry.Item2.TorqueFullLoad, - TorqueDrag = entry.Item2.TorqueDrag - }); - } - } - - var flc = new EngineFullLoadCurve(entries.ToList(), engineCurve.PT1Data) { - EngineData = engineCurve.EngineData, - }; - return flc; - } - } + DigestValueInput = data.DigestValue, + VehicleCategory = data.VehicleCategory, + AxleConfiguration = data.AxleConfiguration, + CurbWeight = data.CurbMassChassis, + GrossVehicleWeight = data.GrossVehicleMassRating, + AirDensity = Physics.AirDensity, + }; + + return retVal; + } + + internal AirdragData SetCommonAirdragData(IAirdragDeclarationInputData data) + { + var retVal = new AirdragData() { + SavedInDeclarationMode = data.SavedInDeclarationMode, + Manufacturer = data.Manufacturer, + ModelName = data.Model, + Date = data.Date, + CertificationMethod = data.CertificationMethod, + CertificationNumber = data.CertificationNumber, + DigestValueInput = data.DigestValue, + }; + return retVal; + } + + internal RetarderData SetCommonRetarderData(IRetarderInputData data) + { + try { + var retarder = new RetarderData { Type = data.Type }; + + switch (retarder.Type) { + //case RetarderType.EngineRetarder: + case RetarderType.TransmissionInputRetarder: + case RetarderType.TransmissionOutputRetarder: + retarder.LossMap = RetarderLossMapReader.Create(data.LossMap); + retarder.Ratio = data.Ratio; + break; + case RetarderType.None: + case RetarderType.LossesIncludedInTransmission: + retarder.Ratio = 1; + break; + default: + // ReSharper disable once NotResolvedInText + // ReSharper disable once LocalizableElement + throw new ArgumentOutOfRangeException("retarder.Type", "RetarderType unknown"); + } + + if (!retarder.Type.IsDedicatedComponent()) { + return retarder; + } + retarder.SavedInDeclarationMode = data.SavedInDeclarationMode; + retarder.Manufacturer = data.Manufacturer; + retarder.ModelName = data.Model; + retarder.Date = data.Date; + retarder.CertificationMethod = data.CertificationMethod; + retarder.CertificationNumber = data.CertificationNumber; + retarder.DigestValueInput = data.DigestValue; + + return retarder; + } catch (Exception e) { + throw new VectoException("Error while Reading Retarder Data: {0}", e.Message); + } + } + + internal CombustionEngineData SetCommonCombustionEngineData(IEngineDeclarationInputData data) + { + var retVal = new CombustionEngineData { + SavedInDeclarationMode = data.SavedInDeclarationMode, + Manufacturer = data.Manufacturer, + ModelName = data.Model, + Date = data.Date, + CertificationNumber = data.CertificationNumber, + DigestValueInput = data.DigestValue, + Displacement = data.Displacement, + IdleSpeed = data.IdleSpeed, + ConsumptionMap = FuelConsumptionMapReader.Create(data.FuelConsumptionMap), + RatedPowerDeclared = data.RatedPowerDeclared, + RatedSpeedDeclared = data.RatedSpeedDeclared, + MaxTorqueDeclared = data.MaxTorqueDeclared, + FuelType = data.FuelType + }; + return retVal; + } + + internal GearboxData SetCommonGearboxData(IGearboxDeclarationInputData data) + { + return new GearboxData { + SavedInDeclarationMode = data.SavedInDeclarationMode, + Manufacturer = data.Manufacturer, + ModelName = data.Model, + Date = data.Date, + CertificationMethod = data.CertificationMethod, + CertificationNumber = data.CertificationNumber, + DigestValueInput = data.DigestValue, + Type = data.Type + }; + } + + protected TransmissionLossMap CreateGearLossMap(ITransmissionInputData gear, uint i, bool useEfficiencyFallback, + bool extendLossMap) + { + if (gear.LossMap != null) { + return TransmissionLossMapReader.Create(gear.LossMap, gear.Ratio, string.Format("Gear {0}", i + 1), extendLossMap); + } + if (useEfficiencyFallback) { + return TransmissionLossMapReader.Create(gear.Efficiency, gear.Ratio, string.Format("Gear {0}", i + 1)); + } + throw new InvalidFileFormatException("Gear {0} LossMap missing.", i + 1); + } + + protected static void CreateTCSecondGearATSerial(GearData gearData, + ShiftPolygon shiftPolygon) + { + gearData.TorqueConverterRatio = gearData.Ratio; + gearData.TorqueConverterGearLossMap = gearData.LossMap; + gearData.TorqueConverterShiftPolygon = shiftPolygon; + } + + protected static void CreateTCFirstGearATSerial(GearData gearData, + ShiftPolygon shiftPolygon) + { + gearData.TorqueConverterRatio = gearData.Ratio; + gearData.TorqueConverterGearLossMap = gearData.LossMap; + gearData.TorqueConverterShiftPolygon = shiftPolygon; + } + + protected static void CretateTCFirstGearATPowerSplit(GearData gearData, uint i, ShiftPolygon shiftPolygon) + { + gearData.TorqueConverterRatio = 1; + gearData.TorqueConverterGearLossMap = TransmissionLossMapReader.Create(1, 1, string.Format("TCGear {0}", i + 1)); + gearData.TorqueConverterShiftPolygon = shiftPolygon; + } + + public AxleGearData CreateAxleGearData(IAxleGearInputData data, bool useEfficiencyFallback) + { + var retVal = SetCommonAxleGearData(data); + retVal.AxleGear.LossMap = ReadAxleLossMap(data, useEfficiencyFallback); + return retVal; + } + + internal TransmissionLossMap ReadAxleLossMap(IAxleGearInputData data, bool useEfficiencyFallback) + { + TransmissionLossMap axleLossMap; + if (data.LossMap == null && useEfficiencyFallback) { + axleLossMap = TransmissionLossMapReader.Create(data.Efficiency, data.Ratio, "Axlegear"); + } else { + if (data.LossMap == null) { + throw new InvalidFileFormatException("LossMap for Axlegear is missing."); + } + axleLossMap = TransmissionLossMapReader.Create(data.LossMap, data.Ratio, "Axlegear"); + } + if (axleLossMap == null) { + throw new InvalidFileFormatException("LossMap for Axlegear is missing."); + } + return axleLossMap; + } + + internal AxleGearData SetCommonAxleGearData(IAxleGearInputData data) + { + return new AxleGearData { + SavedInDeclarationMode = data.SavedInDeclarationMode, + Manufacturer = data.Manufacturer, + ModelName = data.Model, + LineType = data.LineType, + Date = data.Date, + CertificationMethod = data.CertificationMethod, + CertificationNumber = data.CertificationNumber, + DigestValueInput = data.DigestValue, + AxleGear = new GearData { Ratio = data.Ratio } + }; + } + + /// <summary> + /// Creates an AngledriveData or returns null if there is no anglegear. + /// </summary> + /// <param name="data"></param> + /// <param name="useEfficiencyFallback">if true, the Efficiency value is used if no LossMap is found.</param> + /// <returns></returns> + internal AngledriveData CreateAngledriveData(IAngledriveInputData data, bool useEfficiencyFallback) + { + try { + var type = data.Type; + + switch (type) { + case AngledriveType.LossesIncludedInGearbox: + case AngledriveType.None: + return null; + case AngledriveType.SeparateAngledrive: + var angledriveData = new AngledriveData { + SavedInDeclarationMode = data.SavedInDeclarationMode, + Manufacturer = data.Manufacturer, + ModelName = data.Model, + Date = data.Date, + CertificationMethod = data.CertificationMethod, + CertificationNumber = data.CertificationNumber, + DigestValueInput = data.DigestValue, + Type = type, + Angledrive = new TransmissionData { Ratio = data.Ratio } + }; + try { + angledriveData.Angledrive.LossMap = TransmissionLossMapReader.Create(data.LossMap, + data.Ratio, "Angledrive"); + } catch (VectoException ex) { + Log.Info("Angledrive Loss Map not found."); + if (useEfficiencyFallback) { + Log.Info("Angledrive Trying with Efficiency instead of Loss Map."); + angledriveData.Angledrive.LossMap = TransmissionLossMapReader.Create(data.Efficiency, + data.Ratio, "Angledrive"); + } else { + throw new VectoException("Angledrive: LossMap not found.", ex); + } + } + return angledriveData; + default: + throw new ArgumentOutOfRangeException("data", "Unknown Angledrive Type."); + } + } catch (Exception e) { + throw new VectoException("Error while reading Angledrive data: {0}", e.Message, e); + } + } + + /// <summary> + /// Intersects full load curves. + /// </summary> + /// <param name="engineCurve"></param> + /// <param name="maxTorque"></param> + /// <returns>A combined EngineFullLoadCurve with the minimum full load torque over all inputs curves.</returns> + internal static EngineFullLoadCurve IntersectFullLoadCurves(EngineFullLoadCurve engineCurve, NewtonMeter maxTorque) + { + if (maxTorque == null) { + return engineCurve; + } + + var entries = new List<EngineFullLoadCurve.FullLoadCurveEntry>(); + var firstEntry = engineCurve.FullLoadEntries.First(); + if (firstEntry.TorqueFullLoad < maxTorque) { + entries.Add(engineCurve.FullLoadEntries.First()); + } else { + entries.Add(new EngineFullLoadCurve.FullLoadCurveEntry { + EngineSpeed = firstEntry.EngineSpeed, + TorqueFullLoad = maxTorque, + TorqueDrag = firstEntry.TorqueDrag + }); + } + foreach (var entry in engineCurve.FullLoadEntries.Pairwise(Tuple.Create)) { + if (entry.Item1.TorqueFullLoad <= maxTorque && entry.Item2.TorqueFullLoad <= maxTorque) { + // segment is below maxTorque line -> use directly + entries.Add(entry.Item2); + } else if (entry.Item1.TorqueFullLoad > maxTorque && entry.Item2.TorqueFullLoad > maxTorque) { + // segment is above maxTorque line -> add limited entry + entries.Add(new EngineFullLoadCurve.FullLoadCurveEntry { + EngineSpeed = entry.Item2.EngineSpeed, + TorqueFullLoad = maxTorque, + TorqueDrag = entry.Item2.TorqueDrag + }); + } else { + // segment intersects maxTorque line -> add new entry at intersection + var edgeFull = Edge.Create(new Point(entry.Item1.EngineSpeed.Value(), entry.Item1.TorqueFullLoad.Value()), + new Point(entry.Item2.EngineSpeed.Value(), entry.Item2.TorqueFullLoad.Value())); + var edgeDrag = Edge.Create(new Point(entry.Item1.EngineSpeed.Value(), entry.Item1.TorqueDrag.Value()), + new Point(entry.Item2.EngineSpeed.Value(), entry.Item2.TorqueDrag.Value())); + var intersectionX = (maxTorque.Value() - edgeFull.OffsetXY) / edgeFull.SlopeXY; + entries.Add(new EngineFullLoadCurve.FullLoadCurveEntry { + EngineSpeed = intersectionX.SI<PerSecond>(), + TorqueFullLoad = maxTorque, + TorqueDrag = VectoMath.Interpolate(edgeDrag.P1, edgeDrag.P2, intersectionX).SI<NewtonMeter>() + }); + entries.Add(new EngineFullLoadCurve.FullLoadCurveEntry { + EngineSpeed = entry.Item2.EngineSpeed, + TorqueFullLoad = entry.Item2.TorqueFullLoad > maxTorque ? maxTorque : entry.Item2.TorqueFullLoad, + TorqueDrag = entry.Item2.TorqueDrag + }); + } + } + + var flc = new EngineFullLoadCurve(entries.ToList(), engineCurve.PT1Data) { + EngineData = engineCurve.EngineData, + }; + return flc; + } + } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs index d135c2e77348e2cd98e7c537d0a4c11db7e54d1a..35faf312e2f6bc2ac878fd9aeff2b13a417a5782 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs @@ -88,6 +88,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter } var retVal = SetCommonVehicleData(data); + retVal.AirDensity = DeclarationData.AirDensity; retVal.VIN = data.VIN; retVal.ManufacturerAddress = data.ManufacturerAddress; retVal.LegislativeClass = data.LegislativeClass; diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs index 08da7492bd1a75438104956972eb0bf83ddcddcf..2ce233f8e076f43d01e74511b30a3e29f2096744 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs @@ -53,7 +53,6 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter if (data.SavedInDeclarationMode) { WarnEngineeringMode("VehicleData"); } - var retVal = SetCommonVehicleData(data); retVal.BodyAndTrailerWeight = data.CurbMassExtra; //retVal.CurbWeight += data.CurbMassExtra; diff --git a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs index 0e96a009d92372a031687c7d240c35012cd41da8..d0bbf7f591b658d5c44151df5546002619939c30 100644 --- a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs +++ b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs @@ -47,6 +47,15 @@ namespace TUGraz.VectoCore.Models.Declaration { public static class DeclarationData { + /// <summary> + /// The standard acceleration for gravity on earth. + /// http://physics.nist.gov/Pubs/SP330/sp330.pdf (page 52) + /// </summary> + public static readonly MeterPerSquareSecond GravityAccelleration = 9.80665.SI<MeterPerSquareSecond>(); + + public static readonly KilogramPerCubicMeter AirDensity = 1.188.SI<KilogramPerCubicMeter>(); + + public const string DeclarationDataResourcePrefix = "TUGraz.VectoCore.Resources.Declaration"; public static readonly Watt MinEnginePowerForEMS = 300e3.SI<Watt>(); @@ -69,6 +78,7 @@ namespace TUGraz.VectoCore.Models.Declaration public static readonly Payloads Payloads = new Payloads(); public static readonly PTOTransmission PTOTransmission = new PTOTransmission(); + /// <summary> /// Formula for calculating the payload for a given gross vehicle weight. /// (so called "pc-formula", Whitebook Apr 2016, Part 1, p.187) @@ -89,8 +99,10 @@ namespace TUGraz.VectoCore.Models.Declaration /// </summary> public static Kilogram GetPayloadForTrailerWeight(Kilogram grossVehicleWeight, Kilogram curbWeight, bool lowLoading) { - return (Math.Round((Payloads.LookupTrailer(grossVehicleWeight, curbWeight) / (lowLoading ? 7.5 : 1)).LimitTo(0.SI<Kilogram>(), - grossVehicleWeight - curbWeight).Value() / 100, 0) * 100).SI<Kilogram>(); + return + (Math.Round( + (Payloads.LookupTrailer(grossVehicleWeight, curbWeight) / (lowLoading ? 7.5 : 1)).LimitTo(0.SI<Kilogram>(), + grossVehicleWeight - curbWeight).Value() / 100, 0) * 100).SI<Kilogram>(); } public static int PoweredAxle() diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/CrosswindCorrectionCdxALookup.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/CrosswindCorrectionCdxALookup.cs index 9b3e1938c30159f9a66201ef19324913aaeddee6..c7a076b853446965dd167d2c9991f225a125d4a8 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/CrosswindCorrectionCdxALookup.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/CrosswindCorrectionCdxALookup.cs @@ -29,58 +29,58 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ -using System.Collections.Generic; -using TUGraz.VectoCommon.Exceptions; -using TUGraz.VectoCommon.Models; -using TUGraz.VectoCommon.Utils; -using TUGraz.VectoCore.InputData.Reader.ComponentData; -using TUGraz.VectoCore.Models.Simulation.DataBus; -using TUGraz.VectoCore.Utils; - -namespace TUGraz.VectoCore.Models.SimulationComponent.Data -{ - public class CrosswindCorrectionCdxALookup : LoggingObject, ICrossWindCorrection - { - protected readonly List<CrossWindCorrectionCurveReader.CrossWindCorrectionEntry> Entries; - - public CrosswindCorrectionCdxALookup(SquareMeter airDragArea, - List<CrossWindCorrectionCurveReader.CrossWindCorrectionEntry> entries, - CrossWindCorrectionMode correctionMode) - { - AirDragArea = airDragArea; - CorrectionMode = correctionMode; - Entries = entries; - } - - public CrossWindCorrectionMode CorrectionMode { get; internal set; } - - public SquareMeter AirDragArea { get; internal set; } - - public void SetDataBus(IDataBus dataBus) {} - - public Watt AverageAirDragPowerLoss(MeterPerSecond v1, MeterPerSecond v2) - { - var vAverage = (v1 + v2) / 2; - var cdA = EffectiveAirDragArea(vAverage); - - // compute the average force within the current simulation interval - // P(t) = k * CdA * v(t)^3 , v(t) = v0 + a * t // P_avg = 1/T * Integral P(t) dt - // => P_avg = (CdA * rho/2)/(4*a * dt) * (v2^4 - v1^4) // a = (v2-v1)/dt - // -> P_avg = (CdA * rho/2) * (v2^4 - v1^4) / (v2 - v1) = (CdA * rho/2) * (v1 + v2) * (v1^2 + v2^2) - return (Physics.AirDensity / (2.0 * 4) * cdA * (v1 + v2) * (v1 * v1 + v2 * v2)).Cast<Watt>(); - } - - protected internal SquareMeter EffectiveAirDragArea(MeterPerSecond x) - { - var p = Entries.GetSection(c => c.Velocity < x); - - if (!x.IsBetween(p.Item1.Velocity, p.Item2.Velocity)) { - throw new VectoException("CrossWindCorrection Extrapolation: v = {0} (max = {1})", x.ConvertTo().Kilo.Meter.Per.Hour, - p.Item2.Velocity.ConvertTo().Kilo.Meter.Per.Hour); - } - - return VectoMath.Interpolate(p.Item1.Velocity, p.Item2.Velocity, - p.Item1.EffectiveCrossSectionArea, p.Item2.EffectiveCrossSectionArea, x); - } - } +using System.Collections.Generic; +using TUGraz.VectoCommon.Exceptions; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.InputData.Reader.ComponentData; +using TUGraz.VectoCore.Models.Simulation.DataBus; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.Models.SimulationComponent.Data +{ + public class CrosswindCorrectionCdxALookup : LoggingObject, ICrossWindCorrection + { + protected readonly List<CrossWindCorrectionCurveReader.CrossWindCorrectionEntry> Entries; + + public CrosswindCorrectionCdxALookup(SquareMeter airDragArea, + List<CrossWindCorrectionCurveReader.CrossWindCorrectionEntry> entries, + CrossWindCorrectionMode correctionMode) + { + AirDragArea = airDragArea; + CorrectionMode = correctionMode; + Entries = entries; + } + + public CrossWindCorrectionMode CorrectionMode { get; internal set; } + + public SquareMeter AirDragArea { get; internal set; } + + public void SetDataBus(IDataBus dataBus) {} + + public Watt AverageAirDragPowerLoss(MeterPerSecond v1, MeterPerSecond v2, KilogramPerCubicMeter airDensity) + { + var vAverage = (v1 + v2) / 2; + var cdA = EffectiveAirDragArea(vAverage); + + // compute the average force within the current simulation interval + // P(t) = k * CdA * v(t)^3 , v(t) = v0 + a * t // P_avg = 1/T * Integral P(t) dt + // => P_avg = (CdA * rho/2)/(4*a * dt) * (v2^4 - v1^4) // a = (v2-v1)/dt + // -> P_avg = (CdA * rho/2) * (v2^4 - v1^4) / (v2 - v1) = (CdA * rho/2) * (v1 + v2) * (v1^2 + v2^2) + return (airDensity / (2.0 * 4) * cdA * (v1 + v2) * (v1 * v1 + v2 * v2)).Cast<Watt>(); + } + + protected internal SquareMeter EffectiveAirDragArea(MeterPerSecond x) + { + var p = Entries.GetSection(c => c.Velocity < x); + + if (!x.IsBetween(p.Item1.Velocity, p.Item2.Velocity)) { + throw new VectoException("CrossWindCorrection Extrapolation: v = {0} (max = {1})", x.ConvertTo().Kilo.Meter.Per.Hour, + p.Item2.Velocity.ConvertTo().Kilo.Meter.Per.Hour); + } + + return VectoMath.Interpolate(p.Item1.Velocity, p.Item2.Velocity, + p.Item1.EffectiveCrossSectionArea, p.Item2.EffectiveCrossSectionArea, x); + } + } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/CrosswindCorrectionVAirBeta.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/CrosswindCorrectionVAirBeta.cs index c29a191a8d90bf0437f28a2362f6a8521c483440..8e497fe9403ffc6bd8b4947676003484f1bceb5e 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/CrosswindCorrectionVAirBeta.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/CrosswindCorrectionVAirBeta.cs @@ -65,7 +65,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data get { return CrossWindCorrectionMode.VAirBetaLookupTable; } } - public Watt AverageAirDragPowerLoss(MeterPerSecond v1, MeterPerSecond v2) + public Watt AverageAirDragPowerLoss(MeterPerSecond v1, MeterPerSecond v2, KilogramPerCubicMeter airDensity) { if (DataBus == null) { throw new VectoException("Databus is not set - can't access vAir, beta!"); diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/ICrossWindCorrection.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/ICrossWindCorrection.cs index c610dc2e541bd0d73ed280b8fc22bd371b59e8fe..61fd0265df14969958a25549d0418ad5a3471ea6 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/ICrossWindCorrection.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/ICrossWindCorrection.cs @@ -29,22 +29,22 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ -using TUGraz.VectoCommon.Models; -using TUGraz.VectoCommon.Utils; -using TUGraz.VectoCore.Models.Simulation.DataBus; - -namespace TUGraz.VectoCore.Models.SimulationComponent.Data -{ - public interface ICrossWindCorrection - { - //SquareMeter EffectiveAirDragArea(MeterPerSecond x, IDataBus dataBus); - - void SetDataBus(IDataBus dataBus); - - CrossWindCorrectionMode CorrectionMode { get; } - - SquareMeter AirDragArea { get; } - - Watt AverageAirDragPowerLoss(MeterPerSecond v1, MeterPerSecond v2); - } +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Models.Simulation.DataBus; + +namespace TUGraz.VectoCore.Models.SimulationComponent.Data +{ + public interface ICrossWindCorrection + { + //SquareMeter EffectiveAirDragArea(MeterPerSecond x, IDataBus dataBus); + + void SetDataBus(IDataBus dataBus); + + CrossWindCorrectionMode CorrectionMode { get; } + + SquareMeter AirDragArea { get; } + + Watt AverageAirDragPowerLoss(MeterPerSecond v1, MeterPerSecond v2, KilogramPerCubicMeter airDensity); + } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs index 2422a84ff6faa1154fef0106916db14c0267ee7c..835a29c9b433755e7c8a2fbb56a1d0e0d5143a3e 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs @@ -141,6 +141,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data [Required, SIRange(0.1, 0.7)] public Meter DynamicTyreRadius { get; internal set; } + public KilogramPerCubicMeter AirDensity { get; internal set; } + public KilogramSquareMeter WheelsInertia { get { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs index 57cdd58380c2ac56974b0496f08e483539a41728..8bacad4cfdb0347ab9afce2c4371d8bfda373ac8 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs @@ -192,7 +192,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl private Watt ComputeAirDragPowerLoss(MeterPerSecond v1, MeterPerSecond v2) { - return AirdragData.CrossWindCorrectionCurve.AverageAirDragPowerLoss(v1, v2); + return AirdragData.CrossWindCorrectionCurve.AverageAirDragPowerLoss(v1, v2, ModelData.AirDensity); } public Meter Distance diff --git a/VectoCore/VectoCore/Utils/Physics.cs b/VectoCore/VectoCore/Utils/Physics.cs index a7fcce2342d0c1d9468d76b4667cd00008a5db2e..ec43dd6fc0a66e8109b02d6b282cda5aa7f15b61 100644 --- a/VectoCore/VectoCore/Utils/Physics.cs +++ b/VectoCore/VectoCore/Utils/Physics.cs @@ -29,39 +29,40 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ -using TUGraz.VectoCommon.Utils; - -namespace TUGraz.VectoCore.Utils -{ - public static class Physics - { - /// <summary> - /// The standard acceleration for gravity on earth. - /// http://physics.nist.gov/Pubs/SP330/sp330.pdf (page 52) - /// </summary> - public static readonly MeterPerSquareSecond GravityAccelleration = 9.80665.SI<MeterPerSquareSecond>(); - - /// <summary> - /// Density of air. - /// </summary> - public static readonly KilogramPerCubicMeter AirDensity = 1.188.SI<KilogramPerCubicMeter>(); - - - public const double RollResistanceExponent = 0.9; - - /// <summary> - /// Base Wind Speed. - /// </summary> - public static readonly MeterPerSecond BaseWindSpeed = 3.SI<MeterPerSecond>(); - - /// <summary> - /// Base Height for Wind Speed. - /// </summary> - public static readonly Meter BaseWindHeight = 4.SI<Meter>(); - - /// <summary> - /// Hellmann Exponent for modelling of wind speed in specific heights. - /// </summary> - public const double HellmannExponent = 0.2; - } +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Models.Declaration; + +namespace TUGraz.VectoCore.Utils +{ + public static class Physics + { + /// <summary> + /// The standard acceleration for gravity on earth. + /// http://physics.nist.gov/Pubs/SP330/sp330.pdf (page 52) + /// </summary> + public static MeterPerSquareSecond GravityAccelleration = DeclarationData.GravityAccelleration; + + /// <summary> + /// Density of air. + /// </summary> + public static KilogramPerCubicMeter AirDensity = DeclarationData.AirDensity; // 1.188.SI<KilogramPerCubicMeter>(); + + + public const double RollResistanceExponent = 0.9; + + /// <summary> + /// Base Wind Speed. + /// </summary> + public static readonly MeterPerSecond BaseWindSpeed = 3.SI<MeterPerSecond>(); + + /// <summary> + /// Base Height for Wind Speed. + /// </summary> + public static readonly Meter BaseWindHeight = 4.SI<Meter>(); + + /// <summary> + /// Hellmann Exponent for modelling of wind speed in specific heights. + /// </summary> + public const double HellmannExponent = 0.2; + } } \ No newline at end of file