Skip to content

Commit

Permalink
This commit patches a small bug in how variable costs and emission co…
Browse files Browse the repository at this point in the history
…sts are calculated and reported. This is a response to a flagged issue: TemoaProject#90
  • Loading branch information
SutubraResearch committed Nov 26, 2024
1 parent 1f7444d commit 45480ef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
9 changes: 4 additions & 5 deletions temoa/temoa_model/table_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,10 +699,10 @@ def write_costs(self, M: TemoaModel, emission_entries=None, iteration=None):
continue

var_cost = value(M.CostVariable[r, p, t, v])
undiscounted_var_cost = activity * var_cost * value(MPL[r, p, t, v])
undiscounted_var_cost = activity * var_cost * value(M.PeriodLength[p])

model_var_cost = temoa_rules.fixed_or_variable_cost(
activity, var_cost, value(MPL[r, p, t, v]), GDR=GDR, P_0=p_0, p=p
activity, var_cost, value(M.PeriodLength[p]), GDR=GDR, P_0=p_0, p=p
)
if '-' in r:
exchange_costs.add_cost_record(
Expand Down Expand Up @@ -740,7 +740,6 @@ def _gather_emission_costs_and_flows(self, M: 'TemoaModel'):
# see the note on emissions in the Cost function in temoa_rules

GDR = value(M.GlobalDiscountRate)
MPL = M.ModelProcessLife
if self.config.scenario_mode == TemoaMode.MYOPIC:
p_0 = M.MyopicBaseyear
else:
Expand Down Expand Up @@ -788,12 +787,12 @@ def _gather_emission_costs_and_flows(self, M: 'TemoaModel'):
flows[ei] = 0.0
continue
undiscounted_emiss_cost = (
flows[ei] * M.CostEmission[ei.r, ei.p, ei.e] * MPL[ei.r, ei.p, ei.t, ei.v]
flows[ei] * M.CostEmission[ei.r, ei.p, ei.e] * M.PeriodLength[ei.p]
)
discounted_emiss_cost = temoa_rules.fixed_or_variable_cost(
cap_or_flow=flows[ei],
cost_factor=M.CostEmission[ei.r, ei.p, ei.e],
process_lifetime=MPL[ei.r, ei.p, ei.t, ei.v],
process_lifetime=M.PeriodLength[ei.p],
GDR=GDR,
P_0=p_0,
p=ei.p,
Expand Down
8 changes: 4 additions & 4 deletions temoa/temoa_model/temoa_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ def PeriodCost_rule(M: 'TemoaModel', p):
fixed_or_variable_cost(
M.V_FlowOut[r, p, s, d, S_i, S_t, S_v, S_o],
M.CostVariable[r, p, S_t, S_v],
MPL[r, p, S_t, S_v],
M.PeriodLength[p],
GDR,
P_0,
p,
Expand All @@ -509,7 +509,7 @@ def PeriodCost_rule(M: 'TemoaModel', p):
fixed_or_variable_cost(
M.V_FlowOutAnnual[r, p, S_i, S_t, S_v, S_o],
M.CostVariable[r, p, S_t, S_v],
MPL[r, p, S_t, S_v],
M.PeriodLength[p],
GDR,
P_0,
p,
Expand Down Expand Up @@ -555,7 +555,7 @@ def PeriodCost_rule(M: 'TemoaModel', p):
fixed_or_variable_cost(
cap_or_flow=M.V_FlowOut[r, p, s, d, i, t, v, o] * M.EmissionActivity[r, e, i, t, v, o],
cost_factor=M.CostEmission[r, p, e],
process_lifetime=MPL[r, p, t, v],
process_lifetime=M.PeriodLength[p],
GDR=GDR,
P_0=P_0,
p=p,
Expand All @@ -572,7 +572,7 @@ def PeriodCost_rule(M: 'TemoaModel', p):
fixed_or_variable_cost(
cap_or_flow=M.V_FlowOutAnnual[r, p, i, t, v, o] * M.EmissionActivity[r, e, i, t, v, o],
cost_factor=M.CostEmission[r, p, e],
process_lifetime=MPL[r, p, t, v],
process_lifetime=M.PeriodLength[p],
GDR=GDR,
P_0=P_0,
p=p,
Expand Down

0 comments on commit 45480ef

Please sign in to comment.