From aa15956a0d41571e4cf8d602a2a520a8bff9bc78 Mon Sep 17 00:00:00 2001 From: Johannes Kochems Date: Mon, 2 Oct 2023 17:06:30 +0200 Subject: [PATCH] Account for remaining values and limit fixed costs to optimization horizon in invest flow --- .../solph/flows/_investment_flow_block.py | 56 ++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/src/oemof/solph/flows/_investment_flow_block.py b/src/oemof/solph/flows/_investment_flow_block.py index 9ee4122e3..817a9be78 100644 --- a/src/oemof/solph/flows/_investment_flow_block.py +++ b/src/oemof/solph/flows/_investment_flow_block.py @@ -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 @@ -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 @@ -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)