Skip to content

Commit 99f6866

Browse files
committed
Refactor the calculation of PRICE_EMISSION and remove PRICE_EMISSION_NEW
1 parent 72b05c3 commit 99f6866

File tree

4 files changed

+15
-39
lines changed

4 files changed

+15
-39
lines changed

Diff for: message_ix/model/MESSAGE/model_core.gms

+1-8
Original file line numberDiff line numberDiff line change
@@ -135,25 +135,18 @@ Variables
135135
* Variable Explanatory text
136136
* ======================================================================================= =======================================================================================================
137137
* :math:`\text{DEMAND}_{n,c,l,y,h} \in \mathbb{R}` Demand level (in equilibrium with MACRO integration)
138-
* :math:`\text{EMISSION_CONSTRAINT_RESCALE}_{n,\widehat{e},\widehat{t},y} \in \mathbb{R}` Annual average marginal of :ref:`emission_constraint`
139138
* :math:`\text{PRICE_COMMODITY}_{n,c,l,y,h} \in \mathbb{R}` Commodity price (undiscounted marginals of :ref:`commodity_balance_gt` and :ref:`commodity_balance_lt`)
140139
* :math:`\text{PRICE_EMISSION}_{n,\widehat{e},\widehat{t},y} \in \mathbb{R}` Emission price (undiscounted marginals of :ref:`emission_constraint`)
141140
* :math:`\text{COST_NODAL_NET}_{n,y} \in \mathbb{R}` System costs at the node level net of energy trade revenues/cost
142141
* :math:`\text{GDP}_{n,y} \in \mathbb{R}` Gross domestic product (GDP) in market exchange rates for MACRO reporting
143142
* ======================================================================================= =======================================================================================================
144-
*
145-
* .. warning::
146-
* Please be aware that transitioning from one period length to another for consecutive periods may result in false values of :math:`\text{PRICE_EMISSION}`.
147-
* Please see `this issue <https://github.com/iiasa/message_ix/issues/723>`_ for further information. We are currently working on a fix.
148143
***
149144

150145
Variables
151146
* auxiliary variables for demand, prices, costs and GDP (for reporting when MESSAGE is run with MACRO)
152147
DEMAND(node,commodity,level,year_all,time) demand
153-
EMISSION_CONSTRAINT_RESCALE(node,type_emission,type_tec,type_year) rescaled of marginals of EMISSION_CONSTRAINT constraint
154148
PRICE_COMMODITY(node,commodity,level,year_all,time) commodity price (derived from marginals of COMMODITY_BALANCE constraint)
155-
PRICE_EMISSION(node,type_emission,type_tec,year_all) emission price (derived from marginals of EMISSION_BOUND constraint)
156-
PRICE_EMISSION_NEW(node,type_emission,type_tec,year_all) emission price (derived from marginals of EMISSION_EQUIVALENCE constraint)
149+
PRICE_EMISSION(node,type_emission,type_tec,year_all) emission price (derived from marginals of EMISSION_EQUIVALENCE constraint)
157150
COST_NODAL_NET(node,year_all) system costs at the node level over time including effects of energy trade
158151
GDP(node,year_all) gross domestic product (GDP) in market exchange rates for MACRO reporting
159152
;

Diff for: message_ix/model/MESSAGE/model_solve.gms

+9-20
Original file line numberDiff line numberDiff line change
@@ -39,34 +39,23 @@ if (%foresight% = 0,
3939
ABORT "MESSAGEix did not solve to optimality!"
4040
) ;
4141

