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

Skip to content
Snippets Groups Projects
Commit d61fdf56 authored by Stefanos Doumpoulakis's avatar Stefanos Doumpoulakis
Browse files

improved and refactored PWheelCycle

parent 121e568c
No related branches found
No related tags found
No related merge requests found
......@@ -91,6 +91,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
Distance = 0.SI<Meter>(),
};
CurrentState = PreviousState.Clone();
AbsTime = Data.Entries.First().Time;
}
public IResponse Initialize()
......@@ -273,7 +275,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
}
}
private IResponse HandleUnderload(Second absTime, Second dt, ResponseUnderload r,
private IResponse HandleUnderload(Second absTime, Second dt, ResponseUnderload r,
Radian gradient, ref MeterPerSquareSecond acceleration)
{
MeterPerSquareSecond acc = acceleration;
......@@ -371,9 +373,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
protected override void DoCommitSimulationStep(Second time, Second simulationInterval)
{
if ((CycleIterator.RightSample == null) ||
(AbsTime != null && AbsTime.IsGreaterOrEqual(CycleIterator.RightSample.Time)))
{
if ((CycleIterator.RightSample == null) || AbsTime.IsGreaterOrEqual(CycleIterator.RightSample.Time)) {
CycleIterator.MoveNext();
}
AdvanceState();
......
......@@ -71,27 +71,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
gearRatios[0] = 1;
var axleRatio = (RunData.AxleGearData != null) ? RunData.AxleGearData.AxleGear.Ratio : 1;
var emData = RunData.ElectricMachinesData.First().Item2;
foreach (var entry in Data.Entries)
{
if (RunData.JobType == VectoCommon.InputData.VectoSimulationJobType.BatteryElectricVehicle)
{
entry.WheelAngularVelocity = entry.AngularVelocity / (axleRatio * gearRatios[entry.Gear] * emData.RatioADC);
}
else
{
entry.WheelAngularVelocity = entry.AngularVelocity / (axleRatio * gearRatios[entry.Gear]);
}
if (entry.WheelAngularVelocity.Value() == 0)
{
entry.Torque = NewtonMeter.Create(0);
}
else
{
entry.Torque = entry.PWheel / entry.WheelAngularVelocity;
}
var emData = (RunData.ElectricMachinesData.Count > 0) ? RunData.ElectricMachinesData.First().Item2 : null;
var ratioADC = (RunData.JobType == VectoCommon.InputData.VectoSimulationJobType.BatteryElectricVehicle) ? emData.RatioADC : 1;
foreach (var entry in Data.Entries) {
entry.WheelAngularVelocity = entry.AngularVelocity / (axleRatio * gearRatios[entry.Gear] * ratioADC);
entry.Torque = ((entry.WheelAngularVelocity != null) && !entry.WheelAngularVelocity.IsEqual(0))
? entry.PWheel / entry.WheelAngularVelocity
: 0.SI<NewtonMeter>();
}
}
......@@ -114,7 +102,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
return new ResponseCycleFinished(this);
}
SetDriverAction();
DetermineDriverAction();
// interval exceeded
if (CycleIterator.RightSample != null && (absTime + dt).IsGreater(CycleIterator.RightSample.Time)) {
return new ResponseFailTimeInterval(this) {
......@@ -131,6 +120,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
container[ModalResultField.P_wheel_in] = CycleIterator.LeftSample.PWheel;
base.DoWriteModalResults(time, simulationInterval, container);
}
#region IDriverInfo
public MeterPerSecond VehicleSpeed { get; private set; }
......@@ -164,48 +154,38 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
}
public MeterPerSecond MaxVehicleSpeed => null;
public DrivingBehavior DriverBehavior { get; internal set; } = DrivingBehavior.Driving;
public DrivingAction DrivingAction { get; private set; } = DrivingAction.Accelerate;
public MeterPerSquareSecond DriverAcceleration => 0.SI<MeterPerSquareSecond>();
public PCCStates PCCState => PCCStates.OutsideSegment;
public MeterPerSecond NextBrakeTriggerSpeed => 0.SI<MeterPerSecond>();
public DrivingBehavior DriverBehavior { get; internal set; }
public DrivingAction DrivingAction { get; private set; }
private PerSquareSecond GetCurrentAcceleration()
{
var targetSpeed = CycleIterator.RightSample.AngularVelocity;
if (targetSpeed.Value().IsEqual(0, 0.5))
{
targetSpeed = PerSecond.Create(0);
}
var deltaV = targetSpeed - CycleIterator.LeftSample.AngularVelocity;
var deltaT = CycleIterator.RightSample.Time - AbsTime;
if (deltaT.IsSmaller(0))
{
throw new VectoSimulationException("deltaT is smaller than zero");
}
return (deltaV / deltaT);
}
private void SetDriverAction()
private void DetermineDriverAction()
{
var acceleration = GetCurrentAcceleration();
if (VehicleStopped)
{
if (DataBus.EngineInfo == null) {
DetermineDriverActionForBEV();
}
}
private void DetermineDriverActionForBEV()
{
if (VehicleStopped) {
DrivingAction = DrivingAction.Halt;
DriverBehavior = DrivingBehavior.Halted;
}
else if (acceleration.Value() < 0)
{
else if (CycleIterator.LeftSample.PWheel.Value() < 0) {
DrivingAction = DrivingAction.Brake;
DriverBehavior = DrivingBehavior.Braking;
}
else
{
else {
DrivingAction = DrivingAction.Accelerate;
DriverBehavior = DrivingBehavior.Accelerating;
}
}
#endregion
}
#endregion
}
}
\ No newline at end of file
......@@ -36,9 +36,9 @@ namespace TUGraz.VectoCore.Tests.Integration.BatteryElectric
TestCase(E2_JOB, 7, 1, 4.3124, 117.0889, TestName = "E2 BEV TimeRun MeasuredSpeedGear RegionalDelivery"),
TestCase(E2_JOB, 8, 2, 28.7993, 125.4735, TestName = "E2 BEV TimeRun MeasuredSpeedGear UrbanDelivery"),
TestCase(E2_JOB, 9, 0, 1.1661, 120.0129, TestName = "E2 BEV TimeRun MeasuredSpeedPWheel LongHaul"),
TestCase(E2_JOB, 10, 1, 4.6925, 117.3748, TestName = "E2 BEV TimeRun MeasuredSpeedPWheel RegionalDelivery"),
TestCase(E2_JOB, 11, 2, 31.7336, 127.926, TestName = "E2 BEV TimeRun MeasuredSpeedPWheel UrbanDelivery"),
TestCase(E2_JOB, 9, 0, 1.1561, 119.9885, TestName = "E2 BEV TimeRun MeasuredSpeedPWheel LongHaul"),
TestCase(E2_JOB, 10, 1, 4.6791, 117.2513, TestName = "E2 BEV TimeRun MeasuredSpeedPWheel RegionalDelivery"),
TestCase(E2_JOB, 11, 2, 31.6519, 126.6695, TestName = "E2 BEV TimeRun MeasuredSpeedPWheel UrbanDelivery"),
TestCase(E3_JOB, 0, 0, 0.7916, 101.6194, TestName = "E3 BEV TimeRun MeasuredSpeed LongHaul"),
TestCase(E3_JOB, 1, 1, 3.3777, 104.792, TestName = "E3 BEV TimeRun MeasuredSpeed RegionalDelivery"),
......
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