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 53716998 authored by Michael KRISPER's avatar Michael KRISPER
Browse files

BatteryElectricMotorController: Corrected Bug when GearboxModelData is null (e.g. E3)

parent 02fcc521
No related branches found
Tags Build/V3.0.1.312
No related merge requests found
using System.Linq;
using TUGraz.VectoCommon.InputData;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.Configuration;
using TUGraz.VectoCore.Models.Declaration;
using TUGraz.VectoCore.Models.Simulation.Impl;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.Utils;
......@@ -26,16 +24,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl {
#region Implementation of IElectricMotorControl
public NewtonMeter MechanicalAssistPower(
Second absTime, Second dt, NewtonMeter outTorque, PerSecond prevOutAngularVelocity, PerSecond currOutAngularVelocity,
NewtonMeter maxDriveTorque, NewtonMeter maxRecuperationTorque,
PowertrainPosition position, bool dryRun)
public NewtonMeter MechanicalAssistPower(Second absTime, Second dt, NewtonMeter outTorque,
PerSecond prevOutAngularVelocity, PerSecond currOutAngularVelocity, NewtonMeter maxDriveTorque,
NewtonMeter maxRecuperationTorque, PowertrainPosition position, bool dryRun)
{
if (!DataBus.GearboxInfo.GearEngaged(absTime) && DataBus.DriverInfo.DrivingAction == DrivingAction.Roll) {
var avgSpeed = (prevOutAngularVelocity + currOutAngularVelocity) / 2;
var inertiaTorqueLoss = avgSpeed.IsEqual(0)
? 0.SI<NewtonMeter>()
: Formulas.InertiaPower(currOutAngularVelocity, prevOutAngularVelocity, ElectricMotorData.Inertia, dt) / avgSpeed;
: Formulas.InertiaPower(currOutAngularVelocity, prevOutAngularVelocity,
ElectricMotorData.Inertia, dt) / avgSpeed;
//var dragTorque = ElectricMotorData.DragCurve.Lookup()
return (-inertiaTorqueLoss); //.LimitTo(maxDriveTorque, maxRecuperationTorque);
}
......@@ -43,8 +41,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl {
DataBus.DriverInfo.DrivingAction == DrivingAction.Roll) {
return null;
}
if (DataBus.VehicleInfo.VehicleSpeed.IsSmallerOrEqual(GearboxModelData.DisengageWhenHaltingSpeed) && outTorque.IsSmaller(0)) {
if (GearboxModelData != null
&& DataBus.VehicleInfo.VehicleSpeed.IsSmallerOrEqual(GearboxModelData.DisengageWhenHaltingSpeed)
&& outTorque.IsSmaller(0)) {
return null;
}
......@@ -52,7 +52,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl {
return null;
}
return (-outTorque).LimitTo(maxDriveTorque, maxRecuperationTorque ?? VectoMath.Max(maxDriveTorque, 0.SI<NewtonMeter>()));
return (-outTorque).LimitTo(maxDriveTorque, maxRecuperationTorque ?? VectoMath.Max(maxDriveTorque, 0.SI<NewtonMeter>()));
}
#endregion
......
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