Skip to content

Commit

Permalink
Account for remaining values and limit fixed costs to optimization ho…
Browse files Browse the repository at this point in the history
…rizon in invest flow
  • Loading branch information
jokochems committed Oct 2, 2023
1 parent f02297e commit aa15956
Showing 1 changed file with 55 additions and 1 deletion.
56 changes: 55 additions & 1 deletion src/oemof/solph/flows/_investment_flow_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,24 @@ def _objective_expression(self):
* lifetime
* ((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=m.flows[i, o].investment.ep_costs[-1],
n=lifetime,
wacc=interest,
)
remaining_value = (
self.invest[i, o, p]
* remaining_annuity
* remaining_lifetime
) * (
(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

Expand All @@ -910,6 +928,26 @@ def _objective_expression(self):
+ self.invest_status[i, o, p]
* m.flows[i, o].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=m.flows[i, o].investment.ep_costs[-1],
n=lifetime,
wacc=interest,
)
remaining_value = (
self.invest[i, o, p]
* remaining_annuity
* remaining_lifetime
+ self.invest_status[i, o, p]
* m.flows[i, o].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

Expand All @@ -926,16 +964,32 @@ def _objective_expression(self):
m.es.periods_years[p] + lifetime,
)
) * ((1 + m.discount_rate) ** (-m.es.periods_years[p]))
if lifetime > m.es.periods_matrix[p, -1]:
fixed_costs -= sum(
self.invest[i, o, p]
* m.flows[i, o].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 i, o in self.EXISTING_INVESTFLOWS:
if m.flows[i, o].investment.fixed_costs[0] is not None:
lifetime = m.flows[i, o].investment.lifetime
age = m.flows[i, o].investment.age
range_limit = max(
m.es.periods_matrix[0, -1], lifetime - age
)
fixed_costs += sum(
m.flows[i, o].investment.existing
* m.flows[i, o].investment.fixed_costs[pp]
* ((1 + m.discount_rate) ** (-pp))
for pp in range(0, lifetime - age)
for pp in range(0, range_limit)
)

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

0 comments on commit aa15956

Please sign in to comment.