From 3822147f8611489e29cd26158da8ac5e467aab1a Mon Sep 17 00:00:00 2001 From: Markus Quaritsch <markus.quaritsch@tugraz.at> Date: Sat, 6 Mar 2021 11:25:40 +0100 Subject: [PATCH] refactoring busaux P0 model - move battery to outer scope so that power is taken either from battery or DC/DC converter. Add infinity battery and nobattery classes to handle case C3a --- .../Class5_Tractor_ENG_WHR_ESS.vecto | 4 +- .../EngineeringDataAdapter.cs | 15 +- .../Models/BusAuxiliaries/BusAuxiliaries.cs | 91 ++++---- .../Impl/Electrics/M05Impl_P0.cs | 4 +- .../Impl/Electrics/SimpleBattery.cs | 118 ++++++++++- .../DownstreamModules/Impl/M07Impl.cs | 4 +- .../Electrics/ISimpleBattery.cs | 16 +- .../Interfaces/IBusAuxiliaries.cs | 40 ++-- .../Simulation/Data/ModalResultField.cs | 4 +- .../Simulation/DataBus/IDCDCConverter.cs | 10 + .../Models/Simulation/DataBus/IDataBus.cs | 5 +- .../Simulation/Impl/PowertrainBuilder.cs | 45 +++- .../Simulation/Impl/VehicleContainer.cs | 5 +- .../SimulationComponent/DCDCConverter.cs | 14 +- .../Impl/BusAuxiliariesAdapter.cs | 198 +++++++++++++----- .../SimulationComponent/Impl/ElectricMotor.cs | 8 +- .../Impl/HybridController.cs | 7 + .../Impl/StopStartCombustionEngine.cs | 17 +- .../Strategies/HybridStrategy.cs | 52 +++-- .../Strategies/TestPowertrain.cs | 13 +- .../OutputData/IModalDataContainer.cs | 2 +- .../OutputData/ModalDataContainer.cs | 19 +- .../BusAuxiliaries/AuxDemandTest.cs | 6 + .../Integration/CoachAdvancedAuxPowertrain.cs | 9 +- .../HybridStrategyParams.vhctl | 4 +- .../Utils/MockVehicleContainer.cs | 2 + 26 files changed, 522 insertions(+), 190 deletions(-) create mode 100644 VectoCore/VectoCore/Models/Simulation/DataBus/IDCDCConverter.cs diff --git a/Generic Vehicles/Engineering Mode/Group5_Tractor_4x2/Class5_Tractor_ENG_WHR_ESS.vecto b/Generic Vehicles/Engineering Mode/Group5_Tractor_4x2/Class5_Tractor_ENG_WHR_ESS.vecto index 8b378902e0..7efe8dc862 100644 --- a/Generic Vehicles/Engineering Mode/Group5_Tractor_4x2/Class5_Tractor_ENG_WHR_ESS.vecto +++ b/Generic Vehicles/Engineering Mode/Group5_Tractor_4x2/Class5_Tractor_ENG_WHR_ESS.vecto @@ -1,7 +1,7 @@ { "Header": { "CreatedBy": "", - "Date": "2021-03-03T09:16:12.9178198Z", + "Date": "2021-03-04T09:56:51.9746221Z", "AppVersion": "3", "FileVersion": 5 }, @@ -15,7 +15,7 @@ "ShiftStrategy": "", "Padd": 5000.0, "Paux_ICEOff_Driving": 5000.0, - "Paux_ICEOff_Standstill": 0.0, + "Paux_ICEOff_Standstill": 1500.0, "VACC": "Truck.vacc", "EngineStopStartAtVehicleStopThreshold": 2.0, "EngineStopStartMaxOffTimespan": 120.0, diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs index 1925addaf0..3a00e5b350 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs @@ -527,9 +527,13 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter AlternatorGearEfficiency = Constants.BusAuxiliaries.ElectricSystem.AlternatorGearEfficiency, DoorActuationTimeSecond = Constants.BusAuxiliaries.ElectricalConsumers.DoorActuationTimeSecond, AlternatorMap = new SimpleAlternator(busAux.ElectricSystem.AlternatorEfficiency) { - Technologies = new List<string>() { "engineering mode"} + Technologies = new List<string>() { "engineering mode" } }, - AlternatorType = busAux.ElectricSystem.AlternatorType, + AlternatorType = + busAux.ElectricSystem.ESSupplyFromHEVREESS && + busAux.ElectricSystem.AlternatorType != AlternatorType.Smart + ? AlternatorType.None + : busAux.ElectricSystem.AlternatorType, ConnectESToREESS = busAux.ElectricSystem.ESSupplyFromHEVREESS, DCDCEfficiency = busAux.ElectricSystem.DCDCConverterEfficiency.LimitTo(0, 1), MaxAlternatorPower = busAux.ElectricSystem.MaxAlternatorPower, @@ -551,7 +555,9 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter StopBrakeActuation = 0.SI<NormLiterPerKilogram>(), }, PneumaticUserInputsConfig = new PneumaticUserInputsConfig() { - CompressorMap = new CompressorMap(CompressorMapReader.Create(busAux.PneumaticSystem.CompressorMap, 1.0), "engineering mode", busAux.PneumaticSystem.CompressorMap.Source), + CompressorMap = + new CompressorMap(CompressorMapReader.Create(busAux.PneumaticSystem.CompressorMap, 1.0), + "engineering mode", busAux.PneumaticSystem.CompressorMap.Source), CompressorGearEfficiency = Constants.BusAuxiliaries.PneumaticUserConfig.CompressorGearEfficiency, CompressorGearRatio = busAux.PneumaticSystem.GearRatio, SmartAirCompression = busAux.PneumaticSystem.SmartAirCompression, @@ -574,7 +580,8 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter HeatingDemand = busAux.HVACData.AverageHeatingDemand, AuxHeaterEfficiency = Constants.BusAuxiliaries.SteadyStateModel.AuxHeaterEfficiency, FuelEnergyToHeatToCoolant = Constants.BusAuxiliaries.Heater.FuelEnergyToHeatToCoolant, - CoolantHeatTransferredToAirCabinHeater = Constants.BusAuxiliaries.Heater.CoolantHeatTransferredToAirCabinHeater, + CoolantHeatTransferredToAirCabinHeater = + Constants.BusAuxiliaries.Heater.CoolantHeatTransferredToAirCabinHeater, }, VehicleData = vehicleData, }; diff --git a/VectoCore/VectoCore/Models/BusAuxiliaries/BusAuxiliaries.cs b/VectoCore/VectoCore/Models/BusAuxiliaries/BusAuxiliaries.cs index 584c6219e6..c9d5e3b491 100644 --- a/VectoCore/VectoCore/Models/BusAuxiliaries/BusAuxiliaries.cs +++ b/VectoCore/VectoCore/Models/BusAuxiliaries/BusAuxiliaries.cs @@ -37,7 +37,7 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries private Ampere _totalAverageDemandAmpsEngineOffDriving; private ISSMPowerDemand ssmTool; - public BusAuxiliariesNoAlternator(IModalDataContainer modDataContainer) : base(modDataContainer) { } + public BusAuxiliariesNoAlternator(ISimpleBatteryInfo battery) : base(battery) { } public override void Initialise(IAuxiliaryConfig auxCfg) @@ -58,7 +58,6 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries new SimpleSSMTool(auxConfig.SSMInputs) : (ISSMPowerDemand)new SSMTOOL(auxConfig.SSMInputs); - ElectricStorage = new SimpleBattery(0.SI<WattSecond>()); var electricUserInputConfigNoAlternator = new ElectricsUserInputsConfig() { PowerNetVoltage = auxCfg.ElectricalUserInputsConfig.PowerNetVoltage, @@ -95,7 +94,7 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries } public override Watt ElectricPowerConsumer { - get { return M2.AveragePowerDemandAtAlternatorFromElectrics; } + get { return AveragePowerDemandAtAlternatorFromElectrics; } } public override Watt HVACElectricalPowerConsumer { @@ -156,8 +155,8 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries protected IM6 M6; protected IM7 M7; protected IM8 M8; + public ISimpleBatteryInfo ElectricStorage { get; protected set; } - protected ISimpleBattery ElectricStorage; //private IM9 M9; //private IM10 M10; @@ -167,15 +166,13 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries //private IM14 M14; - public BusAuxiliaries(IModalDataContainer modDataContainer) + public BusAuxiliaries(ISimpleBatteryInfo battery) { Signals = new Signals(); - if (modDataContainer != null) { - modDataContainer.AuxHeaterDemandCalc = AuxHeaterDemandCalculation; - } + ElectricStorage = battery; } - protected virtual Joule AuxHeaterDemandCalculation(Second cycleTime, Joule engineWasteHeatTotal) + public virtual Joule AuxHeaterDemandCalculation(Second cycleTime, Joule engineWasteHeatTotal) { if (auxConfig == null) { throw new VectoException("Auxiliary configuration missing!"); @@ -204,11 +201,7 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries new SimpleSSMTool(auxConfig.SSMInputs) : (ISSMPowerDemand)new SSMTOOL(auxConfig.SSMInputs); - ElectricStorage = new SimpleBattery( - auxCfg.ElectricalUserInputsConfig.AlternatorType == AlternatorType.Smart - ? auxCfg.ElectricalUserInputsConfig.ElectricStorageCapacity - : 0.SI<WattSecond>()); - + M0 = new M00Impl(auxConfig.ElectricalUserInputsConfig, Signals, ssmTool.ElectricalWAdjusted); //M0_5 = new M0_5Impl( @@ -357,11 +350,7 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries get { return M1.AveragePowerDemandAtCrankFromHVACMechanicals; } } - public virtual double BatterySOC - { - get { return ElectricStorage.SOC; } - } - + //public string AuxiliaryName //{ // get { return "BusAuxiliaries"; } @@ -377,33 +366,51 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries get { return M8.AuxPowerAtCrankFromElectricalHVACAndPneumaticsAncillaries; } } - - public virtual void CycleStep(Second seconds, double essFactor) + public WattSecond BatteryEnergyDemand(Second dt, double essFactor) { - try { - //M9.CycleStep(seconds); - //M10.CycleStep(seconds); - //M11.CycleStep(seconds); - if (auxConfig.ElectricalUserInputsConfig.AlternatorType == AlternatorType.Smart) { - var generatedElPower = - (auxConfig.PneumaticUserInputsConfig.SmartAirCompression - ? M7.SmartElectricalAndPneumaticAuxAltPowerGenAtCrank - : M7.SmartElectricalOnlyAuxAltPowerGenAtCrank) * M0.AlternatorsEfficiency * - auxConfig.ElectricalUserInputsConfig.AlternatorGearEfficiency; - var energy = (generatedElPower - ElectricPowerConsumerSum) * essFactor * seconds; - var maxCharge = (ElectricStorage.SOC - 1) * ElectricStorage.Capacity; - var maxDischarge = ElectricStorage.SOC * ElectricStorage.Capacity; - var batEnergy = energy.LimitTo(-maxDischarge, -maxCharge); - ElectricStorage.Request(batEnergy); - } - Signals.CurrentCycleTimeInSeconds += seconds.Value(); - } catch (Exception ex) { - //MessageBox.Show("Exception: " + ex.Message + " Stack Trace: " + ex.StackTrace); - throw ex; + if (auxConfig.ElectricalUserInputsConfig.AlternatorType == AlternatorType.Smart) { + var generatedElPower = + (auxConfig.PneumaticUserInputsConfig.SmartAirCompression + ? M7.SmartElectricalAndPneumaticAuxAltPowerGenAtCrank + : M7.SmartElectricalOnlyAuxAltPowerGenAtCrank) * M0.AlternatorsEfficiency * + auxConfig.ElectricalUserInputsConfig.AlternatorGearEfficiency; + var energy = (generatedElPower - ElectricPowerConsumerSum) * essFactor * dt; + return energy; } + + return 0.SI<WattSecond>(); } - public virtual void ResetCalculations() + + + + + public virtual void CycleStep(Second seconds, double essFactor) + { + try { + //M9.CycleStep(seconds); + //M10.CycleStep(seconds); + //M11.CycleStep(seconds); + //if (auxConfig.ElectricalUserInputsConfig.AlternatorType == AlternatorType.Smart) { + // var generatedElPower = + // (auxConfig.PneumaticUserInputsConfig.SmartAirCompression + // ? M7.SmartElectricalAndPneumaticAuxAltPowerGenAtCrank + // : M7.SmartElectricalOnlyAuxAltPowerGenAtCrank) * M0.AlternatorsEfficiency * + // auxConfig.ElectricalUserInputsConfig.AlternatorGearEfficiency; + // var energy = (generatedElPower - ElectricPowerConsumerSum) * essFactor * seconds; + // var maxCharge = (ElectricStorage.SOC - 1) * ElectricStorage.Capacity; + // var maxDischarge = ElectricStorage.SOC * ElectricStorage.Capacity; + // var batEnergy = energy.LimitTo(-maxDischarge, -maxCharge); + // ElectricStorage.Request(batEnergy); + //} + Signals.CurrentCycleTimeInSeconds += seconds.Value(); + } catch (Exception ex) { + //MessageBox.Show("Exception: " + ex.Message + " Stack Trace: " + ex.StackTrace); + throw ex; + } + } + + public virtual void ResetCalculations() { var modules = new List<IAbstractModule>() { M0, M1, M2, M3, M4, M5, M6, M7, M8 }; foreach (var moduel in modules) diff --git a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/M05Impl_P0.cs b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/M05Impl_P0.cs index 2dcc1d94cf..d5aa17120c 100644 --- a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/M05Impl_P0.cs +++ b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/M05Impl_P0.cs @@ -10,13 +10,13 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electric { private IM2_AverageElectricalLoadDemand _m02; private IM1_AverageHVACLoadDemand _m01; - private ISimpleBattery _bat; + private ISimpleBatteryInfo _bat; private IM0_NonSmart_AlternatorsSetEfficiency _m00; private ISignals _signals; private double _alternatorGearEfficiency; private Watt _maxAlternatorPower; - public M05Impl_P0(IM0_NonSmart_AlternatorsSetEfficiency m0, IM1_AverageHVACLoadDemand m01, IM2_AverageElectricalLoadDemand m02, ISimpleBattery bat, IElectricsUserInputsConfig elCfg, ISignals signals) + public M05Impl_P0(IM0_NonSmart_AlternatorsSetEfficiency m0, IM1_AverageHVACLoadDemand m01, IM2_AverageElectricalLoadDemand m02, ISimpleBatteryInfo bat, IElectricsUserInputsConfig elCfg, ISignals signals) { _m00 = m0; _m01 = m01; diff --git a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/SimpleBattery.cs b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/SimpleBattery.cs index a7b5b9fc98..f2a5f33496 100644 --- a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/SimpleBattery.cs +++ b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/SimpleBattery.cs @@ -1,12 +1,73 @@ using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces.DownstreamModules.Electrics; +using TUGraz.VectoCore.Models.Simulation; +using TUGraz.VectoCore.Models.Simulation.Impl; +using TUGraz.VectoCore.Models.SimulationComponent; +using TUGraz.VectoCore.OutputData; namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electrics { - public class SimpleBattery : LoggingObject, ISimpleBattery + + public class NoBattery : VectoSimulationComponent, ISimpleBattery { - public SimpleBattery(WattSecond capacity, double soc = 0.9) + public NoBattery(IVehicleContainer dataBus) : base(dataBus) { } + + #region Implementation of ISimpleBatteryInfo + + public double SOC + { + get { return 0; } + } + public WattSecond Capacity + { + get { return 0.SI<WattSecond>(); } + } + + #endregion + + #region Implementation of ISimpleBattery + + public WattSecond ConsumedEnergy { get; } + public void ConsumeEnergy(WattSecond energy, bool dryRun) + { + + } + + public WattSecond MaxChargeEnergy() + { + return 0.SI<WattSecond>(); + } + + public WattSecond MaxDischargeEnergy() + { + return 0.SI<WattSecond>(); + } + + #endregion + + + + #region Overrides of VectoSimulationComponent + + protected override void DoWriteModalResults(Second time, Second simulationInterval, IModalDataContainer container) + { + + } + + protected override void DoCommitSimulationStep(Second time, Second simulationInterval) + { + + } + + #endregion + } + + // ######################################## + + public class SimpleBattery : StatefulVectoSimulationComponent<SimpleBattery.State>, ISimpleBattery + { + public SimpleBattery(IVehicleContainer container, WattSecond capacity, double soc = 0.9) : base(container) { Capacity = capacity; SOC = soc; @@ -16,12 +77,58 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electric public double SOC { get; private set; } public WattSecond Capacity { get; } + public WattSecond ConsumedEnergy + { + get { return CurrentState.ConsumedEnergy; } + } + + public void ConsumeEnergy(WattSecond energy, bool dryRun) + { + if (!dryRun) { + CurrentState.ConsumedEnergy = energy; + } + var tmpSoc = SOC + energy / Capacity; + if (tmpSoc > 1) { + Log.Warn("SOC would exceed max!"); + + } + if (tmpSoc < 0) { + Log.Warn("SOC would exceed min!"); + } + } #endregion - public void Request(WattSecond energy) + + public WattSecond MaxChargeEnergy() + { + return -(SOC - 1) * Capacity; + } + + public WattSecond MaxDischargeEnergy() + { + return -SOC * Capacity; + } + + public class State { - SOC += energy / Capacity; + public State() + { + ConsumedEnergy = 0.SI<WattSecond>(); + } + public WattSecond ConsumedEnergy { get; set; } + } + + #region Overrides of VectoSimulationComponent + + protected override void DoWriteModalResults(Second time, Second simulationInterval, IModalDataContainer container) + { + + } + + protected override void DoCommitSimulationStep(Second time, Second simulationInterval) + { + SOC += CurrentState.ConsumedEnergy / Capacity; if (SOC > 1) { Log.Warn("SOC > 1!"); SOC = 1; @@ -30,6 +137,9 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electric Log.Warn("SOC < 0!"); SOC = 0; } + AdvanceState(); } + + #endregion } } diff --git a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/M07Impl.cs b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/M07Impl.cs index cb540bfc75..4d8b14b4d3 100644 --- a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/M07Impl.cs +++ b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/M07Impl.cs @@ -15,14 +15,14 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl protected IM5_SmartAlternatorSetGeneration _m5; protected IM6 _m6; protected readonly ISignals _signals; - private ISimpleBattery _bat; + private ISimpleBatteryInfo _bat; private IM2_AverageElectricalLoadDemand _m2; private IM1_AverageHVACLoadDemand _m1; private IM0_NonSmart_AlternatorsSetEfficiency _m0; private double _alternatorGearEfficiency; public M07Impl(IM0_NonSmart_AlternatorsSetEfficiency m0, IM1_AverageHVACLoadDemand m1, - IM2_AverageElectricalLoadDemand m2, IM5_SmartAlternatorSetGeneration m5, IM6 m6, ISimpleBattery bat, + IM2_AverageElectricalLoadDemand m2, IM5_SmartAlternatorSetGeneration m5, IM6 m6, ISimpleBatteryInfo bat, double alternatorGearEfficiency, ISignals signals) { _m5 = m5; diff --git a/VectoCore/VectoCore/Models/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/ISimpleBattery.cs b/VectoCore/VectoCore/Models/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/ISimpleBattery.cs index c33d28d8f0..2afae59c4b 100644 --- a/VectoCore/VectoCore/Models/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/ISimpleBattery.cs +++ b/VectoCore/VectoCore/Models/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/ISimpleBattery.cs @@ -1,9 +1,21 @@ using TUGraz.VectoCommon.Utils; namespace TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces.DownstreamModules.Electrics { - public interface ISimpleBattery { + + public interface ISimpleBatteryInfo + { double SOC { get; } WattSecond Capacity { get; } - void Request(WattSecond energy); + + } + + public interface ISimpleBattery : ISimpleBatteryInfo + { + WattSecond ConsumedEnergy { get; } + + //void Request(WattSecond energy); + void ConsumeEnergy(WattSecond energy, bool dryRun); + WattSecond MaxChargeEnergy(); + WattSecond MaxDischargeEnergy(); } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/BusAuxiliaries/Interfaces/IBusAuxiliaries.cs b/VectoCore/VectoCore/Models/BusAuxiliaries/Interfaces/IBusAuxiliaries.cs index 00cd09c786..380797ff95 100644 --- a/VectoCore/VectoCore/Models/BusAuxiliaries/Interfaces/IBusAuxiliaries.cs +++ b/VectoCore/VectoCore/Models/BusAuxiliaries/Interfaces/IBusAuxiliaries.cs @@ -11,6 +11,7 @@ using TUGraz.VectoCommon.BusAuxiliaries; using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces.DownstreamModules.Electrics; using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.SimulationComponent; @@ -106,7 +107,8 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces Watt PSPowerCompressorDragOnly { get; } Watt HVACMechanicalPowerConsumer { get; } Watt HVACMechanicalPowerGenerated { get; } - double BatterySOC { get; } + + Joule AuxHeaterDemandCalculation(Second cycleTime, Joule engineWasteHeatTotal); ///// <summary> @@ -137,23 +139,23 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces /// <remarks></remarks> void CycleStep(Second seconds, double essFactor); - ///// <summary> - ///// Initialises AAUX Environment ( Begin Processs ) - ///// </summary> - ///// <param name="auxcConfig"></param> - ///// <param name="fuelProperties"></param> - ///// <returns></returns> - ///// <remarks></remarks> - //bool RunStart(IAuxiliaryConfig auxcConfig, IFuelProperties fuelProperties); - - ///// <summary> - ///// Any Termination Which Needs to be done ( Model depenent ) - ///// </summary> - ///// <param name="message"></param> - ///// <returns></returns> - ///// <remarks></remarks> - //bool RunStop(ref string message); - - void ResetCalculations(); + ///// <summary> + ///// Initialises AAUX Environment ( Begin Processs ) + ///// </summary> + ///// <param name="auxcConfig"></param> + ///// <param name="fuelProperties"></param> + ///// <returns></returns> + ///// <remarks></remarks> + //bool RunStart(IAuxiliaryConfig auxcConfig, IFuelProperties fuelProperties); + + ///// <summary> + ///// Any Termination Which Needs to be done ( Model depenent ) + ///// </summary> + ///// <param name="message"></param> + ///// <returns></returns> + ///// <remarks></remarks> + //bool RunStop(ref string message); + + void ResetCalculations(); } } diff --git a/VectoCore/VectoCore/Models/Simulation/Data/ModalResultField.cs b/VectoCore/VectoCore/Models/Simulation/Data/ModalResultField.cs index 620412dd2f..e1740a65ba 100644 --- a/VectoCore/VectoCore/Models/Simulation/Data/ModalResultField.cs +++ b/VectoCore/VectoCore/Models/Simulation/Data/ModalResultField.cs @@ -59,7 +59,9 @@ namespace TUGraz.VectoCore.Models.Simulation.Data [ModalResultField(typeof(SI), caption: "P_ice_start [kW]", outputFactor: 1e-3)] P_ice_start, - [ModalResultField(typeof(SI), caption: "P_aux_ESS_mech [kW]", outputFactor: 1e-3)] P_aux_ice_off, + [ModalResultField(typeof(SI), caption: "P_aux_ESS_mech_ICE_off [kW]", outputFactor: 1e-3)] P_aux_ESS_mech_ice_off, + + [ModalResultField(typeof(SI), caption: "P_aux_ESS_mech_ICE_on [kW]", outputFactor: 1e-3)] P_aux_ESS_mech_ice_on, /// <summary> /// Engine speed [1/min]. diff --git a/VectoCore/VectoCore/Models/Simulation/DataBus/IDCDCConverter.cs b/VectoCore/VectoCore/Models/Simulation/DataBus/IDCDCConverter.cs new file mode 100644 index 0000000000..5c3861dfb5 --- /dev/null +++ b/VectoCore/VectoCore/Models/Simulation/DataBus/IDCDCConverter.cs @@ -0,0 +1,10 @@ +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Models.Connector.Ports.Impl; + +namespace TUGraz.VectoCore.Models.Simulation.DataBus +{ + public interface IDCDCConverter : IElectricAuxPort + { + void ConsumerEnergy(WattSecond electricConsumerPower, bool dryRun); + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/Simulation/DataBus/IDataBus.cs b/VectoCore/VectoCore/Models/Simulation/DataBus/IDataBus.cs index a99137445b..715e43c85e 100644 --- a/VectoCore/VectoCore/Models/Simulation/DataBus/IDataBus.cs +++ b/VectoCore/VectoCore/Models/Simulation/DataBus/IDataBus.cs @@ -83,8 +83,11 @@ namespace TUGraz.VectoCore.Models.Simulation.DataBus IHybridControllerInfo HybridControllerInfo { get; } IHybridControllerCtl HybridControllerCtl { get; } + IAngledriveInfo AngledriveInfo { get; } - + + IDCDCConverter DCDCConverter { get; } + bool IsTestPowertrain { get; } } diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs b/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs index 22f2870826..a88c9c2677 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs @@ -39,6 +39,8 @@ using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.InputData.Reader.ComponentData; +using TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electrics; +using TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces.DownstreamModules.Electrics; using TUGraz.VectoCore.Models.Connector.Ports; using TUGraz.VectoCore.Models.Connector.Ports.Impl; using TUGraz.VectoCore.Models.Declaration; @@ -448,18 +450,25 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl } cycle.IdleController = idleController as IdleControllerSwitcher; - if (data.BusAuxiliaries != null && data.BusAuxiliaries.ElectricalUserInputsConfig.ConnectESToREESS) { + if (data.BusAuxiliaries != null) { if (container.BusAux is BusAuxiliariesAdapter busAux) { - var dcdc = new DCDCConverter(container, - data.BusAuxiliaries.ElectricalUserInputsConfig.DCDCEfficiency); - busAux.DCDCConverter = dcdc; - es.Connect(dcdc); + var auxCfg = data.BusAuxiliaries; + var electricStorage = auxCfg.ElectricalUserInputsConfig.AlternatorType == AlternatorType.Smart + ? new SimpleBattery(container, auxCfg.ElectricalUserInputsConfig.ElectricStorageCapacity) + : (ISimpleBattery)new NoBattery(container); + busAux.ElectricStorage = electricStorage; + if (data.BusAuxiliaries.ElectricalUserInputsConfig.ConnectESToREESS) { + var dcdc = new DCDCConverter(container, + data.BusAuxiliaries.ElectricalUserInputsConfig.DCDCEfficiency); + busAux.DCDCConverter = dcdc; + es.Connect(dcdc); + } + } else { throw new VectoException("BusAux data set but no BusAux component found!"); } } - return container; } @@ -714,16 +723,25 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl } } - if (data.BusAuxiliaries != null && data.BusAuxiliaries.ElectricalUserInputsConfig.ConnectESToREESS) { + if (data.BusAuxiliaries != null) { if (container.BusAux is BusAuxiliariesAdapter busAux) { - var dcdc = new DCDCConverter(container, - data.BusAuxiliaries.ElectricalUserInputsConfig.DCDCEfficiency); - busAux.DCDCConverter = dcdc; - es.Connect(dcdc); + var auxCfg = data.BusAuxiliaries; + var electricStorage = auxCfg.ElectricalUserInputsConfig.AlternatorType == AlternatorType.Smart + ? new SimpleBattery(container, auxCfg.ElectricalUserInputsConfig.ElectricStorageCapacity) + : (ISimpleBattery)new NoBattery(container); + busAux.ElectricStorage = electricStorage; + if (data.BusAuxiliaries.ElectricalUserInputsConfig.ConnectESToREESS) { + var dcdc = new DCDCConverter(container, + data.BusAuxiliaries.ElectricalUserInputsConfig.DCDCEfficiency); + busAux.DCDCConverter = dcdc; + es.Connect(dcdc); + } + } else { throw new VectoException("BusAux data set but no BusAux component found!"); } } + } public void BuildSimplePowertrainE2(VectoRunData data, VehicleContainer container) @@ -821,6 +839,11 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl var conventionalAux = CreateAuxiliaries(data, container); // TODO: MQ 2019-07-30 -- which fuel map for advanced auxiliaries?! var busAux = new BusAuxiliariesAdapter(container, data.BusAuxiliaries, conventionalAux); + var auxCfg = data.BusAuxiliaries; + var electricStorage = auxCfg.ElectricalUserInputsConfig.AlternatorType == AlternatorType.Smart + ? new SimpleBattery(container, auxCfg.ElectricalUserInputsConfig.ElectricStorageCapacity) + : (ISimpleBattery)new NoBattery(container); + busAux.ElectricStorage = electricStorage; return busAux; } diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs b/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs index df7a9bc4d6..bd91405001 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs @@ -80,6 +80,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public virtual ITorqueConverterControl TorqueConverterCtl { get; private set; } + public IDCDCConverter DCDCConverter { get; private set; } + public virtual bool IsTestPowertrain { get { return false; } @@ -195,7 +197,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl }) .If<IHybridController>(c => { HybridController = c; }) .If<IRESSInfo>(c => BatteryInfo = c) - .If<BusAuxiliariesAdapter>(c => BusAux = c); + .If<BusAuxiliariesAdapter>(c => BusAux = c) + .If<IDCDCConverter>(c => DCDCConverter = c); if (ignoreComponent) { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/DCDCConverter.cs b/VectoCore/VectoCore/Models/SimulationComponent/DCDCConverter.cs index fa3fbb8663..1b16ffbedd 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/DCDCConverter.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/DCDCConverter.cs @@ -1,12 +1,13 @@ using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Models.Connector.Ports.Impl; using TUGraz.VectoCore.Models.Simulation.Data; +using TUGraz.VectoCore.Models.Simulation.DataBus; using TUGraz.VectoCore.Models.Simulation.Impl; using TUGraz.VectoCore.OutputData; namespace TUGraz.VectoCore.Models.SimulationComponent { - public class DCDCConverter : StatefulVectoSimulationComponent<DCDCConverter.State>, IElectricAuxPort + public class DCDCConverter : StatefulVectoSimulationComponent<DCDCConverter.State>, IDCDCConverter { public double Efficiency { get; protected set; } @@ -29,12 +30,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent public Watt PowerDemand(Second absTime, Second dt, bool dryRun) { - if (DataBus.BatteryInfo.StoredEnergy.IsGreater(PreviousState.ConsumedEnergy)) { + if ((-DataBus.BatteryInfo.MaxDischargePower(dt) * dt).IsGreater(PreviousState.ConsumedEnergy)) { return PreviousState.ConsumedEnergy / dt / Efficiency; } // write in mod-file for post-processing correction - CurrentState.MissingEnergy = PreviousState.ConsumedEnergy; + if (!dryRun) { + CurrentState.MissingEnergy = PreviousState.ConsumedEnergy; + } + return 0.SI<Watt>(); } @@ -66,10 +70,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent #endregion - public void ConsumerPower(Watt electricConsumerPower, Second dt, bool dryRun) + public void ConsumerEnergy(WattSecond electricConsumerEnergy, bool dryRun) { if (!dryRun) { - CurrentState.ConsumedEnergy = electricConsumerPower * dt; + CurrentState.ConsumedEnergy = electricConsumerEnergy; } } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs index 580f6bad25..8651278c1b 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs @@ -35,6 +35,7 @@ using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Models.BusAuxiliaries; using TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces; +using TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces.DownstreamModules.Electrics; using TUGraz.VectoCore.Models.Simulation; using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.Simulation.DataBus; @@ -70,21 +71,40 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl AuxCfg = auxiliaryConfig; DataBus = container; - var tmpAux = auxiliaryConfig.ElectricalUserInputsConfig.AlternatorType == AlternatorType.None - ? new BusAuxiliaries.BusAuxiliariesNoAlternator(container.ModalData) - : new BusAuxiliaries.BusAuxiliaries(container.ModalData); + if (container.ModalData != null) { + container.ModalData.AuxHeaterDemandCalc = AuxHeaterDemandCalculation; + } + + var electricStorage = + AuxCfg.ElectricalUserInputsConfig.AlternatorType == AlternatorType.Smart && + AuxCfg.ElectricalUserInputsConfig.ConnectESToREESS + // in case of smat alternator with Px hybrid take electric power from P0 REESS first, then from HEV REESS. + // do not use alternator to generate demanded power if P0 REESS is empty. so trick busaux that there is always + // energy in the battery. + ? (ISimpleBatteryInfo)new InfinityBattery(AuxCfg.ElectricalUserInputsConfig.ElectricStorageCapacity) + : new ElectricStorageWrapper(this); + var tmpAux = AuxCfg.ElectricalUserInputsConfig.AlternatorType == AlternatorType.None + ? new BusAuxiliariesNoAlternator(electricStorage) + : new BusAuxiliaries.BusAuxiliaries(electricStorage); + //'Set Signals - tmpAux.Signals.EngineIdleSpeed = container.EngineInfo.EngineIdleSpeed; - tmpAux.Initialise(auxiliaryConfig); + tmpAux.Signals.EngineIdleSpeed = DataBus.EngineInfo.EngineIdleSpeed; + tmpAux.Initialise(AuxCfg); - SmartElectricSystem = auxiliaryConfig.ElectricalUserInputsConfig.AlternatorType == AlternatorType.Smart; + SmartElectricSystem = AuxCfg.ElectricalUserInputsConfig.AlternatorType == AlternatorType.Smart; Auxiliaries = tmpAux; } - public DCDCConverter DCDCConverter { get; set; } + + public IDCDCConverter DCDCConverter { get; set; } + public ISimpleBattery ElectricStorage { get; set; } + + public virtual Joule AuxHeaterDemandCalculation(Second cycleTime, Joule engineWasteHeatTotal) + { + return Auxiliaries.AuxHeaterDemandCalculation(cycleTime, engineWasteHeatTotal);} public IAuxPort Port() { @@ -98,7 +118,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl CurrentState.AngularSpeed = angularSpeed; AdditionalAux?.Initialize(torque, angularSpeed); DCDCConverter?.Initialize(); - PreviousState.PowerDemand = GetBusAuxPowerDemand(0.SI<Second>(), 1.SI<Second>(), torque, angularSpeed); + PreviousState.PowerDemand = GetBusAuxPowerDemand(0.SI<Second>(), 1.SI<Second>(), torque, angularSpeed) + + (AdditionalAux?.PowerDemandEngineOn(0.SI<Second>(), 1.SI<Second>(), angularSpeed) ?? 0.SI<Watt>()); return PreviousState.PowerDemand / angularSpeed; } @@ -113,7 +134,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl signals.EngineStopped = false; signals.VehicleStopped = false; - CurrentState.PowerDemand = GetBusAuxPowerDemand(absTime, dt, torquePowerTrain, angularSpeed, dryRun); + CurrentState.PowerDemand = GetBusAuxPowerDemand(absTime, dt, torquePowerTrain, angularSpeed, dryRun) + + (AdditionalAux?.PowerDemandEngineOn(0.SI<Second>(), 1.SI<Second>(), angularSpeed) ?? 0.SI<Watt>()); var avgAngularSpeed = (CurrentState.AngularSpeed + PreviousState.AngularSpeed) / 2.0; return CurrentState.PowerDemand / avgAngularSpeed; @@ -124,13 +146,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var signals = Auxiliaries.Signals; signals.EngineStopped = false; signals.VehicleStopped = false; - var retVal = GetBusAuxPowerDemand(time, simulationInterval, 0.SI<NewtonMeter>(), engineSpeed, true); + var retVal = GetBusAuxPowerDemand(time, simulationInterval, 0.SI<NewtonMeter>(), engineSpeed, true) + + (AdditionalAux?.PowerDemandEngineOn(0.SI<Second>(), 1.SI<Second>(), engineSpeed) ?? 0.SI<Watt>()); if (!SmartElectricSystem) { return retVal; } - var batteryPwr = Auxiliaries.BatterySOC * AuxCfg.ElectricalUserInputsConfig.ElectricStorageCapacity / simulationInterval; + //var batteryPwr = ElectricStorage.SOC * AuxCfg.ElectricalUserInputsConfig.ElectricStorageCapacity / simulationInterval; var esSum = Auxiliaries.ElectricPowerConsumerSum; //if (batteryPwr < esSum) { retVal += (esSum ) / AuxCfg.ElectricalUserInputsConfig.AlternatorGearEfficiency / @@ -148,30 +171,32 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var signals = Auxiliaries.Signals; - // set internal state of power demand as if ICE is on - multiplied by (1-ESS_UF) - signals.EngineStopped = false; - signals.VehicleStopped = false; + //// set internal state of power demand as if ICE is on - multiplied by (1-ESS_UF) + //signals.EngineStopped = false; + //signals.VehicleStopped = false; + + //// get busaux PowerDemand without additional Auxiliaries first. + //var conventionalAux = AdditionalAux; + //AdditionalAux = null; + signals.EngineStopped = !DataBus.EngineCtl.CombustionEngineOn; + signals.VehicleStopped = DataBus.VehicleInfo.VehicleStopped; - // get busaux PowerDemand without additional Auxiliaries first. - var conventionalAux = AdditionalAux; - AdditionalAux = null; var busAuxPowerDemand = GetBusAuxPowerDemand( absTime, dt, 0.SI<NewtonMeter>(), DataBus.EngineInfo.EngineIdleSpeed); - AdditionalAux = conventionalAux; + //AdditionalAux = conventionalAux; CurrentState.PowerDemand = ((AdditionalAux?.PowerDemandEngineOn(absTime, dt, DataBus.EngineInfo.EngineIdleSpeed) ?? 0.SI<Watt>()) + busAuxPowerDemand) * (1 - EngineStopStartUtilityFactor); //CurrentState.ESPowerGeneratedICE_On = Auxiliaries.ElectricPowerGenerated; //CurrentState.ESPowerMech = Auxiliaries.ElectricPowerDemandMech; // - signals.EngineStopped = !DataBus.EngineCtl.CombustionEngineOn; - signals.VehicleStopped = DataBus.VehicleInfo.VehicleStopped; + - busAuxPowerDemand = GetBusAuxPowerDemand( - absTime, dt, 0.SI<NewtonMeter>(), DataBus.EngineInfo.EngineIdleSpeed); - AdditionalAux = conventionalAux; + //busAuxPowerDemand = GetBusAuxPowerDemand( + // absTime, dt, 0.SI<NewtonMeter>(), DataBus.EngineInfo.EngineIdleSpeed); + //AdditionalAux = conventionalAux; - return EngineStopStartUtilityFactor * (busAuxPowerDemand + AdditionalAux?.PowerDemandEngineOff(absTime, dt)); + return EngineStopStartUtilityFactor * (busAuxPowerDemand + (AdditionalAux?.PowerDemandEngineOff(absTime, dt) ?? 0.SI<Watt>())); } @@ -190,35 +215,44 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl //signals.VehicleStopped = DataBus.VehicleStopped; // cycleStep has to be called here and not in DoCommit, write is called before Commit! - var oldSOC = Auxiliaries.BatterySOC; + //var oldSOC = Auxiliaries.BatterySOC; Auxiliaries.CycleStep(CurrentState.dt, DataBus.EngineCtl.CombustionEngineOn ? 1.0 : EngineStopStartUtilityFactor); - var newSOC = Auxiliaries.BatterySOC; + //var newSOC = Auxiliaries.BatterySOC; //CurrentState.TotalFuelConsumption = Auxiliaries.TotalFuel; container[ModalResultField.P_aux_mech] = CurrentState.PowerDemand; - container[ModalResultField.P_busAux_ES_HVAC] = essUtilityFactor * Auxiliaries.HVACElectricalPowerConsumer; - container[ModalResultField.P_busAux_ES_other] = essUtilityFactor * Auxiliaries.ElectricPowerConsumer; - container[ModalResultField.P_busAux_ES_consumer_sum] = essUtilityFactor * Auxiliaries.ElectricPowerConsumerSum; + container[ModalResultField.P_busAux_ES_HVAC] = /*essUtilityFactor **/ Auxiliaries.HVACElectricalPowerConsumer; + container[ModalResultField.P_busAux_ES_other] = /*essUtilityFactor **/ Auxiliaries.ElectricPowerConsumer; + container[ModalResultField.P_busAux_ES_consumer_sum] = /*essUtilityFactor **/ Auxiliaries.ElectricPowerConsumerSum; container[ModalResultField.P_busAux_ES_sum_mech] = essUtilityFactor * Auxiliaries.ElectricPowerDemandMech; container[ModalResultField.P_busAux_ES_generated] = essUtilityFactor * Auxiliaries.ElectricPowerGenerated; - if (SmartElectricSystem) { - var batteryPwr = (oldSOC - newSOC) * AuxCfg.ElectricalUserInputsConfig.ElectricStorageCapacity / dt; - - container[ModalResultField.BatterySOC] = Auxiliaries.BatterySOC * 100.0; - - container[ModalResultField.P_busAux_ES_generated] = essUtilityFactor * - (DataBus.VehicleInfo.VehicleStopped && - !DataBus.EngineCtl.CombustionEngineOn - ? Auxiliaries.ElectricPowerConsumerSum - : Auxiliaries.ElectricPowerGenerated); - container[ModalResultField.P_busAux_ES_sum_mech] = essUtilityFactor * (Auxiliaries.ElectricPowerConsumerSum - batteryPwr) / - AuxCfg.ElectricalUserInputsConfig.AlternatorGearEfficiency / - AuxCfg.ElectricalUserInputsConfig.AlternatorMap.GetEfficiency(0.RPMtoRad(), 0.SI<Ampere>()); - - if (batteryPwr.IsSmaller(Auxiliaries.ElectricPowerConsumerSum * EngineStopStartUtilityFactor)) { - // add to P_aux_ES + if (AuxCfg.ElectricalUserInputsConfig.ConnectESToREESS) { + container[ModalResultField.P_busAux_ES_HVAC] = Auxiliaries.HVACElectricalPowerConsumer; + container[ModalResultField.P_busAux_ES_other] = Auxiliaries.ElectricPowerConsumer; + container[ModalResultField.P_busAux_ES_consumer_sum] = Auxiliaries.ElectricPowerConsumerSum; + container[ModalResultField.P_busAux_ES_sum_mech] = Auxiliaries.ElectricPowerDemandMech; + container[ModalResultField.P_busAux_ES_generated] = Auxiliaries.ElectricPowerGenerated; + if (SmartElectricSystem) { + container[ModalResultField.BatterySOC] = ElectricStorage.SOC * 100.0; + } + } else { + if (SmartElectricSystem) { + var batteryPwr = ElectricStorage.ConsumedEnergy / dt; + + container[ModalResultField.BatterySOC] = ElectricStorage.SOC * 100.0; + + container[ModalResultField.P_busAux_ES_generated] = essUtilityFactor * + (DataBus.VehicleInfo.VehicleStopped && + !DataBus.EngineCtl.CombustionEngineOn + ? Auxiliaries.ElectricPowerConsumerSum + : Auxiliaries.ElectricPowerGenerated); + container[ModalResultField.P_busAux_ES_sum_mech] = + essUtilityFactor * (Auxiliaries.ElectricPowerConsumerSum - batteryPwr) / + AuxCfg.ElectricalUserInputsConfig.AlternatorGearEfficiency / + AuxCfg.ElectricalUserInputsConfig.AlternatorMap.GetEfficiency(0.RPMtoRad(), 0.SI<Ampere>()); + } } @@ -258,21 +292,21 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var signals = Auxiliaries.Signals; signals.SimulationInterval = dt; - signals.ClutchEngaged = DataBus.ClutchInfo.ClutchClosed(absTime); + signals.ClutchEngaged = DataBus.ClutchInfo.ClutchClosed(absTime) && DataBus.GearboxInfo.GearEngaged(absTime); signals.EngineDrivelineTorque = torquePowerTrain; signals.EngineSpeed = angularSpeed; var avgAngularSpeed = (PreviousState.AngularSpeed + CurrentState.AngularSpeed) / 2; - signals.PreExistingAuxPower = AdditionalAux != null + var preExistingAuxPower = AdditionalAux != null ? AdditionalAux.TorqueDemand(absTime, dt, torquePowerTrain, angularSpeed, dryRun) * avgAngularSpeed : 0.SI<Watt>(); var drivetrainPower = torquePowerTrain * avgAngularSpeed; if (!dryRun && !DataBus.IsTestPowertrain && DataBus.DriverInfo.DrivingAction == DrivingAction.Brake && CurrentState.ExcessiveDragPower.IsEqual(0)) { CurrentState.ExcessiveDragPower = drivetrainPower - - (DataBus.EngineInfo.EngineDragPower(avgAngularSpeed) - signals.PreExistingAuxPower) - DataBus.Brakes.BrakePower; + (DataBus.EngineInfo.EngineDragPower(avgAngularSpeed) - preExistingAuxPower) - DataBus.Brakes.BrakePower; } if (!dryRun && DataBus.DriverInfo.DrivingAction != DrivingAction.Brake) { CurrentState.ExcessiveDragPower = 0.SI<Watt>(); @@ -283,11 +317,34 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl signals.Idle = DataBus.VehicleInfo.VehicleStopped; signals.InNeutral = DataBus.GearboxInfo.Gear.Gear == 0; + + + var maxChg = ElectricStorage.MaxChargeEnergy(); + var maxDischg = ElectricStorage.MaxDischargeEnergy(); + + var essFactor = DataBus.EngineCtl.CombustionEngineOn ? 0.0 : EngineStopStartUtilityFactor; + var elPwrGen = Auxiliaries.ElectricPowerGenerated; + var elPwrConsumed = Auxiliaries.ElectricPowerConsumerSum; + + var energyDemand = (elPwrGen * (1 - essFactor) - elPwrConsumed) * dt; + + var batEnergy = energyDemand.LimitTo(maxDischg, maxChg); + + if (SmartElectricSystem) { + ElectricStorage.ConsumeEnergy(batEnergy, dryRun); + } + + var missingEnergy = energyDemand - batEnergy; + if (AuxCfg.ElectricalUserInputsConfig.ConnectESToREESS) { - DCDCConverter.ConsumerPower(Auxiliaries.ElectricPowerConsumerSum, dt, dryRun); + DCDCConverter.ConsumerEnergy(-missingEnergy, dryRun); + } else { + if (!dryRun) { + CurrentState.MissingElectricEnergy = missingEnergy; + } } - return Auxiliaries.AuxiliaryPowerAtCrankWatts + signals.PreExistingAuxPower; + return Auxiliaries.AuxiliaryPowerAtCrankWatts; } public class BusAuxState @@ -295,8 +352,47 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public Second dt; public PerSecond AngularSpeed; public Watt PowerDemand { get; set; } - + public WattSecond MissingElectricEnergy { get; set; } + public Watt ExcessiveDragPower = 0.SI<Watt>(); } + + public class ElectricStorageWrapper : ISimpleBatteryInfo + { + private BusAuxiliariesAdapter busAuxAdapter; + + public ElectricStorageWrapper(BusAuxiliariesAdapter busAuxiliariesAdapter) + { + busAuxAdapter = busAuxiliariesAdapter; + } + + #region Implementation of ISimpleBatteryInfo + + public double SOC { + get { return busAuxAdapter.ElectricStorage.SOC; } + } + public WattSecond Capacity { + get { return busAuxAdapter.ElectricStorage.Capacity; } + } + + #endregion + } + + public class InfinityBattery : ISimpleBatteryInfo + { + public InfinityBattery(WattSecond electricStorageCapacity) + { + Capacity = electricStorageCapacity; + } + + #region Implementation of ISimpleBatteryInfo + + public double SOC { + get { return 0.5; } + } + public WattSecond Capacity { get; } + + #endregion + } } } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs index 3a8eaced7d..506ec7e545 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs @@ -343,7 +343,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return null; } - var maxBatRecuperationTorque = maxBatPower.IsEqual(0, 1e-3) ? ModelData.DragCurve.Lookup(avgSpeed) : ModelData.EfficiencyMap.LookupTorque(maxBatPower, avgSpeed, maxEmTorque); + var maxBatRecuperationTorque = maxBatPower.IsEqual(0, 1e-3) + ? ModelData.DragCurve.Lookup(avgSpeed) + : ModelData.EfficiencyMap.LookupTorque(maxBatPower, avgSpeed, maxEmTorque); var maxTorqueRecuperate = VectoMath.Min(maxEmTorque, maxBatRecuperationTorque); return maxTorqueRecuperate < 0 ? null : maxTorqueRecuperate; } @@ -363,7 +365,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return null; } - var maxBatDriveTorque = maxBatPower.IsEqual(0, 1e-3) ? ModelData.DragCurve.Lookup(avgSpeed) : ModelData.EfficiencyMap.LookupTorque(maxBatPower, avgSpeed, maxEmTorque); + var maxBatDriveTorque = maxBatPower.IsEqual(0, 1e-3) + ? ModelData.DragCurve.Lookup(avgSpeed) + : ModelData.EfficiencyMap.LookupTorque(maxBatPower, avgSpeed, maxEmTorque); //if (maxBatDriveTorque == null) { // return ModelData.DragCurve.Lookup(avgSpeed); //} diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/HybridController.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/HybridController.cs index 6abef68057..192a15ea13 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/HybridController.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/HybridController.cs @@ -455,11 +455,18 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public override GearshiftPosition Engage(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity) { + var tmpGear = new GearshiftPosition(_nextGear.Gear); if (DataBus.EngineCtl.CombustionEngineOn) { while (GearList.HasPredecessor(_nextGear) && SpeedTooLowForEngine(_nextGear, outAngularVelocity)) { _nextGear = GearList.Predecessor(_nextGear); } + //if (!tmpGear.Equals(_nextGear)) { + // if (GearList.HasPredecessor(_nextGear) && IsBelowDownShiftCurve(_nextGear,)) { + // _nextGear = GearList.Predecessor(_nextGear); + // } + //} + while (GearList.HasSuccessor(_nextGear) && SpeedTooHighForEngine(_nextGear, outAngularVelocity)) { _nextGear = GearList.Successor(_nextGear); } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/StopStartCombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/StopStartCombustionEngine.cs index 5426702207..b2eda4e8a9 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/StopStartCombustionEngine.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/StopStartCombustionEngine.cs @@ -134,7 +134,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { base.DoWriteModalResults(time, simulationInterval, container); var engineStart = !PreviousState.EngineOn && CurrentState.EngineOn; container[ModalResultField.P_ice_start] = engineStart ? EngineStartEnergy / CurrentState.dt : 0.SI<Watt>(); - container[ModalResultField.P_aux_ice_off] = 0.SI<Watt>(); + container[ModalResultField.P_aux_ESS_mech_ice_off] = 0.SI<Watt>(); + container[ModalResultField.P_aux_ESS_mech_ice_on] = 0.SI<Watt>(); } else { container[ModalResultField.P_ice_start] = 0.SI<Watt>(); DoWriteEngineOffResults(time, simulationInterval, container); @@ -160,12 +161,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { container[ModalResultField.T_ice_drag] = 0.SI<NewtonMeter>(); container[ModalResultField.ICEOn] = CurrentState.EngineOn; - container[ModalResultField.P_aux_ice_off] = (CurrentState.AuxPowerEngineOff ?? 0.SI<Watt>()); + + var auxDemandPwr = EngineAux.PowerDemandEngineOn(time, simulationInterval, ModelData.IdleSpeed); + var auxDemandTq = auxDemandPwr / ModelData.IdleSpeed; + + container[ModalResultField.P_aux_ESS_mech_ice_off] = (CurrentState.AuxPowerEngineOff ?? 0.SI<Watt>()); + container[ModalResultField.P_aux_ESS_mech_ice_on] = (auxDemandPwr ?? 0.SI<Watt>()); - - var auxDemand = EngineAux.PowerDemandEngineOn(time, simulationInterval, ModelData.IdleSpeed) / ModelData.IdleSpeed; - - WriteWHRPowerEngineOff(container, ModelData.IdleSpeed, auxDemand); + WriteWHRPowerEngineOff(container, ModelData.IdleSpeed, auxDemandTq); foreach (var fuel in ModelData.Fuels) { var fc = 0.SI<KilogramPerSecond>(); @@ -181,7 +184,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { } - var result = fuel.ConsumptionMap.GetFuelConsumption(auxDemand, ModelData.IdleSpeed); + var result = fuel.ConsumptionMap.GetFuelConsumption(auxDemandTq, ModelData.IdleSpeed); var fcESS = result.Value * (1 - EngineStopStartUtilityFactor) * fuel.FuelData.HeatingValueCorrection * WHTCCorrectionFactor(fuel.FuelData); var fcFinal = fcESS; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Strategies/HybridStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Strategies/HybridStrategy.cs index 69f80ad5cd..210fe91c00 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Strategies/HybridStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Strategies/HybridStrategy.cs @@ -120,6 +120,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies break; } + if (TestPowertrain.DCDCConverter != null) { + TestPowertrain.DCDCConverter.PreviousState.ConsumedEnergy = + (DataBus.DCDCConverter as DCDCConverter).PreviousState.ConsumedEnergy; + } + TestPowertrain.Gearbox.PreviousState.InAngularVelocity = (DataBus.GearboxInfo as Gearbox).PreviousState.InAngularVelocity; @@ -865,13 +870,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies CalcualteCosts(firstResponse, dt, firstEntry, AllowICEOff(absTime), dryRun); var minimumShiftTimePassed = (DataBus.GearboxInfo.LastShift + ModelData.GearshiftParameters.TimeBetweenGearshifts).IsSmallerOrEqual(absTime); if (DataBus.GearboxInfo.GearEngaged(absTime) && !vehiclespeedBelowThreshold) { - if (firstEntry.IgnoreReason.EngineSpeedBelowDownshift() || + if (firstEntry.IgnoreReason.EngineSpeedBelowDownshift()|| firstEntry.IgnoreReason.EngineSpeedTooLow()) { - // downshift required! - var downshift = ResponseEmOff; - downshift.Gear = GearList.Predecessor(nextGear); - eval.Add(downshift); - return; + var best = FindBestGearForBraking(nextGear, firstResponse); + if (!best.Equals(nextGear)) { + // downshift required! + var downshift = ResponseEmOff; + downshift.Gear = best; // GearList.Predecessor(nextGear); + eval.Add(downshift); + return; + } } } } @@ -913,7 +921,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies GearboxInNeutral = false, NextGear = nextGear, MechanicalAssistPower = new Dictionary<PowertrainPosition, Tuple<PerSecond, NewtonMeter>>() { - { emPos, Tuple.Create(firstResponse.ElectricMotor.AngularVelocity, firstResponse.ElectricMotor.MaxRecuperationTorque) } + { emPos, Tuple.Create(firstResponse.ElectricMotor.AngularVelocity, VectoMath.Max(firstResponse.ElectricMotor.MaxRecuperationTorque, 0.SI<NewtonMeter>())) } } }; var maxRecuperationResponse = RequestDryRun( @@ -929,14 +937,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies new HybridResultEntry() { ICEOff = !DataBus.EngineInfo.EngineOn, Gear = nextGear, - Setting = new HybridStrategyResponse() { - CombustionEngineOn = DataBus.EngineInfo.EngineOn, - GearboxInNeutral = false, - NextGear = nextGear, - MechanicalAssistPower = new Dictionary<PowertrainPosition, Tuple<PerSecond, NewtonMeter>>() { - { emPos, Tuple.Create(firstResponse.ElectricMotor.AngularVelocity, firstResponse.ElectricMotor.MaxRecuperationTorque) } - } - } + Setting = maxRecuperation }); return; } @@ -1031,6 +1032,23 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies } } + private GearshiftPosition FindBestGearForBraking(GearshiftPosition nextGear, IResponse firstResponse) + { + var tmpGear = new GearshiftPosition(nextGear.Gear, nextGear.TorqueConverterLocked); + var candidates = new Dictionary<GearshiftPosition, PerSecond>(); + var gbxOutSpeed = firstResponse.Engine.EngineSpeed / + ModelData.GearboxData.Gears[tmpGear.Gear].Ratio; + while (GearList.HasPredecessor(tmpGear)) { + candidates[tmpGear] = gbxOutSpeed * ModelData.GearboxData.Gears[tmpGear.Gear].Ratio; + tmpGear = GearList.Predecessor(tmpGear); + } + + var targetEngineSpeed = ModelData.EngineData.IdleSpeed + + 0.7 * (ModelData.EngineData.FullLoadCurves[0].NP98hSpeed); + var best = candidates.MinBy(x => VectoMath.Abs(x.Value - targetEngineSpeed)).Key; + return best; + } + protected virtual void HandleCoastAction(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, bool dryRun, List<HybridResultEntry> eval) { var nextGear = !DataBus.GearboxInfo.GearEngaged(absTime) @@ -1468,7 +1486,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies var emDrivePower = -(batEnergyAvailable - ModelData.ElectricAuxDemand); var emTorqueM = emTqReq * maxU; if (!responses.Any(x => x.Gear == nextGear && x.U.IsEqual(maxU)) && emTorqueM.IsBetween( - 0.SI<NewtonMeter>(), firstResponse.ElectricMotor.MaxDriveTorque)) { + firstResponse.ElectricMotor.MaxRecuperationTorque, firstResponse.ElectricMotor.MaxDriveTorque)) { var tmp = TryConfiguration(absTime, dt, outTorque, outAngularVelocity, nextGear, emPos, Tuple.Create(firstResponse.ElectricMotor.AngularVelocity, emTorqueM), maxU, allowIceOff, dryRun); responses.Add(tmp); } @@ -1545,7 +1563,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies for (var u = stepSize; u <= 1.0; u += stepSize) { var emTorque = firstResponse.ElectricMotor.MaxRecuperationTorque * u; if (!(emTorque).IsBetween( - firstResponse.ElectricMotor.MaxRecuperationTorque, 0.SI<NewtonMeter>())) { + firstResponse.ElectricMotor.MaxRecuperationTorque, firstResponse.ElectricMotor.MaxDriveTorque)) { continue; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Strategies/TestPowertrain.cs b/VectoCore/VectoCore/Models/SimulationComponent/Strategies/TestPowertrain.cs index 154a5277f7..d5a997d3ec 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Strategies/TestPowertrain.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Strategies/TestPowertrain.cs @@ -23,13 +23,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies { public Clutch Clutch; public IBrakes Brakes; - public IDriverInfo Driver; - public IDrivingCycleInfo DrivingCycle; - public StopStartCombustionEngine CombustionEngine; public ElectricMotor ElectricMotor; public Dictionary<PowertrainPosition, ElectricMotor> ElectricMotorsUpstreamTransmission = new Dictionary<PowertrainPosition, ElectricMotor>(); public TorqueConverter TorqueConverter; + public DCDCConverter DCDCConverter; public TestPowertrain(SimplePowertrainContainer container, IDataBus realContainer) { @@ -62,8 +60,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies { throw new VectoException("Unknown HybridController in TestContainer: {0}", Container.HybridController?.GetType().FullName); } - Driver = new MockDriver(container, realContainer); - DrivingCycle = new MockDrivingCycle(container, realContainer); + var busAux = container.RunData.BusAuxiliaries; + if (busAux != null && busAux.ElectricalUserInputsConfig.ConnectESToREESS) { + DCDCConverter = container.DCDCConverter as DCDCConverter; + } + var driver = new MockDriver(container, realContainer); + var cycle = new MockDrivingCycle(container, realContainer); + Brakes = container.Brakes as Brakes; if (Brakes == null) { throw new VectoException("Unknown or missing brakes in TestContainer: {0}", Container.Brakes?.GetType().FullName); diff --git a/VectoCore/VectoCore/OutputData/IModalDataContainer.cs b/VectoCore/VectoCore/OutputData/IModalDataContainer.cs index 5ce09c8f97..b8ce281cab 100644 --- a/VectoCore/VectoCore/OutputData/IModalDataContainer.cs +++ b/VectoCore/VectoCore/OutputData/IModalDataContainer.cs @@ -341,7 +341,7 @@ namespace TUGraz.VectoCore.OutputData public static WattSecond WorkAuxiliariesDuringEngineStop(this IModalDataContainer data) { - return data.TimeIntegral<WattSecond>(ModalResultField.P_aux_ice_off); + return data.TimeIntegral<WattSecond>(ModalResultField.P_aux_ESS_mech_ice_off); } public static WattSecond WorkEngineStart(this IModalDataContainer data) diff --git a/VectoCore/VectoCore/OutputData/ModalDataContainer.cs b/VectoCore/VectoCore/OutputData/ModalDataContainer.cs index 86e27ec8bf..5d5269c774 100644 --- a/VectoCore/VectoCore/OutputData/ModalDataContainer.cs +++ b/VectoCore/VectoCore/OutputData/ModalDataContainer.cs @@ -531,7 +531,8 @@ namespace TUGraz.VectoCore.OutputData TimeIntegral<WattSecond>(ModalResultField.P_WHR_el_corr); TimeIntegral<WattSecond>(ModalResultField.P_WHR_mech_corr); - TimeIntegral<WattSecond>(ModalResultField.P_aux_ice_off); + TimeIntegral<WattSecond>(ModalResultField.P_aux_ESS_mech_ice_off); + TimeIntegral<WattSecond>(ModalResultField.P_aux_ESS_mech_ice_on); TimeIntegral<WattSecond>(ModalResultField.P_ice_start); } @@ -626,13 +627,15 @@ namespace TUGraz.VectoCore.OutputData var dataColumns = GetOutputColumns(); - var strCols = dataColumns.Concat(Auxiliaries.Values.Where(x => !x.ColumnName.Contains("P_aux_ENG_AUX_")).Select(c => c.ColumnName)) - .Concat( - new[] { - ModalResultField.P_WHR_el_map, ModalResultField.P_WHR_el_corr, ModalResultField.P_WHR_mech_map, ModalResultField.P_WHR_mech_corr, ModalResultField.P_aux_ice_off, - ModalResultField.P_ice_start//, ModalResultField.altitude - }.Select(x => x.GetName())) - .Concat(FuelColumns.SelectMany(kv => kv.Value.Select(kv2 => kv2.Value.ColumnName))); + var strCols = dataColumns.Concat(Auxiliaries.Values.Where(x => !x.ColumnName.Contains("P_aux_ENG_AUX_")) + .Select(c => c.ColumnName)) + .Concat( + new[] { + ModalResultField.P_WHR_el_map, ModalResultField.P_WHR_el_corr, ModalResultField.P_WHR_mech_map, + ModalResultField.P_WHR_mech_corr, ModalResultField.P_aux_ESS_mech_ice_off, ModalResultField.P_aux_ESS_mech_ice_on, + ModalResultField.P_ice_start //, ModalResultField.altitude + }.Select(x => x.GetName())) + .Concat(FuelColumns.SelectMany(kv => kv.Value.Select(kv2 => kv2.Value.ColumnName))); // TODO: 2018-11-20: Disable additional columns after testing gearshifting! //#if TRACE diff --git a/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/AuxDemandTest.cs b/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/AuxDemandTest.cs index aa511fbdcf..e9e9331a72 100644 --- a/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/AuxDemandTest.cs +++ b/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/AuxDemandTest.cs @@ -44,6 +44,8 @@ using System.IO; using TUGraz.VectoCommon.BusAuxiliaries; using TUGraz.VectoCore.InputData.FileIO.JSON; using TUGraz.VectoCore.InputData.Reader.ComponentData; +using TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electrics; +using TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces.DownstreamModules.Electrics; using TUGraz.VectoCore.Models.Declaration; namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries @@ -164,6 +166,10 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries var veh = new MockVehicle(vehicle) { MyVehicleSpeed = 50.KMPHtoMeterPerSecond() }; var auxConfig = BusAuxiliaryInputData.ReadBusAuxiliaries(auxFilePath, vehicle.RunData.VehicleData); var busAux = new BusAuxiliariesAdapter(vehicle, auxConfig); + var electricStorage = auxConfig.ElectricalUserInputsConfig.AlternatorType == AlternatorType.Smart + ? new SimpleBattery(vehicle, auxConfig.ElectricalUserInputsConfig.ElectricStorageCapacity) + : (ISimpleBattery)new NoBattery(vehicle); + busAux.ElectricStorage = electricStorage; return busAux; } } diff --git a/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs b/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs index ddbb796fb8..b70bd3fda0 100644 --- a/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs +++ b/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs @@ -38,6 +38,8 @@ using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.InputData.FileIO.JSON; using TUGraz.VectoCore.InputData.Reader.ComponentData; using TUGraz.VectoCore.InputData.Reader.Impl; +using TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electrics; +using TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces.DownstreamModules.Electrics; using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.Simulation.Impl; @@ -118,7 +120,12 @@ namespace TUGraz.VectoCore.Tests.Integration .AddComponent(engine); var aux = new BusAuxiliariesAdapter(container, runData.BusAuxiliaries); - + + var auxCfg = runData.BusAuxiliaries; + var electricStorage = auxCfg.ElectricalUserInputsConfig.AlternatorType == AlternatorType.Smart + ? new SimpleBattery(container, auxCfg.ElectricalUserInputsConfig.ElectricStorageCapacity) + : (ISimpleBattery)new NoBattery(container); + aux.ElectricStorage = electricStorage; engine.Connect(aux.Port()); return container; diff --git a/VectoCore/VectoCoreTest/TestData/Hybrids/BusAuxEngineeringMode/HybridStrategyParams.vhctl b/VectoCore/VectoCoreTest/TestData/Hybrids/BusAuxEngineeringMode/HybridStrategyParams.vhctl index 7a28da155f..5e5acf3cf2 100644 --- a/VectoCore/VectoCoreTest/TestData/Hybrids/BusAuxEngineeringMode/HybridStrategyParams.vhctl +++ b/VectoCore/VectoCoreTest/TestData/Hybrids/BusAuxEngineeringMode/HybridStrategyParams.vhctl @@ -6,8 +6,8 @@ "FileVersion": 1 }, "Body": { - "EquivalenceFactorDischarge": 2.5, - "EquivalenceFactorCharge": 1.5, + "EquivalenceFactorDischarge": 2.95, + "EquivalenceFactorCharge": 2.15, "MinSoC": 10.0, "MaxSoC": 90.0, "TargetSoC": 50.0, diff --git a/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs b/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs index 5b0c38cf68..b1b64a846b 100644 --- a/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs +++ b/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs @@ -167,6 +167,8 @@ namespace TUGraz.VectoCore.Tests.Utils public IHybridControllerInfo HybridControllerInfo { get; } public IHybridControllerCtl HybridControllerCtl { get; } public IAngledriveInfo AngledriveInfo { get; } + public IDCDCConverter DCDCConverter { get; } + public bool IsTestPowertrain { get { return false; } -- GitLab