From 6b1317ead837e5433871a1b20ed623239ce40a4e Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Tue, 10 Nov 2020 09:51:45 +0100
Subject: [PATCH] correct energy calculation for supercaps

---
 .../VectoCore/Models/SimulationComponent/Impl/SuperCap.cs    | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/SuperCap.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/SuperCap.cs
index 5333051013..ab26393427 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/SuperCap.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/SuperCap.cs
@@ -37,7 +37,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 
 		public WattSecond StoredEnergy
 		{
-			get { return PreviousState.Charge * InternalVoltage; }
+			// E = 1/2 C * U^2 = 1/2 Q^2/C
+			get { return PreviousState.Charge * InternalVoltage / 2.0; }
 		}
 
 		public Watt MaxChargePower(Second dt)
@@ -191,7 +192,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 			container[ModalResultField.P_reess_charge_max] = CurrentState.MaxChargePower;
 			container[ModalResultField.P_reess_discharge_max] = CurrentState.MaxDischargePower;
 
-			container[ModalResultField.E_RESS] = CurrentState.Charge * internalVoltage * ModelData.Capacity;
+			container[ModalResultField.E_RESS] = CurrentState.Charge * CurrentState.Charge / ModelData.Capacity / 2.0;
 		}
 
 		protected override void DoCommitSimulationStep(Second time, Second simulationInterval)
-- 
GitLab