Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit 59163859 authored by Michael KRISPER's avatar Michael KRISPER
Browse files

moved pwheel test files

parent 3ebb5575
No related branches found
No related tags found
No related merge requests found
Showing
with 64 additions and 36 deletions
......@@ -143,6 +143,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
/// Power on the Wheels (only used in PWheel Mode).
/// </summary>
public Watt PWheel { get; set; }
/// <summary>
/// The angular velocity at the wheel. only used in PWheelCycle.
/// </summary>
public PerSecond WheelAngularVelocity;
}
}
}
\ No newline at end of file
......@@ -101,24 +101,43 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
};
}
var response = NextComponent.Request(absTime, dt, LeftSample.Current.Torque,
DataBus.ClutchClosed(absTime) ? LeftSample.Current.AngularVelocity : 0.SI<PerSecond>());
return DoHandleRequest(absTime, dt, LeftSample.Current.AngularVelocity);
}
AbsTime = absTime + dt;
protected IResponse DoHandleRequest(Second absTime, Second dt, PerSecond angularVelocity)
{
var response = NextComponent.Request(absTime, dt, LeftSample.Current.Torque, angularVelocity);
if (response is ResponseGearShift) {
response = NextComponent.Request(absTime, dt, LeftSample.Current.Torque, angularVelocity);
}
response.Switch()
.Case<ResponseUnderload>(r => {
Log.Warn("PowertrainDrivingCycle got an underload response. Using PDrag.");
response = new ResponseSuccess();
var torqueInterval = -r.Delta / (angularVelocity.IsEqual(0) ? 10.RPMtoRad() : angularVelocity);
var torque = SearchAlgorithm.Search(LeftSample.Current.Torque, r.Delta, torqueInterval,
getYValue: result => ((ResponseDryRun)result).DeltaDragLoad,
evaluateFunction: t => NextComponent.Request(absTime, dt, t, angularVelocity, true),
criterion: y =>
((ResponseDryRun)y).DeltaDragLoad.IsEqual(0.SI<Watt>(), Constants.SimulationSettings.EnginePowerSearchTolerance));
response = NextComponent.Request(absTime, dt, torque, angularVelocity);
})
.Case<ResponseOverload>(r => {
Log.Warn("PowertrainDrivingCycle got an underload response. Using PFullLoad.");
response = new ResponseSuccess();
angularVelocity = SearchAlgorithm.Search(angularVelocity, r.Delta, 50.RPMtoRad(),
getYValue: result => ((ResponseDryRun)result).DeltaFullLoad,
evaluateFunction: n => NextComponent.Request(absTime, dt, LeftSample.Current.Torque, n, true),
criterion: y => ((ResponseDryRun)y).DeltaFullLoad.Abs() < Constants.SimulationSettings.EnginePowerSearchTolerance);
response = NextComponent.Request(absTime, dt, LeftSample.Current.Torque, angularVelocity);
})
.Case<ResponseSuccess>(() => { })
.Default(
r => { throw new UnexpectedResponseException("PowertrainDrivingCycle received an unexpected response.", r); });
r => { throw new UnexpectedResponseException("MeasuredSpeedDrivingCycle received an unexpected response.", r); });
if (!(response is ResponseSuccess)) {
throw new UnexpectedResponseException("MeasuredSpeedDrivingCycle received an unexpected response.", response);
}
AbsTime = absTime + dt;
return response;
}
......@@ -184,7 +203,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
/// <summary>
/// Driving Cycle for the PWheel driving cycle.
/// </summary>
public class PWheelCycle : PowertrainDrivingCycle, IDriverInfo, IClutchInfo
public class PWheelCycle : PowertrainDrivingCycle, IDriverInfo
{
/// <summary>
/// Initializes a new instance of the <see cref="PWheelCycle"/> class.
......@@ -194,14 +213,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
/// <param name="axleRatio">The axle ratio.</param>
/// <param name="gearRatios"></param>
public PWheelCycle(IVehicleContainer container, DrivingCycleData cycle, double axleRatio,
IReadOnlyDictionary<uint, double> gearRatios)
: base(container, cycle)
IDictionary<uint, double> gearRatios) : base(container, cycle)
{
// just to ensure that null-gear has ratio 1
gearRatios[0] = 1;
foreach (var entry in Data.Entries) {
// calculate angularVelocity on Wheel: n / (axelRatio * gearRatio)
entry.AngularVelocity = entry.AngularVelocity /
(entry.Gear == 0 ? axleRatio : axleRatio * gearRatios[entry.Gear]);
entry.Torque = entry.PWheel / entry.AngularVelocity;
entry.WheelAngularVelocity = entry.AngularVelocity / (axleRatio * gearRatios[entry.Gear]);
entry.Torque = entry.PWheel / entry.WheelAngularVelocity;
}
}
......@@ -211,7 +230,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
return new ResponseCycleFinished { Source = this };
}
return base.Request(absTime, dt);
// interval exceeded
if ((absTime + dt).IsGreater(RightSample.Current.Time)) {
return new ResponseFailTimeInterval {
AbsTime = absTime,
Source = this,
DeltaT = RightSample.Current.Time - absTime
};
}
return DoHandleRequest(absTime, dt, LeftSample.Current.WheelAngularVelocity);
}
......@@ -240,11 +268,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
}
#endregion
public virtual bool ClutchClosed(Second absTime)
{
return LeftSample.Current.Gear != 0;
}
}
/// <summary>
......@@ -353,10 +376,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
})
.Case<ResponseSuccess>(() => { })
.Default(
r => { throw new UnexpectedResponseException("PowertrainDrivingCycle received an unexpected response.", r); });
r => { throw new UnexpectedResponseException("MeasuredSpeedDrivingCycle received an unexpected response.", r); });
if (!(response is ResponseSuccess)) {
throw new UnexpectedResponseException("PowertrainDrivingCycle received an unexpected response.", response);
throw new UnexpectedResponseException("MeasuredSpeedDrivingCycle received an unexpected response.", response);
}
AbsTime = absTime + dt;
......
......@@ -66,8 +66,8 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
Assert.AreEqual(container.CycleData.LeftSample.Time, 1.SI<Second>());
Assert.AreEqual(container.CycleData.RightSample.Time, 2.SI<Second>());
Assert.AreEqual(1748.RPMtoRad() / (2.3 * 3.5), container.CycleData.LeftSample.AngularVelocity);
Assert.AreEqual(1400.RPMtoRad() / (2.3 * 3.5), container.CycleData.RightSample.AngularVelocity);
Assert.AreEqual(1748.RPMtoRad() / (2.3 * 3.5), container.CycleData.LeftSample.WheelAngularVelocity);
Assert.AreEqual(1400.RPMtoRad() / (2.3 * 3.5), container.CycleData.RightSample.WheelAngularVelocity);
Assert.AreEqual(89.SI().Kilo.Watt, container.CycleData.LeftSample.PWheel);
Assert.AreEqual(120.SI().Kilo.Watt, container.CycleData.RightSample.PWheel);
......@@ -177,7 +177,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
Assert.IsTrue(jobContainer.Runs.All(r => r.Success), string.Concat(jobContainer.Runs.Select(r => r.ExecException)));
ResultFileHelper.TestModFile(@"TestData\Pwheel\Results\P_wheel_in\Atego_HDVCO2_RD_#1_AuxStd.vmod",
ResultFileHelper.TestModFile(@"TestData\Pwheel\Results\Atego_HDVCO2_RD_#1_AuxStd.vmod",
@"TestData\Pwheel\Pwheel_ultimate_RD_#1_Pwheel_AuxStd.vmod", testRowCount: false);
}
}
......
......@@ -7,13 +7,13 @@
},
"Body": {
"SavedInDeclMode": false,
"VehicleFile": "..\\Components\\Pwheel\\Atego.vveh",
"EngineFile": "..\\Components\\Pwheel\\OM906.veng",
"GearboxFile": "..\\Components\\Pwheel\\G_85-6_6_7-0_17.vgbx",
"VehicleFile": "Atego.vveh",
"EngineFile": "OM906.veng",
"GearboxFile": "G_85-6_6_7-0_17.vgbx",
"Cycles": [
"..\\Components\\Pwheel\\Gear2_pt1_rep1_actual.vdri"
"Gear2_pt1_rep1_actual.vdri"
],
"VACC": "..\\Components\\Pwheel\\Truck.vacc",
"VACC": "Truck.vacc",
"EngineOnlyMode": false,
"StartStop": {
"Enabled": false,
......
......@@ -7,13 +7,13 @@
},
"Body": {
"SavedInDeclMode": false,
"VehicleFile": "..\\Components\\Pwheel\\Atego.vveh",
"EngineFile": "..\\Components\\Pwheel\\OM906.veng",
"GearboxFile": "..\\Components\\Pwheel\\G_85-6_6_7-0_17.vgbx",
"VehicleFile": "Atego.vveh",
"EngineFile": "OM906.veng",
"GearboxFile": "G_85-6_6_7-0_17.vgbx",
"Cycles": [
"..\\Components\\Pwheel\\RD_#1_Pwheel_AuxStd.vdri"
"RD_#1_Pwheel_AuxStd.vdri"
],
"VACC": "..\\Components\\Pwheel\\Truck.vacc",
"VACC": "Truck.vacc",
"EngineOnlyMode": false,
"StartStop": {
"Enabled": false,
......
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