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

removed EngineOnlyGearbox (not needed anymore in engine only mode)

parent b941003c
No related branches found
No related tags found
No related merge requests found
Showing
with 78 additions and 53 deletions
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using Newtonsoft.Json.Linq;
using NLog;
using NLog.Fluent;
using TUGraz.VectoCore.Configuration;
using TUGraz.VectoCore.Exceptions;
using TUGraz.VectoCore.InputData.Impl;
using TUGraz.VectoCore.Models;
using TUGraz.VectoCore.Models.Declaration;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.Utils;
......@@ -175,7 +171,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
public JSONInputDataV2(JObject data, string filename) : base(data, filename)
{
_jobname = Path.GetFileName(filename);
_jobname = Path.GetFileNameWithoutExtension(filename);
try {
var gearboxFile = Body.GetEx(JsonKeys.Vehicle_GearboxFile).Value<string>();
if (!EmptyOrInvalidFileName(gearboxFile)) {
......
......@@ -61,7 +61,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl
Cycle = cycle,
Retarder = dao.CreateRetarderData(InputDataProvider.RetarderInputData),
DriverData = driverdata,
IsEngineOnly = false, // InputDataProvider.JobInputData().EngineOnlyMode,
IsEngineOnly = false,
JobName = InputDataProvider.JobInputData().JobName,
ModFileSuffix = loading.Key.ToString(),
Report = Report,
......
......@@ -56,12 +56,10 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
{
var cycle = new PowertrainDrivingCycle(_container, data.Cycle);
var gearbox = new ManualGearbox(_container);
cycle.InPort().Connect(gearbox.OutPort());
var directAux = new Auxiliary(_container);
directAux.AddDirect(cycle);
gearbox.InPort().Connect(directAux.OutPort());
cycle.InPort().Connect(directAux.OutPort());
var engine = new EngineOnlyCombustionEngine(_container, data.EngineData);
directAux.InPort().Connect(engine.OutPort());
......
......@@ -29,7 +29,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
public EngineOnlyCombustionEngine(IVehicleContainer cockpit, CombustionEngineData data) : base(cockpit, data) {}
// the behavior in engin-only mode differs a little bit from normal driving cycle simulation: in engine-only mode
// the behavior in engine-only mode differs a little bit from normal driving cycle simulation: in engine-only mode
// certain amount of overload is tolerated.
protected override IResponse DoHandleRequest(Second absTime, Second dt, NewtonMeter torque, PerSecond engineSpeed,
bool dryRun)
......@@ -46,8 +46,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
if (dryRun) {
return new ResponseDryRun {
DeltaFullLoad = (requestedEnginePower - CurrentState.DynamicFullLoadPower),
DeltaDragLoad = (requestedEnginePower - CurrentState.FullDragPower)
DeltaFullLoad = requestedEnginePower - CurrentState.DynamicFullLoadPower,
DeltaDragLoad = requestedEnginePower - CurrentState.FullDragPower
};
}
......@@ -59,11 +59,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
return new ResponseSuccess();
}
/// <summary>
/// [W] => [W]
/// </summary>
/// <param name="requestedEnginePower">[W]</param>
/// <returns>[W]</returns>
protected override Watt LimitEnginePower(Watt requestedEnginePower)
{
if (requestedEnginePower > CurrentState.DynamicFullLoadPower) {
......
......@@ -210,7 +210,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
/// <item><description>ResponseGearshift</description></item>
/// </list>
/// </returns>
public IResponse Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity, bool dryRun)
public virtual IResponse Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity, bool dryRun)
{
Log.Debug("Gearbox Power Request: torque: {0}, angularVelocity: {1}", torque, angularVelocity);
if (DataBus.VehicleStopped) {
......
......@@ -18,7 +18,9 @@ using TUGraz.VectoCore.Configuration;
using TUGraz.VectoCore.Models.Connector.Ports;
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
......@@ -39,6 +41,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
Gear = DataBus.Gear;
}
if (Data == null || Data.Gears == null) {
var r = NextComponent.Initialize(outTorque, outAngularVelocity);
if (r is ResponseSuccess) {
PreviousInAngularSpeed = outAngularVelocity;
Disengaged = false;
}
return r;
}
var inAngularVelocity = outAngularVelocity * Data.Gears[Gear].Ratio;
var inTorque = Data.Gears[Gear].LossMap.GetInTorque(inAngularVelocity, outTorque);
......@@ -57,6 +68,30 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
return response;
}
/// <summary>
/// Requests the Gearbox to deliver torque and angularVelocity
/// </summary>
/// <returns>
/// <list type="bullet">
/// <item><description>ResponseDryRun</description></item>
/// <item><description>ResponseOverload</description></item>
/// <item><description>ResponseGearshift</description></item>
/// </list>
/// </returns>
public override IResponse Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity,
bool dryRun)
{
Log.Debug("Gearbox Power Request: torque: {0}, angularVelocity: {1}", torque, angularVelocity);
IResponse retVal;
if (ClutchClosed(absTime)) {
retVal = RequestGearEngaged(absTime, dt, torque, angularVelocity, dryRun);
} else {
retVal = RequestGearDisengaged(absTime, dt, torque, angularVelocity, dryRun);
}
return retVal;
}
/// <summary>
/// Requests the gearbox in engaged mode. Sets the gear if no gear was set previously.
......@@ -78,6 +113,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
Log.Debug("Gearbox engaged gear {0}", Gear);
}
if (Data == null || Data.Gears == null) {
var r = NextComponent.Request(absTime, dt, outTorque, outAngularVelocity);
r.GearboxPowerRequest = outTorque * outAngularVelocity;
PreviousInAngularSpeed = outAngularVelocity;
return r;
}
var inEngineSpeed = outAngularVelocity * Data.Gears[Gear].Ratio;
var inTorque = outAngularVelocity.IsEqual(0)
? outTorque / Data.Gears[Gear].Ratio
......@@ -118,5 +160,19 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
}
#endregion
protected override void DoWriteModalResults(IModalDataContainer container)
{
container[ModalResultField.Gear] = Gear;
container[ModalResultField.PlossGB] = PowerLoss;
container[ModalResultField.PaGB] = PowerLossInertia;
}
protected override void DoCommitSimulationStep()
{
if (Data != null && Data.Gears != null) {
base.DoCommitSimulationStep();
}
}
}
}
\ No newline at end of file
......@@ -26,22 +26,14 @@ namespace TUGraz.VectoCore.OutputData.FileIO
public string GetModDataFileName(string runName, string cycleName, string runSuffix)
{
//var modFilePattern = Path.Combine(_basePath,
// runName.Replace(Constants.FileExtensions.VectoJobFile, "") + "_{0}{1}" +
// Constants.FileExtensions.ModDataFile);
//var modFileName = string.Format(modFilePattern, cycleName, runSuffix ?? "");
var modFileName = new StringBuilder(runName);
if (!string.IsNullOrEmpty(cycleName) || !string.IsNullOrEmpty(runSuffix)) {
modFileName.Append("_");
if (!string.IsNullOrEmpty(cycleName)) {
modFileName.Append(cycleName);
}
if (!string.IsNullOrEmpty(runSuffix)) {
modFileName.Append(cycleName);
}
string modFileName;
if (!string.IsNullOrWhiteSpace(cycleName) || !string.IsNullOrWhiteSpace(runSuffix)) {
modFileName = string.Format("{0}_{1}{2}{3}", runName, cycleName, runSuffix, Constants.FileExtensions.ModDataFile);
} else {
modFileName = string.Format("{0}{1}", runName, Constants.FileExtensions.ModDataFile);
}
modFileName.Append(Constants.FileExtensions.ModDataFile);
return modFileName.ToString();
return Path.Combine(_basePath, modFileName);
}
public void WriteModData(string runName, string cycleName, string runSuffix, DataTable modData)
......
......@@ -221,7 +221,7 @@
<Compile Include="Models\Declaration\VehicleCategory.cs" />
<Compile Include="Models\SimulationComponent\Data\VehicleData.cs" />
<Compile Include="Models\SimulationComponent\IClutch.cs" />
<Compile Include="Models\SimulationComponent\IEngineOnlyDrivingCycle.cs" />
<Compile Include="Models\SimulationComponent\IPowertrainSimulation.cs" />
<Compile Include="Models\SimulationComponent\IDrivingCycle.cs" />
<Compile Include="Models\SimulationComponent\IDriver.cs" />
<Compile Include="Models\SimulationComponent\Impl\Vehicle.cs" />
......
......@@ -42,7 +42,7 @@ namespace TUGraz.VectoCore.Tests.FileIO
Assert.AreEqual(false, runData.IsEngineOnly);
Assert.AreEqual(Path.GetFileName(DeclarationJob), runData.JobName);
Assert.AreEqual(Path.GetFileNameWithoutExtension(DeclarationJob), runData.JobName);
Assert.AreEqual(5850, runData.VehicleData.CurbWeight.Value());
Assert.AreEqual(1900, runData.VehicleData.CurbWeigthExtra.Value()); // taken from segmentation table
Assert.AreEqual(11900, runData.VehicleData.GrossVehicleMassRating.Value());
......
......@@ -50,12 +50,10 @@ namespace TUGraz.VectoCore.Tests.Integration.EngineOnlyCycle
var aux = new Auxiliary(vehicle);
aux.AddDirect(cycle);
var gearbox = new ManualGearbox(vehicle);
var engine = new EngineOnlyCombustionEngine(vehicle, engineData);
aux.InPort().Connect(engine.OutPort());
gearbox.InPort().Connect(aux.OutPort());
var port = aux.OutPort();
var absTime = 0.SI<Second>();
......@@ -89,11 +87,7 @@ namespace TUGraz.VectoCore.Tests.Integration.EngineOnlyCycle
var vehicleContainer = new VehicleContainer();
var gearbox = new ManualGearbox(vehicleContainer);
var engine = new CombustionEngine(vehicleContainer,
MockSimulationDataFactory.CreateEngineDataFromFile(EngineFile));
gearbox.InPort().Connect(engine.OutPort());
var engine = new CombustionEngine(vehicleContainer, MockSimulationDataFactory.CreateEngineDataFromFile(EngineFile));
var absTime = 0.SI<Second>();
var dt = 1.SI<Second>();
......@@ -101,7 +95,7 @@ namespace TUGraz.VectoCore.Tests.Integration.EngineOnlyCycle
var angularVelocity = 644.4445.RPMtoRad();
var power = 2329.973.SI<Watt>();
gearbox.OutPort().Request(absTime, dt, power / angularVelocity, angularVelocity);
engine.OutPort().Request(absTime, dt, power / angularVelocity, angularVelocity);
foreach (var sc in vehicleContainer.SimulationComponents()) {
sc.CommitSimulationStep(dataWriter);
......
......@@ -40,7 +40,6 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
var container = job.GetContainer();
Assert.AreEqual(560.RPMtoRad(), container.EngineSpeed);
Assert.AreEqual(0U, container.Gear);
}
[TestMethod]
......@@ -110,7 +109,8 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
jobContainer.WaitFinished();
ResultFileHelper.TestSumFile(@"TestData\Results\EngineOnlyCycles\24t Coach.vsum", @"24t Coach.vsum");
ResultFileHelper.TestSumFile(@"TestData\Results\EngineOnlyCycles\24t Coach.vsum",
@"TestData\Jobs\24t Coach EngineOnly.vsum");
ResultFileHelper.TestModFiles(new[] {
@"TestData\Results\EngineOnlyCycles\24t Coach_Engine Only1.vmod",
......
......@@ -85,8 +85,6 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
var engineData = MockSimulationDataFactory.CreateEngineDataFromFile(CoachEngine);
var engine = new CombustionEngine(vehicle, engineData);
new ManualGearbox(vehicle);
var port = engine.OutPort();
var absTime = 0.SI<Second>();
......@@ -103,7 +101,6 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
var vehicle = new VehicleContainer();
var engineData = MockSimulationDataFactory.CreateEngineDataFromFile(CoachEngine);
var engine = new CombustionEngine(vehicle, engineData);
var gearbox = new ManualGearbox(vehicle);
var port = engine.OutPort();
var absTime = 0.SI<Second>();
......@@ -165,17 +162,14 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
public void TestEngineFullLoadJump()
{
var vehicleContainer = new VehicleContainer();
var gearbox = new ManualGearbox(vehicleContainer);
var engineData =
MockSimulationDataFactory.CreateEngineDataFromFile(
TestContext.DataRow["EngineFile"].ToString());
var engine = new EngineOnlyCombustionEngine(vehicleContainer, engineData);
gearbox.InPort().Connect(engine.OutPort());
var expectedResults = VectoCSVFile.Read(TestContext.DataRow["ResultFile"].ToString());
var requestPort = gearbox.OutPort();
var requestPort = engine.OutPort();
//var modalData = new ModalDataWriter(string.Format("load_jump_{0}.csv", TestContext.DataRow["TestName"].ToString()));
var modalData = new MockModalDataContainer();
......
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