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

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

removed static from SteeringPump, some resharper refactorings

parent 563a95a9
No related branches found
No related tags found
No related merge requests found
......@@ -96,7 +96,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter
retVal.CurbWeight += mission.BodyCurbWeight + mission.TrailerCurbWeight;
retVal.Loading = loading;
retVal.DynamicTyreRadius =
DeclarationData.DynamicTyreRadius(data.Axles[DeclarationData.PoweredAxle()].Wheels, "5° DC Rims"); // TODO!
DeclarationData.DynamicTyreRadius(data.Axles[DeclarationData.PoweredAxle()].Wheels); // TODO!
var aerodynamicDragArea = data.AirDragArea + mission.DeltaCdA;
......@@ -252,7 +252,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter
aux.ID = Constants.Auxiliaries.IDs.Fan;
break;
case AuxiliaryType.SteeringPump:
aux.PowerDemand = SteeringPump.Lookup(mission, hvdClass, auxData.Technology);
aux.PowerDemand = DeclarationData.SteeringPump.Lookup(mission, hvdClass, auxData.Technology);
aux.ID = Constants.Auxiliaries.IDs.SteeringPump;
break;
case AuxiliaryType.HVAC:
......
......@@ -35,7 +35,6 @@ using System.Linq;
using TUGraz.VectoCommon.InputData;
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.Configuration;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox;
......@@ -54,7 +53,6 @@ namespace TUGraz.VectoCore.Models.Declaration
private SteeringPump _steeringPump;
private WHTCCorrection _whtcCorrection;
private AirDrag _airDrag;
private TorqueConverter _torqueConverter;
private StandardBodies _standardBodies;
private Payloads _payloads;
......@@ -83,7 +81,7 @@ namespace TUGraz.VectoCore.Models.Declaration
get { return Instance()._electricSystem ?? (Instance()._electricSystem = new ElectricSystem()); }
}
public static Meter DynamicTyreRadius(string wheels, string rims)
public static Meter DynamicTyreRadius(string wheels)
{
var wheelsEntry = Wheels.Lookup(wheels.RemoveWhitespace());
return wheelsEntry.DynamicTyreRadius * wheelsEntry.CircumferenceFactor / (2 * Math.PI);
......@@ -147,11 +145,6 @@ namespace TUGraz.VectoCore.Models.Declaration
get { return Instance()._airDrag ?? (Instance()._airDrag = new AirDrag()); }
}
public static TorqueConverter TorqueConverter
{
get { return Instance()._torqueConverter ?? (Instance()._torqueConverter = new TorqueConverter()); }
}
public static int PoweredAxle()
{
return 1;
......@@ -223,8 +216,8 @@ namespace TUGraz.VectoCore.Models.Declaration
public static readonly KilogramSquareMeter Inertia = 0.SI<KilogramSquareMeter>();
public static readonly MeterPerSecond TruckMaxAllowedSpeed = 85.KMPHtoMeterPerSecond();
public static double ShiftPolygonRPMMargin = 7;
private static double ShiftPolygonEngineFldMargin = 0.98;
public const double ShiftPolygonRPMMargin = 7;
private const double ShiftPolygonEngineFldMargin = 0.98;
public static readonly Second MinTimeBetweenGearshifts = 2.SI<Second>();
public static readonly Second DownshiftAfterUpshiftDelay = 10.SI<Second>();
......@@ -244,10 +237,8 @@ namespace TUGraz.VectoCore.Models.Declaration
public static ShiftPolygon ComputeShiftPolygon(int gear, FullLoadCurve fullLoadCurve,
IList<ITransmissionInputData> gears, CombustionEngineData engine, double axlegearRatio, Meter dynamicTyreRadius)
{
var engineSpeed85kmhLastGear = ComputeEngineSpeed85kmh(gears[gears.Count - 1], axlegearRatio, dynamicTyreRadius,
engine);
//var engineSpeed85kmhSecondToLastGear = ComputeEngineSpeed85kmh(gears[gears.Count - 2], axlegearRatio,
// dynamicTyreRadius, engine);
// ReSharper disable once InconsistentNaming
var engineSpeed85kmhLastGear = ComputeEngineSpeed85kmh(gears[gears.Count - 1], axlegearRatio, dynamicTyreRadius);
var nVHigh = VectoMath.Min(engineSpeed85kmhLastGear, engine.FullLoadCurve.RatedSpeed);
......@@ -289,11 +280,13 @@ namespace TUGraz.VectoCore.Models.Declaration
var gearRatio = gears[gear].Ratio / gears[gear + 1].Ratio;
var rpmMarginFactor = 1 + ShiftPolygonRPMMargin / 100.0;
// ReSharper disable InconsistentNaming
var p2p = new Point(p2.X * gearRatio * rpmMarginFactor, p2.Y / gearRatio);
var p3p = new Point(p3.X * gearRatio * rpmMarginFactor, p3.Y / gearRatio);
var p6p = new Point(p6.X * gearRatio * rpmMarginFactor, p6.Y / gearRatio);
var edgeP6pP3p = new Edge(p6p, p3p);
var p3pExt = new Point((1.1 * p5.Y - edgeP6pP3p.OffsetXY) / edgeP6pP3p.SlopeXY, 1.1 * p5.Y);
// ReSharper restore InconsistentNaming
upShift = IntersectShiftPolygon(new[] { p4, p7, p5 }.ToList(), new[] { p2p, p6p, p3pExt }.ToList())
.Select(point => new ShiftPolygon.ShiftPolygonEntry() {
......@@ -339,18 +332,11 @@ namespace TUGraz.VectoCore.Models.Declaration
.ToList();
}
internal static PerSecond ComputeEngineSpeed85kmh(ITransmissionInputData gear, double axleRatio,
Meter dynamicTyreRadius, CombustionEngineData engine)
// ReSharper disable once InconsistentNaming
private static PerSecond ComputeEngineSpeed85kmh(ITransmissionInputData gear, double axleRatio,
Meter dynamicTyreRadius)
{
var engineSpeed = TruckMaxAllowedSpeed / dynamicTyreRadius * axleRatio * gear.Ratio;
//if (engineSpeed < engine.IdleSpeed) {
// throw new VectoException("engine speed at velocity {0} in gear {1} is below engine's idle speed! {2}",
// DeclarationData.Gearbox.TruckMaxAllowedSpeed, gear.Gear, engineSpeed);
//}
//if (engineSpeed > engine.FullLoadCurve.FullLoadEntries.Last().EngineSpeed) {
// throw new VectoException("engine speed at velocity {0} in gear {1} is above engine's max speed! {2}",
// DeclarationData.Gearbox.TruckMaxAllowedSpeed, gear.Gear, engineSpeed);
//}
return engineSpeed;
}
......@@ -419,13 +405,13 @@ namespace TUGraz.VectoCore.Models.Declaration
}
}
public static IEnumerable<string> AuxiliaryIDs()
{
return new[] {
Constants.Auxiliaries.IDs.Fan, Constants.Auxiliaries.IDs.SteeringPump,
Constants.Auxiliaries.IDs.HeatingVentilationAirCondition, Constants.Auxiliaries.IDs.ElectricSystem,
Constants.Auxiliaries.IDs.PneumaticSystem
};
}
//public static IEnumerable<string> AuxiliaryIDs()
//{
// return new[] {
// Constants.Auxiliaries.IDs.Fan, Constants.Auxiliaries.IDs.SteeringPump,
// Constants.Auxiliaries.IDs.HeatingVentilationAirCondition, Constants.Auxiliaries.IDs.ElectricSystem,
// Constants.Auxiliaries.IDs.PneumaticSystem
// };
//}
}
}
\ No newline at end of file
......@@ -40,7 +40,7 @@ namespace TUGraz.VectoCore.Models.Declaration
{
public sealed class SteeringPump
{
public static Watt Lookup(MissionType mission, VehicleClass hdvClass, IEnumerable<string> technologies)
public Watt Lookup(MissionType mission, VehicleClass hdvClass, IEnumerable<string> technologies)
{
var baseLookup = new SteeringPumpBaseLine();
var axleLookup = new SteeringPumpAxles();
......
......@@ -151,7 +151,6 @@
<Compile Include="Models\Declaration\Segments.cs" />
<Compile Include="Models\Declaration\StandardBodies.cs" />
<Compile Include="Models\Declaration\SteeringPump.cs" />
<Compile Include="Models\Declaration\TorqueConverter.cs" />
<Compile Include="Models\Declaration\VehicleClass.cs" />
<Compile Include="Models\Declaration\Wheels.cs" />
<Compile Include="Models\Declaration\WHTCCorrection.cs" />
......
......@@ -101,6 +101,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration
Assert.AreEqual(expectedPt1, DeclarationData.PT1.Lookup(rpm.RPMtoRad()).Value(), Tolerance);
}
[TestCase]
public void PT1ExceptionsTest()
{
// EXTRAPOLATE
......@@ -222,48 +223,6 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration
crossWindCorrectionCurve.EffectiveAirDragArea(kmph.KMPHtoMeterPerSecond()));
}
[
// fixed points
TestCase(150, 1.000, 1.000, 0.00),
TestCase(150, 1.100, 1.000, -40.34),
TestCase(150, 1.222, 1.000, -80.34),
TestCase(150, 1.375, 1.000, -136.11),
TestCase(150, 1.571, 1.000, -216.52),
TestCase(150, 1.833, 1.000, -335.19),
TestCase(150, 2.200, 1.000, -528.77),
TestCase(150, 2.750, 1.000, -883.40),
TestCase(150, 4.400, 1.000, -2462.17),
TestCase(150, 11.000, 1.000, -16540.98),
// interpolated
TestCase(150, 1.0025, 1.0, 0.0),
TestCase(150, 1.0525, 1.0, -20.17),
TestCase(150, 1.161, 1.0, -60.34),
TestCase(150, 1.2985, 1.0, -108.225),
TestCase(150, 1.473, 1.0, -176.315),
TestCase(150, 1.702, 1.0, -275.855),
TestCase(150, 2.0165, 1.0, -431.98),
TestCase(150, 2.475, 1.0, -706.085),
TestCase(150, 3.575, 1.0, -1672.785),
TestCase(150, 7.7, 1.0, -9501.575),
// extrapolated
TestCase(150, 0.5, 1.0, 0.0),
TestCase(150, 12.0, 1.0, -18674.133), // = (12-4.4)*(-16540.98- -2462.17)/(11-4.4)+ -2462.17
]
public void DefaultTcTest(double referenceRpm, double nu, double mu, double torque)
{
var referenceSpeed = referenceRpm.SI<PerSecond>();
var r = new Random();
var muLookup = DeclarationData.TorqueConverter.LookupMu(nu);
Assert.AreEqual(muLookup, mu);
var angularSpeed = r.Next(1000).SI<PerSecond>();
var torqueLookup = DeclarationData.TorqueConverter.LookupTorque(nu, angularSpeed, referenceSpeed);
AssertHelper.AreRelativeEqual(
torque.SI<NewtonMeter>() * Math.Pow((angularSpeed / referenceSpeed).Cast<Scalar>(), 2), torqueLookup);
}
[
TestCase(MissionType.LongHaul, "Standard technology", 1200, 0.7),
TestCase(MissionType.RegionalDelivery, "Standard technology", 1000, 0.7),
......@@ -340,8 +299,9 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration
AssertHelper.AreRelativeEqual(expected[i],
DeclarationData.HeatingVentilationAirConditioning.Lookup(_missions[i], vehicleClass));
} else {
var i1 = i;
AssertHelper.Exception<VectoException>(
() => DeclarationData.HeatingVentilationAirConditioning.Lookup(_missions[i], vehicleClass));
() => DeclarationData.HeatingVentilationAirConditioning.Lookup(_missions[i1], vehicleClass));
}
}
}
......@@ -433,7 +393,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration
{
// mk remark: made the test call with 4 axle params, so that the test name is clear in the test explorer.
AssertHelper.AreRelativeEqual(expected,
SteeringPump.Lookup(mission, hdvClass,
DeclarationData.SteeringPump.Lookup(mission, hdvClass,
new[] { axle1, axle2, axle3, axle4 }.TakeWhile(a => a != null).ToArray()));
}
......@@ -449,7 +409,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration
]
public void Aux_SteeringPumpLookupFail(MissionType mission, VehicleClass hdvClass, params string[] tech)
{
AssertHelper.Exception<VectoException>(() => SteeringPump.Lookup(mission, hdvClass, tech));
AssertHelper.Exception<VectoException>(() => DeclarationData.SteeringPump.Lookup(mission, hdvClass, tech));
}
[
......@@ -700,7 +660,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration
Assert.AreEqual(deltaCdA.SI<SquareMeter>(), m.DeltaCdA);
}
public void EqualAcceleration(AccelerationCurveData data, double velocity, double acceleration,
private static void EqualAcceleration(AccelerationCurveData data, double velocity, double acceleration,
double deceleration)
{
var entry = data.Lookup(velocity.KMPHtoMeterPerSecond());
......@@ -708,7 +668,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration
Assert.AreEqual(entry.Deceleration.Value(), deceleration, Tolerance);
}
public void TestAcceleration(AccelerationCurveData data)
private static void TestAcceleration(AccelerationCurveData data)
{
// FIXED POINTS
EqualAcceleration(data, 0, 1, -1);
......
......@@ -79,7 +79,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
DeclarationData.Fan.Lookup(MissionType.LongHaul, "Hydraulic driven - Constant displacement pump"));
aux.AddConstant("PS", DeclarationData.PneumaticSystem.Lookup(mission, "Medium Supply 1-stage"));
aux.AddConstant("STP",
SteeringPump.Lookup(MissionType.LongHaul, hdvClass,
DeclarationData.SteeringPump.Lookup(MissionType.LongHaul, hdvClass,
new[] { "Variable displacement mech. controlled" }));
aux.AddConstant("ES", DeclarationData.ElectricSystem.Lookup(mission));
aux.AddConstant("AC",
......
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