From c70aef11c1e5a64835e340a55b568f1cd4d99e95 Mon Sep 17 00:00:00 2001 From: Markus Quaritsch <markus.quaritsch@tugraz.at> Date: Tue, 11 Feb 2020 17:51:11 +0100 Subject: [PATCH] refactoring getwhrpower in combustion engine --- .../Data/Engine/WHRPowerMap.cs | 5 ++++ .../Impl/CombustionEngine.cs | 26 ++++++++++--------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/WHRPowerMap.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/WHRPowerMap.cs index 00ba54f114..f238ae2818 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/WHRPowerMap.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/WHRPowerMap.cs @@ -15,6 +15,11 @@ namespace TUGraz.VectoCore.InputData.Reader.ComponentData WHRMap = whrMap; } + public string Name + { + get { return WHRMap.Name; } + } + public class Entry { [Required, SIRange(0, 5000 * Constants.RPMToRad)] public readonly PerSecond EngineSpeed; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs index 15b73de27a..aec905d305 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs @@ -455,18 +455,20 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected virtual void GetWHRPower(WHRData whr, PerSecond engineSpeed, NewtonMeter engineTorque, ref Watt pWHRMap, ref Watt pWHRCorr) { - if (whr != null) { - var whrPwrEl = whr.WHRMap.GetWHRPower( - engineTorque, engineSpeed, DataBus.ExecutionMode != ExecutionMode.Declaration); - if (DataBus.ExecutionMode != ExecutionMode.Declaration && whrPwrEl.Extrapolated) { - Log.Warn( - "Electric WHR power was extrapolated: range for WHR-Map is not sufficient: n: {0}, torque: {1}", - engineSpeed.Value(), engineTorque.Value()); - } - if (whrPwrEl.GeneratedPower != null) { - pWHRMap = whrPwrEl.GeneratedPower; - pWHRCorr = pWHRMap * whr.WHRCorrectionFactor; - } + if (whr == null) { + return; + } + + var whrPwr = whr.WHRMap.GetWHRPower( + engineTorque, engineSpeed, DataBus.ExecutionMode != ExecutionMode.Declaration); + if (DataBus.ExecutionMode != ExecutionMode.Declaration && whrPwr.Extrapolated) { + Log.Warn( + "WHR power was extrapolated in {2}: range for WHR-Map is not sufficient: n: {0}, torque: {1}", + engineSpeed.Value(), engineTorque.Value(), whr.WHRMap.Name); + } + if (whrPwr.GeneratedPower != null) { + pWHRMap = whrPwr.GeneratedPower; + pWHRCorr = pWHRMap * whr.WHRCorrectionFactor; } } -- GitLab