From 6dae8bc3725d063bef2249377e75d114a0487f0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrik=20Sch=C3=B6nfeldt?= Date: Mon, 8 Jul 2024 17:12:08 +0200 Subject: [PATCH] Revert "Introduce variable for storage losses" This reverts commit 2e5ca23cfd2d6afbe476ef67abb6f496ab3aaa62. --- .../solph/components/_generic_storage.py | 35 +++++++------------ 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/src/oemof/solph/components/_generic_storage.py b/src/oemof/solph/components/_generic_storage.py index b04410508..7e287fc09 100644 --- a/src/oemof/solph/components/_generic_storage.py +++ b/src/oemof/solph/components/_generic_storage.py @@ -497,8 +497,6 @@ def _storage_content_bound_rule(block, n, t): self.STORAGES, m.TIMEPOINTS, bounds=_storage_content_bound_rule ) - self.storage_losses = Var(self.STORAGES, m.TIMESTEPS) - # set the initial storage content # ToDo: More elegant code possible? for n in group: @@ -510,9 +508,16 @@ def _storage_content_bound_rule(block, n, t): # ************* Constraints *************************** - def _storage_losses_rule(block, n, t): - expr = block.storage_content[n, t] * ( - n.loss_rate[t] ** m.timeincrement[t] + def _storage_balance_rule(block, n, t): + """ + Rule definition for the storage balance of every storage n and + every timestep. + """ + expr = 0 + expr += block.storage_content[n, t + 1] + expr += ( + -block.storage_content[n, t] + * (1 - n.loss_rate[t]) ** m.timeincrement[t] ) expr += ( n.fixed_losses_relative[t] @@ -520,27 +525,13 @@ def _storage_losses_rule(block, n, t): * m.timeincrement[t] ) expr += n.fixed_losses_absolute[t] * m.timeincrement[t] - - return expr == block.storage_losses[n, t] - - self.losses = Constraint( - self.STORAGES, m.TIMESTEPS, rule=_storage_losses_rule - ) - - def _storage_balance_rule(block, n, t): - """ - Rule definition for the storage balance of every storage n and - every timestep. - """ - expr = block.storage_content[n, t] - expr -= block.storage_losses[n, t] expr += ( - m.flow[i[n], n, t] * n.inflow_conversion_factor[t] + -m.flow[i[n], n, t] * n.inflow_conversion_factor[t] ) * m.timeincrement[t] - expr -= ( + expr += ( m.flow[n, o[n], t] / n.outflow_conversion_factor[t] ) * m.timeincrement[t] - return expr == block.storage_content[n, t + 1] + return expr == 0 self.balance = Constraint( self.STORAGES, m.TIMESTEPS, rule=_storage_balance_rule