diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs index c9c252655f0d3ce6bd29049798c88e97585458af..ff8fc30a4160e679ca79e5fe155fc2b4ffb75388 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs @@ -204,7 +204,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (_requestAfterGearshift) { LastShift = absTime; Gear = _strategy.Engage(absTime, dt, outTorque, outAngularVelocity); - CurrentState.PowershiftLosses = ComputeShiftLosses(dt, outTorque, outAngularVelocity); + CurrentState.PowershiftLossEnergy = ComputeShiftLosses(outTorque, outAngularVelocity); + } else { + if (PreviousState.PowershiftLossEnergy != null && PreviousState.PowershiftLossEnergy.IsGreater(0)) { + CurrentState.PowershiftLossEnergy = PreviousState.PowershiftLossEnergy; + } } do { if (CurrentState.Disengaged || (DataBus.DriverBehavior == DrivingBehavior.Halted)) { @@ -264,8 +268,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl : 0.SI<NewtonMeter>(); inTorque += inertiaTorqueLossOut / effectiveRatio; - if (CurrentState.PowershiftLosses != null) { - inTorque += CurrentState.PowershiftLosses; + if (CurrentState.PowershiftLossEnergy != null) { + var remainingShiftLossLime = ModelData.PowershiftShiftTime - (absTime - LastShift); + if (remainingShiftLossLime.IsGreater(0)) { + var aliquotEnergyLoss = CurrentState.PowershiftLossEnergy * VectoMath.Min(1.0, dt / remainingShiftLossLime); + var avgEngineSpeed = (DataBus.EngineSpeed + outAngularVelocity * ModelData.Gears[Gear].Ratio) / 2; + CurrentState.PowershiftLoss = aliquotEnergyLoss / dt / avgEngineSpeed; + inTorque += CurrentState.PowershiftLoss; + CurrentState.PowershiftLossEnergy -= aliquotEnergyLoss; + //inTorque += CurrentState.PowershiftLossEnergy; + } } if (!dryRun) { @@ -359,7 +371,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl CurrentState.OutTorque * avgOutAngularSpeed; container[ModalResultField.P_gbx_inertia] = CurrentState.InertiaTorqueLossOut * avgOutAngularSpeed; container[ModalResultField.P_gbx_in] = CurrentState.InTorque * avgInAngularSpeed; - container[ModalResultField.P_gbx_shift_loss] = CurrentState.PowershiftLosses.DefaultIfNull(0) * avgInAngularSpeed; + container[ModalResultField.P_gbx_shift_loss] = CurrentState.PowershiftLoss.DefaultIfNull(0) * avgInAngularSpeed; container[ModalResultField.n_gbx_out_avg] = avgOutAngularSpeed; container[ModalResultField.T_gbx_out] = CurrentState.OutTorque; } @@ -395,7 +407,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { public bool TorqueConverterLocked; public bool Disengaged = true; - public NewtonMeter PowershiftLosses; + public WattSecond PowershiftLossEnergy; + public NewtonMeter PowershiftLoss; } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AbstractGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AbstractGearbox.cs index 93131a1d37ec3fdc25927139559c468c3c5ec363..cd1643c6e812d7eee080fcfa5afe158cbdb4a215 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AbstractGearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AbstractGearbox.cs @@ -54,7 +54,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected KilogramSquareMeter EngineInertia; - protected AbstractGearbox(IVehicleContainer container, VectoRunData runData): base(container) + protected AbstractGearbox(IVehicleContainer container, VectoRunData runData) : base(container) { ModelData = runData.GearboxData; EngineInertia = runData.EngineData != null @@ -124,7 +124,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl get { return ModelData.TractionInterruption; } } - public uint NumGears { get { return (uint)ModelData.Gears.Count; } } + public uint NumGears + { + get { return (uint)ModelData.Gears.Count; } + } #endregion @@ -147,17 +150,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return nextGear.TorqueConverterLocked; } - protected internal NewtonMeter ComputeShiftLosses(Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity) + protected internal WattSecond ComputeShiftLosses(NewtonMeter outTorque, PerSecond outAngularVelocity) { var torqueGbxIn = outTorque / ModelData.Gears[Gear].Ratio; var deltaEngineSpeed = DataBus.EngineSpeed - outAngularVelocity * ModelData.Gears[Gear].Ratio; var deltaClutchSpeed = (DataBus.EngineSpeed - PreviousState.OutAngularVelocity * ModelData.Gears[Gear].Ratio) / 2; - var torqueInertia = ModelData.PowershiftInertiaFactor * EngineInertia * deltaEngineSpeed / dt; - var averageEngineSpeed = (DataBus.EngineSpeed + outAngularVelocity * ModelData.Gears[Gear].Ratio) / 2; - var torqueLoss = (torqueGbxIn + torqueInertia) * deltaClutchSpeed / averageEngineSpeed * - (ModelData.PowershiftShiftTime / dt); + var torqueInertia = ModelData.PowershiftInertiaFactor * EngineInertia * deltaEngineSpeed / + ModelData.PowershiftShiftTime; + var shiftLossEnergy = (torqueGbxIn + torqueInertia) * deltaClutchSpeed * ModelData.PowershiftShiftTime; - return torqueLoss.Abs(); + return shiftLossEnergy.Abs(); } } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs index 186447cf984607875dfb696bb79523ab5bc8f6f4..da05cbaf73afd19285ea9b89b1b5a2e3faba0bf8 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs @@ -226,9 +226,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } if (Gear != PreviousState.Gear && ConsiderShiftLosses(new GearInfo(Gear, torqueConverterLocked), outTorque)) { - CurrentState.PowershiftLosses = ComputeShiftLosses(dt, outTorque, outAngularVelocity); + CurrentState.PowershiftLosses = ComputeShiftLosses(outTorque, outAngularVelocity); + } + if (CurrentState.PowershiftLosses != null) { + var averageEngineSpeed = (DataBus.EngineSpeed + outAngularVelocity * ModelData.Gears[Gear].Ratio) / 2; + inTorque += CurrentState.PowershiftLosses / dt / averageEngineSpeed; } - inTorque += CurrentState.PowershiftLosses ?? 0.SI<NewtonMeter>(); if (dryRun) { if (TorqueConverter != null && !torqueConverterLocked) { return TorqueConverter.Request(absTime, dt, inTorque, inAngularVelocity, true); @@ -491,7 +494,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public class CycleGearboxState : GearboxState { public bool TorqueConverterActive; - public NewtonMeter PowershiftLosses { get; set; } + public WattSecond PowershiftLosses { get; set; } } public class CycleShiftStrategy : BaseShiftStrategy