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

Skip to content
Snippets Groups Projects
Commit 5f2405e4 authored by Markus QUARITSCH's avatar Markus QUARITSCH
Browse files

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

Merge pull request #783 in VECTO/vecto-sim from ~EMQUARIMA/vecto-sim:bugfix/VECTO-1047-failed-to-find-operating-point-on-construction-cycle-ref-load-at-gearbox to develop

* commit '8ab7d561':
  bugfix: use correct shiftloss energy in second simulation interval when shift losses are split among two intervals
  dding testcase for splitting shift losses among 2 simulation intervals
parents 28efd8f9 8ab7d561
No related branches found
No related tags found
No related merge requests found
......@@ -299,7 +299,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
if (_powershiftLossEnergy != null) {
var remainingShiftLossLime = ModelData.PowershiftShiftTime - (absTime - LastShift);
if (remainingShiftLossLime.IsGreater(0)) {
aliquotEnergyLoss = _powershiftLossEnergy * VectoMath.Min(1.0, dt / remainingShiftLossLime);
aliquotEnergyLoss = _powershiftLossEnergy * VectoMath.Min(1.0, VectoMath.Min(dt, remainingShiftLossLime) / ModelData.PowershiftShiftTime);
var avgEngineSpeed = (DataBus.EngineSpeed + outAngularVelocity * effectiveRatio) / 2;
powershiftLoss = aliquotEnergyLoss / dt / avgEngineSpeed;
inTorque += powershiftLoss;
......@@ -317,7 +317,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
CurrentState.Gear = Gear;
CurrentState.TransmissionTorqueLoss = inTorque * effectiveRatio - outTorque;
CurrentState.PowershiftLoss = powershiftLoss;
CurrentState.PowershiftLossEnergy = _powershiftLossEnergy ?? 0.SI<WattSecond>() - aliquotEnergyLoss;
CurrentState.PowershiftLossEnergy = _powershiftLossEnergy;
TorqueConverter.Locked(CurrentState.InTorque, CurrentState.InAngularVelocity, CurrentState.InTorque,
CurrentState.InAngularVelocity);
}
......
......@@ -29,6 +29,7 @@
* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology
*/
using System;
using System.Globalization;
using NUnit.Framework;
using TUGraz.VectoCommon.Models;
......@@ -70,20 +71,128 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
}
[Test,
TestCase(200, 2u, 562, 620, 19.5023),
TestCase(400, 2u, 562, 620, 39.0046),
TestCase(600, 2u, 562, 620, 58.5069),
TestCase(800, 2u, 562, 620, 78.0092),
TestCase(200, 2u, 562, 600, 19.7908),
TestCase(400, 2u, 562, 600, 39.5816),
TestCase(600, 2u, 562, 600, 59.3723),
TestCase(800, 2u, 562, 600, 79.1632),
TestCase(400, 3u, 500, 490, 30.7900),
TestCase(400, 3u, 550, 490, 32.4643),
TestCase(600, 3u, 550, 490, 48.6965),
TestCase(200, 2u, 562, 620, 19.5023, double.NaN),
TestCase(400, 2u, 562, 620, 39.0046, 3183.0086),
TestCase(600, 2u, 562, 620, 58.5069, double.NaN),
TestCase(800, 2u, 562, 620, 78.0092, double.NaN),
TestCase(200, 2u, 562, 600, 19.7908, double.NaN),
TestCase(400, 2u, 562, 600, 39.5816, double.NaN),
TestCase(600, 2u, 562, 600, 59.3723, 4774.5128),
TestCase(800, 2u, 562, 600, 79.1632, double.NaN),
TestCase(400, 3u, 500, 490, 30.7900, double.NaN),
TestCase(400, 3u, 550, 490, 32.4643, 2328.0855),
TestCase(600, 3u, 550, 490, 48.6965, double.NaN),
]
public void TestShiftLossComputation(double torqueDemand, uint gear, double preShiftRpm,
double postShiftRpm, double expectedShiftLoss)
double postShiftRpm, double expectedShiftLoss, double expectedShiftLossEnergy)
{
AxleGear axleGear;
ATGearbox gbx;
CombustionEngine engine;
var cycleDataStr = "0, 0, 0, 2\n100, 20, 0, 0\n1000, 50, 0, 0";
var container = CreateVehicle(cycleDataStr, preShiftRpm, out axleGear, out gbx, out engine);
gbx.Gear = gear;
var absTime = 20.SI<Second>();
var dt = 0.5.SI<Second>();
var response = gbx.Request(absTime, dt, 0.SI<NewtonMeter>(), preShiftRpm.RPMtoRad());
axleGear.Request(absTime, dt, 0.SI<NewtonMeter>(), preShiftRpm.RPMtoRad());
Assert.IsInstanceOf<ResponseSuccess>(response);
container.CommitSimulationStep(absTime, dt);
absTime += dt;
response = gbx.Request(absTime, dt, torqueDemand.SI<NewtonMeter>(), postShiftRpm.RPMtoRad());
Assert.IsInstanceOf<ResponseFailTimeInterval>(response);
dt = ((ResponseFailTimeInterval)response).DeltaT;
response = gbx.Request(absTime, dt, torqueDemand.SI<NewtonMeter>(), postShiftRpm.RPMtoRad());
Assert.IsInstanceOf<ResponseSuccess>(response);
Assert.AreEqual(expectedShiftLoss, gbx.CurrentState.PowershiftLoss.Value(), 1e-3);
Assert.AreEqual(gear + (postShiftRpm > preShiftRpm ? 1 : -1), gbx.Gear);
if (!double.IsNaN(expectedShiftLossEnergy)) {
var modData = new MockModalDataContainer();
gbx.CommitSimulationStep(modData);
var shiftLossE = (Watt)modData[ModalResultField.P_gbx_shift_loss] * dt;
Assert.AreEqual(expectedShiftLossEnergy, shiftLossE.Value(), 1e-3);
}
}
[Test,
//TestCase(200, 2u, 562, 620, 19.5023),
TestCase(400, 2u, 562, 620, 39.0046, 3183.0086),
//TestCase(600, 2u, 562, 620, 58.5069),
//TestCase(800, 2u, 562, 620, 78.0092),
//TestCase(200, 2u, 562, 600, 19.7908),
//TestCase(400, 2u, 562, 600, 39.5816),
TestCase(600, 2u, 562, 600, 59.3723, 4774.5128),
//TestCase(800, 2u, 562, 600, 79.1632),
//TestCase(400, 3u, 500, 490, 30.7900),
TestCase(400, 3u, 550, 490, 32.4643, 2328.0855),
//TestCase(600, 3u, 550, 490, 48.6965),
]
public void TestSplittingShiftLossesTwoIntervals(double torqueDemand, uint gear, double preShiftRpm,
double postShiftRpm, double expectedShiftLoss, double expectedShiftLossEnergy)
{
AxleGear axleGear;
ATGearbox gbx;
CombustionEngine engine;
var cycleDataStr = "0, 0, 0, 2\n100, 20, 0, 0\n1000, 50, 0, 0";
var container = CreateVehicle(cycleDataStr, preShiftRpm, out axleGear, out gbx, out engine);
var modData = new MockModalDataContainer();
gbx.Gear = gear;
var absTime = 20.SI<Second>();
var dt = 0.5.SI<Second>();
var response = gbx.Request(absTime, dt, 0.SI<NewtonMeter>(), preShiftRpm.RPMtoRad());
axleGear.Request(absTime, dt, 0.SI<NewtonMeter>(), preShiftRpm.RPMtoRad());
Assert.IsInstanceOf<ResponseSuccess>(response);
container.CommitSimulationStep(absTime, dt);
absTime += dt;
response = gbx.Request(absTime, dt, torqueDemand.SI<NewtonMeter>(), postShiftRpm.RPMtoRad());
Assert.IsInstanceOf<ResponseFailTimeInterval>(response);
var splitFactor = 0.75;
var shiftTime = ((ResponseFailTimeInterval)response).DeltaT;
dt = shiftTime * splitFactor;
response = gbx.Request(absTime, dt, torqueDemand.SI<NewtonMeter>(), postShiftRpm.RPMtoRad());
Assert.IsInstanceOf<ResponseSuccess>(response);
Assert.AreEqual(expectedShiftLoss, gbx.CurrentState.PowershiftLoss.Value(), 1e-3);
Assert.AreEqual(gear + (postShiftRpm > preShiftRpm ? 1 : -1), gbx.Gear);
gbx.CommitSimulationStep(modData);
engine.CommitSimulationStep(modData);
var shiftLoss1 = (Watt)modData[ModalResultField.P_gbx_shift_loss] * dt;
Assert.AreEqual(expectedShiftLossEnergy * splitFactor, shiftLoss1.Value(), 1e-3);
axleGear.Request(absTime, dt, 0.SI<NewtonMeter>(), preShiftRpm.RPMtoRad());
absTime += dt;
dt = 0.5.SI<Second>();
response = gbx.Request(absTime, dt, torqueDemand.SI<NewtonMeter>(), postShiftRpm.RPMtoRad());
Assert.IsInstanceOf<ResponseSuccess>(response);
gbx.CommitSimulationStep(modData);
engine.CommitSimulationStep(modData);
var shiftLoss2 = (Watt)modData[ModalResultField.P_gbx_shift_loss] * dt;
Console.WriteLine("expected shiftloss energy: {0}, sum of shift loss energy: {1} ({2} + {3})", expectedShiftLossEnergy, shiftLoss1 + shiftLoss2, shiftLoss1, shiftLoss2);
Assert.AreEqual(expectedShiftLossEnergy * (1 - splitFactor), shiftLoss2.Value(), 1e-3);
Assert.AreEqual(expectedShiftLossEnergy, (shiftLoss1 + shiftLoss2).Value(), 1e-3);
}
private static VehicleContainer CreateVehicle(string cycleDataStr, double preShiftRpm, out AxleGear axleGear, out ATGearbox gbx, out CombustionEngine engine)
{
var engineInertia = 5.SI<KilogramSquareMeter>();
......@@ -92,11 +201,11 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
var container = new VehicleContainer(ExecutionMode.Engineering);
gearboxData.PowershiftShiftTime = 0.8.SI<Second>();
var cycleDataStr = "0, 0, 0, 2\n100, 20, 0, 0\n1000, 50, 0, 0";
var cycleData = SimpleDrivingCycles.CreateCycleData(cycleDataStr);
var cycle = new MockDrivingCycle(container, cycleData);
var axleGear = new AxleGear(container, CreateAxleGearData(GearboxType.ATSerial));
axleGear = new AxleGear(container, CreateAxleGearData(GearboxType.ATSerial));
axleGear.Connect(new MockComponent());
var wheels = new Wheels(container, 0.5.SI<Meter>(), 9.5.SI<KilogramSquareMeter>());
......@@ -106,41 +215,21 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
var driver = new MockDriver(container);
vehicle.MyVehicleSpeed = 10.KMPHtoMeterPerSecond();
driver.DriverBehavior = DrivingBehavior.Driving;
var engine = new CombustionEngine(container,
engine = new CombustionEngine(
container,
MockSimulationDataFactory.CreateEngineDataFromFile(ATPowerTrain.EngineFile, gearboxData.Gears.Count));
container.Engine = engine;
var runData = new VectoRunData() {
GearboxData = gearboxData,
EngineData = new CombustionEngineData() { Inertia = 5.SI<KilogramSquareMeter>() }
};
var gbx = new ATGearbox(container, new ATShiftStrategy(gearboxData, container), runData);
gbx = new ATGearbox(container, new ATShiftStrategy(gearboxData, container), runData);
gbx.Connect(engine);
gbx.IdleController = new MockIdleController();
var init = gbx.Initialize(0.SI<NewtonMeter>(), preShiftRpm.RPMtoRad());
axleGear.Initialize(0.SI<NewtonMeter>(), preShiftRpm.RPMtoRad());
gbx.Gear = gear;
var absTime = 20.SI<Second>();
var dt = 0.5.SI<Second>();
var response = gbx.Request(absTime, dt, 0.SI<NewtonMeter>(), preShiftRpm.RPMtoRad());
axleGear.Request(absTime, dt, 0.SI<NewtonMeter>(), preShiftRpm.RPMtoRad());
Assert.IsInstanceOf<ResponseSuccess>(response);
container.CommitSimulationStep(absTime, dt);
absTime += dt;
response = gbx.Request(absTime, dt, torqueDemand.SI<NewtonMeter>(), postShiftRpm.RPMtoRad());
Assert.IsInstanceOf<ResponseFailTimeInterval>(response);
dt = ((ResponseFailTimeInterval)response).DeltaT;
response = gbx.Request(absTime, dt, torqueDemand.SI<NewtonMeter>(), postShiftRpm.RPMtoRad());
Assert.IsInstanceOf<ResponseSuccess>(response);
Assert.AreEqual(expectedShiftLoss, gbx.CurrentState.PowershiftLoss.Value(), 1e-3);
Assert.AreEqual(gear + (postShiftRpm > preShiftRpm ? 1 : -1), gbx.Gear);
return container;
}
}
}
\ No newline at end of file
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