Code development platform for open source projects from the European Union institutions

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

Merge pull request #579 in VECTO/vecto-sim from...

Merge pull request #579 in VECTO/vecto-sim from ~EMQUARIMA/vecto-sim:bugfix/VECTO-639-failed-to-find-operating-point to develop

* commit '73a2ed4c':
  extend clutch testcases
  modifications in clutch: allow slipping clutch during driving when already in 1st gear
parents 83e960a6 73a2ed4c
No related branches found
No related tags found
No related merge requests found
......@@ -114,9 +114,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
NewtonMeter torqueIn;
PerSecond angularVelocityIn;
var slippingClutchWhenDriving = (DataBus.Gear == 1 && DataBus.DriverBehavior != DrivingBehavior.Braking);
var slippingClutchDuringBraking = DataBus.Gear == 1 && DataBus.DriverBehavior == DrivingBehavior.Braking && outTorque > 0;
//var slippingClutchWhenDriving = (DataBus.Gear == 1 && outTorque > 0);
AddClutchLoss(outTorque, outAngularVelocity,
(DataBus.Gear == 1 && outTorque > 0) || startClutch || outAngularVelocity.IsEqual(0), out torqueIn,
out angularVelocityIn);
slippingClutchWhenDriving || slippingClutchDuringBraking || startClutch || outAngularVelocity.IsEqual(0),
out torqueIn, out angularVelocityIn);
Log.Debug("to Engine: torque: {0}, angularVelocity: {1}, power {2}", torqueIn, angularVelocityIn,
Formulas.TorqueToPower(torqueIn, angularVelocityIn));
......@@ -139,7 +142,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
return retVal;
}
private void AddClutchLoss(NewtonMeter torque, PerSecond angularVelocity, bool startClutch, out NewtonMeter torqueIn,
private void AddClutchLoss(NewtonMeter torque, PerSecond angularVelocity, bool allowSlipping, out NewtonMeter torqueIn,
out PerSecond angularVelocityIn)
{
if (DataBus.DriverBehavior == DrivingBehavior.Halted) {
......@@ -152,14 +155,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
angularVelocityIn = angularVelocity;
var engineSpeedNorm = (angularVelocity - _idleSpeed) / (_ratedSpeed - _idleSpeed);
if (startClutch && engineSpeedNorm < Constants.SimulationSettings.ClutchClosingSpeedNorm) {
// MQ: 27.5.2016: when angularVelocity is 0 (at the end of the simulation interval) don't use the
// angularVelocity but average angular velocity
// Reason: if angularVelocity = 0 also the power (torque * angularVelocity) is 0 and then
// the torque demand for the engine is 0. no drag torque although vehicle has to decelerate
// "the clutch" eats up the whole torque
if (allowSlipping && engineSpeedNorm < Constants.SimulationSettings.ClutchClosingSpeedNorm) {
var engineSpeed = VectoMath.Max(_idleSpeed, angularVelocity);
angularVelocityIn = _clutchSpeedSlippingFactor * engineSpeed + _idleSpeed;
}
}
......
......@@ -30,6 +30,7 @@
*/
using System.Data;
using System.IO;
using NUnit.Framework;
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Utils;
......@@ -49,26 +50,33 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
public class ClutchTest
{
private const string CoachEngine = @"TestData\Components\24t Coach.veng";
[OneTimeSetUp]
public void RunBeforeAnyTests()
{
Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory);
}
[Test,
// clutch slipping
TestCase(DrivingBehavior.Driving, 100, 0, 0, 65.6889),
TestCase(DrivingBehavior.Driving, 100, 0, 3, 0, 65.6889),
TestCase(DrivingBehavior.Driving, 100, 5, 1, 7.6116, 65.6889),
TestCase(DrivingBehavior.Braking, 100, 80, 1, 100, 80),
// clutch opened - would cause neg. clutch losses (which is not possible), torque is adapted
TestCase(DrivingBehavior.Halted, 100, 30, 51.1569, 58.643062),
TestCase(DrivingBehavior.Halted, 100, 30, 0, 51.1569, 58.643062),
// clutch closed
TestCase(DrivingBehavior.Driving, 100, 80, 100, 80),
TestCase(DrivingBehavior.Braking, 100, 80, 100, 80),
TestCase(DrivingBehavior.Driving, 100, 30, 100, 30),
TestCase(DrivingBehavior.Driving, 100, 80, 3, 100, 80),
TestCase(DrivingBehavior.Braking, 100, 80, 3, 100, 80),
TestCase(DrivingBehavior.Driving, 100, 30, 3, 100, 30),
// clutch opened due to braking
//TestCase(DrivingBehavior.Braking, 0, 55, null, null),
]
public void TestClutch(DrivingBehavior drivingBehavior, double torque, double angularSpeed, double expectedTorque,
public void TestClutch(DrivingBehavior drivingBehavior, double torque, double angularSpeed, int gear, double expectedTorque,
double expectedEngineSpeed)
{
var container = new VehicleContainer(ExecutionMode.Engineering);
var engineData = MockSimulationDataFactory.CreateEngineDataFromFile(CoachEngine, 1);
var gearbox = new MockGearbox(container);
gearbox.Gear = 0;
gearbox.Gear = (uint)gear;
var clutch = new Clutch(container, engineData) { IdleController = new MockIdleController() };
var vehicle = new MockVehicle(container);
vehicle.MyVehicleSpeed = 50.KMPHtoMeterPerSecond();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment