diff --git a/Documentation/User Manual Source/Release Notes Vecto3.x.pdf b/Documentation/User Manual Source/Release Notes Vecto3.x.pdf index e9fb391957a2ad2d18649a2fb17daba26ce30418..2828d00c6ee610183b1765d8f8af4f6dd4875e1b 100644 Binary files a/Documentation/User Manual Source/Release Notes Vecto3.x.pdf and b/Documentation/User Manual Source/Release Notes Vecto3.x.pdf differ diff --git a/Generic Vehicles/Engineering Mode/GenericVehicleE2/BEV_ENG_PTO.vecto b/Generic Vehicles/Engineering Mode/GenericVehicleE2/BEV_ENG_PTO.vecto index 6c33428c5f20cee5cf7d402daf549f0053201086..f808250c804ad66c10d9256bef530c14be533db6 100644 --- a/Generic Vehicles/Engineering Mode/GenericVehicleE2/BEV_ENG_PTO.vecto +++ b/Generic Vehicles/Engineering Mode/GenericVehicleE2/BEV_ENG_PTO.vecto @@ -1,44 +1,46 @@ -{ +{ "Header": { - "CreatedBy": " (h)", - "Date": "2016-10-13T08:55:18.2100810Z", + "CreatedBy": "", + "Date": "2022-10-31T15:32:36.6289781Z", "AppVersion": "3", "FileVersion": 9 }, "Body": { "SavedInDeclMode": false, - "EngineOnlyMode": false, "VehicleFile": "BatteryElectricVehicle_PTO.vveh", "GearboxFile": "AMT.vgbx", "TCU": "AMT.vgbx", "Padd_electric": 0.0, - "VACC": "Truck.vacc", - + "EngineStopStartAtVehicleStopThreshold": 2.0, + "EngineStopStartMaxOffTimespan": 120.0, + "EngineStopStartUtilityFactor": 0.8, + "EngineStopStartUtilityFactorDriving": 0.8, + "EcoRollMinSpeed": 60.000000000000007, + "EcoRollActivationDelay": 2.0, + "EcoRollUnderspeedThreshold": 0.0, + "EcoRollMaxAcceleration": 0.1, + "PCCEnableSpeed": 80.0, + "PCCMinSpeed": 50.0, + "PCCUnderspeed": 8.0, + "PCCOverSpeed": 5.0, + "PCCPreviewDistanceUC1": 1500.0, + "PCCPreviewDistanceUC2": 1000.0, "LAC": { "Enabled": true, "PreviewDistanceFactor": 10.0, "DF_offset": 2.5, "DF_scaling": 1.5, "DF_targetSpeedLookup": "", - "Df_velocityDropLookup": "" + "Df_velocityDropLookup": "", + "MinSpeed": 50.0 }, "OverSpeedEcoRoll": { "Mode": "Off", "MinSpeed": 50.0, - "OverSpeed": 5.0, - "UnderSpeed": 5.0 + "OverSpeed": 5.0 }, "Cycles": [ - "LongHaul", - "Coach", - "Construction", - "HeavyUrban", - "Interurban", - "RegionalDelivery", - "Suburban", - "Urban", - "UrbanDelivery", "MunicipalUtility" ] } diff --git a/Generic Vehicles/Engineering Mode/GenericVehicleE2/BEV_ENG_PTO_invalid.vecto b/Generic Vehicles/Engineering Mode/GenericVehicleE2/BEV_ENG_PTO_invalid.vecto new file mode 100644 index 0000000000000000000000000000000000000000..b142f5ff4357994eb9cb5944aaa58f64cb9647b8 --- /dev/null +++ b/Generic Vehicles/Engineering Mode/GenericVehicleE2/BEV_ENG_PTO_invalid.vecto @@ -0,0 +1,45 @@ +{ + "Header": { + "CreatedBy": " (h)", + "Date": "2016-10-13T08:55:18.2100810Z", + "AppVersion": "3", + "FileVersion": 9 + }, + "Body": { + "SavedInDeclMode": false, + "EngineOnlyMode": false, + "VehicleFile": "BatteryElectricVehicle_PTO_invalid.vveh", + "GearboxFile": "AMT.vgbx", + "TCU": "AMT.vgbx", + "Padd_electric": 0.0, + + "VACC": "Truck.vacc", + + "LAC": { + "Enabled": true, + "PreviewDistanceFactor": 10.0, + "DF_offset": 2.5, + "DF_scaling": 1.5, + "DF_targetSpeedLookup": "", + "Df_velocityDropLookup": "" + }, + "OverSpeedEcoRoll": { + "Mode": "Off", + "MinSpeed": 50.0, + "OverSpeed": 5.0, + "UnderSpeed": 5.0 + }, + "Cycles": [ + "LongHaul", + "Coach", + "Construction", + "HeavyUrban", + "Interurban", + "RegionalDelivery", + "Suburban", + "Urban", + "UrbanDelivery", + "MunicipalUtility" + ] + } +} \ No newline at end of file diff --git a/Generic Vehicles/Engineering Mode/GenericVehicleE2/BatteryElectricVehicle_PTO_invalid.vveh b/Generic Vehicles/Engineering Mode/GenericVehicleE2/BatteryElectricVehicle_PTO_invalid.vveh new file mode 100644 index 0000000000000000000000000000000000000000..58f0e3500cf3ff613dc2db51cf5dae3ee0940f3a --- /dev/null +++ b/Generic Vehicles/Engineering Mode/GenericVehicleE2/BatteryElectricVehicle_PTO_invalid.vveh @@ -0,0 +1,91 @@ +{ + "Header": { + "CreatedBy": "", + "Date": "2022-05-30T15:23:54.1506819Z", + "AppVersion": "3", + "FileVersion": 10 + }, + "Body": { + "SavedInDeclMode": false, + "VehCat": "RigidTruck", + "LegislativeClass": "Unknown", + "CurbWeight": 4670.0, + "CurbWeightExtra": 1900.0, + "MassMax": 11.99, + "Loading": 3020.0, + "rdyn": 421.0, + "CdCorrMode": "CdofVdecl", + "CdCorrFile": "", + "AxleConfig": { + "Type": "4x2", + "Axles": [ + { + "Inertia": 6.5, + "Wheels": "265/70 R19.5", + "AxleWeightShare": 0.2, + "TwinTyres": false, + "RRCISO": 0.0065, + "FzISO": 20850.0, + "Type": "VehicleNonDriven" + }, + { + "Inertia": 6.5, + "Wheels": "265/70 R19.5", + "AxleWeightShare": 0.3, + "TwinTyres": true, + "RRCISO": 0.0075, + "FzISO": 20850.0, + "Type": "VehicleDriven" + }, + { + "Inertia": 4.5, + "Wheels": "235/75 R17.5", + "AxleWeightShare": 0.25, + "TwinTyres": false, + "RRCISO": 0.0055, + "FzISO": 16680.0, + "Type": "VehicleNonDriven" + }, + { + "Inertia": 4.5, + "Wheels": "235/75 R17.5", + "AxleWeightShare": 0.25, + "TwinTyres": false, + "RRCISO": 0.0055, + "FzISO": 16680.0, + "Type": "VehicleNonDriven" + } + ] + }, + "EngineStopStart": false, + "EcoRoll": "None", + "PredictiveCruiseControl": "None", + "ATEcoRollReleaseLockupClutch": false, + "VehicleHeight": 3.0, + "InitialSoC": 80.0, + "PowertrainConfiguration": "BatteryElectric", + "ElectricMotors": [ + { + "Count": 2, + "Ratio": 2.0, + "Position": "E2", + "MotorFile": "GenericEMotor_125kW_485Nm.vem", + "MechanicalEfficiency": 0.97 + } + ], + "Batteries": [ + { + "NumPacks": 2, + "BatteryFile": "GenericBattery_243kWh_750V.vbat", + "StreamId": 0 + } + ], + "PTO": { + "Type": "drive shaft and/or up to 2 gear wheels - multi-disc clutch, oil pump", + "LossMap": "PTO-idle.vptol", + "Cycle": "PTO-cycle.vptoc", + "CycleEPTO" : "EPTO-idle.vptoel", + "CycleDriving": "" + } + } +} \ No newline at end of file diff --git a/Generic Vehicles/Engineering Mode/GenericVehicleE2/EPTO-idle.vptoel b/Generic Vehicles/Engineering Mode/GenericVehicleE2/EPTO-idle.vptoel index f88ec6feabdc3dbcd5daf0288e1f05938f7bd93d..d477bc73ecaccd0aa3a54f20f3c413c36b2a39be 100644 --- a/Generic Vehicles/Engineering Mode/GenericVehicleE2/EPTO-idle.vptoel +++ b/Generic Vehicles/Engineering Mode/GenericVehicleE2/EPTO-idle.vptoel @@ -1,25 +1,25 @@ <t> ,<P_PTO_el> - 0 ,8.42 - 1 ,8.42 - 2 ,8.42 - 3 ,8.42 - 4 ,8.42 - 5 ,33.69 - 6 ,33.69 - 7 ,33.69 - 8 ,33.69 - 9 ,25.92 - 10 ,25.92 - 11 ,25.92 - 12 ,25.92 - 13 ,25.92 - 14 ,25.92 - 15 ,25.92 - 16 ,25.92 - 17 ,25.92 - 18 ,25.92 - 19 ,25.92 - 20 ,25.92 - 21 ,25.92 - 22 ,25.92 - 23 ,25.92 \ No newline at end of file + 0 , 8.42 + 1 , 8.42 + 2 , 8.42 + 3 , 8.42 + 4 , 8.42 + 5 , 33.69 + 6 , 33.69 + 7 , 33.69 + 8 , 33.69 + 9 , 25.92 + 10 , 25.92 + 11 , 25.92 + 12 , 25.92 + 13 , 25.92 + 14 , 25.92 + 15 , 25.92 + 16 , 25.92 + 17 , 25.92 + 18 , 25.92 + 19 , 25.92 + 20 , 25.92 + 21 , 25.92 + 22 , 25.92 + 23 , 25.92 \ No newline at end of file diff --git a/Generic Vehicles/Engineering Mode/GenericVehicleE2/PTO-cycle.vptoc b/Generic Vehicles/Engineering Mode/GenericVehicleE2/PTO-cycle.vptoc new file mode 100644 index 0000000000000000000000000000000000000000..a83f94945c455bf460a3fbaa886d251f3f67a834 --- /dev/null +++ b/Generic Vehicles/Engineering Mode/GenericVehicleE2/PTO-cycle.vptoc @@ -0,0 +1,34 @@ +t,Engine speed,PTO Torque +# [s],[rpm],[Nm] +0,600,0 +1,600,0 +2,900,0 +3,1200,47.87750416 +4,1200,67.91951027 +5,1200,103.5934139 +6,1200,142.5363262 +7,1200,166.111409 +8,1200,171.0628326 +9,1200,165.0796753 +10,1200,158.6919685 +11,1200,153.2632141 +12,1200,144.49562 +13,1200,135.5139389 +14,1200,131.4482469 +15,1200,128.4894196 +16,1200,131.626042 +17,1200,153.7727524 +18,1200,175.9667 +19,1200,183.5483045 +20,1200,183.8551277 +21,1200,177.923716 +22,1200,167.7081726 +23,1200,154.8998108 +24,1200,141.3471672 +25,1200,134.1808388 +26,1200,126.8244091 +27,1200,121.6745926 +28,1200,80.85182495 +29,900,0 +30,600,0 +31,600,0 diff --git a/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs b/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs index 93616a77dc4a99eacf53932202b35db1ddf2b460..728e55fa2eaa6843675d312c2d4ab3c941430537 100644 --- a/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs +++ b/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs @@ -596,7 +596,7 @@ namespace VECTO3GUI2020.ViewModel.Implementation }); var start = Stopwatch.StartNew(); - jobContainer.Execute(true); + jobContainer.Execute(true); //TODO HM set back to true while (!jobContainer.AllCompleted) { diff --git a/VectoCore/VectoCore/Models/Simulation/IVehicleContainer.cs b/VectoCore/VectoCore/Models/Simulation/IVehicleContainer.cs index 3d3cf62f7576bad869805aabc2af1e9672acdf3f..d7e4a6069f8558802a8bbbc7a9dcfd58668852dd 100644 --- a/VectoCore/VectoCore/Models/Simulation/IVehicleContainer.cs +++ b/VectoCore/VectoCore/Models/Simulation/IVehicleContainer.cs @@ -83,5 +83,7 @@ namespace TUGraz.VectoCore.Models.Simulation IEnumerable<ISimulationPreprocessor> GetPreprocessingRuns { get; } ISumData SumData { get; } void AddPreprocessor(ISimulationPreprocessor simulationPreprocessor); + void ResetComponents(); + void FinishSingleSimulationRun(Exception e = null); } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/DistanceRun.cs b/VectoCore/VectoCore/Models/Simulation/Impl/DistanceRun.cs index 4cb4629e1b03bd40cbf0728abd2edc89ec46e014..c128a3002df7b1992f48f540adcfe427a294e17b 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/DistanceRun.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/DistanceRun.cs @@ -34,14 +34,15 @@ using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.Models.Connector.Ports.Impl; +using TUGraz.VectoCore.Models.SimulationComponent; using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Simulation.Impl { public class DistanceRun : VectoRun { + public DistanceRun(IVehicleContainer container, IFollowUpRunCreator followUpCreator) : base(container, followUpCreator) {} public DistanceRun(IVehicleContainer container) : base(container) {} - protected override IResponse DoSimulationStep() { IterationStatistics.StartIteration(); diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/FollowUpOVCRunCreator.cs b/VectoCore/VectoCore/Models/Simulation/Impl/FollowUpOVCRunCreator.cs new file mode 100644 index 0000000000000000000000000000000000000000..e5260298ded6ba97b5e51224f87ab95a4bc153dd --- /dev/null +++ b/VectoCore/VectoCore/Models/Simulation/Impl/FollowUpOVCRunCreator.cs @@ -0,0 +1,112 @@ +using System; +using System.Dynamic; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Models.Simulation.Data; +using TUGraz.VectoCore.OutputData; + +namespace TUGraz.VectoCore.Models.Simulation.Impl +{ +// public interface IFollowUpRunCreator +// { +// public +// } + +public interface IFollowUpRunCreator +{ + bool RunAgain(Action runAgainAction, IVectoRun run, Action beforeNextRun); +} + + +public class NoFollowUpRunCreator : LoggingObject, IFollowUpRunCreator +{ + #region Implementation of IFollowUpRunCreator + + public bool RunAgain(Action runAgainAction, IVectoRun run) + { + return false; + } + + #endregion + + #region Implementation of IFollowUpRunCreator + + public bool RunAgain(Action runAgainAction, IVectoRun run, Action beforeNextRun) + { + throw new NotImplementedException(); + } + + #endregion +} +/// <summary> + /// This class decides if a run is executed another time, stores the relevant data from the current run and prepares the VehicleContainer for the next run + /// </summary> + public class FollowUpOvcRunCreator : LoggingObject, IFollowUpRunCreator +{ + + private int testRunCount = 2; + + private int iteration = 0; + public FollowUpOvcRunCreator() + { + } + + /// <summary> + /// Determines if a run should be simulated again, if the run should be simulated again, + /// necessary simulation components are reset, the rundata is adjusted and the runAgainAction is executed + /// </summary> + /// <param name="runAgainAction"></param> + /// <param name="run"></param> + public bool RunAgain(Action runAgainAction, IVectoRun run, Action beforeNextRun) + { + var container = run.GetContainer(); + if (!ShouldRunAgain(run)) { + return false; + } + + beforeNextRun(); + + + + //Assign a new modaldata container to the current run, preserve the current modaldatacontainer for finishing the simulation + //var runData = container.RunData; + + // container.ModalData = new ModalDataContainer(runData:runData, addReportResult:) + + //(container.ModalData as ModalDataContainer).PushResults(); + + ResetSimulationComponents(container); + UpdateRunData(container.RunData); + runAgainAction(); + ResetRunData(container.RunData); + + return true; + } + + private void ResetRunData(VectoRunData containerRunData) + { + + } + + private void UpdateRunData(VectoRunData runData) + { + runData.ModFileSuffix += ++iteration; + runData.VehicleData.Loading -= 100d.SI<Kilogram>(); //TEST + runData.VehicleData.Manufacturer += (testRunCount + 1); + } + + private void ResetSimulationComponents(IVehicleContainer vehicleContainer) + { + vehicleContainer.RunStatus = VectoRun.Status.Pending; + vehicleContainer.ResetComponents(); + } + + + private bool ShouldRunAgain(IVectoRun run) + { + Log.Info(string.Format("Run {0} again!", run.RunName)); + return (testRunCount-- > 0); + } + } + +} \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/IFollowUpRunCreatorFactory.cs b/VectoCore/VectoCore/Models/Simulation/Impl/IFollowUpRunCreatorFactory.cs new file mode 100644 index 0000000000000000000000000000000000000000..3c12d607a00b04f01ad7ee71981d49dc8f0c72fe --- /dev/null +++ b/VectoCore/VectoCore/Models/Simulation/Impl/IFollowUpRunCreatorFactory.cs @@ -0,0 +1,27 @@ +using TUGraz.VectoCore.Models.Simulation.Data; + +namespace TUGraz.VectoCore.Models.Simulation.Impl +{ + public interface IFollowUpRunCreatorFactory + { + IFollowUpRunCreator CreateFollowUpRunCreator(VectoRunData runData); + } + public class FollowUpRunCreatorFactory : IFollowUpRunCreatorFactory + { + #region Implementation of IFollowUpRunCreatorFactory + + public IFollowUpRunCreator CreateFollowUpRunCreator(VectoRunData runData) + { + if (runData.VehicleData.InputData.OvcHev) + { + return new FollowUpOvcRunCreator(); + } + else + { + return new NoFollowUpRunCreator(); + } + } + + #endregion + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory/SimulatorFactory.cs b/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory/SimulatorFactory.cs index 74efc1582e1b59441c6c13f314e7b0019c32b0f3..387e51876a79c58c8a0a8b2367c8636dc0e60365 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory/SimulatorFactory.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory/SimulatorFactory.cs @@ -65,7 +65,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl.SimulatorFactory private static object _kernelLock = new object(); private static IKernel _kernel; //Kernel is only used when the SimulatorFactory is created with the Factory Method. - + protected IFollowUpSimulatorFactoryCreator _followUpSimulatorFactoryCreator = null; protected bool _simulate = true; @@ -86,9 +86,10 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl.SimulatorFactory public bool CreateFollowUpSimulatorFactory { get; set; } = false; protected readonly ExecutionMode _mode; + private IFollowUpRunCreatorFactory _followUpRunFactory = new FollowUpRunCreatorFactory(); -#region Constructors and Factory Methods to instantiate Instances of SimulatorFactory without NInject (should only be used in Testcases that are not updated yet) + #region Constructors and Factory Methods to instantiate Instances of SimulatorFactory without NInject (should only be used in Testcases that are not updated yet) [Obsolete("Creation of new SimulatorFactories should be done with SimulatorFactoryFactory NInject Factory", false)] public static ISimulatorFactory CreateSimulatorFactory(ExecutionMode mode, IInputDataProvider dataProvider, IOutputDataWriter writer, IDeclarationReport declarationReport = null, IVTPReport vtpReport=null, bool validate = true) @@ -201,10 +202,9 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl.SimulatorFactory (ReportWriter as FileOutputWriter)?.BasePath ?? "", $"{data.JobName}_{data.Cycle.Name}{data.ModFileSuffix}.json"), JsonConvert.SerializeObject(data, Formatting.Indented)); } - data.JobNumber = JobNumber; data.RunNumber = current; - var run = GetVectoRun(data, modContainer, SumData); + var run = GetVectoRun(data, modContainer, _followUpRunFactory, SumData); if (Validate && firstRun) { ValidateVectoRunData( @@ -240,15 +240,19 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl.SimulatorFactory } } - private static VectoRun GetVectoRun(VectoRunData data, IModalDataContainer modData, ISumData sumWriter) + private static VectoRun GetVectoRun(VectoRunData data, IModalDataContainer modData, + IFollowUpRunCreatorFactory followUpRunCreatorFactory, ISumData sumWriter) { VectoRun run; + switch (data.Cycle.CycleType) { case CycleType.DistanceBased: if ((data.SimulationType & SimulationType.DistanceCycle) == 0) { throw new VectoException("Distance-based cycle can not be simulated in {0} mode", data.SimulationType); } - run = new DistanceRun(PowertrainBuilder.Build(data, modData, sumWriter)); + + var container = PowertrainBuilder.Build(data, modData, sumWriter); + run = new DistanceRun(container, followUpRunCreatorFactory.CreateFollowUpRunCreator(data)); break; case CycleType.EngineOnly: if ((data.SimulationType & SimulationType.EngineOnly) == 0) { diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory/SimulatorFactoryDeclaration.cs b/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory/SimulatorFactoryDeclaration.cs index 57130ddcfa7d59abcb6ad4e12d9fb9aa9049c1f3..3be08d43b57c4bf26f6eda83c16213b8e5100b21 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory/SimulatorFactoryDeclaration.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory/SimulatorFactoryDeclaration.cs @@ -22,6 +22,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl.SimulatorFactory private IVTPReport _currentStageVTPReport; protected readonly IXMLDeclarationReportFactory _xmlDeclarationReportFactory; + public SimulatorFactoryDeclaration(IInputDataProvider dataProvider, IOutputDataWriter writer, @@ -31,8 +32,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl.SimulatorFactory IXMLInputDataReader xmlInputDataReader, ISimulatorFactoryFactory simulatorFactoryFactory, IXMLDeclarationReportFactory xmlDeclarationReportFactory, - IVectoRunDataFactoryFactory runDataFactoryFactory - ) : base(ExecutionMode.Declaration, writer, validate) + IVectoRunDataFactoryFactory runDataFactoryFactory + ) : base(ExecutionMode.Declaration, writer, validate) { _xmlInputDataReader = xmlInputDataReader; _simFactoryFactory = simulatorFactoryFactory; diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/VectoRun.cs b/VectoCore/VectoCore/Models/Simulation/Impl/VectoRun.cs index c32d35109c6bc1b0c369e8516d2f78ad83940bd3..24dc26059268e88a3847cf6c9c897b5b28478750 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/VectoRun.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/VectoRun.cs @@ -50,6 +50,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl protected Second AbsTime = 0.SI<Second>(); protected Second dt = 1.SI<Second>(); private bool _cancelled; + private readonly IFollowUpRunCreator _followUpCreator; protected ISimulationOutPort CyclePort { get; set; } [Required, ValidateObject] @@ -59,6 +60,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public int RunIdentifier { get; protected set; } + public virtual string RunName => Container.RunData.JobName; public virtual string CycleName => Container.RunData.Cycle.Name; @@ -79,6 +81,11 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl WritingResultsDone = false; } + protected VectoRun(IVehicleContainer container, IFollowUpRunCreator followUpCreator) : this(container) + { + _followUpCreator = followUpCreator; + } + public IVehicleContainer GetContainer() => Container; public virtual bool CalculateAggregateValues() @@ -179,8 +186,16 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl Container.RunStatus = Status.Success; } - Container.FinishSimulationRun(); - WritingResultsDone = true; + + + var runAgain = _followUpCreator.RunAgain(Run, + this, + () => Container.FinishSingleSimulationRun()); + if (!runAgain) { + Container.FinishSimulationRun(); + WritingResultsDone = true; + } + if (Progress.IsSmaller(1, 1e-9)) { if (response is ResponseBatteryEmpty) { throw new VectoSimulationException("{3} ({4} {5}) REESS was empty before cycle could be finished. Progress: {6:P1} - absTime: {0:F1}, distance: {1:F1}, dt: {2:F1}", diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs b/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs index 00c21c0ac92cb65b103100d3052f48ea37f6d15c..bf9811d66a72f9427f199ea951043490e8b1c917 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs @@ -100,6 +100,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl internal readonly Dictionary<PowertrainPosition, IElectricMotorInfo> ElectricMotors = new Dictionary<PowertrainPosition, IElectricMotorInfo>(); + private IList<IResetableVectoSimulationComponent> _resetableComponents = new List<IResetableVectoSimulationComponent>(3); + public VehicleContainer(ExecutionMode executionMode, IModalDataContainer modData = null, ISumData writeSumData = null) @@ -138,6 +140,10 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl { var commitPriority = 0; + if (component is IResetableVectoSimulationComponent resetable) { + _resetableComponents.Add(resetable); + } + if (component is IEngineControl c1) { EngineCtl = c1; } if (component is IDriverInfo c2) { DriverInfo = c2; } if (component is IGearboxControl c3) { GearboxCtl = c3; } @@ -271,13 +277,18 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl } } - public virtual void FinishSimulationRun(Exception e = null) + public virtual void FinishSingleSimulationRun(Exception e = null) { Log.Info("VehicleContainer finishing simulation."); ModData?.Finish(RunStatus, e); WriteSumData?.Write(ModData, RunData); + } + public virtual void FinishSimulationRun(Exception e = null) + { + FinishSingleSimulationRun(e); + ModData?.FinishSimulation(); DrivingCycleInfo?.FinishSimulation(); } @@ -304,6 +315,13 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl return new ReadOnlyCollection<VectoSimulationComponent>(_components.Select(x => x.Item2).ToList()); } + public void ResetComponents() + { + foreach (var resetableVectoSimulationComponent in _resetableComponents) { + resetableVectoSimulationComponent.Reset(this); + } + } + public virtual bool HasElectricMotor { get; private set; } public PowertrainPosition[] ElectricMotorPositions => ElectricMotors.Keys.ToArray(); diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs index 57f46260cfbe400e584d2e8e47ab448641dc7e21..ded77ffbc310bada10c06b8bd4175bdc6c537f25 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs @@ -31,6 +31,7 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Globalization; using System.Linq; using TUGraz.VectoCommon.Exceptions; @@ -52,7 +53,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// </summary> public sealed class DistanceBasedDrivingCycle : StatefulProviderComponent <DistanceBasedDrivingCycle.DrivingCycleState, ISimulationOutPort, IDrivingCycleInPort, IDrivingCycleOutPort>, - IDrivingCycle, ISimulationOutPort, IDrivingCycleInPort, IDisposable, IUpdateable + IDrivingCycle, ISimulationOutPort, IDrivingCycleInPort, IDisposable, IUpdateable, IResetableVectoSimulationComponent { private const double LookaheadTimeSafetyMargin = 1.5; internal readonly IDrivingCycleData Data; @@ -76,6 +77,26 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl CycleStartDistance = Data.Entries.Count > 0 ? Data.Entries.First().Distance : 0.SI<Meter>(); CycleEndDistance = Data.Entries.Count > 0 ? Data.Entries.Last().Distance : 0.SI<Meter>(); + InitState(container); + } + + #region Overrides of VectoSimulationComponent + + public void Reset(IVehicleContainer vehicleContainer) + { + CycleIntervalIterator.Reset(); + InitState(vehicleContainer); + if (!(Initialize() is ResponseSuccess)) { + throw new VectoException("Initialization failed"); + } + + ; + } + + #endregion + + private void InitState(IVehicleContainer container) + { var first = Data.Entries.First(); PreviousState = new DrivingCycleState { AbsTime = 0.SI<Second>(), @@ -85,10 +106,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl VehicleTargetSpeed = Data.Entries.First().VehicleTargetSpeed }; CurrentState = PreviousState.Clone(); - + StartSpeed = container.RunData.GearshiftParameters?.StartSpeed; StartAcceleration = container.RunData.GearshiftParameters?.StartAcceleration; - } public IResponse Initialize() diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs index 2d70b003450cc5d60cfee6cf0a2ef790e27ae6fd..115de800829c6d577b131a61f87af439737141f1 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs @@ -57,7 +57,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public class Driver : StatefulProviderComponent<Driver.DriverState, IDrivingCycleOutPort, IDriverDemandInPort, IDriverDemandOutPort>, - IDriver, IDrivingCycleOutPort, IDriverDemandInPort, IDriverActions, IDriverInfo + IDriver, IDrivingCycleOutPort, IDriverDemandInPort, IDriverActions, IDriverInfo, IResetableVectoSimulationComponent { public DriverData DriverData { get; protected set; } @@ -94,6 +94,17 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return retVal; } + #region Implementation of IResetableVectoSimulationComponent + + public void Reset(IVehicleContainer vehicleContainer) + { + CurrentState = new DriverState(); + PreviousState = new DriverState(); + DriverAcceleration = 0.SI<MeterPerSquareSecond>(); + } + + #endregion + public IResponse Request(Second absTime, Meter ds, MeterPerSecond targetVelocity, Radian gradient) { IterationStatistics.Increment(this, "Requests"); @@ -1460,5 +1471,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public PCCStates PCCState => DriverStrategy.PCCState; public MeterPerSecond NextBrakeTriggerSpeed => DriverStrategy.BrakeTrigger?.NextTargetSpeed; + + } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/VectoSimulationComponent.cs b/VectoCore/VectoCore/Models/SimulationComponent/VectoSimulationComponent.cs index 9e2874f554efc2aeb604ab301e790e249654dc86..2b4d93420c9dfda9f10c3f702902e89175616cd3 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/VectoSimulationComponent.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/VectoSimulationComponent.cs @@ -38,6 +38,11 @@ using TUGraz.VectoCore.OutputData; namespace TUGraz.VectoCore.Models.SimulationComponent { + public interface IResetableVectoSimulationComponent + { + void Reset(IVehicleContainer vehicleContainer); + } + /// <summary> /// Base class for all vecto simulation components. /// </summary> @@ -80,6 +85,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent protected abstract void DoCommitSimulationStep(Second time, Second simulationInterval); } + + public abstract class StatefulVectoSimulationComponent<TStateType> : VectoSimulationComponent where TStateType : new() { protected internal TStateType CurrentState; diff --git a/VectoCore/VectoCoreTest/Integration/Declaration/HeavyLorry/HeavyLorrySimulation.cs b/VectoCore/VectoCoreTest/Integration/Declaration/HeavyLorry/HeavyLorrySimulation.cs index 7254c40557ad17d9c81de8332282306fcb7abc6c..7662c242ebd0df16f40c8f1f1ac21cb6a8050a37 100644 --- a/VectoCore/VectoCoreTest/Integration/Declaration/HeavyLorry/HeavyLorrySimulation.cs +++ b/VectoCore/VectoCoreTest/Integration/Declaration/HeavyLorry/HeavyLorrySimulation.cs @@ -45,8 +45,7 @@ public class HeavyLorrySimulation TestCase(@"HeavyLorry\PEV_heavyLorry_AMT_E2_pto_transm.xml"), TestCase(@"HeavyLorry\PEV_heavyLorry_E4.xml"), TestCase(@"HeavyLorry\Group2_HEV_S2.xml"), - TestCase(@"HeavyLorry\Group5_HEV_P2_.xml"), - ] + TestCase(@"HeavyLorry\Group5_HEV_P2_.xml")] public void HeavyLorrySimulationTest(string jobFile) { #if singlethreaded @@ -69,7 +68,11 @@ public class HeavyLorrySimulation PrintRuns(jobContainer, null); jobContainer.Execute(multiThreaded); - jobContainer.WaitFinished(); + + if (multiThreaded) { + jobContainer.WaitFinished(); + } + Assert.IsTrue(jobContainer.AllCompleted); Assert.IsTrue(jobContainer.Runs.TrueForAll(runEntry => runEntry.Success)); PrintRuns(jobContainer, fileWriter); diff --git a/VectoCore/VectoCoreTest/TestData/Hybrids/GenericVehicle_Group2_P2/GenericMap240kW.vemo b/VectoCore/VectoCoreTest/TestData/Hybrids/GenericVehicle_Group2_P2/GenericMap240kW.vemo index a490c328019ccca2acd9579f01ec5189f4b9d6ad..ba78207a21f64de0fa47878b7cef537d2c425af9 100644 --- a/VectoCore/VectoCoreTest/TestData/Hybrids/GenericVehicle_Group2_P2/GenericMap240kW.vemo +++ b/VectoCore/VectoCoreTest/TestData/Hybrids/GenericVehicle_Group2_P2/GenericMap240kW.vemo @@ -1,4 +1,4 @@ -rpm , T , P_bat +rpm , T , P_el 0 , -1600 , 19.6898 0 , -1550 , 18.5438 0 , -1500 , 17.4322 diff --git a/VectoCore/VectoCoreTest/TestData/XML/XMLReaderDeclaration/SchemaVersion2.4/Distributed/HeavyLorry/Conventional_heavyLorry_AMT _vocational.vsum b/VectoCore/VectoCoreTest/TestData/XML/XMLReaderDeclaration/SchemaVersion2.4/Distributed/HeavyLorry/Conventional_heavyLorry_AMT _vocational.vsum new file mode 100644 index 0000000000000000000000000000000000000000..acf6c095305816df3627e5c4edeaf72e75f9850f --- /dev/null +++ b/VectoCore/VectoCoreTest/TestData/XML/XMLReaderDeclaration/SchemaVersion2.4/Distributed/HeavyLorry/Conventional_heavyLorry_AMT _vocational.vsum @@ -0,0 +1,3 @@ +# VECTO-DEV 0.7.9.2826-DEV - 27.09.2022 10:14 +Job [-],Input File [-],Cycle [-],Status,Vehicle manufacturer [-],VIN number,Vehicle model [-],HDV CO2 vehicle class [-],Corrected Actual Curb Mass [kg],Loading [kg],Passenger count [-],Total vehicle mass [kg],Engine manufacturer [-],Engine model [-],Engine fuel type [-],Engine rated power [kW],Engine idling speed [rpm],Engine rated speed [rpm],Engine displacement [ccm],Engine WHTCUrban,Engine WHTCRural,Engine WHTCMotorway,Engine BFColdHot,Engine CFRegPer,Engine actual CF,Vehicle fuel type [-],AirDrag model [-],Declared CdxA [m²],CdxA [m²],Sleeper cab [-],Declared RRC axle 1 [-],Declared FzISO axle 1 [N],Declared RRC axle 2 [-],Declared FzISO axle 2 [N],Declared RRC axle 3 [-],Declared FzISO axle 3 [N],Declared RRC axle 4 [-],Declared FzISO axle 4 [N],total RRC [-],weighted RRC w/o trailer [-],r_dyn [m],Number axles vehicle driven [-],Number axles vehicle non-driven [-],Number axles trailer [-],Gearbox manufacturer [-],Gearbox model [-],Gearbox type [-],Gear ratio first gear [-],Gear ratio last gear [-],Torque converter manufacturer [-],Torque converter model [-],Retarder manufacturer [-],Retarder model [-],Retarder type [-],Angledrive manufacturer [-],Angledrive model [-],Angledrive ratio [-],Axle manufacturer [-],Axle model [-],Axle gear ratio [-],Auxiliary technology STP [-],Auxiliary technology FAN [-],Auxiliary technology AC [-],Auxiliary technology PS [-],Auxiliary technology ES [-],ShiftStrategy,ADAS technology combination [-],PTOShaftsGearWheels,REESS Capacity,Cargo Volume [m³],time [s],distance [km],speed [km/h],altitudeDelta [m],CO2 [g/km],CO2 [g/tkm],CO2 [g/m³km],CO2 [g/Pkm],P_wheel_in [kW],P_wheel_in_pos [kW],P_fcmap [kW],P_fcmap_pos [kW],E_fcmap_pos [kWh],E_fcmap_neg [kWh],E_powertrain_inertia [kWh],E_aux_sum [kWh],E_aux_el(HV) [kWh],E_clutch_loss [kWh],E_tc_loss [kWh],E_shift_loss [kWh],E_gbx_loss [kWh],E_ret_loss [kWh],E_angle_loss [kWh],E_axl_loss [kWh],E_brake [kWh],E_vehi_inertia [kWh],E_air [kWh],E_roll [kWh],E_grad [kWh],BusAux PS air consumed [Nl],BusAux PS air generated [Nl],E_PS_compressorOff [kWh],E_PS_compressorOn [kWh],E_BusAux_ES_consumed [kWh],E_BusAux_ES_generated [kWh],ΔE_BusAux_Bat [kWh],E_BusAux_PS_corr [kWh],E_BusAux_ES_mech_corr [kWh],E_BusAux_HVAC_mech [kWh],E_BusAux_HVAC_el [kWh],E_BusAux_AuxhHeater [kWh],E_WHR_el [kWh],E_WHR_mech [kWh],E_ice_start [kWh],E_aux_ESS_missing [kWh],ice_starts [-],a [m/s^2],a_pos [m/s^2],a_neg [m/s^2],AccelerationTimeShare [%],DecelerationTimeShare [%],CruiseTimeShare [%],max. speed [km/h],max. acc [m/s²],max. dec [m/s²],n_eng_avg [rpm],n_eng_max [rpm],gear shifts [-],StopTimeShare [%],ICE max. Load time share [%],ICE off time share [%],CoastingTimeShare [%],BrakingTimeShare [%],a_avg_acc,Engine certification number,Average engine efficiency [-],Torque converter certification option,TorqueConverter certification number,Average torque converter efficiency w/o lockup [-],Average torque converter efficiency with lockup [-],Gearbox certification option,Gearbox certification number,Average gearbox efficiency [-],Retarder certification option,Retarder certification number,Angledrive certification option,Angledrive certification number,Average angledrive efficiency [-],Axlegear certification method,Axlegear certification number,Average axlegear efficiency [-],AirDrag certification number,AirDrag certification option +#@ SHA256: Oiupa+62/TUFv6xphKI/iJIgGF2Yf13um36uIQ+NupI= diff --git a/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs b/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs index e519daac621a3187a2637d9ab68608d059899e45..83479259dc38e74fe25f0bc13cee9fce2be6d285 100644 --- a/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs +++ b/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs @@ -335,6 +335,16 @@ namespace TUGraz.VectoCore.Tests.Utils throw new NotImplementedException(); } + public void ResetComponents() + { + throw new NotImplementedException(); + } + + public void FinishSingleSimulationRun(Exception e = null) + { + throw new NotImplementedException(); + } + #region Implementation of IPowertainInfo diff --git a/VectoCore/VectoCoreTest/VectoCoreTest.csproj b/VectoCore/VectoCoreTest/VectoCoreTest.csproj index d51695d8a9f3dad74a81b1e54fa9af9f78317cd9..ab17540d1987f5ec84958eb0dd85e6f36dd3ec2f 100644 --- a/VectoCore/VectoCoreTest/VectoCoreTest.csproj +++ b/VectoCore/VectoCoreTest/VectoCoreTest.csproj @@ -24,6 +24,7 @@ <ItemGroup> <ProjectReference Include="..\..\VectoCommon\VectoCommon\VectoCommon.csproj" /> + <ProjectReference Include="..\..\VectoCommon\VectoHashing\VectoHashing.csproj" /> <ProjectReference Include="..\VectoCore\VectoCore.csproj" /> </ItemGroup>