42-
* rescale the dual of the emission constraint to account that the constraint is defined on the average year, not total
43-
EMISSION_CONSTRAINT_RESCALE.l(node,type_emission,type_tec,type_year)$(
44-
EMISSION_CONSTRAINT.m(node,type_emission,type_tec,type_year) ) =
45-
EMISSION_CONSTRAINT.m(node,type_emission,type_tec,type_year)
46-
/ SUM(year$( cat_year(type_year,year) ), duration_period(year) )
47-
;
48-
49-
50-
* assign auxiliary variables DEMAND, PRICE_COMMODITY and PRICE_EMISSION for integration with MACRO and reporting
42+
* assign auxiliary variables DEMAND for integration with MACRO
5143
DEMAND.l(node,commodity,level,year,time) = demand_fixed(node,commodity,level,year,time) ;
44+
45+
* assign auxiliary variables PRICE_COMMODITY and PRICE_EMISSION for reporting
5246
PRICE_COMMODITY.l(node,commodity,level,year,time) =
5347
( COMMODITY_BALANCE_GT.m(node,commodity,level,year,time) + COMMODITY_BALANCE_LT.m(node,commodity,level,year,time) )
5448
/ df_period(year) ;
55-
PRICE_EMISSION.l(node,type_emission,type_tec,year)$( SUM(type_year$( cat_year(type_year,year) ), 1 ) ) =
56-
SMAX(type_year$( cat_year(type_year,year) ),
57-
- EMISSION_CONSTRAINT_RESCALE.l(node,type_emission,type_tec,type_year) )
58-
/ df_period(year) * duration_period(year);
59-
PRICE_EMISSION.l(node,type_emission,type_tec,year)$(
60-
PRICE_EMISSION.l(node,type_emission,type_tec,year) = - inf ) = 0 ;
61-
* Calculate PRICE_EMISSION based on the marginals of EMISSION_EQUIVALENCE
62-
PRICE_EMISSION_NEW.l(node,type_emission,type_tec,year)$( SUM(emission$( cat_emission(type_emission,emission) ),
49+
50+
* calculate PRICE_EMISSION based on the marginals of EMISSION_EQUIVALENCE
51+
PRICE_EMISSION.l(node,type_emission,type_tec,year)$( SUM(emission$( cat_emission(type_emission,emission) ),
6352
EMISSION_EQUIVALENCE.m(node,emission,type_tec,year) ) ) =
6453
SMAX(emission$( cat_emission(type_emission,emission) ),
6554
EMISSION_EQUIVALENCE.m(node,emission,type_tec,year) / emission_scaling(type_emission,emission) )
6655
/ df_period(year);
67-
PRICE_EMISSION_NEW.l(node,type_emission,type_tec,year)$(
68-
( PRICE_EMISSION_NEW.l(node,type_emission,type_tec,year) = eps ) or
69-
( PRICE_EMISSION_NEW.l(node,type_emission,type_tec,year) = -inf ) ) = 0 ;
56+
PRICE_EMISSION.l(node,type_emission,type_tec,year)$(
57+
( PRICE_EMISSION.l(node,type_emission,type_tec,year) = eps ) or
58+
( PRICE_EMISSION.l(node,type_emission,type_tec,year) = -inf ) ) = 0 ;
7059

7160
%AUX_BOUNDS% AUX_ACT_BOUND_LO(node,tec,year_all,year_all2,mode,time)$( ACT.l(node,tec,year_all,year_all2,mode,time) < 0 AND
7261
%AUX_BOUNDS% ACT.l(node,tec,year_all,year_all2,mode,time) = -%AUX_BOUND_VALUE% ) = yes ;

Diff for: message_ix/models.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,6 @@ def initialize(cls, scenario):
407407
par("commodity_stock", "n c l y")
408408
par("construction_time", "nl t yv")
409409
par("demand", "n c l y h")
410-
par("df_year", "y")
411-
par("df_period", "y")
412410
par("duration_period", "y")
413411
par("duration_time", "h")
414412
par("dynamic_land_lo", "n s y u")
@@ -457,7 +455,6 @@ def initialize(cls, scenario):
457455
par("level_cost_activity_soft_up", "nl t ya h")
458456
par("level_cost_new_capacity_soft_lo", "nl t yv")
459457
par("level_cost_new_capacity_soft_up", "nl t yv")
460-
par("levelized_cost", "n t y h")
461458
par("min_utilization_factor", "nl t yv ya")
462459
par("operation_factor", "nl t yv ya")
463460
par("output", "nl t yv ya m nd c l h hd")
@@ -560,12 +557,7 @@ def initialize(cls, scenario):
560557
var(
561558
"PRICE_EMISSION",
562559
"n type_emission type_tec y",
563-
"Emission price (derived from marginals of EMISSION_BOUND constraint)",
564-
)
565-
var(
566-
"PRICE_EMISSION_NEW",
567-
"n type_emission type_tec y",
568-
"TEMPORARY test for Emission price fix",
560+
"Emission price (derived from marginals of EMISSION_EQUIVALENCE constraint)",
569561
)
570562
var(
571563
"REL",

Diff for: message_ix/tests/test_feature_price_emission.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88

99
solve_args = {
1010
"equ_list": ["EMISSION_EQUIVALENCE"],
11-
"par_list": ["df_period", "df_year", "levelized_cost"],
12-
"var_list": ["PRICE_EMISSION_NEW"],
11+
# "par_list": ["df_period", "df_year", "levelized_cost"],
12+
# At the moment, it is not possible to retrieve auxilliary parameters that
13+
# are created in GAMS back to ixmp. The default "par_list" is coded in Java
14+
# backened, and specifying a list here does not add/modify the default list.
1315
}
1416

1517

0 commit comments

Comments
 (0)