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

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

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

Merge pull request #296 in VECTO/vecto-sim from ~EMKRISPMI/vecto-sim:bugfix/VECTO-368-validation-error-on-gears-ratio to master

* commit '79e80421':
  added RangeOrNaN validation attribute for Gear-Ratio. Switched to TC-Ratio for NonLockedGears
  VECTO-386 validation fails on gear's ratio
parents 5f563e29 79e80421
No related branches found
No related tags found
No related merge requests found
......@@ -213,6 +213,17 @@ namespace TUGraz.VectoCommon.Utils
}
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = true)]
public class RangeOrNaN : RangeAttribute
{
public override bool IsValid(object value)
{
return double.IsNaN((double)value) || base.IsValid(value);
}
public RangeOrNaN(double minimum, double maximum) : base(minimum, maximum) {}
}
/// <summary>
/// Attribute which validates the Min-Max Range of an SI Object.
/// </summary>
......
......@@ -141,13 +141,15 @@ namespace TUGraz.VectoCore.Models.Simulation.Data
for (var angularVelocity = engineData.IdleSpeed;
angularVelocity < engineData.FullLoadCurve.RatedSpeed;
angularVelocity += 2.0 / 3.0 * (engineData.FullLoadCurve.RatedSpeed - engineData.IdleSpeed) / 10.0) {
if (!gear.Value.HasLockedGear)
continue;
var velocity = angularVelocity / gear.Value.Ratio / angledriveRatio / axlegearRatio * dynamicTyreRadius;
if (velocity > maxSpeed) {
continue;
}
for (var inTorque = engineData.FullLoadCurve.FullLoadStationaryTorque(angularVelocity) / 3;
inTorque < engineData.FullLoadCurve.FullLoadStationaryTorque(angularVelocity);
inTorque += 2.0 / 3.0 * engineData.FullLoadCurve.FullLoadStationaryTorque(angularVelocity) / 10.0) {
......
......@@ -41,7 +41,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox
[ValidateObject]
public TransmissionLossMap LossMap { get; internal set; }
[Required, Range(double.Epsilon, 25)]
[Required, RangeOrNaN(double.Epsilon, 25)]
public double Ratio { get; internal set; }
}
......
......@@ -186,10 +186,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
}
if (!_gearbox.TorqueConverterLocked && Data.Gears.ContainsKey(gear + 1) && Data.Gears[gear + 1].HasTorqueConverter) {
// C -> C upshift
var gearRatio = Data.Gears[gear + 1].Ratio / Data.Gears[gear].Ratio;
var gearRatio = Data.Gears[gear + 1].TorqueConverterRatio / Data.Gears[gear].TorqueConverterRatio;
var minEnginseSpeed = VectoMath.Min(700.RPMtoRad(), gearRatio * (DataBus.EngineN80hSpeed - 150.RPMtoRad()));
var nextGbxInSpeed = outAngularVelocity * Data.Gears[gear + 1].Ratio;
var nextGbxInTorque = outTorque / Data.Gears[gear + 1].Ratio;
var nextGbxInSpeed = outAngularVelocity * Data.Gears[gear + 1].TorqueConverterRatio;
var nextGbxInTorque = outTorque / Data.Gears[gear + 1].TorqueConverterRatio;
var tcOperatingPoint = _gearbox.TorqueConverter.FindOperatingPoint(nextGbxInTorque, nextGbxInSpeed);
if (tcOperatingPoint.InAngularVelocity.IsGreater(minEnginseSpeed) &&
DataBus.EngineStationaryFullPower(tcOperatingPoint.InAngularVelocity)
......
......@@ -96,13 +96,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
public Watt GearboxLoss()
{
//var outTorque = ModelData.Gears[Gear].LossMap.GetOutTorque(inAngularVelocity, inTorque, true);
//var torqueLoss = inTorque - outTorque * ModelData.Gears[Gear].Ratio;
//return torqueLoss * inAngularVelocity;
var ratio = ModelData.Gears[PreviousState.Gear].HasLockedGear
? ModelData.Gears[PreviousState.Gear].Ratio
: ModelData.Gears[PreviousState.Gear].TorqueConverterRatio;
return (PreviousState.TransmissionTorqueLoss +
PreviousState.InertiaTorqueLossOut / ModelData.Gears[PreviousState.Gear].Ratio) * PreviousState.InAngularVelocity;
PreviousState.InertiaTorqueLossOut / ratio) * PreviousState.InAngularVelocity;
}
#endregion
......
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