From ff25c47f105d7ca0364fa0b09f7d147568d3ef5a Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Mon, 18 Nov 2019 17:41:16 +0100
Subject: [PATCH] limit max engine speed in validation to maximum of max gear
 speed and max engine speed

(cherry picked from commit 74df1e83ba875d6c2b23858431bba3996c082f28)
(cherry picked from commit 2de9d234ae2122b27cd17d9d29e1a1cdcff7fcd9)
---
 VectoCore/VectoCore/Models/Simulation/Data/VectoRunData.cs | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/VectoCore/VectoCore/Models/Simulation/Data/VectoRunData.cs b/VectoCore/VectoCore/Models/Simulation/Data/VectoRunData.cs
index 98ec6532ea..5d2690b2ec 100644
--- a/VectoCore/VectoCore/Models/Simulation/Data/VectoRunData.cs
+++ b/VectoCore/VectoCore/Models/Simulation/Data/VectoRunData.cs
@@ -184,9 +184,10 @@ namespace TUGraz.VectoCore.Models.Simulation.Data
 			}
 
 			foreach (var gear in gearboxData.Gears) {
+				var maxEngineSpeed = VectoMath.Min(engineData.FullLoadCurves[gear.Key].RatedSpeed, gear.Value.MaxSpeed);
 				for (var angularVelocity = engineData.IdleSpeed;
-					angularVelocity < engineData.FullLoadCurves[gear.Key].RatedSpeed;
-					angularVelocity += 2.0 / 3.0 * (engineData.FullLoadCurves[gear.Key].RatedSpeed - engineData.IdleSpeed) / 10.0) {
+					angularVelocity < maxEngineSpeed;
+					angularVelocity += 2.0 / 3.0 * (maxEngineSpeed - engineData.IdleSpeed) / 10.0) {
 					if (!gear.Value.HasLockedGear) {
 						continue;
 					}
-- 
GitLab