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

some refactoring, more testcases with P3 hybrid configuration work

parent 92c61c71
No related branches found
No related tags found
No related merge requests found
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using TUGraz.VectoCommon.InputData;
using TUGraz.VectoCommon.Utils;
......@@ -10,5 +12,53 @@ namespace TUGraz.VectoCommon.Models {
public uint NextGear { get; set; }
public bool GearboxInNeutral { get; set; }
public bool CombustionEngineOn { get; set; }
public HybridResultEntry EvaluatedSolution { get; set; }
}
[DebuggerDisplay("{U}: {Score} - G{Gear}")]
public class HybridResultEntry
{
public double U { get; set; }
public HybridStrategyResponse Setting { get; set; }
public IResponse Response { get; set; }
public double Score { get { return (FuelCosts + EqualityFactor * (BatCosts + ICEStartPenalty1) * SoCPenalty + ICEStartPenalty2) / GearshiftPenalty; } }
public double FuelCosts { get; set; }
public double BatCosts { get; set; }
public double SoCPenalty { get; set; }
public double EqualityFactor { get; set; }
public double GearshiftPenalty { get; set; }
public double ICEStartPenalty1 { get; set; }
public double ICEStartPenalty2 { get; set; }
public uint Gear { get; set; }
public bool ICEOff { get; set; }
public HybridConfigurationIgnoreReason IgnoreReason { get; set; }
}
[Flags]
public enum HybridConfigurationIgnoreReason
{
NotEvaluated = 0,
EngineSpeedTooLow = 1 << 2,
EngineSpeedTooHigh = 1 << 3,
EngineTorqueDemandTooHigh = 1 << 4,
EngineTorqueDemandTooLow = 1 << 5,
EngineSpeedAboveUpshift = 1 << 6,
EngineSpeedBelowDownshift = 1 << 7,
NoResponseAvailable = 1 << 8,
Evaluated = 1 << 9,
}
}
\ No newline at end of file
......@@ -295,6 +295,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
DynamicFullLoadTorque = dynamicFullLoadTorque,
DragPower = CurrentState.FullDragTorque * avgEngineSpeed,
AuxiliariesPowerDemand = auxTorqueDemand * avgEngineSpeed,
DragTorque = fullDragTorque,
},
};
}
......@@ -315,6 +316,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
DragPower = CurrentState.FullDragTorque * avgEngineSpeed,
EngineSpeed = angularVelocity,
AuxiliariesPowerDemand = auxTorqueDemand * avgEngineSpeed,
DragTorque = fullDragTorque,
},
};
}
......@@ -332,6 +334,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
DragPower = CurrentState.FullDragTorque * avgEngineSpeed,
EngineSpeed = angularVelocity,
AuxiliariesPowerDemand = auxTorqueDemand * avgEngineSpeed,
DragTorque = fullDragTorque,
},
};
}
......
......@@ -162,7 +162,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
// return retVal;
//}
if (!eMotorTorque.IsBetween(maxDriveTorque ?? 0.SI<NewtonMeter>(), maxRecuperationTorque ?? 0.SI<NewtonMeter>())) {
if (!dryRun && !eMotorTorque.IsBetween(maxDriveTorque ?? 0.SI<NewtonMeter>(), maxRecuperationTorque ?? 0.SI<NewtonMeter>())) {
throw new VectoException("Invalid operating point provided by strategy! SupportPower: {0}, max Power: {1}, min Power: {2}", eMotorTorque, maxDriveTorque, maxRecuperationTorque);
}
......
using System.Collections.Generic;
using TUGraz.VectoCommon.Exceptions;
using TUGraz.VectoCommon.InputData;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.Models.Simulation;
using TUGraz.VectoCore.Models.Simulation.DataBus;
using TUGraz.VectoCore.Models.Simulation.Impl;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.Models.SimulationComponent.Impl;
using TUGraz.VectoCore.OutputData;
namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies {
public class TestPowertrain
{
public SimplePowertrainContainer Container;
public Gearbox Gearbox;
public SimpleHybridController HybridController;
public Battery Battery;
public Clutch Clutch;
public IBrakes Brakes;
public IDriverInfo Driver;
public IDrivingCycleInfo DrivingCycle;
public StopStartCombustionEngine CombustionEngine;
public ElectricMotor ElectricMotorP2;
public TestPowertrain(SimplePowertrainContainer container, IDataBus realContainer)
{
Container = container;
Gearbox = Container.GearboxCtl as Gearbox;
HybridController = Container.HybridController as SimpleHybridController;
Battery = Container.BatteryInfo as Battery;
Clutch = Container.ClutchInfo as Clutch;
CombustionEngine = Container.EngineInfo as StopStartCombustionEngine;
ElectricMotorP2 = container.ElectricMotors.ContainsKey(PowertrainPosition.HybridP2)
? container.ElectricMotors[PowertrainPosition.HybridP2] as ElectricMotor
: null;
if (Gearbox == null) {
throw new VectoException("Unknown gearboxtype in TestContainer: {0}", Container.GearboxCtl.GetType().FullName);
}
if (HybridController == null) {
throw new VectoException("Unknown HybridController in TestContainer: {0}", Container.HybridController.GetType().FullName);
}
Driver = new MockDriver(container, realContainer);
DrivingCycle = new MockDrivingCycle(container, realContainer);
Brakes = new MockBrakes(container);
}
}
public class MockBrakes : VectoSimulationComponent, IBrakes
{
public MockBrakes(IVehicleContainer container) : base(container)
{
BrakePower = 0.SI<Watt>();
}
#region Overrides of VectoSimulationComponent
protected override void DoWriteModalResults(Second time, Second simulationInterval, IModalDataContainer container)
{
}
protected override void DoCommitSimulationStep(Second time, Second simulationInterval)
{
}
#endregion
#region Implementation of IBrakes
public Watt BrakePower { get; set; }
#endregion
}
public class MockDrivingCycle : VectoSimulationComponent, IDrivingCycleInfo
{
private IDataBus realContainer;
public MockDrivingCycle(VehicleContainer container, IDataBus rcontainer) : base(container)
{
realContainer = rcontainer;
}
#region Implementation of IDrivingCycleInfo
public CycleData CycleData
{
get { return realContainer.DrivingCycleInfo.CycleData; }
}
public bool PTOActive
{
get { return realContainer.DrivingCycleInfo.PTOActive; }
}
public DrivingCycleData.DrivingCycleEntry CycleLookAhead(Meter distance)
{
return realContainer.DrivingCycleInfo.CycleLookAhead(distance);
}
public Meter Altitude
{
get { return realContainer.DrivingCycleInfo.Altitude; }
}
public Radian RoadGradient
{
get { return realContainer.DrivingCycleInfo.RoadGradient; }
}
public MeterPerSecond TargetSpeed
{
get { return realContainer.DrivingCycleInfo.TargetSpeed; }
}
public Second StopTime
{
get { return realContainer.DrivingCycleInfo.StopTime; }
}
public Meter CycleStartDistance
{
get { return realContainer?.DrivingCycleInfo?.CycleStartDistance ?? 0.SI<Meter>(); }
}
public IReadOnlyList<DrivingCycleData.DrivingCycleEntry> LookAhead(Meter lookaheadDistance)
{
return realContainer.DrivingCycleInfo.LookAhead(lookaheadDistance);
}
public IReadOnlyList<DrivingCycleData.DrivingCycleEntry> LookAhead(Second time)
{
return realContainer.DrivingCycleInfo.LookAhead(time);
}
public SpeedChangeEntry LastTargetspeedChange
{
get { return realContainer.DrivingCycleInfo.LastTargetspeedChange; }
}
public void FinishSimulation()
{
}
#endregion
#region Overrides of VectoSimulationComponent
protected override void DoWriteModalResults(Second time, Second simulationInterval, IModalDataContainer container)
{
}
protected override void DoCommitSimulationStep(Second time, Second simulationInterval)
{
}
#endregion
}
public class MockDriver : VectoSimulationComponent, IDriverInfo
{
private IDataBus realContainer;
public MockDriver(VehicleContainer container, IDataBus rcontainer) : base(container)
{
realContainer = rcontainer;
}
#region Implementation of IDriverInfo
public DrivingBehavior DriverBehavior
{
get { return realContainer?.DriverInfo?.DriverBehavior ?? DrivingBehavior.Accelerating; }
}
public DrivingAction DrivingAction
{
get { return realContainer?.DriverInfo?.DrivingAction ?? DrivingAction.Accelerate; }
}
public MeterPerSquareSecond DriverAcceleration
{
get { return realContainer?.DriverInfo.DriverAcceleration; }
}
#endregion
#region Overrides of VectoSimulationComponent
protected override void DoWriteModalResults(Second time, Second simulationInterval, IModalDataContainer container)
{
}
protected override void DoCommitSimulationStep(Second time, Second simulationInterval)
{
}
#endregion
}
}
\ No newline at end of file
......@@ -406,6 +406,7 @@
<Compile Include="Models\SimulationComponent\Impl\StopStartCombustionEngine.cs" />
<Compile Include="Models\SimulationComponent\Strategies\DelegateParallelHybridStrategy.cs" />
<Compile Include="Models\SimulationComponent\Strategies\HybridStrategy.cs" />
<Compile Include="Models\SimulationComponent\Strategies\TestPowertrain.cs" />
<Compile Include="Models\SimulationComponent\SwitchableClutch.cs" />
<Compile Include="Models\Simulation\DataBus\IBatteryInfo.cs" />
<Compile Include="Models\Simulation\DataBus\IElectricMotorInfo.cs" />
......
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