diff --git a/Generic Vehicles/Declaration Mode/12t Delivery Truck/12t Delivery Truck.vmap b/Generic Vehicles/Declaration Mode/12t Delivery Truck/12t Delivery Truck.vmap index f7ad107b968d22126c862db3a0d24a78c7ba3f14..8d0ccfd038e234717b6cd5b95d91ab5b2b62e883 100644 --- a/Generic Vehicles/Declaration Mode/12t Delivery Truck/12t Delivery Truck.vmap +++ b/Generic Vehicles/Declaration Mode/12t Delivery Truck/12t Delivery Truck.vmap @@ -183,4 +183,6 @@ engine speed [1/min],torque [Nm],fuel consumption [g/h] 2600,400,23315 2600,480,28351 2700,-150,0 -2700,0,5900 \ No newline at end of file +2700,0,5900 +3000,1200,40000 +600,1200,40000 \ No newline at end of file diff --git a/Generic Vehicles/Declaration Mode/12t Delivery Truck/Direct Gear.vtlm b/Generic Vehicles/Declaration Mode/12t Delivery Truck/Direct Gear.vtlm index 0e5b9b3eb574682a62d048c9e995fbe62e6e7694..a55ff21acae9b105850d33fae94498b42c6ffca1 100644 --- a/Generic Vehicles/Declaration Mode/12t Delivery Truck/Direct Gear.vtlm +++ b/Generic Vehicles/Declaration Mode/12t Delivery Truck/Direct Gear.vtlm @@ -116,3 +116,5 @@ Input Speed [rpm],Input Torque [Nm],Torque Loss [Nm],Eff [-] 2000,-1000,10.94, 2200,-1000,11.336, 2400,-1000,11.732, +0,1300,12 +2400,1300,12 diff --git a/Generic Vehicles/Declaration Mode/40t Long Haul Truck/40t_Long_Haul_Truck.vmap b/Generic Vehicles/Declaration Mode/40t Long Haul Truck/40t_Long_Haul_Truck.vmap index 26c035cad9373137a6be4195e75a204b3625a22c..a201ed96fb030c871f8d13df05a11556b3e8a317 100644 --- a/Generic Vehicles/Declaration Mode/40t Long Haul Truck/40t_Long_Haul_Truck.vmap +++ b/Generic Vehicles/Declaration Mode/40t Long Haul Truck/40t_Long_Haul_Truck.vmap @@ -111,3 +111,5 @@ 2100,800,35717 2100,1000,45643 2100,1100,50653 +2100,2400,60000 +560,2400,60000 \ No newline at end of file diff --git a/Generic Vehicles/Declaration Mode/40t Long Haul Truck/Direct Gear.vtlm b/Generic Vehicles/Declaration Mode/40t Long Haul Truck/Direct Gear.vtlm index fa171bece8e04fad0fd78574764f3a4f17465444..5edeb690649e881d3604440136e1af4e1aa8ecd2 100644 --- a/Generic Vehicles/Declaration Mode/40t Long Haul Truck/Direct Gear.vtlm +++ b/Generic Vehicles/Declaration Mode/40t Long Haul Truck/Direct Gear.vtlm @@ -191,3 +191,4 @@ Input Speed [rpm],Input Torque [Nm],Torque Loss [Nm] 1700,-1000,18.662 1900,-1000,19.674 2100,-1000,20.686 +0,0,0 \ No newline at end of file diff --git a/Generic Vehicles/Declaration Mode/40t Long Haul Truck/Indirect Gear.vtlm b/Generic Vehicles/Declaration Mode/40t Long Haul Truck/Indirect Gear.vtlm index 0198efcc3633373b82fdd76362e1b2080f0dbd1e..26b819e032cf682602a35cb03d83ff05aade29fb 100644 --- a/Generic Vehicles/Declaration Mode/40t Long Haul Truck/Indirect Gear.vtlm +++ b/Generic Vehicles/Declaration Mode/40t Long Haul Truck/Indirect Gear.vtlm @@ -191,3 +191,4 @@ Input Speed [rpm],Input Torque [Nm],Torque Loss [Nm] 1700,-1000,33.662 1900,-1000,34.674 2100,-1000,35.686 +0,0,0 diff --git a/VectoCore/ModelbasedTests/DriverStrategy/SimpleCycles.cs b/VectoCore/ModelbasedTests/DriverStrategy/SimpleCycles.cs index a9edbb1a1a17559dab3fde2b0e60954cd5d38256..e3c8cc7e4b0df309ceed8d8a0c7e0174e2558542 100644 --- a/VectoCore/ModelbasedTests/DriverStrategy/SimpleCycles.cs +++ b/VectoCore/ModelbasedTests/DriverStrategy/SimpleCycles.cs @@ -70,11 +70,11 @@ namespace TUGraz.VectoCore.ModelbasedTests.DriverStrategy return slopeStr; } - [ - TestCase(0, 80), TestCase(80, 0), TestCase(80, 80), - TestCase(0, 60), TestCase(60, 0), TestCase(60, 60), - TestCase(0, 40), TestCase(40, 0), TestCase(40, 40), - TestCase(0, 20), TestCase(20, 0), TestCase(20, 20), + [Category("LongRunning"), + TestCase(0, 80), TestCase(80, 0), TestCase(80, 80), + TestCase(0, 60), TestCase(60, 0), TestCase(60, 60), + TestCase(0, 40), TestCase(40, 0), TestCase(40, 40), + TestCase(0, 20), TestCase(20, 0), TestCase(20, 20), ] public void Truck_AllSlopes(double v1, double v2) { @@ -100,11 +100,11 @@ namespace TUGraz.VectoCore.ModelbasedTests.DriverStrategy } } - [ - TestCase(0, 80), TestCase(80, 0), TestCase(80, 80), - TestCase(0, 60), TestCase(60, 0), TestCase(60, 60), - TestCase(0, 40), TestCase(40, 0), TestCase(40, 40), - TestCase(0, 20), TestCase(20, 0), TestCase(20, 20), + [Category("LongRunning"), + TestCase(0, 80), TestCase(80, 0), TestCase(80, 80), + TestCase(0, 60), TestCase(60, 0), TestCase(60, 60), + TestCase(0, 40), TestCase(40, 0), TestCase(40, 40), + TestCase(0, 20), TestCase(20, 0), TestCase(20, 20), ] public void Coach_AllSlopes(double v1, double v2) { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/CrossWindCorrectionCurveReader.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/CrossWindCorrectionCurveReader.cs index a34b7b0fbd9cbdab2f5fd9de5ab14d8711d4423b..a85875497dc40ca840f44f43b79256803965ff96 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/CrossWindCorrectionCurveReader.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/CrossWindCorrectionCurveReader.cs @@ -50,7 +50,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data EffectiveCrossSectionArea = aerodynamicDragArea }, new CrossWindCorrectionEntry { - Velocity = 100.KMPHtoMeterPerSecond(), + Velocity = 150.KMPHtoMeterPerSecond(), EffectiveCrossSectionArea = aerodynamicDragArea } }.ToList(); @@ -91,7 +91,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data return ParseCdxABetaFromColumnIndices(betaTable); } - protected static List<CrossWindCorrectionEntry> ParseSpeedDependent(DataTable data, SquareMeter aerodynamicDragArea) { @@ -172,7 +171,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data public const string DeltaCdxA = "delta CdA"; } - public class AirDragBetaEntry { public double Beta; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/CrosswindCorrectionCdxALookup.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/CrosswindCorrectionCdxALookup.cs index d492bc51093ef866c247c3f5f2f40b1622cbaa20..9e29d58e916a96ec70edb0e445c5222f4949abc6 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/CrosswindCorrectionCdxALookup.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/CrosswindCorrectionCdxALookup.cs @@ -35,7 +35,6 @@ using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Models.Simulation.DataBus; using TUGraz.VectoCore.Utils; - namespace TUGraz.VectoCore.Models.SimulationComponent.Data { public class CrosswindCorrectionCdxALookup : LoggingObject, ICrossWindCorrection @@ -73,7 +72,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data //Log.Error(_data.CrossWindCorrectionMode == CrossWindCorrectionMode.VAirBetaLookupTable // ? string.Format("CdExtrapol β = {0}", x) // : string.Format("CdExtrapol v = {0}", x)); - Log.Error("CdExtrapol v = {0}", x); + Log.Error("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, diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/TransmissionLossMap.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/TransmissionLossMap.cs index a5c2988fffdf2d25bbe9d59ca9ebb0ddbf53a1d3..11144a9f162d2f75293760330c45eafc302f752a 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/TransmissionLossMap.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/TransmissionLossMap.cs @@ -64,6 +64,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox public bool Extrapolated { get { return _lossMap.Extrapolated; } + set { _lossMap.Extrapolated = value; } + } + + public void DrawGraph() + { + _lossMap.DrawGraph(); } public string GearName { get; private set; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs index 448907ed6a76df6d4d07ce1ebadae0ed35034a31..bfeeaef886f2f778e688a2c8743fb37771641cd7 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs @@ -38,7 +38,6 @@ 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; @@ -173,7 +172,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var avgEngineSpeed = (PreviousState.EngineSpeed + CurrentState.EngineSpeed) / 2.0; CurrentState.EngineTorqueOut = torqueOut; CurrentState.FullDragTorque = ModelData.FullLoadCurve.DragLoadStationaryTorque(avgEngineSpeed); - var dynamicFullLoadPower = ComputeFullLoadPower(angularVelocity, dt); + var dynamicFullLoadPower = ComputeFullLoadPower(avgEngineSpeed, dt); CurrentState.DynamicFullLoadTorque = dynamicFullLoadPower / avgEngineSpeed; CurrentState.InertiaTorqueLoss = Formulas.InertiaPower(angularVelocity, PreviousState.EngineSpeed, ModelData.Inertia, dt) / @@ -339,8 +338,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl container[ModalResultField.Tq_drag] = CurrentState.FullDragTorque; try { - var fc = ModelData.ConsumptionMap.GetFuelConsumption(CurrentState.EngineTorque, avgEngineSpeed, - allowExtrapolation: (DataBus.ExecutionMode != ExecutionMode.Declaration)); + var fc = ModelData.ConsumptionMap.GetFuelConsumption(CurrentState.EngineTorque, avgEngineSpeed); //TODO mk-2015-11-11: calculate aux start stop correction var fcAux = fc; @@ -354,19 +352,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl container[ModalResultField.FCWHTCc] = fcWHTC; container[ModalResultField.FCAAUX] = fcAAUX; container[ModalResultField.FCFinal] = fcFinal; - - if (ModelData.ConsumptionMap.Extrapolated) { - Log.Warn("FuelMap Extrapolated: n_eng_avg: {0} Tq: {1}, FC: {2}", avgEngineSpeed.ConvertTo().Rounds.Per.Minute, - CurrentState.EngineTorque, fc); - } - } catch (VectoException ex) { - Log.Warn("FuelMap: {0} n_eng_avg: {1} Tq: {2}", ex.Message, avgEngineSpeed.ConvertTo().Rounds.Per.Minute, + } catch (Exception) { + Log.Error("FuelMap Extrapolated: n_eng_avg: {0} Tq: {1}", avgEngineSpeed.ConvertTo().Rounds.Per.Minute, CurrentState.EngineTorque); - container[ModalResultField.FCMap] = null; - container[ModalResultField.FCAUXc] = null; - container[ModalResultField.FCWHTCc] = null; - container[ModalResultField.FCAAUX] = null; - container[ModalResultField.FCFinal] = null; + throw; } } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs index 9d4010fde971bf2e7447c15e657a4bb7f3124487..27a6ef06c48f37773e31320feb5976ad318309c7 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs @@ -736,6 +736,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } ); } + }). + Case<ResponseGearShift>(r => { + Log.Info("Got GearShift response, performing roll action..."); + response = Driver.DrivingActionRoll(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient); }); break; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs index cbac7b8de5ad70e9f616319885d9bd032655c2af..fa53ac27fbf347d8d0e0889f71bfd08a4db49228 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs @@ -429,6 +429,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl retVal.Switch(). Case<ResponseSuccess>(). + Case<ResponseGearShift>(). Case<ResponseFailTimeInterval>(r => retVal = new ResponseDrivingCycleDistanceExceeded() { Source = this, diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs index b4930376aec6f4a6db3e66b6e5f0566159e33c06..d20b7faee1ebb223e8c7e5b24002e22e5a1932bb 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs @@ -448,6 +448,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Disengaged = false; _engageTime = -double.MaxValue.SI<Second>(); } + ModelData.Gears[Gear].LossMap.Extrapolated = false; AdvanceState(); } diff --git a/VectoCore/VectoCore/OutputData/ModalDataContainer.cs b/VectoCore/VectoCore/OutputData/ModalDataContainer.cs index 6b2e33f3ef9daf44a6edf4b832e437364669518c..8fb1dfe27b704da9ab3d2f7e668f8f7475bd1d7e 100644 --- a/VectoCore/VectoCore/OutputData/ModalDataContainer.cs +++ b/VectoCore/VectoCore/OutputData/ModalDataContainer.cs @@ -274,12 +274,11 @@ namespace TUGraz.VectoCore.OutputData object[] remainingRow = null; var gearsList = new Dictionary<object, Second>(3); - var v_act = 0.SI<MeterPerSecond>(); + var v_act = data.Rows.Cast<DataRow>().First().Field<MeterPerSecond>((int)ModalResultField.v_act); foreach (DataRow row in data.Rows) { var currentDt = row.Field<Second>((int)ModalResultField.simulationInterval); distance = row.Field<Meter>((int)ModalResultField.dist); - v_act = (MeterPerSecond)row[(int)ModalResultField.v_act]; // if current + remaining time >= 1 second: take remaining row and split up currentRow to fill up 1 second. if (remainingDt > 0 && remainingDt + currentDt >= 1) { diff --git a/VectoCore/VectoCore/Utils/DelaunayMap.cs b/VectoCore/VectoCore/Utils/DelaunayMap.cs index 321c0aa3ba4c2dcafe40748dea24340b74caeed2..b956dc5178dda859d04b7b441cd3936a66c80340 100644 --- a/VectoCore/VectoCore/Utils/DelaunayMap.cs +++ b/VectoCore/VectoCore/Utils/DelaunayMap.cs @@ -36,7 +36,6 @@ using System.Drawing; using System.IO; using System.Linq; using System.Threading; -using System.Threading.Tasks; using System.Windows.Forms.DataVisualization.Charting; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; @@ -130,8 +129,9 @@ namespace TUGraz.VectoCore.Utils } } +#if TRACE DrawGraph(pointCount, triangles, superTriangle, points); - +#endif _convexHull = triangles.FindAll(t => t.SharesVertexWith(superTriangle)). SelectMany(t => t.GetEdges()). Where(e => !(superTriangle.Contains(e.P1) || superTriangle.Contains(e.P2))).ToArray(); @@ -152,17 +152,23 @@ namespace TUGraz.VectoCore.Utils } } + public void DrawGraph() + { + const int max = 100000; + var superTriangle = new Triangle(new Point(max, 0), new Point(0, max), new Point(-max, -max)); + DrawGraph(0, _triangles, superTriangle, Points.ToArray()); + } + /// <summary> /// Draws the delaunay map (except supertriangle). /// </summary> - [Conditional("TRACE")] private static void DrawGraph(int i, List<Triangle> triangles, Triangle superTriangle, Point[] points, Point lastPoint = null) { - var xmin = points.Min(p => p.X); - var xmax = points.Max(p => p.X); - var ymin = points.Min(p => p.Y); - var ymax = points.Max(p => p.Y); + var xmin = Math.Min(points.Min(p => p.X), lastPoint != null ? lastPoint.X : double.NaN); + var xmax = Math.Max(points.Max(p => p.X), lastPoint != null ? lastPoint.X : double.NaN); + var ymin = Math.Min(points.Min(p => p.Y), lastPoint != null ? lastPoint.Y : double.NaN); + var ymax = Math.Max(points.Max(p => p.Y), lastPoint != null ? lastPoint.Y : double.NaN); using (var chart = new Chart { Width = 1000, Height = 1000 }) { chart.ChartAreas.Add(new ChartArea("main") { diff --git a/VectoCore/VectoCore/Utils/SearchAlgorithm.cs b/VectoCore/VectoCore/Utils/SearchAlgorithm.cs index 9feb4fd9b40953af4e6718b577e5dcff9a288db6..4ad877f912d71d2ef137bb1c08fb734ffaf4f51f 100644 --- a/VectoCore/VectoCore/Utils/SearchAlgorithm.cs +++ b/VectoCore/VectoCore/Utils/SearchAlgorithm.cs @@ -116,7 +116,7 @@ namespace TUGraz.VectoCore.Utils var intervalFactor = 1.0; var origY = y; var debug = new DebugData(); - debug.Add(new { x, y }); + debug.Add(new { x = x.Value(), y = y.Value() }); log.Debug("Log Disabled during LineSearch."); LogManager.DisableLogging(); try { @@ -129,7 +129,7 @@ namespace TUGraz.VectoCore.Utils x += interval * -y.Sign(); var result = evaluateFunction(x); y = getYValue(result); - debug.Add(new { x, y, delta = criterion(result), result }); + debug.Add(new { x = x.Value(), y = y.Value(), delta = criterion(result), result }); if (criterion(result).IsEqual(0, Constants.SimulationSettings.LineSearchTolerance)) { LogManager.EnableLogging(); log.Debug("LineSearch found an operating point after {0} function calls.", count); @@ -161,20 +161,23 @@ namespace TUGraz.VectoCore.Utils [Conditional("TRACE")] private static void AppendDebug(DebugData debug) { - var xmin = debug.Data.Min(d => d.x).Value(); - var xmax = debug.Data.Max(d => d.x).Value(); - var ymin = debug.Data.Min(d => d.y).Value(); - var ymax = debug.Data.Max(d => d.y).Value(); + var xmin = debug.Data.Min(d => d.x); + var xmax = debug.Data.Max(d => d.x); + var ymin = debug.Data.Min(d => d.y); + var ymax = debug.Data.Max(d => d.y); var rand = new Random().Next(); - using (var f = new StreamWriter(File.Open("LineSearch-" + Thread.CurrentThread.ManagedThreadId + "-statistics.csv", FileMode.Append))) { + using ( + var f = + new StreamWriter(File.Open("LineSearch-" + Thread.CurrentThread.ManagedThreadId + "-statistics.csv", + FileMode.Append))) { foreach (var d in debug.Data) { f.WriteLine(string.Format("{0}, {1}, {2}, {3}, {4}, {5}, {6}", rand, - (d.x.Value() - xmin) / (xmax - xmin), - (d.y.Value() - ymin) / (ymax - ymin), - d.x.Value() / Math.Max(Math.Abs(xmax), Math.Abs(xmin)), - d.y.Value() / Math.Max(Math.Abs(ymax), Math.Abs(ymin)), + (d.x - xmin) / (xmax - xmin), + (d.y - ymin) / (ymax - ymin), + d.x / Math.Max(Math.Abs(xmax), Math.Abs(xmin)), + d.y / Math.Max(Math.Abs(ymax), Math.Abs(ymin)), d.x, d.y)); } } @@ -223,7 +226,7 @@ namespace TUGraz.VectoCore.Utils if (!(ex.InnerException is DivideByZeroException)) { throw; } - debug.Add(new { x = x2, y = getYValue(result), delta = criterion(result), result }); + debug.Add(new { x = x2, y = getYValue(result).Value(), delta = criterion(result), result }); LogManager.EnableLogging(); log.Debug("InterpolateSearch could not get more exact. Aborting after {0} function calls.", count); LogManager.DisableLogging(); @@ -234,7 +237,7 @@ namespace TUGraz.VectoCore.Utils result = evaluateFunction(x2.SI<T>()); if (criterion(result).IsEqual(0, Constants.SimulationSettings.InterpolateSearchTolerance)) { - debug.Add(new { x = x2, y = getYValue(result), delta = criterion(result), result }); + debug.Add(new { x = x2, y = getYValue(result).Value(), delta = criterion(result), result }); LogManager.EnableLogging(); log.Debug("InterpolateSearch found an operating point after {0} function calls.", count); LogManager.DisableLogging(); diff --git a/VectoCore/VectoCoreTest/Integration/FullCycleDeclarationTest.cs b/VectoCore/VectoCoreTest/Integration/FullCycleDeclarationTest.cs index ab742c192f1afaed87925d04284658792bf09a67..32b0336b1739c3394bb5e1a6242587dd94bbeebe 100644 --- a/VectoCore/VectoCoreTest/Integration/FullCycleDeclarationTest.cs +++ b/VectoCore/VectoCoreTest/Integration/FullCycleDeclarationTest.cs @@ -256,6 +256,23 @@ namespace TUGraz.VectoCore.Tests.Integration .Select(r => r.ParseDoubleOrGetDefault(ModalResultField.FCWHTCc.GetShortCaption())) .Sum(); AssertHelper.AreRelativeEqual(sumFuelConsumption, sumFuelConsumption1Hz, "Fuel Consumption is not equal", 1e-4); + + // test speed not negative + Assert.IsTrue( + modFile1Hz.Rows.Cast<DataRow>() + .All(r => r.ParseDouble(ModalResultField.v_act.GetShortCaption()).IsGreaterOrEqual(0)), + "v_act must not be negative."); + + // test fuel consumption not negative + Assert.IsTrue( + modFile1Hz.Rows.Cast<DataRow>() + .All(r => r.ParseDouble(ModalResultField.FCWHTCc.GetShortCaption()).IsGreaterOrEqual(0)), + "fuel consumption must not be negative."); + + // last v_act entry must be the same as original + var v_act = modFile.Rows.Cast<DataRow>().Last().ParseDouble((int)ModalResultField.v_act).SI<MeterPerSecond>(); + var v_act1Hz = modFile1Hz.Rows.Cast<DataRow>().Last().ParseDouble((int)ModalResultField.v_act).SI<MeterPerSecond>(); + AssertHelper.AreRelativeEqual(v_act, v_act1Hz, "end velocity is not equal", 1e-4); } [TestMethod, TestCategory("LongRunning")] diff --git a/VectoCore/VectoCoreTest/Models/Simulation/DrivingCycleTests.cs b/VectoCore/VectoCoreTest/Models/Simulation/DrivingCycleTests.cs index 450061d769e2257b582b130b385b7ad11a75646d..ee80cf4dc60299ed9ce33f4f2a53b5df3a2d1146 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/DrivingCycleTests.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/DrivingCycleTests.cs @@ -135,7 +135,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation if (absTime < 5) { Assert.AreEqual(600.RPMtoRad(), outPort.AngularVelocity); - AssertHelper.AreRelativeEqual(0.SI<NewtonMeter>(), outPort.Torque, 1e-3); + AssertHelper.AreRelativeEqual(0.SI<NewtonMeter>(), outPort.Torque, toleranceFactor: 1e-3); } else if (absTime.IsBetween(12.75, 13.25) || absTime.IsBetween(14, 15)) { Assert.IsTrue(outPort.AngularVelocity > 600.RPMtoRad()); Assert.IsTrue(outPort.Torque < 0); diff --git a/VectoCore/VectoCoreTest/Models/Simulation/SimulationTests.cs b/VectoCore/VectoCoreTest/Models/Simulation/SimulationTests.cs index 75bd4460e584e06c50c94e7242ad2e8eee86e4a3..0f8a54d266e8e7fd9b45ec0c9f5722bfe6a890f6 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/SimulationTests.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/SimulationTests.cs @@ -67,6 +67,8 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation var job = CreateRun(actual); job.Run(); + Assert.IsTrue(job.FinishedWithoutErrors); + ResultFileHelper.TestModFile(expected, actual); } @@ -86,10 +88,14 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation var run = CreateRun(actual); - var sim = new JobContainer(new MockSumWriter()); - sim.AddRun(run); - sim.Execute(); - sim.WaitFinished(); + var jobContainer = new JobContainer(new MockSumWriter()); + jobContainer.AddRun(run); + jobContainer.Execute(); + jobContainer.WaitFinished(); + + foreach (var r in jobContainer.Runs) { + Assert.IsTrue(r.Run.FinishedWithoutErrors, string.Format("{0}", r.ExecException)); + } ResultFileHelper.TestModFile(expected, actual); } @@ -124,6 +130,10 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation jobContainer.WaitFinished(); + foreach (var run in jobContainer.Runs) { + Assert.IsTrue(run.Run.FinishedWithoutErrors, string.Format("{0}", run.ExecException)); + } + ResultFileHelper.TestSumFile(@"TestData\Results\EngineOnlyCycles\24t Coach.vsum", @"TestData\Jobs\24t Coach EngineOnly.vsum"); diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxPowertrainTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxPowertrainTest.cs index 993094236ca754666e7cbc50ea4925df012d61fe..786876332e8f7b10ad250cf30e606041a0117a38 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxPowertrainTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxPowertrainTest.cs @@ -116,7 +116,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent Assert.AreEqual(11u, container.Gear); Assert.IsInstanceOfType(retVal, typeof(ResponseSuccess)); - AssertHelper.AreRelativeEqual(1530.263.RPMtoRad(), container.EngineSpeed, 0.001); + AssertHelper.AreRelativeEqual(1530.263.RPMtoRad(), container.EngineSpeed, toleranceFactor: 1e-3); var absTime = 0.SI<Second>(); var ds = 1.SI<Meter>(); diff --git a/VectoCore/VectoCoreTest/TestData/Components/12t Delivery Truck.vmap b/VectoCore/VectoCoreTest/TestData/Components/12t Delivery Truck.vmap index f7ad107b968d22126c862db3a0d24a78c7ba3f14..b53be2b0edccdcc7ce6a25939fd925cc553a3ec7 100644 --- a/VectoCore/VectoCoreTest/TestData/Components/12t Delivery Truck.vmap +++ b/VectoCore/VectoCoreTest/TestData/Components/12t Delivery Truck.vmap @@ -183,4 +183,7 @@ engine speed [1/min],torque [Nm],fuel consumption [g/h] 2600,400,23315 2600,480,28351 2700,-150,0 -2700,0,5900 \ No newline at end of file +2700,0,5900 +500,-500,50000 +3000,1500,50000 +3000,-500,50000 \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/TestData/Components/24t Coach.vmap b/VectoCore/VectoCoreTest/TestData/Components/24t Coach.vmap index 26c035cad9373137a6be4195e75a204b3625a22c..ef9b0c0123eb3c3da97dd0a52dc3d652684f130b 100644 --- a/VectoCore/VectoCoreTest/TestData/Components/24t Coach.vmap +++ b/VectoCore/VectoCoreTest/TestData/Components/24t Coach.vmap @@ -111,3 +111,6 @@ 2100,800,35717 2100,1000,45643 2100,1100,50653 +500,-500,50000 +3000,1500,50000 +3000,-500,50000 \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/TestData/Integration/DeclarationMode/12t Truck/12t Delivery Truck.vmap b/VectoCore/VectoCoreTest/TestData/Integration/DeclarationMode/12t Truck/12t Delivery Truck.vmap index f7ad107b968d22126c862db3a0d24a78c7ba3f14..8d0ccfd038e234717b6cd5b95d91ab5b2b62e883 100644 --- a/VectoCore/VectoCoreTest/TestData/Integration/DeclarationMode/12t Truck/12t Delivery Truck.vmap +++ b/VectoCore/VectoCoreTest/TestData/Integration/DeclarationMode/12t Truck/12t Delivery Truck.vmap @@ -183,4 +183,6 @@ engine speed [1/min],torque [Nm],fuel consumption [g/h] 2600,400,23315 2600,480,28351 2700,-150,0 -2700,0,5900 \ No newline at end of file +2700,0,5900 +3000,1200,40000 +600,1200,40000 \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/TestData/Integration/DeclarationMode/40t Truck/40t_Long_Haul_Truck.vmap b/VectoCore/VectoCoreTest/TestData/Integration/DeclarationMode/40t Truck/40t_Long_Haul_Truck.vmap index 26c035cad9373137a6be4195e75a204b3625a22c..a201ed96fb030c871f8d13df05a11556b3e8a317 100644 --- a/VectoCore/VectoCoreTest/TestData/Integration/DeclarationMode/40t Truck/40t_Long_Haul_Truck.vmap +++ b/VectoCore/VectoCoreTest/TestData/Integration/DeclarationMode/40t Truck/40t_Long_Haul_Truck.vmap @@ -111,3 +111,5 @@ 2100,800,35717 2100,1000,45643 2100,1100,50653 +2100,2400,60000 +560,2400,60000 \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/TestData/MeasuredSpeed/FuelConsumption.vmap b/VectoCore/VectoCoreTest/TestData/MeasuredSpeed/FuelConsumption.vmap index f7ad107b968d22126c862db3a0d24a78c7ba3f14..28bb9569197f55dd56dceeac9a91e64d8f1f7f92 100644 --- a/VectoCore/VectoCoreTest/TestData/MeasuredSpeed/FuelConsumption.vmap +++ b/VectoCore/VectoCoreTest/TestData/MeasuredSpeed/FuelConsumption.vmap @@ -183,4 +183,7 @@ engine speed [1/min],torque [Nm],fuel consumption [g/h] 2600,400,23315 2600,480,28351 2700,-150,0 -2700,0,5900 \ No newline at end of file +2700,0,5900 +1200,-400,50000 +0,-400,50000 +3000,-400,50000 \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/Utils/AssertHelper.cs b/VectoCore/VectoCoreTest/Utils/AssertHelper.cs index c527d7eb5e867a94a0b8169b6e10c797cdccaa7c..5e3a4487004afbfc430090909f81b5fad1fb4f66 100644 --- a/VectoCore/VectoCoreTest/Utils/AssertHelper.cs +++ b/VectoCore/VectoCoreTest/Utils/AssertHelper.cs @@ -56,8 +56,8 @@ namespace TUGraz.VectoCore.Tests.Utils } [DebuggerHidden] - public static void AreRelativeEqual(SI expected, SI actual, - double toleranceFactor = DoubleExtensionMethods.ToleranceFactor, string message = null) + public static void AreRelativeEqual(SI expected, SI actual, string message = null, + double toleranceFactor = DoubleExtensionMethods.ToleranceFactor) { Assert.IsTrue(actual.HasEqualUnit(expected), string.Format("Wrong SI Units: expected: {0}, actual: {1}", expected.ToBasicUnits(), actual.ToBasicUnits()));