Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit 131f3af8 authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

PWheel: implement IVehicleInfo, refactor: make properties instead of method,...

PWheel: implement IVehicleInfo, refactor: make properties instead of method, cyclegearbox: use 'old method' for AT when disengaged
parent 5300e8cb
Branches
Tags
No related merge requests found
......@@ -141,7 +141,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
new ModalDataContainer(data, ModWriter,
addReportResult: _mode == ExecutionMode.Declaration ? addReportResult : null,
writeEngineOnly: _engineOnlyMode,
filter: data.Cycle.CycleType.IsDistanceBased() ? modDataFilter : null) {
filter: data.Cycle.CycleType.IsDistanceBased() && ModalResults1Hz || ActualModalData ? modDataFilter : null) {
WriteAdvancedAux = data.AdvancedAux != null && data.AdvancedAux.AuxiliaryAssembly == AuxiliaryModel.Advanced,
WriteModalResults = _mode != ExecutionMode.Declaration || WriteModalResults
};
......
......@@ -126,24 +126,29 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
public CrossWindCorrectionMode CrossWindCorrectionMode { get; set; }
public Kilogram TotalVehicleWeight()
public Kilogram TotalVehicleWeight
{
get
{
var retVal = 0.0;
if (CurbWeight != null)
if (CurbWeight != null) {
retVal += CurbWeight.Value();
if (Loading != null)
}
if (Loading != null) {
retVal += Loading.Value();
}
return retVal.SI<Kilogram>();
}
}
public Kilogram TotalCurbWeight()
public Kilogram TotalCurbWeight
{
return CurbWeight ?? 0.SI<Kilogram>();
get { return CurbWeight ?? 0.SI<Kilogram>(); }
}
protected void ComputeRollResistanceAndReducedMassWheels()
{
if (TotalVehicleWeight() == 0.SI<Kilogram>()) {
if (TotalVehicleWeight == 0.SI<Kilogram>()) {
throw new VectoException("Total vehicle weight must be greater than 0! Set CurbWeight and Loading before!");
}
if (DynamicTyreRadius == null) {
......@@ -159,7 +164,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
continue;
}
var nrWheels = axle.TwinTyres ? 4 : 2;
var baseValue = (axle.AxleWeightShare * TotalVehicleWeight() * g / axle.TyreTestLoad / nrWheels).Value();
var baseValue = (axle.AxleWeightShare * TotalVehicleWeight * g / axle.TyreTestLoad / nrWheels).Value();
rrc += axle.AxleWeightShare * axle.RollResistanceCoefficient *
Math.Pow(baseValue, Physics.RollResistanceExponent - 1);
......@@ -211,10 +216,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
// vehicleData.AxleConfiguration.GetName(), vehicleData.AxleConfiguration.NumAxles(), vehicleData.AxleData.Count));
//}
if (vehicleData.TotalVehicleWeight() > gvwTotal) {
if (vehicleData.TotalVehicleWeight > gvwTotal) {
return new ValidationResult(
string.Format("Total Vehicle Weight is greater than GrossVehicleWeight! Weight: {0}, GVW: {1}",
vehicleData.TotalVehicleWeight(), gvwTotal));
vehicleData.TotalVehicleWeight, gvwTotal));
}
return ValidationResult.Success;
}
......
......@@ -336,7 +336,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
// }
// disengagedResponse = NextComponent.Request(absTime, dt, 0.SI<NewtonMeter>(), motoringSpeed);
//}
var disengagedResponse = NextComponent.Request(absTime, dt, 0.SI<NewtonMeter>(), null);
IResponse disengagedResponse;
if (GearboxType.AutomaticTransmission()) {
disengagedResponse = EngineIdleRequest(absTime, dt);
} else {
disengagedResponse = NextComponent.Request(absTime, dt, 0.SI<NewtonMeter>(), null);
}
if (TorqueConverter != null) {
TorqueConverter.Locked(CurrentState.InTorque, disengagedResponse.EngineSpeed);
}
......@@ -347,6 +352,30 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
return disengagedResponse;
}
private IResponse EngineIdleRequest(Second absTime, Second dt)
{
var disengagedResponse = NextComponent.Request(absTime, dt, 0.SI<NewtonMeter>(), DataBus.EngineIdleSpeed);
if (disengagedResponse is ResponseSuccess) {
return disengagedResponse;
}
var motoringSpeed = DataBus.EngineSpeed;
if (motoringSpeed.IsGreater(DataBus.EngineIdleSpeed)) {
var first = (ResponseDryRun)NextComponent.Request(absTime, dt, 0.SI<NewtonMeter>(), motoringSpeed, true);
try {
motoringSpeed = SearchAlgorithm.Search(motoringSpeed, first.DeltaDragLoad,
Constants.SimulationSettings.EngineIdlingSearchInterval,
getYValue: result => ((ResponseDryRun)result).DeltaDragLoad,
evaluateFunction: n => NextComponent.Request(absTime, dt, 0.SI<NewtonMeter>(), n, true),
criterion: result => ((ResponseDryRun)result).DeltaDragLoad.Value());
} catch (VectoException) {
Log.Warn("CycleGearbox could not find motoring speed for disengaged state.");
}
motoringSpeed = motoringSpeed.LimitTo(DataBus.EngineIdleSpeed, DataBus.EngineSpeed);
}
disengagedResponse = NextComponent.Request(absTime, dt, 0.SI<NewtonMeter>(), motoringSpeed);
return disengagedResponse;
}
protected override void DoWriteModalResults(IModalDataContainer container)
{
var avgInAngularSpeed = (PreviousState.InAngularVelocity + CurrentState.InAngularVelocity) / 2.0;
......@@ -397,7 +426,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
var nextGear = 0u;
var torqueConverterLocked = true;
foreach (var entry in future) {
if (entry.VehicleTargetSpeed.IsEqual(0)) {
if (entry.WheelAngularVelocity.IsEqual(0)) {
// vehicle is stopped, no next gear, engine should go to idle
break;
}
......@@ -421,7 +450,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
}
var future = DataBus.LookAhead(ModelData.TractionInterruption * 5);
foreach (var entry in future) {
if (entry.VehicleTargetSpeed.IsEqual(0)) {
if (entry.VehicleTargetSpeed != null && entry.VehicleTargetSpeed.IsEqual(0)) {
// vehicle is stopped, no next gear, engine should go to idle
break;
}
if (entry.WheelAngularVelocity != null && entry.WheelAngularVelocity.IsEqual(0)) {
// vehicle is stopped, no next gear, engine should go to idle
break;
}
......
......@@ -81,22 +81,18 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
public void Reset()
{
LeftSample.Reset();
LeftSample.MoveNext();
RightSample.Reset();
RightSample.MoveNext();
RightSample.MoveNext();
CycleIterator.Reset();
IdleStart = null;
}
public Second GetNextCycleTime()
{
if (RightSample.Current == null)
if (CycleIterator.RightSample == null) {
return null;
}
return RightSample.Current.Time - LeftSample.Current.Time;
return CycleIterator.RightSample.Time - CycleIterator.LeftSample.Time;
}
protected override void DoWriteModalResults(IModalDataContainer container)
......
......@@ -142,7 +142,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
public Newton RollingResistance(Radian gradient)
{
var weight = ModelData.TotalVehicleWeight();
var weight = ModelData.TotalVehicleWeight;
var gravity = Physics.GravityAccelleration;
var rollCoefficient = ModelData.TotalRollResistanceCoefficient;
......@@ -153,14 +153,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
protected internal Newton DriverAcceleration(MeterPerSquareSecond accelleration)
{
var retVal = ModelData.TotalVehicleWeight() * accelleration;
var retVal = ModelData.TotalVehicleWeight * accelleration;
Log.Debug("DriverAcceleration: {0}", retVal);
return retVal;
}
public Newton SlopeResistance(Radian gradient)
{
var retVal = ModelData.TotalVehicleWeight() * Physics.GravityAccelleration * Math.Sin(gradient.Value());
var retVal = ModelData.TotalVehicleWeight * Physics.GravityAccelleration * Math.Sin(gradient.Value());
Log.Debug("SlopeResistance: {0}", retVal);
return retVal;
}
......@@ -199,7 +199,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
public Kilogram VehicleMass
{
get { return ModelData.TotalCurbWeight(); }
get { return ModelData.TotalCurbWeight; }
}
public Kilogram VehicleLoading
......@@ -209,7 +209,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
public Kilogram TotalMass
{
get { return ModelData.TotalVehicleWeight(); }
get { return ModelData.TotalVehicleWeight; }
}
public class VehicleState
......
......@@ -152,6 +152,7 @@
<Compile Include="Models\SimulationComponent\Impl\AbstractGearbox.cs" />
<Compile Include="Models\SimulationComponent\Impl\ATGearbox.cs" />
<Compile Include="Models\SimulationComponent\Impl\ATShiftStrategy.cs" />
<Compile Include="Models\SimulationComponent\Impl\DrivingCycleEnumerator.cs" />
<Compile Include="Models\SimulationComponent\Impl\MeasuredSpeedDrivingCycle.cs" />
<Compile Include="Models\SimulationComponent\Impl\PTOCycleController.cs" />
<Compile Include="Models\SimulationComponent\Impl\PWheelCycle.cs" />
......
......@@ -99,7 +99,7 @@ namespace TUGraz.VectoCore.Tests.Integration
.AddComponent(engine);
var aux = new BusAuxiliariesAdapter(container, AdvancedAuxFile, "Coach",
vehicleData.TotalVehicleWeight(), engineData.ConsumptionMap, engineData.IdleSpeed);
vehicleData.TotalVehicleWeight, engineData.ConsumptionMap, engineData.IdleSpeed);
engine.Connect(aux.Port());
......
......@@ -316,7 +316,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
}
private static void RunJob(string jobFile, string expectedModFile, string actualModFile, string expectedSumFile,
string actualSumFile)
string actualSumFile, bool actualModData = false)
{
var fileWriter = new FileOutputWriter(jobFile);
var sumWriter = new SummaryDataContainer(fileWriter);
......@@ -324,6 +324,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
var inputData = JSONInputDataFactory.ReadJsonJob(jobFile);
var runsFactory = new SimulatorFactory(ExecutionMode.Engineering, inputData, fileWriter);
runsFactory.ActualModalData = actualModData;
jobContainer.AddRuns(runsFactory);
jobContainer.Execute();
......@@ -409,6 +410,16 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
@"TestData\MeasuredSpeed\Results\MeasuredSpeedGear.vsum", @"TestData\MeasuredSpeed\MeasuredSpeedGear.vsum");
}
[TestMethod]
public void MeasuredSpeed_Gear_TractionInterruption_Run()
{
RunJob(@"TestData\MeasuredSpeed\MeasuredSpeedGear_TractionInterruption.vecto",
@"TestData\MeasuredSpeed\Results\MeasuredSpeedGear_TractionInterruption_MeasuredSpeed_Gear_Rural_TractionInterruption.vmod",
@"TestData\MeasuredSpeed\MeasuredSpeedGear_TractionInterruption_MeasuredSpeed_Gear_Rural_TractionInterruption.vmod",
@"TestData\MeasuredSpeed\Results\MeasuredSpeedGear_TractionInterruption.vsum",
@"TestData\MeasuredSpeed\MeasuredSpeedGear_TractionInterruption.vsum", true);
}
[TestMethod]
public void MeasuredSpeed_Gear_Aux_Run()
{
......
......@@ -74,7 +74,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
Gears = new Dictionary<uint, GearData> { { 1, new GearData { Ratio = 2.0 } }, { 2, new GearData { Ratio = 3.5 } } }
}, 0.SI<KilogramSquareMeter>());
var cycle = new PWheelCycle(container, drivingCycle, 2.3,
var cycle = new PWheelCycle(container, drivingCycle, 2.3, null,
gearbox.ModelData.Gears.ToDictionary(g => g.Key, g => g.Value.Ratio));
Assert.AreEqual(container.CycleData.LeftSample.Time, 1.SI<Second>());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment