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

Skip to content
Snippets Groups Projects
Commit 5d8f7edb authored by Stefanos Doumpoulakis's avatar Stefanos Doumpoulakis
Browse files

a)2 implementations for StopStart, b)added test with real engine torque input

parent 0b674cd2
No related branches found
No related tags found
No related merge requests found
......@@ -180,6 +180,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
.AddComponent(gearbox, data.Retarder, container)
.AddComponent(new Clutch(container, data.EngineData));
var engine = new VTPCombustionEngine(container, data.EngineData, pt1Disabled: true);
//var engine = new VTPnoSScombustionEngine(container, data.EngineData, pt1Disabled: true);
var aux = CreateSpeedDependentAuxiliaries(data, container);
var engineFan = new EngineFanAuxiliary(data.FanData.FanCoefficients, data.FanData.FanDiameter);
......
......@@ -38,6 +38,7 @@ using TUGraz.VectoCore.Configuration;
using TUGraz.VectoCore.Models.Connector.Ports.Impl;
using TUGraz.VectoCore.Models.Simulation;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.OutputData;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
......@@ -214,7 +215,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
: DataBus.DrivingCycleInfo.CycleData.LeftSample.EngineSpeed;
}
protected override double WHTCCorrectionFactor(IFuelProperties fuel)
protected override double WHTCCorrectionFactor(IFuelProperties fuel)
{
var selected = ModelData.Fuels.First(x => x.FuelData.FuelType == fuel.FuelType);
......
using System;
using System.Linq;
using TUGraz.VectoCommon.BusAuxiliaries;
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.Configuration;
using TUGraz.VectoCore.Models.Connector.Ports.Impl;
using TUGraz.VectoCore.Models.Simulation;
using TUGraz.VectoCore.Models.Simulation.Data;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.OutputData;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
{
public class VTPnoSScombustionEngine : CombustionEngine
{
private bool firstInit = true;
public VTPnoSScombustionEngine(IVehicleContainer container, CombustionEngineData modelData, bool pt1Disabled = false) : base(container, modelData, pt1Disabled) { }
public override IResponse Initialize(NewtonMeter outTorque, PerSecond outAngularVelocity)
{
if (outAngularVelocity == null) {
outAngularVelocity = EngineIdleSpeed;
}
var auxDemand = EngineAux == null ? 0.SI<NewtonMeter>() : EngineAux.Initialize(outTorque, outAngularVelocity);
if (firstInit) {
PreviousState = new EngineState {
EngineSpeed = outAngularVelocity,
dt = 1.SI<Second>(),
InertiaTorqueLoss = 0.SI<NewtonMeter>(),
StationaryFullLoadTorque = ModelData.FullLoadCurves[DataBus.GearboxInfo.Gear.Gear].FullLoadStationaryTorque(outAngularVelocity),
FullDragTorque = ModelData.FullLoadCurves[DataBus.GearboxInfo.Gear.Gear].DragLoadStationaryTorque(outAngularVelocity),
EngineTorque = outTorque + auxDemand,
EnginePower = (outTorque + auxDemand) * outAngularVelocity,
};
PreviousState.DynamicFullLoadTorque = PreviousState.StationaryFullLoadTorque;
}
return new ResponseSuccess(this) {
Engine = {
PowerRequest = PreviousState.EnginePower,
EngineSpeed = outAngularVelocity
}
};
}
protected override IResponse DoHandleRequest(Second absTime, Second dt, NewtonMeter torqueReq,
PerSecond angularVelocity, bool dryRun)
{
firstInit = false;
var powerDemand = angularVelocity * torqueReq;
var avgEngineSpeed = GetEngineSpeed(angularVelocity);
var torqueOut = powerDemand / avgEngineSpeed;
var fullDragTorque = ModelData.FullLoadCurves[DataBus.GearboxInfo.Gear.Gear].DragLoadStationaryTorque(avgEngineSpeed);
var fullLoadTorque = ModelData.FullLoadCurves[DataBus.GearboxInfo.Gear.Gear].FullLoadStationaryTorque(avgEngineSpeed);
var inertiaTorqueLoss =
Formulas.InertiaPower(angularVelocity, PreviousState.EngineSpeed, ModelData.Inertia, dt) /
avgEngineSpeed;
if (EngineAux != null) {
EngineAux.Initialize(0.SI<NewtonMeter>(), avgEngineSpeed);
}
var auxTorqueDemand = EngineAux == null
? 0.SI<NewtonMeter>()
: EngineAux.TorqueDemand(absTime, dt, torqueOut, avgEngineSpeed, dryRun);
// compute the torque the engine has to provide. powertrain + aux + its own inertia
var totalTorqueDemand = torqueOut + auxTorqueDemand + inertiaTorqueLoss;
Log.Debug("EngineInertiaTorque: {0}", inertiaTorqueLoss);
Log.Debug("Drag Curve: torque: {0}, power: {1}", fullDragTorque, fullDragTorque * avgEngineSpeed);
var deltaFull = totalTorqueDemand - fullLoadTorque;
var deltaDrag = totalTorqueDemand - fullDragTorque;
if (dryRun) {
return new ResponseDryRun(this) {
DeltaFullLoad = deltaFull * avgEngineSpeed,
DeltaDragLoad = deltaDrag * avgEngineSpeed,
DeltaEngineSpeed = 0.RPMtoRad(),
Engine = {
PowerRequest = torqueOut * avgEngineSpeed,
DynamicFullLoadPower = fullLoadTorque * avgEngineSpeed,
DragPower = fullDragTorque * avgEngineSpeed,
EngineSpeed = angularVelocity,
AuxiliariesPowerDemand = auxTorqueDemand * avgEngineSpeed,
},
};
}
CurrentState.dt = dt;
CurrentState.EngineSpeed = angularVelocity;
CurrentState.EngineTorqueOut = torqueOut;
CurrentState.FullDragTorque = fullDragTorque;
CurrentState.DynamicFullLoadTorque = fullLoadTorque;
CurrentState.StationaryFullLoadTorque = fullLoadTorque;
CurrentState.InertiaTorqueLoss = inertiaTorqueLoss;
if ((deltaFull * avgEngineSpeed).IsGreater(0.SI<Watt>(), Constants.SimulationSettings.LineSearchTolerance) &&
(deltaDrag * avgEngineSpeed).IsSmaller(0.SI<Watt>(), Constants.SimulationSettings.LineSearchTolerance)) {
//throw new VectoSimulationException(
Log.Error(
"Unexpected condition: requested torque_out is above gearbox full-load and engine is below drag load! deltaFull: {0}, deltaDrag: {1}",
deltaFull, deltaDrag);
}
var minTorque = CurrentState.FullDragTorque;
var maxTorque = CurrentState.DynamicFullLoadTorque;
try {
CurrentState.EngineTorque = totalTorqueDemand.LimitTo(minTorque, maxTorque);
} catch (Exception) {
var extrapolated = avgEngineSpeed > ModelData.FullLoadCurves[0].FullLoadEntries.Last().EngineSpeed;
Log.Error("Engine full-load torque is below drag torque. max_torque: {0}, drag_torque: {1}, extrapolated: {2}", maxTorque, minTorque, extrapolated);
throw;
}
CurrentState.EnginePower = CurrentState.EngineTorque * avgEngineSpeed;
if (totalTorqueDemand.IsGreater(0) &&
(deltaFull * avgEngineSpeed).IsGreater(0, Constants.SimulationSettings.LineSearchTolerance)) {
Log.Debug("requested engine power exceeds fullload power: delta: {0}", deltaFull);
return new ResponseOverload(this) {
AbsTime = absTime,
Delta = deltaFull * avgEngineSpeed,
Engine = {
PowerRequest = totalTorqueDemand * avgEngineSpeed,
DynamicFullLoadPower = fullLoadTorque * avgEngineSpeed,
DragPower = CurrentState.FullDragTorque * avgEngineSpeed,
EngineSpeed = angularVelocity,
AuxiliariesPowerDemand = auxTorqueDemand * avgEngineSpeed,
},
};
}
if (totalTorqueDemand.IsSmaller(0) &&
(deltaDrag * avgEngineSpeed).IsSmaller(0, Constants.SimulationSettings.LineSearchTolerance)) {
Log.Debug("requested engine power is below drag power: delta: {0}", deltaDrag);
return new ResponseUnderload(this) {
AbsTime = absTime,
Delta = deltaDrag * avgEngineSpeed,
Engine = {
PowerRequest = totalTorqueDemand * avgEngineSpeed,
DynamicFullLoadPower = fullLoadTorque * avgEngineSpeed,
DragPower = CurrentState.FullDragTorque * avgEngineSpeed,
EngineSpeed = angularVelocity,
AuxiliariesPowerDemand = auxTorqueDemand * avgEngineSpeed,
},
};
}
//UpdateEngineState(CurrentState.EnginePower, avgEngineSpeed);
return new ResponseSuccess(this) {
Engine = {
PowerRequest = totalTorqueDemand * avgEngineSpeed,
DynamicFullLoadPower = fullLoadTorque * avgEngineSpeed,
DragPower = CurrentState.FullDragTorque * avgEngineSpeed,
EngineSpeed = angularVelocity,
AuxiliariesPowerDemand = auxTorqueDemand * avgEngineSpeed,
},
};
}
protected override PerSecond GetEngineSpeed(PerSecond angularSpeed)
{
// When speed is below idle, clip to idle to avoid crashing.
// Returning zero causes crashes (divide by zero, etc).
return (DataBus.DrivingCycleInfo.CycleData.LeftSample.EngineSpeed < EngineIdleSpeed)
? EngineIdleSpeed
: DataBus.DrivingCycleInfo.CycleData.LeftSample.EngineSpeed;
}
protected override void DoWriteModalResults(Second time, Second simulationInterval, IModalDataContainer container)
{
base.DoWriteModalResults(time, simulationInterval, container);
var avgEngineSpeed = GetEngineSpeed(CurrentState.EngineSpeed);
foreach (var fuel in ModelData.Fuels) {
var result = fuel.ConsumptionMap.GetFuelConsumption(
CurrentState.EngineTorque, avgEngineSpeed,
DataBus.ExecutionMode != ExecutionMode.Declaration);
var fuelData = fuel.FuelData;
bool aboveIdleSpeed = (DataBus.DrivingCycleInfo.CycleData.LeftSample.EngineSpeed >= EngineIdleSpeed);
var fc = aboveIdleSpeed ? result.Value : 0.SI<KilogramPerSecond>();
var fcNCVcorr = fc * fuelData.HeatingValueCorrection;
var fcWHTC = fcNCVcorr * WHTCCorrectionFactor(fuel.FuelData);
var advancedAux = EngineAux as BusAuxiliariesAdapter;
if (advancedAux != null) {
advancedAux.DoWriteModalResultsICE(time, simulationInterval, container);
}
var fcFinal = fcWHTC;
container[ModalResultField.FCMap, fuelData] = fc;
container[ModalResultField.FCNCVc, fuel.FuelData] = fcNCVcorr;
container[ModalResultField.FCWHTCc, fuel.FuelData] = fcWHTC;
container[ModalResultField.FCFinal, fuel.FuelData] = fcFinal;
}
}
protected override double WHTCCorrectionFactor(IFuelProperties fuel)
{
var selected = ModelData.Fuels.First(x => x.FuelData.FuelType == fuel.FuelType);
if (DataBus.DrivingCycleInfo.CycleData.LeftSample.VehicleTargetSpeed >= Constants.SimulationSettings.HighwaySpeedThreshold) {
return selected.WHTCMotorway;
}
if (DataBus.DrivingCycleInfo.CycleData.LeftSample.VehicleTargetSpeed >= Constants.SimulationSettings.RuralSpeedThreshold) {
return selected.WHTCRural;
}
return selected.WHTCUrban;
}
}
}
......@@ -356,6 +356,7 @@
<Compile Include="Models\SimulationComponent\Impl\StopStartCombustionEngine.cs" />
<Compile Include="Models\SimulationComponent\Impl\VelocityRollingLookup.cs" />
<Compile Include="Models\SimulationComponent\Impl\VelocitySpeedGearshiftPreprocessor.cs" />
<Compile Include="Models\SimulationComponent\Impl\VTPnoSScombustionEngine.cs" />
<Compile Include="Models\Simulation\DataBus\IEngineControl.cs" />
<Compile Include="Models\Simulation\DataBus\IGearboxControl.cs" />
<Compile Include="Models\Simulation\Data\ShiftStrategyParameters.cs" />
......
......@@ -85,17 +85,24 @@ namespace TUGraz.VectoCore.Tests.Integration.VTP
}
private const string STOP_START_JOB = @"TestData\Integration\VTPMode\Group2_RigidTruck_4x2\Class2_RigidTruck_DECL_SS_VTP.vecto";
private const string POLLUTANTS_JOB = @"TestData\Integration\VTPMode\Group2_RigidTruck_4x2\Class2_RigidTruck_VTP_pollutants.vecto";
private const string PEL_FAN_JOB = @"TestData\Integration\VTPMode\GenericVehicle\class_5_generic vehicle_DECL_FanPel.vecto";
private const string DUAL_FUEL_JOB = @"TestData\Integration\VTPMode\DualFuelVehicle\VTP_DualFuel.vecto";
private const string DUAL_FUEL_STOP_START_JOB = @"TestData\Integration\VTPMode\DualFuelVehicle\VTP_StopStart_DualFuel.vecto";
[Category("JRC")]
[Category("LongRunning")]
[Category("Integration")]
[TestCase(@"TestData\Integration\VTPMode\GenericVehicle\class_5_generic vehicle_DECL.vecto", 4.44E-08, 0.8972, TestName = "Generic Group 5 VTP Test Declaration Mode"),
TestCase(@"TestData\Integration\VTPMode\GenericVehicle XMLJob PTO\class_5_generic vehicle_DECL.vecto", 4.45E-08, 0.8925, TestName = "Generic Group 5 VTP Test Declaration Mode with PTO"),
[
TestCase(@"TestData\Integration\VTPMode\GenericVehicle\class_5_generic vehicle_DECL.vecto", 4.44E-08, 0.8972, TestName = "Generic Group 5 VTP Test Declaration Mode"),
TestCase(@"TestData\Integration\VTPMode\GenericVehicle XMLJob PTO\class_5_generic vehicle_DECL.vecto", 4.45E-08, 0.8925, TestName = "Generic Group 5 VTP Test Declaration Mode with PTO"),
TestCase(@"TestData\Integration\VTPMode\GenericVehicle\class_3_generic vehicle_DECL.vecto", 1.26E-07, 1.0068, TestName = "Generic Group 3 VTP Test Declaration Mode"),
TestCase(@"TestData\Integration\VTPMode\Group2_RigidTruck_4x2\Class2_RigidTruck_DECL_SS_VTP.vecto", 7.89E-08, 1.0099, TestName = "Class 2 RigidTruck VTP StopStart"),
TestCase(@"TestData\Integration\VTPMode\GenericVehicle\class_5_generic vehicle_DECL_FanPel.vecto", 4.44E-08, 0.8968, TestName = "Generic Group 5 VTP Test Declaration Mode Fan Electrical Power"),
TestCase(@"TestData\Integration\VTPMode\GenericVehicle\class_5_generic vehicle_DECL_pollutants.vecto", 4.44E-08, 0.8972, TestName = "Generic Group 5 VTP Test Declaration Mode Pollutnats"),
TestCase(@"TestData\Integration\VTPMode\DualFuelVehicle\VTP_DualFuel.vecto", 4.71E-09, 1.0107, TestName = "RunVTPDualFuel_Declaration"),
TestCase(@"TestData\Integration\VTPMode\DualFuelVehicle\VTP_StopStart_DualFuel.vecto", 4.71E-09, 1.0105, TestName = "RunVTPDualFuel_StopStart")
TestCase(STOP_START_JOB, 7.89E-08, 1.0099, TestName = "VTP StopStart"),
TestCase(PEL_FAN_JOB, 4.44E-08, 0.8968, TestName = "VTP Fan Electrical Power"),
TestCase(POLLUTANTS_JOB, 7.89E-08, 1.0082, TestName = "VTP Pollutants"),
TestCase(DUAL_FUEL_JOB, 4.71E-09, 1.0107, TestName = "VTP Dual Fuel"),
TestCase(DUAL_FUEL_STOP_START_JOB, 4.71E-09, 1.0105, TestName = "VTP Dual Fuel StopStart")
]
public void RunVTP_Declaration(string jobFile, double expectedDeclaredCO2, double expectedCVTP)
{
......
{
"Header": {
"CreatedBy": "",
"Date": "2021-12-01T12:41:11.9871671Z",
"AppVersion": "3",
"FileVersion": 4
},
"Body": {
"SavedInDeclMode": true,
"DeclarationVehicle": "Class2_RigidTruck_DECL_SS.xml",
"ManufacturerRecord": "Class2_RigidTruck_DECL_SS.RSLT_MANUFACTURER.xml",
"Mileage": 20000.0,
"FanPowerCoefficients": [
7.32,
1200.0,
810.0
],
"FanDiameter": 0.225,
"Cycles": [
"VTP_LongHaulReferenceLoad.vdri"
]
}
}
\ No newline at end of file
......@@ -2646,6 +2646,15 @@
<None Include="TestData\Integration\VTPMode\Group2_RigidTruck_4x2\Class2_RigidTruck_DECL_SS_VTP.vecto">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestData\Integration\VTPMode\Group2_RigidTruck_4x2\Class2_RigidTruck_VTP_pollutants.vecto">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestData\Integration\VTPMode\Group2_RigidTruck_4x2\VTP_LongHaulReferenceLoad.vdri">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestData\Integration\VTPMode\Group2_RigidTruck_4x2\VTP_RegionalDeliveryReferenceLoad.vdri">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestData\Jobs\12t Delivery Truck Engineering Efficiency.vecto">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
......
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