Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

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

Merge pull request #108 in VECTO/vecto-sim from...

Merge pull request #108 in VECTO/vecto-sim from ~EMQUARIMA/vecto-sim:feature/VECTO-183-adaptation-of-powertrain-architecture to develop

* commit 'fbaf57ed':
  make tests compile (and partly run) again after refactoring of powertrain architecture
  make sure exactly 5 auxiliaries are provided in declaration mode
  moving auxiliaries 'to the other side of the engine'
  bugfix in json input data provider: add auxiliary even if no path etc. is given...
parents 00a5adc2 fbaf57ed
No related branches found
No related tags found
No related merge requests found
Showing
with 231 additions and 161 deletions
...@@ -433,6 +433,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON ...@@ -433,6 +433,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
}; };
var auxFile = aux["Path"]; var auxFile = aux["Path"];
if (auxFile == null || EmptyOrInvalidFileName(auxFile.Value<string>())) { if (auxFile == null || EmptyOrInvalidFileName(auxFile.Value<string>())) {
retVal.Add(auxData);
continue; continue;
} }
var stream = new StreamReader(Path.Combine(BasePath, auxFile.Value<string>())); var stream = new StreamReader(Path.Combine(BasePath, auxFile.Value<string>()));
......
...@@ -27,6 +27,7 @@ using TUGraz.VectoCore.Models.Simulation.Data; ...@@ -27,6 +27,7 @@ using TUGraz.VectoCore.Models.Simulation.Data;
using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine; using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine;
using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox;
using TUGraz.VectoCore.OutputData;
using TUGraz.VectoCore.Utils; using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdaper namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdaper
...@@ -193,10 +194,24 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdaper ...@@ -193,10 +194,24 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdaper
WarnDeclarationMode("AuxiliariesData"); WarnDeclarationMode("AuxiliariesData");
} }
var retVal = new List<VectoRunData.AuxData>(); var retVal = new List<VectoRunData.AuxData>();
foreach (var auxData in auxInputData.Auxiliaries) {
var aux = new VectoRunData.AuxData { DemandType = AuxiliaryDemandType.Constant }; if (auxInputData.Auxiliaries.Count != 5) {
aux.Technology = auxData.Technology; Log.Error(
switch (AuxiliaryTypeHelper.Parse(auxData.Type)) { "In Declaration Mode exactly 5 Auxiliaries must be defined: Fan, Steering pump, HVAC, Electric System, Pneumatic System.");
throw new VectoException(
"In Declaration Mode exactly 5 Auxiliaries must be defined: Fan, Steering pump, HVAC, Electric System, Pneumatic System.");
}
foreach (var auxType in EnumHelper.GetValues<AuxiliaryType>()) {
var auxData = auxInputData.Auxiliaries.FirstOrDefault(a => AuxiliaryTypeHelper.Parse(a.Type) == auxType);
if (auxData == null) {
throw new VectoException("Auxiliary {0} not found.", auxType);
}
var aux = new VectoRunData.AuxData {
DemandType = AuxiliaryDemandType.Constant,
Technology = auxData.Technology
};
switch (auxType) {
case AuxiliaryType.Fan: case AuxiliaryType.Fan:
aux.PowerDemand = DeclarationData.Fan.Lookup(mission, auxData.Technology); aux.PowerDemand = DeclarationData.Fan.Lookup(mission, auxData.Technology);
aux.ID = Constants.Auxiliaries.IDs.Fan; aux.ID = Constants.Auxiliaries.IDs.Fan;
...@@ -214,9 +229,10 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdaper ...@@ -214,9 +229,10 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdaper
aux.ID = Constants.Auxiliaries.IDs.PneumaticSystem; aux.ID = Constants.Auxiliaries.IDs.PneumaticSystem;
break; break;
case AuxiliaryType.ElectricSystem: case AuxiliaryType.ElectricSystem:
aux.PowerDemand = DeclarationData.ElectricSystem.Lookup(mission, auxData.TechList.ToArray()); aux.PowerDemand = DeclarationData.ElectricSystem.Lookup(mission,
auxData.TechList.DefaultIfNull(Enumerable.Empty<string>()).ToArray());
aux.ID = Constants.Auxiliaries.IDs.ElectricSystem; aux.ID = Constants.Auxiliaries.IDs.ElectricSystem;
aux.TechList = auxData.TechList.ToArray(); aux.TechList = auxData.TechList.DefaultIfNull(Enumerable.Empty<string>()).ToArray();
break; break;
default: default:
continue; continue;
...@@ -226,6 +242,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdaper ...@@ -226,6 +242,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdaper
return retVal; return retVal;
} }
private void WarnDeclarationMode(string inputData) private void WarnDeclarationMode(string inputData)
{ {
Log.Warn("{0} not in Declaration Mode!", inputData); Log.Warn("{0} not in Declaration Mode!", inputData);
......
...@@ -59,13 +59,13 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl ...@@ -59,13 +59,13 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
{ {
var cycle = new PowertrainDrivingCycle(_container, data.Cycle); var cycle = new PowertrainDrivingCycle(_container, data.Cycle);
var directAux = new Auxiliary(_container); var directAux = new EngineAuxiliary(_container);
directAux.AddDirect(); directAux.AddDirect();
cycle.InPort().Connect(directAux.OutPort());
var engine = new EngineOnlyCombustionEngine(_container, data.EngineData); var engine = new EngineOnlyCombustionEngine(_container, data.EngineData);
directAux.InPort().Connect(engine.OutPort()); engine.Connect(directAux.Port());
cycle.InPort().Connect(engine.OutPort());
return _container; return _container;
} }
...@@ -105,9 +105,13 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl ...@@ -105,9 +105,13 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
// gearbox --> clutch // gearbox --> clutch
tmp = AddComponent(tmp, clutch); tmp = AddComponent(tmp, clutch);
// clutch --> direct aux --> ... --> aux_XXX --> directAux // clutch --> engine
AddComponent(tmp, engine);
// engine --> aux
if (data.Aux != null) { if (data.Aux != null) {
var aux = new Auxiliary(_container); var aux = new EngineAuxiliary(_container);
foreach (var auxData in data.Aux) { foreach (var auxData in data.Aux) {
switch (auxData.DemandType) { switch (auxData.DemandType) {
case AuxiliaryDemandType.Constant: case AuxiliaryDemandType.Constant:
...@@ -122,11 +126,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl ...@@ -122,11 +126,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
} }
_modData.AddAuxiliary(auxData.ID); _modData.AddAuxiliary(auxData.ID);
} }
tmp = AddComponent(tmp, aux); engine.Connect(aux.Port());
} }
// connect aux --> engine
AddComponent(tmp, engine);
engine.IdleController.RequestPort = clutch.IdleControlPort; engine.IdleController.RequestPort = clutch.IdleControlPort;
return _container; return _container;
...@@ -180,10 +181,12 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl ...@@ -180,10 +181,12 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
// gearbox --> clutch // gearbox --> clutch
tmp = AddComponent(tmp, clutch); tmp = AddComponent(tmp, clutch);
// clutch --> engine
AddComponent(tmp, engine);
// clutch --> direct aux --> ... --> aux_XXX --> directAux // connect aux --> engine
if (data.Aux != null) { if (data.Aux != null) {
var aux = new Auxiliary(_container); var aux = new EngineAuxiliary(_container);
foreach (var auxData in data.Aux) { foreach (var auxData in data.Aux) {
switch (auxData.DemandType) { switch (auxData.DemandType) {
case AuxiliaryDemandType.Constant: case AuxiliaryDemandType.Constant:
...@@ -198,10 +201,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl ...@@ -198,10 +201,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
} }
_modData.AddAuxiliary(auxData.ID); _modData.AddAuxiliary(auxData.ID);
} }
tmp = AddComponent(tmp, aux); engine.Connect(aux.Port());
} }
// connect aux --> engine
AddComponent(tmp, engine);
engine.IdleController.RequestPort = clutch.IdleControlPort; engine.IdleController.RequestPort = clutch.IdleControlPort;
......
...@@ -24,7 +24,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent ...@@ -24,7 +24,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent
/// <summary> /// <summary>
/// Defines Interfaces for a combustion engine. /// Defines Interfaces for a combustion engine.
/// </summary> /// </summary>
public interface ICombustionEngine : ITnOutProvider, IEngineInfo public interface ICombustionEngine : ITnOutProvider, IEngineAuxOutProvider, IEngineInfo
{ {
ICombustionEngineIdleController IdleController { get; } ICombustionEngineIdleController IdleController { get; }
} }
......
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.SimulationComponent
{
public interface IEngineAuxInProvider
{
IEngineAuxPort Port();
}
public interface IEngineAuxOutProvider
{
void Connect(IEngineAuxPort aux);
}
public interface IEngineAuxPort
{
NewtonMeter Initialize(NewtonMeter torque, PerSecond angularSpeed);
NewtonMeter PowerDemand(Second absTime, Second dt, NewtonMeter torque, PerSecond angularSpeed, bool dryRun = false);
}
}
\ No newline at end of file
...@@ -37,7 +37,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -37,7 +37,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
/// <summary> /// <summary>
/// Component for a combustion engine. /// Component for a combustion engine.
/// </summary> /// </summary>
public class CombustionEngine : StatefulVectoSimulationComponent<CombustionEngine.EngineState>, ICombustionEngine, ITnOutPort public class CombustionEngine : StatefulVectoSimulationComponent<CombustionEngine.EngineState>, ICombustionEngine,
ITnOutPort
{ {
public bool PT1Disabled { get; set; } public bool PT1Disabled { get; set; }
...@@ -61,6 +62,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -61,6 +62,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
protected internal readonly CombustionEngineData Data; protected internal readonly CombustionEngineData Data;
protected IEngineAuxPort EngineAux;
public CombustionEngine(IVehicleContainer cockpit, CombustionEngineData data, bool pt1Disabled = false) public CombustionEngine(IVehicleContainer cockpit, CombustionEngineData data, bool pt1Disabled = false)
: base(cockpit) : base(cockpit)
{ {
...@@ -119,8 +122,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -119,8 +122,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
IResponse ITnOutPort.Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity, bool dryRun) IResponse ITnOutPort.Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity, bool dryRun)
{ {
Log.Debug("Engine Power Request: torque: {0}, angularVelocity: {1}, power: {2}", torque, angularVelocity, Log.Debug("Engine Powertrain Power Request: torque: {0}, angularVelocity: {1}, power: {2}", torque, angularVelocity,
torque * angularVelocity); torque * angularVelocity);
return DoHandleRequest(absTime, dt, torque, angularVelocity, dryRun); return DoHandleRequest(absTime, dt, torque, angularVelocity, dryRun);
} }
...@@ -132,7 +136,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -132,7 +136,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
angularVelocity = PreviousState.EngineSpeed; angularVelocity = PreviousState.EngineSpeed;
} }
var requestedEnginePower = ComputeRequestedEnginePower(absTime, dt, torque, angularVelocity); var auxPowerDemand = EngineAux == null
? 0.SI<NewtonMeter>()
: EngineAux.PowerDemand(absTime, dt, torque, angularVelocity, dryRun);
var requestedEnginePower = ComputeRequestedEnginePower(absTime, dt, torque + auxPowerDemand, angularVelocity);
ComputeFullLoadPower(angularVelocity, dt); ComputeFullLoadPower(angularVelocity, dt);
...@@ -206,6 +214,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -206,6 +214,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
public IResponse Initialize(NewtonMeter torque, PerSecond angularSpeed) public IResponse Initialize(NewtonMeter torque, PerSecond angularSpeed)
{ {
var auxDemand = EngineAux == null ? 0.SI<NewtonMeter>() : EngineAux.Initialize(torque, angularSpeed);
PreviousState = new EngineState { PreviousState = new EngineState {
EngineSpeed = angularSpeed, EngineSpeed = angularSpeed,
dt = 1.SI<Second>(), dt = 1.SI<Second>(),
...@@ -213,8 +222,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -213,8 +222,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
StationaryFullLoadTorque = StationaryFullLoadTorque =
Data.FullLoadCurve.FullLoadStationaryTorque(angularSpeed), Data.FullLoadCurve.FullLoadStationaryTorque(angularSpeed),
FullDragTorque = Data.FullLoadCurve.DragLoadStationaryTorque(angularSpeed), FullDragTorque = Data.FullLoadCurve.DragLoadStationaryTorque(angularSpeed),
EngineTorque = torque, EngineTorque = torque + auxDemand,
EnginePower = torque * angularSpeed, EnginePower = (torque + auxDemand) * angularSpeed,
}; };
PreviousState.StationaryFullLoadPower = PreviousState.StationaryFullLoadTorque * angularSpeed; PreviousState.StationaryFullLoadPower = PreviousState.StationaryFullLoadTorque * angularSpeed;
PreviousState.DynamicFullLoadTorque = PreviousState.StationaryFullLoadTorque; PreviousState.DynamicFullLoadTorque = PreviousState.StationaryFullLoadTorque;
...@@ -452,6 +461,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -452,6 +461,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
} }
} }
public void Connect(IEngineAuxPort aux)
{
EngineAux = aux;
}
#endregion #endregion
protected class CombustionEngineIdleController : LoggingObject, ICombustionEngineIdleController protected class CombustionEngineIdleController : LoggingObject, ICombustionEngineIdleController
......
/* using System;
* Copyright 2015, 2016 Graz University of Technology,
* Institute of Internal Combustion Engines and Thermodynamics,
* Institute of Technical Informatics
*
* Licensed under the EUPL (the "Licence");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://ec.europa.eu/idabc/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
using System;
using System.Collections.Generic; using System.Collections.Generic;
using TUGraz.VectoCore.Exceptions; using TUGraz.VectoCore.Exceptions;
using TUGraz.VectoCore.Models.Connector.Ports;
using TUGraz.VectoCore.Models.Simulation; using TUGraz.VectoCore.Models.Simulation;
using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.Simulation.Data;
using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Models.SimulationComponent.Data;
...@@ -28,55 +9,33 @@ using TUGraz.VectoCore.Utils; ...@@ -28,55 +9,33 @@ using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.SimulationComponent.Impl namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
{ {
public class Auxiliary : VectoSimulationComponent, IAuxiliary, ITnInPort, ITnOutPort public class EngineAuxiliary : StatefulVectoSimulationComponent<EngineAuxiliary.EngineAuxState>, IEngineAuxInProvider,
IEngineAuxPort
{ {
public const string DirectAuxiliaryId = ""; public const string DirectAuxiliaryId = "";
private readonly Dictionary<string, Func<PerSecond, Watt>> _auxDict = new Dictionary<string, Func<PerSecond, Watt>>(); private readonly Dictionary<string, Func<PerSecond, Watt>> _auxDict = new Dictionary<string, Func<PerSecond, Watt>>();
private readonly Dictionary<string, Watt> _powerDemands = new Dictionary<string, Watt>(); private readonly Dictionary<string, Watt> _powerDemands = new Dictionary<string, Watt>();
protected ITnOutPort NextComponent; public EngineAuxiliary(IVehicleContainer container) : base(container) {}
public Auxiliary(IVehicleContainer container) : base(container) {}
#region ITnInProvider public IEngineAuxPort Port()
public ITnInPort InPort()
{ {
return this; return this;
} }
#endregion public NewtonMeter PowerDemand(Second absTime, Second dt, NewtonMeter torque, PerSecond angularSpeed,
bool dryRun = false)
#region ITnOutProvider
public ITnOutPort OutPort()
{ {
return this; CurrentState.AngularSpeed = angularSpeed;
var avgAngularSpeed = (CurrentState.AngularSpeed + PreviousState.AngularSpeed) / 2.0;
return ComputePowerDemand(avgAngularSpeed) / avgAngularSpeed;
} }
#endregion public NewtonMeter Initialize(NewtonMeter torque, PerSecond angularSpeed)
#region ITnInPort
void ITnInPort.Connect(ITnOutPort other)
{ {
NextComponent = other; PreviousState.AngularSpeed = angularSpeed;
} return ComputePowerDemand(angularSpeed) / angularSpeed;
#endregion
#region ITnOutPort
IResponse ITnOutPort.Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity, bool dryRun)
{
var currentAngularVelocity = angularVelocity ?? DataBus.EngineSpeed;
var powerDemand = ComputePowerDemand(currentAngularVelocity);
var retVal = NextComponent.Request(absTime, dt, torque + powerDemand / currentAngularVelocity, angularVelocity,
dryRun);
retVal.AuxiliariesPowerDemand = powerDemand;
return retVal;
} }
private Watt ComputePowerDemand(PerSecond engineSpeed) private Watt ComputePowerDemand(PerSecond engineSpeed)
...@@ -92,16 +51,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -92,16 +51,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
return powerDemand; return powerDemand;
} }
public IResponse Initialize(NewtonMeter torque, PerSecond angularSpeed)
{
var powerDemand = ComputePowerDemand(angularSpeed);
return NextComponent.Initialize(torque + powerDemand / angularSpeed, angularSpeed);
}
#endregion
#region VectoSimulationComponent
protected override void DoWriteModalResults(IModalDataContainer container) protected override void DoWriteModalResults(IModalDataContainer container)
{ {
var sum = 0.SI<Watt>(); var sum = 0.SI<Watt>();
...@@ -115,9 +64,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -115,9 +64,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
container[ModalResultField.Paux] = sum; container[ModalResultField.Paux] = sum;
} }
protected override void DoCommitSimulationStep() {} protected override void DoCommitSimulationStep()
{
#endregion AdvanceState();
}
public void AddConstant(string auxId, Watt powerDemand) public void AddConstant(string auxId, Watt powerDemand)
{ {
...@@ -145,5 +95,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -145,5 +95,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
return powerAuxIn / data.EfficiencyToEngine; return powerAuxIn / data.EfficiencyToEngine;
}; };
} }
public class EngineAuxState
{
public PerSecond AngularSpeed;
}
} }
} }
\ No newline at end of file
...@@ -168,8 +168,10 @@ ...@@ -168,8 +168,10 @@
<Compile Include="Models\SimulationComponent\IDriverActions.cs" /> <Compile Include="Models\SimulationComponent\IDriverActions.cs" />
<Compile Include="Models\SimulationComponent\IDriverStrategy.cs" /> <Compile Include="Models\SimulationComponent\IDriverStrategy.cs" />
<Compile Include="Models\SimulationComponent\IDrivingCycleInfo.cs" /> <Compile Include="Models\SimulationComponent\IDrivingCycleInfo.cs" />
<Compile Include="Models\SimulationComponent\IEngineAuxPort.cs" />
<Compile Include="Models\SimulationComponent\Impl\Brakes.cs" /> <Compile Include="Models\SimulationComponent\Impl\Brakes.cs" />
<Compile Include="Models\SimulationComponent\Impl\DefaultDriverStrategy.cs" /> <Compile Include="Models\SimulationComponent\Impl\DefaultDriverStrategy.cs" />
<Compile Include="Models\SimulationComponent\Impl\EngineAuxiliary.cs" />
<Compile Include="Models\SimulationComponent\Impl\EngineOnlyCombustionEngine.cs" /> <Compile Include="Models\SimulationComponent\Impl\EngineOnlyCombustionEngine.cs" />
<Compile Include="Models\SimulationComponent\IShiftStrategy.cs" /> <Compile Include="Models\SimulationComponent\IShiftStrategy.cs" />
<Compile Include="Models\SimulationComponent\Impl\ShiftStrategy.cs" /> <Compile Include="Models\SimulationComponent\Impl\ShiftStrategy.cs" />
...@@ -245,7 +247,6 @@ ...@@ -245,7 +247,6 @@
<Compile Include="Models\SimulationComponent\IGearbox.cs" /> <Compile Include="Models\SimulationComponent\IGearbox.cs" />
<Compile Include="Models\Connector\Ports\ISimulationPort.cs" /> <Compile Include="Models\Connector\Ports\ISimulationPort.cs" />
<Compile Include="Models\SimulationComponent\Impl\DistanceBasedDrivingCycle.cs" /> <Compile Include="Models\SimulationComponent\Impl\DistanceBasedDrivingCycle.cs" />
<Compile Include="Models\SimulationComponent\Impl\Auxiliary.cs" />
<Compile Include="Models\SimulationComponent\Impl\TimeBasedDrivingCycle.cs" /> <Compile Include="Models\SimulationComponent\Impl\TimeBasedDrivingCycle.cs" />
<Compile Include="Models\SimulationComponent\Impl\CombustionEngine.cs" /> <Compile Include="Models\SimulationComponent\Impl\CombustionEngine.cs" />
<Compile Include="Models\SimulationComponent\Impl\ManualGearbox.cs" /> <Compile Include="Models\SimulationComponent\Impl\ManualGearbox.cs" />
......
...@@ -78,10 +78,10 @@ namespace TUGraz.VectoCore.Tests.Integration ...@@ -78,10 +78,10 @@ namespace TUGraz.VectoCore.Tests.Integration
new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container))); new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container)));
tmp = Port.AddComponent(tmp, clutch); tmp = Port.AddComponent(tmp, clutch);
var aux = new Auxiliary(container); var aux = new EngineAuxiliary(container);
aux.AddConstant("", 0.SI<Watt>()); aux.AddConstant("", 0.SI<Watt>());
tmp = Port.AddComponent(tmp, aux); engine.Connect(aux.Port());
Port.AddComponent(tmp, engine); Port.AddComponent(tmp, engine);
......
...@@ -49,13 +49,14 @@ namespace TUGraz.VectoCore.Tests.Integration.EngineOnlyCycle ...@@ -49,13 +49,14 @@ namespace TUGraz.VectoCore.Tests.Integration.EngineOnlyCycle
var engineData = var engineData =
MockSimulationDataFactory.CreateEngineDataFromFile(TestContext.DataRow["EngineFile"].ToString()); MockSimulationDataFactory.CreateEngineDataFromFile(TestContext.DataRow["EngineFile"].ToString());
var aux = new Auxiliary(vehicle); var aux = new EngineAuxiliary(vehicle);
aux.AddDirect(); aux.AddDirect();
var engine = new EngineOnlyCombustionEngine(vehicle, engineData); var engine = new EngineOnlyCombustionEngine(vehicle, engineData);
engine.Connect(aux);
aux.InPort().Connect(engine.OutPort()); //aux.InPort().Connect(engine.OutPort());
var port = aux.OutPort(); var port = engine.OutPort();
var absTime = 0.SI<Second>(); var absTime = 0.SI<Second>();
var dt = 1.SI<Second>(); var dt = 1.SI<Second>();
......
...@@ -89,10 +89,10 @@ namespace TUGraz.VectoCore.Tests.Integration ...@@ -89,10 +89,10 @@ namespace TUGraz.VectoCore.Tests.Integration
new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container))); new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container)));
tmp = Port.AddComponent(tmp, clutch); tmp = Port.AddComponent(tmp, clutch);
var aux = new Auxiliary(container); var aux = new EngineAuxiliary(container);
aux.AddConstant("", 0.SI<Watt>()); aux.AddConstant("", 0.SI<Watt>());
engine.Connect(aux.Port());
tmp = Port.AddComponent(tmp, aux);
Port.AddComponent(tmp, engine); Port.AddComponent(tmp, engine);
engine.IdleController.RequestPort = clutch.IdleControlPort; engine.IdleController.RequestPort = clutch.IdleControlPort;
......
...@@ -52,10 +52,8 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation ...@@ -52,10 +52,8 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
(writer, mass, loading) => sumWriter.WriteFullPowertrain(modData, "", "", "", null, null)); (writer, mass, loading) => sumWriter.WriteFullPowertrain(modData, "", "", "", null, null));
var data = DrivingCycleDataReader.ReadFromFile(@"TestData\Cycles\LongHaul_short.vdri", CycleType.DistanceBased); var data = DrivingCycleDataReader.ReadFromFile(@"TestData\Cycles\LongHaul_short.vdri", CycleType.DistanceBased);
var mockcycle = new MockDrivingCycle(container, data); var mockcycle = new MockDrivingCycle(container, data);
var port = new MockTnOutPort();
var aux = new Auxiliary(container); var aux = new EngineAuxiliary(container);
aux.InPort().Connect(port);
var hdvClass = VehicleClass.Class5; var hdvClass = VehicleClass.Class5;
var mission = MissionType.LongHaul; var mission = MissionType.LongHaul;
...@@ -74,8 +72,9 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation ...@@ -74,8 +72,9 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
var t = 0.SI<Second>(); var t = 0.SI<Second>();
var dt = 1.SI<Second>(); var dt = 1.SI<Second>();
aux.Initialize(torque, speed);
for (var i = 0; i < 11; i++) { for (var i = 0; i < 11; i++) {
aux.OutPort().Request(t, dt, torque, speed); aux.PowerDemand(t, dt, torque, speed);
modData[ModalResultField.dist] = i.SI<Meter>(); modData[ModalResultField.dist] = i.SI<Meter>();
modData[ModalResultField.Pe_eng] = 0.SI<Watt>(); modData[ModalResultField.Pe_eng] = 0.SI<Watt>();
modData[ModalResultField.acc] = 0.SI<MeterPerSquareSecond>(); modData[ModalResultField.acc] = 0.SI<MeterPerSquareSecond>();
...@@ -99,9 +98,8 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation ...@@ -99,9 +98,8 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
{ {
var dataWriter = new MockModalDataContainer(); var dataWriter = new MockModalDataContainer();
var container = new VehicleContainer(dataWriter); var container = new VehicleContainer(dataWriter);
var port = new MockTnOutPort(); //var port = new MockTnOutPort();
var aux = new Auxiliary(container); var aux = new EngineAuxiliary(container);
aux.InPort().Connect(port);
var constPower = 1200.SI<Watt>(); var constPower = 1200.SI<Watt>();
aux.AddConstant("CONSTANT", constPower); aux.AddConstant("CONSTANT", constPower);
...@@ -109,24 +107,22 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation ...@@ -109,24 +107,22 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
var speed = 2358.RPMtoRad(); var speed = 2358.RPMtoRad();
var torque = 500.SI<NewtonMeter>(); var torque = 500.SI<NewtonMeter>();
var t = 0.SI<Second>(); var t = 0.SI<Second>();
aux.OutPort().Request(t, t, torque, speed);
Assert.AreEqual(speed, port.AngularVelocity); aux.Initialize(torque, speed);
var newTorque = torque + constPower / speed; var auxDemand = aux.PowerDemand(t, t, torque, speed);
AssertHelper.AreRelativeEqual(port.Torque, newTorque); AssertHelper.AreRelativeEqual(constPower / speed, auxDemand);
speed = 2358.RPMtoRad(); speed = 2358.RPMtoRad();
torque = 1500.SI<NewtonMeter>(); torque = 1500.SI<NewtonMeter>();
aux.OutPort().Request(t, t, torque, speed); aux.Initialize(torque, speed);
Assert.AreEqual(speed, port.AngularVelocity); auxDemand = aux.PowerDemand(t, t, torque, speed);
newTorque = torque + constPower / speed; AssertHelper.AreRelativeEqual(constPower / speed, auxDemand);
AssertHelper.AreRelativeEqual(port.Torque, newTorque);
speed = 1500.RPMtoRad(); speed = 1500.RPMtoRad();
torque = 1500.SI<NewtonMeter>(); torque = 1500.SI<NewtonMeter>();
aux.OutPort().Request(t, t, torque, speed); aux.Initialize(torque, speed);
Assert.AreEqual(speed, port.AngularVelocity); auxDemand = aux.PowerDemand(t, t, torque, speed);
newTorque = torque + constPower / speed; AssertHelper.AreRelativeEqual(constPower / speed, auxDemand);
AssertHelper.AreRelativeEqual(port.Torque, newTorque);
} }
[TestMethod] [TestMethod]
...@@ -136,9 +132,8 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation ...@@ -136,9 +132,8 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
var container = new VehicleContainer(dataWriter); var container = new VehicleContainer(dataWriter);
var data = DrivingCycleDataReader.ReadFromFile(@"TestData\Cycles\Coach time based short.vdri", CycleType.TimeBased); var data = DrivingCycleDataReader.ReadFromFile(@"TestData\Cycles\Coach time based short.vdri", CycleType.TimeBased);
var cycle = new MockDrivingCycle(container, data); var cycle = new MockDrivingCycle(container, data);
var port = new MockTnOutPort();
var aux = new Auxiliary(container); var aux = new EngineAuxiliary(container);
aux.InPort().Connect(port);
aux.AddDirect(); aux.AddDirect();
...@@ -149,11 +144,10 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation ...@@ -149,11 +144,10 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
var expected = new[] { 6100, 3100, 2300, 4500, 6100 }; var expected = new[] { 6100, 3100, 2300, 4500, 6100 };
foreach (var e in expected) { foreach (var e in expected) {
aux.OutPort().Request(t, t, torque, speed); aux.Initialize(torque, speed);
Assert.AreEqual(speed, port.AngularVelocity); var auxDemand = aux.PowerDemand(t, t, torque, speed);
var newTorque = torque + e.SI<Watt>() / speed;
AssertHelper.AreRelativeEqual(port.Torque, newTorque);
AssertHelper.AreRelativeEqual((e.SI<Watt>() / speed).Value(), auxDemand.Value());
cycle.CommitSimulationStep(null); cycle.CommitSimulationStep(null);
} }
} }
...@@ -172,10 +166,8 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation ...@@ -172,10 +166,8 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
// ALT1 in cycle file: 0, 0.3724 (=0.38*0.96), 0.4802 (=0.49*0.96), 0.6272 (0.64*0.96), ... // ALT1 in cycle file: 0, 0.3724 (=0.38*0.96), 0.4802 (=0.49*0.96), 0.6272 (0.64*0.96), ...
var cycle = new MockDrivingCycle(container, data); var cycle = new MockDrivingCycle(container, data);
var port = new MockTnOutPort();
var aux = new Auxiliary(container); var aux = new EngineAuxiliary(container);
aux.InPort().Connect(port);
var auxData = AuxiliaryData.ReadFromFile(@"TestData\Components\24t_Coach_ALT.vaux"); var auxData = AuxiliaryData.ReadFromFile(@"TestData\Components\24t_Coach_ALT.vaux");
// ratio = 4.078 // ratio = 4.078
...@@ -208,10 +200,10 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation ...@@ -208,10 +200,10 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
}; };
foreach (var e in expected) { foreach (var e in expected) {
aux.OutPort().Request(t, t, torque, speed); aux.Initialize(torque, speed);
Assert.AreEqual(speed, port.AngularVelocity); var auxDemand = aux.PowerDemand(t, t, torque, speed);
AssertHelper.AreRelativeEqual(port.Torque, torque + e.SI<Watt>() / speed); AssertHelper.AreRelativeEqual((e.SI<Watt>() / speed).Value(), auxDemand.Value());
cycle.CommitSimulationStep(null); cycle.CommitSimulationStep(null);
} }
...@@ -233,8 +225,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation ...@@ -233,8 +225,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
var cycle = new MockDrivingCycle(container, data); var cycle = new MockDrivingCycle(container, data);
var port = new MockTnOutPort(); var port = new MockTnOutPort();
var aux = new Auxiliary(container); var aux = new EngineAuxiliary(container);
aux.InPort().Connect(port);
var auxData = AuxiliaryData.ReadFromFile(@"TestData\Components\24t_Coach_ALT.vaux"); var auxData = AuxiliaryData.ReadFromFile(@"TestData\Components\24t_Coach_ALT.vaux");
// ratio = 4.078 // ratio = 4.078
...@@ -262,10 +253,10 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation ...@@ -262,10 +253,10 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
}; };
foreach (var e in expected) { foreach (var e in expected) {
aux.OutPort().Request(t, t, torque, speed); aux.Initialize(torque, speed);
Assert.AreEqual(speed, port.AngularVelocity); var auxDemand = aux.PowerDemand(t, t, torque, speed);
AssertHelper.AreRelativeEqual(port.Torque, torque + e.SI<Watt>() / speed); AssertHelper.AreRelativeEqual((e.SI<Watt>() / speed).Value(), auxDemand);
cycle.CommitSimulationStep(null); cycle.CommitSimulationStep(null);
} }
...@@ -278,7 +269,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation ...@@ -278,7 +269,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
var data = DrivingCycleDataReader.ReadFromFile(@"TestData\Cycles\Coach time based short.vdri", CycleType.TimeBased); var data = DrivingCycleDataReader.ReadFromFile(@"TestData\Cycles\Coach time based short.vdri", CycleType.TimeBased);
var cycle = new MockDrivingCycle(container, data); var cycle = new MockDrivingCycle(container, data);
var aux = new Auxiliary(container); var aux = new EngineAuxiliary(container);
AssertHelper.Exception<VectoException>(() => aux.AddMapping("NONEXISTING_AUX", null), AssertHelper.Exception<VectoException>(() => aux.AddMapping("NONEXISTING_AUX", null),
"driving cycle does not contain column for auxiliary: NONEXISTING_AUX"); "driving cycle does not contain column for auxiliary: NONEXISTING_AUX");
} }
...@@ -341,13 +332,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation ...@@ -341,13 +332,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
var inputData = JSONInputDataFactory.ReadJsonJob(@"TestData\Jobs\40t_Long_Haul_Truck_wrong_AUX.vecto"); var inputData = JSONInputDataFactory.ReadJsonJob(@"TestData\Jobs\40t_Long_Haul_Truck_wrong_AUX.vecto");
var runsFactory = new SimulatorFactory(ExecutionMode.Declaration, inputData, fileWriter); var runsFactory = new SimulatorFactory(ExecutionMode.Declaration, inputData, fileWriter);
jobContainer.AddRuns(runsFactory); AssertHelper.Exception<VectoException>(() => jobContainer.AddRuns(runsFactory));
jobContainer.Execute();
ResultFileHelper.TestSumFile(@"TestData\Results\Declaration\40t_Long_Haul_Truck.vsum",
@"AuxReadJobFileDeclarationMode.vsum");
Assert.Inconclusive();
} }
} }
} }
\ No newline at end of file
...@@ -223,15 +223,15 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent ...@@ -223,15 +223,15 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
var driver = new MockDriver(container); var driver = new MockDriver(container);
var aux = new Auxiliary(container); var aux = new EngineAuxiliary(container);
aux.AddConstant("", 5000.SI<Watt>()); aux.AddConstant("", 5000.SI<Watt>());
gearbox.Gear = 1; gearbox.Gear = 1;
//gearbox.InPort().Connect(engine.OutPort()); //gearbox.InPort().Connect(engine.OutPort());
gearbox.InPort().Connect(clutch.OutPort()); gearbox.InPort().Connect(clutch.OutPort());
clutch.InPort().Connect(aux.OutPort()); clutch.InPort().Connect(engine.OutPort());
aux.InPort().Connect(engine.OutPort()); engine.Connect(aux.Port());
engine.IdleController.RequestPort = clutch.IdleControlPort; engine.IdleController.RequestPort = clutch.IdleControlPort;
// var expectedResults = VectoCSVFile.Read(TestContext.DataRow["ResultFile"].ToString()); // var expectedResults = VectoCSVFile.Read(TestContext.DataRow["ResultFile"].ToString());
...@@ -314,8 +314,8 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent ...@@ -314,8 +314,8 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
absTime += dt; absTime += dt;
Assert.IsInstanceOfType(response, typeof(ResponseSuccess)); Assert.IsInstanceOfType(response, typeof(ResponseSuccess));
Assert.AreEqual(engineSpeed[i].Value(), engine.PreviousState.EngineSpeed.Value(), Tolerance); Assert.AreEqual(engineSpeed[i].Value(), engine.PreviousState.EngineSpeed.Value(), Tolerance, "i: {0}", i);
Assert.AreEqual(enginePower[i].Value(), engine.PreviousState.EnginePower.Value(), Tolerance); Assert.AreEqual(enginePower[i].Value(), engine.PreviousState.EnginePower.Value(), Tolerance, "i: {0}", i);
} }
} }
...@@ -510,15 +510,15 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent ...@@ -510,15 +510,15 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
var driver = new MockDriver(container); var driver = new MockDriver(container);
var aux = new Auxiliary(container); var aux = new EngineAuxiliary(container);
aux.AddConstant("", 5000.SI<Watt>()); aux.AddConstant("", 5000.SI<Watt>());
gearbox.Gear = 1; gearbox.Gear = 1;
//gearbox.InPort().Connect(engine.OutPort()); //gearbox.InPort().Connect(engine.OutPort());
gearbox.InPort().Connect(clutch.OutPort()); gearbox.InPort().Connect(clutch.OutPort());
clutch.InPort().Connect(aux.OutPort()); clutch.InPort().Connect(engine.OutPort());
aux.InPort().Connect(engine.OutPort()); engine.Connect(aux.Port());
// has to be done after connecting components! // has to be done after connecting components!
engine.IdleController.RequestPort = clutch.IdleControlPort; engine.IdleController.RequestPort = clutch.IdleControlPort;
......
...@@ -20,32 +20,32 @@ ...@@ -20,32 +20,32 @@
"ID": "FAN", "ID": "FAN",
"Type": "Fan", "Type": "Fan",
"Path": "<NOFILE>", "Path": "<NOFILE>",
"Technology": "" "Technology": "Belt driven or driven via transm. - Discrete step clutch"
}, },
{ {
"ID": "STP", "ID": "STP",
"Type": "Steering pump", "Type": "Steering pump",
"Path": "<NOFILE>", "Path": "<NOFILE>",
"Technology": "" "Technology": "Variable displacement"
}, },
{ {
"ID": "AC", "ID": "AC",
"Type": "HVAC", "Type": "HVAC",
"Path": "<NOFILE>", "Path": "<NOFILE>",
"Technology": "" "Technology": "Default"
}, },
{ {
"ID": "ES", "ID": "ES",
"Type": "Electric System", "Type": "Electric System",
"Path": "<NOFILE>", "Path": "<NOFILE>",
"Technology": "", "Technology": "Custom Technology List",
"TechList": [] "TechList": []
}, },
{ {
"ID": "PS", "ID": "PS",
"Type": "Pneumatic System", "Type": "Pneumatic System",
"Path": "<NOFILE>", "Path": "<NOFILE>",
"Technology": "" "Technology": "Default"
} }
], ],
"VACC": "<NOFILE>", "VACC": "<NOFILE>",
......
{
"Header": {
"CreatedBy": "Raphael Luz IVT TU-Graz (85407225-fc3f-48a8-acda-c84a05df6837)",
"Date": "29.07.2014 16:59:08",
"AppVersion": "2.0.4-beta",
"FileVersion": 2
},
"Body": {
"SavedInDeclMode": true,
"VehicleFile": "../Components/40t_Long_Haul_Truck.vveh",
"EngineFile": "../Components/40t_Long_Haul_Truck.veng",
"GearboxFile": "../Components/40t_Long_Haul_Truck.vgbx",
"Cycles": [
"Long Haul",
"Regional Delivery"
],
"Aux": [
{
"ID": "FAN",
"Type": "Fan",
"Path": "<NOFILE>",
"Technology": "Hydraulic driven - Constant displacement pump"
},
{
"ID": "STP",
"Type": "Steering pump",
"Path": "<NOFILE>",
"Technology": "Variable displacement"
},
{
"ID": "ACA",
"Type": "HVAC",
"Path": "<NOFILE>",
"Technology": "Default"
},
{
"ID": "LIP",
"Type": "Electric System",
"Path": "<NOFILE>",
"Technology": "Custom Technology List",
"TechList": [ ]
},
{
"ID": "LIP",
"Type": "Electric System",
"Path": "<NOFILE>",
"Technology": "Custom Technology List",
"TechList": []
}
],
"VACC": "<NOFILE>",
"EngineOnlyMode": false,
"StartStop": {
"Enabled": false,
"MaxSpeed": 5.0,
"MinTime": 5.0,
"Delay": 5
},
"LAC": {
"Enabled": true,
"Dec": -0.5,
"MinSpeed": 50.0
},
"OverSpeedEcoRoll": {
"Mode": "OverSpeed",
"MinSpeed": 50.0,
"OverSpeed": 5.0,
"UnderSpeed": 5.0
}
}
}
\ No newline at end of file
...@@ -720,6 +720,9 @@ ...@@ -720,6 +720,9 @@
<None Include="TestData\Jobs\40t_Long_Haul_Truck_invalid-JSON.vecto"> <None Include="TestData\Jobs\40t_Long_Haul_Truck_invalid-JSON.vecto">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Include="TestData\Jobs\40t_Long_Haul_Truck_wrong_AUX.vecto">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestData\Jobs\job-report.vecto"> <None Include="TestData\Jobs\job-report.vecto">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment