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 c2de1ba0 authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

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

Merge pull request #48 in VECTO/vecto-sim from ~EMKRISPMI/vecto-sim:feature/VECTO-79-add-jobcontainer-or-similar to develop

* commit 'fef1a3f7':
  added fields for vehicle mass and vehicle loading in sum file
  acceleration average over seconds and 3 second running average
  V79 structurally finished. Still some changes needed (which fields in engineonly mode, correct calculation of the 3second average in sum file).
  sum file gets written. nearly all tests running.
  sum file write / changed some interfaces and testcases
  changes for sum file
  shorter vectojob tests
  tests for reading vecto job file, executing the job and writing moddata
  changed port provider interfaces, finished builder for assembling a full powertrain
  reading of job file, added methods for builder, added new auxiliary class for mapping-auxiliaries
  added test method and test files for job file
  added code comments, corrected error in IsEqual for double comparison with tolerance.
  reading job file, added builder for the powertrain
  faster job tests, all tests runable and successful
  more SI tests, easier SI units
  changed a test to run much faster. temporarily ignored job tests.
  preparings for sum file
  started with classes for reading job file and writing sum file
parents dfc7420d fef1a3f7
Branches
Tags
No related merge requests found
Showing
with 535 additions and 322 deletions
......@@ -103,7 +103,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
public const string EngineSpeed = "n";
/// <summary>
/// [-] GearData input. Overwrites the gear shift model.
/// [-] Gear input. Overwrites the gear shift model.
/// </summary>
public const string Gear = "gear";
......@@ -181,7 +181,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
public PerSecond EngineSpeed { get; set; }
/// <summary>
/// [-] GearData input. Overwrites the gear shift model.
/// [-] Gear input. Overwrites the gear shift model.
/// </summary>
public double Gear { get; set; }
......
......@@ -65,9 +65,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine
{
// delauney map needs is initialised with rpm, therefore the engineSpeed has to be converted.
return
_fuelMap.Interpolate((double) torque, (double) engineSpeed.ConvertTo().Rounds.Per.Minute)
.SI()
.Kilo.Gramm.Per.Second;
_fuelMap.Interpolate(torque.Double(), engineSpeed.ConvertTo().Rounds.Per.Minute.Double()).SI().Kilo.Gramm.Per.Second;
}
private static class Fields
......
......@@ -152,7 +152,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine
/// <returns>[1/s]</returns>
public PerSecond RatedSpeed()
{
var max = new Tuple<PerSecond, Watt>(new PerSecond(), new Watt());
var max = new Tuple<PerSecond, Watt>(0.SI<PerSecond>(), 0.SI<Watt>());
for (var idx = 1; idx < _entries.Count; idx++) {
var currentMax = FindMaxPower(_entries[idx - 1], _entries[idx]);
if (currentMax.Item2 > max.Item2) {
......@@ -171,8 +171,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine
/// <returns>index</returns>
protected int FindIndex(PerSecond angularVelocity)
{
Contract.Requires(angularVelocity.HasEqualUnit(new SI().Radian.Per.Second));
int idx;
if (angularVelocity < _entries[0].EngineSpeed) {
Log.ErrorFormat("requested rpm below minimum rpm in FLD curve - extrapolating. n: {0}, rpm_min: {1}",
......@@ -200,7 +198,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine
// y = kx + d
var k = (p2.TorqueFullLoad - p1.TorqueFullLoad) / (p2.EngineSpeed - p1.EngineSpeed);
var d = p2.TorqueFullLoad - k * p2.EngineSpeed;
if (k == 0.0.SI()) {
if (k == 0.SI()) {
return new Tuple<PerSecond, Watt>(p2.EngineSpeed, Formulas.TorqueToPower(p2.TorqueFullLoad, p2.EngineSpeed));
}
var engineSpeedMaxPower = (-1 * d / (2 * k)).Cast<PerSecond>();
......
using System;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.SimulationComponent.Data
{
public interface IAuxiliaryCycleData
{
Watt GetPowerDemand(TimeSpan absTime, TimeSpan dt);
}
}
\ No newline at end of file
using System;
namespace TUGraz.VectoCore.Models.SimulationComponent.Data
{
public class VehicleData
{
public static VehicleData ReadFromFile(string vehicleFile)
{
throw new NotImplementedException();
}
}
}
\ No newline at end of file
using TUGraz.VectoCore.Models.Connector.Ports;
namespace TUGraz.VectoCore.Models.SimulationComponent
{
/// <summary>
/// Defines interfaces for a driver.
/// </summary>
public interface IDriver : IDriverDemandInProvider, IDriverDemandOutProvider {}
}
\ No newline at end of file
using TUGraz.VectoCore.Models.Connector.Ports;
namespace TUGraz.VectoCore.Models.SimulationComponent
{
/// <summary>
/// Defines interfaces for a vehicle.
/// </summary>
public interface IVehicle : IDriverDemandOutProvider, IRoadPortInProvider {}
}
\ No newline at end of file
......@@ -37,7 +37,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
public override void CommitSimulationStep(IModalDataWriter writer)
{
throw new NotImplementedException();
//todo: implement!
//throw new NotImplementedException();
}
public ITnInPort InShaft()
......@@ -59,7 +60,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
if (Cockpit.Gear() == 0) {
_clutchState = ClutchState.ClutchOpened;
engineSpeedIn = _idleSpeed;
torqueIn = 0.0.SI<NewtonMeter>();
torqueIn = 0.SI<NewtonMeter>();
} else {
var engineSpeedNorm = (angularVelocity - _idleSpeed) /
(_ratedSpeed - _idleSpeed);
......
......@@ -268,7 +268,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
protected Watt InertiaPowerLoss(NewtonMeter torque, PerSecond angularVelocity)
{
var deltaEngineSpeed = angularVelocity - _previousState.EngineSpeed;
var avgEngineSpeed = (_previousState.EngineSpeed + angularVelocity) / 2.0.SI<Second>();
var avgEngineSpeed = (_previousState.EngineSpeed + angularVelocity) / 2.SI<Second>();
var result = _data.Inertia * deltaEngineSpeed * avgEngineSpeed;
return result.Cast<Watt>();
}
......
using System;
using TUGraz.VectoCore.Utils;
using TUGraz.VectoCore.Exceptions;
using TUGraz.VectoCore.Models.Simulation;
using TUGraz.VectoCore.Models.Connector.Ports;
using TUGraz.VectoCore.Models.Simulation.Data;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
{
public class DirectAuxiliary : VectoSimulationComponent, IAuxiliary, ITnInPort, ITnOutPort
{
private readonly IAuxiliaryCycleData _demand;
private ITnOutPort _outPort;
private Watt _powerDemand;
public DirectAuxiliary(IVehicleContainer container, IAuxiliaryCycleData demand)
: base(container)
{
_demand = demand;
}
#region IInShaft
public ITnInPort InShaft()
{
return this;
}
#endregion
#region IOutShaft
public ITnOutPort OutShaft()
{
return this;
}
#endregion
#region ITnInPort
void ITnInPort.Connect(ITnOutPort other)
{
_outPort = other;
}
#endregion
#region ITnOutPort
IResponse ITnOutPort.Request(TimeSpan absTime, TimeSpan dt, NewtonMeter torque, PerSecond engineSpeed)
{
if (_outPort == null) {
Log.ErrorFormat("{0} cannot handle incoming request - no outport available", absTime);
throw new VectoSimulationException(
String.Format("{0} cannot handle incoming request - no outport available",
absTime.TotalSeconds));
}
_powerDemand = _demand.GetPowerDemand(absTime, dt);
var tq = Formulas.PowerToTorque(_powerDemand, engineSpeed);
return _outPort.Request(absTime, dt, torque + tq, engineSpeed);
}
#endregion
#region VectoSimulationComponent
public override void CommitSimulationStep(IModalDataWriter writer)
{
writer[ModalResultField.Paux] = (double)_powerDemand;
}
#endregion
}
}
\ No newline at end of file
......@@ -25,7 +25,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
#region IDriverDemandInProvider
public IDriverDemandInPort InPort()
public IDriverDemandInPort InShaft()
{
return this;
}
......@@ -34,7 +34,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
#region IDrivingCycleOutProvider
public IDrivingCycleOutPort OutPort()
public IDrivingCycleOutPort OutShaft()
{
return this;
}
......
using System;
using TUGraz.VectoCore.Models.Connector.Ports;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
{
public class Driver : IDriver, IDriverDemandInPort, IDriverDemandOutPort
{
public Driver(DriverData driverData)
{
throw new NotImplementedException();
}
public IDriverDemandInPort InShaft()
{
throw new NotImplementedException();
}
public IDriverDemandOutPort OutShaft()
{
throw new NotImplementedException();
}
public void Connect(IDriverDemandOutPort other)
{
throw new NotImplementedException();
}
public IResponse Request(TimeSpan absTime, TimeSpan dt, MeterPerSecond velocity, Radian gradient)
{
throw new NotImplementedException();
}
}
}
\ No newline at end of file
using System;
using TUGraz.VectoCore.Exceptions;
using TUGraz.VectoCore.Models.Connector.Ports;
using TUGraz.VectoCore.Models.Simulation;
using TUGraz.VectoCore.Models.Simulation.Data;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
{
public class EngineOnlyAuxiliary : VectoSimulationComponent, IAuxiliary, ITnInPort, ITnOutPort
{
private readonly AuxiliariesDemandAdapter _demand;
private ITnOutPort _outPort;
private Watt _powerDemand;
public EngineOnlyAuxiliary(IVehicleContainer container, AuxiliariesDemandAdapter demand) : base(container)
{
_demand = demand;
}
#region IInShaft
public ITnInPort InShaft()
{
return this;
}
#endregion
#region IOutShaft
public ITnOutPort OutShaft()
{
return this;
}
#endregion
#region ITnInPort
void ITnInPort.Connect(ITnOutPort other)
{
_outPort = other;
}
#endregion
#region ITnOutPort
IResponse ITnOutPort.Request(TimeSpan absTime, TimeSpan dt, NewtonMeter torque, PerSecond engineSpeed)
{
if (_outPort == null) {
Log.ErrorFormat("{0} cannot handle incoming request - no outport available", absTime);
throw new VectoSimulationException(
String.Format("{0} cannot handle incoming request - no outport available",
absTime.TotalSeconds));
}
_powerDemand = _demand.GetPowerDemand(absTime, dt);
var tq = Formulas.PowerToTorque(_powerDemand, engineSpeed);
return _outPort.Request(absTime, dt, torque + tq, engineSpeed);
}
#endregion
#region VectoSimulationComponent
public override void CommitSimulationStep(IModalDataWriter writer)
{
writer[ModalResultField.Paux] = (double) _powerDemand;
}
#endregion
}
}
\ No newline at end of file
......@@ -32,7 +32,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
#region IDrivingCycleOutProvider
public IDrivingCycleOutPort OutPort()
public IDrivingCycleOutPort OutShaft()
{
return this;
}
......
......@@ -38,7 +38,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
#endregion
#region ITnOutPort
IResponse ITnOutPort.Request(TimeSpan absTime, TimeSpan dt, NewtonMeter torque, PerSecond engineSpeed)
......
using System;
using TUGraz.VectoCore.Exceptions;
using TUGraz.VectoCore.Models.Connector.Ports;
using TUGraz.VectoCore.Models.Simulation;
using TUGraz.VectoCore.Models.Simulation.Data;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
{
public class AuxiliaryData
{
public double EfficiencyToSupply { get; set; }
public double TransitionRatio { get; set; }
public double EfficiencyToEngine { get; set; }
public Watt GetPowerDemand(PerSecond nAuxiliary, Watt powerAuxOut)
{
throw new NotImplementedException();
}
public static AuxiliaryData ReadFromFile(string filePath)
{
throw new NotImplementedException();
}
}
public class MappingAuxiliary : VectoSimulationComponent, IAuxiliary, ITnInPort, ITnOutPort
{
private readonly IAuxiliaryCycleData _demand;
private AuxiliaryData _data;
private ITnOutPort _outPort;
private Watt _powerDemand;
public MappingAuxiliary(IVehicleContainer container, IAuxiliaryCycleData demand, AuxiliaryData data)
: base(container)
{
_demand = demand;
_data = data;
}
#region IInShaft
public ITnInPort InShaft()
{
return this;
}
#endregion
#region IOutShaft
public ITnOutPort OutShaft()
{
return this;
}
#endregion
#region ITnInPort
void ITnInPort.Connect(ITnOutPort other)
{
_outPort = other;
}
#endregion
#region ITnOutPort
IResponse ITnOutPort.Request(TimeSpan absTime, TimeSpan dt, NewtonMeter torque, PerSecond angularVelocity)
{
if (_outPort == null) {
Log.ErrorFormat("{0} cannot handle incoming request - no outport available", absTime);
throw new VectoSimulationException(
String.Format("{0} cannot handle incoming request - no outport available",
absTime.TotalSeconds));
}
var power_supply = _demand.GetPowerDemand(absTime, dt);
var power_aux_out = power_supply / _data.EfficiencyToSupply;
var n_auxiliary = angularVelocity * _data.TransitionRatio;
var power_aux_in = _data.GetPowerDemand(n_auxiliary, power_aux_out);
var power_aux = power_aux_in / _data.EfficiencyToEngine;
_powerDemand = power_aux;
var torque_aux = Formulas.PowerToTorque(power_aux, angularVelocity);
return _outPort.Request(absTime, dt, torque + torque_aux, angularVelocity);
}
#endregion
#region VectoSimulationComponent
public override void CommitSimulationStep(IModalDataWriter writer)
{
writer[ModalResultField.Paux_xxx] = (double)_powerDemand;
}
#endregion
}
}
\ No newline at end of file
......@@ -24,7 +24,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
#region IDrivingCycleOutProvider
public IDrivingCycleOutPort OutPort()
public IDrivingCycleOutPort OutShaft()
{
return this;
}
......@@ -33,7 +33,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
#region IDriverDemandInProvider
public IDriverDemandInPort InPort()
public IDriverDemandInPort InShaft()
{
return this;
}
......
using System;
using TUGraz.VectoCore.Models.Connector.Ports;
using TUGraz.VectoCore.Models.Simulation.Impl;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
{
public class Vehicle : IVehicle, IDriverDemandOutPort, IFvInPort
{
public Vehicle(VehicleContainer container, VehicleData vehicleData)
{
throw new NotImplementedException();
}
public IDriverDemandOutPort OutShaft()
{
throw new NotImplementedException();
}
public IFvInPort InShaft()
{
throw new NotImplementedException();
}
public IResponse Request(TimeSpan absTime, TimeSpan dt, MeterPerSecond velocity, Radian gradient)
{
throw new NotImplementedException();
}
public void Connect(IFvOutPort other)
{
throw new NotImplementedException();
}
}
}
\ No newline at end of file
......@@ -15,7 +15,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
#region IRoadPortOutProvider
IFvOutPort IRoadPortOutProvider.OutPort()
IFvOutPort IRoadPortOutProvider.OutShaft()
{
throw new NotImplementedException();
}
......
......@@ -90,9 +90,9 @@ namespace TUGraz.VectoCore.Utils
Z = z;
}
public double X { get; set; }
public double Y { get; set; }
public double Z { get; set; }
public double X;
public double Y;
public double Z;
public static Point operator -(Point p1, Point p2)
{
......@@ -164,10 +164,10 @@ namespace TUGraz.VectoCore.Utils
W = tr.P1.X * cross.X + tr.P1.Y * cross.Y + tr.P1.Z * cross.Z;
}
public double X { get; set; }
public double Y { get; set; }
public double Z { get; set; }
public double W { get; set; }
public double X;
public double Y;
public double Z;
public double W;
public override string ToString()
{
......@@ -184,9 +184,9 @@ namespace TUGraz.VectoCore.Utils
P3 = p3;
}
public Point P1 { get; set; }
public Point P2 { get; set; }
public Point P3 { get; set; }
public Point P1;
public Point P2;
public Point P3;
public bool IsInside(double x, double y, bool exact = true)
{
......@@ -308,8 +308,8 @@ namespace TUGraz.VectoCore.Utils
P2 = p2;
}
public Point P1 { get; set; }
public Point P2 { get; set; }
public Point P1;
public Point P2;
public override string ToString()
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment