diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs b/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs index 4a7cddb69c5d4704cf7d070d2e969b5beb527393..ed7337b3d1b97de0fb51c8b583ef8e394fdce9bc 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs @@ -46,255 +46,255 @@ using Wheels = TUGraz.VectoCore.Models.SimulationComponent.Impl.Wheels; namespace TUGraz.VectoCore.Models.Simulation.Impl { - /// <summary> - /// Provides Methods to build a simulator with a powertrain step by step. - /// </summary> - public class PowertrainBuilder - { - private readonly IModalDataContainer _modData; - private readonly WriteSumData _sumWriter; - - public PowertrainBuilder(IModalDataContainer modData, WriteSumData sumWriter = null) - { - if (modData == null) { - throw new VectoException("Modal Data Container can't be null"); - } - _modData = modData; - _sumWriter = sumWriter; - } - - public VehicleContainer Build(VectoRunData data) - { - switch (data.Cycle.CycleType) { - case CycleType.EngineOnly: - return BuildEngineOnly(data); - case CycleType.PWheel: - return BuildPWheel(data); - case CycleType.MeasuredSpeed: - return BuildMeasuredSpeed(data); - case CycleType.MeasuredSpeedGear: - return BuildMeasuredSpeedGear(data); - case CycleType.DistanceBased: - return BuildFullPowertrain(data); - default: - throw new VectoException("Powertrain Builder cannot build Powertrain for CycleType: {0}", data.Cycle.CycleType); - } - } - - private VehicleContainer BuildEngineOnly(VectoRunData data) - { - if (data.Cycle.CycleType != CycleType.EngineOnly) { - throw new VectoException("CycleType must be EngineOnly."); - } - - var container = new VehicleContainer(ExecutionMode.Engineering, _modData, _sumWriter) { RunData = data }; - var cycle = new PowertrainDrivingCycle(container, data.Cycle); - - var directAux = new EngineAuxiliary(container); - directAux.AddCycle(Constants.Auxiliaries.Cycle); - container.ModalData.AddAuxiliary(Constants.Auxiliaries.Cycle); - var engine = new EngineOnlyCombustionEngine(container, data.EngineData); - engine.Connect(directAux.Port()); - - cycle.InPort().Connect(engine.OutPort()); - return container; - } - - private VehicleContainer BuildPWheel(VectoRunData data) - { - if (data.Cycle.CycleType != CycleType.PWheel) { - throw new VectoException("CycleType must be PWheel."); - } - - var container = new VehicleContainer(ExecutionMode.Engineering, _modData, _sumWriter) { RunData = data }; - var gearbox = new CycleGearbox(container, data.GearboxData, data.EngineData.Inertia); - - // PWheelCycle --> AxleGear --> CycleClutch --> Engine <-- Aux - var powertrain = new PWheelCycle(container, data.Cycle, data.AxleGearData.AxleGear.Ratio, - gearbox.ModelData.Gears.ToDictionary(g => g.Key, g => g.Value.Ratio)) - .AddComponent(new AxleGear(container, data.AxleGearData)) - .AddComponent(data.AngledriveData != null ? new Angledrive(container, data.AngledriveData) : null) - .AddComponent(gearbox, data.Retarder, container) - .AddComponent(new Clutch(container, data.EngineData)); - var engine = new CombustionEngine(container, data.EngineData, pt1Disabled: true); - var idleController = GetIdleController(data.PTO, engine); - - powertrain.AddComponent(engine, idleController) - .AddAuxiliaries(container, data); - - return container; - } - - private VehicleContainer BuildMeasuredSpeed(VectoRunData data) - { - if (data.Cycle.CycleType != CycleType.MeasuredSpeed) { - throw new VectoException("CycleType must be MeasuredSpeed."); - } - - var container = new VehicleContainer(ExecutionMode.Engineering, _modData, _sumWriter) { RunData = data }; - - // MeasuredSpeedDrivingCycle --> vehicle --> wheels --> brakes - // --> axleGear --> (retarder) --> GearBox --> (retarder) --> Clutch --> engine <-- Aux - var cycle = new MeasuredSpeedDrivingCycle(container, data.Cycle); - var powertrain = cycle - .AddComponent(new Vehicle(container, data.VehicleData)) - .AddComponent(new Wheels(container, data.VehicleData.DynamicTyreRadius, data.VehicleData.WheelsInertia)) - .AddComponent(new Brakes(container)) - .AddComponent(new AxleGear(container, data.AxleGearData)) - .AddComponent(data.AngledriveData != null ? new Angledrive(container, data.AngledriveData) : null) - .AddComponent(GetGearbox(container, data.GearboxData, data.EngineData.Inertia), data.Retarder, container); - if (data.GearboxData.Type.ManualTransmission()) { - powertrain = powertrain.AddComponent(new Clutch(container, data.EngineData)); - } - - var engine = new CombustionEngine(container, data.EngineData); - var idleController = GetIdleController(data.PTO, engine); - - powertrain.AddComponent(engine, idleController) - .AddAuxiliaries(container, data); - _modData.HasTorqueConverter = data.GearboxData.Type.AutomaticTransmission(); - - return container; - } - - private VehicleContainer BuildMeasuredSpeedGear(VectoRunData data) - { - if (data.Cycle.CycleType != CycleType.MeasuredSpeedGear) { - throw new VectoException("CycleType must be MeasuredSpeed with Gear."); - } - - var container = new VehicleContainer(ExecutionMode.Engineering, _modData, _sumWriter) { RunData = data }; - - // MeasuredSpeedDrivingCycle --> vehicle --> wheels --> brakes - // --> axleGear --> (retarder) --> CycleGearBox --> (retarder) --> CycleClutch --> engine <-- Aux - var powertrain = new MeasuredSpeedDrivingCycle(container, data.Cycle) - .AddComponent(new Vehicle(container, data.VehicleData)) - .AddComponent(new Wheels(container, data.VehicleData.DynamicTyreRadius, data.VehicleData.WheelsInertia)) - .AddComponent(new Brakes(container)) - .AddComponent(new AxleGear(container, data.AxleGearData)) - .AddComponent(data.AngledriveData != null ? new Angledrive(container, data.AngledriveData) : null) - .AddComponent(new CycleGearbox(container, data.GearboxData, data.EngineData.Inertia)); - if (data.GearboxData.Type.ManualTransmission()) { - powertrain = powertrain.AddComponent(new Clutch(container, data.EngineData)); - } - powertrain.AddComponent(new CombustionEngine(container, data.EngineData)) - .AddAuxiliaries(container, data); - - _modData.HasTorqueConverter = data.GearboxData.Type.AutomaticTransmission(); - - return container; - } - - private VehicleContainer BuildFullPowertrain(VectoRunData data) - { - if (data.Cycle.CycleType != CycleType.DistanceBased) { - throw new VectoException("CycleType must be DistanceBased"); - } - - var container = new VehicleContainer(data.ExecutionMode, _modData, _sumWriter) { RunData = data }; - - // DistanceBasedDrivingCycle --> driver --> vehicle --> wheels - // --> axleGear --> (retarder) --> gearBox --> (retarder) --> clutch --> engine <-- Aux - var cycle = new DistanceBasedDrivingCycle(container, data.Cycle); - var powertrain = cycle.AddComponent(new Driver(container, data.DriverData, new DefaultDriverStrategy())) - .AddComponent(new Vehicle(container, data.VehicleData)) - .AddComponent(new Wheels(container, data.VehicleData.DynamicTyreRadius, data.VehicleData.WheelsInertia)) - .AddComponent(new Brakes(container)) - .AddComponent(new AxleGear(container, data.AxleGearData)) - .AddComponent(data.AngledriveData != null ? new Angledrive(container, data.AngledriveData) : null) - .AddComponent(GetGearbox(container, data.GearboxData, data.EngineData.Inertia), data.Retarder, container); - if (data.GearboxData.Type.ManualTransmission()) { - powertrain = powertrain.AddComponent(new Clutch(container, data.EngineData)); - } - - var engine = new CombustionEngine(container, data.EngineData); - var idleController = GetIdleController(data.PTO, engine); - cycle.IdleController = idleController as IdleControllerSwitcher; - - powertrain.AddComponent(engine, idleController) - .AddAuxiliaries(container, data); - - _modData.HasTorqueConverter = data.GearboxData.Type.AutomaticTransmission(); - - return container; - } - - private static IIdleController GetIdleController(PTOData pto, ICombustionEngine engine) - { - var controller = engine.IdleController; - - if (pto != null) { - var ptoController = new PTOCycleController(pto.PTOCycle); - controller = new IdleControllerSwitcher(engine.IdleController, ptoController); - } - - return controller; - } - - internal static IAuxInProvider CreateAdvancedAuxiliaries(VectoRunData data, IVehicleContainer container) - { - var conventionalAux = CreateAuxiliaries(data, container); - var busAux = new BusAuxiliariesAdapter(container, data.AdvancedAux.AdvancedAuxiliaryFilePath, data.Cycle.Name, - data.VehicleData.TotalVehicleWeight(), data.EngineData.ConsumptionMap, data.EngineData.IdleSpeed, conventionalAux); - return busAux; - } - - internal static EngineAuxiliary CreateAuxiliaries(VectoRunData data, IVehicleContainer container) - { - var aux = new EngineAuxiliary(container); - foreach (var auxData in data.Aux) { - // id's in upper case - var id = auxData.ID.ToUpper(); - - switch (auxData.DemandType) { - case AuxiliaryDemandType.Constant: - aux.AddConstant(id, auxData.PowerDemand); - break; - case AuxiliaryDemandType.Direct: - aux.AddCycle(id); - break; - case AuxiliaryDemandType.Mapping: - aux.AddMapping(id, auxData.Data); - break; - default: - throw new ArgumentOutOfRangeException(); - } - container.ModalData.AddAuxiliary(id); - } - - if (data.PTO != null) { - aux.AddConstant(Constants.Auxiliaries.IDs.PTOTransmission, - DeclarationData.PTOTransmission.Lookup(data.PTO.TransmissionType)); - container.ModalData.AddAuxiliary(Constants.Auxiliaries.IDs.PTOTransmission, - Constants.Auxiliaries.PowerPrefix + Constants.Auxiliaries.IDs.PTOTransmission); - - aux.Add(Constants.Auxiliaries.IDs.PTOConsumer, - n => container.CycleData.LeftSample.PTOActive ? null : data.PTO.LossMap.GetTorqueLoss(n) * n); - container.ModalData.AddAuxiliary(Constants.Auxiliaries.IDs.PTOConsumer, - Constants.Auxiliaries.PowerPrefix + Constants.Auxiliaries.IDs.PTOConsumer); - } - - return aux; - } - - private static IGearbox GetGearbox(IVehicleContainer container, GearboxData data, KilogramSquareMeter engineInertia) - { - IShiftStrategy strategy; - switch (data.Type) { - case GearboxType.AMT: - strategy = new AMTShiftStrategy(data, container); - break; - case GearboxType.MT: - strategy = new MTShiftStrategy(data, container); - break; - case GearboxType.ATPowerSplit: - case GearboxType.ATSerial: - strategy = new ATShiftStrategy(data, container); - return new ATGearbox(container, data, strategy, engineInertia); - default: - throw new VectoSimulationException("Unknown Gearbox Type: {0}", data.Type); - } - return new Gearbox(container, data, strategy, engineInertia); - } - } + /// <summary> + /// Provides Methods to build a simulator with a powertrain step by step. + /// </summary> + public class PowertrainBuilder + { + private readonly IModalDataContainer _modData; + private readonly WriteSumData _sumWriter; + + public PowertrainBuilder(IModalDataContainer modData, WriteSumData sumWriter = null) + { + if (modData == null) { + throw new VectoException("Modal Data Container can't be null"); + } + _modData = modData; + _sumWriter = sumWriter; + } + + public VehicleContainer Build(VectoRunData data) + { + switch (data.Cycle.CycleType) { + case CycleType.EngineOnly: + return BuildEngineOnly(data); + case CycleType.PWheel: + return BuildPWheel(data); + case CycleType.MeasuredSpeed: + return BuildMeasuredSpeed(data); + case CycleType.MeasuredSpeedGear: + return BuildMeasuredSpeedGear(data); + case CycleType.DistanceBased: + return BuildFullPowertrain(data); + default: + throw new VectoException("Powertrain Builder cannot build Powertrain for CycleType: {0}", data.Cycle.CycleType); + } + } + + private VehicleContainer BuildEngineOnly(VectoRunData data) + { + if (data.Cycle.CycleType != CycleType.EngineOnly) { + throw new VectoException("CycleType must be EngineOnly."); + } + + var container = new VehicleContainer(ExecutionMode.Engineering, _modData, _sumWriter) { RunData = data }; + var cycle = new PowertrainDrivingCycle(container, data.Cycle); + + var directAux = new EngineAuxiliary(container); + directAux.AddCycle(Constants.Auxiliaries.Cycle); + container.ModalData.AddAuxiliary(Constants.Auxiliaries.Cycle); + var engine = new EngineOnlyCombustionEngine(container, data.EngineData); + engine.Connect(directAux.Port()); + + cycle.InPort().Connect(engine.OutPort()); + return container; + } + + private VehicleContainer BuildPWheel(VectoRunData data) + { + if (data.Cycle.CycleType != CycleType.PWheel) { + throw new VectoException("CycleType must be PWheel."); + } + + var container = new VehicleContainer(ExecutionMode.Engineering, _modData, _sumWriter) { RunData = data }; + var gearbox = new CycleGearbox(container, data.GearboxData, data.EngineData.Inertia); + + // PWheelCycle --> AxleGear --> CycleClutch --> Engine <-- Aux + var powertrain = new PWheelCycle(container, data.Cycle, data.AxleGearData.AxleGear.Ratio, data.VehicleData, + gearbox.ModelData.Gears.ToDictionary(g => g.Key, g => g.Value.Ratio)) + .AddComponent(new AxleGear(container, data.AxleGearData)) + .AddComponent(data.AngledriveData != null ? new Angledrive(container, data.AngledriveData) : null) + .AddComponent(gearbox, data.Retarder, container) + .AddComponent(new Clutch(container, data.EngineData)); + var engine = new CombustionEngine(container, data.EngineData, pt1Disabled: true); + var idleController = GetIdleController(data.PTO, engine); + + powertrain.AddComponent(engine, idleController) + .AddAuxiliaries(container, data); + + return container; + } + + private VehicleContainer BuildMeasuredSpeed(VectoRunData data) + { + if (data.Cycle.CycleType != CycleType.MeasuredSpeed) { + throw new VectoException("CycleType must be MeasuredSpeed."); + } + + var container = new VehicleContainer(ExecutionMode.Engineering, _modData, _sumWriter) { RunData = data }; + + // MeasuredSpeedDrivingCycle --> vehicle --> wheels --> brakes + // --> axleGear --> (retarder) --> GearBox --> (retarder) --> Clutch --> engine <-- Aux + var cycle = new MeasuredSpeedDrivingCycle(container, data.Cycle); + var powertrain = cycle + .AddComponent(new Vehicle(container, data.VehicleData)) + .AddComponent(new Wheels(container, data.VehicleData.DynamicTyreRadius, data.VehicleData.WheelsInertia)) + .AddComponent(new Brakes(container)) + .AddComponent(new AxleGear(container, data.AxleGearData)) + .AddComponent(data.AngledriveData != null ? new Angledrive(container, data.AngledriveData) : null) + .AddComponent(GetGearbox(container, data.GearboxData, data.EngineData.Inertia), data.Retarder, container); + if (data.GearboxData.Type.ManualTransmission()) { + powertrain = powertrain.AddComponent(new Clutch(container, data.EngineData)); + } + + var engine = new CombustionEngine(container, data.EngineData); + var idleController = GetIdleController(data.PTO, engine); + + powertrain.AddComponent(engine, idleController) + .AddAuxiliaries(container, data); + _modData.HasTorqueConverter = data.GearboxData.Type.AutomaticTransmission(); + + return container; + } + + private VehicleContainer BuildMeasuredSpeedGear(VectoRunData data) + { + if (data.Cycle.CycleType != CycleType.MeasuredSpeedGear) { + throw new VectoException("CycleType must be MeasuredSpeed with Gear."); + } + + var container = new VehicleContainer(ExecutionMode.Engineering, _modData, _sumWriter) { RunData = data }; + + // MeasuredSpeedDrivingCycle --> vehicle --> wheels --> brakes + // --> axleGear --> (retarder) --> CycleGearBox --> (retarder) --> CycleClutch --> engine <-- Aux + var powertrain = new MeasuredSpeedDrivingCycle(container, data.Cycle) + .AddComponent(new Vehicle(container, data.VehicleData)) + .AddComponent(new Wheels(container, data.VehicleData.DynamicTyreRadius, data.VehicleData.WheelsInertia)) + .AddComponent(new Brakes(container)) + .AddComponent(new AxleGear(container, data.AxleGearData)) + .AddComponent(data.AngledriveData != null ? new Angledrive(container, data.AngledriveData) : null) + .AddComponent(new CycleGearbox(container, data.GearboxData, data.EngineData.Inertia)); + if (data.GearboxData.Type.ManualTransmission()) { + powertrain = powertrain.AddComponent(new Clutch(container, data.EngineData)); + } + powertrain.AddComponent(new CombustionEngine(container, data.EngineData)) + .AddAuxiliaries(container, data); + + _modData.HasTorqueConverter = data.GearboxData.Type.AutomaticTransmission(); + + return container; + } + + private VehicleContainer BuildFullPowertrain(VectoRunData data) + { + if (data.Cycle.CycleType != CycleType.DistanceBased) { + throw new VectoException("CycleType must be DistanceBased"); + } + + var container = new VehicleContainer(data.ExecutionMode, _modData, _sumWriter) { RunData = data }; + + // DistanceBasedDrivingCycle --> driver --> vehicle --> wheels + // --> axleGear --> (retarder) --> gearBox --> (retarder) --> clutch --> engine <-- Aux + var cycle = new DistanceBasedDrivingCycle(container, data.Cycle); + var powertrain = cycle.AddComponent(new Driver(container, data.DriverData, new DefaultDriverStrategy())) + .AddComponent(new Vehicle(container, data.VehicleData)) + .AddComponent(new Wheels(container, data.VehicleData.DynamicTyreRadius, data.VehicleData.WheelsInertia)) + .AddComponent(new Brakes(container)) + .AddComponent(new AxleGear(container, data.AxleGearData)) + .AddComponent(data.AngledriveData != null ? new Angledrive(container, data.AngledriveData) : null) + .AddComponent(GetGearbox(container, data.GearboxData, data.EngineData.Inertia), data.Retarder, container); + if (data.GearboxData.Type.ManualTransmission()) { + powertrain = powertrain.AddComponent(new Clutch(container, data.EngineData)); + } + + var engine = new CombustionEngine(container, data.EngineData); + var idleController = GetIdleController(data.PTO, engine); + cycle.IdleController = idleController as IdleControllerSwitcher; + + powertrain.AddComponent(engine, idleController) + .AddAuxiliaries(container, data); + + _modData.HasTorqueConverter = data.GearboxData.Type.AutomaticTransmission(); + + return container; + } + + private static IIdleController GetIdleController(PTOData pto, ICombustionEngine engine) + { + var controller = engine.IdleController; + + if (pto != null) { + var ptoController = new PTOCycleController(pto.PTOCycle); + controller = new IdleControllerSwitcher(engine.IdleController, ptoController); + } + + return controller; + } + + internal static IAuxInProvider CreateAdvancedAuxiliaries(VectoRunData data, IVehicleContainer container) + { + var conventionalAux = CreateAuxiliaries(data, container); + var busAux = new BusAuxiliariesAdapter(container, data.AdvancedAux.AdvancedAuxiliaryFilePath, data.Cycle.Name, + data.VehicleData.TotalVehicleWeight, data.EngineData.ConsumptionMap, data.EngineData.IdleSpeed, conventionalAux); + return busAux; + } + + internal static EngineAuxiliary CreateAuxiliaries(VectoRunData data, IVehicleContainer container) + { + var aux = new EngineAuxiliary(container); + foreach (var auxData in data.Aux) { + // id's in upper case + var id = auxData.ID.ToUpper(); + + switch (auxData.DemandType) { + case AuxiliaryDemandType.Constant: + aux.AddConstant(id, auxData.PowerDemand); + break; + case AuxiliaryDemandType.Direct: + aux.AddCycle(id); + break; + case AuxiliaryDemandType.Mapping: + aux.AddMapping(id, auxData.Data); + break; + default: + throw new ArgumentOutOfRangeException(); + } + container.ModalData.AddAuxiliary(id); + } + + if (data.PTO != null) { + aux.AddConstant(Constants.Auxiliaries.IDs.PTOTransmission, + DeclarationData.PTOTransmission.Lookup(data.PTO.TransmissionType)); + container.ModalData.AddAuxiliary(Constants.Auxiliaries.IDs.PTOTransmission, + Constants.Auxiliaries.PowerPrefix + Constants.Auxiliaries.IDs.PTOTransmission); + + aux.Add(Constants.Auxiliaries.IDs.PTOConsumer, + n => container.CycleData.LeftSample.PTOActive ? null : data.PTO.LossMap.GetTorqueLoss(n) * n); + container.ModalData.AddAuxiliary(Constants.Auxiliaries.IDs.PTOConsumer, + Constants.Auxiliaries.PowerPrefix + Constants.Auxiliaries.IDs.PTOConsumer); + } + + return aux; + } + + private static IGearbox GetGearbox(IVehicleContainer container, GearboxData data, KilogramSquareMeter engineInertia) + { + IShiftStrategy strategy; + switch (data.Type) { + case GearboxType.AMT: + strategy = new AMTShiftStrategy(data, container); + break; + case GearboxType.MT: + strategy = new MTShiftStrategy(data, container); + break; + case GearboxType.ATPowerSplit: + case GearboxType.ATSerial: + strategy = new ATShiftStrategy(data, container); + return new ATGearbox(container, data, strategy, engineInertia); + default: + throw new VectoSimulationException("Unknown Gearbox Type: {0}", data.Type); + } + return new Gearbox(container, data, strategy, engineInertia); + } + } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/EngineFullLoadCurve.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/EngineFullLoadCurve.cs index 6b1d338d43717e87c29d5ca6ad9a620f1842b1da..a7155ba5a9b906e6255b6638f3ac8cae996170f8 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/EngineFullLoadCurve.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/EngineFullLoadCurve.cs @@ -180,6 +180,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine if (k.IsEqual(0, 0.0001)) { // constant torque: solve linear equation // power = M * n_eng_avg + if (d.IsEqual(0, 0.0001)) { + return new List<PerSecond>(); + } return (power / d).ToEnumerable(); } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs index c099332a7e774e99d42b7c7ba98eac1ce2d670b2..a6e1f7d7a107f806dda4eb2a22a9c1abc19b1975 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs @@ -126,24 +126,29 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data public CrossWindCorrectionMode CrossWindCorrectionMode { get; set; } - public Kilogram TotalVehicleWeight() + public Kilogram TotalVehicleWeight { - var retVal = 0.0; - if (CurbWeight != null) - retVal += CurbWeight.Value(); - if (Loading != null) - retVal += Loading.Value(); - return retVal.SI<Kilogram>(); + get + { + var retVal = 0.0; + if (CurbWeight != null) { + retVal += CurbWeight.Value(); + } + if (Loading != null) { + retVal += Loading.Value(); + } + return retVal.SI<Kilogram>(); + } } - public Kilogram TotalCurbWeight() + public Kilogram TotalCurbWeight { - return CurbWeight ?? 0.SI<Kilogram>(); + get { return CurbWeight ?? 0.SI<Kilogram>(); } } protected void ComputeRollResistanceAndReducedMassWheels() { - if (TotalVehicleWeight() == 0.SI<Kilogram>()) { + if (TotalVehicleWeight == 0.SI<Kilogram>()) { throw new VectoException("Total vehicle weight must be greater than 0! Set CurbWeight and Loading before!"); } if (DynamicTyreRadius == null) { @@ -159,7 +164,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data continue; } var nrWheels = axle.TwinTyres ? 4 : 2; - var baseValue = (axle.AxleWeightShare * TotalVehicleWeight() * g / axle.TyreTestLoad / nrWheels).Value(); + var baseValue = (axle.AxleWeightShare * TotalVehicleWeight * g / axle.TyreTestLoad / nrWheels).Value(); rrc += axle.AxleWeightShare * axle.RollResistanceCoefficient * Math.Pow(baseValue, Physics.RollResistanceExponent - 1); @@ -211,10 +216,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data // vehicleData.AxleConfiguration.GetName(), vehicleData.AxleConfiguration.NumAxles(), vehicleData.AxleData.Count)); //} - if (vehicleData.TotalVehicleWeight() > gvwTotal) { + if (vehicleData.TotalVehicleWeight > gvwTotal) { return new ValidationResult( string.Format("Total Vehicle Weight is greater than GrossVehicleWeight! Weight: {0}, GVW: {1}", - vehicleData.TotalVehicleWeight(), gvwTotal)); + vehicleData.TotalVehicleWeight, gvwTotal)); } return ValidationResult.Success; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AbstractGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AbstractGearbox.cs index 3c5065a01872a9d6a3d00ba78493219e6e4f26d5..1ce2598dc48a68c618a826ef39ab1801c35ea55f 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AbstractGearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AbstractGearbox.cs @@ -117,7 +117,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public abstract GearInfo NextGear { get; } - public Second TractionInterruption + public virtual Second TractionInterruption { get { return ModelData.TractionInterruption; } } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs index ccd4adf4377c2d5f135a4a6e4cb83112f5a59831..002aa023c7118408c97e1f56f92767cecf011535 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs @@ -444,7 +444,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var tStar = tStarPrev + PreviousState.dt; dynFullPowerCalculated = stationaryFullLoadPower * (1 - Math.Exp((-tStar / pt1).Value())); dynFullPowerCalculated = VectoMath.Max(PreviousState.EnginePower, dynFullPowerCalculated); - } catch (Exception ) { + } catch (Exception) { Log.Error("failed to calculate dynamic full-load power - using stationary idle full-load. n: {0}", angularVelocity); } } @@ -500,6 +500,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl private Second _idleStart; private Watt _lastEnginePower; + private PerSecond _engineTargetSpeed; public ITnOutPort RequestPort { private get; set; } @@ -539,11 +540,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (!outTorque.IsEqual(0)) { throw new VectoException("Torque has to be 0 for idle requests!"); } - var targetVelocity = _engine.PreviousState.EngineSpeed / _dataBus.GetGearData(_dataBus.Gear).Ratio * + if (_idleStart == null) { + _idleStart = absTime; + _engineTargetSpeed = _engine.PreviousState.EngineSpeed / _dataBus.GetGearData(_dataBus.Gear).Ratio * _dataBus.GetGearData(_dataBus.NextGear.Gear).Ratio; - var velocitySlope = (targetVelocity - _engine.PreviousState.EngineSpeed) / _dataBus.TractionInterruption; + } + + + var velocitySlope = (_engineTargetSpeed - _engine.PreviousState.EngineSpeed) / (_dataBus.TractionInterruption - (absTime - _idleStart)); - var nextAngularSpeed = (velocitySlope * dt + _engine.PreviousState.EngineSpeed); + var nextAngularSpeed = (velocitySlope * dt + _engine.PreviousState.EngineSpeed); if (nextAngularSpeed < _engine.ModelData.IdleSpeed) { nextAngularSpeed = _engine.ModelData.IdleSpeed; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs index 8f469964323b96c0681fd175692b364f6be85a68..fa2ee45207fced4419840963378a1d85a657362f 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs @@ -48,6 +48,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { public class CycleGearbox : AbstractGearbox<CycleGearbox.CycleGearboxState> { + /// <summary> + /// True if gearbox is disengaged (no gear is set). + /// </summary> + protected internal Second Disengaged = null; + protected bool? TorqueConverterActive; protected internal readonly TorqueConverter TorqueConverter; @@ -130,9 +135,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl bool dryRun = false) { Log.Debug("Gearbox Power Request: torque: {0}, angularVelocity: {1}", outTorque, outAngularVelocity); - Gear = DataBus.DriverBehavior == DrivingBehavior.Braking - ? DataBus.CycleData.LeftSample.Gear - : DataBus.CycleData.RightSample.Gear; + var gear = GetGearFromCycle(); TorqueConverterActive = DataBus.DriverBehavior == DrivingBehavior.Braking ? DataBus.CycleData.LeftSample.TorqueConverterActive @@ -141,13 +144,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (TorqueConverter != null && TorqueConverterActive == null) { throw new VectoSimulationException("Driving cycle does not contain information about TorqueConverter!"); } - if (Gear != 0 && !ModelData.Gears.ContainsKey(Gear)) { - throw new VectoSimulationException("Requested Gear {0} from driving cycle is not available", Gear); + if (gear != 0 && !ModelData.Gears.ContainsKey(gear)) { + throw new VectoSimulationException("Requested Gear {0} from driving cycle is not available", gear); } // mk 2016-11-30: added additional check for outAngularVelocity due to failing test: MeasuredSpeed_Gear_AT_PS_Run // mq 2016-12-16: changed check to vehicle halted due to failing test: MeasuredSpeed_Gear_AT_* - var retVal = Gear == 0 || DataBus.DriverBehavior == DrivingBehavior.Halted + var retVal = gear == 0 || DataBus.DriverBehavior == DrivingBehavior.Halted //|| (outAngularVelocity.IsSmallerOrEqual(0, 1) && outTorque.IsSmallerOrEqual(0, 1)) ? RequestDisengaged(absTime, dt, outTorque, outAngularVelocity, dryRun) : RequestEngaged(absTime, dt, outTorque, outAngularVelocity, dryRun); @@ -156,6 +159,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return retVal; } + private uint GetGearFromCycle() + { + return DataBus.DriverBehavior == DrivingBehavior.Braking + ? DataBus.CycleData.LeftSample.Gear + : DataBus.CycleData.RightSample.Gear; + } + /// <summary> /// Handles requests when a gear is engaged /// </summary> @@ -168,6 +178,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl private IResponse RequestEngaged(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, bool dryRun) { + Disengaged = null; + + Gear = GetGearFromCycle(); + var torqueConverterLocked = TorqueConverterActive == null || !TorqueConverterActive.Value; var effectiveRatio = ModelData.Gears[Gear].Ratio; @@ -270,6 +284,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl private IResponse RequestDisengaged(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, bool dryRun) { + if (Disengaged == null) { + Disengaged = absTime; + } + var avgOutAngularVelocity = (PreviousState.OutAngularVelocity + outAngularVelocity) / 2.0; if (dryRun) { // if gearbox is disengaged the 0-line is the limit for drag and full load @@ -298,41 +316,70 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl }; } - CurrentState.SetState(0.SI<NewtonMeter>(), 0.SI<PerSecond>(), 0.SI<NewtonMeter>(), outAngularVelocity); - CurrentState.Gear = Gear; - - var motoringSpeed = DataBus.EngineIdleSpeed; - var disengagedResponse = NextComponent.Request(absTime, dt, 0.SI<NewtonMeter>(), DataBus.EngineIdleSpeed); - if (!(disengagedResponse is ResponseSuccess)) { - motoringSpeed = DataBus.EngineSpeed; - if (motoringSpeed.IsGreater(DataBus.EngineIdleSpeed)) { - var first = (ResponseDryRun)NextComponent.Request(absTime, dt, 0.SI<NewtonMeter>(), motoringSpeed, true); - try { - motoringSpeed = SearchAlgorithm.Search(motoringSpeed, first.DeltaDragLoad, - Constants.SimulationSettings.EngineIdlingSearchInterval, - getYValue: result => ((ResponseDryRun)result).DeltaDragLoad, - evaluateFunction: n => NextComponent.Request(absTime, dt, 0.SI<NewtonMeter>(), n, true), - criterion: result => ((ResponseDryRun)result).DeltaDragLoad.Value()); - } catch (VectoException) { - Log.Warn("CycleGearbox could not find motoring speed for disengaged state."); - } - motoringSpeed = motoringSpeed.LimitTo(DataBus.EngineIdleSpeed, DataBus.EngineSpeed); - } - - disengagedResponse = NextComponent.Request(absTime, dt, 0.SI<NewtonMeter>(), motoringSpeed); + //var motoringSpeed = DataBus.EngineIdleSpeed; + //var disengagedResponse = NextComponent.Request(absTime, dt, 0.SI<NewtonMeter>(), DataBus.EngineIdleSpeed); + //if (!(disengagedResponse is ResponseSuccess)) { + // motoringSpeed = DataBus.EngineSpeed; + // if (motoringSpeed.IsGreater(DataBus.EngineIdleSpeed)) { + // var first = (ResponseDryRun)NextComponent.Request(absTime, dt, 0.SI<NewtonMeter>(), motoringSpeed, true); + // try { + // motoringSpeed = SearchAlgorithm.Search(motoringSpeed, first.DeltaDragLoad, + // Constants.SimulationSettings.EngineIdlingSearchInterval, + // getYValue: result => ((ResponseDryRun)result).DeltaDragLoad, + // evaluateFunction: n => NextComponent.Request(absTime, dt, 0.SI<NewtonMeter>(), n, true), + // criterion: result => ((ResponseDryRun)result).DeltaDragLoad.Value()); + // } catch (VectoException) { + // Log.Warn("CycleGearbox could not find motoring speed for disengaged state."); + // } + // motoringSpeed = motoringSpeed.LimitTo(DataBus.EngineIdleSpeed, DataBus.EngineSpeed); + // } + // disengagedResponse = NextComponent.Request(absTime, dt, 0.SI<NewtonMeter>(), motoringSpeed); + //} + IResponse disengagedResponse; + if (GearboxType.AutomaticTransmission()) { + disengagedResponse = EngineIdleRequest(absTime, dt); + } else { + disengagedResponse = NextComponent.Request(absTime, dt, 0.SI<NewtonMeter>(), null); } if (TorqueConverter != null) { - TorqueConverter.Locked(CurrentState.InTorque, motoringSpeed); + TorqueConverter.Locked(CurrentState.InTorque, disengagedResponse.EngineSpeed); } disengagedResponse.GearboxPowerRequest = outTorque * avgOutAngularVelocity; + CurrentState.SetState(0.SI<NewtonMeter>(), disengagedResponse.EngineSpeed, 0.SI<NewtonMeter>(), outAngularVelocity); + CurrentState.Gear = Gear; + + return disengagedResponse; + } + + private IResponse EngineIdleRequest(Second absTime, Second dt) + { + var disengagedResponse = NextComponent.Request(absTime, dt, 0.SI<NewtonMeter>(), DataBus.EngineIdleSpeed); + if (disengagedResponse is ResponseSuccess) { + return disengagedResponse; + } + var motoringSpeed = DataBus.EngineSpeed; + if (motoringSpeed.IsGreater(DataBus.EngineIdleSpeed)) { + var first = (ResponseDryRun)NextComponent.Request(absTime, dt, 0.SI<NewtonMeter>(), motoringSpeed, true); + try { + motoringSpeed = SearchAlgorithm.Search(motoringSpeed, first.DeltaDragLoad, + Constants.SimulationSettings.EngineIdlingSearchInterval, + getYValue: result => ((ResponseDryRun)result).DeltaDragLoad, + evaluateFunction: n => NextComponent.Request(absTime, dt, 0.SI<NewtonMeter>(), n, true), + criterion: result => ((ResponseDryRun)result).DeltaDragLoad.Value()); + } catch (VectoException) { + Log.Warn("CycleGearbox could not find motoring speed for disengaged state."); + } + motoringSpeed = motoringSpeed.LimitTo(DataBus.EngineIdleSpeed, DataBus.EngineSpeed); + } + disengagedResponse = NextComponent.Request(absTime, dt, 0.SI<NewtonMeter>(), motoringSpeed); return disengagedResponse; } protected override void DoWriteModalResults(IModalDataContainer container) { var avgInAngularSpeed = (PreviousState.InAngularVelocity + CurrentState.InAngularVelocity) / 2.0; - container[ModalResultField.Gear] = Gear; + container[ModalResultField.Gear] = Disengaged != null ? 0 : Gear; container[ModalResultField.P_gbx_loss] = CurrentState.TransmissionTorqueLoss * avgInAngularSpeed; container[ModalResultField.P_gbx_inertia] = CurrentState.InertiaTorqueLossOut * avgInAngularSpeed; container[ModalResultField.P_gbx_in] = CurrentState.InTorque * avgInAngularSpeed; @@ -372,7 +419,55 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { get { - return new GearInfo(DataBus.CycleData.RightSample.Gear, !DataBus.CycleData.RightSample.TorqueConverterActive ?? true); + if (Disengaged == null) { + return new GearInfo(Gear, !TorqueConverterActive ?? true); + } + var future = DataBus.LookAhead(ModelData.TractionInterruption * 5); + var nextGear = 0u; + var torqueConverterLocked = true; + foreach (var entry in future) { + if (entry.VehicleTargetSpeed != null && entry.VehicleTargetSpeed.IsEqual(0)) { + // vehicle is stopped, no next gear, engine should go to idle + break; + } + if (entry.WheelAngularVelocity != null && entry.WheelAngularVelocity.IsEqual(0)) { + // vehicle is stopped, no next gear, engine should go to idle + break; + } + if (entry.Gear == 0) { + continue; + } + nextGear = entry.Gear; + torqueConverterLocked = !entry.TorqueConverterActive ?? false; + break; + } + return new GearInfo(nextGear, torqueConverterLocked); + } + } + + public override Second TractionInterruption + { + get + { + if (Disengaged == null) { + return ModelData.TractionInterruption; + } + var future = DataBus.LookAhead(ModelData.TractionInterruption * 5); + foreach (var entry in future) { + if (entry.VehicleTargetSpeed != null && entry.VehicleTargetSpeed.IsEqual(0)) { + // vehicle is stopped, no next gear, engine should go to idle + break; + } + if (entry.WheelAngularVelocity != null && entry.WheelAngularVelocity.IsEqual(0)) { + // vehicle is stopped, no next gear, engine should go to idle + break; + } + if (entry.Gear == 0) { + continue; + } + return entry.Time - Disengaged; + } + return ModelData.TractionInterruption; } } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs index 9b04cfa5a974e19cac13a16e0ecea31c22266147..a2430f10218721d7b4fc8fe7504686662b1dd417 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs @@ -484,76 +484,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl CycleStartDistance = startDistance; } - public sealed class DrivingCycleEnumerator : IEnumerator<DrivingCycleData.DrivingCycleEntry> - { - private int _currentCycleIndex; - private readonly IDrivingCycleData _data; - - public DrivingCycleEnumerator(IDrivingCycleData data) - { - _currentCycleIndex = 0; - _data = data; - LastEntry = false; - } - - public DrivingCycleEnumerator Clone() - { - return new DrivingCycleEnumerator(_data) { - _currentCycleIndex = _currentCycleIndex, - LastEntry = LastEntry - }; - } - - public DrivingCycleData.DrivingCycleEntry Current - { - get { return LeftSample; } - } - - public DrivingCycleData.DrivingCycleEntry Next - { - get { return RightSample; } - } - - public DrivingCycleData.DrivingCycleEntry LeftSample - { - get { return _data.Entries[_currentCycleIndex]; } - } - - public DrivingCycleData.DrivingCycleEntry RightSample - { - get { return _currentCycleIndex + 1 >= _data.Entries.Count ? null : _data.Entries[_currentCycleIndex + 1]; } - } - - public bool LastEntry { get; private set; } - - object System.Collections.IEnumerator.Current - { - get { return LeftSample; } - } - - public bool MoveNext() - { - // cycleIndex has to be max. next to last (so that rightSample is still valid. - if (_currentCycleIndex >= _data.Entries.Count - 2) { - LastEntry = true; - return false; - } - _currentCycleIndex++; - if (_currentCycleIndex == _data.Entries.Count - 2) { - LastEntry = true; - } - - return true; - } - - public void Reset() - { - _currentCycleIndex = 0; - } - - public void Dispose() {} - } - public sealed class DrivingCycleState { public DrivingCycleState Clone() diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DrivingCycleEnumerator.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DrivingCycleEnumerator.cs new file mode 100644 index 0000000000000000000000000000000000000000..22720e2a0ccee0996cf8891f2f6d24fa66b4bf2a --- /dev/null +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DrivingCycleEnumerator.cs @@ -0,0 +1,75 @@ +using System.Collections.Generic; +using TUGraz.VectoCore.Models.SimulationComponent.Data; + +namespace TUGraz.VectoCore.Models.SimulationComponent.Impl +{ + public sealed class DrivingCycleEnumerator : IEnumerator<DrivingCycleData.DrivingCycleEntry> + { + private int _currentCycleIndex; + private readonly IDrivingCycleData _data; + + public DrivingCycleEnumerator(IDrivingCycleData data) + { + _currentCycleIndex = 0; + _data = data; + LastEntry = false; + } + + public DrivingCycleEnumerator Clone() + { + return new DrivingCycleEnumerator(_data) { + _currentCycleIndex = _currentCycleIndex, + LastEntry = LastEntry + }; + } + + public DrivingCycleData.DrivingCycleEntry Current + { + get { return LeftSample; } + } + + public DrivingCycleData.DrivingCycleEntry Next + { + get { return RightSample; } + } + + public DrivingCycleData.DrivingCycleEntry LeftSample + { + get { return _data.Entries[_currentCycleIndex]; } + } + + public DrivingCycleData.DrivingCycleEntry RightSample + { + get { return _currentCycleIndex + 1 >= _data.Entries.Count ? null : _data.Entries[_currentCycleIndex + 1]; } + } + + public bool LastEntry { get; private set; } + + object System.Collections.IEnumerator.Current + { + get { return LeftSample; } + } + + public bool MoveNext() + { + // cycleIndex has to be max. next to last (so that rightSample is still valid. + if (_currentCycleIndex >= _data.Entries.Count - 2) { + LastEntry = true; + return false; + } + _currentCycleIndex++; + if (_currentCycleIndex == _data.Entries.Count - 2) { + LastEntry = true; + } + + return true; + } + + public void Reset() + { + _currentCycleIndex = 0; + } + + public void Dispose() {} + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/MeasuredSpeedDrivingCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/MeasuredSpeedDrivingCycle.cs index 8b3b5726a89af2c39fbfd202a47396967482b790..4ffcc1feb118ba8dfcd395da3714570fb8c00ddf 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/MeasuredSpeedDrivingCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/MeasuredSpeedDrivingCycle.cs @@ -72,8 +72,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected readonly IDrivingCycleData Data; private bool _isInitializing; - protected IEnumerator<DrivingCycleData.DrivingCycleEntry> RightSample { get; set; } - protected IEnumerator<DrivingCycleData.DrivingCycleEntry> LeftSample { get; set; } + protected internal readonly DrivingCycleEnumerator CycleIterator; protected Second AbsTime { get; set; } @@ -86,12 +85,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl : base(container) { Data = cycle; - LeftSample = Data.Entries.GetEnumerator(); - LeftSample.MoveNext(); - - RightSample = Data.Entries.GetEnumerator(); - RightSample.MoveNext(); - RightSample.MoveNext(); + CycleIterator = new DrivingCycleEnumerator(cycle); PreviousState = new DrivingCycleState { Distance = 0.SI<Meter>(), @@ -129,22 +123,22 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var debug = new DebugData(); // cycle finished - if (RightSample.Current == null || LeftSample.Current == null) { + if (CycleIterator.LastEntry && absTime >= CycleIterator.RightSample.Time) { return new ResponseCycleFinished { AbsTime = absTime, Source = this }; } // interval exceeded - if (RightSample.Current != null && (absTime + dt).IsGreater(RightSample.Current.Time)) { + if (CycleIterator.RightSample != null && (absTime + dt).IsGreater(CycleIterator.RightSample.Time)) { return new ResponseFailTimeInterval { AbsTime = absTime, Source = this, - DeltaT = RightSample.Current.Time - absTime + DeltaT = CycleIterator.RightSample.Time - absTime }; } // calc acceleration from speed diff vehicle to cycle - var deltaV = RightSample.Current.VehicleTargetSpeed - DataBus.VehicleSpeed; - var deltaT = RightSample.Current.Time - LeftSample.Current.Time; + var deltaV = CycleIterator.RightSample.VehicleTargetSpeed - DataBus.VehicleSpeed; + var deltaT = CycleIterator.RightSample.Time - CycleIterator.LeftSample.Time; if (DataBus.VehicleSpeed.IsSmaller(0)) { throw new VectoSimulationException("vehicle velocity is smaller than zero"); @@ -155,7 +149,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } var acceleration = deltaV / deltaT; - var gradient = LeftSample.Current.RoadGradient; + var gradient = CycleIterator.LeftSample.RoadGradient; DriverAcceleration = acceleration; DriverBehavior = acceleration < 0 ? DriverBehavior = DrivingBehavior.Braking @@ -242,21 +236,18 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { container[ModalResultField.dist] = CurrentState.Distance; container[ModalResultField.simulationDistance] = CurrentState.SimulationDistance; - container[ModalResultField.v_targ] = LeftSample.Current.VehicleTargetSpeed; - container[ModalResultField.grad] = LeftSample.Current.RoadGradientPercent; - container[ModalResultField.altitude] = LeftSample.Current.Altitude; + container[ModalResultField.v_targ] = CycleIterator.LeftSample.VehicleTargetSpeed; + container[ModalResultField.grad] = CycleIterator.LeftSample.RoadGradientPercent; + container[ModalResultField.altitude] = CycleIterator.LeftSample.Altitude; container[ModalResultField.acc] = CurrentState.Acceleration; } protected override void DoCommitSimulationStep() { - if ((RightSample.Current == null) || AbsTime.IsGreaterOrEqual(RightSample.Current.Time)) { - RightSample.MoveNext(); - LeftSample.MoveNext(); + if ((CycleIterator.RightSample == null) || AbsTime.IsGreaterOrEqual(CycleIterator.RightSample.Time)) { + CycleIterator.MoveNext(); } - - PreviousState = CurrentState; - CurrentState = CurrentState.Clone(); + AdvanceState(); } public string CycleName @@ -274,23 +265,23 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl get { return new CycleData { - AbsTime = LeftSample.Current.Time, + AbsTime = CycleIterator.LeftSample.Time, AbsDistance = null, - LeftSample = LeftSample.Current, - RightSample = RightSample.Current, + LeftSample = CycleIterator.LeftSample, + RightSample = CycleIterator.RightSample, }; } } public DrivingCycleData.DrivingCycleEntry CycleLookAhead(Meter distance) { - return new DrivingCycleData.DrivingCycleEntry(RightSample.Current); + return new DrivingCycleData.DrivingCycleEntry(CycleIterator.RightSample); //throw new System.NotImplementedException(); } public Meter Altitude { - get { return LeftSample.Current.Altitude; } + get { return CycleIterator.LeftSample.Altitude; } } public Meter CycleStartDistance @@ -305,7 +296,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public IReadOnlyList<DrivingCycleData.DrivingCycleEntry> LookAhead(Second time) { - throw new NotImplementedException(); + var retVal = new List<DrivingCycleData.DrivingCycleEntry>(); + + var iterator = CycleIterator.Clone(); + do { + retVal.Add(iterator.RightSample); + } while (iterator.MoveNext() && iterator.RightSample.Time < AbsTime + time); + + return retVal; } public void FinishSimulation() @@ -315,7 +313,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public bool VehicleStopped { - get { return !_isInitializing && LeftSample.Current.VehicleTargetSpeed.IsEqual(0); } + get { return !_isInitializing && CycleIterator.LeftSample.VehicleTargetSpeed.IsEqual(0); } } public DrivingBehavior DriverBehavior { get; internal set; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PTOCycleController.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PTOCycleController.cs index e2708ce6fb46378df0fed771130faebaac42744b..5ae1b9637b2f333929bd086c3a0252047016dee9 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PTOCycleController.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PTOCycleController.cs @@ -81,22 +81,18 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public void Reset() { - LeftSample.Reset(); - LeftSample.MoveNext(); - - RightSample.Reset(); - RightSample.MoveNext(); - RightSample.MoveNext(); + CycleIterator.Reset(); IdleStart = null; } public Second GetNextCycleTime() { - if (RightSample.Current == null) + if (CycleIterator.RightSample == null) { return null; + } - return RightSample.Current.Time - LeftSample.Current.Time; + return CycleIterator.RightSample.Time - CycleIterator.LeftSample.Time; } protected override void DoWriteModalResults(IModalDataContainer container) diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PWheelCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PWheelCycle.cs index 1e81e876ab0d76371bdb613e4f50082f2a9af930..6805445e1450981a94786f8cd1256dfe63cd743e 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PWheelCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PWheelCycle.cs @@ -44,21 +44,24 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// <summary> /// Driving Cycle for the PWheel driving cycle. /// </summary> - public class PWheelCycle : PowertrainDrivingCycle, IDriverInfo + public class PWheelCycle : PowertrainDrivingCycle, IDriverInfo, IVehicleInfo { + private VehicleData _vehicleData; + /// <summary> /// Initializes a new instance of the <see cref="PWheelCycle"/> class. /// </summary> /// <param name="container">The container.</param> /// <param name="cycle">The cycle.</param> /// <param name="axleRatio">The axle ratio.</param> + /// <param name="vehicleData"></param> /// <param name="gearRatios"></param> - public PWheelCycle(IVehicleContainer container, IDrivingCycleData cycle, double axleRatio, + public PWheelCycle(IVehicleContainer container, IDrivingCycleData cycle, double axleRatio, VehicleData vehicleData, IDictionary<uint, double> gearRatios) : base(container, cycle) { // just to ensure that null-gear has ratio 1 gearRatios[0] = 1; - + _vehicleData = vehicleData; foreach (var entry in Data.Entries) { entry.WheelAngularVelocity = entry.AngularVelocity / (axleRatio * gearRatios[entry.Gear]); entry.Torque = entry.PWheel / entry.WheelAngularVelocity; @@ -76,36 +79,68 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public override IResponse Request(Second absTime, Second dt) { - if (RightSample.Current == null) { + if (CycleIterator.LastEntry && CycleIterator.RightSample.Time == absTime) { return new ResponseCycleFinished { Source = this }; } // interval exceeded - if ((absTime + dt).IsGreater(RightSample.Current.Time)) { + if (CycleIterator.RightSample != null && (absTime + dt).IsGreater(CycleIterator.RightSample.Time)) { return new ResponseFailTimeInterval { AbsTime = absTime, Source = this, - DeltaT = RightSample.Current.Time - absTime + DeltaT = CycleIterator.RightSample.Time - absTime }; } - return DoHandleRequest(absTime, dt, LeftSample.Current.WheelAngularVelocity); + return DoHandleRequest(absTime, dt, CycleIterator.LeftSample.WheelAngularVelocity); } protected override void DoWriteModalResults(IModalDataContainer container) { - container[ModalResultField.P_wheel_in] = LeftSample.Current.PWheel; + container[ModalResultField.P_wheel_in] = CycleIterator.LeftSample.PWheel; base.DoWriteModalResults(container); } #region IDriverInfo + public MeterPerSecond VehicleSpeed { get; private set; } + /// <summary> /// True if the angularVelocity at the wheels is 0. /// </summary> public bool VehicleStopped { - get { return false; } + get { return CycleIterator.LeftSample.WheelAngularVelocity.IsEqual(0); } + } + + public Kilogram VehicleMass + { + get { return _vehicleData.TotalCurbWeight; } + } + + public Kilogram VehicleLoading + { + get { return _vehicleData.Loading; } + } + + public Kilogram TotalMass + { + get { return _vehicleData.TotalVehicleWeight; } + } + + public Newton AirDragResistance(MeterPerSecond previousVelocity, MeterPerSecond nextVelocity) + { + throw new System.NotImplementedException(); + } + + public Newton RollingResistance(Radian gradient) + { + throw new System.NotImplementedException(); + } + + public Newton SlopeResistance(Radian gradient) + { + throw new System.NotImplementedException(); } /// <summary> diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs index 7b0cc4c5a2d7d96259c1f73c03070f4243703c6b..62e0102d0b4c53b8221374c4b245884e59f078c0 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs @@ -52,8 +52,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl IDrivingCycleInfo, ISimulationOutPort, ITnInProvider, ITnInPort { protected readonly IDrivingCycleData Data; - protected IEnumerator<DrivingCycleData.DrivingCycleEntry> RightSample { get; set; } - protected IEnumerator<DrivingCycleData.DrivingCycleEntry> LeftSample { get; set; } + protected internal readonly DrivingCycleEnumerator CycleIterator; protected Second AbsTime { get; set; } @@ -65,12 +64,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public PowertrainDrivingCycle(IVehicleContainer container, IDrivingCycleData cycle) : base(container) { Data = cycle; - LeftSample = Data.Entries.GetEnumerator(); - LeftSample.MoveNext(); - - RightSample = Data.Entries.GetEnumerator(); - RightSample.MoveNext(); - RightSample.MoveNext(); + CycleIterator = new DrivingCycleEnumerator(Data); AbsTime = 0.SI<Second>(); } @@ -94,20 +88,20 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public virtual IResponse Request(Second absTime, Second dt) { // cycle finished (no more entries in cycle) - if (LeftSample.Current == null) { + if (CycleIterator.LastEntry && CycleIterator.RightSample.Time == absTime) { return new ResponseCycleFinished { Source = this }; } // interval exceeded - if (RightSample.Current != null && (absTime + dt).IsGreater(RightSample.Current.Time)) { + if (CycleIterator.RightSample != null && (absTime + dt).IsGreater(CycleIterator.RightSample.Time)) { return new ResponseFailTimeInterval { AbsTime = absTime, Source = this, - DeltaT = RightSample.Current.Time - absTime + DeltaT = CycleIterator.RightSample.Time - absTime }; } - return DoHandleRequest(absTime, dt, LeftSample.Current.AngularVelocity); + return DoHandleRequest(absTime, dt, CycleIterator.LeftSample.AngularVelocity); } protected IResponse DoHandleRequest(Second absTime, Second dt, PerSecond angularVelocity) @@ -117,16 +111,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl IResponse response; var responseCount = 0; do { - response = NextComponent.Request(absTime, dt, LeftSample.Current.Torque, angularVelocity); + response = NextComponent.Request(absTime, dt, CycleIterator.LeftSample.Torque, angularVelocity); CurrentState.InAngularVelocity = angularVelocity; - CurrentState.InTorque = LeftSample.Current.Torque; + CurrentState.InTorque = CycleIterator.LeftSample.Torque; debug.Add(response); response.Switch() .Case<ResponseGearShift>( - () => response = NextComponent.Request(absTime, dt, LeftSample.Current.Torque, angularVelocity)) + () => response = NextComponent.Request(absTime, dt, CycleIterator.LeftSample.Torque, angularVelocity)) .Case<ResponseUnderload>(r => { var torqueInterval = -r.Delta / (angularVelocity.IsEqual(0) ? 10.RPMtoRad() : angularVelocity); - var torque = SearchAlgorithm.Search(LeftSample.Current.Torque, r.Delta, torqueInterval, + var torque = SearchAlgorithm.Search(CycleIterator.LeftSample.Torque, r.Delta, torqueInterval, getYValue: result => ((ResponseDryRun)result).DeltaDragLoad, evaluateFunction: t => NextComponent.Request(absTime, dt, t, angularVelocity, true), criterion: y => ((ResponseDryRun)y).DeltaDragLoad.Value()); @@ -136,9 +130,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl .Case<ResponseOverload>(r => { angularVelocity = SearchAlgorithm.Search(angularVelocity, r.Delta, 50.RPMtoRad(), getYValue: result => ((ResponseDryRun)result).DeltaFullLoad, - evaluateFunction: n => NextComponent.Request(absTime, dt, LeftSample.Current.Torque, n, true), + evaluateFunction: n => NextComponent.Request(absTime, dt, CycleIterator.LeftSample.Torque, n, true), criterion: y => ((ResponseDryRun)y).DeltaFullLoad.Value()); - response = NextComponent.Request(absTime, dt, LeftSample.Current.Torque, angularVelocity); + response = NextComponent.Request(absTime, dt, CycleIterator.LeftSample.Torque, angularVelocity); CurrentState.InAngularVelocity = angularVelocity; }) .Case<ResponseFailTimeInterval>(r => { dt = r.DeltaT; }) @@ -171,10 +165,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected override void DoCommitSimulationStep() { - if ((RightSample.Current == null) || AbsTime.IsGreaterOrEqual(RightSample.Current.Time)) { - RightSample.MoveNext(); - LeftSample.MoveNext(); - } + CycleIterator.MoveNext(); } #endregion @@ -184,10 +175,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl get { return new CycleData { - AbsTime = LeftSample.Current.Time, + AbsTime = CycleIterator.LeftSample.Time, AbsDistance = null, - LeftSample = LeftSample.Current, - RightSample = RightSample.Current, + LeftSample = CycleIterator.LeftSample, + RightSample = CycleIterator.RightSample, }; } } @@ -216,7 +207,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public IReadOnlyList<DrivingCycleData.DrivingCycleEntry> LookAhead(Second time) { - throw new NotImplementedException(); + var retVal = new List<DrivingCycleData.DrivingCycleEntry>(); + + var iterator = CycleIterator.Clone(); + do { + retVal.Add(iterator.RightSample); + } while (iterator.MoveNext() && iterator.RightSample.Time < AbsTime + time); + + return retVal; } public void FinishSimulation() diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs index f5abf10e10be1be0698e6672eeef4f97ed0438d4..eacb4b4a185154d2c3e8f2fb030abc73cb1e032b 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs @@ -142,7 +142,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public Newton RollingResistance(Radian gradient) { - var weight = ModelData.TotalVehicleWeight(); + var weight = ModelData.TotalVehicleWeight; var gravity = Physics.GravityAccelleration; var rollCoefficient = ModelData.TotalRollResistanceCoefficient; @@ -153,14 +153,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected internal Newton DriverAcceleration(MeterPerSquareSecond accelleration) { - var retVal = ModelData.TotalVehicleWeight() * accelleration; + var retVal = ModelData.TotalVehicleWeight * accelleration; Log.Debug("DriverAcceleration: {0}", retVal); return retVal; } public Newton SlopeResistance(Radian gradient) { - var retVal = ModelData.TotalVehicleWeight() * Physics.GravityAccelleration * Math.Sin(gradient.Value()); + var retVal = ModelData.TotalVehicleWeight * Physics.GravityAccelleration * Math.Sin(gradient.Value()); Log.Debug("SlopeResistance: {0}", retVal); return retVal; } @@ -199,7 +199,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public Kilogram VehicleMass { - get { return ModelData.TotalCurbWeight(); } + get { return ModelData.TotalCurbWeight; } } public Kilogram VehicleLoading @@ -209,7 +209,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public Kilogram TotalMass { - get { return ModelData.TotalVehicleWeight(); } + get { return ModelData.TotalVehicleWeight; } } public class VehicleState diff --git a/VectoCore/VectoCore/VectoCore.csproj b/VectoCore/VectoCore/VectoCore.csproj index 0f2e04640fc27c687a8bf4433a2c17eb3b6e9d76..a84ec69b247ee04968fb9da7d9591d65e2af5850 100644 --- a/VectoCore/VectoCore/VectoCore.csproj +++ b/VectoCore/VectoCore/VectoCore.csproj @@ -152,6 +152,7 @@ <Compile Include="Models\SimulationComponent\Impl\AbstractGearbox.cs" /> <Compile Include="Models\SimulationComponent\Impl\ATGearbox.cs" /> <Compile Include="Models\SimulationComponent\Impl\ATShiftStrategy.cs" /> + <Compile Include="Models\SimulationComponent\Impl\DrivingCycleEnumerator.cs" /> <Compile Include="Models\SimulationComponent\Impl\MeasuredSpeedDrivingCycle.cs" /> <Compile Include="Models\SimulationComponent\Impl\PTOCycleController.cs" /> <Compile Include="Models\SimulationComponent\Impl\PWheelCycle.cs" /> diff --git a/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs b/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs index f797490a05be21dfd9ae0c0b4d565e4f93cde4ee..8d6587d16dac4abaf6aa8b6f6b32e741fedc77c6 100644 --- a/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs +++ b/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs @@ -99,7 +99,7 @@ namespace TUGraz.VectoCore.Tests.Integration .AddComponent(engine); var aux = new BusAuxiliariesAdapter(container, AdvancedAuxFile, "Coach", - vehicleData.TotalVehicleWeight(), engineData.ConsumptionMap, engineData.IdleSpeed); + vehicleData.TotalVehicleWeight, engineData.ConsumptionMap, engineData.IdleSpeed); engine.Connect(aux.Port()); diff --git a/VectoCore/VectoCoreTest/Models/Simulation/MeasuredSpeedModeTest.cs b/VectoCore/VectoCoreTest/Models/Simulation/MeasuredSpeedModeTest.cs index d167d84b2a75fd222332508300992d14399a0cf7..56092394692d0a9b10accb4658720db7526d0d02 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/MeasuredSpeedModeTest.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/MeasuredSpeedModeTest.cs @@ -410,6 +410,16 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation @"TestData\MeasuredSpeed\Results\MeasuredSpeedGear.vsum", @"TestData\MeasuredSpeed\MeasuredSpeedGear.vsum", true); } + [TestMethod] + public void MeasuredSpeed_Gear_TractionInterruption_Run() + { + RunJob(@"TestData\MeasuredSpeed\MeasuredSpeedGear_TractionInterruption.vecto", + @"TestData\MeasuredSpeed\Results\MeasuredSpeedGear_TractionInterruption_MeasuredSpeed_Gear_Rural_TractionInterruption.vmod", + @"TestData\MeasuredSpeed\MeasuredSpeedGear_TractionInterruption_MeasuredSpeed_Gear_Rural_TractionInterruption.vmod", + @"TestData\MeasuredSpeed\Results\MeasuredSpeedGear_TractionInterruption.vsum", + @"TestData\MeasuredSpeed\MeasuredSpeedGear_TractionInterruption.vsum", true); + } + [TestMethod] public void MeasuredSpeed_Gear_Aux_Run() { diff --git a/VectoCore/VectoCoreTest/Models/Simulation/PwheelModeTests.cs b/VectoCore/VectoCoreTest/Models/Simulation/PwheelModeTests.cs index d3f9f0b7ed654b93e6f6f5c5b6125009ebf7049b..c5cebefa70f4f04103787324a0caf00edb6791ad 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/PwheelModeTests.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/PwheelModeTests.cs @@ -74,7 +74,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation Gears = new Dictionary<uint, GearData> { { 1, new GearData { Ratio = 2.0 } }, { 2, new GearData { Ratio = 3.5 } } } }, 0.SI<KilogramSquareMeter>()); - var cycle = new PWheelCycle(container, drivingCycle, 2.3, + var cycle = new PWheelCycle(container, drivingCycle, 2.3, null, gearbox.ModelData.Gears.ToDictionary(g => g.Key, g => g.Value.Ratio)); Assert.AreEqual(container.CycleData.LeftSample.Time, 1.SI<Second>()); diff --git a/VectoCore/VectoCoreTest/TestData/Results/EngineOnlyCycles/24t Coach EngineOnly_Engine Only1.vmod b/VectoCore/VectoCoreTest/TestData/Results/EngineOnlyCycles/24t Coach EngineOnly_Engine Only1.vmod index 08c93bd384d2a9d2e7446942bba0b0f32e51c167..9fe26bdbf277ce51f0953f28f15e3c29df3bb272 100644 --- a/VectoCore/VectoCoreTest/TestData/Results/EngineOnlyCycles/24t Coach EngineOnly_Engine Only1.vmod +++ b/VectoCore/VectoCoreTest/TestData/Results/EngineOnlyCycles/24t Coach EngineOnly_Engine Only1.vmod @@ -1,5 +1,5 @@ time [s],n_eng_avg [1/min],T_eng_fcmap [Nm],Tq_full [Nm],Tq_drag [Nm],P_eng_fcmap [kW],P_eng_full [kW],P_eng_full_stat [kW],P_eng_drag [kW],P_eng_inertia [kW],P_eng_out [kW],P_clutch_loss [kW],P_clutch_out [kW],P_aux [kW],P_aux_cycle,FC-Map [g/h],FC-AUXc [g/h],FC-WHTCc [g/h],FC-AAUX [g/h],FC-Final [g/h] -0.5000,580.0000,15.3868,1139.3103,-148.5000,0.9346,69.1988,74.7678,-9.0195,0.9668,0.0000,,,0.0000,0.0000,1506.8291,1506.8291,1506.8291,1506.8291,1506.8291 +0.5000,600.0000,0.0000,1101.3333,-148.0000,0.0000,69.1988,80.5504,-9.2991,0.0000,0.0000,,,0.0000,0.0000,1459.0000,1459.0000,1459.0000,1459.0000,1459.0000 1.5000,600.0000,0.0000,1101.3333,-148.0000,0.0000,69.1988,80.5504,-9.2991,0.0000,0.0000,,,0.0000,0.0000,1459.0000,1459.0000,1459.0000,1459.0000,1459.0000 2.5000,600.0000,0.0000,1101.3333,-148.0000,0.0000,69.1988,80.5504,-9.2991,0.0000,0.0000,,,0.0000,0.0000,1459.0000,1459.0000,1459.0000,1459.0000,1459.0000 3.5000,600.0000,0.0000,1101.3333,-148.0000,0.0000,69.1988,80.5504,-9.2991,0.0000,0.0000,,,0.0000,0.0000,1459.0000,1459.0000,1459.0000,1459.0000,1459.0000 @@ -694,4 +694,3 @@ 692.5000,1828.8550,419.6568,1757.6779,-269.3382,80.3715,336.6256,341.6938,-51.5829,4.5158,77.1577,,,0.0000,0.0000,18432.2375,18432.2375,18432.2375,18432.2375,18432.2375 693.5000,1879.2710,186.7066,1634.0959,-278.6651,36.7433,321.5848,326.0610,-54.8404,3.2561,33.8936,,,0.0000,0.0000,12627.1055,12627.1055,12627.1055,12627.1055,12627.1055 694.5000,1913.7100,282.6382,1544.5241,-285.0363,56.6416,309.5276,314.6095,-57.1222,2.1771,54.8685,,,0.0000,0.0000,15798.5513,15798.5513,15798.5513,15798.5513,15798.5513 -695.5000,1632.2305,423.4192,1856.7600,-239.6734,72.3737,317.3700,349.2417,-40.9666,-40.1481,99.4356,,,0.0000,0.0000,15949.2211,15949.2211,15949.2211,15949.2211,15949.2211 diff --git a/VectoCore/VectoCoreTest/TestData/Results/EngineOnlyCycles/24t Coach EngineOnly_Engine Only2.vmod b/VectoCore/VectoCoreTest/TestData/Results/EngineOnlyCycles/24t Coach EngineOnly_Engine Only2.vmod index fd1a7512eabf48f70e815100373eabb44ae85fec..92d6624300efed33a17067fcc5a6c16a756aafed 100644 --- a/VectoCore/VectoCoreTest/TestData/Results/EngineOnlyCycles/24t Coach EngineOnly_Engine Only2.vmod +++ b/VectoCore/VectoCoreTest/TestData/Results/EngineOnlyCycles/24t Coach EngineOnly_Engine Only2.vmod @@ -1,5 +1,5 @@ time [s],n_eng_avg [1/min],T_eng_fcmap [Nm],Tq_full [Nm],Tq_drag [Nm],P_eng_fcmap [kW],P_eng_full [kW],P_eng_full_stat [kW],P_eng_drag [kW],P_eng_inertia [kW],P_eng_out [kW],P_clutch_loss [kW],P_clutch_out [kW],P_aux [kW],P_aux_cycle,FC-Map [g/h],FC-AUXc [g/h],FC-WHTCc [g/h],FC-AAUX [g/h],FC-Final [g/h] -0.5000,580.0000,15.3868,1139.3103,-148.5000,0.9346,69.1988,74.7678,-9.0195,0.9668,0.0000,,,0.0000,0.0000,1506.8291,1506.8291,1506.8291,1506.8291,1506.8291 +0.5000,600.0000,0.0000,1101.3333,-148.0000,0.0000,69.1988,80.5504,-9.2991,0.0000,0.0000,,,0.0000,0.0000,1459.0000,1459.0000,1459.0000,1459.0000,1459.0000 1.5000,600.0000,0.0000,1101.3333,-148.0000,0.0000,69.1988,80.5504,-9.2991,0.0000,0.0000,,,0.0000,0.0000,1459.0000,1459.0000,1459.0000,1459.0000,1459.0000 2.5000,600.0000,0.0000,1101.3333,-148.0000,0.0000,69.1988,80.5504,-9.2991,0.0000,0.0000,,,0.0000,0.0000,1459.0000,1459.0000,1459.0000,1459.0000,1459.0000 3.5000,600.0000,0.0000,1101.3333,-148.0000,0.0000,69.1988,80.5504,-9.2991,0.0000,0.0000,,,0.0000,0.0000,1459.0000,1459.0000,1459.0000,1459.0000,1459.0000 @@ -1005,4 +1005,3 @@ 1003.5000,1747.2970,300.1032,1848.6197,-256.3581,54.9118,338.2540,350.4916,-46.9075,0.6887,54.3718,,,0.0000,0.0000,13995.8711,13995.8711,13995.8711,13995.8711,13995.8711 1004.5000,1756.4730,279.3416,1846.5955,-257.6886,51.3814,339.6580,350.4587,-47.3986,0.6510,50.8605,,,0.0000,0.0000,13517.1779,13517.1779,13517.1779,13517.1779,13517.1779 1005.5000,1767.0600,371.2643,1842.4875,-259.2237,68.7010,340.9451,350.3965,-47.9683,0.9043,68.0355,,,0.0000,0.0000,16168.5403,16168.5403,16168.5403,16168.5403,16168.5403 -1006.5000,1782.7120,420.7529,1838.6908,-261.4932,78.5483,343.2563,350.2568,-48.8169,1.4133,77.5542,,,0.0000,0.0000,17735.7210,17735.7210,17735.7210,17735.7210,17735.7210 diff --git a/VectoCore/VectoCoreTest/TestData/Results/EngineOnlyCycles/24t Coach EngineOnly_Engine Only3.vmod b/VectoCore/VectoCoreTest/TestData/Results/EngineOnlyCycles/24t Coach EngineOnly_Engine Only3.vmod index 8684e84cb631642a8811ac355f2eadc196247071..f197498f180f1799eaee7b248dae9712f661a030 100644 --- a/VectoCore/VectoCoreTest/TestData/Results/EngineOnlyCycles/24t Coach EngineOnly_Engine Only3.vmod +++ b/VectoCore/VectoCoreTest/TestData/Results/EngineOnlyCycles/24t Coach EngineOnly_Engine Only3.vmod @@ -1,5 +1,5 @@ time [s],n_eng_avg [1/min],T_eng_fcmap [Nm],Tq_full [Nm],Tq_drag [Nm],P_eng_fcmap [kW],P_eng_full [kW],P_eng_full_stat [kW],P_eng_drag [kW],P_eng_inertia [kW],P_eng_out [kW],P_clutch_loss [kW],P_clutch_out [kW],P_aux [kW],P_aux_cycle,FC-Map [g/h],FC-AUXc [g/h],FC-WHTCc [g/h],FC-AAUX [g/h],FC-Final [g/h] -0.5000,580.0000,15.3868,1139.3103,-148.5000,0.9346,69.1988,74.7678,-9.0195,0.9668,0.0000,,,0.0000,0.0000,1506.8291,1506.8291,1506.8291,1506.8291,1506.8291 +0.5000,600.0000,0.0000,1101.3333,-148.0000,0.0000,69.1988,80.5504,-9.2991,0.0000,0.0000,,,0.0000,0.0000,1459.0000,1459.0000,1459.0000,1459.0000,1459.0000 1.5000,600.0000,0.0000,1101.3333,-148.0000,0.0000,69.1988,80.5504,-9.2991,0.0000,0.0000,,,0.0000,0.0000,1459.0000,1459.0000,1459.0000,1459.0000,1459.0000 2.5000,600.0000,0.0000,1101.3333,-148.0000,0.0000,69.1988,80.5504,-9.2991,0.0000,0.0000,,,0.0000,0.0000,1459.0000,1459.0000,1459.0000,1459.0000,1459.0000 3.5000,600.0000,0.0000,1101.3333,-148.0000,0.0000,69.1988,80.5504,-9.2991,0.0000,0.0000,,,0.0000,0.0000,1459.0000,1459.0000,1459.0000,1459.0000,1459.0000 @@ -165,4 +165,3 @@ 163.5000,1304.2050,-130.9400,1839.3308,-191.5046,-17.8833,251.2085,314.1249,-26.1549,-2.9996,-14.5053,,,0.0000,0.0000,1284.6858,1284.6858,1284.6858,1284.6858,1284.6858 164.5000,1249.3625,-130.3151,1840.3154,-184.9235,-17.0495,240.7739,300.9158,-24.1941,-2.8371,-13.8406,,,0.0000,0.0000,1146.0132,1146.0132,1146.0132,1146.0132,1146.0132 165.5000,1202.9710,-127.2652,1840.5811,-179.3565,-16.0322,231.8669,289.7421,-22.5944,-1.9195,-13.8576,,,0.0000,0.0000,970.6337,970.6337,970.6337,970.6337,970.6337 -166.5000,1174.7100,28.3827,1841.3623,-176.5975,3.4915,226.5158,282.9353,-21.7242,-0.8925,4.3569,,,0.0000,0.0000,3760.5779,3760.5779,3760.5779,3760.5779,3760.5779 diff --git a/VectoCore/VectoCoreTest/TestData/Results/EngineOnlyCycles/EngineOnlyJob_Coach Engine Only short.vmod b/VectoCore/VectoCoreTest/TestData/Results/EngineOnlyCycles/EngineOnlyJob_Coach Engine Only short.vmod index 88702f8843f23b46c8a3ee63ed10e7f0c4421419..ee62e8207e4c456a0b4b811399a3fa75656a2b5b 100644 --- a/VectoCore/VectoCoreTest/TestData/Results/EngineOnlyCycles/EngineOnlyJob_Coach Engine Only short.vmod +++ b/VectoCore/VectoCoreTest/TestData/Results/EngineOnlyCycles/EngineOnlyJob_Coach Engine Only short.vmod @@ -1,5 +1,5 @@ time [s],n_eng_avg [1/min],T_eng_fcmap [Nm],Tq_full [Nm],Tq_drag [Nm],P_eng_fcmap [kW],P_eng_full [kW],P_eng_full_stat [kW],P_eng_drag [kW],P_eng_inertia [kW],P_eng_out [kW],P_clutch_loss [kW],P_clutch_out [kW],P_aux [kW],P_aux_cycle,FC-Map [g/h],FC-AUXc [g/h],FC-WHTCc [g/h],FC-AAUX [g/h],FC-Final [g/h] -0.5000,580.0000,15.3868,1139.3103,-148.5000,0.9346,69.1988,74.7678,-9.0195,0.9668,0.0000,,,0.0000,0.0000,1506.8291,1506.8291,1506.8291,1506.8291,1506.8291 +0.5000,600.0000,0.0000,1101.3333,-148.0000,0.0000,69.1988,80.5504,-9.2991,0.0000,0.0000,,,0.0000,0.0000,1459.0000,1459.0000,1459.0000,1459.0000,1459.0000 1.5000,600.0000,0.0000,1101.3333,-148.0000,0.0000,69.1988,80.5504,-9.2991,0.0000,0.0000,,,0.0000,0.0000,1459.0000,1459.0000,1459.0000,1459.0000,1459.0000 2.5000,600.0000,0.0000,1101.3333,-148.0000,0.0000,69.1988,80.5504,-9.2991,0.0000,0.0000,,,0.0000,0.0000,1459.0000,1459.0000,1459.0000,1459.0000,1459.0000 3.5000,600.0000,0.0000,1101.3333,-148.0000,0.0000,69.1988,80.5504,-9.2991,0.0000,0.0000,,,0.0000,0.0000,1459.0000,1459.0000,1459.0000,1459.0000,1459.0000 @@ -305,4 +305,3 @@ 303.5000,1817.8445,141.0337,1783.3780,-267.3012,26.8478,339.4914,344.9291,-50.8846,-0.0916,26.9304,,,0.0000,0.0000,10466.0279,10466.0279,10466.0279,10466.0279,10466.0279 304.5000,1811.6175,43.1361,1796.7821,-266.1492,8.1834,340.8714,346.7304,-50.4917,-0.8489,9.0070,,,0.0000,0.0000,7743.6503,7743.6503,7743.6503,7743.6503,7743.6503 305.5000,1796.3285,-29.2842,1825.3949,-263.4676,-5.5087,343.3770,350.0889,-49.5612,-1.4472,-4.0319,,,0.0000,0.0000,5685.1572,5685.1572,5685.1572,5685.1572,5685.1572 -306.5000,1775.9475,-8.8781,1830.6861,-260.5124,-1.6511,340.4651,350.3242,-48.4493,-1.5859,-0.0553,,,0.0000,0.0000,6067.8939,6067.8939,6067.8939,6067.8939,6067.8939 diff --git a/VectoCore/VectoCoreTest/VectoCoreTest.csproj b/VectoCore/VectoCoreTest/VectoCoreTest.csproj index 481c9329ebff5e3fee39df1b9c30d82a19c5039c..30e21b6b0e7ab2fc1f829ca1d485d4c2f3e3261e 100644 --- a/VectoCore/VectoCoreTest/VectoCoreTest.csproj +++ b/VectoCore/VectoCoreTest/VectoCoreTest.csproj @@ -1279,6 +1279,9 @@ <None Include="TestData\MeasuredSpeed\GearboxSerial.vgbx"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> + <None Include="TestData\MeasuredSpeed\Gearbox_TractionInterruption.vgbx"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> <None Include="TestData\MeasuredSpeed\Gear_Axle_loss.vtlm"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> @@ -1324,6 +1327,9 @@ <None Include="TestData\MeasuredSpeed\MeasuredSpeedGear_AT-PS.vdri"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> + <None Include="TestData\MeasuredSpeed\MeasuredSpeedGear_TractionInterruption.vecto"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> <None Include="TestData\MeasuredSpeed\MeasuredSpeedVair.vdri"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> @@ -1360,6 +1366,9 @@ <None Include="TestData\MeasuredSpeed\MeasuredSpeed_Gear_Rural_Aux.vdri"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> + <None Include="TestData\MeasuredSpeed\MeasuredSpeed_Gear_Rural_TractionInterruption.vdri"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> <None Include="TestData\MeasuredSpeed\MeasuredSpeed_Gear_Rural_Vair.vdri"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> @@ -1411,6 +1420,12 @@ <None Include="TestData\MeasuredSpeed\Results\MeasuredSpeedGear_MeasuredSpeed_Gear_Rural.vmod"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> + <None Include="TestData\MeasuredSpeed\Results\MeasuredSpeedGear_TractionInterruption.vsum"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="TestData\MeasuredSpeed\Results\MeasuredSpeedGear_TractionInterruption_MeasuredSpeed_Gear_Rural_TractionInterruption.vmod"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> <None Include="TestData\MeasuredSpeed\Results\MeasuredSpeedVair.vsum"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None>