From 5150f14dd1a0c1e39cd30ca6ad05c25e5fc0af72 Mon Sep 17 00:00:00 2001 From: Markus Quaritsch <markus.quaritsch@tugraz.at> Date: Mon, 27 Jul 2020 11:12:26 +0200 Subject: [PATCH] reading hybrid vehicle from json files --- VECTO/Input Files/Gearbox.vb | 1 + VECTO/Input Files/VectoJob.vb | 6 +++++ .../InputData/EngineeringInputData.cs | 24 +++++++++++++++---- .../FileIO/JSON/JSONComponentInputData.cs | 5 ++++ .../InputData/FileIO/JSON/JSONInputData.cs | 23 ++++++++++++++++++ .../FileIO/JSON/JSONInputDataFactory.cs | 18 +++++++++++++- .../InputData/FileIO/JSON/JSONVehicleData.cs | 2 ++ .../XMLEngineeringJobInputDataProvider.cs | 5 ++++ .../EngineeringDataAdapter.cs | 11 +++++++++ .../EngineeringModeVectoRunDataFactory.cs | 1 + VectoCore/VectoCore/VectoCore.csproj | 1 + .../VectoCoreTest/FileIO/JsonReadTest.cs | 1 + .../Integration/Hybrid/ParallelHybridTest.cs | 4 ++-- .../Class2_RigidTruck.vveh | 12 ++++++---- .../Class2_RigidTruck_ParHyb_ENG.vecto | 7 +++--- .../GenericBattery.vbat | 16 ++++++------- .../GenericEMotor240kW.vem | 22 ++++++++--------- .../GenericEMotor240kW.vemp | 2 +- .../HybridStrategyParams.vctl | 9 ++++--- VectoCore/VectoCoreTest/VectoCoreTest.csproj | 3 +++ 20 files changed, 131 insertions(+), 42 deletions(-) diff --git a/VECTO/Input Files/Gearbox.vb b/VECTO/Input Files/Gearbox.vb index a3e5b96701..c943f2a06c 100644 --- a/VECTO/Input Files/Gearbox.vb +++ b/VECTO/Input Files/Gearbox.vb @@ -889,6 +889,7 @@ Public Class MockJobInputData Implements IEngineeringJobInputData.Vehicle Public Property Vehicle As IVehicleDeclarationInputData Implements IDeclarationJobInputData.Vehicle + Public ReadOnly Property HybridStrategyParameters As IHybridStrategyParameters Implements IEngineeringJobInputData.HybridStrategyParameters Public Property Cycles As IList(Of ICycleData) Implements IEngineeringJobInputData.Cycles Public Property EngineOnlyMode As Boolean Implements IEngineeringJobInputData.EngineOnlyMode Public Property EngineOnly As IEngineEngineeringInputData Implements IEngineeringJobInputData.EngineOnly diff --git a/VECTO/Input Files/VectoJob.vb b/VECTO/Input Files/VectoJob.vb index 7a2be139a8..f344902cde 100644 --- a/VECTO/Input Files/VectoJob.vb +++ b/VECTO/Input Files/VectoJob.vb @@ -602,6 +602,12 @@ Public Class VectoJob End Get End Property + Public ReadOnly Property HybridStrategyParameters As IHybridStrategyParameters Implements IEngineeringJobInputData.HybridStrategyParameters + Get + Return Nothing + End Get + End Property + Public ReadOnly Property Cycles As IList(Of ICycleData) Implements IEngineeringJobInputData.Cycles Get Dim retVal As ICycleData() = New ICycleData(CycleFiles.Count - 1) {} diff --git a/VectoCommon/VectoCommon/InputData/EngineeringInputData.cs b/VectoCommon/VectoCommon/InputData/EngineeringInputData.cs index bab13c84d5..ed83cbc146 100644 --- a/VectoCommon/VectoCommon/InputData/EngineeringInputData.cs +++ b/VectoCommon/VectoCommon/InputData/EngineeringInputData.cs @@ -40,11 +40,14 @@ namespace TUGraz.VectoCommon.InputData { new IVehicleEngineeringInputData Vehicle { get; } - /// <summary> - /// P008 Cycles - /// cf. VECTO Input Parameters.xlsx - /// </summary> - IList<ICycleData> Cycles { get; } + + IHybridStrategyParameters HybridStrategyParameters { get; } + + /// <summary> + /// P008 Cycles + /// cf. VECTO Input Parameters.xlsx + /// </summary> + IList<ICycleData> Cycles { get; } /// <summary> /// P001 @@ -56,6 +59,17 @@ namespace TUGraz.VectoCommon.InputData } + public interface IHybridStrategyParameters + { + double EquivalenceFactor { get; } + + double MinSoC { get; } + + double MaxSoC { get; } + + double TargetSoC { get; } + } + public interface IVehicleEngineeringInputData : IVehicleDeclarationInputData { /// <summary> diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONComponentInputData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONComponentInputData.cs index ee26b45594..204a5ab87d 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONComponentInputData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONComponentInputData.cs @@ -168,6 +168,11 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON get { return Vehicle; } } + public IHybridStrategyParameters HybridStrategyParameters + { + get { return null; } + } + public IVehicleEngineeringInputData Vehicle { get { return VehicleData ?? this; } diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs index 38b0921505..54f740f649 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs @@ -273,6 +273,11 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON get { return VehicleInputData; } } + public virtual IHybridStrategyParameters HybridStrategyParameters + { + get { return null; } + } + public virtual IEngineeringJobInputData JobInputData { get { return this; } @@ -1029,6 +1034,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON #endregion } + + public class EcoRollInputData : IEcoRollEngineeringInputData { #region Implementation of IEcoRollEngineeringInputData @@ -1181,4 +1188,20 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON #endregion } + + public class JSONInputDataV8 : JSONInputDataV5 + { + public JSONInputDataV8(JObject data, string filename, bool tolerateMissing = false) : base(data, filename, tolerateMissing) { } + + public override IHybridStrategyParameters HybridStrategyParameters + { + get + { + return Body["HybridStrategyParams"] == null + ? null : JSONInputDataFactory.ReadHybridStrategyParameters( + Path.Combine(BasePath, Body.GetEx<string>("HybridStrategyParams")), false); + } + } + + } } diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputDataFactory.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputDataFactory.cs index b1e48b577e..bf6abf0a18 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputDataFactory.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputDataFactory.cs @@ -97,6 +97,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON return new JSONInputDataSingleBusV6(json, filename, tolerateMissing); case 7: return new JSONInputDataComptededBusFactorMethodV7(json, filename, tolerateMissing); + case 8: + return new JSONInputDataV8(json, filename, tolerateMissing); default: throw new VectoException("Job-File: Unsupported FileVersion. Got: {0} ", version); } @@ -170,7 +172,21 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON } } - public static IBatteryPackEngineeringInputData ReadBatteryData(string filename, bool tolerateMissing) + public static IHybridStrategyParameters ReadHybridStrategyParameters(string filename, bool tolerateMissing) + { + var json = ReadFile(filename); + var version = ReadVersion(json); + switch (version) { + case 1: + return new JSONHybridStrategyParameters(json, filename, tolerateMissing); + default: + throw new VectoException("HybridStrategyParameter-File: Unsupported FileVersion. Got {0}", version); + + } + } + + + public static IBatteryPackEngineeringInputData ReadBatteryData(string filename, bool tolerateMissing) { var json = ReadFile(filename); var version = ReadVersion(json); diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs index beb68ceb63..3c244bf7e4 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs @@ -79,6 +79,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON var tmp = new ElectricMachineEntry<IElectricMotorEngineeringInputData>() { Position = PowertrainPositionHelper.Parse(entry.GetEx<string>("Position")), + Ratio = entry.GetEx<double>("Ratio"), + MechanicalEfficiency = entry.GetEx<double>("MechanicalEfficiency"), Count = entry.GetEx<int>("Count"), ElectricMachine = JSONInputDataFactory.ReadElectricMotorData(Path.Combine(BasePath, entry.GetEx<string>("MotorFile")), false) }; diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringJobInputDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringJobInputDataProvider.cs index 775423b377..92b9170d5c 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringJobInputDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringJobInputDataProvider.cs @@ -39,6 +39,11 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider } + public virtual IHybridStrategyParameters HybridStrategyParameters + { + get { return null; } + } + public virtual IList<ICycleData> Cycles { get { return (_cycles ?? (_cycles = Reader.CreateCycles)).Cycles; } diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs index 6fd194084f..bf6b3c3c09 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs @@ -663,5 +663,16 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter Inertia = motorData.Inertia, }; } + + public HybridStrategyParameters CreateHybridStrategyParameters(IHybridStrategyParameters hybridStrategyParameters) + { + var retVal = new HybridStrategyParameters() { + EquivalenceFactor = hybridStrategyParameters.EquivalenceFactor, + MinSoC = hybridStrategyParameters.MinSoC, + MaxSoC = hybridStrategyParameters.MaxSoC, + TargetSoC = hybridStrategyParameters.TargetSoC + }; + return retVal; + } } } diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringModeVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringModeVectoRunDataFactory.cs index 0e123a83d3..eca20e7248 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringModeVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringModeVectoRunDataFactory.cs @@ -115,6 +115,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl Cycle = new DrivingCycleProxy(drivingCycle, cycle.Name), ExecutionMode = ExecutionMode.Engineering, ElectricMachinesData = dao.CreateElectricMachines(vehicle.Components.ElectricMachines), + HybridStrategyParameters = dao.CreateHybridStrategyParameters(InputDataProvider.JobInputData.HybridStrategyParameters), BatteryData = dao.CreateBatteryData(vehicle.Components.ElectricStorage, vehicle.InitialSOC), SimulationType = SimulationType.DistanceCycle | SimulationType.MeasuredSpeedCycle | SimulationType.PWheel, GearshiftParameters = dao.CreateGearshiftData( diff --git a/VectoCore/VectoCore/VectoCore.csproj b/VectoCore/VectoCore/VectoCore.csproj index 448800c4c9..3f4d2b81f3 100644 --- a/VectoCore/VectoCore/VectoCore.csproj +++ b/VectoCore/VectoCore/VectoCore.csproj @@ -144,6 +144,7 @@ <Compile Include="InputData\FileIO\JSON\JSONComponentInputData.cs" /> <Compile Include="InputData\FileIO\JSON\JSONElectricMotor.cs" /> <Compile Include="InputData\FileIO\JSON\JsonExtensionMethods.cs" /> + <Compile Include="InputData\FileIO\JSON\JSONHybridStrategyParameters.cs" /> <Compile Include="InputData\FileIO\JSON\JSONTCUData.cs" /> <Compile Include="InputData\FileIO\JSON\SSMInputData.cs" /> <Compile Include="InputData\FileIO\XML\Declaration\DataProvider\AbstractCommonComponentType.cs" /> diff --git a/VectoCore/VectoCoreTest/FileIO/JsonReadTest.cs b/VectoCore/VectoCoreTest/FileIO/JsonReadTest.cs index 190bc0df3e..af65fd243a 100644 --- a/VectoCore/VectoCoreTest/FileIO/JsonReadTest.cs +++ b/VectoCore/VectoCoreTest/FileIO/JsonReadTest.cs @@ -528,6 +528,7 @@ namespace TUGraz.VectoCore.Tests.FileIO public bool SavedInDeclarationMode { get; set; } public IVehicleEngineeringInputData Vehicle { get; set; } + public IHybridStrategyParameters HybridStrategyParameters { get; } public IList<ICycleData> Cycles { get; set; } public bool EngineOnlyMode { get; set; } public IEngineEngineeringInputData EngineOnly { get; set; } diff --git a/VectoCore/VectoCoreTest/Integration/Hybrid/ParallelHybridTest.cs b/VectoCore/VectoCoreTest/Integration/Hybrid/ParallelHybridTest.cs index 99c43ad99f..1428da91e8 100644 --- a/VectoCore/VectoCoreTest/Integration/Hybrid/ParallelHybridTest.cs +++ b/VectoCore/VectoCoreTest/Integration/Hybrid/ParallelHybridTest.cs @@ -38,9 +38,9 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid public const string BatFile = @"TestData\Hybrids\Battery\GenericBattery.vbat"; public const string AccelerationFile = @"TestData\Components\Truck.vacc"; - public const string MotorFile240kW = @"TestData\Hybrids\ElectricMotor\GenericEMotor240kW.vem"; + public const string MotorFile240kW = @"TestData\Hybrids\ElectricMotor\GenericEMotor240kW.vem"; - public const string GearboxIndirectLoss = @"TestData\Components\Indirect Gear.vtlm"; + public const string GearboxIndirectLoss = @"TestData\Components\Indirect Gear.vtlm"; public const string GearboxDirectLoss = @"TestData\Components\Direct Gear.vtlm"; [OneTimeSetUp] diff --git a/VectoCore/VectoCoreTest/TestData/Hybrids/GenericVehicle_Group2_P2/Class2_RigidTruck.vveh b/VectoCore/VectoCoreTest/TestData/Hybrids/GenericVehicle_Group2_P2/Class2_RigidTruck.vveh index f59250f537..e43f461144 100644 --- a/VectoCore/VectoCoreTest/TestData/Hybrids/GenericVehicle_Group2_P2/Class2_RigidTruck.vveh +++ b/VectoCore/VectoCoreTest/TestData/Hybrids/GenericVehicle_Group2_P2/Class2_RigidTruck.vveh @@ -34,14 +34,16 @@ }, "ElectricMotors": [ { - "Count": 1, - "Position": "P2", - "MotorFile": "GenericEMotor240kW.vem" + "Count": 1, + "Ratio": 1, + "MechanicalEfficiency": 1, + "Position": "P2", + "MotorFile": "GenericEMotor240kW.vem" } - ], + ], "Battery": { "NumPacks": 2, - "BatteryFile": "GenericBattery.vbat", + "BatteryFile": "GenericBattery.vbat" }, "InitialSoC": 80, "TorqueLimits": {}, diff --git a/VectoCore/VectoCoreTest/TestData/Hybrids/GenericVehicle_Group2_P2/Class2_RigidTruck_ParHyb_ENG.vecto b/VectoCore/VectoCoreTest/TestData/Hybrids/GenericVehicle_Group2_P2/Class2_RigidTruck_ParHyb_ENG.vecto index 3c0afab2b0..f774a58669 100644 --- a/VectoCore/VectoCoreTest/TestData/Hybrids/GenericVehicle_Group2_P2/Class2_RigidTruck_ParHyb_ENG.vecto +++ b/VectoCore/VectoCoreTest/TestData/Hybrids/GenericVehicle_Group2_P2/Class2_RigidTruck_ParHyb_ENG.vecto @@ -3,7 +3,7 @@ "CreatedBy": " ()", "Date": "2016-10-13T08:55:18.2100810Z", "AppVersion": "3", - "FileVersion": 4 + "FileVersion": 8 }, "Body": { "SavedInDeclMode": false, @@ -16,8 +16,7 @@ "AuxiliaryVersion": "CLASSIC", "AdvancedAuxiliaryFilePath": "", - "HybridStrategy": "SimpleParallelHybridStrategy", - "HybridCtlFile": "HybridStrategyParams.vctl", + "HybridStrategyParams": "HybridStrategyParams.vctl", "Aux": [], "Padd": 3540.0, @@ -47,7 +46,7 @@ }, "Cycles": [ "RegionalDelivery", - "UrbanDelivery" + ] } } \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/TestData/Hybrids/GenericVehicle_Group2_P2/GenericBattery.vbat b/VectoCore/VectoCoreTest/TestData/Hybrids/GenericVehicle_Group2_P2/GenericBattery.vbat index 1aa2c2ac95..fe2e69719a 100644 --- a/VectoCore/VectoCoreTest/TestData/Hybrids/GenericVehicle_Group2_P2/GenericBattery.vbat +++ b/VectoCore/VectoCoreTest/TestData/Hybrids/GenericVehicle_Group2_P2/GenericBattery.vbat @@ -7,17 +7,17 @@ }, "Body": { "SavedInDeclMode": false, - "Model": "Generic Battery", - "InternalResistance": 0.12, - "SOC_min": 20, - "SOC_max": 80, - "MaxCurrentFactor": 5, - "Capacity": 14, + "Model": "Generic Battery", + "SOC_min": 20, + "SOC_max": 80, + "Capacity": 7.5, + "InternalResistance": 0.4986666, + "MaxCurrentFactor": 50, "SOC": [ [ 0, 590 ], [ 10, 614 ], [ 20, 626 ], - [ 30, 632 ], + [ 30, 634 ], [ 40, 638 ], [ 50, 640 ], [ 60, 640 ], @@ -26,5 +26,5 @@ [ 90, 650 ], [ 100, 658 ] ] - } + } } \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/TestData/Hybrids/GenericVehicle_Group2_P2/GenericEMotor240kW.vem b/VectoCore/VectoCoreTest/TestData/Hybrids/GenericVehicle_Group2_P2/GenericEMotor240kW.vem index c135ad47cb..74a934daae 100644 --- a/VectoCore/VectoCoreTest/TestData/Hybrids/GenericVehicle_Group2_P2/GenericEMotor240kW.vem +++ b/VectoCore/VectoCoreTest/TestData/Hybrids/GenericVehicle_Group2_P2/GenericEMotor240kW.vem @@ -1,16 +1,16 @@ { - "Header": { - "CreatedBy": " ()", - "Date": "2016-10-13T08:54:28.7387223Z", - "AppVersion": "3", - "FileVersion": 1 - }, - "Body": { - "SavedInDeclMode": false, + "Header": { + "CreatedBy": " ()", + "Date": "2016-10-13T08:54:28.7387223Z", + "AppVersion": "3", + "FileVersion": 1 + }, + "Body": { + "SavedInDeclMode": false, "Model": "Generic Electric Motor", - "FullLoadCurve": "GenericEMotor240kW.vemp", - "EfficiencyMap": "GenericMap240kW.vemo", + "FullLoadCurve": "GenericEMotor240kW.vemp", "DragCurve": "GenericDrag.vemd", - "Inertia" : 0.15 + "EfficiencyMap": "GenericMap240kW.vemo", + "Inertia" : 0.2 } } \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/TestData/Hybrids/GenericVehicle_Group2_P2/GenericEMotor240kW.vemp b/VectoCore/VectoCoreTest/TestData/Hybrids/GenericVehicle_Group2_P2/GenericEMotor240kW.vemp index d5f1106f86..694f189434 100644 --- a/VectoCore/VectoCoreTest/TestData/Hybrids/GenericVehicle_Group2_P2/GenericEMotor240kW.vemp +++ b/VectoCore/VectoCoreTest/TestData/Hybrids/GenericVehicle_Group2_P2/GenericEMotor240kW.vemp @@ -1,4 +1,4 @@ -n [rpm] , T_drive [Nm] , T_drag [Nm] +n [rpm] , T_drive [Nm] , T_recuperation [Nm] 0 , 802.14 , -802.14 1600 , 802.14 , -802.14 1665 , 802.14 , -802.14 diff --git a/VectoCore/VectoCoreTest/TestData/Hybrids/GenericVehicle_Group2_P2/HybridStrategyParams.vctl b/VectoCore/VectoCoreTest/TestData/Hybrids/GenericVehicle_Group2_P2/HybridStrategyParams.vctl index 5a94a8a4c5..3df557399e 100644 --- a/VectoCore/VectoCoreTest/TestData/Hybrids/GenericVehicle_Group2_P2/HybridStrategyParams.vctl +++ b/VectoCore/VectoCoreTest/TestData/Hybrids/GenericVehicle_Group2_P2/HybridStrategyParams.vctl @@ -6,10 +6,9 @@ "FileVersion": 1 }, "Body": { - "ICE IgnitionOn Speed": "600" , - "ICE RampUp Torque": "-800" , - "Electric Motor Ramp Down Time On Engine Start": "0.1", - "Generator Speed": "1400" , - "Generator Torque": "600" + "EquivalenceFactor": 2.5, + "MinSoC": 20 , + "MaxSoC": 80, + "TargetSoC": 50 } } \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/VectoCoreTest.csproj b/VectoCore/VectoCoreTest/VectoCoreTest.csproj index 2d6840cf78..1f21390cf7 100644 --- a/VectoCore/VectoCoreTest/VectoCoreTest.csproj +++ b/VectoCore/VectoCoreTest/VectoCoreTest.csproj @@ -432,6 +432,9 @@ <None Include="TestData\Hybrids\GenericVehicle_Group2_P2\GenericMap240kW.vemo"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> + <None Include="TestData\Hybrids\GenericVehicle_Group2_P2\HybridStrategyParams.vctl"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> <None Include="TestData\Hybrids\GenericVehicle_Group2_P2\Truck.vacc"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> -- GitLab