From 054079a4074cb5c52cef19c70c421d36e64af29a Mon Sep 17 00:00:00 2001 From: "VKMTHD\\haraldmartini" <harald.martini@student.tugraz.at> Date: Tue, 27 Sep 2022 09:42:00 +0200 Subject: [PATCH] PowertrainBuilder: connect only aux with ConnectToREESS set to true to DCDC converter renamed P_ES_consumers to P_aux_el_HV added attribute mapping for electric machine power map --- ...ectricMotorDeclarationInputDataProvider.cs | 7 +- .../ComponentData/ElectricMotorMapReader.cs | 5 + .../AuxiliaryDataAdapter.cs | 107 +++++++++++------- .../ElectricMachinesDataAdapter.cs | 3 +- .../Models/Declaration/DeclarationData.cs | 1 + .../Models/Simulation/Data/ModalResult.cs | 2 +- .../Simulation/Data/ModalResultField.cs | 2 +- .../Models/Simulation/Data/VectoRunData.cs | 2 +- .../Simulation/Impl/PowertrainBuilder.cs | 76 ++----------- .../SimulationComponent/DCDCConverter.cs | 19 ++-- .../SimulationComponent/ElectricSystem.cs | 2 +- .../Impl/ElectricAuxiliaries.cs | 18 ++- .../OutputData/ModalDataContainer.cs | 4 +- .../VectoCore/OutputData/SumDataFields.cs | 2 +- .../OutputData/XML/AttributeMappings.cs | 10 ++ 15 files changed, 133 insertions(+), 127 deletions(-) diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLElectricMotorDeclarationInputDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLElectricMotorDeclarationInputDataProvider.cs index a8d5bd96a4..403fbacfd1 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLElectricMotorDeclarationInputDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLElectricMotorDeclarationInputDataProvider.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Xml; using System.Xml.Linq; +using TUGraz.IVT.VectoXML; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Resources; @@ -133,11 +134,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider public class ElectricMotorPowerMap : AbstractXMLType, IElectricMotorPowerMap { - private Dictionary<string, string> powerMapMapping = new Dictionary<string, string> { - { XMLNames.PowerMap_OutShaftSpeed, XMLNames.PowerMap_OutShaftSpeed }, - { XMLNames.PowerMap_Torque, XMLNames.PowerMap_Torque }, - { XMLNames.PowerMap_ElectricPower, XMLNames.PowerMap_ElectricPower } - }; + private Dictionary<string, string> powerMapMapping = AttributeMappings.EMPowerMap; public ElectricMotorPowerMap(XmlNode xmlNode) : base(xmlNode) { } diff --git a/VectoCore/VectoCore/InputData/Reader/ComponentData/ElectricMotorMapReader.cs b/VectoCore/VectoCore/InputData/Reader/ComponentData/ElectricMotorMapReader.cs index 9e618d7747..a8c28b645a 100644 --- a/VectoCore/VectoCore/InputData/Reader/ComponentData/ElectricMotorMapReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/ComponentData/ElectricMotorMapReader.cs @@ -76,6 +76,11 @@ namespace TUGraz.VectoCore.InputData.Reader.ComponentData { var speeds = new MeanShiftClustering(){ClusterCount = 100}.FindClusters(entries.Select(x => x.MotorSpeed.AsRPM).ToArray(), 10) .Where(x => x > 0).ToList(); + + if (speeds.Count <= 2) { + throw new VectoException( + "Failed to generate electric power map - at least two speed entries > 0 are required!"); + } var lowerSpeed = speeds.First().RPMtoRad() / 2.0; var upperSpeed = speeds.First().RPMtoRad() + (speeds[1] - speeds.First()).RPMtoRad() / 2.0; diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/AuxiliaryDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/AuxiliaryDataAdapter.cs index f214af2d3d..b501b01430 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/AuxiliaryDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/AuxiliaryDataAdapter.cs @@ -9,6 +9,7 @@ using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.PrimaryBus; +using TUGraz.VectoCore.InputData.Reader.Impl.DeclarationMode.HeavyLorryRunDataFactory; using TUGraz.VectoCore.Models.BusAuxiliaries; using TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electrics; using TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC; @@ -163,13 +164,13 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen AddSteeringPumps(mission, hdvClass, numSteeredAxles, jobType, auxData, alternatorEfficiency, aux, retVal); break; case AuxiliaryType.HVAC: - AddHVAC(mission, hdvClass, aux, auxData, 1/DeclarationData.HVACElectricEfficiencyFactor, retVal); + AddHVAC(mission, jobType, hdvClass, aux, auxData, 1/DeclarationData.HVACElectricEfficiencyFactor, retVal); break; case AuxiliaryType.PneumaticSystem: AddPneumaticSystem(mission, jobType, auxData, alternatorEfficiency, aux,retVal); break; case AuxiliaryType.ElectricSystem: - AddElectricSystem(mission, aux, auxData, alternatorEfficiency, retVal); + AddElectricSystem(mission, jobType, aux, auxData, alternatorEfficiency, retVal); break; default: continue; } @@ -194,17 +195,22 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen IsFullyElectric = true, MissionType = mission, DemandType = AuxiliaryDemandType.Dynamic, - ID = "Cond" + ID = "Cond", + ConnectToREESS = true, }; Func<IDataBus, Watt> parallelHybridPowerDemand = (dataBus) => { + double xFactor = 0; var elInfo = dataBus.ElectricMotorInfo(dataBus.PowertrainInfo.ElectricMotorPositions.Single()); - var iceInfo = dataBus.EngineInfo; - var emPower = elInfo.ElectricMotorSpeed * elInfo.ElectricMotorTorque; - var icePower = iceInfo.EngineSpeed * iceInfo.EngineTorque; - - var xFactor = emPower.Abs() / (emPower.Abs() + icePower.Abs()); + if (!elInfo.EmOff) { + var iceInfo = dataBus.EngineInfo; + var emPower = elInfo.ElectricMotorSpeed * elInfo.ElectricMotorTorque; + var icePower = iceInfo.EngineSpeed * iceInfo.EngineTorque; + + xFactor = emPower.Abs() / (emPower.Abs() + icePower.Abs()); + } + return DeclarationData.Conditioning.LookupPowerDemand(hdv, mission) * xFactor; }; @@ -243,12 +249,15 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen } - private static void AddElectricSystem(MissionType mission, VectoRunData.AuxData aux, + private static void AddElectricSystem(MissionType mission, VectoSimulationJobType vectoSimulationJobType, + VectoRunData.AuxData aux, IAuxiliaryDeclarationInputData auxData, double alternatorEfficiency, List<VectoRunData.AuxData> auxDataList) { aux.PowerDemandMech = DeclarationData.ElectricSystem.Lookup(mission, auxData.Technology.FirstOrDefault()).PowerDemand; aux.ID = Constants.Auxiliaries.IDs.ElectricSystem; aux.PowerDemandElectric = aux.PowerDemandMech * alternatorEfficiency; + aux.ConnectToREESS = vectoSimulationJobType.IsOneOf(VectoSimulationJobType.BatteryElectricVehicle, + VectoSimulationJobType.ParallelHybridVehicle); auxDataList.Add(aux); } @@ -273,10 +282,18 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen } else { aux.PowerDemandElectric = aux.PowerDemandMech * alternatorEfficiency; } + + aux.ConnectToREESS = aux.IsFullyElectric && jobType.IsOneOf( + VectoSimulationJobType.BatteryElectricVehicle, + VectoSimulationJobType.SerialHybridVehicle, + VectoSimulationJobType.IEPC_E, + VectoSimulationJobType.IEPC_S, + VectoSimulationJobType.ParallelHybridVehicle); auxDataList.Add(aux); } - private static void AddHVAC(MissionType mission, VehicleClass hdvClass, VectoRunData.AuxData aux, + private static void AddHVAC(MissionType mission, VectoSimulationJobType vectoSimulationJobType, + VehicleClass hdvClass, VectoRunData.AuxData aux, IAuxiliaryDeclarationInputData auxData, double efficiency, List<VectoRunData.AuxData> auxDataList) { aux.PowerDemandMech = DeclarationData.HeatingVentilationAirConditioning.Lookup( @@ -284,6 +301,9 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen auxData.Technology.FirstOrDefault(), hdvClass).PowerDemand; aux.ID = Constants.Auxiliaries.IDs.HeatingVentilationAirCondition; aux.PowerDemandElectric = aux.PowerDemandMech * efficiency; + + aux.ConnectToREESS = (vectoSimulationJobType == VectoSimulationJobType.BatteryElectricVehicle || + vectoSimulationJobType == VectoSimulationJobType.SerialHybridVehicle); auxDataList.Add(aux); return; } @@ -307,37 +327,48 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen var powerDemand = DeclarationData.SteeringPump.Lookup(mission, hdvClass, auxData.Technology); - if (powerDemand.mechanicalPumps != 0.SI<Watt>()) { - var spMech = new VectoRunData.AuxData - { - DemandType = AuxiliaryDemandType.Constant, - Technology = auxData.Technology.Where(tech => !DeclarationData.SteeringPump.IsFullyElectric(tech)) - .ToList(), - IsFullyElectric = false, - ID = Constants.Auxiliaries.IDs.SteeringPump, - PowerDemandMech = powerDemand.mechanicalPumps, - MissionType = mission, - }; + var spMech = new VectoRunData.AuxData + { + DemandType = AuxiliaryDemandType.Constant, + Technology = auxData.Technology.Where(tech => !DeclarationData.SteeringPump.IsFullyElectric(tech)) + .ToList(), + IsFullyElectric = false, + ID = Constants.Auxiliaries.IDs.SteeringPump, + PowerDemandMech = powerDemand.mechanicalPumps, + MissionType = mission, + }; - auxDataList.Add(spMech); - } - if (powerDemand.electricPumps != 0.SI<Watt>()) { - var spElectric = new VectoRunData.AuxData + if (jobType == VectoSimulationJobType.ConventionalVehicle) { + //Add to mechanical steering pump aux + spMech.PowerDemandMech += powerDemand.electricPumps; + } else { + //Create separate auxiliary component for connection to REESS via DC/DC converter + if (powerDemand.electricPumps.IsGreater(0)) { - DemandType = AuxiliaryDemandType.Constant, - Technology = auxData.Technology.Where(tech => DeclarationData.SteeringPump.IsFullyElectric(tech)) - .ToList(), - IsFullyElectric = true, - ID = Constants.Auxiliaries.IDs.SteeringPump_el, - PowerDemandElectric = powerDemand.electricPumps * alternatorEfficiency, - PowerDemandMech = powerDemand.electricPumps / alternatorEfficiency, //in case the fully electric pumps are connected to a Conventional vehicle - MissionType = mission, - }; + var spElectric = new VectoRunData.AuxData + { + DemandType = AuxiliaryDemandType.Constant, + Technology = auxData.Technology.Where(tech => DeclarationData.SteeringPump.IsFullyElectric(tech)) + .ToList(), + IsFullyElectric = true, + ConnectToREESS = true, + ID = Constants.Auxiliaries.IDs.SteeringPump_el, + PowerDemandElectric = powerDemand.electricPumps * alternatorEfficiency, + PowerDemandMech = powerDemand.electricPumps, + MissionType = mission, + }; + + auxDataList.Add(spElectric); + } + } - auxDataList.Add(spElectric); + if (spMech.PowerDemandMech.IsGreater(0)) + { + auxDataList.Add(spMech); } + } private static void AddFan(MissionType mission, VehicleClass hdvClass, VectoSimulationJobType jobType, @@ -356,11 +387,11 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen aux.PowerDemandMech = DeclarationData.Fan.LookupPowerDemand(hdvClass, mission, auxData.Technology.FirstOrDefault()); aux.ID = Constants.Auxiliaries.IDs.Fan; aux.IsFullyElectric = DeclarationData.Fan.IsFullyElectric(hdvClass, auxData.Technology.FirstOrDefault()); - - aux.PowerDemandElectric = aux.PowerDemandMech * alternatorEfficiency; + aux.PowerDemandElectric = aux.PowerDemandMech * alternatorEfficiency; + aux.ConnectToREESS = aux.IsFullyElectric && (!jobType.IsOneOf(VectoSimulationJobType.ConventionalVehicle, + VectoSimulationJobType.EngineOnlySimulation)); auxDataList.Add(aux); } - #endregion } diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/ElectricMachinesDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/ElectricMachinesDataAdapter.cs index be7003ec71..2556fb85ee 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/ElectricMachinesDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/ElectricMachinesDataAdapter.cs @@ -88,7 +88,8 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen voltageLevels.Add(vLevelData); } catch (Exception ex) { throw new VectoException( - $"Could not create Voltage Level data for {entry.VoltageLevel} at position {powertrainPosition}", + $"Could not create Voltage Level data for {entry.VoltageLevel} at position {powertrainPosition}!\n" + + $"{ex.Message}", ex); } } diff --git a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs index 95af962560..adf8108d17 100644 --- a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs +++ b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs @@ -102,6 +102,7 @@ namespace TUGraz.VectoCore.Models.Declaration public static readonly WeightingFactors WeightingFactors = new WeightingFactors(); public const double AlternatorEfficiency = 0.7; + public const double DCDCEfficiency = 1.0; public const double HVACElectricEfficiencyFactor = 0.8; diff --git a/VectoCore/VectoCore/Models/Simulation/Data/ModalResult.cs b/VectoCore/VectoCore/Models/Simulation/Data/ModalResult.cs index cf1ce88b6e..3989005867 100644 --- a/VectoCore/VectoCore/Models/Simulation/Data/ModalResult.cs +++ b/VectoCore/VectoCore/Models/Simulation/Data/ModalResult.cs @@ -306,7 +306,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Data // ------------------------------------------------------------------------------------ public static readonly ModalResultField[] ElectricSystemSignals = { - ModalResultField.P_ES_consumers, + ModalResultField.P_Aux_el_HV, }; // ------------------------------------------------------------------------------------ diff --git a/VectoCore/VectoCore/Models/Simulation/Data/ModalResultField.cs b/VectoCore/VectoCore/Models/Simulation/Data/ModalResultField.cs index 08dd4a8329..600af83d19 100644 --- a/VectoCore/VectoCore/Models/Simulation/Data/ModalResultField.cs +++ b/VectoCore/VectoCore/Models/Simulation/Data/ModalResultField.cs @@ -117,7 +117,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Data /// <summary> /// [kW] Total auxiliary power demand . /// </summary> - [ModalResultField(typeof(SI), caption: "P_es_consumers [kW]", outputFactor: 1e-3)] P_ES_consumers, + [ModalResultField(typeof(SI), caption: "P_aux_el_HV [kW]", outputFactor: 1e-3)] P_Aux_el_HV, /// <summary> /// [g/h] Fuel consumption from FC map.. diff --git a/VectoCore/VectoCore/Models/Simulation/Data/VectoRunData.cs b/VectoCore/VectoCore/Models/Simulation/Data/VectoRunData.cs index b001885665..7a57e9e9b8 100644 --- a/VectoCore/VectoCore/Models/Simulation/Data/VectoRunData.cs +++ b/VectoCore/VectoCore/Models/Simulation/Data/VectoRunData.cs @@ -196,7 +196,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Data [Required] public AuxiliaryDemandType DemandType; - [Required] public bool ConnectToDcDc; + [Required] public bool ConnectToREESS; [Required] public bool IsFullyElectric; diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs b/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs index c244bd3b36..15a99effe0 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs @@ -692,9 +692,9 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl var ctl = new BatteryElectricMotorController(container, es); - var aux = new HighVoltageElectricAuxiliary(container); - aux.AddConstant("P_aux_el", data.ElectricAuxDemand ?? 0.SI<Watt>()); - es.Connect(aux); + //var aux = new HighVoltageElectricAuxiliary(container); + //aux.AddConstant("P_aux_el", data.ElectricAuxDemand ?? 0.SI<Watt>()); + //es.Connect(aux); var cycle = new DistanceBasedDrivingCycle(container, data.Cycle); @@ -765,9 +765,13 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl es.Connect(dcdc); em.BusAux = busAux; } else { - var dcdc = new DCDCConverter(container, 1); + var dcdc = new DCDCConverter(container, DeclarationData.DCDCEfficiency); + es.Connect(dcdc); - dcdc.Connect(new ElectricAuxiliaries(container)); + var elAux = new ElectricAuxiliaries(container); + elAux.AddAuxiliaries(data.Aux.Where(x => x.ConnectToREESS)); + + dcdc.Connect(elAux); dcdc.Initialize(); } @@ -1657,68 +1661,6 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl var shiftStrategyName = GetShiftStrategyName(gearboxType, jobType, isTestPowerTrain); runData.ShiftStrategy = shiftStrategyName; return ShiftStrategy.Create(container, runData.ShiftStrategy); - - switch (gearboxType) { - case GearboxType.AMT: - switch (jobType) { - case VectoSimulationJobType.ConventionalVehicle: - case VectoSimulationJobType.ParallelHybridVehicle: - runData.ShiftStrategy = AMTShiftStrategyOptimized.Name; - return new AMTShiftStrategyOptimized(container); - case VectoSimulationJobType.BatteryElectricVehicle: - case VectoSimulationJobType.SerialHybridVehicle: - runData.ShiftStrategy = PEVAMTShiftStrategy.Name; - return new PEVAMTShiftStrategy(container); - default: - throw new VectoException( - "no default gearshift strategy available for gearbox type {0} and job type {1}", - gearboxType, jobType); - } - case GearboxType.MT: - runData.ShiftStrategy = MTShiftStrategy.Name; - return new MTShiftStrategy(container); - - case GearboxType.ATPowerSplit: - case GearboxType.ATSerial: - switch (jobType) { - case VectoSimulationJobType.ParallelHybridVehicle: - case VectoSimulationJobType.ConventionalVehicle: - runData.ShiftStrategy = ATShiftStrategyOptimized.Name; - return new ATShiftStrategyOptimized(container); - case VectoSimulationJobType.SerialHybridVehicle: - case VectoSimulationJobType.BatteryElectricVehicle: - runData.ShiftStrategy = APTNShiftStrategy.Name; - return new APTNShiftStrategy(container); - default: - throw new VectoException( - "no default gearshift strategy available for gearbox type {0} and job type {1}", - gearboxType, jobType); - } - case GearboxType.APTN: - switch (jobType) { - case VectoSimulationJobType.ParallelHybridVehicle: - case VectoSimulationJobType.SerialHybridVehicle: - case VectoSimulationJobType.BatteryElectricVehicle: - case VectoSimulationJobType.IEPC_E: - case VectoSimulationJobType.IEPC_S: - runData.ShiftStrategy = APTNShiftStrategy.Name; - return new APTNShiftStrategy(container); - case VectoSimulationJobType.ConventionalVehicle when container.IsTestPowertrain: - return null; - default: - throw new ArgumentException("APT-N Gearbox is only applicable on hybrids and battery electric vehicles."); - } - case GearboxType.IHPC: - switch (jobType) { - case VectoSimulationJobType.IHPC: - runData.ShiftStrategy = AMTShiftStrategyOptimized.Name; - return new AMTShiftStrategyOptimized(container); - default: - throw new ArgumentException("IHPC Gearbox is only applicable on hybrid vehicle of type IHPC."); - } - default: - throw new ArgumentOutOfRangeException("GearboxType", gearboxType, "VECTO can not automatically derive shift strategy for GearboxType."); - } } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/DCDCConverter.cs b/VectoCore/VectoCore/Models/SimulationComponent/DCDCConverter.cs index 11b7126d9b..6235dba057 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/DCDCConverter.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/DCDCConverter.cs @@ -40,23 +40,24 @@ namespace TUGraz.VectoCore.Models.SimulationComponent var dischargeEnergy = (-DataBus.BatteryInfo.MaxDischargePower(dt) * dt); var chargeEnergy = (-DataBus.BatteryInfo.MaxChargePower(dt) * dt); - var efficiency = PreviousState.ConsumedEnergy > 0 ? 1 / Efficiency : Efficiency; + var efficiency = PreviousState.ConsumedEnergy > 0 ? 1 / Efficiency : Efficiency; //WHY ? - - + + var electricConsumersPower = + _electricConsumers.Sum(aux => aux.PowerDemand(absTime, dt, dryRun)).DefaultIfNull(0); if (!dryRun) { - CurrentState.ConsumedEnergy += _electricConsumers.Sum(aux => aux.PowerDemand(absTime, dt, dryRun)).DefaultIfNull(0) * dt; + CurrentState.ElectricAuxPower = electricConsumersPower; } + if ((PreviousState.ConsumedEnergy * efficiency).IsBetween(chargeEnergy, dischargeEnergy)) { - return PreviousState.ConsumedEnergy / dt * efficiency; - + return (PreviousState.ConsumedEnergy / dt * efficiency) + electricConsumersPower; } // write in mod-file for post-processing correction if (!dryRun) { - CurrentState.MissingEnergy = PreviousState.ConsumedEnergy; + CurrentState.MissingEnergy = PreviousState.ConsumedEnergy + electricConsumersPower * dt; } return 0.SI<Watt>(); @@ -109,9 +110,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent { MissingEnergy = 0.SI<WattSecond>(); ConsumedEnergy = 0.SI<WattSecond>(); + + ElectricAuxPower = 0.SI<Watt>(); simInterval = 0.SI<Second>(); } + public Watt ElectricAuxPower { get; set; } + public WattSecond ConsumedEnergy { get; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/ElectricSystem.cs b/VectoCore/VectoCore/Models/SimulationComponent/ElectricSystem.cs index ea6c76ac63..7bdcbc29e4 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/ElectricSystem.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/ElectricSystem.cs @@ -69,7 +69,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent protected override void DoWriteModalResults(Second absTime, Second dt, IModalDataContainer container) { - container[ModalResultField.P_ES_consumers] = CurrentState.AuxPower; + container[ModalResultField.P_Aux_el_HV] = CurrentState.AuxPower; } protected override void DoCommitSimulationStep(Second time, Second simulationInterval) diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricAuxiliaries.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricAuxiliaries.cs index c70468729b..ad9ce93cf4 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricAuxiliaries.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricAuxiliaries.cs @@ -19,7 +19,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// </summary> public class ElectricAuxiliaries : VectoSimulationComponent, IElectricAuxPort { - private IEnumerable<VectoRunData.AuxData> _auxData; + private IList<VectoRunData.AuxData> _auxData = new List<VectoRunData.AuxData>(4); private IDictionary<string, string> _auxColumnName = new Dictionary<string, string>(); private IDictionary<string, Watt> _powerDemands = new Dictionary<string, Watt>(); @@ -34,12 +34,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } + + + private IVehicleContainer VehicleContainer { get; set; } public Watt Initialize() { - _auxData = VehicleContainer.RunData.Aux.Where(aux => aux.MissionType == VehicleContainer.RunData.Mission.MissionType); foreach (var auxData in _auxData) { var name = $"P_{auxData.ID}_el"; _auxColumnName.Add(auxData.ID, name); //use column name as ID @@ -49,6 +51,18 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return 0.SI<Watt>(); } + public void AddAuxiliary(VectoRunData.AuxData aux) + { + _auxData.Add(aux); + } + + public void AddAuxiliaries(IEnumerable<VectoRunData.AuxData> auxData) + { + foreach (var aux in auxData) { + AddAuxiliary(aux); + } + } + public Watt PowerDemand(Second absTime, Second dt, bool dryRun) { diff --git a/VectoCore/VectoCore/OutputData/ModalDataContainer.cs b/VectoCore/VectoCore/OutputData/ModalDataContainer.cs index 2ac21234a6..2883141ba1 100644 --- a/VectoCore/VectoCore/OutputData/ModalDataContainer.cs +++ b/VectoCore/VectoCore/OutputData/ModalDataContainer.cs @@ -662,7 +662,7 @@ namespace TUGraz.VectoCore.OutputData ModalResultField.P_clutch_out, // Aux ModalResultField.P_aux_mech, - ModalResultField.P_ES_consumers, + ModalResultField.P_Aux_el_HV, // Gbx ModalResultField.P_gbx_in, ModalResultField.P_gbx_loss, @@ -831,7 +831,7 @@ namespace TUGraz.VectoCore.OutputData dataColumns.AddRange( new[] { ModalResultField.P_aux_mech, - ModalResultField.P_ES_consumers + ModalResultField.P_Aux_el_HV }.Select(x => x.GetName())); if (!writeEngineOnly) { diff --git a/VectoCore/VectoCore/OutputData/SumDataFields.cs b/VectoCore/VectoCore/OutputData/SumDataFields.cs index bd283d4bef..27beb27709 100644 --- a/VectoCore/VectoCore/OutputData/SumDataFields.cs +++ b/VectoCore/VectoCore/OutputData/SumDataFields.cs @@ -465,7 +465,7 @@ namespace TUGraz.VectoCore.OutputData { E_POWERTRAIN_INERTIA, SumFunc((r, m) => m.PowerAccelerations().ConvertToKiloWattHour(), ModalResultField.P_ice_inertia, ModalResultField.P_gbx_inertia)}, { E_AUX, SumFunc((r, m) => m.WorkAuxiliaries()?.ConvertToKiloWattHour(), ModalResultField.P_aux_mech)}, - { E_AUX_EL_HV, SumFunc((r, m) => m.TimeIntegral<WattSecond>(ModalResultField.P_ES_consumers).ConvertToKiloWattHour(), ModalResultField.P_ES_consumers)}, + { E_AUX_EL_HV, SumFunc((r, m) => m.TimeIntegral<WattSecond>(ModalResultField.P_Aux_el_HV).ConvertToKiloWattHour(), ModalResultField.P_Aux_el_HV)}, { E_CLUTCH_LOSS, SumFunc((r, m) => m.WorkClutch().ConvertToKiloWattHour(), ModalResultField.P_clutch_loss)}, { E_TC_LOSS, SumFunc((r, m) => m.WorkTorqueConverter().ConvertToKiloWattHour(), ModalResultField.P_TC_loss)}, { E_SHIFT_LOSS, SumFunc((r, m) => m.WorkGearshift().ConvertToKiloWattHour(), ModalResultField.P_gbx_shift_loss)}, diff --git a/VectoCore/VectoCore/OutputData/XML/AttributeMappings.cs b/VectoCore/VectoCore/OutputData/XML/AttributeMappings.cs index ba3da16449..56a43154b2 100644 --- a/VectoCore/VectoCore/OutputData/XML/AttributeMappings.cs +++ b/VectoCore/VectoCore/OutputData/XML/AttributeMappings.cs @@ -30,6 +30,7 @@ */ using System.Collections.Generic; +using System.Security; using TUGraz.VectoCommon.Resources; using TUGraz.VectoCore.InputData.Reader.ComponentData; using TUGraz.VectoCore.Models.Declaration; @@ -130,6 +131,8 @@ namespace TUGraz.IVT.VectoXML { DrivingCycleDataReader.Fields.PTOTorque, XMLNames.Vehicle_PTOCycle_Torque_Attr }, }; + #region Battery + public static readonly Dictionary<string, string> InternalResistanceMap = new Dictionary<string, string> { { BatteryInternalResistanceReader.Fields.StateOfCharge, XMLNames.REESS_InternalResistanceCurve_SoC }, { BatteryInternalResistanceReader.Fields.InternalResistance_2, XMLNames.REESS_InternalResistanceCurve_R2 }, { @@ -153,6 +156,13 @@ namespace TUGraz.IVT.VectoXML { BatteryMaxCurrentReader.Fields.MaxDischargeCurrent, XMLNames.REESS_CurrentLimits_MaxDischargingCurrent } }; + #endregion + public static readonly Dictionary<string, string> EMPowerMap = new Dictionary<string, string> { + { ElectricMotorMapReader.Fields.MotorSpeed, XMLNames.PowerMap_OutShaftSpeed }, + {ElectricMotorMapReader.Fields.Torque, XMLNames.PowerMap_Torque }, + { ElectricMotorMapReader.Fields.PowerElectrical, XMLNames.PowerMap_ElectricPower } + }; + //ElectricMotorMapReader } } \ No newline at end of file -- GitLab