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 d136e010 authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

apply torque losses only when avgspeed >0

parent 5a8af67b
No related branches found
No related tags found
No related merge requests found
......@@ -218,6 +218,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
var avgOutAngularVelocity = (PreviousState.OutAngularVelocity + outAngularVelocity) / 2.0;
var inTorqueLossResult = ModelData.Gears[gear].LossMap.GetTorqueLoss(avgOutAngularVelocity, outTorque);
if (avgOutAngularVelocity.IsEqual(0, 1e-9)) {
inTorqueLossResult.Value = 0.SI<NewtonMeter>();
}
var inTorque = outTorque / ModelData.Gears[gear].Ratio + inTorqueLossResult.Value;
var inAngularVelocity = outAngularVelocity * ModelData.Gears[gear].Ratio;
......@@ -411,12 +414,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
if (CurrentState.TorqueLossResult != null && CurrentState.TorqueLossResult.Extrapolated) {
Log.Warn(
"Gear {0} LossMap data was extrapolated: range for loss map is not sufficient: n:{1}, torque:{2}, ratio:{3}",
Gear, CurrentState.OutAngularVelocity.ConvertToRoundsPerMinute(), CurrentState.OutTorque,
Gear, CurrentState.OutAngularVelocity.ConvertToRoundsPerMinute(), CurrentState.OutTorque,
ModelData.Gears[Gear].Ratio);
if (DataBus.ExecutionMode == ExecutionMode.Declaration) {
throw new VectoException(
"Gear {0} LossMap data was extrapolated in Declaration Mode: range for loss map is not sufficient: n:{1}, torque:{2}, ratio:{3}",
Gear, CurrentState.InAngularVelocity.ConvertToRoundsPerMinute(), CurrentState.InTorque,
Gear, CurrentState.InAngularVelocity.ConvertToRoundsPerMinute(), CurrentState.InTorque,
ModelData.Gears[Gear].Ratio);
}
}
......
......@@ -61,6 +61,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
{
_lossMap = lossMap;
_ratio = ratio;
_primaryRetarder = container.RunData != null && container.RunData.Retarder.Type == RetarderType.TransmissionInputRetarder;
}
public IResponse Initialize(NewtonMeter torque, PerSecond angularVelocity)
......@@ -76,7 +77,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
return NextComponent.Request(absTime, dt, torque, angularVelocity, dryRun);
}
var avgAngularSpeed = (PreviousState.InAngularVelocity + angularVelocity) / 2.0;
var retarderTorqueLoss = _lossMap.GetTorqueLoss(avgAngularSpeed * _ratio) * _ratio;
var retarderTorqueLoss = avgAngularSpeed.IsEqual(0, 1e-9) ? 0.SI<NewtonMeter>() : _lossMap.GetTorqueLoss(avgAngularSpeed * _ratio) * _ratio;
CurrentState.SetState(torque + retarderTorqueLoss, angularVelocity, torque, angularVelocity);
return NextComponent.Request(absTime, dt, CurrentState.InTorque, CurrentState.InAngularVelocity, dryRun);
}
......
......@@ -80,6 +80,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
var avgOutAngularVelocity = (PreviousState.OutAngularVelocity + outAngularVelocity) / 2.0;
var torqueLossResult = ModelData.LossMap.GetTorqueLoss(avgOutAngularVelocity, outTorque);
if (avgOutAngularVelocity.IsEqual(0, 1e-9)) {
torqueLossResult.Value = 0.SI<NewtonMeter>();
}
var inTorque = outTorque / ModelData.Ratio + torqueLossResult.Value;
CurrentState.SetState(inTorque, inAngularVelocity, outTorque, outAngularVelocity);
......@@ -105,12 +108,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
{
if (CurrentState.TorqueLossResult.Extrapolated) {
Log.Warn("{2} LossMap data was extrapolated: range for loss map is not sufficient: n:{0}, torque:{1}",
CurrentState.OutAngularVelocity.ConvertToRoundsPerMinute(), CurrentState.OutTorque, GetType().Name);
CurrentState.OutAngularVelocity.ConvertToRoundsPerMinute(), CurrentState.OutTorque, GetType().Name);
if (DataBus.ExecutionMode == ExecutionMode.Declaration) {
throw new VectoException(
"{2} LossMap data was extrapolated in Declaration Mode: range for loss map is not sufficient: n:{0}, torque:{1}",
CurrentState.OutAngularVelocity.ConvertToRoundsPerMinute(), CurrentState.OutTorque, GetType().Name);
CurrentState.OutAngularVelocity.ConvertToRoundsPerMinute(), CurrentState.OutTorque, GetType().Name);
}
}
AdvanceState();
......
......@@ -107,7 +107,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
CurrentState.Distance = PreviousState.Distance + PreviousState.Velocity * dt + acceleration * dt * dt / 2;
CurrentState.DriverAcceleration = DriverAcceleration(acceleration);
CurrentState.RollingResistance = RollingResistance(gradient);
CurrentState.RollingResistance = (PreviousState.Velocity + CurrentState.Velocity).IsEqual(0, 1e-9) ? 0.SI<Newton>() : RollingResistance(gradient);
try {
CurrentState.AirDragResistance = AirDragResistance(PreviousState.Velocity, CurrentState.Velocity);
} catch (VectoException ex) {
......
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