diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/AuxiliaryDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/AuxiliaryDataAdapter.cs index 70451885b9466be886d939e629b9a386b3ba6c9a..abfed569a0e8d6e5899cc08752f8462ba2248190 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/AuxiliaryDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/AuxiliaryDataAdapter.cs @@ -196,61 +196,6 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen ConnectToREESS = true, }; - - VectoRunData.AuxData.PowerDemandFunc parallelHybridPowerDemand = (dataBus, mechPower) => { - double xFactor = 0; - if (mechPower == true) - { - throw new NotImplementedException( - "Conditioning only applies to xEVs and should be connected to the DCDC system"); - } - var elInfo = dataBus.ElectricMotorInfo(dataBus.PowertrainInfo.ElectricMotorPositions.Single()); - 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; - }; - - VectoRunData.AuxData.PowerDemandFunc powerDemandFunc = (dataBus, mechPower) => { - var elInfo = dataBus.ElectricMotorInfo(dataBus.PowertrainInfo.ElectricMotorPositions.Single()); - if (mechPower == true) { - throw new NotImplementedException( - "Conditioning only applies to xEVs and should be connected to the DCDC system"); - } - if (elInfo.EmOff) - { - return 0.SI<Watt>(); - } - else - { - return DeclarationData.Conditioning.LookupPowerDemand(hdv, mission); - } - }; - - - - switch (jobType) { - case VectoSimulationJobType.ConventionalVehicle: - throw new VectoException("Should not be created for conventional vehicles"); - case VectoSimulationJobType.BatteryElectricVehicle: - case VectoSimulationJobType.SerialHybridVehicle: - aux.PowerDemandDataBusFunc = powerDemandFunc; - break; - case VectoSimulationJobType.ParallelHybridVehicle: - aux.PowerDemandDataBusFunc = parallelHybridPowerDemand; - break; - case VectoSimulationJobType.EngineOnlySimulation: - case VectoSimulationJobType.IEPC_E: - case VectoSimulationJobType.IEPC_S: - case VectoSimulationJobType.IHPC: - default: - throw new ArgumentOutOfRangeException(nameof(jobType), jobType, null); - } auxDataList.Add(aux); } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Auxiliaries/Conditioning.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Auxiliaries/Conditioning.cs index 64950d5d0e52bdec11835a8bd765acfa360a1edd..135c3cc1ac6b0eda117aa212e6b20c9bc491b762 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Auxiliaries/Conditioning.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Auxiliaries/Conditioning.cs @@ -1,31 +1,114 @@ using System; +using System.Collections.Generic; +using System.Linq; +using System.ServiceModel.Syndication; +using System.Text; +using System.Threading.Tasks; +using TUGraz.VectoCommon.Exceptions; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Configuration; +using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponents; +using TUGraz.VectoCore.Models.Connector.Ports.Impl; using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Models.Simulation.Data; +using TUGraz.VectoCore.Models.Simulation.DataBus; namespace TUGraz.VectoCore.Models.SimulationComponent.Impl.Auxiliaries { - public class Conditioning + public interface IAuxDemand { + Watt PowerDemand(IDataBus dataBus); + string AuxID { get; } + } + + public class Conditioning : IAuxDemand + { + private readonly Watt electricPowerDemand; + + #region Implementation of IAuxDemand + + public string AuxID { get; } + + #endregion - public Conditioning(VectoRunData.AuxData auxData) + public Conditioning(VectoRunData.AuxData condAuxData) { - if (!auxData.ID.Contains(Constants.Auxiliaries.IDs.Cond)) { - throw new ArgumentException(); + if (condAuxData.ID != Constants.Auxiliaries.IDs.Cond) { + throw new VectoException($"Invalid {nameof(condAuxData)}: ID must be {Constants.Auxiliaries.IDs.Cond}"); } + electricPowerDemand = condAuxData.PowerDemandElectric; + AuxID = condAuxData.ID; + } + public Watt PowerDemand(IDataBus dataBus) + { + switch (dataBus.PowertrainInfo.VehicleArchitecutre) { + case VectoSimulationJobType.BatteryElectricVehicle: + case VectoSimulationJobType.SerialHybridVehicle: + return GetPEV_SHEV_PowerDemand(dataBus); + case VectoSimulationJobType.ParallelHybridVehicle: + return GetP_HEV_PowerDemand(dataBus); + case VectoSimulationJobType.EngineOnlySimulation: + case VectoSimulationJobType.IEPC_E: + case VectoSimulationJobType.IEPC_S: + case VectoSimulationJobType.IHPC: + case VectoSimulationJobType.ConventionalVehicle: + default: + throw new ArgumentOutOfRangeException(); + } + } + public Watt GetPEV_SHEV_PowerDemand(IDataBus dataBus) + { + var elInfo = GetElectricMotorInfo(dataBus); + if (elInfo.EmOff) + { + return 0.SI<Watt>(); + } + else { + return electricPowerDemand; + } + } + public Watt GetP_HEV_PowerDemand(IDataBus dataBus) + { + double xFactor = 0; + var elInfo = GetElectricMotorInfo(dataBus); + 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 electricPowerDemand * xFactor; + } + + private IElectricMotorInfo GetElectricMotorInfo(IDataBus dataBus) + { + try + { + return dataBus.ElectricMotorInfo(dataBus.PowertrainInfo.ElectricMotorPositions.Single()); + } + catch (Exception ex) + { + throw new VectoException("Only one electric motor position supported"); + } } } -} \ No newline at end of file + + +} diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Auxiliaries/ElectricAuxiliaries.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Auxiliaries/ElectricAuxiliaries.cs index ea204b3f6cbce2587faba6ec4bb7e9c1ec96d7c9..d3a36831e8e86371c024df1f93c8a078231aacc1 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Auxiliaries/ElectricAuxiliaries.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Auxiliaries/ElectricAuxiliaries.cs @@ -5,6 +5,7 @@ using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.PrimaryBus; using TUGraz.VectoCore.Models.Connector.Ports.Impl; using TUGraz.VectoCore.Models.Simulation; @@ -76,12 +77,23 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public Watt PowerDemand(Second absTime, Second dt, bool dryRun) { - - + + var auxiliarieIgnoredDuringVehicleStop = new[] { + Constants.Auxiliaries.IDs.Fan, + }; var sum = 0.SI<Watt>(); + foreach (var aux in _auxData) { + var powerDemand = 0.SI<Watt>(); - powerDemand += aux.Value(DataBus); + if (DataBus.VehicleInfo.VehicleStopped) { + powerDemand += auxiliarieIgnoredDuringVehicleStop.Contains(aux.Key) + ? aux.Value(DataBus) + : 0.SI<Watt>(); + } else { + powerDemand += aux.Value(DataBus); + } + if (!dryRun) { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Auxiliaries/SteeringPump.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Auxiliaries/SteeringPump.cs deleted file mode 100644 index 843172b0756c62c702f46cc14ab7bc5648f2fcde..0000000000000000000000000000000000000000 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Auxiliaries/SteeringPump.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.ServiceModel.Syndication; -using System.Text; -using System.Threading.Tasks; -using TUGraz.VectoCommon.Exceptions; -using TUGraz.VectoCommon.Models; -using TUGraz.VectoCommon.Utils; -using TUGraz.VectoCore.Configuration; -using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponents; -using TUGraz.VectoCore.Models.Connector.Ports.Impl; -using TUGraz.VectoCore.Models.Simulation.Data; -using TUGraz.VectoCore.Models.Simulation.DataBus; - -namespace TUGraz.VectoCore.Models.SimulationComponent.Impl.Auxiliaries -{ - public class SteeringPumpSystem : IAuxDemand - { - private bool ConnectedToREESS = false; - - private List<VectoRunData.AuxData> fullyElectricSp = new List<VectoRunData.AuxData>(); - private List<VectoRunData.AuxData> mechanicalSp = new List<VectoRunData.AuxData>(); - - - - - public SteeringPumpSystem(VectoRunData.AuxData[] spAuxData) - { - if (spAuxData.Any(aux => aux.ID != Constants.Auxiliaries.IDs.SteeringPump)) { - throw new VectoException($"Only steering pumps can be used in {nameof(SteeringPumpSystem)}"); - } - - ConnectedToREESS = spAuxData.All(aux => aux.ConnectToREESS); - if (spAuxData.Any(aux => aux.ConnectToREESS != ConnectedToREESS)) { - throw new VectoException("All steering pumps must be connected to either REESS or Engine"); - } - - if (spAuxData.Any(auxData => auxData.DemandType != AuxiliaryDemandType.Constant)) { - throw new VectoException("Only constant auxiliaries supported"); - } - - if (ConnectedToREESS && spAuxData.Any(aux => !aux.IsFullyElectric)) { - throw new VectoException("Only fully electric steering pumps can be connected to REESS"); - } - - foreach (var aux in spAuxData) { - if (aux.IsFullyElectric) { - fullyElectricSp.Add(aux); - } else { - mechanicalSp.Add(aux); - } - } - } - - - #region Implementation of IAuxDemand - /// <summary> - /// Returns electrical power demand if the SteeringPumpSystem is connected to REESS - /// </summary> - /// <param name="dataBus"></param> - /// <returns></returns> - public Watt PowerDemand(IDataBus dataBus) - { - var powerDemand = 0.SI<Watt>(); - if (!dataBus.VehicleInfo.VehicleStopped) { - powerDemand += fullyElectricSp - .Sum(aux => ConnectedToREESS ? aux.PowerDemandElectric : aux.PowerDemandMech).DefaultIfNull(0); - } - - powerDemand += mechanicalSp.Sum(aux => ConnectedToREESS ? aux.PowerDemandElectric : aux.PowerDemandMech).DefaultIfNull(0); - return powerDemand; - } - - public string AuxID => Constants.Auxiliaries.IDs.SteeringPump; - - #endregion - } - - public interface IAuxDemand - { - Watt PowerDemand(IDataBus dataBus); - - string AuxID { get; } - } -}