diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs b/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs index 998ae37ac35eb54fbbe18fcf24215026bba6a16a..e720ce146960f002f16732fdc61eeae80be447ba 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs @@ -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 }; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs index c099332a7e774e99d42b7c7ba98eac1ce2d670b2..a6e1f7d7a107f806dda4eb2a22a9c1abc19b1975 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs @@ -126,24 +126,29 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data public CrossWindCorrectionMode CrossWindCorrectionMode { get; set; } - public Kilogram TotalVehicleWeight() + public Kilogram TotalVehicleWeight { - var retVal = 0.0; - if (CurbWeight != null) - retVal += CurbWeight.Value(); - if (Loading != null) - retVal += Loading.Value(); - return retVal.SI<Kilogram>(); + get + { + var retVal = 0.0; + if (CurbWeight != null) { + retVal += CurbWeight.Value(); + } + 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; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs index ba0de23edff7b978886aab17a72c66f3a669b65b..3274a5a568143d798bfe50d86e5464bf48064890 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs @@ -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; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PTOCycleController.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PTOCycleController.cs index e2708ce6fb46378df0fed771130faebaac42744b..5ae1b9637b2f333929bd086c3a0252047016dee9 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PTOCycleController.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PTOCycleController.cs @@ -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) diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs index f5abf10e10be1be0698e6672eeef4f97ed0438d4..eacb4b4a185154d2c3e8f2fb030abc73cb1e032b 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs @@ -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 diff --git a/VectoCore/VectoCore/VectoCore.csproj b/VectoCore/VectoCore/VectoCore.csproj index 0f2e04640fc27c687a8bf4433a2c17eb3b6e9d76..a84ec69b247ee04968fb9da7d9591d65e2af5850 100644 --- a/VectoCore/VectoCore/VectoCore.csproj +++ b/VectoCore/VectoCore/VectoCore.csproj @@ -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" /> diff --git a/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs b/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs index f797490a05be21dfd9ae0c0b4d565e4f93cde4ee..8d6587d16dac4abaf6aa8b6f6b32e741fedc77c6 100644 --- a/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs +++ b/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.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()); diff --git a/VectoCore/VectoCoreTest/Models/Simulation/MeasuredSpeedModeTest.cs b/VectoCore/VectoCoreTest/Models/Simulation/MeasuredSpeedModeTest.cs index f9f15ceee5faa297993587575a74670aa083cb9d..c5e7dba60beac79912e1ff02eea7d503162ef0ca 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/MeasuredSpeedModeTest.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/MeasuredSpeedModeTest.cs @@ -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() { diff --git a/VectoCore/VectoCoreTest/Models/Simulation/PwheelModeTests.cs b/VectoCore/VectoCoreTest/Models/Simulation/PwheelModeTests.cs index d3f9f0b7ed654b93e6f6f5c5b6125009ebf7049b..c5cebefa70f4f04103787324a0caf00edb6791ad 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/PwheelModeTests.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/PwheelModeTests.cs @@ -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>());