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

introduce combustion engine model for engine-only cycles (handling of overload situations)

introduce minimum acceleration in driver model (abort otherwise)
interpretation of driving cycle (stop-time + increase distance), altitude computation
make all testcases green...
parent ac62d709
No related branches found
No related tags found
No related merge requests found
Showing
with 186 additions and 156 deletions
...@@ -54,7 +54,7 @@ namespace TUGraz.VectoCore.Configuration ...@@ -54,7 +54,7 @@ namespace TUGraz.VectoCore.Configuration
/// threshold for changes in the road gradient. changes below this threshold will be considered to be equal for filtering out the driving cycle. /// threshold for changes in the road gradient. changes below this threshold will be considered to be equal for filtering out the driving cycle.
/// altitude computation is done before filtering! /// altitude computation is done before filtering!
/// </summary> /// </summary>
public static readonly double DrivingCycleRoadGradientTolerance = 0; public static readonly double DrivingCycleRoadGradientTolerance = 1E-12;
//VectoMath.InclinationToAngle(0.25 / 100.0).Value(); //VectoMath.InclinationToAngle(0.25 / 100.0).Value();
......
...@@ -69,16 +69,28 @@ namespace TUGraz.VectoCore.FileIO.Reader ...@@ -69,16 +69,28 @@ namespace TUGraz.VectoCore.FileIO.Reader
filtered.Add(current); filtered.Add(current);
var distance = current.Distance; var distance = current.Distance;
var altitude = current.Altitude; var altitude = current.Altitude;
foreach (var entry in entries) { //foreach (var entry in entries) {
for (var i = 0; i < entries.Count; i++) {
var entry = entries[i];
if (i > 0) {
altitude += (entry.Distance - distance) * entries[i - 1].RoadGradientPercent / 100.0;
}
entry.Altitude = altitude; entry.Altitude = altitude;
if (!CycleEntriesAreEqual(current, entry)) { if (!CycleEntriesAreEqual(current, entry)) {
entry.Altitude = altitude; entry.Altitude = altitude;
filtered.Add(entry); filtered.Add(entry);
current = entry; current = entry;
} }
if (entry.StoppingTime.IsEqual(0) && !entry.VehicleTargetSpeed.IsEqual(0)) { if (!entry.StoppingTime.IsEqual(0) && entry.VehicleTargetSpeed.IsEqual(0)) {
altitude += (entry.Distance - distance) * entry.RoadGradientPercent / 100.0; // vehicle stops. duplicate current distance entry with 0 waiting time
var tmp = new DrivingCycleData.DrivingCycleEntry(entry) {
StoppingTime = 0.SI<Second>(),
VehicleTargetSpeed = i < entries.Count - 1 ? entries[i + 1].VehicleTargetSpeed : 0.SI<MeterPerSecond>()
};
filtered.Add(tmp);
current = tmp;
} }
distance = entry.Distance; distance = entry.Distance;
} }
log.Info(string.Format("Data loaded. Number of Entries: {0}, filtered Entries: {1}", entries.Count, filtered.Count)); log.Info(string.Format("Data loaded. Number of Entries: {0}, filtered Entries: {1}", entries.Count, filtered.Count));
......
...@@ -91,9 +91,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl ...@@ -91,9 +91,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
return _container; return _container;
} }
protected protected IGearbox GetGearbox(VehicleContainer container, GearboxData data)
IGearbox GetGearbox
(VehicleContainer container, GearboxData data)
{ {
switch (data.Type) { switch (data.Type) {
case GearboxData.GearboxType.AT: case GearboxData.GearboxType.AT:
...@@ -105,59 +103,44 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl ...@@ -105,59 +103,44 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
} }
} }
protected virtual protected virtual IDriver AddComponent(IDrivingCycle prev, IDriver next)
IDriver AddComponent
(IDrivingCycle prev, IDriver next)
{ {
prev.InPort().Connect(next.OutPort()); prev.InPort().Connect(next.OutPort());
return next; return next;
} }
protected virtual protected virtual IVehicle AddComponent(IDriver prev, IVehicle next)
IVehicle AddComponent
(IDriver prev, IVehicle next)
{ {
prev.InPort().Connect(next.OutPort()); prev.InPort().Connect(next.OutPort());
return next; return next;
} }
protected virtual protected virtual IWheels AddComponent(IFvInProvider prev, IWheels next)
IWheels AddComponent
(IFvInProvider prev, IWheels next)
{ {
prev.InPort().Connect(next.OutPort()); prev.InPort().Connect(next.OutPort());
return next; return next;
} }
protected virtual protected virtual IPowerTrainComponent AddComponent(IWheels prev, IPowerTrainComponent next)
IPowerTrainComponent AddComponent
(IWheels prev, IPowerTrainComponent next)
{ {
prev.InPort().Connect(next.OutPort()); prev.InPort().Connect(next.OutPort());
return next; return next;
} }
protected virtual protected virtual IPowerTrainComponent AddComponent(IPowerTrainComponent prev, IPowerTrainComponent next)
IPowerTrainComponent AddComponent
(IPowerTrainComponent prev, IPowerTrainComponent next)
{ {
prev.InPort().Connect(next.OutPort()); prev.InPort().Connect(next.OutPort());
return next; return next;
} }
protected virtual protected virtual void AddComponent(IPowerTrainComponent prev, ITnOutProvider next)
void AddComponent
(IPowerTrainComponent prev, ITnOutProvider next)
{ {
prev.InPort().Connect(next.OutPort()); prev.InPort().Connect(next.OutPort());
} }
private private VehicleContainer BuildEngineOnly(VectoRunData data)
VehicleContainer BuildEngineOnly
(VectoRunData
data)
{ {
var cycle = new EngineOnlySimulation(_container, data.Cycle); var cycle = new EngineOnlySimulation(_container, data.Cycle);
...@@ -169,7 +152,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl ...@@ -169,7 +152,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
directAux.AddDirect(cycle); directAux.AddDirect(cycle);
gearbox.InPort().Connect(directAux.OutPort()); gearbox.InPort().Connect(directAux.OutPort());
var engine = new CombustionEngine(_container, data.EngineData); var engine = new EngineOnlyCombustionEngine(_container, data.EngineData);
directAux.InPort().Connect(engine.OutPort()); directAux.InPort().Connect(engine.OutPort());
return _container; return _container;
......
...@@ -22,6 +22,26 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data ...@@ -22,6 +22,26 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
public class DrivingCycleEntry public class DrivingCycleEntry
{ {
public DrivingCycleEntry() {}
public DrivingCycleEntry(DrivingCycleEntry entry)
{
Distance = entry.Distance;
Time = entry.Time;
VehicleTargetSpeed = entry.VehicleTargetSpeed;
RoadGradient = entry.RoadGradient;
Altitude = entry.Altitude;
StoppingTime = entry.StoppingTime;
EngineSpeed = entry.EngineSpeed;
Gear = entry.Gear;
AdditionalAuxPowerDemand = entry.AdditionalAuxPowerDemand;
AirSpeedRelativeToVehicle = entry.AirSpeedRelativeToVehicle;
WindYawAngle = entry.WindYawAngle;
EngineTorque = entry.EngineTorque;
Drag = entry.Drag;
AuxiliarySupplyPower = new Dictionary<string, Watt>(entry.AuxiliarySupplyPower);
}
/// <summary> /// <summary>
/// [m] Travelled distance used for distance-based cycles. If "t" /// [m] Travelled distance used for distance-based cycles. If "t"
/// is also defined this column will be ignored. /// is also defined this column will be ignored.
......
...@@ -29,11 +29,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -29,11 +29,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
Undef Undef
} }
private const int EngineIdleSpeedStopThreshold = 100; protected const int EngineIdleSpeedStopThreshold = 100;
private const double MaxPowerExceededThreshold = 1.05; protected const double MaxPowerExceededThreshold = 1.05;
private const double ZeroThreshold = 0.0001; protected const double ZeroThreshold = 0.0001;
private const double FullLoadMargin = 0.01; protected const double FullLoadMargin = 0.01;
[NonSerialized] private readonly List<Second> _enginePowerCorrections = new List<Second>();
/// <summary> /// <summary>
/// Current state is computed in request method /// Current state is computed in request method
...@@ -76,21 +75,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -76,21 +75,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
IResponse ITnOutPort.Request(Second absTime, Second dt, NewtonMeter torque, PerSecond engineSpeed, bool dryRun) IResponse ITnOutPort.Request(Second absTime, Second dt, NewtonMeter torque, PerSecond engineSpeed, bool dryRun)
{ {
_currentState.dt = dt; return DoHandleRequest(absTime, dt, torque, engineSpeed, dryRun);
_currentState.EngineSpeed = engineSpeed;
_currentState.AbsTime = absTime;
var requestedPower = Formulas.TorqueToPower(torque, engineSpeed);
_currentState.EnginePowerLoss = InertiaPowerLoss(torque, engineSpeed);
var requestedEnginePower = requestedPower + _currentState.EnginePowerLoss;
if (engineSpeed < _data.IdleSpeed.Value() - EngineIdleSpeedStopThreshold) {
_currentState.OperationMode = EngineOperationMode.Stopped;
//todo: _currentState.EnginePowerLoss = enginePowerLoss;
} }
_currentState.FullDragTorque = _data.FullLoadCurve.DragLoadStationaryTorque(engineSpeed); protected virtual IResponse DoHandleRequest(Second absTime, Second dt, NewtonMeter torque, PerSecond engineSpeed,
_currentState.FullDragPower = Formulas.TorqueToPower(_currentState.FullDragTorque, engineSpeed); bool dryRun)
{
Watt requestedPower;
Watt requestedEnginePower;
ComputeRequestedEnginePower(absTime, dt, torque, engineSpeed, out requestedPower, out requestedEnginePower);
ComputeFullLoadPower(engineSpeed, dt); ComputeFullLoadPower(engineSpeed, dt);
...@@ -118,6 +111,26 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -118,6 +111,26 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
return new ResponseSuccess(); return new ResponseSuccess();
} }
protected void ComputeRequestedEnginePower(Second absTime, Second dt, NewtonMeter torque, PerSecond engineSpeed,
out Watt requestedPower, out Watt requestedEnginePower)
{
_currentState.dt = dt;
_currentState.EngineSpeed = engineSpeed;
_currentState.AbsTime = absTime;
requestedPower = Formulas.TorqueToPower(torque, engineSpeed);
_currentState.EnginePowerLoss = InertiaPowerLoss(torque, engineSpeed);
requestedEnginePower = requestedPower + _currentState.EnginePowerLoss;
if (engineSpeed < _data.IdleSpeed.Value() - EngineIdleSpeedStopThreshold) {
_currentState.OperationMode = EngineOperationMode.Stopped;
//todo: _currentState.EnginePowerLoss = enginePowerLoss;
}
_currentState.FullDragTorque = _data.FullLoadCurve.DragLoadStationaryTorque(engineSpeed);
_currentState.FullDragPower = Formulas.TorqueToPower(_currentState.FullDragTorque, engineSpeed);
}
public IResponse Initialize(NewtonMeter torque, PerSecond engineSpeed) public IResponse Initialize(NewtonMeter torque, PerSecond engineSpeed)
{ {
_previousState = new EngineState() { _previousState = new EngineState() {
...@@ -179,7 +192,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -179,7 +192,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
/// Validates the requested power demand [W]. /// Validates the requested power demand [W].
/// </summary> /// </summary>
/// <param name="requestedEnginePower">[W]</param> /// <param name="requestedEnginePower">[W]</param>
protected void ValidatePowerDemand(SI requestedEnginePower) protected virtual void ValidatePowerDemand(SI requestedEnginePower)
{ {
Contract.Requires(requestedEnginePower.HasEqualUnit(new SI().Watt)); Contract.Requires(requestedEnginePower.HasEqualUnit(new SI().Watt));
...@@ -198,25 +211,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -198,25 +211,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
/// </summary> /// </summary>
/// <param name="requestedEnginePower">[W]</param> /// <param name="requestedEnginePower">[W]</param>
/// <returns>[W]</returns> /// <returns>[W]</returns>
protected Watt LimitEnginePower(Watt requestedEnginePower) protected virtual Watt LimitEnginePower(Watt requestedEnginePower)
{ {
if (requestedEnginePower > _currentState.DynamicFullLoadPower) { if (requestedEnginePower > _currentState.DynamicFullLoadPower) {
if (requestedEnginePower / _currentState.DynamicFullLoadPower > MaxPowerExceededThreshold) {
_enginePowerCorrections.Add(_currentState.AbsTime);
Log.WarnFormat(
"t: {0} requested power > P_engine_full * 1.05 - corrected. P_request: {1} P_engine_full: {2}",
_currentState.AbsTime, requestedEnginePower, _currentState.DynamicFullLoadPower);
}
return _currentState.DynamicFullLoadPower; return _currentState.DynamicFullLoadPower;
} }
if (requestedEnginePower < _currentState.FullDragPower) { if (requestedEnginePower < _currentState.FullDragPower) {
if (requestedEnginePower / _currentState.FullDragPower > MaxPowerExceededThreshold &&
requestedEnginePower > -99999) {
_enginePowerCorrections.Add(_currentState.AbsTime);
Log.WarnFormat(
"t: {0} requested power < P_engine_drag * 1.05 - corrected. P_request: {1} P_engine_drag: {2}",
_currentState.AbsTime, requestedEnginePower, _currentState.FullDragPower);
}
return _currentState.FullDragPower; return _currentState.FullDragPower;
} }
return requestedEnginePower; return requestedEnginePower;
...@@ -226,7 +226,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -226,7 +226,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
/// Updates the engine state dependend on the requested power [W]. /// Updates the engine state dependend on the requested power [W].
/// </summary> /// </summary>
/// <param name="requestedEnginePower">[W]</param> /// <param name="requestedEnginePower">[W]</param>
protected void UpdateEngineState(Watt requestedEnginePower) protected virtual void UpdateEngineState(Watt requestedEnginePower)
{ {
if (requestedEnginePower < -ZeroThreshold) { if (requestedEnginePower < -ZeroThreshold) {
_currentState.OperationMode = IsFullLoad(requestedEnginePower, _currentState.DynamicFullLoadPower) _currentState.OperationMode = IsFullLoad(requestedEnginePower, _currentState.DynamicFullLoadPower)
...@@ -242,13 +242,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -242,13 +242,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
} }
} }
public IList<string> Warnings()
{
IList<string> retVal = new List<string>();
retVal.Add(string.Format("Engine power corrected (>5%) in {0} time steps ", _enginePowerCorrections.Count));
return retVal;
}
/// <summary> /// <summary>
/// computes full load power from gear [-], angularVelocity [rad/s] and dt [s]. /// computes full load power from gear [-], angularVelocity [rad/s] and dt [s].
/// </summary> /// </summary>
......
...@@ -33,7 +33,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -33,7 +33,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
{ {
Data = cycle; Data = cycle;
CycleIntervalIterator = new DrivingCycleEnumerator(Data); CycleIntervalIterator = new DrivingCycleEnumerator(Data);
CycleIntervalIterator.MoveNext();
} }
#region IDrivingCycleInProvider #region IDrivingCycleInProvider
......
...@@ -149,8 +149,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -149,8 +149,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
CurrentState.Acceleration += searchInterval; CurrentState.Acceleration += searchInterval;
} }
// check for minimum acceleration, add some safety margin due to search // check for minimum acceleration, add some safety margin due to search
if (CurrentState.Acceleration < Constants.SimulationSettings.MinimumAcceleration / 5.0 && if (Math.Abs(CurrentState.Acceleration.Value()) < Constants.SimulationSettings.MinimumAcceleration.Value() / 5.0 &&
searchInterval < Constants.SimulationSettings.MinimumAcceleration.Value() / 20.0) { Math.Abs(searchInterval) < Constants.SimulationSettings.MinimumAcceleration.Value() / 20.0) {
throw new VectoSimulationException("Could not achieve minimum acceleration"); throw new VectoSimulationException("Could not achieve minimum acceleration");
} }
searchInterval /= 2.0; searchInterval /= 2.0;
......
using System.Collections.Generic;
using TUGraz.VectoCore.Configuration;
using TUGraz.VectoCore.Models.Connector.Ports;
using TUGraz.VectoCore.Models.Connector.Ports.Impl;
using TUGraz.VectoCore.Models.Simulation;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
{
public class EngineOnlyCombustionEngine : CombustionEngine
{
protected readonly List<Second> _enginePowerCorrections = new List<Second>();
public EngineOnlyCombustionEngine(IVehicleContainer cockpit, CombustionEngineData data) : base(cockpit, data) {}
// the behavior in engin-only mode differs a little bit from normal driving cycle simulation: in engine-only mode
// certain amount of overload is tolerated.
protected override IResponse DoHandleRequest(Second absTime, Second dt, NewtonMeter torque, PerSecond engineSpeed,
bool dryRun)
{
Watt requestedPower;
Watt requestedEnginePower;
ComputeRequestedEnginePower(absTime, dt, torque, engineSpeed, out requestedPower, out requestedEnginePower);
ComputeFullLoadPower(engineSpeed, dt);
ValidatePowerDemand(requestedEnginePower);
_currentState.EnginePower = LimitEnginePower(requestedEnginePower);
if (dryRun) {
return new ResponseDryRun() {
DeltaFullLoad = (requestedEnginePower - _currentState.DynamicFullLoadPower).Value(),
DeltaDragLoad = (requestedEnginePower - _currentState.FullDragPower).Value()
};
}
UpdateEngineState(_currentState.EnginePower);
// = requestedEnginePower; //todo + _currentState.EnginePowerLoss;
_currentState.EngineTorque = Formulas.PowerToTorque(_currentState.EnginePower,
_currentState.EngineSpeed);
return new ResponseSuccess();
}
/// <summary>
/// [W] => [W]
/// </summary>
/// <param name="requestedEnginePower">[W]</param>
/// <returns>[W]</returns>
protected override Watt LimitEnginePower(Watt requestedEnginePower)
{
if (requestedEnginePower > _currentState.DynamicFullLoadPower) {
if (requestedEnginePower / _currentState.DynamicFullLoadPower > MaxPowerExceededThreshold) {
_enginePowerCorrections.Add(_currentState.AbsTime);
Log.WarnFormat(
"t: {0} requested power > P_engine_full * 1.05 - corrected. P_request: {1} P_engine_full: {2}",
_currentState.AbsTime, requestedEnginePower, _currentState.DynamicFullLoadPower);
}
return _currentState.DynamicFullLoadPower;
}
if (requestedEnginePower < _currentState.FullDragPower) {
if (requestedEnginePower / _currentState.FullDragPower > MaxPowerExceededThreshold &&
requestedEnginePower > -99999) {
_enginePowerCorrections.Add(_currentState.AbsTime);
Log.WarnFormat(
"t: {0} requested power < P_engine_drag * 1.05 - corrected. P_request: {1} P_engine_drag: {2}",
_currentState.AbsTime, requestedEnginePower, _currentState.FullDragPower);
}
return _currentState.FullDragPower;
}
return requestedEnginePower;
}
public IList<string> Warnings()
{
IList<string> retVal = new List<string>();
retVal.Add(string.Format("Engine power corrected (>5%) in {0} time steps ", _enginePowerCorrections.Count));
return retVal;
}
}
}
\ No newline at end of file
...@@ -22,8 +22,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -22,8 +22,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
public Vehicle(VehicleContainer container, VehicleData data) : base(container) public Vehicle(VehicleContainer container, VehicleData data) : base(container)
{ {
_data = data; _data = data;
_previousState = new VehicleState { Velocity = 0.SI<MeterPerSecond>() }; _previousState = new VehicleState() { Distance = 0.SI<Meter>(), Velocity = 0.SI<MeterPerSecond>() };
_currentState = new VehicleState(); _currentState = new VehicleState() { Distance = 0.SI<Meter>(), Velocity = 0.SI<MeterPerSecond>() };
} }
public Vehicle(VehicleContainer container, VehicleData data, double initialVelocity) : this(container, data) public Vehicle(VehicleContainer container, VehicleData data, double initialVelocity) : this(container, data)
...@@ -49,7 +49,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -49,7 +49,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
protected override void DoWriteModalResults(IModalDataWriter writer) protected override void DoWriteModalResults(IModalDataWriter writer)
{ {
writer[ModalResultField.v_act] = (_previousState.Velocity + _currentState.Velocity) / 2; writer[ModalResultField.v_act] = (_previousState.Velocity + _currentState.Velocity) / 2;
writer[ModalResultField.dist] = (_previousState.Distance - _currentState.Distance) / 2; writer[ModalResultField.dist] = _currentState.Distance;
// hint: take care to use correct velocity when writing the P... values in moddata // hint: take care to use correct velocity when writing the P... values in moddata
} }
...@@ -65,7 +65,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -65,7 +65,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
{ {
_currentState.Velocity = (_previousState.Velocity + (accelleration * dt)).Cast<MeterPerSecond>(); _currentState.Velocity = (_previousState.Velocity + (accelleration * dt)).Cast<MeterPerSecond>();
_currentState.dt = dt; _currentState.dt = dt;
_currentState.Distance = ((_previousState.Velocity + _currentState.Velocity) / 2 * _currentState.dt).Cast<Meter>(); _currentState.Distance = _previousState.Distance +
((_previousState.Velocity + _currentState.Velocity) / 2 * _currentState.dt).Cast<Meter>();
// DriverAcceleration = vehicleAccelerationForce - RollingResistance - AirDragResistance - SlopeResistance // DriverAcceleration = vehicleAccelerationForce - RollingResistance - AirDragResistance - SlopeResistance
var vehicleAccelerationForce = DriverAcceleration(accelleration) + RollingResistance(gradient) + var vehicleAccelerationForce = DriverAcceleration(accelleration) + RollingResistance(gradient) +
......
...@@ -158,6 +158,7 @@ ...@@ -158,6 +158,7 @@
<Compile Include="Models\Declaration\MissionType.cs" /> <Compile Include="Models\Declaration\MissionType.cs" />
<Compile Include="Models\SimulationComponent\Data\Engine\PT1Curve.cs" /> <Compile Include="Models\SimulationComponent\Data\Engine\PT1Curve.cs" />
<Compile Include="Models\SimulationComponent\IDrivingCycleInfo.cs" /> <Compile Include="Models\SimulationComponent\IDrivingCycleInfo.cs" />
<Compile Include="Models\SimulationComponent\Impl\EngineOnlyCombustionEngine.cs" />
<Compile Include="Models\SimulationComponent\Impl\MappingAuxiliaryData.cs" /> <Compile Include="Models\SimulationComponent\Impl\MappingAuxiliaryData.cs" />
<Compile Include="Models\Simulation\Data\AuxiliaryDemandType.cs" /> <Compile Include="Models\Simulation\Data\AuxiliaryDemandType.cs" />
<Compile Include="Models\SimulationComponent\Data\AuxiliaryType.cs" /> <Compile Include="Models\SimulationComponent\Data\AuxiliaryType.cs" />
......
...@@ -4,6 +4,7 @@ using System.Linq; ...@@ -4,6 +4,7 @@ using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using TUGraz.VectoCore.FileIO.Reader; using TUGraz.VectoCore.FileIO.Reader;
using TUGraz.VectoCore.FileIO.Reader.Impl; using TUGraz.VectoCore.FileIO.Reader.Impl;
using TUGraz.VectoCore.Models.Connector.Ports.Impl;
using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.Simulation.Data;
using TUGraz.VectoCore.Models.Simulation.Impl; using TUGraz.VectoCore.Models.Simulation.Impl;
using TUGraz.VectoCore.Models.SimulationComponent.Impl; using TUGraz.VectoCore.Models.SimulationComponent.Impl;
...@@ -34,7 +35,7 @@ namespace TUGraz.VectoCore.Tests.Integration.EngineOnlyCycle ...@@ -34,7 +35,7 @@ namespace TUGraz.VectoCore.Tests.Integration.EngineOnlyCycle
aux.AddDirect(cycle); aux.AddDirect(cycle);
var gearbox = new EngineOnlyGearbox(vehicle); var gearbox = new EngineOnlyGearbox(vehicle);
var engine = new CombustionEngine(vehicle, engineData); var engine = new EngineOnlyCombustionEngine(vehicle, engineData);
aux.InPort().Connect(engine.OutPort()); aux.InPort().Connect(engine.OutPort());
gearbox.InPort().Connect(aux.OutPort()); gearbox.InPort().Connect(aux.OutPort());
...@@ -47,7 +48,8 @@ namespace TUGraz.VectoCore.Tests.Integration.EngineOnlyCycle ...@@ -47,7 +48,8 @@ namespace TUGraz.VectoCore.Tests.Integration.EngineOnlyCycle
var dataWriter = new ModalDataWriter(modFile, true); var dataWriter = new ModalDataWriter(modFile, true);
foreach (var cycleEntry in data.Entries) { foreach (var cycleEntry in data.Entries) {
port.Request(absTime, dt, cycleEntry.EngineTorque, cycleEntry.EngineSpeed); var response = port.Request(absTime, dt, cycleEntry.EngineTorque, cycleEntry.EngineSpeed);
Assert.IsInstanceOfType(response, typeof(ResponseSuccess));
foreach (var sc in vehicle.SimulationComponents()) { foreach (var sc in vehicle.SimulationComponents()) {
dataWriter[ModalResultField.time] = absTime + dt / 2; dataWriter[ModalResultField.time] = absTime + dt / 2;
sc.CommitSimulationStep(dataWriter); sc.CommitSimulationStep(dataWriter);
......
...@@ -159,74 +159,6 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns ...@@ -159,74 +159,6 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns
} }
[TestMethod]
public void TestWheelsAndEngineOverload()
{
var engineData = EngineeringModeSimulationDataReader.CreateEngineDataFromFile(EngineFile);
var cycleData = DrivingCycleDataReader.ReadFromFileDistanceBased(CycleFile);
var vehicleData = CreateVehicleData(50000.SI<Kilogram>());
var driverData = CreateDriverData();
var modalWriter = new ModalDataWriter("Coach_MinimalPowertrainOverload.vmod", false); //new TestModalDataWriter();
var sumWriter = new TestSumWriter();
var vehicleContainer = new VehicleContainer(modalWriter, sumWriter);
var cycle = new DistanceBasedDrivingCycle(vehicleContainer, cycleData);
dynamic tmp = AddComponent(cycle, new Driver(vehicleContainer, driverData));
tmp = AddComponent(tmp, new Vehicle(vehicleContainer, vehicleData));
tmp = AddComponent(tmp, new Wheels(vehicleContainer, vehicleData.DynamicTyreRadius));
tmp = AddComponent(tmp, new Clutch(vehicleContainer, engineData));
AddComponent(tmp, new CombustionEngine(vehicleContainer, engineData));
var gbx = new DummyGearbox(vehicleContainer);
var cyclePort = cycle.OutPort();
cyclePort.Initialize();
gbx.CurrentGear = 0;
var absTime = 0.SI<Second>();
var response = cyclePort.Request(absTime, 1.SI<Meter>());
Assert.IsInstanceOfType(response, typeof(ResponseSuccess));
vehicleContainer.CommitSimulationStep(absTime, response.SimulationInterval);
absTime += response.SimulationInterval;
gbx.CurrentGear = 1;
var ds = Constants.SimulationSettings.DriveOffDistance;
while (vehicleContainer.Distance().Value() < 200) {
response = cyclePort.Request(absTime, ds);
switch (response.ResponseType) {
case ResponseType.DrivingCycleDistanceExceeded:
var rsp = response as ResponseDrivingCycleDistanceExceeded;
ds = rsp.MaxDistance;
continue;
}
Assert.IsInstanceOfType(response, typeof(ResponseSuccess));
vehicleContainer.CommitSimulationStep(absTime, response.SimulationInterval);
absTime += response.SimulationInterval;
ds = vehicleContainer.VehicleSpeed().IsEqual(0)
? Constants.SimulationSettings.DriveOffDistance
: (Constants.SimulationSettings.TargetTimeInterval * vehicleContainer.VehicleSpeed()).Cast<Meter>();
modalWriter.Finish();
}
modalWriter.Finish();
//var run = new DistanceRun(vehicleContainer);
//run.Run();
}
private static VehicleData CreateVehicleData(Kilogram loading) private static VehicleData CreateVehicleData(Kilogram loading)
{ {
var axles = new List<Axle>() { var axles = new List<Axle>() {
......
...@@ -148,7 +148,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent ...@@ -148,7 +148,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
var engineData = var engineData =
EngineeringModeSimulationDataReader.CreateEngineDataFromFile( EngineeringModeSimulationDataReader.CreateEngineDataFromFile(
TestContext.DataRow["EngineFile"].ToString()); TestContext.DataRow["EngineFile"].ToString());
var engine = new CombustionEngine(vehicleContainer, engineData); var engine = new EngineOnlyCombustionEngine(vehicleContainer, engineData);
gearbox.InPort().Connect(engine.OutPort()); gearbox.InPort().Connect(engine.OutPort());
......
using System; using System;
using System.Linq; using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using TUGraz.VectoCore.Configuration;
using TUGraz.VectoCore.Exceptions; using TUGraz.VectoCore.Exceptions;
using TUGraz.VectoCore.FileIO.Reader; using TUGraz.VectoCore.FileIO.Reader;
using TUGraz.VectoCore.FileIO.Reader.Impl; using TUGraz.VectoCore.FileIO.Reader.Impl;
...@@ -23,6 +24,8 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent ...@@ -23,6 +24,8 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
[TestMethod] [TestMethod]
public void TestDistanceRequest() public void TestDistanceRequest()
{ {
// Constants.SimulationSettings.DrivingCycleRoadGradientTolerance = 1E-12;
var cycleData = DrivingCycleDataReader.ReadFromFile(ShortCycle, DrivingCycleData.CycleType.DistanceBased); var cycleData = DrivingCycleDataReader.ReadFromFile(ShortCycle, DrivingCycleData.CycleType.DistanceBased);
var vehicleContainer = new VehicleContainer(); var vehicleContainer = new VehicleContainer();
...@@ -52,7 +55,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent ...@@ -52,7 +55,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
Assert.IsInstanceOfType(response, typeof(ResponseSuccess)); Assert.IsInstanceOfType(response, typeof(ResponseSuccess));
Assert.AreEqual(5.SI<MeterPerSecond>().Value(), driver.LastRequest.TargetVelocity.Value(), Tolerance); Assert.AreEqual(5.SI<MeterPerSecond>().Value(), driver.LastRequest.TargetVelocity.Value(), Tolerance);
Assert.AreEqual(0.02667562971628240, driver.LastRequest.Gradient.Value(), 1E-12); Assert.AreEqual(0.0284160694958265, driver.LastRequest.Gradient.Value(), 1E-12);
Assert.AreEqual(1 + startDistance, cycle.CurrentState.Distance.Value(), Tolerance); Assert.AreEqual(1 + startDistance, cycle.CurrentState.Distance.Value(), Tolerance);
vehicleContainer.CommitSimulationStep(absTime, response.SimulationInterval); vehicleContainer.CommitSimulationStep(absTime, response.SimulationInterval);
...@@ -64,7 +67,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent ...@@ -64,7 +67,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
Assert.IsInstanceOfType(response, typeof(ResponseSuccess)); Assert.IsInstanceOfType(response, typeof(ResponseSuccess));
Assert.AreEqual(5.SI<MeterPerSecond>().Value(), driver.LastRequest.TargetVelocity.Value(), Tolerance); Assert.AreEqual(5.SI<MeterPerSecond>().Value(), driver.LastRequest.TargetVelocity.Value(), Tolerance);
Assert.AreEqual(0.02667562971628240, driver.LastRequest.Gradient.Value(), 1E-12); Assert.AreEqual(0.0284160694958265, driver.LastRequest.Gradient.Value(), 1E-12);
Assert.AreEqual(2 + startDistance, cycle.CurrentState.Distance.Value(), Tolerance); Assert.AreEqual(2 + startDistance, cycle.CurrentState.Distance.Value(), Tolerance);
vehicleContainer.CommitSimulationStep(absTime, response.SimulationInterval); vehicleContainer.CommitSimulationStep(absTime, response.SimulationInterval);
...@@ -75,10 +78,10 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent ...@@ -75,10 +78,10 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
Assert.IsInstanceOfType(response, typeof(ResponseDrivingCycleDistanceExceeded)); Assert.IsInstanceOfType(response, typeof(ResponseDrivingCycleDistanceExceeded));
var tmp = response as ResponseDrivingCycleDistanceExceeded; var tmp = response as ResponseDrivingCycleDistanceExceeded;
Assert.AreEqual(36, tmp.MaxDistance.Value(), Tolerance); Assert.AreEqual(16, tmp.MaxDistance.Value(), Tolerance);
Assert.AreEqual(5.SI<MeterPerSecond>().Value(), driver.LastRequest.TargetVelocity.Value(), Tolerance); Assert.AreEqual(5.SI<MeterPerSecond>().Value(), driver.LastRequest.TargetVelocity.Value(), Tolerance);
Assert.AreEqual(0.02667562971628240, driver.LastRequest.Gradient.Value(), 1E-12); Assert.AreEqual(0.0284160694958265, driver.LastRequest.Gradient.Value(), 1E-12);
Assert.AreEqual(2 + startDistance, cycle.CurrentState.Distance.Value(), Tolerance); Assert.AreEqual(2 + startDistance, cycle.CurrentState.Distance.Value(), Tolerance);
try { try {
...@@ -91,8 +94,8 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent ...@@ -91,8 +94,8 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
response = cycle.OutPort().Request(absTime, tmp.MaxDistance); response = cycle.OutPort().Request(absTime, tmp.MaxDistance);
Assert.AreEqual(5.SI<MeterPerSecond>().Value(), driver.LastRequest.TargetVelocity.Value(), Tolerance); Assert.AreEqual(5.SI<MeterPerSecond>().Value(), driver.LastRequest.TargetVelocity.Value(), Tolerance);
Assert.AreEqual(0.02667562971628240, driver.LastRequest.Gradient.Value(), 1E-12); Assert.AreEqual(0.0284160694958265, driver.LastRequest.Gradient.Value(), 1E-12);
Assert.AreEqual(38 + startDistance, cycle.CurrentState.Distance.Value(), Tolerance); Assert.AreEqual(18 + startDistance, cycle.CurrentState.Distance.Value(), Tolerance);
vehicleContainer.CommitSimulationStep(absTime, response.SimulationInterval); vehicleContainer.CommitSimulationStep(absTime, response.SimulationInterval);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment