diff --git a/VectoCore/VectoCore/InputData/Reader/ComponentData/BatteryInternalResistanceReader.cs b/VectoCore/VectoCore/InputData/Reader/ComponentData/BatteryInternalResistanceReader.cs index d6ac03ab898001eeccf45445e5e5b50e3350ec03..4d5bebd0958b2bf2691ea9a65cf65ce7075a9f9b 100644 --- a/VectoCore/VectoCore/InputData/Reader/ComponentData/BatteryInternalResistanceReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/ComponentData/BatteryInternalResistanceReader.cs @@ -1,4 +1,5 @@ using System.Data; +using System.IO; using System.Linq; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; @@ -39,5 +40,10 @@ namespace TUGraz.VectoCore.InputData.Reader.ComponentData public const string InternalResistance = "Ri"; } + + public static InternalResistanceMap Create(Stream data, int packCount) + { + return Create(VectoCSVFile.ReadStream(data), packCount); + } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/ComponentData/BatteryMaxCurrentReader.cs b/VectoCore/VectoCore/InputData/Reader/ComponentData/BatteryMaxCurrentReader.cs index d0fa37157209e16d00e6adff32311f4caa65c075..8f09f43c4b718d2b3f4e310c57abee37acace5e3 100644 --- a/VectoCore/VectoCore/InputData/Reader/ComponentData/BatteryMaxCurrentReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/ComponentData/BatteryMaxCurrentReader.cs @@ -1,4 +1,5 @@ using System.Data; +using System.IO; using System.Linq; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; @@ -44,5 +45,10 @@ namespace TUGraz.VectoCore.InputData.Reader.ComponentData public const string MaxDischargeCurrent = "I_discharge"; } + + public static MaxCurrentMap Create(Stream data, int packCount) + { + return Create(VectoCSVFile.ReadStream(data), packCount); + } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/ComponentData/BatterySOCReader.cs b/VectoCore/VectoCore/InputData/Reader/ComponentData/BatterySOCReader.cs index 4a7d50b19dc705c0ca5ad421bca6b9880edf7068..3c6f5bd0159d49a882e0daa5110fe439a320df7b 100644 --- a/VectoCore/VectoCore/InputData/Reader/ComponentData/BatterySOCReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/ComponentData/BatterySOCReader.cs @@ -1,4 +1,5 @@ using System.Data; +using System.IO; using System.Linq; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; @@ -9,6 +10,11 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.InputData.Reader.ComponentData { public static class BatterySOCReader { + public static SOCMap Create(Stream data) + { + return Create(VectoCSVFile.ReadStream(data)); + } + public static SOCMap Create(DataTable data) { diff --git a/VectoCore/VectoCore/Models/Simulation/Data/ModalResultField.cs b/VectoCore/VectoCore/Models/Simulation/Data/ModalResultField.cs index e1740a65ba191430b768398fd849138fb7519c4a..46d2c202b032fcc14ff6aebd3e184bb45162c08c 100644 --- a/VectoCore/VectoCore/Models/Simulation/Data/ModalResultField.cs +++ b/VectoCore/VectoCore/Models/Simulation/Data/ModalResultField.cs @@ -299,6 +299,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Data [ModalResultField(typeof(double), caption:"Battery SoC")] BatterySOC, + [ModalResultField(typeof(SI), caption: "P_busAux_bat [kW]", outputFactor: 1e-3)] P_busAux_bat, + /// <summary> /// [-] true/false indicate whether torque converter is locked or not (only applicable for gears with TC) diff --git a/VectoCore/VectoCore/Models/SimulationComponent/DCDCConverter.cs b/VectoCore/VectoCore/Models/SimulationComponent/DCDCConverter.cs index 1b16ffbedd8c7926e23efcaa02a4ffbfa9fc1e4d..c697576c804c6ab16502f78d5c0a4d9ad98ec549 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/DCDCConverter.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/DCDCConverter.cs @@ -1,5 +1,6 @@ using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Models.Connector.Ports.Impl; +using TUGraz.VectoCore.Models.Simulation; using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.Simulation.DataBus; using TUGraz.VectoCore.Models.Simulation.Impl; @@ -11,7 +12,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent { public double Efficiency { get; protected set; } - public DCDCConverter(VehicleContainer container, double efficiency) : base(container) + public DCDCConverter(IVehicleContainer container, double efficiency) : base(container) { Efficiency = efficiency; PreviousState.ConsumedEnergy = 0.SI<WattSecond>(); diff --git a/VectoCore/VectoCore/Models/SimulationComponent/IAuxPort.cs b/VectoCore/VectoCore/Models/SimulationComponent/IAuxPort.cs index 3574b1494107089a62144b209aa4483886bb713f..8ffddbf456c1cf2f3f9c42112a21cddca1f8df29 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/IAuxPort.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/IAuxPort.cs @@ -49,9 +49,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent NewtonMeter TorqueDemand(Second absTime, Second dt, NewtonMeter torquePowerTrain, PerSecond angularSpeed, bool dryRun = false); - Watt PowerDemandEngineOn(Second time, Second simulationInterval, PerSecond engineSpeed); + Watt PowerDemandESSEngineOn(Second time, Second simulationInterval, PerSecond engineSpeed); - Watt PowerDemandEngineOff(Second absTime, Second dt); + Watt PowerDemandESSEngineOff(Second absTime, Second dt); } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs index 4cda44042f6f7989a09b001ca35aeffd8b444d4d..33317317cb5ab7715a606562c0a36861db9db3ce 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs @@ -119,42 +119,76 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl AdditionalAux?.Initialize(torque, angularSpeed); DCDCConverter?.Initialize(); PreviousState.PowerDemand = GetBusAuxPowerDemand(0.SI<Second>(), 1.SI<Second>(), torque, angularSpeed) + - (AdditionalAux?.PowerDemandEngineOn(0.SI<Second>(), 1.SI<Second>(), angularSpeed) ?? 0.SI<Watt>()); + (AdditionalAux?.PowerDemandESSEngineOn(0.SI<Second>(), 1.SI<Second>(), angularSpeed) ?? 0.SI<Watt>()); return PreviousState.PowerDemand / angularSpeed; } - public NewtonMeter TorqueDemand(Second absTime, Second dt, NewtonMeter torquePowerTrain, PerSecond angularSpeed, bool dryRun = false) + public virtual NewtonMeter TorqueDemand(Second absTime, Second dt, NewtonMeter torquePowerTrain, PerSecond angularSpeed, bool dryRun = false) { CurrentState.AngularSpeed = angularSpeed; CurrentState.dt = dt; var signals = Auxiliaries.Signals; // trick bus auxiliaries that ice is on - all auxiliaries are considered. ESS is corrected in post-processing - signals.EngineStopped = false; - signals.VehicleStopped = false; + signals.EngineStopped = !DataBus.EngineCtl.CombustionEngineOn; //false; + signals.InNeutral = !DataBus.EngineCtl.CombustionEngineOn; + signals.VehicleStopped = DataBus.VehicleInfo.VehicleStopped; // false; CurrentState.PowerDemand = GetBusAuxPowerDemand(absTime, dt, torquePowerTrain, angularSpeed, dryRun) + - (AdditionalAux?.PowerDemandEngineOn(0.SI<Second>(), 1.SI<Second>(), angularSpeed) ?? 0.SI<Watt>()); + (AdditionalAux?.PowerDemandESSEngineOn(0.SI<Second>(), 1.SI<Second>(), angularSpeed) ?? 0.SI<Watt>()); var avgAngularSpeed = (CurrentState.AngularSpeed + PreviousState.AngularSpeed) / 2.0; return CurrentState.PowerDemand / avgAngularSpeed; } - public Watt PowerDemandEngineOn(Second time, Second simulationInterval, PerSecond engineSpeed) + public virtual Watt PowerDemandESSEngineOn(Second time, Second simulationInterval, PerSecond engineSpeed) { var signals = Auxiliaries.Signals; - signals.EngineStopped = false; - signals.VehicleStopped = false; + signals.EngineStopped = false; + signals.VehicleStopped = DataBus.VehicleInfo.VehicleStopped; + + var busAuxPwrICEOn = GetBusAuxPowerDemand(time, simulationInterval, 0.SI<NewtonMeter>(), engineSpeed, true); + var esICEOnLoad = Auxiliaries.ElectricPowerConsumerSum; + + signals.EngineStopped = true; + var busAuxPwrICEOff = GetBusAuxPowerDemand(time, simulationInterval, 0.SI<NewtonMeter>(), engineSpeed, true); + var esICEOffLoad = Auxiliaries.ElectricPowerConsumerSum; + + // if busAuxPwrICEOn and busAuxPwrICEOff are different the battery is empty and the mechanical power is the difference + // if both are equal we need to add the difference between ES ICE On and ES ICE Off power demand (the latter is corrected by ES correction) + + var esSupplyNotFromICE = AuxCfg.ElectricalUserInputsConfig.AlternatorType == AlternatorType.None || + (AuxCfg.ElectricalUserInputsConfig.ConnectESToREESS); + + var esMech = (busAuxPwrICEOn - busAuxPwrICEOff).IsEqual(0) && !esSupplyNotFromICE + ? (esICEOnLoad - esICEOffLoad) / AuxCfg.ElectricalUserInputsConfig.AlternatorGearEfficiency / + AuxCfg.ElectricalUserInputsConfig.AlternatorMap.GetEfficiency(0.RPMtoRad(), 0.SI<Ampere>()) + : 0.SI<Watt>(); + + return busAuxPwrICEOff - Auxiliaries.PSPowerDemandAirGenerated + esMech - Auxiliaries.ElectricPowerDemandMech + (busAuxPwrICEOn - busAuxPwrICEOff) + + (AdditionalAux?.PowerDemandESSEngineOn(0.SI<Second>(), 1.SI<Second>(), engineSpeed) ?? + 0.SI<Watt>()); + } + + protected virtual Watt ComputePowerDemand(Second time, Second simulationInterval, PerSecond engineSpeed, bool includeESBaseLoad = true) + { + var signals = Auxiliaries.Signals; + //signals.EngineStopped = true; + //signals.VehicleStopped = DataBus.VehicleInfo.VehicleStopped; + var esBaseLoad = Auxiliaries.ElectricPowerConsumerSum; + + //signals.EngineStopped = false; + //signals.VehicleStopped = false; var retVal = GetBusAuxPowerDemand(time, simulationInterval, 0.SI<NewtonMeter>(), engineSpeed, true) + - (AdditionalAux?.PowerDemandEngineOn(0.SI<Second>(), 1.SI<Second>(), engineSpeed) ?? 0.SI<Watt>()); + (AdditionalAux?.PowerDemandESSEngineOn(0.SI<Second>(), 1.SI<Second>(), engineSpeed) ?? 0.SI<Watt>()); if (!SmartElectricSystem) { return retVal; } //var batteryPwr = ElectricStorage.SOC * AuxCfg.ElectricalUserInputsConfig.ElectricStorageCapacity / simulationInterval; - var esSum = Auxiliaries.ElectricPowerConsumerSum; + var esSum = Auxiliaries.ElectricPowerConsumerSum - esBaseLoad; //if (batteryPwr < esSum) { retVal += (esSum ) / AuxCfg.ElectricalUserInputsConfig.AlternatorGearEfficiency / AuxCfg.ElectricalUserInputsConfig.AlternatorMap.GetEfficiency(0.RPMtoRad(), 0.SI<Ampere>()); @@ -163,40 +197,34 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return retVal; } - public Watt PowerDemandEngineOff(Second absTime, Second dt) + public virtual Watt PowerDemandESSEngineOff(Second absTime, Second dt) { - CurrentState.AngularSpeed = DataBus.EngineInfo.EngineIdleSpeed; - CurrentState.dt = dt; + //CurrentState.AngularSpeed = DataBus.EngineInfo.EngineIdleSpeed; + //CurrentState.dt = dt; 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; - - //// get busaux PowerDemand without additional Auxiliaries first. - //var conventionalAux = AdditionalAux; - //AdditionalAux = null; signals.EngineStopped = !DataBus.EngineCtl.CombustionEngineOn; + signals.InNeutral = !DataBus.EngineCtl.CombustionEngineOn; signals.VehicleStopped = DataBus.VehicleInfo.VehicleStopped; var busAuxPowerDemand = GetBusAuxPowerDemand( - absTime, dt, 0.SI<NewtonMeter>(), DataBus.EngineInfo.EngineIdleSpeed); - //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; - // - + absTime, dt, 0.SI<NewtonMeter>(), DataBus.EngineInfo.EngineIdleSpeed, true) - Auxiliaries.ElectricPowerDemandMech; + //AdditionalAux = conventionalAux; + + CurrentState.PowerDemand = ((AdditionalAux?.PowerDemandESSEngineOn(absTime, dt, DataBus.EngineInfo.EngineIdleSpeed) ?? 0.SI<Watt>()) + + busAuxPowerDemand) * (1 - EngineStopStartUtilityFactor); + //CurrentState.ESPowerGeneratedICE_On = Auxiliaries.ElectricPowerGenerated; + //CurrentState.ESPowerMech = Auxiliaries.ElectricPowerDemandMech; + // + - //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) ?? 0.SI<Watt>())); + return EngineStopStartUtilityFactor * (busAuxPowerDemand - Auxiliaries.PSPowerDemandAirGenerated + (AdditionalAux?.PowerDemandESSEngineOff(absTime, dt) ?? 0.SI<Watt>())); } @@ -210,13 +238,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl essUtilityFactor = 1 - EngineStopStartUtilityFactor; } - //var signals = Auxiliaries.Signals; - //signals.EngineStopped = !DataBus.IgnitionOn; - //signals.VehicleStopped = DataBus.VehicleStopped; + var signals = Auxiliaries.Signals; + signals.EngineStopped = !DataBus.EngineCtl.CombustionEngineOn; + signals.InNeutral = !DataBus.EngineCtl.CombustionEngineOn; + signals.VehicleStopped = DataBus.VehicleInfo.VehicleStopped; - // cycleStep has to be called here and not in DoCommit, write is called before Commit! - //var oldSOC = Auxiliaries.BatterySOC; - Auxiliaries.CycleStep(CurrentState.dt, DataBus.EngineCtl.CombustionEngineOn ? 1.0 : EngineStopStartUtilityFactor); + // cycleStep has to be called here and not in DoCommit, write is called before Commit! + //var oldSOC = Auxiliaries.BatterySOC; + Auxiliaries.CycleStep(CurrentState.dt, DataBus.EngineCtl.CombustionEngineOn ? 1.0 : EngineStopStartUtilityFactor); //var newSOC = Auxiliaries.BatterySOC; //CurrentState.TotalFuelConsumption = Auxiliaries.TotalFuel; @@ -236,12 +265,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl container[ModalResultField.P_busAux_ES_generated] = Auxiliaries.ElectricPowerGenerated; if (SmartElectricSystem) { container[ModalResultField.BatterySOC] = ElectricStorage.SOC * 100.0; + container[ModalResultField.P_busAux_bat] = ElectricStorage.ConsumedEnergy / dt; } } else { if (SmartElectricSystem) { var batteryPwr = ElectricStorage.ConsumedEnergy / dt; container[ModalResultField.BatterySOC] = ElectricStorage.SOC * 100.0; + container[ModalResultField.P_busAux_bat] = ElectricStorage.ConsumedEnergy / dt; container[ModalResultField.P_busAux_ES_generated] = essUtilityFactor * (DataBus.VehicleInfo.VehicleStopped && @@ -249,7 +280,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ? Auxiliaries.ElectricPowerConsumerSum : Auxiliaries.ElectricPowerGenerated); container[ModalResultField.P_busAux_ES_sum_mech] = - essUtilityFactor * (Auxiliaries.ElectricPowerConsumerSum - batteryPwr) / + essUtilityFactor * (Auxiliaries.ElectricPowerConsumerSum + batteryPwr) / AuxCfg.ElectricalUserInputsConfig.AlternatorGearEfficiency / AuxCfg.ElectricalUserInputsConfig.AlternatorMap.GetEfficiency(0.RPMtoRad(), 0.SI<Ampere>()); @@ -315,7 +346,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl signals.ExcessiveDragPower = CurrentState.ExcessiveDragPower; signals.Idle = DataBus.VehicleInfo.VehicleStopped; - signals.InNeutral = DataBus.GearboxInfo.Gear.Gear == 0; + signals.InNeutral = DataBus.GearboxInfo.Gear.Gear == 0 || !DataBus.EngineCtl.CombustionEngineOn; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs index dbd298ab144b642db67b6501d8351b26174da6d3..fd4d86c13873aa0c53d4b5a34c27da1005453bfe 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs @@ -657,7 +657,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public bool EngineOn { get; set; } - public Watt AuxPowerEngineOff { get; set; } + //public Watt AuxPowerEngineOff { get; set; } } protected internal class CombustionEngineIdleController : LoggingObject, IIdleController diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineAuxiliary.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineAuxiliary.cs index 805ac1b940ac415aba9a970671a806b7dfb72495..0ceb2ce33e9ba04bd3fe0705d4fc930e74cc7f60 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineAuxiliary.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineAuxiliary.cs @@ -133,7 +133,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return 0.SI<NewtonMeter>(); } - public Watt PowerDemandEngineOff(Second absTime, Second dt) + public Watt PowerDemandESSEngineOff(Second absTime, Second dt) { var auxiliarieIgnoredDuringVehicleStop = new[] { @@ -169,7 +169,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return engineOffDemand; //powerDemands.Sum(kv => kv.Value); } - public Watt PowerDemandEngineOn(Second absTime, Second dt, PerSecond engineSpeed) + public Watt PowerDemandESSEngineOn(Second absTime, Second dt, PerSecond engineSpeed) { return ComputePowerDemand(engineSpeed, absTime, dt, true); } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/StopStartCombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/StopStartCombustionEngine.cs index 6fce8459ee66fee16f6d18ca6b1c9e3f970fa2c6..45e6fd86a036b4840970c0687642a2a9ced969fd 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/StopStartCombustionEngine.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/StopStartCombustionEngine.cs @@ -90,10 +90,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { CurrentState.EnginePower = 0.SI<Watt>(); CurrentState.dt = dt; - if (!dryRun) { + //if (!dryRun) { //EngineAux.TorqueDemand(absTime, dt, 0.SI<NewtonMeter>(), 0.SI<NewtonMeter>(), ModelData.IdleSpeed); - CurrentState.AuxPowerEngineOff = EngineAux.PowerDemandEngineOff(absTime, dt); - } else { + //CurrentState.AuxPowerEngineOff = EngineAux.PowerDemandEngineOff(absTime, dt); + //} else { + if (dryRun) { return new ResponseDryRun(this) { DeltaFullLoad = 0.SI<Watt>(), DeltaDragLoad = 0.SI<Watt>(), @@ -113,6 +114,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { }; } + EngineAux?.TorqueDemand(absTime, dt, outTorque, outAngularVelocity, dryRun); return new ResponseSuccess(this) { Engine = { TorqueOutDemand = outTorque, @@ -182,11 +184,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { container[ModalResultField.ICEOn] = CurrentState.EngineOn; - var auxDemandPwr = EngineAux.PowerDemandEngineOn(time, simulationInterval, ModelData.IdleSpeed); - var auxDemandTq = auxDemandPwr / ModelData.IdleSpeed; + var auxDemandPwrICEOn = EngineAux.PowerDemandESSEngineOn(time, simulationInterval, ModelData.IdleSpeed); + var auxDemandPwrICEOff = EngineAux.PowerDemandESSEngineOff(time, simulationInterval); + var auxDemandTq = auxDemandPwrICEOn / 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>()); + container[ModalResultField.P_aux_ESS_mech_ice_off] = (auxDemandPwrICEOff ?? 0.SI<Watt>()); + container[ModalResultField.P_aux_ESS_mech_ice_on] = (auxDemandPwrICEOn ?? 0.SI<Watt>()); WriteWHRPowerEngineOff(container, ModelData.IdleSpeed, auxDemandTq); diff --git a/VectoCore/VectoCoreTest/Models/EngineeringMode/EngineeringModeBusAuxTest.cs b/VectoCore/VectoCoreTest/Models/EngineeringMode/EngineeringModeBusAuxTest.cs index 7853613203473406d63b6476562b554c5084f62b..5a23cee49172f4663928ab84edbf5e90f42e5463 100644 --- a/VectoCore/VectoCoreTest/Models/EngineeringMode/EngineeringModeBusAuxTest.cs +++ b/VectoCore/VectoCoreTest/Models/EngineeringMode/EngineeringModeBusAuxTest.cs @@ -1,14 +1,44 @@ -using System.IO; +using System; +using System.Collections.Generic; +using System.Data; +using System.IO; using System.Linq; using Ninject; using NUnit.Framework; using NUnit.Framework.Internal; +using TUGraz.VectoCommon.BusAuxiliaries; +using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.InputData.FileIO.JSON; using TUGraz.VectoCore.InputData.FileIO.XML; +using TUGraz.VectoCore.InputData.Reader.ComponentData; +using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter; +using TUGraz.VectoCore.InputData.Reader.Impl; +using TUGraz.VectoCore.Models.BusAuxiliaries; +using TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electrics; +using TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC; +using TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Pneumatics; +using TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces.DownstreamModules.Electrics; +using TUGraz.VectoCore.Models.Connector.Ports.Impl; +using TUGraz.VectoCore.Models.Declaration; +using TUGraz.VectoCore.Models.Simulation; +using TUGraz.VectoCore.Models.Simulation.Data; +using TUGraz.VectoCore.Models.Simulation.DataBus; using TUGraz.VectoCore.Models.Simulation.Impl; +using TUGraz.VectoCore.Models.SimulationComponent; +using TUGraz.VectoCore.Models.SimulationComponent.Data; +using TUGraz.VectoCore.Models.SimulationComponent.Data.Battery; +using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; +using TUGraz.VectoCore.Models.SimulationComponent.Impl; using TUGraz.VectoCore.OutputData; using TUGraz.VectoCore.OutputData.FileIO; +using TUGraz.VectoCore.Tests.Models.SimulationComponent; +using TUGraz.VectoCore.Tests.Utils; +using TUGraz.VectoCore.Utils; +using ElectricSystem = TUGraz.VectoCore.Models.SimulationComponent.ElectricSystem; +using Wheels = TUGraz.VectoCore.Models.SimulationComponent.Impl.Wheels; namespace TUGraz.VectoCore.Tests.Models.EngineeringMode { @@ -41,6 +71,9 @@ namespace TUGraz.VectoCore.Tests.Models.EngineeringMode const string JobFile_C3a = @"TestData\Hybrids\BusAuxEngineeringMode\InterurbanBus_ENG_BusAux_C3a.vecto"; const string JobFile_C3b = @"TestData\Hybrids\BusAuxEngineeringMode\InterurbanBus_ENG_BusAux_C3b.vecto"; + + private const string JobRoeck_BusAux_B = + @"J:\TE-Em\Emissionsmodelle\VECTO\Arbeitsordner\AAUX\Check bus aux electrical system configurations\System type B\Citybus_P0-APT-S-175kW-6.8l_B\Citybus_P0_B.vecto"; [ TestCase(JobFile, 0, TestName = "InterurbanBus ENG BusAux NonSmart Interurban"), TestCase(JobFile, 1, TestName = "InterurbanBus ENG BusAux NonSmart Coach"), @@ -80,10 +113,15 @@ namespace TUGraz.VectoCore.Tests.Models.EngineeringMode TestCase(JobFile_C1, 0, TestName = "InterurbanBus ENG BusAux C1 Interurban"), + TestCase(JobRoeck_BusAux_B, 0, "dev", TestName = "Roeck Citybus P0 Type B"), ] - public void InterurbanBus_BusAuxTest(string jobFile, int runIdx) + public void InterurbanBus_BusAuxTest(string jobFile, int runIdx, string outPath = null) { - var writer = new FileOutputWriter(jobFile); + var outFile = Path.Combine(Path.GetDirectoryName(jobFile), outPath, Path.GetFileName(jobFile)); + if (!Directory.Exists(Path.GetDirectoryName(outFile))) { + Directory.CreateDirectory(Path.GetDirectoryName(outFile)); + } + var writer = new FileOutputWriter(outFile); var inputData = Path.GetExtension(jobFile) == ".xml" ? xmlInputReader.CreateDeclaration(jobFile) //? new XMLDeclarationInputDataProvider(relativeJobPath, true) @@ -114,5 +152,960 @@ namespace TUGraz.VectoCore.Tests.Models.EngineeringMode jobContainer.Execute(); jobContainer.WaitFinished(); } + + + // ########################################################## + + public const double AlternatorEfficiency = 0.7; + public const double DCDCEfficiency = 0.97; + + public const double MaxAlternatorPower = 4000.0; + + public const double I_Base = 25.0; + public const double I_ICEOff_dr = 20.0; + public const double I_ICEOff_stop = 10.0; + + public const double P_aux_m_Base = 900; + public const double P_aux_m_ICEOff_dr = 750; + public const double P_aux_m_ICEOff_st = 300; + + public const double PowernetVoltage = 28.3; + public const double P_ES_base = I_Base * PowernetVoltage; // 707,5 W + public const double P_ES_ICEOff_dr = I_ICEOff_dr * PowernetVoltage; // 566 W + public const double P_ES_ICEOff_stop = I_ICEOff_stop * PowernetVoltage; // 283 W + + public const double P_PS_600 = 1839.537986 / 0.97; //1896.430913 W + public const double P_PS_1000 = 2025.38602 / 0.97; // 2088.026824 W + + public const double Nl_PS = 2.1; + + public static WattSecond ElectricStorageCapacity = 28.3.SI(Unit.SI.Watt.Hour).Cast<WattSecond>(); + + public const double REESS_Capacity = 4.5; + public const double REESS_MinSoC = 0.2; + public const double REESS_MaxSoC = 0.8; + + [TestCase(DrivingBehavior.Driving, true, 0, + P_aux_m_Base + P_PS_1000 + P_ES_base / AlternatorEfficiency, P_ES_base, P_ES_base, + P_ES_base / AlternatorEfficiency, 0, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case A (1); driving, ICE on")] + [TestCase(DrivingBehavior.Driving, false, 0, + 0, 0, P_ES_ICEOff_dr, 0, P_aux_m_ICEOff_dr, + P_aux_m_Base + (P_ES_base - P_ES_ICEOff_dr) / AlternatorEfficiency, 0, Nl_PS, 0, + TestName = "BusAux Case A (2); driving, ICE off")] + [TestCase(DrivingBehavior.Halted, true, 0, + P_aux_m_Base + P_PS_600 + P_ES_base / AlternatorEfficiency, P_ES_base, P_ES_base, + P_ES_base / AlternatorEfficiency, 0, 0, Nl_PS, Nl_PS, P_PS_600, + TestName = "BusAux Case A (3); standstill, ICE on")] + [TestCase(DrivingBehavior.Halted, false, 0, + 0, 0, P_ES_ICEOff_stop, 0, P_aux_m_ICEOff_st, + P_aux_m_Base + (P_ES_base - P_ES_ICEOff_stop) / AlternatorEfficiency, 0, Nl_PS, 0, + TestName = "BusAux Case A (4); standstill, ICE off")] + [TestCase(DrivingBehavior.Braking, true, 0, + P_aux_m_Base + P_PS_1000 + P_ES_base / AlternatorEfficiency, P_ES_base, P_ES_base, + P_ES_base / AlternatorEfficiency, 0, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case A (5); braking, ICE on")] + public void TestBusAux_Case_A(DrivingBehavior drivingBehavior, bool iceOn, double batterySoC, + double P_auxMech_expected, double P_busAux_ES_gen_expected, double P_busAux_ES_consumer_sum_expected, + double P_busAux_ES_mech, + double P_aux_ESS_mech_ICE_off_expected, double P_aux_ESS_mech_ICE_on_expected, + double Nl_PS_gen_expected, double Nl_PS_consumer_expected, double P_PS_expected) + { + var container = CreatePowerTrain(AlternatorType.Conventional, batterySoC, null, false); + + // check powertrain architecture and config + Assert.NotNull(container.Components.FirstOrDefault(x => x is StopStartCombustionEngine)); + Assert.NotNull(container.Components.FirstOrDefault(x => x is BusAuxiliariesAdapter)); + Assert.NotNull(container.Components.FirstOrDefault(x => x is NoBattery)); + + // no HEV + Assert.Null(container.Components.FirstOrDefault(x => x is DCDCConverter)); + Assert.Null(container.Components.FirstOrDefault(x => x is ElectricSystem)); + Assert.Null(container.Components.FirstOrDefault(x => x is Battery)); + + Assert.AreEqual(AlternatorType.Conventional, container.RunData.BusAuxiliaries.ElectricalUserInputsConfig.AlternatorType); + Assert.IsFalse(container.RunData.BusAuxiliaries.ElectricalUserInputsConfig.ConnectESToREESS); + + TestBusAux_Cases(container, drivingBehavior, iceOn, batterySoC, double.NaN, + P_auxMech_expected, P_busAux_ES_gen_expected, double.NaN, P_busAux_ES_consumer_sum_expected, P_busAux_ES_mech, + Nl_PS_gen_expected, Nl_PS_consumer_expected, P_PS_expected, double.NaN, + P_aux_ESS_mech_ICE_off_expected, P_aux_ESS_mech_ICE_on_expected, null, null, null); + } + + // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + + [TestCase(DrivingBehavior.Driving, true, 0.5, + P_aux_m_Base + P_PS_1000, 0, P_ES_base, P_ES_base, 0, 0, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case B (1); driving, ICE on, battery not empty")] + [TestCase(DrivingBehavior.Driving, true, 0, + P_aux_m_Base + P_PS_1000 + P_ES_base / AlternatorEfficiency, P_ES_base, 0, P_ES_base, + P_ES_base / AlternatorEfficiency, 0, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case B (2); driving, ICE on, battery empty")] + [TestCase(DrivingBehavior.Driving, false, 0.5, + 0, 0, P_ES_ICEOff_dr, P_ES_ICEOff_dr, 0, P_aux_m_ICEOff_dr, + P_aux_m_Base + (P_ES_base - P_ES_ICEOff_dr) / AlternatorEfficiency, 0, Nl_PS, 0, + TestName = "BusAux Case B (3); driving, ICE off, battery not empty")] + [TestCase(DrivingBehavior.Driving, false, 0, + 0, 0, 0, P_ES_ICEOff_dr, 0, P_aux_m_ICEOff_dr, + P_aux_m_Base + (P_ES_base - P_ES_ICEOff_dr) / AlternatorEfficiency, 0, Nl_PS, 0, + TestName = "BusAux Case B (4); driving, ICE off, battery empty")] + [TestCase(DrivingBehavior.Halted, true, 0.5, + P_aux_m_Base + P_PS_600, 0, P_ES_base, P_ES_base, 0, 0, 0, Nl_PS, Nl_PS, P_PS_600, + TestName = "BusAux Case B (5); standstill, ICE on, battery not empty")] + [TestCase(DrivingBehavior.Halted, true, 0, + P_aux_m_Base + P_PS_600 + P_ES_base / AlternatorEfficiency, P_ES_base, 0, P_ES_base, + P_ES_base / AlternatorEfficiency, 0, 0, Nl_PS, Nl_PS, P_PS_600, + TestName = "BusAux Case B (6); standstill, ICE on, battery empty")] + [TestCase(DrivingBehavior.Halted, false, 0.5, + 0, 0, P_ES_ICEOff_stop, P_ES_ICEOff_stop, 0, P_aux_m_ICEOff_st, + P_aux_m_Base + (P_ES_base - P_ES_ICEOff_stop) / AlternatorEfficiency, 0, Nl_PS, 0, + TestName = "BusAux Case B (7); standstill, ICE off, battery not empty")] + [TestCase(DrivingBehavior.Halted, false, 0, + 0, 0, 0, P_ES_ICEOff_stop, 0, P_aux_m_ICEOff_st, + P_aux_m_Base + (P_ES_base - P_ES_ICEOff_stop) / AlternatorEfficiency, 0, Nl_PS, 0, + TestName = "BusAux Case B (8); standstill, ICE off, battery empty")] + [TestCase(DrivingBehavior.Braking, true, 0.5, + P_aux_m_Base + P_PS_1000 + MaxAlternatorPower / AlternatorEfficiency, MaxAlternatorPower, P_ES_base - MaxAlternatorPower, P_ES_base, + MaxAlternatorPower / AlternatorEfficiency, 0, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case B (9); braking, ICE on, battery not full")] + [TestCase(DrivingBehavior.Braking, true, 1, + P_aux_m_Base + P_PS_1000 + P_ES_base / AlternatorEfficiency, P_ES_base, 0, P_ES_base, + P_ES_base / AlternatorEfficiency, 0, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case B (10); braking, ICE on, battery full")] + public void TestBusAux_Case_B(DrivingBehavior drivingBehavior, bool iceOn, double batterySoC, + double P_auxMech_expected, double P_busAux_ES_gen_expected, double P_bat_P0, double P_busAux_ES_consumer_sum_expected, + double P_busAux_ES_mech, + double P_aux_ESS_mech_ICE_off_expected, double P_aux_ESS_mech_ICE_on_expected, + double Nl_PS_gen_expected, double Nl_PS_consumer_expected, double P_PS_expected) + { + var container = CreatePowerTrain(AlternatorType.Smart, batterySoC, null, false); + + + // check powertrain architecture and config + Assert.NotNull(container.Components.FirstOrDefault(x => x is StopStartCombustionEngine)); + Assert.NotNull(container.Components.FirstOrDefault(x => x is BusAuxiliariesAdapter)); + Assert.NotNull(container.Components.FirstOrDefault(x => x is SimpleBattery)); + + // no HEV + Assert.Null(container.Components.FirstOrDefault(x => x is DCDCConverter)); + Assert.Null(container.Components.FirstOrDefault(x => x is ElectricSystem)); + Assert.Null(container.Components.FirstOrDefault(x => x is Battery)); + + Assert.AreEqual(AlternatorType.Smart, container.RunData.BusAuxiliaries.ElectricalUserInputsConfig.AlternatorType); + Assert.IsFalse(container.RunData.BusAuxiliaries.ElectricalUserInputsConfig.ConnectESToREESS); + + TestBusAux_Cases(container, drivingBehavior, iceOn, batterySoC, double.NaN, + P_auxMech_expected, P_busAux_ES_gen_expected, -P_bat_P0, P_busAux_ES_consumer_sum_expected, P_busAux_ES_mech, + Nl_PS_gen_expected, Nl_PS_consumer_expected, P_PS_expected, double.NaN, + P_aux_ESS_mech_ICE_off_expected, P_aux_ESS_mech_ICE_on_expected, null, null, null); + } + + // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + + [TestCase(DrivingBehavior.Driving, true, 0.5, + P_aux_m_Base + P_PS_1000, 0, P_ES_base, 0, 0, 0, P_ES_base, 0, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case C1 (1); driving, ICE on, REESS not empty")] + [TestCase(DrivingBehavior.Driving, true, REESS_MinSoC, + P_aux_m_Base + P_PS_1000, 0, P_ES_base, 0, 0, 0, 0, P_ES_base, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case C1 (2); driving, ICE on, REESS empty")] + [TestCase(DrivingBehavior.Driving, false, 0.5, + 0, 0, P_ES_ICEOff_dr, 0, P_aux_m_ICEOff_dr , P_aux_m_Base , P_ES_ICEOff_dr, 0, 0, 0, Nl_PS, 0, + TestName = "BusAux Case C1 (3); driving, ICE off, REESS not empty")] + [TestCase(DrivingBehavior.Driving, false, REESS_MinSoC, + 0, 0, P_ES_ICEOff_dr, 0, P_aux_m_ICEOff_dr , P_aux_m_Base, 0, P_ES_ICEOff_dr, P_ES_base - P_ES_ICEOff_dr, 0, Nl_PS, 0, + TestName = "BusAux Case C1 (4); driving, ICE off, REESS empty")] + + [TestCase(DrivingBehavior.Halted, true, 0.5, + P_aux_m_Base + P_PS_600, 0, P_ES_base, 0, 0, 0, P_ES_base, 0, 0, Nl_PS, Nl_PS, P_PS_600, + TestName = "BusAux Case C1 (5); standstill, ICE on, REESS not empty")] + [TestCase(DrivingBehavior.Halted, true, REESS_MinSoC, + P_aux_m_Base + P_PS_600, 0, P_ES_base, 0, 0, 0, 0, P_ES_base, 0, Nl_PS, Nl_PS, P_PS_600, + TestName = "BusAux Case C1 (6); standstill, ICE on, REESS empty")] + [TestCase(DrivingBehavior.Halted, false, 0.5, + 0, 0, P_ES_ICEOff_stop, 0, P_aux_m_ICEOff_st , P_aux_m_Base , P_ES_ICEOff_stop, 0, 0, 0, Nl_PS, 0, + TestName = "BusAux Case C1 (7); standstill, ICE off, REESS not empty")] + [TestCase(DrivingBehavior.Halted, false, REESS_MinSoC, + 0, 0, P_ES_ICEOff_stop, 0, P_aux_m_ICEOff_st , P_aux_m_Base , 0, P_ES_ICEOff_stop, P_ES_base - P_ES_ICEOff_stop, 0, Nl_PS, 0, + TestName = "BusAux Case C1 (8); standstill, ICE off, REESS empty")] + + [TestCase(DrivingBehavior.Braking, true, 0.5, + P_aux_m_Base + P_PS_1000, 0, P_ES_base, 0, 0, 0, P_ES_base, 0, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case C1 (9); braking, ICE on, REESS not empty")] + [TestCase(DrivingBehavior.Braking, true, REESS_MinSoC, + P_aux_m_Base + P_PS_1000, 0, P_ES_base, 0, 0, 0, 0, P_ES_base, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case C1 (10); braking, ICE on, REESS empty")] + [TestCase(DrivingBehavior.Braking, false, 0.5, + 0, 0, P_ES_ICEOff_dr, 0, P_aux_m_ICEOff_dr , P_aux_m_Base , P_ES_ICEOff_dr, 0, 0, 0, Nl_PS, 0, + TestName = "BusAux Case C1 (11); braking, ICE off, REESS not empty")] + [TestCase(DrivingBehavior.Braking, false, REESS_MinSoC, + 0, 0, P_ES_ICEOff_dr, 0, P_aux_m_ICEOff_dr , P_aux_m_Base , 0, P_ES_ICEOff_dr, P_ES_base - P_ES_ICEOff_dr, 0, Nl_PS, 0, + TestName = "BusAux Case C1 (12); braking, ICE off, REESS empty")] + public void TestBusAux_Case_C1(DrivingBehavior drivingBehavior, bool iceOn, double reessSoC, + double P_auxMech_expected, double P_busAux_ES_gen_expected, double P_busAux_ES_consumer_sum_expected, + double P_busAux_ES_mech, + double P_aux_ESS_mech_ICE_off_expected, double P_aux_ESS_mech_ICE_on_expected, double P_DCDC_out_expected, double P_DCDC_missing_expected, double P_DCDC_missing_ESS_ICE_on, + double Nl_PS_gen_expected, double Nl_PS_consumer_expected, double P_PS_expected) + { + var container = CreatePowerTrain(AlternatorType.None, double.NaN, reessSoC, true); + + // check powertrain architecture and config + Assert.NotNull(container.Components.FirstOrDefault(x => x is StopStartCombustionEngine)); + Assert.NotNull(container.Components.FirstOrDefault(x => x is BusAuxiliariesAdapter)); + Assert.NotNull(container.Components.FirstOrDefault(x => x is NoBattery)); + + // HEV + Assert.NotNull(container.Components.FirstOrDefault(x => x is DCDCConverter)); + Assert.NotNull(container.Components.FirstOrDefault(x => x is ElectricSystem)); + Assert.NotNull(container.Components.FirstOrDefault(x => x is Battery)); + + Assert.AreEqual(AlternatorType.None, container.RunData.BusAuxiliaries.ElectricalUserInputsConfig.AlternatorType); + Assert.IsTrue(container.RunData.BusAuxiliaries.ElectricalUserInputsConfig.ConnectESToREESS); + + TestBusAux_Cases(container, drivingBehavior, iceOn, double.NaN, reessSoC, + P_auxMech_expected, P_busAux_ES_gen_expected, double.NaN, P_busAux_ES_consumer_sum_expected, P_busAux_ES_mech, + Nl_PS_gen_expected, Nl_PS_consumer_expected, P_PS_expected, double.NaN, + P_aux_ESS_mech_ICE_off_expected, P_aux_ESS_mech_ICE_on_expected, P_DCDC_out_expected, P_DCDC_missing_expected, P_DCDC_missing_ESS_ICE_on); + + } + + // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + + + [TestCase(DrivingBehavior.Driving, true, 0.5, + P_aux_m_Base + P_PS_1000, 0, P_ES_base, 0, 0, 0, P_ES_base, 0, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case C2a (1); driving, ICE on, REESS not empty")] + [TestCase(DrivingBehavior.Driving, true, REESS_MinSoC, + P_aux_m_Base + P_PS_1000, 0, P_ES_base, 0, 0, 0, 0, P_ES_base, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case C2a (2); driving, ICE on, REESS empty")] + [TestCase(DrivingBehavior.Driving, false, 0.5, + 0, 0, P_ES_ICEOff_dr, 0, P_aux_m_ICEOff_dr, P_aux_m_Base, P_ES_ICEOff_dr, 0, 0, 0, Nl_PS, 0, + TestName = "BusAux Case C2a (3); driving, ICE off, REESS not empty")] + [TestCase(DrivingBehavior.Driving, false, REESS_MinSoC, + 0, 0, P_ES_ICEOff_dr, 0, P_aux_m_ICEOff_dr, P_aux_m_Base, 0, P_ES_ICEOff_dr, P_ES_base - P_ES_ICEOff_dr, 0, Nl_PS, 0, + TestName = "BusAux Case C2a (4); driving, ICE off, REESS empty")] + + [TestCase(DrivingBehavior.Halted, true, 0.5, + P_aux_m_Base + P_PS_600, 0, P_ES_base, 0, 0, 0, P_ES_base, 0, 0, Nl_PS, Nl_PS, P_PS_600, + TestName = "BusAux Case C2a (5); standstill, ICE on, REESS not empty")] + [TestCase(DrivingBehavior.Halted, true, REESS_MinSoC, + P_aux_m_Base + P_PS_600, 0, P_ES_base, 0, 0, 0, 0, P_ES_base, 0, Nl_PS, Nl_PS, P_PS_600, + TestName = "BusAux Case C2a (6); standstill, ICE on, REESS empty")] + [TestCase(DrivingBehavior.Halted, false, 0.5, + 0, 0, P_ES_ICEOff_stop, 0, P_aux_m_ICEOff_st, P_aux_m_Base, P_ES_ICEOff_stop, 0, 0, 0, Nl_PS, 0, + TestName = "BusAux Case C2a (7); standstill, ICE off, REESS not empty")] + [TestCase(DrivingBehavior.Halted, false, REESS_MinSoC, + 0, 0, P_ES_ICEOff_stop, 0, P_aux_m_ICEOff_st, P_aux_m_Base, 0, P_ES_ICEOff_stop, P_ES_base - P_ES_ICEOff_stop, 0, Nl_PS, 0, + TestName = "BusAux Case C2a (8); standstill, ICE off, REESS empty")] + + [TestCase(DrivingBehavior.Braking, true, 0.5, + P_aux_m_Base + P_PS_1000, 0, P_ES_base, 0, 0, 0, P_ES_base, 0, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case C2a (9); braking, ICE on, REESS not empty")] + [TestCase(DrivingBehavior.Braking, true, REESS_MinSoC, + P_aux_m_Base + P_PS_1000, 0, P_ES_base, 0, 0, 0, 0, P_ES_base, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case C2a (10); braking, ICE on, REESS empty")] + [TestCase(DrivingBehavior.Braking, false, 0.5, + 0, 0, P_ES_ICEOff_dr, 0, P_aux_m_ICEOff_dr, P_aux_m_Base, P_ES_ICEOff_dr, 0, 0, 0, Nl_PS, 0, + TestName = "BusAux Case C2a (11); braking, ICE off, REESS not empty")] + [TestCase(DrivingBehavior.Braking, false, REESS_MinSoC, + 0, 0, P_ES_ICEOff_dr, 0, P_aux_m_ICEOff_dr, P_aux_m_Base, 0, P_ES_ICEOff_dr, P_ES_base - P_ES_ICEOff_dr, 0, Nl_PS, 0, + TestName = "BusAux Case C2a (12); braking, ICE off, REESS empty")] + public void TestBusAux_Case_C2A(DrivingBehavior drivingBehavior, bool iceOn, double reessSoC, + double P_auxMech_expected, double P_busAux_ES_gen_expected, double P_busAux_ES_consumer_sum_expected, + double P_busAux_ES_mech, + double P_aux_ESS_mech_ICE_off_expected, double P_aux_ESS_mech_ICE_on_expected, double P_DCDC_out_expected, double P_DCDC_missing_expected, double P_DCDC_missing_ESS_ICE_on, + double Nl_PS_gen_expected, double Nl_PS_consumer_expected, double P_PS_expected) + { + var container = CreatePowerTrain(AlternatorType.Conventional, double.NaN, reessSoC, true); + + // check powertrain architecture and config + Assert.NotNull(container.Components.FirstOrDefault(x => x is StopStartCombustionEngine)); + Assert.NotNull(container.Components.FirstOrDefault(x => x is BusAuxiliariesAdapter)); + Assert.NotNull(container.Components.FirstOrDefault(x => x is NoBattery)); + + // HEV + Assert.NotNull(container.Components.FirstOrDefault(x => x is DCDCConverter)); + Assert.NotNull(container.Components.FirstOrDefault(x => x is ElectricSystem)); + Assert.NotNull(container.Components.FirstOrDefault(x => x is Battery)); + + // simulated with alternator type NONE! + Assert.AreEqual(AlternatorType.None, container.RunData.BusAuxiliaries.ElectricalUserInputsConfig.AlternatorType); + Assert.IsTrue(container.RunData.BusAuxiliaries.ElectricalUserInputsConfig.ConnectESToREESS); + + TestBusAux_Cases(container, drivingBehavior, iceOn, double.NaN, reessSoC, + P_auxMech_expected, P_busAux_ES_gen_expected, double.NaN, P_busAux_ES_consumer_sum_expected, P_busAux_ES_mech, Nl_PS_gen_expected, Nl_PS_consumer_expected, P_PS_expected, double.NaN, + P_aux_ESS_mech_ICE_off_expected, P_aux_ESS_mech_ICE_on_expected, P_DCDC_out_expected, P_DCDC_missing_expected, P_DCDC_missing_ESS_ICE_on); + + } + + + // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + + [TestCase(DrivingBehavior.Driving, true, 0, + P_aux_m_Base + P_PS_1000 + P_ES_base / AlternatorEfficiency, P_ES_base, P_ES_base, P_ES_base / AlternatorEfficiency, 0, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case C2b (1); driving, ICE on")] + [TestCase(DrivingBehavior.Driving, false, 0, + 0, 0, P_ES_ICEOff_dr, 0, P_aux_m_ICEOff_dr , + P_aux_m_Base + (P_ES_base - P_ES_ICEOff_dr) / AlternatorEfficiency, 0, Nl_PS, 0, + TestName = "BusAux Case C2b (2); driving, ICE off")] + [TestCase(DrivingBehavior.Halted, true, 0, + P_aux_m_Base + P_PS_600 + P_ES_base / AlternatorEfficiency, P_ES_base, P_ES_base, + P_ES_base / AlternatorEfficiency, 0, 0, Nl_PS, Nl_PS, P_PS_600, + TestName = "BusAux Case C2b (3); standstill, ICE on")] + [TestCase(DrivingBehavior.Halted, false, 0, + 0, 0, P_ES_ICEOff_stop, 0, P_aux_m_ICEOff_st, + P_aux_m_Base + (P_ES_base - P_ES_ICEOff_stop) / AlternatorEfficiency, 0, Nl_PS, 0, + TestName = "BusAux Case C2b (4); standstill, ICE off")] + [TestCase(DrivingBehavior.Braking, true, 0, + P_aux_m_Base + P_PS_1000 + P_ES_base / AlternatorEfficiency, P_ES_base, P_ES_base, + P_ES_base / AlternatorEfficiency, 0, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case C2b (5); braking, ICE on")] + public void TestBusAux_Case_C2B(DrivingBehavior drivingBehavior, bool iceOn, double batterySoC, + double P_auxMech_expected, double P_busAux_ES_gen_expected, double P_busAux_ES_consumer_sum_expected, + double P_busAux_ES_mech, + double P_aux_ESS_mech_ICE_off_expected, double P_aux_ESS_mech_ICE_on_expected, double Nl_PS_gen_expected, double Nl_PS_consumer_expected, double P_PS_expected) + { + var container = CreatePowerTrain(AlternatorType.Conventional, batterySoC, 0.5, false); + + // check powertrain architecture and config + Assert.NotNull(container.Components.FirstOrDefault(x => x is StopStartCombustionEngine)); + Assert.NotNull(container.Components.FirstOrDefault(x => x is BusAuxiliariesAdapter)); + Assert.NotNull(container.Components.FirstOrDefault(x => x is NoBattery)); + + // HEV, no DCDC converter + Assert.Null(container.Components.FirstOrDefault(x => x is DCDCConverter)); + Assert.NotNull(container.Components.FirstOrDefault(x => x is ElectricSystem)); + Assert.NotNull(container.Components.FirstOrDefault(x => x is Battery)); + + // simulated with alternator type NONE! + Assert.AreEqual(AlternatorType.Conventional, container.RunData.BusAuxiliaries.ElectricalUserInputsConfig.AlternatorType); + Assert.IsFalse(container.RunData.BusAuxiliaries.ElectricalUserInputsConfig.ConnectESToREESS); + + TestBusAux_Cases(container, drivingBehavior, iceOn, batterySoC, double.NaN, + P_auxMech_expected, P_busAux_ES_gen_expected, double.NaN, P_busAux_ES_consumer_sum_expected, P_busAux_ES_mech, Nl_PS_gen_expected, Nl_PS_consumer_expected, P_PS_expected, double.NaN, + P_aux_ESS_mech_ICE_off_expected, P_aux_ESS_mech_ICE_on_expected, null, null, null); + + } + + // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + + + [TestCase(DrivingBehavior.Driving, true, 0.5, 0.5, double.NaN, + P_aux_m_Base + P_PS_1000, 0, P_ES_base, P_ES_base, 0, 0, 0, 0, 0, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case C3a (1); driving, ICE on, battery not empyt, REESS not empty")] + [TestCase(DrivingBehavior.Driving, true, 0.0, 0.5, double.NaN, + P_aux_m_Base + P_PS_1000, 0, 0, P_ES_base, 0, 0, 0, P_ES_base, 0, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case C3a (2); driving, ICE on, battery empty, REESS not empty")] + [TestCase(DrivingBehavior.Driving, true, 0.5, REESS_MinSoC, double.NaN, + P_aux_m_Base + P_PS_1000, 0, P_ES_base, P_ES_base, 0, 0, 0, 0, 0, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case C3a (3); driving, ICE on, battery not empty, REESS empty")] + [TestCase(DrivingBehavior.Driving, true, 0.0, REESS_MinSoC, double.NaN, + P_aux_m_Base + P_PS_1000, 0, 0, P_ES_base, 0, 0, 0, 0, P_ES_base, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case C3a (4); driving, ICE on, battery empty, REESS empty")] + + [TestCase(DrivingBehavior.Driving, false, 0.5, 0.5, double.NaN, + 0, 0, P_ES_ICEOff_dr, P_ES_ICEOff_dr, 0, P_aux_m_ICEOff_dr, P_aux_m_Base, 0, 0, 0, 0, Nl_PS, 0, + TestName = "BusAux Case C3a (5); driving, ICE off, battery not empty, REESS not empty")] + [TestCase(DrivingBehavior.Driving, false, 0.0, 0.5, double.NaN, + 0, 0, 0, P_ES_ICEOff_dr, 0, P_aux_m_ICEOff_dr, P_aux_m_Base, P_ES_ICEOff_dr, 0, 0, 0, Nl_PS, 0, + TestName = "BusAux Case C3a (6); driving, ICE off, battery empty, REESS not empty")] + [TestCase(DrivingBehavior.Driving, false, 0.5, REESS_MinSoC, double.NaN, + 0, 0, P_ES_ICEOff_dr, P_ES_ICEOff_dr, 0, P_aux_m_ICEOff_dr, P_aux_m_Base, 0, 0, 0, 0, Nl_PS, 0, + TestName = "BusAux Case C3a (7); driving, ICE off, battery not empty, REESS empty")] + [TestCase(DrivingBehavior.Driving, false, 0.0, REESS_MinSoC, double.NaN, + 0, 0, 0, P_ES_ICEOff_dr, 0, P_aux_m_ICEOff_dr, P_aux_m_Base, 0, P_ES_ICEOff_dr, 0, 0, Nl_PS, 0, + TestName = "BusAux Case C3a (8); driving, ICE off, battery empty, REESS empty")] + + [TestCase(DrivingBehavior.Halted, true, 0.5, 0.5, double.NaN, + P_aux_m_Base + P_PS_600, 0, P_ES_base, P_ES_base, 0, 0, 0, 0, 0, 0, Nl_PS, Nl_PS, P_PS_600, + TestName = "BusAux Case C3a (9); standstill, ICE on, battery not empty, REESS not empty")] + [TestCase(DrivingBehavior.Halted, true, 0.0, 0.5, double.NaN, + P_aux_m_Base + P_PS_600, 0, 0, P_ES_base, 0, 0, 0, P_ES_base, 0, 0, Nl_PS, Nl_PS, P_PS_600, + TestName = "BusAux Case C3a (10); standstill, ICE on, battery empty, REESS not empty")] + [TestCase(DrivingBehavior.Halted, true, 0.5, REESS_MinSoC, double.NaN, + P_aux_m_Base + P_PS_600, 0, P_ES_base, P_ES_base, 0, 0, 0, 0, 0, 0, Nl_PS, Nl_PS, P_PS_600, + TestName = "BusAux Case C3a (11); standstill, ICE on, battery not empty, REESS empty")] + [TestCase(DrivingBehavior.Halted, true, 0.0, REESS_MinSoC, double.NaN, + P_aux_m_Base + P_PS_600, 0, 0, P_ES_base, 0, 0, 0, 0, P_ES_base, 0, Nl_PS, Nl_PS, P_PS_600, + TestName = "BusAux Case C3a (12); standstill, ICE on, battery empty, REESS empty")] + + [TestCase(DrivingBehavior.Halted, false, 0.5, 0.5, double.NaN, + 0, 0, P_ES_ICEOff_stop, P_ES_ICEOff_stop, 0, P_aux_m_ICEOff_st, P_aux_m_Base, 0, 0, (P_ES_base - P_ES_ICEOff_stop), 0, Nl_PS, 0, + TestName = "BusAux Case C3a (13); standstill, ICE off, battery not empty, REESS not empty")] + [TestCase(DrivingBehavior.Halted, false, 0.0, 0.5, double.NaN, + 0, 0, 0, P_ES_ICEOff_stop, 0, P_aux_m_ICEOff_st, P_aux_m_Base, P_ES_ICEOff_stop, 0, (P_ES_base - P_ES_ICEOff_stop), 0, Nl_PS, 0, + TestName = "BusAux Case C3a (14); standstill, ICE off, battery empty, REESS not empty")] + [TestCase(DrivingBehavior.Halted, false, 0.5, REESS_MinSoC, double.NaN, + 0, 0, P_ES_ICEOff_stop, P_ES_ICEOff_stop, 0, P_aux_m_ICEOff_st, P_aux_m_Base, 0, 0, (P_ES_base - P_ES_ICEOff_stop), 0, Nl_PS, 0, + TestName = "BusAux Case C3a (15); standstill, ICE off, battery not empty, REESS empty")] + [TestCase(DrivingBehavior.Halted, false, 0.0, REESS_MinSoC, double.NaN, + 0, 0, 0, P_ES_ICEOff_stop, 0, P_aux_m_ICEOff_st, P_aux_m_Base, 0, P_ES_ICEOff_stop, (P_ES_base - P_ES_ICEOff_stop), 0, Nl_PS, 0, + TestName = "BusAux Case C3a (16); standstill, ICE off, battery empty, REESS empty")] + + [TestCase(DrivingBehavior.Braking, true, 0.5, 0.5, 0.5, + P_aux_m_Base + P_PS_1000, 0, P_ES_base, P_ES_base, 0, 0, 0, 0, 0, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case C3a (17); braking, ICE on, battery not empty, REESS not empty, P1 recup 0.5")] + [TestCase(DrivingBehavior.Braking, true, 0.0, 0.5, 0.5, + P_aux_m_Base + P_PS_1000, 0, 0, P_ES_base, 0, 0, 0, P_ES_base, 0, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case C3a (18); braking, ICE on, battery empty, REESS not empty, P1 recup 0.5")] + [TestCase(DrivingBehavior.Braking, true, 0.5, REESS_MinSoC, 0.5, + P_aux_m_Base + P_PS_1000, 0, P_ES_base, P_ES_base, 0, 0, 0, 0, 0, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case C3a (19); braking, ICE on, battery not empty, REESS empty, P1 recup 0.5")] + [TestCase(DrivingBehavior.Braking, true, 0.0, REESS_MinSoC, 0.5, + P_aux_m_Base + P_PS_1000, 0, 0, P_ES_base, 0, 0, 0, 0, P_ES_base, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case C3a (20); braking, ICE on, battery empty, REESS empty, P1 recup 0.5")] + + [TestCase(DrivingBehavior.Braking, false, 0.5, 0.5, 0.5, + 0, 0, P_ES_ICEOff_dr, P_ES_ICEOff_dr, 0, P_aux_m_ICEOff_dr, P_aux_m_Base, 0, 0, (P_ES_base - P_ES_ICEOff_dr), 0, Nl_PS, 0, + TestName = "BusAux Case C3a (21); braking, ICE off, battery not empty, REESS not empty, P1 recup 0.5")] + [TestCase(DrivingBehavior.Braking, false, 0.0, 0.5, 0.5, + 0, 0, 0, P_ES_ICEOff_dr, 0, P_aux_m_ICEOff_dr, P_aux_m_Base, P_ES_ICEOff_dr, 0, (P_ES_base - P_ES_ICEOff_dr), 0, Nl_PS, 0, + TestName = "BusAux Case C3a (22); braking, ICE off, battery empty, REESS not empty, P1 recup 0.5")] + [TestCase(DrivingBehavior.Braking, false, 0.5, REESS_MinSoC, 0.5, + 0, 0, P_ES_ICEOff_dr, P_ES_ICEOff_dr, 0, P_aux_m_ICEOff_dr, P_aux_m_Base, 0, 0, (P_ES_base - P_ES_ICEOff_dr), 0, Nl_PS, 0, + TestName = "BusAux Case C3a (23); braking, ICE off, battery not empty, REESS empty, P1 recup 0.5")] + [TestCase(DrivingBehavior.Braking, false, 0.0, REESS_MinSoC, 0.5, + 0, 0, 0, P_ES_ICEOff_dr, 0, P_aux_m_ICEOff_dr, P_aux_m_Base, 0, P_ES_ICEOff_dr, (P_ES_base - P_ES_ICEOff_dr), 0, Nl_PS, 0, + TestName = "BusAux Case C3a (24); braking, ICE off, battery empty, REESS empty, P1 recup 0.5")] + + [TestCase(DrivingBehavior.Braking, true, 0.5, 0.5, 1, + P_aux_m_Base + P_PS_1000 + MaxAlternatorPower / AlternatorEfficiency, MaxAlternatorPower, P_ES_base - MaxAlternatorPower, P_ES_base, MaxAlternatorPower / AlternatorEfficiency, 0, 0, 0, 0, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case C3a (25); braking, ICE on, battery not empty, REESS not empty, P1 recup 1")] + [TestCase(DrivingBehavior.Braking, true, 0.0, 0.5, 1, + P_aux_m_Base + P_PS_1000 + MaxAlternatorPower / AlternatorEfficiency, MaxAlternatorPower, P_ES_base - MaxAlternatorPower, P_ES_base, MaxAlternatorPower / AlternatorEfficiency, 0, 0, 0, 0, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case C3a (26); braking, ICE on, battery empty, REESS not empty, P1 recup 1")] + [TestCase(DrivingBehavior.Braking, true, 0.5, REESS_MinSoC, 1, + P_aux_m_Base + P_PS_1000 + MaxAlternatorPower / AlternatorEfficiency, MaxAlternatorPower, P_ES_base - MaxAlternatorPower, P_ES_base, MaxAlternatorPower / AlternatorEfficiency, 0, 0, 0, 0, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case C3a (27); braking, ICE on, battery not empty, REESS empty, P1 recup 1")] + [TestCase(DrivingBehavior.Braking, true, 0.0, REESS_MinSoC, 1, + P_aux_m_Base + P_PS_1000 + MaxAlternatorPower / AlternatorEfficiency, MaxAlternatorPower, P_ES_base - MaxAlternatorPower, P_ES_base, MaxAlternatorPower / AlternatorEfficiency, 0, 0, 0, 0, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case C3a (28); braking, ICE on, battery empty, REESS empty, P1 recup 1")] + + [TestCase(DrivingBehavior.Braking, false, 0.5, 0.5, 1, + 0, 0, P_ES_ICEOff_dr, P_ES_ICEOff_dr, 0, P_aux_m_ICEOff_dr, P_aux_m_Base, 0, 0, (P_ES_base - P_ES_ICEOff_dr), 0, Nl_PS, 0, + TestName = "BusAux Case C3a (29); braking, ICE off, battery not empty, REESS not empty, P1 recup 1")] + [TestCase(DrivingBehavior.Braking, false, 0.0, 0.5, 1, + 0, 0, 0, P_ES_ICEOff_dr, 0, P_aux_m_ICEOff_dr, P_aux_m_Base, P_ES_ICEOff_dr, 0, (P_ES_base - P_ES_ICEOff_dr), 0, Nl_PS, 0, + TestName = "BusAux Case C3a (30); braking, ICE off, battery empty, REESS not empty, P1 recup 1")] + [TestCase(DrivingBehavior.Braking, false, 0.5, REESS_MinSoC, 1, + 0, 0, P_ES_ICEOff_dr, P_ES_ICEOff_dr, 0, P_aux_m_ICEOff_dr, P_aux_m_Base, 0, 0, (P_ES_base - P_ES_ICEOff_dr), 0, Nl_PS, 0, + TestName = "BusAux Case C3a (31); braking, ICE off, battery not empty, REESS empty, P1 recup 1")] + [TestCase(DrivingBehavior.Braking, false, 0.0, REESS_MinSoC, 1, + 0, 0, 0, P_ES_ICEOff_dr, 0, P_aux_m_ICEOff_dr, P_aux_m_Base, 0, P_ES_ICEOff_dr, (P_ES_base - P_ES_ICEOff_dr), 0, Nl_PS, 0 + , + TestName = "BusAux Case C3a (32); braking, ICE off, battery empty, REESS empty, P1 recup 1")] + + public void TestBusAux_Case_C3A(DrivingBehavior drivingBehavior, bool iceOn, double batterySoC, double reessSoC, double P1recupPct, + double P_auxMech_expected, double P_busAux_ES_gen_expected, double P_bat_P0, double P_busAux_ES_consumer_sum_expected, + double P_busAux_ES_mech, + double P_aux_ESS_mech_ICE_off_expected, double P_aux_ESS_mech_ICE_on_expected, + double P_DCDC_out_expected, double P_DCDC_missing_expected, double P_DCDC_missing_ESS_ICE_on, + double Nl_PS_gen_expected, double Nl_PS_consumer_expected, double P_PS_expected) + { + var container = CreatePowerTrain(AlternatorType.Smart, batterySoC, reessSoC, true); + + + // check powertrain architecture and config + Assert.NotNull(container.Components.FirstOrDefault(x => x is StopStartCombustionEngine)); + Assert.NotNull(container.Components.FirstOrDefault(x => x is BusAuxiliariesAdapter)); + Assert.NotNull(container.Components.FirstOrDefault(x => x is SimpleBattery)); + + // HEV, no DCDC converter + Assert.NotNull(container.Components.FirstOrDefault(x => x is DCDCConverter)); + Assert.NotNull(container.Components.FirstOrDefault(x => x is ElectricSystem)); + Assert.NotNull(container.Components.FirstOrDefault(x => x is Battery)); + + // simulated with alternator type NONE! + Assert.AreEqual(AlternatorType.Smart, container.RunData.BusAuxiliaries.ElectricalUserInputsConfig.AlternatorType); + Assert.IsTrue(container.RunData.BusAuxiliaries.ElectricalUserInputsConfig.ConnectESToREESS); + + TestBusAux_Cases(container, drivingBehavior, iceOn, batterySoC, double.NaN, + P_auxMech_expected, P_busAux_ES_gen_expected, -P_bat_P0, P_busAux_ES_consumer_sum_expected, P_busAux_ES_mech, Nl_PS_gen_expected, Nl_PS_consumer_expected, P_PS_expected, P1recupPct, + P_aux_ESS_mech_ICE_off_expected, P_aux_ESS_mech_ICE_on_expected, null, null, null); + } + + // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + + + [TestCase(DrivingBehavior.Driving, true, 0.5, double.NaN, + P_aux_m_Base + P_PS_1000, 0, P_ES_base, P_ES_base, 0, 0, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case C3b (1); driving, ICE on, P0 battery not empty")] + [TestCase(DrivingBehavior.Driving, true, 0, double.NaN, + P_aux_m_Base + P_PS_1000 + P_ES_base / AlternatorEfficiency, P_ES_base, 0, P_ES_base, P_ES_base / AlternatorEfficiency, 0, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case C3b (2); driving, ICE on, P0 battery empty")] + [TestCase(DrivingBehavior.Driving, false, 0.5, double.NaN, + 0, 0, P_ES_ICEOff_dr, P_ES_ICEOff_dr, 0, P_aux_m_ICEOff_dr, P_aux_m_Base + (P_ES_base - P_ES_ICEOff_dr) / AlternatorEfficiency, 0, Nl_PS, 0, + TestName = "BusAux Case C3b (3); driving, ICE off, P0 battery not empty")] + [TestCase(DrivingBehavior.Driving, false, 0, double.NaN, + 0, 0, 0, P_ES_ICEOff_dr, 0, P_aux_m_ICEOff_dr, P_aux_m_Base + (P_ES_base - P_ES_ICEOff_dr) / AlternatorEfficiency, 0, Nl_PS, 0, + TestName = "BusAux Case C3b (4); driving, ICE off, P0 battery empty")] + + [TestCase(DrivingBehavior.Halted, true, 0.5, double.NaN, + P_aux_m_Base + P_PS_600, 0, P_ES_base, P_ES_base, 0, 0, 0, Nl_PS, Nl_PS, P_PS_600, + TestName = "BusAux Case C3b (5); standstill, ICE on, P0 battery not empty")] + [TestCase(DrivingBehavior.Halted, true, 0, double.NaN, + P_aux_m_Base + P_PS_600 + P_ES_base / AlternatorEfficiency, P_ES_base, 0, P_ES_base, P_ES_base / AlternatorEfficiency, 0, 0, Nl_PS, Nl_PS, P_PS_600, + TestName = "BusAux Case C3b (6); standstill, ICE on, P0 battery empty")] + [TestCase(DrivingBehavior.Halted, false, 0.5, double.NaN, + 0, 0, P_ES_ICEOff_stop, P_ES_ICEOff_stop, 0, P_aux_m_ICEOff_st, P_aux_m_Base + (P_ES_base - P_ES_ICEOff_stop) / AlternatorEfficiency, 0, Nl_PS, 0, + TestName = "BusAux Case C3b (7); standstill, ICE off, P0 battery not empty")] + [TestCase(DrivingBehavior.Halted, false, 0, double.NaN, + 0, 0, 0, P_ES_ICEOff_stop, 0, P_aux_m_ICEOff_st, P_aux_m_Base + (P_ES_base - P_ES_ICEOff_stop) / AlternatorEfficiency, 0, Nl_PS, 0, + TestName = "BusAux Case C3b (8); standstill, ICE off, P0 battery empty")] + + [TestCase(DrivingBehavior.Braking, true, 0.5, 0.5, + P_aux_m_Base + P_PS_1000, 0, P_ES_base, P_ES_base, 0, 0, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case C3b (9); braking, ICE on, P0 battery not empty, P1 recup 0.5")] + [TestCase(DrivingBehavior.Braking, true, 1, 0.5, + P_aux_m_Base + P_PS_1000, 0, P_ES_base, P_ES_base, 0, 0, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case C3b (10); braking, ICE on, P0 battery full, P1 recup 0.5")] + [TestCase(DrivingBehavior.Braking, true, 0, 0.5, + P_aux_m_Base + P_PS_1000 + P_ES_base / AlternatorEfficiency, P_ES_base, 0, P_ES_base, P_ES_base / AlternatorEfficiency, 0, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case C3b (11); braking, ICE on, P0 battery empty, P1 recup 0.5")] + [TestCase(DrivingBehavior.Braking, false, 0.5, 0.5, + 0, 0, P_ES_ICEOff_dr, P_ES_ICEOff_dr, 0, P_aux_m_ICEOff_dr, P_aux_m_Base + (P_ES_base - P_ES_ICEOff_dr) / AlternatorEfficiency, 0, Nl_PS, 0, + TestName = "BusAux Case C3b (12); braking, ICE off, P0 battery not empty, P1 recup 0.5")] + [TestCase(DrivingBehavior.Braking, false, 1, 0.5, + 0, 0, P_ES_ICEOff_dr, P_ES_ICEOff_dr, 0, P_aux_m_ICEOff_dr, P_aux_m_Base + (P_ES_base - P_ES_ICEOff_dr) / AlternatorEfficiency, 0, Nl_PS, 0, + TestName = "BusAux Case C3b (13); braking, ICE off, P0 battery full, P1 recup 0.5")] + [TestCase(DrivingBehavior.Braking, false, 0, 0.5, + 0, 0, 0, P_ES_ICEOff_dr, 0, P_aux_m_ICEOff_dr, P_aux_m_Base + (P_ES_base - P_ES_ICEOff_dr) / AlternatorEfficiency, 0, Nl_PS, 0, + TestName = "BusAux Case C3b (14); braking, ICE off, P0 battery empty, P1 recup 0.5")] + + [TestCase(DrivingBehavior.Braking, true, 0.5, 1, + P_aux_m_Base + P_PS_1000 + MaxAlternatorPower / AlternatorEfficiency, MaxAlternatorPower, P_ES_base - MaxAlternatorPower, P_ES_base, MaxAlternatorPower / AlternatorEfficiency, 0, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case C3b (15); braking, ICE on, P0 battery not empty, P1 recup 1")] + [TestCase(DrivingBehavior.Braking, true, 1, 1, + P_aux_m_Base + P_PS_1000 + P_ES_base / AlternatorEfficiency, P_ES_base, 0, P_ES_base, P_ES_base / AlternatorEfficiency, 0, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case C3b (16); braking, ICE on, P0 battery full, P1 recup 1")] + [TestCase(DrivingBehavior.Braking, true, 0, 1, + P_aux_m_Base + P_PS_1000 + MaxAlternatorPower / AlternatorEfficiency, MaxAlternatorPower, P_ES_base - MaxAlternatorPower, P_ES_base, MaxAlternatorPower / AlternatorEfficiency, 0, 0, Nl_PS, Nl_PS, P_PS_1000, + TestName = "BusAux Case C3b (17); braking, ICE on, P0 battery empty, P1 recup 1")] + [TestCase(DrivingBehavior.Braking, false, 0.5, 1, + 0, 0, P_ES_ICEOff_dr, P_ES_ICEOff_dr, 0, P_aux_m_ICEOff_dr, P_aux_m_Base + (P_ES_base - P_ES_ICEOff_dr) / AlternatorEfficiency, 0, Nl_PS, 0, + TestName = "BusAux Case C3b (18); braking, ICE off, P0 battery not empty, P1 recup 1")] + [TestCase(DrivingBehavior.Braking, false, 1, 1, + 0, 0, P_ES_ICEOff_dr, P_ES_ICEOff_dr, 0, P_aux_m_ICEOff_dr, P_aux_m_Base + (P_ES_base - P_ES_ICEOff_dr) / AlternatorEfficiency, 0, Nl_PS, 0, + TestName = "BusAux Case C3b (19); braking, ICE off, P0 battery full, P1 recup 1")] + [TestCase(DrivingBehavior.Braking, false, 0, 1, + 0, 0, 0, P_ES_ICEOff_dr, 0, P_aux_m_ICEOff_dr, P_aux_m_Base + (P_ES_base - P_ES_ICEOff_dr) / AlternatorEfficiency, 0, Nl_PS, 0, + TestName = "BusAux Case C3b (20); braking, ICE off, P0 battery empty, P1 recup 1")] + public void TestBusAux_Case_C3B(DrivingBehavior drivingBehavior, bool iceOn, double batterySoC, double P1recupPct, + double P_auxMech_expected, double P_busAux_ES_gen_expected, double P_bat_P0, double P_busAux_ES_consumer_sum_expected, + double P_busAux_ES_mech, double P_aux_ESS_mech_ICE_off_expected, double P_aux_ESS_mech_ICE_on_expected, + double Nl_PS_gen_expected, double Nl_PS_consumer_expected, double P_PS_expected) + { + var container = CreatePowerTrain(AlternatorType.Smart, batterySoC, 0.5, false); + + // check powertrain architecture and config + Assert.NotNull(container.Components.FirstOrDefault(x => x is StopStartCombustionEngine)); + Assert.NotNull(container.Components.FirstOrDefault(x => x is BusAuxiliariesAdapter)); + Assert.NotNull(container.Components.FirstOrDefault(x => x is SimpleBattery)); + + // HEV + Assert.Null(container.Components.FirstOrDefault(x => x is DCDCConverter)); + Assert.NotNull(container.Components.FirstOrDefault(x => x is ElectricSystem)); + Assert.NotNull(container.Components.FirstOrDefault(x => x is Battery)); + + // simulated with alternator type NONE! + Assert.AreEqual(AlternatorType.Smart, container.RunData.BusAuxiliaries.ElectricalUserInputsConfig.AlternatorType); + Assert.IsFalse(container.RunData.BusAuxiliaries.ElectricalUserInputsConfig.ConnectESToREESS); + + TestBusAux_Cases(container, drivingBehavior, iceOn, batterySoC, double.NaN, + P_auxMech_expected, P_busAux_ES_gen_expected, -P_bat_P0, P_busAux_ES_consumer_sum_expected, P_busAux_ES_mech, Nl_PS_gen_expected, Nl_PS_consumer_expected, P_PS_expected, P1recupPct, + P_aux_ESS_mech_ICE_off_expected, P_aux_ESS_mech_ICE_on_expected, null, null, null); + } + + // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + + public void TestBusAux_Cases(MockVehicleContainer container, DrivingBehavior drivingBehavior, bool iceOn, + double batterySoC, double reessSoC, + double P_auxMech_expected, double P_busAux_ES_gen_expected, double P_bat_P0, + double P_busAux_ES_consumer_sum_expected, + double P_busAux_ES_mech, + double Nl_gen_expected, double Nl_consumed_expected, double P_PS_m_expected, + double P1_recup_Pct, + double P_aux_ESS_mech_ICE_off_expected, double P_aux_ESS_mech_ICE_on_expected, double? P_DCDC_out_expected, + double? P_DCDC_missing_expected, double? P_DCDC_missing_ESS_ICE_on) + { + container.VehicleStopped = drivingBehavior == DrivingBehavior.Halted; + container.VehicleSpeed = drivingBehavior == DrivingBehavior.Halted + ? 0.KMPHtoMeterPerSecond() + : 30.KMPHtoMeterPerSecond(); + container.DriverBehavior = drivingBehavior; + container.DrivingAction = drivingBehavior == DrivingBehavior.Halted + ? DrivingAction.Halt + : (drivingBehavior == DrivingBehavior.Braking ? DrivingAction.Brake : DrivingAction.Accelerate); + container.EngineSpeed = drivingBehavior == DrivingBehavior.Halted ? 600.RPMtoRad() : 1000.RPMtoRad(); + container.EngineCtl.CombustionEngineOn = iceOn; + + + var ice = container.Components.First(x => x is ICombustionEngine) as StopStartCombustionEngine; + Assert.NotNull(ice); + + var modData = container.ModalData as ModalDataContainer; + Assert.NotNull(modData); + + var absTime = 0.SI<Second>(); + var dt = 1.SI<Second>(); + IResponse response = null; + switch (drivingBehavior) { + case DrivingBehavior.Halted: + container.Gear = new GearshiftPosition(0); + ice.CombustionEngineOn = iceOn; + response = ice.Request(absTime, dt, 0.SI<NewtonMeter>(), 600.RPMtoRad(), false); + break; + case DrivingBehavior.Accelerating: + case DrivingBehavior.Driving: + container.Gear = new GearshiftPosition(3); + ice.CombustionEngineOn = iceOn; + response = ice.Request(absTime, dt, 0.SI<NewtonMeter>(), iceOn ? 1000.RPMtoRad() : 600.RPMtoRad(), false); + break; + case DrivingBehavior.Braking: + container.Gear = new GearshiftPosition(3); + container.BrakePower = P1_recup_Pct.IsSmaller(1) ? 0.SI<Watt>() : 50e3.SI<Watt>(); + ice.CombustionEngineOn = iceOn; + response = ice.Request(absTime, dt, 0.SI<NewtonMeter>(), iceOn ? 1000.RPMtoRad() : 600.RPMtoRad(), false); + break; + default: + throw new ArgumentOutOfRangeException(nameof(drivingBehavior), drivingBehavior, null); + } + + (container.Components.FirstOrDefault(x => x is IElectricSystem) as ElectricSystem)?.Request(absTime, dt, 0.SI<Watt>()); + + Assert.NotNull(response); + Assert.IsAssignableFrom<ResponseSuccess>(response); + + container.CommitSimulationStep(absTime, dt); + modData.CommitSimulationStep(); + + Assert.AreEqual(1, modData.Data.Rows.Count); + + var row = modData.Data.Rows[0]; + + Assert.AreEqual(iceOn, row.Field<bool>(ModalResultField.ICEOn.GetName()), ModalResultField.ICEOn.GetName()); + Assert.AreEqual(P_auxMech_expected, row.Field<SI>(ModalResultField.P_aux_mech.GetName()).Value(), 1e-3, ModalResultField.P_aux_mech.GetName()); + Assert.AreEqual(P_busAux_ES_gen_expected, row.Field<SI>(ModalResultField.P_busAux_ES_generated.GetName()).Value(), 1e-3, ModalResultField.P_busAux_ES_generated.GetName()); + Assert.AreEqual(P_busAux_ES_consumer_sum_expected, row.Field<SI>(ModalResultField.P_busAux_ES_consumer_sum.GetName()).Value(), 1e-3, ModalResultField.P_busAux_ES_consumer_sum.GetName()); + Assert.AreEqual(P_busAux_ES_consumer_sum_expected, row.Field<SI>(ModalResultField.P_busAux_ES_other.GetName()).Value(), 1e-3, ModalResultField.P_busAux_ES_other.GetName()); + Assert.AreEqual(P_busAux_ES_mech, row.Field<SI>(ModalResultField.P_busAux_ES_sum_mech.GetName()).Value(), 1e-3, ModalResultField.P_busAux_ES_sum_mech.GetName()); + + Assert.AreEqual(Nl_consumed_expected, row.Field<SI>(ModalResultField.Nl_busAux_PS_consumer.GetName()).Value(), 1e-3, ModalResultField.Nl_busAux_PS_consumer.GetName()); + Assert.AreEqual(Nl_gen_expected, row.Field<SI>(ModalResultField.Nl_busAux_PS_generated.GetName()).Value(), 1e-3, ModalResultField.Nl_busAux_PS_generated.GetName()); + Assert.AreEqual(P_PS_m_expected, row.Field<SI>(ModalResultField.P_busAux_PS_generated.GetName()).Value(), 1e-3, ModalResultField.P_busAux_PS_generated.GetName()); + + Assert.AreEqual(P_aux_ESS_mech_ICE_off_expected, row.Field<SI>(ModalResultField.P_aux_ESS_mech_ice_off.GetName()).Value(), 1e-3, ModalResultField.P_aux_ESS_mech_ice_off.GetName()); + Assert.AreEqual(P_aux_ESS_mech_ICE_on_expected, row.Field<SI>(ModalResultField.P_aux_ESS_mech_ice_on.GetName()).Value(), 1e-3, ModalResultField.P_aux_ESS_mech_ice_on.GetName()); + + if (!double.IsNaN(P_bat_P0)) { + Assert.AreEqual(P_bat_P0, row.Field<SI>(ModalResultField.P_busAux_bat.GetName()).Value(), 1e-3, ModalResultField.P_busAux_bat.GetName()); + } else { + Assert.IsTrue(container.Components.Any(x => x is NoBattery)); + } + + if (P_DCDC_missing_expected.HasValue && P_DCDC_out_expected.HasValue && P_DCDC_missing_ESS_ICE_on.HasValue) { + var dcdcConverter = container.Components.FirstOrDefault(x => x is IDCDCConverter) as DCDCConverter; + Assert.NotNull(dcdcConverter); + + // 'consumed' and 'missing' electric energy is applied in next simulation step - read out directly and perform additional step + if (reessSoC.IsEqual(REESS_MinSoC)) { + Assert.AreEqual(P_DCDC_missing_expected.Value, (dcdcConverter.PreviousState.ConsumedEnergy / dt).Value(), 1e-3, ModalResultField.P_DCDC_missing.GetName()); + } else { + Assert.AreEqual(P_busAux_ES_consumer_sum_expected, (dcdcConverter.PreviousState.ConsumedEnergy / dt).Value(), 1e-3, ModalResultField.P_DCDC_Out.GetName()); + } + + var dcdcDemand = dcdcConverter.PowerDemand(absTime, dt, false); + + if (reessSoC.IsEqual(REESS_MinSoC)) { + Assert.AreEqual(0, dcdcDemand.Value(), 1e-3, "DC/DC PowerDemand"); + } else { + Assert.AreEqual(P_DCDC_out_expected.Value / DCDCEfficiency, dcdcDemand.Value(), 1e-3, + "DC/DC PowerDemand OUT"); + } + + dcdcConverter.CommitSimulationStep(absTime, dt, modData); + modData.CommitSimulationStep(); + var row1 = modData.Data.Rows[1]; + + Assert.AreEqual(P_DCDC_missing_expected.Value, row1.Field<SI>(ModalResultField.P_DCDC_missing.GetName()).Value(), 1e-3, ModalResultField.P_DCDC_missing.GetName()); + + Assert.AreEqual(P_DCDC_out_expected.Value, row1.Field<SI>(ModalResultField.P_DCDC_Out.GetName()).Value(), 1e-3, ModalResultField.P_DCDC_Out.GetName()); + Assert.AreEqual(P_DCDC_out_expected.Value / DCDCEfficiency, row1.Field<SI>(ModalResultField.P_DCDC_In.GetName()).Value(), 1e-3, ModalResultField.P_DCDC_In.GetName()); + + // TODO: Assertion P_DCDC_missing_ESS_ICE_on + + } + } + + public const string EngineFileHigh = @"TestData\Components\24t Coach_high.veng"; + + public static MockVehicleContainer CreatePowerTrain(AlternatorType alternatorType, double initialSoC, + double? reessSoC, bool connectEsToReess) + { + //var gearboxData = CreateGearboxData(); + var engineData = MockSimulationDataFactory.CreateEngineDataFromFile(EngineFileHigh, 6); + //var axleGearData = CreateAxleGearData(); + var vehicleData = CreateVehicleData(3300.SI<Kilogram>()); + //var airdragData = CreateAirdragData(); + //var driverData = CreateDriverData(AccelerationFile); + + var cycleData = DrivingCycleDataReader.ReadFromStream("s,v,grad,stop\n0,0,0,10\n10,20,0,0\n20,21,0,0\n30,22,0,0\n40,23,0,0\n50,24,0,0\n60,25,0,0\n70,26,0,0\n80,27,0,0\n90,28,0,0\n100,29,0,0".ToStream(), CycleType.DistanceBased, "DummyCycle", false); + + var runData = new VectoRunData() { + JobRunId = 0, + VehicleData = vehicleData, + EngineData = engineData, + ElectricMachinesData = new List<Tuple<PowertrainPosition, ElectricMotorData>>(), + SimulationType = SimulationType.DistanceCycle, + Cycle = cycleData, + BusAuxiliaries = CreateBusAuxData(alternatorType, vehicleData, connectEsToReess), + Aux = CreateAuxiliaryData(P_aux_m_Base.SI<Watt>(), P_aux_m_ICEOff_dr.SI<Watt>(), P_aux_m_ICEOff_st.SI<Watt>()) + }; + + + var modData = new ModalDataContainer(runData, null, null) { + WriteModalResults = false + }; + + var container = new MockVehicleContainer() { + CycleData = new CycleData() { LeftSample = cycleData.Entries.First()}, + ModalData = modData, + HasCombustionEngine = true, + HasElectricMotor = false, + RunData = runData + }; + var engine = new StopStartCombustionEngine(container, engineData); + + container.EngineInfo = engine; + + var conventionalAux = CreateAuxiliaries(runData.Aux, container); + var aux = new BusAuxiliariesAdapter(container, runData.BusAuxiliaries, conventionalAux); + + var auxCfg = runData.BusAuxiliaries; + var electricStorage = auxCfg.ElectricalUserInputsConfig.AlternatorType == AlternatorType.Smart + ? new SimpleBattery(container, auxCfg.ElectricalUserInputsConfig.ElectricStorageCapacity, + auxCfg.ElectricalUserInputsConfig.StoredEnergyEfficiency, initialSoC) + : (ISimpleBattery)new NoBattery(container); + aux.ElectricStorage = electricStorage; + engine.Connect(aux.Port()); + + + if (reessSoC.HasValue) { + // hybrid powertrain + var packCount = 2; + runData.BatteryData = new BatteryData() { + Capacity = REESS_Capacity.SI(Unit.SI.Ampere.Hour).Cast<AmpereSecond>(), + MinSOC = REESS_MinSoC, + MaxSOC = REESS_MaxSoC, + SOCMap = BatterySOCReader.Create("SOC,V\n0,590\n100,658".ToStream()), + InternalResistance = BatteryInternalResistanceReader.Create("SoC, Ri\n0,0.02\n100,0.02".ToStream(), packCount), + MaxCurrent = BatteryMaxCurrentReader.Create("SOC, I_charge, I_discharge\n0, 375, 573\n100, 375, 375".ToStream(), packCount), + InitialSoC = reessSoC.Value + }; + var es = new ElectricSystem(container); + var battery = new Battery(container, runData.BatteryData); + battery.Initialize(runData.BatteryData.InitialSoC); + container.BatteryInfo = battery; + es.Connect(battery); + if (connectEsToReess) { + var dcdc = new DCDCConverter(container, DCDCEfficiency); + dcdc.Initialize(); + aux.DCDCConverter = dcdc; + es.Connect(dcdc); + } + } + + + return container; + } + + private static IAuxPort CreateAuxiliaries(IEnumerable<VectoRunData.AuxData> auxDataList, + IVehicleContainer container) + { + var aux = new EngineAuxiliary(container); + foreach (var auxData in auxDataList) { + // id's in upper case + var id = auxData.ID.ToUpper(); + + switch (auxData.DemandType) { + case AuxiliaryDemandType.Constant: + aux.AddConstant(id, auxData.PowerDemand); + break; + default: + throw new ArgumentOutOfRangeException("AuxiliaryDemandType", auxData.DemandType.ToString()); + } + + container.ModalData?.AddAuxiliary(id); + } + + return aux; + } + + private static IList<VectoRunData.AuxData> CreateAuxiliaryData(Watt pwrICEOn, Watt pwrICEOffDriving, Watt pwrICEOffStandstill) + { + var baseDemand = pwrICEOffStandstill; + var stpDemand = pwrICEOffDriving - pwrICEOffStandstill; + var fanDemand = pwrICEOn - pwrICEOffDriving; + + var auxList = new List<VectoRunData.AuxData>() { + new VectoRunData.AuxData { ID = Constants.Auxiliaries.IDs.ENG_AUX_MECH_BASE, DemandType = AuxiliaryDemandType.Constant, PowerDemand = baseDemand}, + new VectoRunData.AuxData { ID = Constants.Auxiliaries.IDs.ENG_AUX_MECH_STP, DemandType = AuxiliaryDemandType.Constant, PowerDemand = stpDemand}, + new VectoRunData.AuxData { ID = Constants.Auxiliaries.IDs.ENG_AUX_MECH_FAN, DemandType = AuxiliaryDemandType.Constant, PowerDemand = fanDemand}, + }; + + return auxList; + } + + private static AuxiliaryConfig CreateBusAuxData(AlternatorType alternatorType, VehicleData vehicleData, + bool esSupplyFromHevreess) + { + var CompressorMap = "TestData/Integration/BusAuxiliaries/DEFAULT_2-Cylinder_1-Stage_650ccm.ACMP"; + var AverageAirDemand = Nl_PS.SI<NormLiterPerSecond>(); + var SmartAirCompression = false; + var GearRatio = 1.0; + + var BatteryEfficiency = 1.0; + //var ESSupplyFromHEVREESS = false; + //var AlternatorType = VectoCommon.Models.AlternatorType.Smart; + var ElectricPowerDemand = 0.0.SI<Watt>(); + var MechanicalPowerDemand = 0.0.SI<Watt>(); + var AuxHeaterPower = 0.0.SI<Watt>(); + var AverageHeatingDemand = 0.0.SI<Joule>(); + + var retVal = new AuxiliaryConfig() { + //InputData = auxInputData.BusAuxiliariesData, + ElectricalUserInputsConfig = new ElectricsUserInputsConfig() { + PowerNetVoltage = Constants.BusAuxiliaries.ElectricSystem.PowernetVoltage, + //StoredEnergyEfficiency = Constants.BusAuxiliaries.ElectricSystem.StoredEnergyEfficiency, + ResultCardIdle = new DummyResultCard(), + ResultCardOverrun = new DummyResultCard(), + ResultCardTraction = new DummyResultCard(), + AlternatorGearEfficiency = Constants.BusAuxiliaries.ElectricSystem.AlternatorGearEfficiency, + DoorActuationTimeSecond = Constants.BusAuxiliaries.ElectricalConsumers.DoorActuationTimeSecond, + AlternatorMap = new SimpleAlternator(AlternatorEfficiency) { + Technologies = new List<string>() { "engineering mode" } + }, + AlternatorType = esSupplyFromHevreess && + alternatorType != AlternatorType.Smart + ? AlternatorType.None + : alternatorType, + ConnectESToREESS = esSupplyFromHevreess, + DCDCEfficiency = DCDCEfficiency, + MaxAlternatorPower = MaxAlternatorPower.SI<Watt>(), + ElectricStorageCapacity = ElectricStorageCapacity ?? 0.SI<WattSecond>(), + StoredEnergyEfficiency = BatteryEfficiency, + ElectricalConsumers = GetElectricConsumers(I_Base.SI<Ampere>(), I_ICEOff_dr.SI<Ampere>(), I_ICEOff_stop.SI<Ampere>()), + }, + PneumaticAuxillariesConfig = new PneumaticsConsumersDemand() { + AdBlueInjection = 0.SI<NormLiterPerSecond>(), + AirControlledSuspension = AverageAirDemand, + Braking = 0.SI<NormLiterPerKilogram>(), + BreakingWithKneeling = 0.SI<NormLiterPerKilogramMeter>(), + DeadVolBlowOuts = 0.SI<PerSecond>(), + DeadVolume = 0.SI<NormLiter>(), + NonSmartRegenFractionTotalAirDemand = 0, + SmartRegenFractionTotalAirDemand = 0, + OverrunUtilisationForCompressionFraction = + Constants.BusAuxiliaries.PneumaticConsumersDemands.OverrunUtilisationForCompressionFraction, + DoorOpening = 0.SI<NormLiter>(), + StopBrakeActuation = 0.SI<NormLiterPerKilogram>(), + }, + PneumaticUserInputsConfig = new PneumaticUserInputsConfig() { + CompressorMap = + new CompressorMap(CompressorMapReader.Create(VectoCSVFile.Read(CompressorMap), 1.0), + "engineering mode", ""), + CompressorGearEfficiency = Constants.BusAuxiliaries.PneumaticUserConfig.CompressorGearEfficiency, + CompressorGearRatio = GearRatio, + SmartAirCompression = SmartAirCompression, + SmartRegeneration = false, + KneelingHeight = 0.SI<Meter>(), + AirSuspensionControl = ConsumerTechnology.Pneumatically, + AdBlueDosing = ConsumerTechnology.Electrically, + Doors = ConsumerTechnology.Electrically + }, + Actuations = new Actuations() { + Braking = 0, + Kneeling = 0, + ParkBrakeAndDoors = 0, + CycleTime = 1.SI<Second>() + }, + SSMInputs = new SSMEngineeringInputs() { + MechanicalPower = MechanicalPowerDemand, + ElectricPower = ElectricPowerDemand, + AuxHeaterPower = AuxHeaterPower, + HeatingDemand = AverageHeatingDemand, + AuxHeaterEfficiency = Constants.BusAuxiliaries.SteadyStateModel.AuxHeaterEfficiency, + FuelEnergyToHeatToCoolant = Constants.BusAuxiliaries.Heater.FuelEnergyToHeatToCoolant, + CoolantHeatTransferredToAirCabinHeater = + Constants.BusAuxiliaries.Heater.CoolantHeatTransferredToAirCabinHeater, + }, + VehicleData = vehicleData, + }; + + return retVal; + } + + private static Dictionary<string, ElectricConsumerEntry> GetElectricConsumers(Ampere currentDemand, Ampere currentDemandEngineOffDriving, Ampere currentDemandEngineOffStandstill) + { + var retVal = new Dictionary<string, ElectricConsumerEntry>(); + + var iBase = currentDemandEngineOffStandstill; + var iSP = currentDemandEngineOffDriving - + currentDemandEngineOffStandstill; + var iFan = currentDemand - currentDemandEngineOffDriving; + + retVal["BaseLoad"] = new ElectricConsumerEntry() { + Current = iBase, + BaseVehicle = true + }; + retVal[Constants.Auxiliaries.IDs.SteeringPump] = new ElectricConsumerEntry() { + Current = iSP, + ActiveDuringEngineStopStandstill = false, + }; + retVal[Constants.Auxiliaries.IDs.Fan] = new ElectricConsumerEntry() { + Current = iFan, + ActiveDuringEngineStopStandstill = false, + ActiveDuringEngineStopDriving = false, + }; + return retVal; + } + + + + private static VehicleData CreateVehicleData(Kilogram loading) + { + var axles = new List<Axle> { + new Axle { + AxleWeightShare = 0.4375, + Inertia = 21.66667.SI<KilogramSquareMeter>(), + RollResistanceCoefficient = 0.0055, + TwinTyres = false, + TyreTestLoad = 62538.75.SI<Newton>() + }, + new Axle { + AxleWeightShare = 0.375, + Inertia = 10.83333.SI<KilogramSquareMeter>(), + RollResistanceCoefficient = 0.0065, + TwinTyres = true, + TyreTestLoad = 52532.55.SI<Newton>() + }, + new Axle { + AxleWeightShare = 0.1875, + Inertia = 21.66667.SI<KilogramSquareMeter>(), + RollResistanceCoefficient = 0.0055, + TwinTyres = false, + TyreTestLoad = 62538.75.SI<Newton>() + } + }; + return new VehicleData { + AirDensity = DeclarationData.AirDensity, + AxleConfiguration = AxleConfiguration.AxleConfig_6x2, + CurbMass = 15700.SI<Kilogram>(), + Loading = loading, + DynamicTyreRadius = 0.52.SI<Meter>(), + AxleData = axles, + SavedInDeclarationMode = false + }; + } + } } \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/bin/Debug/TestData/Integration/VTPMode/GenericVehicle XMLJob PTO/Tractor_4x2_vehicle-class-5_Generic vehicle.RSLT_MANUFACTURER.xml b/VectoCore/VectoCoreTest/TestData/Integration/VTPMode/GenericVehicle XMLJob PTO/Tractor_4x2_vehicle-class-5_Generic vehicle.RSLT_MANUFACTURER.xml similarity index 100% rename from VectoCore/VectoCoreTest/bin/Debug/TestData/Integration/VTPMode/GenericVehicle XMLJob PTO/Tractor_4x2_vehicle-class-5_Generic vehicle.RSLT_MANUFACTURER.xml rename to VectoCore/VectoCoreTest/TestData/Integration/VTPMode/GenericVehicle XMLJob PTO/Tractor_4x2_vehicle-class-5_Generic vehicle.RSLT_MANUFACTURER.xml diff --git a/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs b/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs index b1b64a846bb56a8a38f01667a2bafa3dc350ed39..c4a7bca1e3c615bfeda8a5a3ad477609c77eb611 100644 --- a/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs +++ b/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs @@ -146,7 +146,8 @@ namespace TUGraz.VectoCore.Tests.Utils public IRESSInfo BatteryInfo { - get { throw new NotImplementedException(); } + get; + set; } public ITorqueConverterInfo TorqueConverterInfo @@ -403,8 +404,8 @@ namespace TUGraz.VectoCore.Tests.Utils set; } - public bool HasElectricMotor { get; } - public PowertrainPosition[] ElectricMotorPositions { get; } + public bool HasElectricMotor { get; set; } + public PowertrainPosition[] ElectricMotorPositions { get; set; } #endregion }