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

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

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

Merge pull request #42 in VECTO/vecto-sim from ~EMQUARIMA/vecto-sim:feature/VECTO-86-improve-simulation-performance to develop

* commit '78e936a7':
  new search method to look up auxiliary power demand
  identify performance bottlenecks
parents 96e67384 78e936a7
No related branches found
No related tags found
No related merge requests found
......@@ -31,8 +31,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Data
public object this[ModalResultField key]
{
get { return CurrentRow[key.GetName()]; }
set { CurrentRow[key.GetName()] = value; }
get { return CurrentRow[(int)key]; }
set { CurrentRow[(int)key] = value; }
}
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using Common.Logging;
......@@ -10,14 +11,21 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
public class AuxiliariesDemandAdapter
{
private readonly DrivingCycleData _drivingCycle;
private IEnumerator<DrivingCycleData.DrivingCycleEntry> _nextCycleEntry;
private readonly string _auxiliaryId;
protected DrivingCycleData.DrivingCycleEntry CurrentCycleEntry { get; set; }
//protected DrivingCycleData.DrivingCycleEntry NextCycleEntry { get { return _nextCycleEntry.Current; } }
private ILog Log;
public AuxiliariesDemandAdapter(DrivingCycleData inputData, string column = null)
{
Log = LogManager.GetLogger(this.GetType());
_drivingCycle = inputData;
_nextCycleEntry = _drivingCycle.Entries.GetEnumerator();
_nextCycleEntry.MoveNext();
CurrentCycleEntry = _drivingCycle.Entries.First();
_auxiliaryId = column;
if (_auxiliaryId != null && !_drivingCycle.Entries.First().AuxiliarySupplyPower.ContainsKey(_auxiliaryId)) {
Log.ErrorFormat("driving cycle data does not contain column {0}", column);
......@@ -27,16 +35,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
public Watt GetPowerDemand(TimeSpan absTime, TimeSpan dt)
{
var entry = _drivingCycle.Entries.FindLastIndex(x => x.Time <= absTime.TotalSeconds);
//if (entry == null) {
// Log.ErrorFormat("could not find entry in driving cycle for time {0}", absTime.TotalSeconds);
// return 0;
//}
if (entry == -1) {
Log.ErrorFormat("time: {0} could not find power demand for auxiliary {1}", absTime.TotalSeconds, _auxiliaryId);
throw new VectoSimulationException(String.Format("time: {0} could not find power demand for auxiliary {1}", absTime.TotalSeconds, _auxiliaryId));
if (_nextCycleEntry.Current.Time <= absTime.TotalSeconds) {
CurrentCycleEntry = _nextCycleEntry.Current;
_nextCycleEntry.MoveNext();
}
return _auxiliaryId == null ? _drivingCycle.Entries[entry].AdditionalAuxPowerDemand : _drivingCycle.Entries[entry].AuxiliarySupplyPower[_auxiliaryId];
return String.IsNullOrEmpty(_auxiliaryId) ? CurrentCycleEntry.AdditionalAuxPowerDemand : CurrentCycleEntry.AuxiliarySupplyPower[_auxiliaryId];
}
}
......
......@@ -310,7 +310,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
/// </summary>
public SI Inertia
{
get { return _data.Body.Inertia.SI().Kilo.Gramm.Square.Meter.To().Kilo.Gramm.Square.Meter.Value(); }
get { return _data.Body.Inertia.SI().Kilo.Gramm.Square.Meter; }
protected set { _data.Body.Inertia = (double)value.To().Kilo.Gramm.Square.Meter; }
}
......
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