diff --git a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs index 75ad114b0aa69fd5c9f88e38045fb8df9c063f47..71820d27d28802bdf361f30ea94b385e2ee2efcc 100644 --- a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs +++ b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs @@ -294,7 +294,7 @@ namespace TUGraz.VectoCore.Models.Declaration var p6 = new Point(p2.X, VectoMath.Interpolate(p1, p3, p2.X)); var p7 = new Point(p4.X, VectoMath.Interpolate(p2, p5, p4.X)); - var fldMargin = ShiftPolygonFldMargin(fullLoadCurve.FullLoadEntries, nVHigh * 0.95); + var fldMargin = ShiftPolygonFldMargin(fullLoadCurve.FullLoadEntries, (p3.X * 0.95).SI<PerSecond>()); var downshiftCorr = MoveDownshiftBelowFld(Edge.Create(p6, p3), fldMargin, 1.1 * fullLoadCurve.MaxTorque); var downShift = new List<ShiftPolygon.ShiftPolygonEntry>(); diff --git a/VectoCore/VectoCore/Models/Declaration/VehicleClass.cs b/VectoCore/VectoCore/Models/Declaration/VehicleClass.cs index 6254e7cc9e57e3c350f647ba8862fb0d2f14cb80..eae963c5cb8ebc09cabb90181324a654e4fe61ba 100644 --- a/VectoCore/VectoCore/Models/Declaration/VehicleClass.cs +++ b/VectoCore/VectoCore/Models/Declaration/VehicleClass.cs @@ -67,7 +67,7 @@ namespace TUGraz.VectoCore.Models.Declaration public static VehicleClass Parse(string text) { - return text.Replace(Prefix, "").ParseEnum<VehicleClass>(); + return (Prefix + text).ParseEnum<VehicleClass>(); } public static string GetClassNumber(this VehicleClass hdvClass) diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs index ebab9c27613051f27cc58d832643a1c7dca89edc..f271d4c0bf51c6a4977e92208bfbdffa32751e1e 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs @@ -281,7 +281,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } /// <summary> - /// Handles Requests when no gear is engaged + /// Handles Requests when no gear is disengaged /// </summary> /// <param name="absTime"></param> /// <param name="dt"></param> @@ -303,8 +303,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl }; } - if ((outTorque * avgOutAngularVelocity).IsGreater(0.SI<Watt>(), - Constants.SimulationSettings.LineSearchTolerance)) { + if ((outTorque * avgOutAngularVelocity).IsGreater(0.SI<Watt>(), Constants.SimulationSettings.LineSearchTolerance) && + !outAngularVelocity.IsEqual(0)) { return new ResponseOverload { Source = this, Delta = outTorque * avgOutAngularVelocity, @@ -312,8 +312,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl }; } - if ((outTorque * avgOutAngularVelocity).IsSmaller(0.SI<Watt>(), - Constants.SimulationSettings.LineSearchTolerance)) { + if ((outTorque * avgOutAngularVelocity).IsSmaller(0.SI<Watt>(), Constants.SimulationSettings.LineSearchTolerance)) { return new ResponseUnderload { Source = this, Delta = outTorque * avgOutAngularVelocity, @@ -321,13 +320,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl }; } - CurrentState.SetState(0.SI<NewtonMeter>(), 0.RPMtoRad(), outTorque, outAngularVelocity); + CurrentState.SetState(0.SI<NewtonMeter>(), 0.SI<PerSecond>(), outTorque, outAngularVelocity); CurrentState.Gear = Gear; var disengagedResponse = NextComponent.Request(absTime, dt, 0.SI<NewtonMeter>(), DataBus.EngineIdleSpeed); disengagedResponse.GearboxPowerRequest = outTorque * avgOutAngularVelocity; return disengagedResponse; - //todo mk-2016-08-17: minus inTorqueLoss?? Why not plus? } private TorqueConverterOperatingPoint FindOperatingPoint(NewtonMeter outTorque, @@ -359,7 +357,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl (x.InTorque * x.InAngularVelocity).IsGreaterOrEqual(DataBus.EngineDragPower(x.InAngularVelocity), Constants.SimulationSettings.LineSearchTolerance.SI<Watt>()) ).ToArray(); - if (filtered.Count() == 1) { + if (filtered.Length == 1) { return filtered.First(); } return operatingPointList[0]; @@ -482,7 +480,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public override bool ClutchClosed(Second absTime) { - return DataBus.CycleData.LeftSample.Gear != 0; + return (DataBus.DriverBehavior == DrivingBehavior.Braking + ? DataBus.CycleData.LeftSample.Gear + : DataBus.CycleData.RightSample.Gear) != 0; } #endregion diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/MeasuredSpeedDrivingCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/MeasuredSpeedDrivingCycle.cs index d54e997e837b7f5fa1664823fd1ae42dc0e7b95b..a716c914fae6ec20723f8161dc7c81497f64164e 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/MeasuredSpeedDrivingCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/MeasuredSpeedDrivingCycle.cs @@ -31,17 +31,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { return new DrivingCycleState { Distance = Distance, - VehicleSpeed = VehicleSpeed, }; } public Meter Distance; - public MeterPerSecond VehicleSpeed; public Meter SimulationDistance; public MeterPerSquareSecond Acceleration; } - protected DrivingCycleData Data; + protected readonly DrivingCycleData Data; private bool _isInitializing; protected IEnumerator<DrivingCycleData.DrivingCycleEntry> RightSample { get; set; } protected IEnumerator<DrivingCycleData.DrivingCycleEntry> LeftSample { get; set; } @@ -64,10 +62,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl RightSample.MoveNext(); RightSample.MoveNext(); - var first = LeftSample.Current; PreviousState = new DrivingCycleState { Distance = 0.SI<Meter>(), - VehicleSpeed = first.VehicleTargetSpeed, }; CurrentState = PreviousState.Clone(); } @@ -118,6 +114,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl // calc acceleration from speed diff vehicle to cycle var deltaV = RightSample.Current.VehicleTargetSpeed - DataBus.VehicleSpeed; var deltaT = RightSample.Current.Time - LeftSample.Current.Time; + + if (DataBus.VehicleSpeed.IsSmaller(0)) { + throw new VectoSimulationException("vehicle velocity is smaller than zero"); + } + + if (deltaT.IsSmaller(0)) { + throw new VectoSimulationException("deltaT is smaller than zero"); + } + var acceleration = deltaV / deltaT; var gradient = LeftSample.Current.RoadGradient; DriverAcceleration = acceleration; @@ -190,9 +195,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl response.Acceleration = acceleration; debug.Add(response); - CurrentState.SimulationDistance = acceleration / 2 * dt * dt + PreviousState.VehicleSpeed * dt; + CurrentState.SimulationDistance = acceleration / 2 * dt * dt + DataBus.VehicleSpeed * dt; + if (CurrentState.SimulationDistance.IsSmaller(0)) + throw new VectoSimulationException( + "MeasuredSpeed: Simulation Distance must not be negative. Driving Backward is not allowed."); + CurrentState.Distance = CurrentState.SimulationDistance + PreviousState.Distance; - CurrentState.VehicleSpeed = acceleration * dt + PreviousState.VehicleSpeed; CurrentState.Acceleration = acceleration; return response; diff --git a/VectoCore/VectoCore/Resources/Declaration/SegmentTable.csv b/VectoCore/VectoCore/Resources/Declaration/SegmentTable.csv index 8f88bdc8d56bab902fb4ffdc10a7db21256fdfc8..1918214449d52452225539695b45cff3b9ed18d0 100644 --- a/VectoCore/VectoCore/Resources/Declaration/SegmentTable.csv +++ b/VectoCore/VectoCore/Resources/Declaration/SegmentTable.csv @@ -1,5 +1,5 @@ Valid,Vehicle Category,Axle Conf.,GVW_Min,GVW_Max,HDV class,Body,Trailer,Semitrailer,.vacc file,Cross Wind Correction - Long haul,Cross Wind Correction - Other,Truck Axles - Long haul,Truck Axles - Other,Trailer Axles - Long haul,Trailer Axles - Other,Long haul,Regional delivery,Urban delivery,Municipal utility,Construction,Heavy Urban,Urban,Suburban,Interurban,Coach -0 ,RigidTruck ,4x2 ,0 ,7.5 ,0 , , , ,Truck.vacc, ,RigidSolo , , , , ,- ,pc(R) ,pc(R) ,- ,- ,- ,- ,- ,- ,- +# @@@quam below 7.5t is not considered by VECTO atm. @@@ 0 ,RigidTruck ,4x2 ,0 ,7.5 ,0 , , , ,Truck.vacc, ,RigidSolo , , , , ,- ,pc(R) ,pc(R) ,- ,- ,- ,- ,- ,- ,- 1 ,RigidTruck ,4x2 ,7.5 ,10 ,1 ,B1 , , ,Truck.vacc, ,RigidSolo , ,45/55 , , ,- ,pc(R) ,pc(R) ,- ,- ,- ,- ,- ,- ,- 1 ,Tractor ,4x2 ,7.5 ,10 ,1 ,B1 , , ,Truck.vacc, ,RigidSolo , ,45/55 , , ,- ,pc(R) ,pc(R) ,- ,- ,- ,- ,- ,- ,- 1 ,RigidTruck ,4x2 ,10 ,12 ,2 ,B2 ,T1 , ,Truck.vacc,RigidTrailer ,RigidSolo ,22.5/32.5 ,45/55 ,45/1 , ,pc(R) ,pc(R) ,pc(R) ,- ,- ,- ,- ,- ,- ,- diff --git a/VectoCore/VectoCore/Resources/Declaration/Wheels.csv b/VectoCore/VectoCore/Resources/Declaration/Wheels.csv index 81aef7c3bbcba4c6107c848aedb15e30ab819625..be80d0c0378e617402bcdacbed1f0d62a199c408 100644 --- a/VectoCore/VectoCore/Resources/Declaration/Wheels.csv +++ b/VectoCore/VectoCore/Resources/Declaration/Wheels.csv @@ -1,58 +1,58 @@ Wheel ,cross-sectional width [mm],tire aspect ratio [%],rim diameter [inch],d [mm],Inertia,F [-] -9.5 R17.5 ,241.3 ,0.95 ,17.5 ,842.0 ,4.9 ,3.05 -9.00 R20 ,228.6 ,0.95 ,20 ,1018.0,10.5 ,3.05 -9 R22.5 ,228.6 ,0.95 ,22.5 ,970.0 ,8.9 ,3.05 -10 R17.5 ,254 ,0.95 ,17.5 ,858.0 ,5 ,3.05 -10 R22.5 ,254 ,0.95 ,22.5 ,1020.0,11 ,3.05 -10.00 R20 ,254 ,0.95 ,20 ,1052.0,13.1 ,3.05 -11 R22.5 ,279.4 ,0.95 ,22.5 ,1050.0,14.4 ,3.05 -11.00 R20 ,279.4 ,0.95 ,20 ,1082.0,14.6 ,3.05 -11.00 R22 ,279.4 ,0.95 ,22 ,1050.0,16 ,3.05 -12 R22.5 ,304.8 ,0.95 ,22.5 ,1084.0,16.85 ,3.05 -12.00 R20 ,304.8 ,0.95 ,20 ,1122.0,19.5 ,3.05 -12.00 R24 ,304.8 ,0.95 ,24 ,1226.0,27.7 ,3.05 -12.5 R20 ,317.5 ,0.95 ,20 ,1120 ,12.7 ,3.05 -13 R22.5 ,330.2 ,0.95 ,22.5 ,1124.0,20 ,3.05 -14.00 R20 ,355.6 ,0.95 ,20 ,1238.0,30.8 ,3.05 -14.5 R20 ,368.3 ,0.95 ,20 ,1092 ,14.8 ,3.05 -16.00 R20 ,406.4 ,0.95 ,20 ,1343 ,47.5 ,3.05 -205/75 R17.5,205 ,0.75 ,17.5 ,753.0 ,3.5 ,3.05 -215/75 R17.5,215 ,0.75 ,17.5 ,767.0 ,3.9 ,3.05 -225/70 R17.5,225 ,0.7 ,17.5 ,759.5 ,4 ,3.05 -225/75 R17.5,225 ,0.75 ,17.5 ,782 ,4 ,3.05 -235/75 R17.5,235 ,0.75 ,17.5 ,797.0 ,4.5 ,3.05 -245/70 R17.5,245 ,0.7 ,17.5 ,789.0 ,5.2 ,3.05 -245/70 R19.5,245 ,0.7 ,19.5 ,839.0 ,6 ,3.05 -255/70 R22.5,255 ,0.7 ,22.5 ,930.0 ,9.5 ,3.05 -265/70 R17.5,265 ,0.7 ,17.5 ,817 ,5.6 ,3.05 -265/70 R19.5,265 ,0.7 ,19.5 ,867.0 ,6.5 ,3.05 -275/70 R22.5,275 ,0.7 ,22.5 ,958.0 ,11.9 ,3.05 -275/80 R22.5,275 ,0.8 ,22.5 ,1012.0,12.8 ,3.05 -285/60 R22.5,285 ,0.6 ,22.5 ,914.0 ,10.6 ,3.03 -285/70 R19.5,285 ,0.7 ,19.5 ,895.0 ,7.9 ,3.05 -295/55 R22.5,295 ,0.55 ,22.5 ,896.0 ,10.2 ,3.03 -295/60 R22.5,295 ,0.6 ,22.5 ,926.0 ,10.8 ,3.03 -295/80 R22.5,295 ,0.8 ,22.5 ,1044.0,15.5 ,3.05 -305/60 R22.5,305 ,0.6 ,22.5 ,938.0 ,11.4 ,3.03 -305/70 R19.5,305 ,0.7 ,19.5 ,923.0 ,9.2 ,3.05 -305/70 R22.5,305 ,0.7 ,22.5 ,1000.0,13.9 ,3.05 -305/75 R24.5,305 ,0.75 ,24.5 ,1079.8,21.2 ,3.05 -315/45 R22.5,315 ,0.45 ,22.5 ,856.0 ,9.9 ,3.03 -315/60 R22.5,315 ,0.6 ,22.5 ,950.0 ,12.8 ,3.03 -315/70 R22.5,315 ,0.7 ,22.5 ,1014.0,14.9 ,3.05 -315/80 R22.5,315 ,0.8 ,22.5 ,1076.0,17.6 ,3.05 -325/95 R24 ,325 ,0.95 ,24 ,1228.0,27.6 ,3.05 -335/80 R20 ,335 ,0.8 ,20 ,1044.0,13.5 ,3.05 -355/50 R22.5,355 ,0.5 ,22.5 ,928.0 ,12.2 ,3.03 -365/70 R22.5,365 ,0.7 ,22.5 ,1084.0,18.6 ,3.05 -365/80 R20 ,365 ,0.8 ,20 ,1092.0,17.2 ,3.05 -365/85 R20 ,365 ,0.85 ,20 ,1128.0,22.5 ,3.05 -375/45 R22.5,375 ,0.45 ,22.5 ,910.0 ,11.2 ,3.03 -375/50 R22.5,375 ,0.5 ,22.5 ,948.0 ,13 ,3.03 -375/90 R22.5,375 ,0.9 ,22.5 ,1246.5,33.8 ,3.05 -385/55 R22.5,385 ,0.55 ,22.5 ,996.0 ,15.9 ,3.03 -385/65 R22.5,385 ,0.65 ,22.5 ,1072.0,19.2 ,3.03 -395/85 R20 ,395 ,0.85 ,20 ,1180.0,27.9 ,3.05 -425/65 R22.5,425 ,0.65 ,22.5 ,1124.0,22.5 ,3.03 -495/45 R22.5,495 ,0.45 ,22.5 ,1018.0,20.7 ,3.03 -525/65 R20.5,525 ,0.65 ,20.5 ,1203.2,35 ,3.03 \ No newline at end of file +9.00 R20 ,258.00 ,0.95 ,20 ,1018.0,10.5 ,3.05 +9 R22.5 ,230.00 ,0.95 ,22.5 ,970.0 ,8.9 ,3.05 +9.5 R17.5 ,240.00 ,0.95 ,17.5 ,842.0 ,4.9 ,3.05 +10 R17.5 ,254.00 ,0.95 ,17.5 ,858.0 ,5 ,3.05 +10 R22.5 ,254.00 ,0.95 ,22.5 ,1020.0,11 ,3.05 +10.00 R20 ,275.00 ,0.95 ,20 ,1052.0,13.1 ,3.05 +11 R22.5 ,279.00 ,0.95 ,22.5 ,1050.0,14.4 ,3.05 +11.00 R20 ,286.00 ,0.95 ,20 ,1082.0,14.6 ,3.05 +11.00 R22.5 ,279.00 ,0.95 ,22.5 ,1050.0,16 ,3.05 +12 R22.5 ,300.00 ,0.95 ,22.5 ,1084.0,16.85 ,3.05 +12.00 R20 ,313.00 ,0.95 ,20 ,1122.0,19.5 ,3.05 +12.00 R24 ,313.00 ,0.95 ,24 ,1226.0,27.7 ,3.05 +12.5 R20 ,317.50 ,0.95 ,20 ,1120 ,12.7 ,3.05 +13 R22.5 ,320.00 ,0.95 ,22.5 ,1124.0,20 ,3.05 +14.00 R20 ,370.00 ,0.95 ,20 ,1238.0,30.8 ,3.05 +14.5 R20 ,368.30 ,0.95 ,20 ,1092 ,14.8 ,3.05 +16.00 R20 ,406.40 ,0.95 ,20 ,1343 ,47.5 ,3.05 +205/75 R17.5,205.00 ,0.75 ,17.5 ,753.0 ,3.5 ,3.05 +215/75 R17.5,212.00 ,0.75 ,17.5 ,767.0 ,3.9 ,3.05 +225/70 R17.5,226.00 ,0.7 ,17.5 ,761.0 ,4 ,3.05 +225/75 R17.5,226.00 ,0.75 ,17.5 ,783.0 ,4 ,3.05 +235/75 R17.5,233.00 ,0.75 ,17.5 ,797.0 ,4.5 ,3.05 +245/70 R17.5,248.00 ,0.7 ,17.5 ,789.0 ,5.2 ,3.05 +245/70 R19.5,248.00 ,0.7 ,19.5 ,839.0 ,6 ,3.05 +255/70 R22.5,255.00 ,0.7 ,22.5 ,930.0 ,9.5 ,3.05 +265/70 R17.5,262.00 ,0.7 ,17.5 ,817.0 ,5.6 ,3.05 +265/70 R19.5,262.00 ,0.7 ,19.5 ,867.0 ,6.5 ,3.05 +275/70 R22.5,276.00 ,0.7 ,22.5 ,958.0 ,11.9 ,3.05 +275/80 R22.5,276.00 ,0.8 ,22.5 ,1012.0,12.8 ,3.05 +285/60 R22.5,285.00 ,0.6 ,22.5 ,914.0 ,10.6 ,3.03 +285/70 R19.5,283.00 ,0.7 ,19.5 ,895.0 ,7.9 ,3.05 +295/55 R22.5,292.00 ,0.55 ,22.5 ,896.0 ,10.2 ,3.03 +295/60 R22.5,292.00 ,0.6 ,22.5 ,926.0 ,10.8 ,3.03 +295/80 R22.5,298.00 ,0.8 ,22.5 ,1044.0,15.5 ,3.05 +305/60 R22.5,306.00 ,0.6 ,22.5 ,938.0 ,11.4 ,3.03 +305/70 R19.5,305.00 ,0.7 ,19.5 ,923.0 ,9.2 ,3.05 +305/70 R22.5,305.00 ,0.7 ,22.5 ,1000.0,13.9 ,3.05 +305/75 R24.5,305.00 ,0.75 ,24.5 ,1080.0,21.2 ,3.05 +315/45 R22.5,307.00 ,0.45 ,22.5 ,856.0 ,9.9 ,3.03 +315/60 R22.5,313.00 ,0.6 ,22.5 ,950.0 ,12.8 ,3.03 +315/70 R22.5,312.00 ,0.7 ,22.5 ,1014.0,14.9 ,3.05 +315/80 R22.5,312.00 ,0.8 ,22.5 ,1076.0,17.6 ,3.05 +325/95 R24 ,325.00 ,0.95 ,24 ,1228.0,27.6 ,3.05 +335/80 R20 ,340.00 ,0.8 ,20 ,1044.0,13.5 ,3.05 +355/50 R22.5,361.00 ,0.5 ,22.5 ,928.0 ,12.2 ,3.03 +365/70 R22.5,375.00 ,0.7 ,22.5 ,1084.0,18.6 ,3.05 +365/80 R20 ,360.00 ,0.8 ,20 ,1092.0,17.2 ,3.05 +365/85 R20 ,364.00 ,0.85 ,20 ,1128.0,22.5 ,3.05 +375/45 R22.5,372.00 ,0.45 ,22.5 ,910.0 ,11.2 ,3.03 +375/50 R22.5,374.00 ,0.5 ,22.5 ,948.0 ,13 ,3.03 +375/90 R22.5,369.00 ,0.9 ,22.5 ,1248.0,33.8 ,3.05 +385/55 R22.5,386.00 ,0.55 ,22.5 ,996.0 ,15.9 ,3.03 +385/65 R22.5,389.00 ,0.65 ,22.5 ,1072.0,19.2 ,3.03 +395/85 R20 ,386.00 ,0.85 ,20 ,1180.0,27.9 ,3.05 +425/65 R22.5,430.00 ,0.65 ,22.5 ,1124.0,22.5 ,3.03 +495/45 R22.5,500.00 ,0.45 ,22.5 ,1018.0,20.7 ,3.03 +525/65 R20.5,530.00 ,0.65 ,20.5 ,1203.0,35 ,3.03 \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/Integration/EngineOnlyCycle/EngineOnlyCycleTest.cs b/VectoCore/VectoCoreTest/Integration/EngineOnlyCycle/EngineOnlyCycleTest.cs index c0302b2db80ae86fad02fb8a91e21076d5556ee3..16b80d77c4b51754d4f76759e83327438a4f2402 100644 --- a/VectoCore/VectoCoreTest/Integration/EngineOnlyCycle/EngineOnlyCycleTest.cs +++ b/VectoCore/VectoCoreTest/Integration/EngineOnlyCycle/EngineOnlyCycleTest.cs @@ -104,7 +104,7 @@ namespace TUGraz.VectoCore.Tests.Integration.EngineOnlyCycle } modData.Finish(VectoRun.Status.Success); - ResultFileHelper.TestModFile(modalResultFile, modFile + Constants.FileExtensions.ModDataFile, testVelocity: false); + ResultFileHelper.TestModFile(modalResultFile, modFile + Constants.FileExtensions.ModDataFile); } [TestCase] diff --git a/VectoCore/VectoCoreTest/Models/Declaration/ShiftPolygonTest.cs b/VectoCore/VectoCoreTest/Models/Declaration/ShiftPolygonTest.cs index 4d27acea0be018ec2404ee430b1af5796bdc21b0..58d99663d8de1441a0133fd7739c9e0e2dc4bfce 100644 --- a/VectoCore/VectoCoreTest/Models/Declaration/ShiftPolygonTest.cs +++ b/VectoCore/VectoCoreTest/Models/Declaration/ShiftPolygonTest.cs @@ -389,25 +389,30 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration }; engineData.FullLoadCurve.EngineData = engineData; - var gearboxData = new JSONGearboxDataV5(JSONInputDataFactory.ReadFile(gearboxFile), gearboxFile); + var gearboxData = new JSONGearboxDataV6(JSONInputDataFactory.ReadFile(gearboxFile), gearboxFile); var shiftPolygons = new List<ShiftPolygon>(); var downshiftTransformed = new List<List<Point>>(); var downshiftOrig = new List<List<Point>>(); var upshiftOrig = new List<List<Point>>(); + var fullLoadCurves = new List<EngineFullLoadCurve>(); for (var i = 0; i < gearboxData.Gears.Count; i++) { - shiftPolygons.Add(DeclarationData.Gearbox.ComputeShiftPolygon(i, engineData.FullLoadCurve, gearboxData.Gears, + var fullLoadCurve = AbstractSimulationDataAdapter.IntersectFullLoadCurves(engineData.FullLoadCurve, + gearboxData.Gears[i].MaxTorque); + shiftPolygons.Add(DeclarationData.Gearbox.ComputeShiftPolygon(i, fullLoadCurve, gearboxData.Gears, engineData, axlegearRatio, rdyn)); List<Point> tmp1, tmp2, tmp3; - ShiftPolygonComparison.ComputShiftPolygonPoints(i, engineData.FullLoadCurve, gearboxData.Gears, + + ShiftPolygonComparison.ComputShiftPolygonPoints(i, fullLoadCurve, gearboxData.Gears, engineData, axlegearRatio, rdyn, out tmp1, out tmp2, out tmp3); upshiftOrig.Add(tmp1); downshiftTransformed.Add(tmp2); downshiftOrig.Add(tmp3); + fullLoadCurves.Add(fullLoadCurve); } - ShiftPolygonDrawer.DrawShiftPolygons(Path.GetDirectoryName(gearboxFile), engineData.FullLoadCurve, shiftPolygons, - "scania_fullload_shiftpolygon-test.png", + ShiftPolygonDrawer.DrawShiftPolygons(Path.GetDirectoryName(gearboxFile), fullLoadCurves, shiftPolygons, + "daimler_fullload_shiftpolygon-test_3.png", DeclarationData.Gearbox.TruckMaxAllowedSpeed / rdyn * axlegearRatio * gearboxData.Gears.Last().Ratio, upshiftOrig, downshiftTransformed, downshiftOrig); } @@ -458,22 +463,26 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration var shiftPolygons = new List<ShiftPolygon>(); var downshiftTransformed = new List<List<Point>>(); var upshiftOrig = new List<List<Point>>(); + var fullLoadCurves = new List<EngineFullLoadCurve>(); for (var i = 0; i < gearboxData.Gears.Count; i++) { + var fullLoadCurve = AbstractSimulationDataAdapter.IntersectFullLoadCurves(engineData.FullLoadCurve, + gearboxData.Gears[i].MaxTorque); shiftPolygons.Add( - DeclarationData.Gearbox.ComputeShiftPolygon(i, engineData.FullLoadCurve, gearboxData.Gears, + DeclarationData.Gearbox.ComputeShiftPolygon(i, fullLoadCurve, gearboxData.Gears, engineData, axlegearRatio, rdyn.SI<Meter>()) ); List<Point> tmp1, tmp2, tmp3; - ComputShiftPolygonPoints(i, engineData.FullLoadCurve, gearboxData.Gears, + ComputShiftPolygonPoints(i, fullLoadCurve, gearboxData.Gears, engineData, axlegearRatio, rdyn.SI<Meter>(), out tmp1, out tmp2, out tmp3); upshiftOrig.Add(tmp1); downshiftTransformed.Add(tmp2); + fullLoadCurves.Add(fullLoadCurve); } var imageFile = Path.GetDirectoryName(gearboxFile) + "_" + Path.GetFileNameWithoutExtension(gearboxFile) + "_" + Path.GetFileNameWithoutExtension(engineFldFile) + ".png"; - ShiftPolygonDrawer.DrawShiftPolygons(Path.GetDirectoryName(gearboxFile), engineData.FullLoadCurve, shiftPolygons, + ShiftPolygonDrawer.DrawShiftPolygons(Path.GetDirectoryName(gearboxFile), fullLoadCurves, shiftPolygons, imageFile, DeclarationData.Gearbox.TruckMaxAllowedSpeed / rdyn.SI<Meter>() * axlegearRatio * gearboxData.Gears.Last().Ratio, upshiftOrig, downshiftTransformed); diff --git a/VectoCore/VectoCoreTest/Models/Simulation/AuxTests.cs b/VectoCore/VectoCoreTest/Models/Simulation/AuxTests.cs index d06e55cc5c261873e7f888532dadd4bef3abf2ab..9f87714bc7943e9d4b9767c46cc078b5f2f44f4e 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/AuxTests.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/AuxTests.cs @@ -109,7 +109,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation var testColumns = new[] { "P_aux_FAN", "P_aux_STP", "P_aux_AC", "P_aux_ES", "P_aux_PS", "P_aux" }; ResultFileHelper.TestModFile(@"TestData\Results\EngineOnlyCycles\AuxWriteModFileSumFile.vmod", - @"AuxWriteModFileSumFile.vmod", testColumns, testVelocity: false); + @"AuxWriteModFileSumFile.vmod", testColumns); ResultFileHelper.TestSumFile(@"TestData\Results\EngineOnlyCycles\AuxWriteModFileSumFile.vsum", @"AuxWriteModFileSumFile.vsum"); } diff --git a/VectoCore/VectoCoreTest/Models/Simulation/PwheelModeTests.cs b/VectoCore/VectoCoreTest/Models/Simulation/PwheelModeTests.cs index 2cbb49582202e2642fc97763b327d6d3ddcd13da..d3f9f0b7ed654b93e6f6f5c5b6125009ebf7049b 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/PwheelModeTests.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/PwheelModeTests.cs @@ -166,7 +166,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation ResultFileHelper.TestSumFile(@"TestData\Pwheel\Results\Pwheel.vsum", @"TestData\Pwheel\Pwheel.vsum"); ResultFileHelper.TestModFile(@"TestData\Pwheel\Results\Pwheel_Gear2_pt1_rep1_actual.vmod", - @"TestData\Pwheel\Pwheel_Gear2_pt1_rep1_actual.vmod", testVelocity: false); + @"TestData\Pwheel\Pwheel_Gear2_pt1_rep1_actual.vmod"); } /// <summary> @@ -194,7 +194,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation ResultFileHelper.TestSumFile(@"TestData\Pwheel\Results\Pwheel_ultimate.vsum", @"TestData\Pwheel\Pwheel_ultimate.vsum"); ResultFileHelper.TestModFile(@"TestData\Pwheel\Results\Pwheel_ultimate_RD_#1_Pwheel_AuxStd.vmod", - @"TestData\Pwheel\Pwheel_ultimate_RD_#1_Pwheel_AuxStd.vmod", testVelocity: false); + @"TestData\Pwheel\Pwheel_ultimate_RD_#1_Pwheel_AuxStd.vmod"); } } } \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/Models/Simulation/SimulationTests.cs b/VectoCore/VectoCoreTest/Models/Simulation/SimulationTests.cs index 9a6632f0de5fb2b539fe0b7810503d28a9403f4f..98e683de89efbbaea66c7563856b7abd60805b20 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/SimulationTests.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/SimulationTests.cs @@ -69,7 +69,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation Assert.IsTrue(job.FinishedWithoutErrors); - ResultFileHelper.TestModFile(expected, actual, testVelocity: false); + ResultFileHelper.TestModFile(expected, actual); } [TestMethod] @@ -89,7 +89,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation Assert.IsTrue(r.Run.FinishedWithoutErrors, string.Format("{0}", r.ExecException)); } - ResultFileHelper.TestModFile(expected, actual, testVelocity: false); + ResultFileHelper.TestModFile(expected, actual); } public IVectoRun CreateRun(string resultFileName) @@ -136,7 +136,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation @"TestData\Jobs\24t Coach EngineOnly_Engine Only1.vmod", @"TestData\Jobs\24t Coach EngineOnly_Engine Only2.vmod", @"TestData\Jobs\24t Coach EngineOnly_Engine Only3.vmod" - }, testVelocity: false) + }) ; } } diff --git a/VectoCore/VectoCoreTest/Utils/ResultFileHelper.cs b/VectoCore/VectoCoreTest/Utils/ResultFileHelper.cs index 4b9c1bdfc404d50dd0de65192c8c7019323038c9..d747cfc73d2321350bc60d36dedfbba13df41307 100644 --- a/VectoCore/VectoCoreTest/Utils/ResultFileHelper.cs +++ b/VectoCore/VectoCoreTest/Utils/ResultFileHelper.cs @@ -43,13 +43,13 @@ namespace TUGraz.VectoCore.Tests.Utils public static class ResultFileHelper { public static void TestModFile(string expectedFile, string actualFile, string[] testColumns = null, - bool testRowCount = true, bool testVelocity = true) + bool testRowCount = true) { - TestModFiles(new[] { expectedFile }, new[] { actualFile }, testColumns, testRowCount, testVelocity); + TestModFiles(new[] { expectedFile }, new[] { actualFile }, testColumns, testRowCount); } public static void TestModFiles(IEnumerable<string> expectedFiles, IEnumerable<string> actualFiles, - string[] testColumns = null, bool testRowcount = true, bool testVelocity = true) + string[] testColumns = null, bool testRowcount = true) { var resultFiles = expectedFiles.ZipAll(actualFiles, (expectedFile, actualFile) => new { expectedFile, actualFile }); foreach (var result in resultFiles) { @@ -59,17 +59,31 @@ namespace TUGraz.VectoCore.Tests.Utils var expected = VectoCSVFile.Read(result.expectedFile); var actual = VectoCSVFile.Read(result.actualFile); - if (testVelocity) { - Assert.IsTrue( - actual.Rows.Cast<DataRow>() + if (actual.Columns.Contains(ModalResultField.v_act.GetShortCaption()) && + !double.IsNaN(actual.Rows[0].Field<string>(ModalResultField.v_act.GetShortCaption()).ToDouble(double.NaN))) { + // test v_act >= 0 + Assert.IsTrue(actual.Rows.Cast<DataRow>() .All(r => r.ParseDouble(ModalResultField.v_act.GetShortCaption()).IsGreaterOrEqual(0)), "v_act must not be negative."); - Assert.IsTrue( - actual.Rows.Cast<DataRow>() + + // test v_targ >= 0 + Assert.IsTrue(actual.Rows.Cast<DataRow>() .All(r => r.ParseDouble(ModalResultField.v_targ.GetShortCaption()).IsGreaterOrEqual(0)), "v_targ must not be negative."); } + if (actual.Columns.Contains(ModalResultField.dist.GetShortCaption()) && + !double.IsNaN(actual.Rows[0].Field<string>(ModalResultField.dist.GetShortCaption()).ToDouble(double.NaN))) { + // test distance monotonous increasing + + var distPrev = actual.Rows[0].ParseDouble(ModalResultField.dist.GetShortCaption()); + for (var i = 1; i < actual.Rows.Count; i++) { + var dist = actual.Rows[i].ParseDouble(ModalResultField.dist.GetShortCaption()); + Assert.IsTrue(distPrev.IsSmallerOrEqual(dist), "distance must not decrease."); + distPrev = dist; + } + } + if (testRowcount) { Assert.AreEqual(expected.Rows.Count, actual.Rows.Count, string.Format("Moddata: Row count differs.\nExpected {0} Rows in {1}\nGot {2} Rows in {3}", expected.Rows.Count, diff --git a/VectoCore/VectoCoreTest/Utils/ShiftPolygonDrawer.cs b/VectoCore/VectoCoreTest/Utils/ShiftPolygonDrawer.cs index 994b829230837f6f68883df95ca89af7567233a4..3f20a218b2d4274b7df34d5f03e978c712061cd1 100644 --- a/VectoCore/VectoCoreTest/Utils/ShiftPolygonDrawer.cs +++ b/VectoCore/VectoCoreTest/Utils/ShiftPolygonDrawer.cs @@ -52,7 +52,7 @@ namespace TUGraz.VectoCore.Tests.Utils private static Size _diagramSize = new Size(1000, 800); - public static void DrawShiftPolygons(string title, EngineFullLoadCurve engineFld, List<ShiftPolygon> polygons, + public static void DrawShiftPolygons(string title, List<EngineFullLoadCurve> engineFld, List<ShiftPolygon> polygons, string imageFileName, PerSecond speed85kmh, List<List<Point>> upshiftOrig = null, List<List<Point>> downshiftTransformed = null, List<List<Point>> downshiftOrig = null) { @@ -62,7 +62,7 @@ namespace TUGraz.VectoCore.Tests.Utils var chart = new Chart() { Size = new Size((int)(_diagramSize.Width * numCols), (int)(_diagramSize.Height * numRows)) }; - var maxX = engineFld.FullLoadEntries.Last().EngineSpeed.Value() / Constants.RPMToRad * 1.1; + var maxX = engineFld.First().FullLoadEntries.Last().EngineSpeed.Value() / Constants.RPMToRad * 1.1; AddLegend(chart); @@ -70,8 +70,8 @@ namespace TUGraz.VectoCore.Tests.Utils foreach (var shiftPolygon in polygons) { var chartArea = AddChartArea(chart, "Gear " + (i + 1), "Engine Speed", "Torque", 0, maxX); - PlotPower(engineFld, chartArea, chart, "engine power " + i); - PlotFLD(engineFld, speed85kmh, chartArea, chart, "Engine Full Load " + i); + PlotPower(engineFld[i], chartArea, chart, "engine power " + i); + PlotFLD(engineFld[i], speed85kmh, chartArea, chart, "Engine Full Load " + i); if (upshiftOrig != null && i < upshiftOrig.Count) { PlotShiftLine("UpshiftOrig " + i, chartArea, chart, Color.Gray,