From b94031ae7724d076df2188e8f575488c7469c6b1 Mon Sep 17 00:00:00 2001 From: Markus Quaritsch <markus.quaritsch@tugraz.at> Date: Fri, 4 Mar 2016 12:15:44 +0100 Subject: [PATCH] fix in mod-data test, stay disengaged (clutch/gbx) when vehicle stops --- VectoCore/Configuration/Constants.cs | 2 +- .../Models/SimulationComponent/Impl/Clutch.cs | 68 ++++++++++--------- .../SimulationComponent/Impl/ShiftStrategy.cs | 4 +- VectoCoreTest/Reports/ModDataTest.cs | 17 +++-- 4 files changed, 50 insertions(+), 41 deletions(-) diff --git a/VectoCore/Configuration/Constants.cs b/VectoCore/Configuration/Constants.cs index 8b055121ed..3a244994ef 100644 --- a/VectoCore/Configuration/Constants.cs +++ b/VectoCore/Configuration/Constants.cs @@ -114,7 +114,7 @@ namespace TUGraz.VectoCore.Configuration public static readonly Watt EnginePowerSearchTolerance = 0.50.SI<Watt>(); // Watt - public const double CluchNormSpeed = 0.03; + public const double ClutchNormSpeed = 0.03; public static readonly MeterPerSquareSecond MinimumAcceleration = 0.1.SI<MeterPerSquareSecond>(); diff --git a/VectoCore/Models/SimulationComponent/Impl/Clutch.cs b/VectoCore/Models/SimulationComponent/Impl/Clutch.cs index 72376f0eb9..09734356ae 100644 --- a/VectoCore/Models/SimulationComponent/Impl/Clutch.cs +++ b/VectoCore/Models/SimulationComponent/Impl/Clutch.cs @@ -66,23 +66,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return _clutchState; } - protected override void DoWriteModalResults(IModalDataContainer container) - { - if (PreviousState.InAngularVelocity == null || CurrentState.InAngularVelocity == null) { - container[ModalResultField.P_clutch_out] = 0.SI<Watt>(); - container[ModalResultField.P_clutch_loss] = 0.SI<Watt>(); - } else { - var avgAngularVelocity = (PreviousState.InAngularVelocity + CurrentState.InAngularVelocity) / 2.0; - container[ModalResultField.P_clutch_out] = CurrentState.OutTorque * avgAngularVelocity; - container[ModalResultField.P_clutch_loss] = (CurrentState.InTorque - CurrentState.OutTorque) * avgAngularVelocity; - } - } - - protected override void DoCommitSimulationStep() - { - AdvanceState(); - } - public ITnInPort InPort() { return this; @@ -93,11 +76,29 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return this; } + public void Connect(ITnOutPort other) + { + NextComponent = other; + } + public ITnOutPort IdleControlPort { get { return NextComponent; } } + + public virtual IResponse Initialize(NewtonMeter torque, PerSecond angularVelocity) + { + NewtonMeter torqueIn; + PerSecond engineSpeedIn; + AddClutchLoss(torque, angularVelocity, out torqueIn, out engineSpeedIn); + PreviousState.SetState(torqueIn, angularVelocity, torque, angularVelocity); + + var retVal = NextComponent.Initialize(torqueIn, engineSpeedIn); + retVal.ClutchPowerRequest = torque * angularVelocity; + return retVal; + } + public virtual IResponse Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity, bool dryRun = false) { @@ -125,23 +126,28 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return retVal; } - public virtual IResponse Initialize(NewtonMeter torque, PerSecond angularVelocity) - { - NewtonMeter torqueIn; - PerSecond engineSpeedIn; - AddClutchLoss(torque, angularVelocity, out torqueIn, out engineSpeedIn); - PreviousState.SetState(torqueIn, angularVelocity, torque, angularVelocity); - var retVal = NextComponent.Initialize(torqueIn, engineSpeedIn); - retVal.ClutchPowerRequest = torque * angularVelocity; - return retVal; + protected override void DoWriteModalResults(IModalDataContainer container) + { + if (PreviousState.InAngularVelocity == null || CurrentState.InAngularVelocity == null) { + container[ModalResultField.P_clutch_out] = 0.SI<Watt>(); + container[ModalResultField.P_clutch_loss] = 0.SI<Watt>(); + } else { + var avgOutAngularVelocity = (PreviousState.OutAngularVelocity + CurrentState.OutAngularVelocity) / 2.0; + var avgInAngularVelocity = (PreviousState.InAngularVelocity + CurrentState.InAngularVelocity) / 2.0; + container[ModalResultField.P_clutch_out] = CurrentState.OutTorque * avgOutAngularVelocity; + container[ModalResultField.P_clutch_loss] = CurrentState.InTorque * avgInAngularVelocity - + CurrentState.OutTorque * avgOutAngularVelocity; + //(CurrentState.InTorque - CurrentState.OutTorque) * avgInAngularVelocity; + } } - public void Connect(ITnOutPort other) + protected override void DoCommitSimulationStep() { - NextComponent = other; + AdvanceState(); } + private void AddClutchLoss(NewtonMeter torque, PerSecond angularVelocity, out NewtonMeter torqueIn, out PerSecond angularVelocityIn) { @@ -156,12 +162,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl torqueIn = 0.SI<NewtonMeter>(); } else { var engineSpeedNorm = (angularVelocity - _idleSpeed) / (_ratedSpeed - _idleSpeed); - if (engineSpeedNorm < Constants.SimulationSettings.CluchNormSpeed) { + if (engineSpeedNorm < Constants.SimulationSettings.ClutchNormSpeed) { _clutchState = ClutchState.ClutchSlipping; var engineSpeed0 = VectoMath.Max(_idleSpeed, angularVelocity); - var clutchSpeedNorm = Constants.SimulationSettings.CluchNormSpeed / - ((_idleSpeed + Constants.SimulationSettings.CluchNormSpeed * (_ratedSpeed - _idleSpeed)) / _ratedSpeed); + var clutchSpeedNorm = Constants.SimulationSettings.ClutchNormSpeed / + ((_idleSpeed + Constants.SimulationSettings.ClutchNormSpeed * (_ratedSpeed - _idleSpeed)) / _ratedSpeed); angularVelocityIn = ((clutchSpeedNorm * engineSpeed0 / _ratedSpeed) * (_ratedSpeed - _idleSpeed) + _idleSpeed).Radian.Cast<PerSecond>(); diff --git a/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs b/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs index f3c23ec2ac..489395d52f 100644 --- a/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs +++ b/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs @@ -242,7 +242,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (!IsBelowDownShiftCurve(gear, inTorque, inAngularSpeed) && !IsAboveUpShiftCurve(gear, inTorque, inAngularSpeed) && reserve >= Data.StartTorqueReserve) { if ((inAngularSpeed - DataBus.EngineIdleSpeed) / (DataBus.EngineRatedSpeed - DataBus.EngineIdleSpeed) < - Constants.SimulationSettings.CluchNormSpeed && gear > 1) { + Constants.SimulationSettings.ClutchNormSpeed && gear > 1) { gear--; } @@ -350,7 +350,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if ((Data.Gears[NextGear].Ratio * outAngularVelocity - DataBus.EngineIdleSpeed) / (DataBus.EngineRatedSpeed - DataBus.EngineIdleSpeed) < - Constants.SimulationSettings.CluchNormSpeed && NextGear > 1) { + Constants.SimulationSettings.ClutchNormSpeed && NextGear > 1) { NextGear--; } diff --git a/VectoCoreTest/Reports/ModDataTest.cs b/VectoCoreTest/Reports/ModDataTest.cs index 0f8b1691f2..10bb4e22e5 100644 --- a/VectoCoreTest/Reports/ModDataTest.cs +++ b/VectoCoreTest/Reports/ModDataTest.cs @@ -67,12 +67,16 @@ namespace TUGraz.VectoCore.Tests.Reports run.Run(); Assert.IsTrue(run.FinishedWithoutErrors); - var skipNext = false; + var lastGear = 0u; foreach (DataRow row in modData.Data.Rows) { - if (skipNext) { + var gear = (uint)row[(int)ModalResultField.Gear]; + var time = (Second)row[(int)ModalResultField.time]; + + if ((lastGear == 0 && gear != 0) || (lastGear != 0 && gear == 0)) { + //skipNext = (uint)row[(int)ModalResultField.Gear] == 0; + lastGear = gear; continue; } - var time = (Second)row[(int)ModalResultField.time]; var distance = (Meter)row[(int)ModalResultField.dist]; var tqEngFcmap = (NewtonMeter)row[(int)ModalResultField.T_eng_fcmap]; var nEngFcMap = (PerSecond)row[(int)ModalResultField.n_eng_avg]; @@ -113,7 +117,7 @@ namespace TUGraz.VectoCore.Tests.Reports var pClutchLoss = (Watt)row[(int)ModalResultField.P_clutch_loss]; var pClutchOut = (Watt)row[(int)ModalResultField.P_clutch_out]; var pWheelInertia = (Watt)row[(int)ModalResultField.P_wheel_inertia]; - var gear = (uint)row[(int)ModalResultField.Gear]; + // P_trac = P_veh_inertia + P_roll + P_air + P_slope Assert.AreEqual(pTrac.Value(), (pAir + pRoll + pGrad + pVehInertia).Value(), 1E-3, "time: {0} distance: {1}", time, @@ -140,10 +144,9 @@ namespace TUGraz.VectoCore.Tests.Reports if (gear != 0) { Assert.AreEqual(pEngFcmap.Value(), (pTrac + pWheelInertia + pBrakeLoss + pLossAxle + pLossRet + pLossGbx + pGbxInertia + pEngInertia + pAux + - pClutchLoss) - .Value(), 1E-3, "time: {0} distance: {1}", time, distance); + pClutchLoss).Value(), 0.5, "time: {0} distance: {1}", time, distance); } - skipNext = gear == 0; + lastGear = gear; } } } -- GitLab