From 1ed1493da61cdda07959d92b97beca3bf357482c Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Fri, 9 Sep 2016 14:32:35 +0200
Subject: [PATCH] renaming method for better understandability

---
 .../Models/SimulationComponent/IAuxPort.cs         |  2 +-
 .../Models/SimulationComponent/Impl/ATGearbox.cs   |  2 +-
 .../Impl/BusAuxiliariesAdapter.cs                  |  4 ++--
 .../SimulationComponent/Impl/CombustionEngine.cs   |  4 ++--
 .../SimulationComponent/Impl/EngineAuxiliary.cs    |  2 +-
 .../Impl/EngineOnlyCombustionEngine.cs             |  2 +-
 .../Models/SimulationComponent/Impl/Gearbox.cs     |  2 +-
 .../Integration/BusAuxiliaries/AuxDemandTest.cs    |  8 ++++----
 .../Integration/BusAuxiliaries/BusAdapterTest.cs   |  8 ++++----
 .../VectoCoreTest/Models/Simulation/AuxTests.cs    | 14 +++++++-------
 10 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/VectoCore/VectoCore/Models/SimulationComponent/IAuxPort.cs b/VectoCore/VectoCore/Models/SimulationComponent/IAuxPort.cs
index d62678eca3..7ec5e4a130 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/IAuxPort.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/IAuxPort.cs
@@ -47,7 +47,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent
 	{
 		NewtonMeter Initialize(NewtonMeter torque, PerSecond angularSpeed);
 
-		NewtonMeter PowerDemand(Second absTime, Second dt, NewtonMeter torquePowerTrain, NewtonMeter torqueEngine,
+		NewtonMeter TorqueDemand(Second absTime, Second dt, NewtonMeter torquePowerTrain, NewtonMeter torqueEngine,
 			PerSecond angularSpeed, bool dryRun = false);
 	}
 }
