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

Skip to content
Snippets Groups Projects
Commit 53c63458 authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

fix reading parameters for serial hybrid strategy

powertrain builder serial hybrid: connect genset to charger port of electric system
serial hybrid controller: handle responses where state in the powertrain does not match
update S2 testcase
parent 869c1ae3
No related branches found
No related tags found
No related merge requests found
......@@ -45,9 +45,10 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
public double EquivalenceFactorDischarge => double.NaN;
public double EquivalenceFactorCharge => double.NaN;
public double MinSoC { get; }
public double MinSoC => Body.GetEx<double>("MinSoC") / 100.0;
public double MaxSoC => double.NaN;
public double TargetSoC { get; }
public double TargetSoC => Body.GetEx<double>("TargetSoC") / 100.0;
public Second MinimumICEOnTime => null;
public Second AuxBufferTime => null;
public Second AuxBufferChargeTime => null;
......
......@@ -744,8 +744,12 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
container.ModData?.AddElectricMotor(pos);
ctl.AddElectricMotor(pos, motorData.Item2);
var motor = new ElectricMotor(container, motorData.Item2, ctl.ElectricMotorControl(pos), pos);
motor.Connect(es);
return motor;
if (pos == PowertrainPosition.GEN) {
es.Connect(new GensetChargerAdapter(motor));
} else {
motor.Connect(es);
}
return motor;
}
private static IElectricMotor GetElectricMachine(PowertrainPosition pos,
......
......@@ -2,6 +2,7 @@
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.Models.Connector.Ports.Impl;
using TUGraz.VectoCore.Models.Simulation.DataBus;
using TUGraz.VectoCore.Models.SimulationComponent.Impl;
namespace TUGraz.VectoCore.Models.SimulationComponent
{
......@@ -21,6 +22,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent
public interface IElectricSystem : IElectricSystemInfo
{
IElectricSystemResponse Request(Second absTime, Second dt, Watt powerDemand, bool dryRun = false);
void Connect(IElectricChargerPort charger);
}
public interface IElectricEnergyStorage : IBatteryProvider, IRESSInfo
......
......@@ -68,6 +68,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
};
}
public void Connect(IElectricChargerPort charger)
{
throw new System.NotImplementedException();
}
#endregion
}
}
......
......@@ -67,65 +67,89 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
public IResponse Request(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, bool dryRun)
{
var strategyResponse = Strategy.Request(absTime, dt, outTorque, outAngularVelocity, dryRun);
if (strategyResponse is HybridStrategyLimitedResponse ovl) {
if (dryRun) {
return new ResponseDryRun(this) {
DeltaDragLoad = ovl.Delta,
DeltaFullLoad = ovl.Delta,
// TODO! delta full/drag torque
DeltaEngineSpeed = ovl.DeltaEngineSpeed,
Gearbox = {
InputTorque = ovl.GearboxResponse?.InputTorque,
InputSpeed = ovl.GearboxResponse?.InputSpeed,
OutputTorque = ovl.GearboxResponse?.OutputTorque,
OutputSpeed = ovl.GearboxResponse?.OutputSpeed,
PowerRequest = ovl.GearboxResponse?.PowerRequest,
Gear = ovl.GearboxResponse?.Gear
}
var retry = false;
var retryCount = 0;
IResponse retVal;
do {
if (retryCount > 10) {
throw new VectoException("SerialHybridStrategy: retry count exceeded! {0}", DebugData);
}
retry = false;
var strategyResponse = Strategy.Request(absTime, dt, outTorque, outAngularVelocity, dryRun);
if (strategyResponse is HybridStrategyLimitedResponse ovl) {
if (dryRun) {
return new ResponseDryRun(this) {
DeltaDragLoad = ovl.Delta,
DeltaFullLoad = ovl.Delta,
// TODO! delta full/drag torque
DeltaEngineSpeed = ovl.DeltaEngineSpeed,
Gearbox = {
InputTorque = ovl.GearboxResponse?.InputTorque,
InputSpeed = ovl.GearboxResponse?.InputSpeed,
OutputTorque = ovl.GearboxResponse?.OutputTorque,
OutputSpeed = ovl.GearboxResponse?.OutputSpeed,
PowerRequest = ovl.GearboxResponse?.PowerRequest,
Gear = ovl.GearboxResponse?.Gear
}
};
}
return new ResponseOverload(this) {
Delta = ovl.Delta
};
}
return new ResponseOverload(this) {
Delta = ovl.Delta
};
}
var strategySettings = strategyResponse as HybridStrategyResponse;
ApplyStrategySettings(strategySettings);
CurrentStrategySettings = strategySettings;
if (!dryRun) {
CurrentState.SetState(outTorque, outAngularVelocity, outTorque, outAngularVelocity);
CurrentState.StrategyResponse = strategySettings;
}
// Todo: re-think for S2 configuration....
//if (!dryRun && /*!DataBus.EngineInfo.EngineOn &&*/ strategySettings.ShiftRequired) {
// DataBus.GearboxCtl.TriggerGearshift(absTime, dt);
// _shiftStrategy.SetNextGear(strategySettings.NextGear);
// SelectedGear = strategySettings.NextGear;
// if (!DataBus.GearboxInfo.GearboxType.AutomaticTransmission()) {
// return new ResponseGearShift(this);
// }
//}
var strategySettings = strategyResponse as HybridStrategyResponse;
ApplyStrategySettings(strategySettings);
CurrentStrategySettings = strategySettings;
if (!dryRun) {
CurrentState.SetState(outTorque, outAngularVelocity, outTorque, outAngularVelocity);
CurrentState.StrategyResponse = strategySettings;
}
var gensetResponse = GenSetPort.Request(absTime, dt, 0.SI<NewtonMeter>(), _electricMotorTorque[PowertrainPosition.GEN].Item1, dryRun);
// Todo: re-think for S2 configuration....
//if (!dryRun && /*!DataBus.EngineInfo.EngineOn &&*/ strategySettings.ShiftRequired) {
// DataBus.GearboxCtl.TriggerGearshift(absTime, dt);
// _shiftStrategy.SetNextGear(strategySettings.NextGear);
// SelectedGear = strategySettings.NextGear;
// if (!DataBus.GearboxInfo.GearboxType.AutomaticTransmission()) {
// return new ResponseGearShift(this);
// }
//}
var gensetResponse = GenSetPort.Request(absTime, dt, 0.SI<NewtonMeter>(),
_electricMotorTorque[PowertrainPosition.GEN].Item1, dryRun);
if (!(gensetResponse is ResponseSuccess || gensetResponse is ResponseDryRun)) {
throw new VectoException("Invalid operating point for Genset provided by strategy! {0}",
gensetResponse);
}
if (!(gensetResponse is ResponseSuccess || gensetResponse is ResponseDryRun)) {
throw new VectoException("Invalid operating point for Genset provided by strategy! {0}", gensetResponse);
}
retVal = NextComponent.Request(absTime, dt, outTorque, outAngularVelocity, dryRun);
DebugData.Add(new {
DrivingAction = DataBus.DriverInfo.DrivingAction,
StrategySettings = strategySettings,
Response = retVal,
DryRun = dryRun
});
if (retVal is ResponseDifferentGearEngaged) {
retryCount++;
retry = true;
Strategy.OperatingpointChangedDuringRequest(absTime, dt, outTorque, outAngularVelocity, dryRun,
retVal);
continue;
}
retVal.HybridController.StrategySettings = strategySettings;
} while (retry);
var retVal = NextComponent.Request(absTime, dt, outTorque, outAngularVelocity, dryRun);
DebugData.Add(new {
DrivingAction = DataBus.DriverInfo.DrivingAction,
StrategySettings = strategySettings,
Response = retVal,
DryRun = dryRun
});
retVal.HybridController.StrategySettings = strategySettings;
var modifiedResponse = Strategy.AmendResponse(retVal, absTime, dt, outTorque, outAngularVelocity, dryRun);
var modifiedResponse =
Strategy.AmendResponse(retVal, absTime, dt, outTorque, outAngularVelocity, dryRun);
return modifiedResponse;
}
......@@ -156,6 +180,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
var strategyResponse = Strategy.Initialize(outTorque, outAngularVelocity);
PreviousState.StrategyResponse = strategyResponse as HybridStrategyResponse;
_electricMotorTorque = PreviousState.StrategyResponse.MechanicalAssistPower;
DuringInitialize = true;
var retVal = NextComponent.Initialize(outTorque, outAngularVelocity);
if (DataBus.GearboxInfo != null) {
SelectedGear = DataBus.GearboxInfo.Gear;
......@@ -164,9 +191,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
GenSetPort.Initialize(0.SI<NewtonMeter>(), DataBus.EngineInfo.EngineIdleSpeed);
DuringInitialize = false;
return retVal;
}
protected bool DuringInitialize { get; set; }
#endregion
#region Implementation of IHybridControllerInfo
......@@ -216,8 +247,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
#endregion
private NewtonMeter MechanicalAssistPower(PowertrainPosition pos, Second absTime, Second dt,
NewtonMeter outTorque, PerSecond prevOutAngularVelocity, PerSecond currOutAngularVelocity, bool dryRun)
NewtonMeter outTorque, PerSecond prevOutAngularVelocity, PerSecond currOutAngularVelocity, NewtonMeter maxDriveTorque, NewtonMeter maxRecuperationTorque, bool dryRun)
{
if (DuringInitialize && pos == PowertrainPosition.BatteryElectricE2) {
return (-outTorque).LimitTo(maxDriveTorque, maxRecuperationTorque ?? VectoMath.Max(maxDriveTorque, 0.SI<NewtonMeter>()));
}
return _electricMotorTorque[pos]?.Item2;
//return CurrentState.StrategyResponse.MechanicalAssistPower[pos];
......@@ -277,7 +312,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
NewtonMeter maxDriveTorque, NewtonMeter maxRecuperationTorque, PowertrainPosition position, bool dryRun)
{
return _controller.MechanicalAssistPower(position, absTime, dt, outTorque, prevOutAngularVelocity,
currOutAngularVelocity, dryRun);
currOutAngularVelocity, maxDriveTorque, maxRecuperationTorque, dryRun);
}
}
......
......@@ -416,6 +416,20 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies
protected DrivetrainDemand GetDrivetrainPowerDemand(Second absTime, Second dt, NewtonMeter outTorque,
PerSecond outAngularVelocity, GenSetOperatingPoint maxPowerGenset)
{
if (TestPowertrain.Gearbox != null) {
var currentGear = DataBus.VehicleInfo.VehicleStopped
? (DataBus.GearboxInfo as Gearbox).NextGear
: PreviousState.GearboxEngaged ? DataBus.GearboxInfo.Gear : (DataBus.GearboxInfo as Gearbox).NextGear;
TestPowertrain.Gearbox.PreviousState.InAngularVelocity =
(DataBus.GearboxInfo as Gearbox).PreviousState.InAngularVelocity;
TestPowertrain.Gearbox.Disengaged = (DataBus.GearboxInfo as Gearbox).Disengaged;
TestPowertrain.Gearbox.DisengageGearbox = (DataBus.GearboxInfo as Gearbox).DisengageGearbox;
TestPowertrain.Gearbox.Gear = currentGear;
TestPowertrain.Gearbox._nextGear = (DataBus.GearboxInfo as Gearbox).NextGear;
}
TestPowertrain.Container.VehiclePort.Initialize(DataBus.VehicleInfo.VehicleSpeed, DataBus.DrivingCycleInfo.RoadGradient ?? 0.SI<Radian>());
TestPowertrain.ElectricMotor.ThermalBuffer =
(DataBus.ElectricMotorInfo(EmPosition) as ElectricMotor).ThermalBuffer;
TestPowertrain.ElectricMotor.DeRatingActive =
......@@ -441,6 +455,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies
TestPowertrain.BatterySystem.PreviousState.PowerDemand = (DataBus.BatteryInfo as BatterySystem).PreviousState.PowerDemand;
}
//if (TestPowertrain.Gearbox != null) {
// TestPowertrain.Gearbox.PreviousState.InAngularVelocity =
// (DataBus.GearboxInfo as Gearbox).PreviousState.InAngularVelocity;
// TestPowertrain.Gearbox.Disengaged = (DataBus.GearboxInfo as Gearbox).Disengaged;
// TestPowertrain.Gearbox.DisengageGearbox = (DataBus.GearboxInfo as Gearbox).DisengageGearbox;
// TestPowertrain.Gearbox.Gear = (DataBus.GearboxInfo as Gearbox).Gear;
// TestPowertrain.Gearbox._nextGear = (DataBus.GearboxInfo as Gearbox).NextGear;
//}
TestPowertrain.Charger.ChargingPower = maxPowerGenset.ElectricPower;
TestPowertrain.HybridController.Initialize(Controller.PreviousState.OutTorque,
Controller.PreviousState.OutAngularVelocity);
......@@ -645,7 +668,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies
public void OperatingpointChangedDuringRequest(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity,
bool dryRun, IResponse retVal)
{
throw new NotImplementedException();
}
public void RepeatDrivingAction(Second absTime)
......
......@@ -38,10 +38,13 @@
"MechanicalEfficiency": 1
}
],
"Battery": {
"NumPacks": 2,
"Batteries": [
{
"NumPacks": 1,
"StreamId": 0,
"BatteryFile": "GenericBattery.vreess"
},
}
],
"InitialSoC": 80,
"TorqueLimits": {},
"IdlingSpeed": 0.0,
......
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