Skip to content

Commit

Permalink
Merge branch 'dev' into feature/storage_losses
Browse files Browse the repository at this point in the history
  • Loading branch information
p-snft committed Jul 9, 2024
2 parents ced3300 + 6dae8bc commit 98fef1e
Showing 1 changed file with 13 additions and 22 deletions.
35 changes: 13 additions & 22 deletions src/oemof/solph/components/_generic_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -510,37 +508,30 @@ 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]
* n.nominal_storage_capacity
* 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
Expand Down

0 comments on commit 98fef1e

Please sign in to comment.