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

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

Allow more values for AirDrag in DryRun (in Search)

parent ffc8e7c6
No related branches found
No related tags found
No related merge requests found
......@@ -164,12 +164,22 @@ namespace TUGraz.VectoCommon.Utils
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T Max<T>(T c1, T c2) where T : IComparable
{
return c1.CompareTo(c2) >= 0 ? c1 : c2;
return c1.CompareTo(c2) > 0 ? c1 : c2;
}
/// <summary>
/// Returns the maximum of two values.
/// </summary>
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T Max<T>(double c1, T c2) where T : SIBase<T>
{
return c1 > c2.Value() ? c1.SI<T>() : c2;
}
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T Max<T>(T c1, T c2, T c3) where T : IComparable
public static T Max<T>(T c1, T c2, T c3) where T : SIBase<T>
{
return Max(Max(c1, c2), c3);
}
......
......@@ -605,8 +605,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
var prevEngineSpeed = _engine.PreviousState.EngineSpeed;
var dragLoad = _engine.ModelData.FullLoadCurve.DragLoadStationaryPower(prevEngineSpeed);
var nextEnginePower = (_lastEnginePower - dragLoad) *
VectoMath.Max(idleTime.Value() * PeDropSlope + PeDropOffset, 0) + dragLoad;
var nextEnginePower = (_lastEnginePower - dragLoad) * Math.Max(0, idleTime.Value() * PeDropSlope + PeDropOffset) +
dragLoad;
var auxDemandResponse = RequestPort.Request(absTime, dt, 0.SI<NewtonMeter>(), prevEngineSpeed, true);
......
......@@ -30,6 +30,7 @@
*/
using System;
using TUGraz.VectoCommon.Exceptions;
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.Configuration;
......@@ -102,7 +103,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
CurrentState.DriverAcceleration = DriverAcceleration(acceleration);
CurrentState.RollingResistance = RollingResistance(gradient);
CurrentState.AirDragResistance = AirDragResistance(PreviousState.Velocity, CurrentState.Velocity);
try {
CurrentState.AirDragResistance = AirDragResistance(PreviousState.Velocity, CurrentState.Velocity);
} catch (VectoException ex) {
Log.Warn("Exception during calculation of AirDragResistance: absTime: {0}, dist: {1}, v: {2}. {3}", absTime,
CurrentState.Distance, CurrentState.Velocity, ex);
CurrentState.AirDragResistance = AirDragResistance(VectoMath.Max(0, PreviousState.Velocity),
VectoMath.Max(0, CurrentState.Velocity));
}
CurrentState.SlopeResistance = SlopeResistance(gradient);
// DriverAcceleration = vehicleTractionForce - RollingResistance - AirDragResistance - SlopeResistance
......
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