\ No newline at end of file
diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs
index bfae1be4cf..5de45f6723 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs
@@ -189,7 +189,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 
 			if (Auxiliary != null) {
 				//todo mk-2016-08-22: aux loss from out-direction or in-direction of the gearbox?
-				inTorque += Auxiliary.PowerDemand(absTime, dt, outTorque, inTorque, outAngularVelocity, dryRun);
+				inTorque += Auxiliary.TorqueDemand(absTime, dt, outTorque, inTorque, outAngularVelocity, dryRun);
 			}
 
 			if (!TorqueConverterLocked && !ModelData.Gears[Gear].HasTorqueConverter) {
diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs
index 4b41df468f..3bc3fbffe7 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs
@@ -138,7 +138,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 		}
 
 
-		public NewtonMeter PowerDemand(Second absTime, Second dt, NewtonMeter torquePowerTrain, NewtonMeter torqueEngine,
+		public NewtonMeter TorqueDemand(Second absTime, Second dt, NewtonMeter torquePowerTrain, NewtonMeter torqueEngine,
 			PerSecond angularSpeed, bool dryRun = false)
 		{
 			CurrentState.AngularSpeed = angularSpeed;
@@ -251,7 +251,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 			Auxiliaries.Signals.EngineSpeed = angularSpeed;
 			var avgAngularSpeed = (PreviousState.AngularSpeed + CurrentState.AngularSpeed) / 2;
 			Auxiliaries.Signals.PreExistingAuxPower = AdditionalAux != null
-				? AdditionalAux.PowerDemand(absTime, dt, torquePowerTrain, torqueEngine, angularSpeed, dryRun) * avgAngularSpeed
+				? AdditionalAux.TorqueDemand(absTime, dt, torquePowerTrain, torqueEngine, angularSpeed, dryRun) * avgAngularSpeed
 				: 0.SI<Watt>();
 			 //mAAUX_Global.PreExistingAuxPower;
 			Auxiliaries.Signals.Idle = DataBus.VehicleStopped;
diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs
index 4c2e520c79..423492afe3 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs
@@ -191,7 +191,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 
 			var auxTorqueDemand = EngineAux == null
 				? 0.SI<NewtonMeter>()
-				: EngineAux.PowerDemand(absTime, dt, CurrentState.EngineTorqueOut,
+				: EngineAux.TorqueDemand(absTime, dt, CurrentState.EngineTorqueOut,
 					CurrentState.EngineTorqueOut + CurrentState.InertiaTorqueLoss, angularVelocity, dryRun);
 			// compute the torque the engine has to provide. powertrain + aux + its own inertia
 			var totalTorqueDemand = torqueOut + auxTorqueDemand + CurrentState.InertiaTorqueLoss;
@@ -207,7 +207,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 			// get max. torque as limited by gearbox. gearbox only limits torqueOut!
 			var gearboxFullLoad = DataBus.GearMaxTorque;
 
-			var deltaFull = ComputeDelta(torqueOut, totalTorqueDemand, CurrentState.DynamicFullLoadTorque, gearboxFullLoad, true);
+			var deltaFull = ComputeDelta(torqueOut, totalTorqueDemand + (CurrentState.InertiaTorqueLoss < 0 ? CurrentState.InertiaTorqueLoss : 0.SI<NewtonMeter>()), CurrentState.DynamicFullLoadTorque, gearboxFullLoad, true);
 			var deltaDrag = ComputeDelta(torqueOut, totalTorqueDemand, CurrentState.FullDragTorque,
 				gearboxFullLoad != null ? -gearboxFullLoad : null, false);
 
diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineAuxiliary.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineAuxiliary.cs
index bed32b35e8..346199cc47 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineAuxiliary.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineAuxiliary.cs
@@ -96,7 +96,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 			return ComputePowerDemand(angularSpeed) / angularSpeed;
 		}
 
-		public NewtonMeter PowerDemand(Second absTime, Second dt, NewtonMeter torquePowerTrain, NewtonMeter torqueEngine,
+		public NewtonMeter TorqueDemand(Second absTime, Second dt, NewtonMeter torquePowerTrain, NewtonMeter torqueEngine,
 			PerSecond angularSpeed, bool dryRun = false)
 		{
 			CurrentState.AngularSpeed = angularSpeed;
diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineOnlyCombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineOnlyCombustionEngine.cs
index e867f7c0e2..f2f1dd9621 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineOnlyCombustionEngine.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineOnlyCombustionEngine.cs
@@ -64,7 +64,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 
 			var auxTorqueDemand = EngineAux == null
 				? 0.SI<NewtonMeter>()
-				: EngineAux.PowerDemand(absTime, dt, CurrentState.EngineTorqueOut,
+				: EngineAux.TorqueDemand(absTime, dt, CurrentState.EngineTorqueOut,
 					CurrentState.EngineTorqueOut + CurrentState.InertiaTorqueLoss, angularVelocity, dryRun);
 
 			var totalTorqueDemand = CurrentState.EngineTorqueOut + auxTorqueDemand + CurrentState.InertiaTorqueLoss;
diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs
index 4e46124cbc..b989ba75ea 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs
@@ -302,7 +302,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 
 			if (Auxiliary != null) {
 				//todo mk-2016-08-17: aux loss from out-direction or in-direction of the gearbox?
-				inTorque += Auxiliary.PowerDemand(absTime, dt, outTorque, inTorque, outAngularVelocity, dryRun);
+				inTorque += Auxiliary.TorqueDemand(absTime, dt, outTorque, inTorque, outAngularVelocity, dryRun);
 			}
 
 			var inAngularVelocity = outAngularVelocity * ModelData.Gears[Gear].Ratio;
diff --git a/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/AuxDemandTest.cs b/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/AuxDemandTest.cs
index 5b06ce329f..3cf1cb4cf8 100644
--- a/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/AuxDemandTest.cs
+++ b/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/AuxDemandTest.cs
@@ -60,7 +60,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries
 			var engineSpeed = engineSpeedRpm.RPMtoRad();
 			busAux.Initialize(engineDrivelinePower / engineSpeed, engineSpeed);
 
-			var torque = busAux.PowerDemand(0.SI<Second>(), 1.SI<Second>(), engineDrivelinePower / engineSpeed,
+			var torque = busAux.TorqueDemand(0.SI<Second>(), 1.SI<Second>(), engineDrivelinePower / engineSpeed,
 				(internalPower * 1000).SI<Watt>() / engineSpeed, engineSpeed);
 
 			Assert.AreEqual(expectedPowerDemand, (torque * engineSpeed).Value(), 1e-2);
@@ -83,7 +83,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries
 			var modalData = new MockModalDataContainer();
 
 			for (int i = 0; i < 10; i++) {
-				var torque = busAux.PowerDemand(0.SI<Second>(), 1.SI<Second>(), engineDrivelinePower / engineSpeed,
+				var torque = busAux.TorqueDemand(0.SI<Second>(), 1.SI<Second>(), engineDrivelinePower / engineSpeed,
 					(internalPower * 1000).SI<Watt>() / engineSpeed, engineSpeed);
 				Assert.AreEqual(6086.9321, (torque * engineSpeed).Value(), 1e-3);
 				busAux.DoWriteModalResults(modalData);
@@ -95,7 +95,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries
 			internalPower = -50;
 
 			for (int i = 0; i < 10; i++) {
-				var torque = busAux.PowerDemand(0.SI<Second>(), 1.SI<Second>(), engineDrivelinePower / engineSpeed,
+				var torque = busAux.TorqueDemand(0.SI<Second>(), 1.SI<Second>(), engineDrivelinePower / engineSpeed,
 					(internalPower * 1000).SI<Watt>() / engineSpeed, engineSpeed);
 				Assert.AreEqual(8954.1396, (torque * engineSpeed).Value(), 1e-3);
 				busAux.DoWriteModalResults(modalData);
@@ -107,7 +107,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries
 			internalPower = 148;
 
 			for (int i = 0; i < 10; i++) {
-				var torque = busAux.PowerDemand(0.SI<Second>(), 1.SI<Second>(), engineDrivelinePower / engineSpeed,
+				var torque = busAux.TorqueDemand(0.SI<Second>(), 1.SI<Second>(), engineDrivelinePower / engineSpeed,
 					(internalPower * 1000).SI<Watt>() / engineSpeed, engineSpeed);
 				Assert.AreEqual(6086.9321, (torque * engineSpeed).Value(), 1e-3);
 				busAux.DoWriteModalResults(modalData);
diff --git a/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/BusAdapterTest.cs b/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/BusAdapterTest.cs
index 44e6fedf96..14e434a22f 100644
--- a/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/BusAdapterTest.cs
+++ b/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/BusAdapterTest.cs
@@ -63,7 +63,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries
 			var engineSpeed = engineSpeedRpm.RPMtoRad();
 			busAux.Initialize(engineDrivelinePower / engineSpeed, engineSpeed);
 
-			var torque = busAux.PowerDemand(0.SI<Second>(), 1.SI<Second>(), engineDrivelinePower / engineSpeed,
+			var torque = busAux.TorqueDemand(0.SI<Second>(), 1.SI<Second>(), engineDrivelinePower / engineSpeed,
 				(internalPower * 1000).SI<Watt>() / engineSpeed, engineSpeed);
 
 			Assert.AreEqual(expectedPowerDemand, (torque * engineSpeed).Value(), 1e-2);
@@ -95,7 +95,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries
 			var engineSpeed = engineSpeedRpm.RPMtoRad();
 			busAux.Initialize(engineDrivelinePower / engineSpeed, engineSpeed);
 
-			var torque = busAux.PowerDemand(0.SI<Second>(), 1.SI<Second>(), engineDrivelinePower / engineSpeed,
+			var torque = busAux.TorqueDemand(0.SI<Second>(), 1.SI<Second>(), engineDrivelinePower / engineSpeed,
 				(internalPower * 1000).SI<Watt>() / engineSpeed, engineSpeed);
 
 			Assert.AreEqual(expectedPowerDemand, (torque * engineSpeed).Value(), 1e-2);
@@ -118,7 +118,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries
 			var engineSpeed = engineSpeedRpm.RPMtoRad();
 			busAux.Initialize(engineDrivelinePower / engineSpeed, engineSpeed);
 
-			var torque = busAux.PowerDemand(0.SI<Second>(), 1.SI<Second>(), engineDrivelinePower / engineSpeed,
+			var torque = busAux.TorqueDemand(0.SI<Second>(), 1.SI<Second>(), engineDrivelinePower / engineSpeed,
 				(internalPower * 1000).SI<Watt>() / engineSpeed, engineSpeed);
 
 			Assert.AreEqual(expectedPowerDemand, (torque * engineSpeed).Value(), 1e-3);
@@ -147,7 +147,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries
 				var engineSpeed = engineSpeedRpm.RPMtoRad();
 				busAux.Initialize(engineDrivelinePower / engineSpeed, engineSpeed);
 
-				var torque = busAux.PowerDemand(0.SI<Second>(), 1.SI<Second>(), engineDrivelinePower / engineSpeed,
+				var torque = busAux.TorqueDemand(0.SI<Second>(), 1.SI<Second>(), engineDrivelinePower / engineSpeed,
 					(internalPower).SI<Watt>() / engineSpeed, engineSpeed);
 
 				var row = table.NewRow();
diff --git a/VectoCore/VectoCoreTest/Models/Simulation/AuxTests.cs b/VectoCore/VectoCoreTest/Models/Simulation/AuxTests.cs
index 6fb6a1c2cd..4b1a32cf76 100644
--- a/VectoCore/VectoCoreTest/Models/Simulation/AuxTests.cs
+++ b/VectoCore/VectoCoreTest/Models/Simulation/AuxTests.cs
@@ -95,7 +95,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
 
 			aux.Initialize(torque, speed);
 			for (var i = 0; i < 11; i++) {
-				aux.PowerDemand(t, dt, torque, torque, speed);
+				aux.TorqueDemand(t, dt, torque, torque, speed);
 				modData[ModalResultField.dist] = i.SI<Meter>();
 				modData[ModalResultField.P_eng_out] = 0.SI<Watt>();
 				modData[ModalResultField.acc] = 0.SI<MeterPerSquareSecond>();
@@ -130,19 +130,19 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
 			var t = 0.SI<Second>();
 
 			aux.Initialize(torque, speed);
-			var auxDemand = aux.PowerDemand(t, t, torque, torque, speed);
+			var auxDemand = aux.TorqueDemand(t, t, torque, torque, speed);
 			AssertHelper.AreRelativeEqual(constPower / speed, auxDemand);
 
 			speed = 2358.RPMtoRad();
 			torque = 1500.SI<NewtonMeter>();
 			aux.Initialize(torque, speed);
-			auxDemand = aux.PowerDemand(t, t, torque, torque, speed);
+			auxDemand = aux.TorqueDemand(t, t, torque, torque, speed);
 			AssertHelper.AreRelativeEqual(constPower / speed, auxDemand);
 
 			speed = 1500.RPMtoRad();
 			torque = 1500.SI<NewtonMeter>();
 			aux.Initialize(torque, speed);
-			auxDemand = aux.PowerDemand(t, t, torque, torque, speed);
+			auxDemand = aux.TorqueDemand(t, t, torque, torque, speed);
 			AssertHelper.AreRelativeEqual(constPower / speed, auxDemand);
 		}
 
@@ -167,7 +167,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
 			var expected = new[] { 6100, 3100, 2300, 4500, 6100 };
 			foreach (var e in expected) {
 				aux.Initialize(torque, speed);
-				var auxDemand = aux.PowerDemand(t, t, torque, torque, speed);
+				var auxDemand = aux.TorqueDemand(t, t, torque, torque, speed);
 
 				AssertHelper.AreRelativeEqual((e.SI<Watt>() / speed).Value(), auxDemand.Value());
 				cycle.CommitSimulationStep(null);
@@ -224,7 +224,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
 
 			foreach (var e in expected) {
 				aux.Initialize(torque, speed);
-				var auxDemand = aux.PowerDemand(t, t, torque, torque, speed);
+				var auxDemand = aux.TorqueDemand(t, t, torque, torque, speed);
 
 				AssertHelper.AreRelativeEqual((e.SI<Watt>() / speed).Value(), auxDemand.Value());
 
@@ -278,7 +278,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
 
 			foreach (var e in expected) {
 				aux.Initialize(torque, speed);
-				var auxDemand = aux.PowerDemand(t, t, torque, torque, speed);
+				var auxDemand = aux.TorqueDemand(t, t, torque, torque, speed);
 
 				AssertHelper.AreRelativeEqual((e.SI<Watt>() / speed).Value(), auxDemand);
 
-- 
GitLab