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

Merge branch 'develop' into...

Merge branch 'develop' into feature/VECTO-1606-modal-data-results-only-provide-necessary-columns-in-output
parents 81b27a12 bed134b6
Branches
Tags
No related merge requests found
Showing
with 257 additions and 79 deletions
......@@ -29,6 +29,7 @@
* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology
*/
using System;
using System.Collections.Generic;
using System.Xml;
using TUGraz.VectoCommon.Exceptions;
......@@ -136,12 +137,14 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Common {
protected virtual TableData ReadTableData(string baseElement, string entryElement, Dictionary<string, string> mapping)
{
var entries = BaseNode.SelectNodes(
XMLHelper.QueryLocalName(baseElement, entryElement));
try {
var entries = BaseNode.SelectNodes(XMLHelper.QueryLocalName(baseElement, entryElement));
if (entries != null && entries.Count > 0) {
return XMLHelper.ReadTableData(mapping, entries);
}
} catch (NullReferenceException) {
throw new VectoException($"Could not find element: {baseElement} {entryElement}");
}
return null;
}
}
......
......@@ -191,16 +191,6 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider
IAuxiliariesDeclarationInputData IVehicleComponentsDeclaration.AuxiliaryInputData => null;
#region Overrides of XMLDeclarationComponentsDataProviderV10
public override IAngledriveInputData AngledriveInputData =>
ElementExists(XMLNames.Component_Angledrive) ? base.AngledriveInputData : null;
public override IRetarderInputData RetarderInputData =>
ElementExists(XMLNames.Component_Retarder) ? base.RetarderInputData : null;
#endregion
public override IBusAuxiliariesDeclarationData BusAuxiliaries =>
_busAuxiliaries ?? (_busAuxiliaries = ComponentReader.BusAuxiliariesInputData);
......
......@@ -1128,7 +1128,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter
FullDriveTorque = gearboxData.Gears[key].MaxTorque
}
}.ToList();
retVal[new GearshiftPosition(key)] = new VehicleMaxPropulsionTorque(gbxLimit);
retVal[new GearshiftPosition(key, true)] = new VehicleMaxPropulsionTorque(gbxLimit);
continue;
}
......@@ -1160,7 +1160,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter
// if no gearbox limit is defined, MaxTorque is null;
// in case of P3 or P4, do not apply gearbox limit to propulsion limit as ICE is already cropped with max torque
var gearboxTorqueLimit = isP3OrP4Hybrid ? null : gearboxData.Gears[key].MaxTorque;
retVal[new GearshiftPosition(key)] = new VehicleMaxPropulsionTorque(IntersectMaxPropulsionTorqueCurve(entries, gearboxTorqueLimit));
retVal[new GearshiftPosition(key, true)] = new VehicleMaxPropulsionTorque(IntersectMaxPropulsionTorqueCurve(entries, gearboxTorqueLimit));
}
......
......@@ -56,6 +56,12 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electric
}
#endregion
#region Implementation of IUpdateable
public bool UpdateFrom(object other) => false;
#endregion
}
// ########################################
......@@ -114,6 +120,8 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electric
ConsumedEnergy = 0.SI<WattSecond>();
}
public WattSecond ConsumedEnergy { get; set; }
public State Clone() => (State)MemberwiseClone();
}
#region Overrides of VectoSimulationComponent
......@@ -136,7 +144,17 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electric
}
AdvanceState();
}
#endregion
#region Implementation of IUpdateable
public bool UpdateFrom(object other) {
if (other is SimpleBattery b) {
PreviousState = b.PreviousState.Clone();
SOC = b.SOC;
return true;
}
return false;
}
#endregion
}
}
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.Models.SimulationComponent;
namespace TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces.DownstreamModules.Electrics {
......@@ -9,7 +10,7 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.Interfaces.DownstreamModules.El
}
public interface ISimpleBattery : ISimpleBatteryInfo
public interface ISimpleBattery : ISimpleBatteryInfo, IUpdateable
{
WattSecond ConsumedEnergy { get; }
......
......@@ -78,6 +78,8 @@ namespace TUGraz.VectoCore.Models.Simulation.DataBus
bool DisengageGearbox { get; }
bool GearEngaged(Second absTime);
bool RequestAfterGearshift { get; set; }
}
public interface IGearboxControl
......
......@@ -1627,28 +1627,30 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
}
}
public class SimpleCharger : IElectricChargerPort
public class SimpleCharger : IElectricChargerPort, IUpdateable
{
#region Implementation of IElectricChargerPort
private Watt _chargingPower;
public SimpleCharger() => _chargingPower = 0.SI<Watt>();
public Watt Initialize() => _chargingPower = 0.SI<Watt>();
public Watt PowerDemand(Second absTime, Second dt, Watt powerDemandEletricMotor, Watt auxPower, bool dryRun) => _chargingPower;
#endregion
public Watt ChargingPower { get; set; }
public SimpleCharger()
#region Implementation of IUpdateable
public bool UpdateFrom(object other)
{
ChargingPower = 0.SI<Watt>();
if (other is IElectricSystemInfo es) {
_chargingPower = es.ChargePower;
return true;
}
public Watt Initialize()
{
ChargingPower = 0.SI<Watt>();
return ChargingPower;
if (other is Watt w) {
_chargingPower = w;
return true;
}
public Watt PowerDemand(Second absTime, Second dt, Watt powerDemandEletricMotor, Watt auxPower, bool dryRun)
{
return ChargingPower;
return false;
}
#endregion
}
......@@ -1855,6 +1857,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
return true;
}
public bool RequestAfterGearshift { get; set; }
#endregion
}
......
......@@ -78,7 +78,10 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl.SimulatorFactory
// return null;
if (_followUpSimulatorFactoryCreator != null) {
return _followUpSimulatorFactoryCreator.GetNextFactory();
var retVal = _followUpSimulatorFactoryCreator.GetNextFactory();
retVal.SerializeVectoRunData = SerializeVectoRunData;
return retVal;
} else {
return null;
}
......
......@@ -202,8 +202,49 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
WriteSumData?.RegisterComponent(component, RunData);
}
private List<(IUpdateable, object)> ComponentUpdateList = new List<(IUpdateable, object)>();
protected void UpdateComponentsInternal(IDataBus realContainer)
{
if (ComponentUpdateList.Any()) {
foreach (var (target, source) in ComponentUpdateList) {
target.UpdateFrom(source);
}
} else {
foreach (var (_, c) in _components) {
#if DEBUG
var found = false;
#endif
if (c is IUpdateable target) {
foreach (var (_, source) in (realContainer as VehicleContainer)._components) {
if (target.UpdateFrom(source)) {
ComponentUpdateList.Add((target, source));
#if DEBUG
found = true;
#endif
}
}
}
#if DEBUG
if (!found) {
Console.WriteLine("Test Component is not updateable: " + c.GetType());
}
#endif
}
#if DEBUG
var sourceList = ComponentUpdateList.Select(st => st.Item2).ToArray();
foreach (var (_, source) in (realContainer as VehicleContainer)._components) {
if (!sourceList.Contains(source)){
Console.WriteLine("Real Component is not used for update: " + source.GetType());
}
}
#endif
ComponentUpdateList = ComponentUpdateList.Distinct().ToList();
}
}
public virtual void CommitSimulationStep(Second time, Second simulationInterval)
{
......
......@@ -5,7 +5,7 @@ using TUGraz.VectoCore.OutputData;
namespace TUGraz.VectoCore.Models.Simulation.Impl
{
public class WHRCharger : StatefulVectoSimulationComponent<WHRCharger.State>, IElectricChargerPort
public class WHRCharger : StatefulVectoSimulationComponent<WHRCharger.State>, IElectricChargerPort, IUpdateable
{
public double Efficiency { get; }
......@@ -71,7 +71,20 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
public WattSecond GeneratedEnergy { get; set; }
public WattSecond ExcessiveEnergy { get; set; }
public State Clone() => (State)MemberwiseClone();
}
#region Implementation of IUpdateable
public bool UpdateFrom(object other) {
if (other is WHRCharger c) {
PreviousState = c.PreviousState.Clone();
return true;
}
return false;
}
#endregion
}
}
\ No newline at end of file
......@@ -8,7 +8,7 @@ using TUGraz.VectoCore.OutputData;
namespace TUGraz.VectoCore.Models.SimulationComponent
{
public class DCDCConverter : StatefulVectoSimulationComponent<DCDCConverter.State>, IDCDCConverter
public class DCDCConverter : StatefulVectoSimulationComponent<DCDCConverter.State>, IDCDCConverter, IUpdateable
{
public double Efficiency { get; protected set; }
......@@ -90,6 +90,18 @@ namespace TUGraz.VectoCore.Models.SimulationComponent
public WattSecond ConsumedEnergy { get; set; }
public WattSecond MissingEnergy { get; set; }
public State Clone() => (State)MemberwiseClone();
}
#region Implementation of IUpdateable
public bool UpdateFrom(object other) {
if (other is DCDCConverter d) {
PreviousState = d.PreviousState.Clone();
return true;
}
return false;
}
#endregion
}
}
\ No newline at end of file
......@@ -145,6 +145,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
EngineSpeed = entry.EngineSpeed;
FanSpeed = entry.FanSpeed;
PTOPowerDemandDuringDrive = entry.PTOPowerDemandDuringDrive;
Highway = entry.Highway;
}
/// <summary>
......
......@@ -150,42 +150,50 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.ElectricMotor
}
try {
var retVal = SearchAlgorithm.Search(
maxEmTorque, elPowerMaxEM.ElectricalPower - batPower,
-maxEmTorque * 0.1 * (maxEmTorque > 0 ? -1 : 1),
getYValue: x => {
var myX = (EfficiencyResult)x;
return myX.ElectricalPower - batPower;
},
evaluateFunction: x => LookupElectricPower(avgSpeed, x, true),
criterion: x => {
var myX = (EfficiencyResult)x;
return (myX.ElectricalPower - batPower).Value();
},
searcher: this);
var retVal = SearchTorqueForElectricPower(batPower, avgSpeed, maxEmTorque, elPowerMaxEM);
var tmp = LookupElectricPower(avgSpeed, retVal, true);
if ((tmp.ElectricalPower - batPower).IsGreater(Constants.SimulationSettings.InterpolateSearchTolerance)) {
if (VectoMath.Abs(tmp.ElectricalPower - batPower).IsGreater(Constants.SimulationSettings.InterpolateSearchTolerance)) {
// searched operating point is not accurate enough...
retVal = SearchAlgorithm.Search(
retVal = SearchTorqueForElectricPower(batPower, avgSpeed, maxEmTorque, elPowerMaxEM, 1e3);
}
if (maxEmTorque < 0) {
// propelling
if (retVal.IsSmaller(maxEmTorque)) {
retVal = SearchTorqueForElectricPower(batPower, avgSpeed, maxEmTorque, elPowerMaxEM, 1e3, true);
}
} else {
// recuperating
if (retVal.IsGreater(maxEmTorque)) {
retVal = SearchTorqueForElectricPower(batPower, avgSpeed, maxEmTorque, elPowerMaxEM, 1e3, true);
}
}
return retVal;
} catch (VectoSearchFailedException vsfe) {
Log.Error("Failed to find mechanic power for given electric power! n_avg: {0} P_el: {1}; {2}", avgSpeed.AsRPM, batPower, vsfe.Message);
}
return null;
}
private NewtonMeter SearchTorqueForElectricPower(Watt batPower, PerSecond avgSpeed, NewtonMeter maxEmTorque,
EfficiencyResult elPowerMaxEM, double factor = 1.0, bool forceLinesearch = false)
{
var retVal = SearchAlgorithm.Search(
maxEmTorque, elPowerMaxEM.ElectricalPower - batPower,
-maxEmTorque * 0.1 * (maxEmTorque > 0 ? -1 : 1),
getYValue: x => {
var myX = (EfficiencyResult)x;
return (myX.ElectricalPower - batPower) * 1e3;
return (myX.ElectricalPower - batPower) * factor;
},
evaluateFunction: x => LookupElectricPower(avgSpeed, x, true),
criterion: x => {
var myX = (EfficiencyResult)x;
return (myX.ElectricalPower - batPower).Value() * 1e3;
return (myX.ElectricalPower - batPower).Value() * factor;
},
searcher: this);
}
searcher: this,
forceLineSearch: forceLinesearch);
return retVal;
} catch (VectoSearchFailedException vsfe) {
Log.Error("Failed to find mechanic power for given electric power! n_avg: {0} P_el: {1}; {2}", avgSpeed.AsRPM, batPower, vsfe.Message);
}
return null;
}
public PerSecond MaxSpeed
......
......@@ -6,11 +6,13 @@ using TUGraz.VectoCore.Configuration;
using TUGraz.VectoCore.Models.Connector.Ports.Impl;
using TUGraz.VectoCore.Models.Simulation;
using TUGraz.VectoCore.Models.Simulation.Data;
using TUGraz.VectoCore.Models.SimulationComponent.Impl;
using TUGraz.VectoCore.OutputData;
namespace TUGraz.VectoCore.Models.SimulationComponent
{
public class ElectricSystem : StatefulVectoSimulationComponent<ElectricSystem.State>, IElectricSystem, IElectricAuxConnecor, IElectricChargerConnector, IBatteryConnector
public class ElectricSystem : StatefulVectoSimulationComponent<ElectricSystem.State>, IElectricSystem, IElectricAuxConnecor,
IElectricChargerConnector, IBatteryConnector, IUpdateable
{
protected readonly List<IElectricAuxPort> Consumers = new List<IElectricAuxPort>();
......@@ -141,7 +143,21 @@ namespace TUGraz.VectoCore.Models.SimulationComponent
ConsumerPower = powerDemand;
BatteryPower = batteryPower;
}
public State Clone() => (State)MemberwiseClone();
}
#region Implementation of IUpdateable
public bool UpdateFrom(object other) {
if (other is ElectricSystem s) {
PreviousState = s.PreviousState.Clone();
return true;
}
return false;
}
#endregion
}
}
\ No newline at end of file
......@@ -43,7 +43,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent
void Connect(IAuxPort aux);
}
public interface IAuxPort
public interface IAuxPort: IUpdateable
{
NewtonMeter Initialize(NewtonMeter torque, PerSecond angularSpeed);
......
......@@ -33,7 +33,7 @@ using TUGraz.VectoCommon.Utils;
namespace TUGraz.VectoCore.Models.SimulationComponent
{
public interface IBrakes
public interface IBrakes: IUpdateable
{
Watt BrakePower { get; set; }
}
......
/*
* This file is part of VECTO.
*
* Copyright © 2012-2019 European Union
*
* Developed by Graz University of Technology,
* Institute of Internal Combustion Engines and Thermodynamics,
* Institute of Technical Informatics
*
* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence");
* You may not use VECTO except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* https://joinup.ec.europa.eu/community/eupl/og_page/eupl
*
* Unless required by applicable law or agreed to in writing, VECTO
* 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.
*
* Authors:
* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology
* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology
* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology
* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology
* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology
* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology
*/
namespace TUGraz.VectoCore.Models.SimulationComponent
{
public interface IUpdateable
{
/// <summary>
/// Tries to update the internal state of this object from the other object.
/// </summary>
/// <returns>True if the update was possible. False if the update is not possible.</returns>
bool UpdateFrom(object other);
}
}
\ No newline at end of file
......@@ -130,9 +130,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
continue;
}
var estimatedEngineSpeed = (vehicleSpeedPostShift * (totalTransmissionRatio /
GearboxModelData.Gears[currentGear.Gear].Ratio * GearboxModelData.Gears[tryNextGear.Gear].Ratio))
.Cast<PerSecond>();
var estimatedEngineSpeed = vehicleSpeedPostShift * (totalTransmissionRatio /
GearboxModelData.Gears[currentGear.Gear].Ratio * GearboxModelData.Gears[tryNextGear.Gear].Ratio);
if (estimatedEngineSpeed.IsSmaller(shiftStrategyParameters.MinEngineSpeedPostUpshift)) {
continue;
}
......
......@@ -77,7 +77,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
Gear = oldGear;
return new ResponseDryRun(this, response) {
ElectricMotor = { PowerRequest = response.ElectricMotor.PowerRequest },
Gearbox = { PowerRequest = outTorque * outAngularVelocity },
Gearbox = {
PowerRequest = outTorque * outAngularVelocity,
InputSpeed = inAngularVelocity,
InputTorque = inTorque,
OutputTorque = outTorque,
OutputSpeed = outAngularVelocity,
},
DeltaFullLoad = response.ElectricMotor.PowerRequest - fullLoad
};
}
......
......@@ -40,17 +40,17 @@ using TUGraz.VectoCore.Models.Simulation;
using TUGraz.VectoCore.Models.Simulation.Data;
using TUGraz.VectoCore.Models.Simulation.DataBus;
using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox;
using TUGraz.VectoCore.Models.SimulationComponent.Strategies;
using TUGraz.VectoCore.OutputData;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
{
public class ATGearbox : AbstractGearbox<ATGearbox.ATGearboxState>, IHybridControlledGearbox
public class ATGearbox : AbstractGearbox<ATGearbox.ATGearboxState>, IHybridControlledGearbox, IUpdateable
{
protected internal readonly IShiftStrategy _strategy;
protected internal readonly TorqueConverter TorqueConverter;
private IIdleController _idleController;
protected internal bool RequestAfterGearshift;
internal WattSecond _powershiftLossEnergy;
protected internal KilogramSquareMeter EngineInertia;
......@@ -581,8 +581,27 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
public bool Disengaged = true;
public WattSecond PowershiftLossEnergy;
public NewtonMeter PowershiftLoss;
public new ATGearboxState Clone() => (ATGearboxState)MemberwiseClone();
}
public bool SwitchToNeutral { get; set; }
#region Implementation of IUpdateable
public bool UpdateFrom(object other)
{
if (other is ATGearbox g) {
PreviousState = g.PreviousState.Clone();
_powershiftLossEnergy = g._powershiftLossEnergy;
LastShift = g.LastShift;
return true;
}
return false;
}
#endregion
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment