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

Merge pull request #235 in VECTO/vecto-sim from ~EMQUARIMA/vecto-sim:develop to develop

* commit '1ab01c9b':
  fuel consumption map
  transmissionlossmap: display value in debugger
  renaming parameter
  allow extrapolation of fuel-map in engineering mode
  bugfix in gearbox: disengage when vehicle is stopped
parents 34806299 1ab01c9b
No related branches found
No related tags found
No related merge requests found
Showing with 36 additions and 17 deletions
......@@ -32,6 +32,7 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using TUGraz.VectoCommon.Exceptions;
......@@ -53,18 +54,22 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine
/// <summary>
/// Calculates the fuel consumption based on the given fuel map, the angularVelocity and the torque.
/// </summary>
public KilogramPerSecond GetFuelConsumption(NewtonMeter torque, PerSecond angularVelocity,
public FuelConsumptionResult GetFuelConsumption(NewtonMeter torque, PerSecond angularVelocity,
bool allowExtrapolation = false)
{
var result = new FuelConsumptionResult();
// delaunay map needs is initialised with rpm, therefore the angularVelocity has to be converted.
var value = _fuelMap.Interpolate(torque.Value(), angularVelocity.AsRPM);
if (value.HasValue) {
return value.Value.SI().Kilo.Gramm.Per.Second.Cast<KilogramPerSecond>();
result.Value = value.Value.SI().Kilo.Gramm.Per.Second.Cast<KilogramPerSecond>();
return result;
}
if (allowExtrapolation) {
return
result.Value =
_fuelMap.Extrapolate(torque.Value(), angularVelocity.AsRPM).SI().Kilo.Gramm.Per.Second.Cast<KilogramPerSecond>();
result.Extrapolated = true;
return result;
}
throw new VectoException("FuelConsumptionMap: Interpolation failed. torque: {0}, n: {1}", torque.Value(),
......@@ -125,6 +130,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine
#endregion
}
[DebuggerDisplay("{Value} (extrapolated: {Extrapolated})")]
public class FuelConsumptionResult
{
public KilogramPerSecond Value;
public bool Extrapolated;
}
#region Equality members
protected bool Equals(FuelConsumptionMap other)
......
......@@ -87,7 +87,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox
/// <returns>Torque loss as seen on input side (towards the engine).</returns>
public LossMapResult GetTorqueLoss(PerSecond outAngularVelocity, NewtonMeter outTorque)
{
var result = new TransmissionLossMap.LossMapResult();
var result = new LossMapResult();
var torqueLoss = _lossMap.Interpolate(outAngularVelocity.ConvertTo().Rounds.Per.Minute.Value() * _ratio,
outTorque.Value() / _ratio);
......@@ -104,6 +104,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox
return result;
}
[DebuggerDisplay("{Value} (extrapolated: {Extrapolated})")]
public class LossMapResult
{
public bool Extrapolated;
......
......@@ -89,11 +89,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
PreviousGear = Gearbox.Gear;
}
public override uint InitGear(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outEngineSpeed)
public override uint InitGear(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity)
{
if (DataBus.VehicleSpeed.IsEqual(0)) {
for (var gear = (uint)Data.Gears.Count; gear > 1; gear--) {
var inAngularSpeed = outEngineSpeed * Data.Gears[gear].Ratio;
var inAngularSpeed = outAngularVelocity * Data.Gears[gear].Ratio;
var ratedSpeed = Data.Gears[gear].FullLoadCurve != null
? Data.Gears[gear].FullLoadCurve.RatedSpeed
......@@ -102,7 +102,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
continue;
}
var response = Gearbox.Initialize(gear, outTorque, outEngineSpeed);
var response = Gearbox.Initialize(gear, outTorque, outAngularVelocity);
var fullLoadPower = response.EnginePowerRequest - response.DeltaFullLoad;
var reserve = 1 - response.EnginePowerRequest / fullLoadPower;
......@@ -117,9 +117,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
return 1;
}
for (var gear = (uint)Data.Gears.Count; gear > 1; gear--) {
var response = Gearbox.Initialize(gear, outTorque, outEngineSpeed);
var response = Gearbox.Initialize(gear, outTorque, outAngularVelocity);
var inAngularSpeed = outEngineSpeed * Data.Gears[gear].Ratio;
var inAngularSpeed = outAngularVelocity * Data.Gears[gear].Ratio;
var fullLoadPower = response.EnginePowerRequest - response.DeltaFullLoad;
var reserve = 1 - response.EnginePowerRequest / fullLoadPower;
var inTorque = response.ClutchPowerRequest / inAngularSpeed;
......@@ -211,8 +211,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
}
// if a gear is skipped but acceleration is less than 0.1, try for next gear. if acceleration is still below 0.1 don't shift!
if (nextGear > currentGear &&
EstimateAccelerationForGear(currentGear + 1, outAngularVelocity).IsSmaller(Gearbox.ModelData.UpshiftMinAcceleration))
{
EstimateAccelerationForGear(currentGear + 1, outAngularVelocity)
.IsSmaller(Gearbox.ModelData.UpshiftMinAcceleration)) {
return currentGear;
}
nextGear = currentGear + 1;
......
......@@ -275,7 +275,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
public KilogramPerSecond GetFuelConsumption(NewtonMeter torque, PerSecond angularVelocity)
{
return FcMap.GetFuelConsumption(torque, angularVelocity, AllowExtrapolation);
return FcMap.GetFuelConsumption(torque, angularVelocity, AllowExtrapolation).Value;
}
}
......
......@@ -344,8 +344,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
container[ModalResultField.Tq_full] = CurrentState.DynamicFullLoadTorque;
container[ModalResultField.Tq_drag] = CurrentState.FullDragTorque;
var fc = ModelData.ConsumptionMap.GetFuelConsumption(CurrentState.EngineTorque, avgEngineSpeed);
var result = ModelData.ConsumptionMap.GetFuelConsumption(CurrentState.EngineTorque, avgEngineSpeed,
DataBus.ExecutionMode != ExecutionMode.Declaration);
if (DataBus.ExecutionMode != ExecutionMode.Declaration && result.Extrapolated) {
Log.Warn("FuelConsumptionMap was extrapolated: range for FC-Map is not sufficient: n: {0}, torque: {2}",
avgEngineSpeed.Value(), CurrentState.EngineTorque.Value());
}
var fc = result.Value;
//TODO mk-2015-11-11: calculate aux start stop correction
var fcAux = fc;
......
......@@ -480,7 +480,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
}
}
if (DataBus.VehicleStopped) {
Disengaged = false;
Disengaged = true;
_engageTime = -double.MaxValue.SI<Second>();
}
AdvanceState();
......
......@@ -62,7 +62,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
public abstract bool ShiftRequired(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity,
NewtonMeter inTorque, PerSecond inAngularSpeed, uint gear, Second lastShiftTime);
public abstract uint InitGear(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outEngineSpeed);
public abstract uint InitGear(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity);
public Gearbox Gearbox { get; set; }
......
......@@ -66,7 +66,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData
var entry = lines[i].Split(',').Select(x => double.Parse(x, CultureInfo.InvariantCulture)).ToArray();
Assert.AreEqual(entry[2].SI().Gramm.Per.Hour.ConvertTo().Kilo.Gramm.Per.Second.Value(),
map.GetFuelConsumption(entry[1].SI<NewtonMeter>(), entry[0].RPMtoRad(), true).Value(), Tolerance);
map.GetFuelConsumption(entry[1].SI<NewtonMeter>(), entry[0].RPMtoRad(), true).Value.Value(), Tolerance);
}
}
}
......
......@@ -86,7 +86,7 @@ namespace TUGraz.VectoCore.Tests.Reports
// check fuel consumption interpolation
var fuelConsumption = (SI)row[(int)ModalResultField.FCMap];
Assert.AreEqual(fuelConsumption.Value(),
engineData.ConsumptionMap.GetFuelConsumption(tqEngFcmap, nEngFcMap).Value(), 1E-3, "time: {0} distance: {1}",
engineData.ConsumptionMap.GetFuelConsumption(tqEngFcmap, nEngFcMap).Value.Value(), 1E-3, "time: {0} distance: {1}",
time, distance);
// check P_eng_FCmap = T_eng_fcmap * n_eng
......
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