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

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

added overload and underload check in LimitEnginePower

parent 60153f73
No related branches found
No related tags found
No related merge requests found
using TUGraz.VectoCore.Utils;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.Simulation.DataBus
{
......@@ -17,5 +18,7 @@ namespace TUGraz.VectoCore.Models.Simulation.DataBus
MeterPerSecond StartSpeed { get; }
MeterPerSquareSecond StartAcceleration { get; }
FullLoadCurve GearFullLoadCurve { get; }
}
}
\ No newline at end of file
......@@ -69,6 +69,11 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
}
}
public FullLoadCurve GearFullLoadCurve
{
get { return Gearbox != null ? Gearbox.GearFullLoadCurve : null; }
}
#endregion
#region IEngineCockpit
......
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Resources;
using NLog;
using TUGraz.VectoCore.Configuration;
using TUGraz.VectoCore.Exceptions;
......@@ -126,7 +124,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
ValidatePowerDemand(requestedEnginePower);
CurrentState.EnginePower = LimitEnginePower(requestedEnginePower);
if (dryRun) {
return new ResponseDryRun {
......@@ -136,12 +133,17 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
};
}
if (!CurrentState.EnginePower.IsEqual(requestedEnginePower, Constants.SimulationSettings.EnginePowerSearchTolerance)) {
var delta = (requestedEnginePower - CurrentState.EnginePower);
Log.Debug("requested engine power exceeds FLD: delta: {0}", delta);
return delta > 0
? new ResponseOverload { Delta = delta, EnginePowerRequest = requestedEnginePower, Source = this }
: new ResponseUnderload { Delta = delta, EnginePowerRequest = requestedEnginePower, Source = this };
CurrentState.EnginePower = LimitEnginePower(requestedEnginePower);
var delta = requestedEnginePower - CurrentState.EnginePower;
if (delta.IsGreater(0.SI<Watt>(), Constants.SimulationSettings.EnginePowerSearchTolerance)) {
Log.Debug("requested engine power exceeds fullload power: delta: {0}", delta);
return new ResponseOverload { Delta = delta, EnginePowerRequest = requestedEnginePower, Source = this };
}
if (delta.IsSmaller(0.SI<Watt>(), Constants.SimulationSettings.EnginePowerSearchTolerance)) {
Log.Debug("requested engine power is below drag power: delta: {0}", delta);
return new ResponseUnderload { Delta = delta, EnginePowerRequest = requestedEnginePower, Source = this };
}
UpdateEngineState(CurrentState.EnginePower);
......@@ -250,7 +252,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
/// </summary>
protected virtual Watt LimitEnginePower(Watt requestedEnginePower)
{
return VectoMath.Limit(requestedEnginePower, CurrentState.FullDragPower, CurrentState.DynamicFullLoadPower);
var curve = DataBus.GearFullLoadCurve;
if (curve != null) {
var gearboxFullLoad = curve.FullLoadStationaryTorque(CurrentState.EngineSpeed) * CurrentState.EngineSpeed;
var gearboxDragLoad = curve.DragLoadStationaryTorque(CurrentState.EngineSpeed) * CurrentState.EngineSpeed;
requestedEnginePower = VectoMath.Limit(requestedEnginePower, gearboxFullLoad, gearboxDragLoad);
}
return VectoMath.Limit(requestedEnginePower, CurrentState.DynamicFullLoadPower, CurrentState.FullDragPower);
}
/// <summary>
......@@ -289,7 +298,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
Data.FullLoadCurve.FullLoadStationaryTorque(angularVelocity);
CurrentState.StationaryFullLoadPower = CurrentState.StationaryFullLoadTorque * angularVelocity;
double pt1 = Data.FullLoadCurve.PT1(angularVelocity).Value();
var pt1 = Data.FullLoadCurve.PT1(angularVelocity).Value();
// var dynFullPowerCalculated = (1 / (pt1 + 1)) *
// (_currentState.StationaryFullLoadPower + pt1 * _previousState.EnginePower);
......@@ -377,6 +386,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
/// </summary>
public NewtonMeter EngineTorque { get; set; }
// ReSharper disable once InconsistentNaming
public Second dt { get; set; }
#region Equality members
......@@ -457,8 +467,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
protected CombustionEngine Engine;
protected Second IdleStart = null;
protected Watt LastEnginePower = null;
protected Second IdleStart;
protected Watt LastEnginePower;
public CombustionEngineIdleController(CombustionEngine combustionEngine)
{
......@@ -485,7 +495,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
IdleStart = absTime;
LastEnginePower = Engine.PreviousState.EnginePower;
}
IResponse retVal = null;
IResponse retVal;
var idleTime = absTime - IdleStart + dt;
var prevEngineSpeed = Engine.PreviousState.EngineSpeed;
......@@ -532,8 +542,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
Log.Info("Disabling logging during search idling speed");
LogManager.DisableLogging();
var prevEngineSpeed = Engine.PreviousState.EngineSpeed;
var searchInterval = Constants.SimulationSettings.EngineIdlingSearchInterval;
var intervalFactor = 1.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;
......
......@@ -4,6 +4,7 @@ using TUGraz.VectoCore.Models.Connector.Ports;
using TUGraz.VectoCore.Models.Simulation;
using TUGraz.VectoCore.Models.Simulation.Data;
using TUGraz.VectoCore.Models.Simulation.DataBus;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
......@@ -36,7 +37,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
uint IGearboxInfo.Gear
{
get { return 0; }
//set { }
}
public MeterPerSecond StartSpeed
......@@ -49,6 +49,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
get { throw new VectoSimulationException("Not Implemented: EngineOnlyGearbox has no StartAcceleration value."); }
}
public FullLoadCurve GearFullLoadCurve
{
get { return null; }
}
#endregion
#region ITnInPort
......
......@@ -103,6 +103,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
get { return Data.StartAcceleration; }
}
public FullLoadCurve GearFullLoadCurve
{
get { return Gear == 0 ? null : Data.Gears[Gear].FullLoadCurve; }
}
#endregion
#region ITnOutPort
......
......@@ -4,6 +4,7 @@ using TUGraz.VectoCore.Models.Simulation;
using TUGraz.VectoCore.Models.Simulation.Data;
using TUGraz.VectoCore.Models.Simulation.DataBus;
using TUGraz.VectoCore.Models.SimulationComponent;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Tests.Utils
......@@ -36,6 +37,11 @@ namespace TUGraz.VectoCore.Tests.Utils
get { return 0.6.SI<MeterPerSquareSecond>(); }
}
public FullLoadCurve GearFullLoadCurve
{
get { return null; }
}
public void Connect(ITnOutPort other)
{
......
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