Skip to content

Commit

Permalink
Adjust generic storage objective alike
Browse files Browse the repository at this point in the history
  • Loading branch information
jokochems committed Oct 6, 2023
1 parent 6c6f3a0 commit 6f999c0
Showing 1 changed file with 25 additions and 60 deletions.
85 changes: 25 additions & 60 deletions src/oemof/solph/components/_generic_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -1714,6 +1714,9 @@ def _objective_expression(self):
"microeconomic interest requirements."
)

duration_last_period = m.es.get_period_duration(-1)
end_of_optimization = m.es.periods_years[-1] + duration_last_period

for n in self.CONVEX_INVESTSTORAGES:
lifetime = n.investment.lifetime
interest = n.investment.interest_rate
Expand All @@ -1729,30 +1732,15 @@ def _objective_expression(self):
n=lifetime,
wacc=interest,
)
investment_costs_increment = (
self.invest[n, p]
* annuity
* lifetime
* ((1 + m.discount_rate) ** (-m.es.periods_years[p]))
duration = min(
end_of_optimization - m.es.periods_years[p], lifetime
)
remaining_value = 0
if lifetime > m.es.periods_matrix[p, -1]:
remaining_lifetime = (
lifetime - m.es.periods_matrix[p, -1]
)
remaining_annuity = economics.annuity(
capex=n.investment.ep_costs[-1],
n=lifetime,
wacc=interest,
)
remaining_value = (
self.invest[n, p]
* remaining_annuity
* remaining_lifetime
) * (
(1 + m.discount_rate) ** (-m.es.periods_years[-1])
)
investment_costs_increment -= remaining_value
present_value_factor = 1 / economics.annuity(
capex=1, n=duration, wacc=m.discount_rate
)
investment_costs_increment = (
self.invest[n, p] * annuity * present_value_factor
) * ((1 + m.discount_rate) ** (-m.es.periods_years[p]))
investment_costs += investment_costs_increment
period_investment_costs[p] += investment_costs_increment

Expand All @@ -1771,72 +1759,49 @@ def _objective_expression(self):
n=lifetime,
wacc=interest,
)
duration = min(
end_of_optimization - m.es.periods_years[p], lifetime
)
present_value_factor = 1 / economics.annuity(
capex=1, n=duration, wacc=m.discount_rate
)
investment_costs_increment = (
self.invest[n, p] * annuity * lifetime
self.invest[n, p] * annuity * present_value_factor
+ self.invest_status[n, p] * n.investment.offset[p]
) * ((1 + m.discount_rate) ** (-m.es.periods_years[p]))
remaining_value = 0
if lifetime > m.es.periods_matrix[p, -1]:
remaining_lifetime = (
lifetime - m.es.periods_matrix[p, -1]
)
remaining_annuity = economics.annuity(
capex=n.investment.ep_costs[-1],
n=lifetime,
wacc=interest,
)
remaining_value = (
self.invest[n, p]
* remaining_annuity
* remaining_lifetime
+ self.invest_status[n, p]
* n.investment.offset[-1]
) * (
(1 + m.discount_rate) ** (-m.es.periods_years[-1])
)
investment_costs_increment -= remaining_value
investment_costs += investment_costs_increment
period_investment_costs[p] += investment_costs_increment

for n in self.INVESTSTORAGES:
if n.investment.fixed_costs[0] is not None:
lifetime = n.investment.lifetime
for p in m.PERIODS:
range_limit = min(
end_of_optimization,
m.es.periods_years[p] + lifetime,
)
fixed_costs += sum(
self.invest[n, p]
* n.investment.fixed_costs[pp]
* ((1 + m.discount_rate) ** (-pp))
for pp in range(
m.es.periods_years[p],
m.es.periods_years[p] + lifetime,
range_limit,
)
) * ((1 + m.discount_rate) ** (-m.es.periods_years[p]))
if lifetime > m.es.periods_matrix[p, -1]:
fixed_costs -= sum(
self.invest[n, p]
* n.investment.fixed_costs[pp]
* ((1 + m.discount_rate) ** (-pp))
for pp in range(
m.es.periods_years[-1],
m.es.periods_years[p] + lifetime,
)
) * (
(1 + m.discount_rate)
** (-m.es.periods_years[-1])
)

for n in self.EXISTING_INVESTSTORAGES:
if n.investment.fixed_costs[0] is not None:
lifetime = n.investment.lifetime
age = n.investment.age
range_limit = min(
m.es.periods_matrix[0, -1], lifetime - age
end_of_optimization, lifetime - age
)
fixed_costs += sum(
n.investment.existing
* n.investment.fixed_costs[pp]
* ((1 + m.discount_rate) ** (-pp))
for pp in range(0, range_limit)
for pp in range(range_limit)
)

self.investment_costs = Expression(expr=investment_costs)
Expand Down

0 comments on commit 6f999c0

Please sign in to comment.