From b8eeb88ce0eb9c968c63e7698e8e6ba09a2c5986 Mon Sep 17 00:00:00 2001 From: Markus Quaritsch <markus.quaritsch@tugraz.at> Date: Tue, 28 Feb 2017 14:31:14 +0100 Subject: [PATCH] limit pt1 value to 0, allow computation with 0 pt1 (during search operating point) --- VectoCore/VectoCore/Models/Declaration/PT1.cs | 3 ++- .../SimulationComponent/Impl/CombustionEngine.cs | 13 ++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/VectoCore/VectoCore/Models/Declaration/PT1.cs b/VectoCore/VectoCore/Models/Declaration/PT1.cs index f7d2555008..6f4265bcd2 100644 --- a/VectoCore/VectoCore/Models/Declaration/PT1.cs +++ b/VectoCore/VectoCore/Models/Declaration/PT1.cs @@ -113,7 +113,8 @@ namespace TUGraz.VectoCore.Models.Declaration var pt1 = VectoMath.Interpolate(_entries[index - 1].Key, _entries[index].Key, _entries[index - 1].Value, _entries[index].Value, key); if (pt1 < 0) { - throw new VectoException("The calculated pt1 value must not be smaller than 0. Value: " + pt1); + pt1 = 0.SI<Second>(); + //throw new VectoException("The calculated pt1 value must not be smaller than 0. Value: " + pt1); } return pt1; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs index 3c7bf49db2..5af9201959 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs @@ -350,7 +350,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var avgEngineSpeed = (PreviousState.EngineSpeed + CurrentState.EngineSpeed) / 2.0; container[ModalResultField.P_eng_fcmap] = CurrentState.EngineTorque * avgEngineSpeed; - container[ModalResultField.P_eng_out] = container[ModalResultField.P_eng_out] is DBNull ? CurrentState.EngineTorqueOut * avgEngineSpeed : container[ModalResultField.P_eng_out]; + container[ModalResultField.P_eng_out] = container[ModalResultField.P_eng_out] is DBNull + ? CurrentState.EngineTorqueOut * avgEngineSpeed + : container[ModalResultField.P_eng_out]; container[ModalResultField.P_eng_inertia] = CurrentState.InertiaTorqueLoss * avgEngineSpeed; container[ModalResultField.n_eng_avg] = avgEngineSpeed; @@ -441,7 +443,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var powerRatio = (PreviousState.EnginePower / stationaryFullLoadPower).Value(); var tStarPrev = pt1 * Math.Log(1.0 / (1 - powerRatio), Math.E).SI<Second>(); var tStar = tStarPrev + PreviousState.dt; - dynFullPowerCalculated = stationaryFullLoadPower * (1 - Math.Exp((-tStar / pt1).Value())); + dynFullPowerCalculated = stationaryFullLoadPower * (pt1.IsEqual(0) ? 1 : (1 - Math.Exp((-tStar / pt1).Value()))); } catch (VectoException e) { Log.Warn("PT1 calculation failed (dryRun: {0}): {1}", dryRun, e.Message); if (dryRun) { @@ -552,9 +554,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } - var velocitySlope = (_dataBus.TractionInterruption - (absTime - _idleStart)).IsEqual(0) ? 0.SI<PerSquareSecond>() : - (_engineTargetSpeed - _engine.PreviousState.EngineSpeed) / - (_dataBus.TractionInterruption - (absTime - _idleStart)); + var velocitySlope = (_dataBus.TractionInterruption - (absTime - _idleStart)).IsEqual(0) + ? 0.SI<PerSquareSecond>() + : (_engineTargetSpeed - _engine.PreviousState.EngineSpeed) / + (_dataBus.TractionInterruption - (absTime - _idleStart)); var nextAngularSpeed = (velocitySlope * dt + _engine.PreviousState.EngineSpeed); -- GitLab