diff --git a/VectoCore/VectoCore/Models/Declaration/PT1.cs b/VectoCore/VectoCore/Models/Declaration/PT1.cs index f7d255500814e1622ad0ea1abdd19692dd00e7fb..6f4265bcd2ef07a733111a22250c38abf5d7c801 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 3c7bf49db28a596c1a3cb2e94f1c6956b9be27e7..5af9201959f5d8400cf822a8266cf63cefdd53ee 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);