Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit b94031ae authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

fix in mod-data test, stay disengaged (clutch/gbx) when vehicle stops

parent 13cd14c4
No related branches found
No related tags found
No related merge requests found
...@@ -114,7 +114,7 @@ namespace TUGraz.VectoCore.Configuration ...@@ -114,7 +114,7 @@ namespace TUGraz.VectoCore.Configuration
public static readonly Watt EnginePowerSearchTolerance = 0.50.SI<Watt>(); // Watt 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>(); public static readonly MeterPerSquareSecond MinimumAcceleration = 0.1.SI<MeterPerSquareSecond>();
......
...@@ -66,23 +66,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -66,23 +66,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
return _clutchState; 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() public ITnInPort InPort()
{ {
return this; return this;
...@@ -93,11 +76,29 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -93,11 +76,29 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
return this; return this;
} }
public void Connect(ITnOutPort other)
{
NextComponent = other;
}
public ITnOutPort IdleControlPort public ITnOutPort IdleControlPort
{ {
get { return NextComponent; } 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, public virtual IResponse Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity,
bool dryRun = false) bool dryRun = false)
{ {
...@@ -125,23 +126,28 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -125,23 +126,28 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
return retVal; 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); protected override void DoWriteModalResults(IModalDataContainer container)
retVal.ClutchPowerRequest = torque * angularVelocity; {
return retVal; 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, private void AddClutchLoss(NewtonMeter torque, PerSecond angularVelocity, out NewtonMeter torqueIn,
out PerSecond angularVelocityIn) out PerSecond angularVelocityIn)
{ {
...@@ -156,12 +162,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -156,12 +162,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
torqueIn = 0.SI<NewtonMeter>(); torqueIn = 0.SI<NewtonMeter>();
} else { } else {
var engineSpeedNorm = (angularVelocity - _idleSpeed) / (_ratedSpeed - _idleSpeed); var engineSpeedNorm = (angularVelocity - _idleSpeed) / (_ratedSpeed - _idleSpeed);
if (engineSpeedNorm < Constants.SimulationSettings.CluchNormSpeed) { if (engineSpeedNorm < Constants.SimulationSettings.ClutchNormSpeed) {
_clutchState = ClutchState.ClutchSlipping; _clutchState = ClutchState.ClutchSlipping;
var engineSpeed0 = VectoMath.Max(_idleSpeed, angularVelocity); var engineSpeed0 = VectoMath.Max(_idleSpeed, angularVelocity);
var clutchSpeedNorm = Constants.SimulationSettings.CluchNormSpeed / var clutchSpeedNorm = Constants.SimulationSettings.ClutchNormSpeed /
((_idleSpeed + Constants.SimulationSettings.CluchNormSpeed * (_ratedSpeed - _idleSpeed)) / _ratedSpeed); ((_idleSpeed + Constants.SimulationSettings.ClutchNormSpeed * (_ratedSpeed - _idleSpeed)) / _ratedSpeed);
angularVelocityIn = angularVelocityIn =
((clutchSpeedNorm * engineSpeed0 / _ratedSpeed) * (_ratedSpeed - _idleSpeed) + _idleSpeed).Radian.Cast<PerSecond>(); ((clutchSpeedNorm * engineSpeed0 / _ratedSpeed) * (_ratedSpeed - _idleSpeed) + _idleSpeed).Radian.Cast<PerSecond>();
......
...@@ -242,7 +242,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -242,7 +242,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
if (!IsBelowDownShiftCurve(gear, inTorque, inAngularSpeed) && !IsAboveUpShiftCurve(gear, inTorque, inAngularSpeed) && if (!IsBelowDownShiftCurve(gear, inTorque, inAngularSpeed) && !IsAboveUpShiftCurve(gear, inTorque, inAngularSpeed) &&
reserve >= Data.StartTorqueReserve) { reserve >= Data.StartTorqueReserve) {
if ((inAngularSpeed - DataBus.EngineIdleSpeed) / (DataBus.EngineRatedSpeed - DataBus.EngineIdleSpeed) < if ((inAngularSpeed - DataBus.EngineIdleSpeed) / (DataBus.EngineRatedSpeed - DataBus.EngineIdleSpeed) <
Constants.SimulationSettings.CluchNormSpeed && gear > 1) { Constants.SimulationSettings.ClutchNormSpeed && gear > 1) {
gear--; gear--;
} }
...@@ -350,7 +350,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -350,7 +350,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
if ((Data.Gears[NextGear].Ratio * outAngularVelocity - DataBus.EngineIdleSpeed) / if ((Data.Gears[NextGear].Ratio * outAngularVelocity - DataBus.EngineIdleSpeed) /
(DataBus.EngineRatedSpeed - DataBus.EngineIdleSpeed) < (DataBus.EngineRatedSpeed - DataBus.EngineIdleSpeed) <
Constants.SimulationSettings.CluchNormSpeed && NextGear > 1) { Constants.SimulationSettings.ClutchNormSpeed && NextGear > 1) {
NextGear--; NextGear--;
} }
......
...@@ -67,12 +67,16 @@ namespace TUGraz.VectoCore.Tests.Reports ...@@ -67,12 +67,16 @@ namespace TUGraz.VectoCore.Tests.Reports
run.Run(); run.Run();
Assert.IsTrue(run.FinishedWithoutErrors); Assert.IsTrue(run.FinishedWithoutErrors);
var skipNext = false; var lastGear = 0u;
foreach (DataRow row in modData.Data.Rows) { 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; continue;
} }
var time = (Second)row[(int)ModalResultField.time];
var distance = (Meter)row[(int)ModalResultField.dist]; var distance = (Meter)row[(int)ModalResultField.dist];
var tqEngFcmap = (NewtonMeter)row[(int)ModalResultField.T_eng_fcmap]; var tqEngFcmap = (NewtonMeter)row[(int)ModalResultField.T_eng_fcmap];
var nEngFcMap = (PerSecond)row[(int)ModalResultField.n_eng_avg]; var nEngFcMap = (PerSecond)row[(int)ModalResultField.n_eng_avg];
...@@ -113,7 +117,7 @@ namespace TUGraz.VectoCore.Tests.Reports ...@@ -113,7 +117,7 @@ namespace TUGraz.VectoCore.Tests.Reports
var pClutchLoss = (Watt)row[(int)ModalResultField.P_clutch_loss]; var pClutchLoss = (Watt)row[(int)ModalResultField.P_clutch_loss];
var pClutchOut = (Watt)row[(int)ModalResultField.P_clutch_out]; var pClutchOut = (Watt)row[(int)ModalResultField.P_clutch_out];
var pWheelInertia = (Watt)row[(int)ModalResultField.P_wheel_inertia]; 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 // 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, 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 ...@@ -140,10 +144,9 @@ namespace TUGraz.VectoCore.Tests.Reports
if (gear != 0) { if (gear != 0) {
Assert.AreEqual(pEngFcmap.Value(), Assert.AreEqual(pEngFcmap.Value(),
(pTrac + pWheelInertia + pBrakeLoss + pLossAxle + pLossRet + pLossGbx + pGbxInertia + pEngInertia + pAux + (pTrac + pWheelInertia + pBrakeLoss + pLossAxle + pLossRet + pLossGbx + pGbxInertia + pEngInertia + pAux +
pClutchLoss) pClutchLoss).Value(), 0.5, "time: {0} distance: {1}", time, distance);
.Value(), 1E-3, "time: {0} distance: {1}", time, distance);
} }
skipNext = gear == 0; lastGear = gear;
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment