Skip to content

Commit eba5fe2

Browse files
measrainseykhaeru
authored andcommitted
Add script to modify Very Low scenarios
1 parent d09b435 commit eba5fe2

File tree

1 file changed

+132
-0
lines changed
  • message_ix_models/project/ssp/script/scenarios

1 file changed

+132
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
import os
2+
3+
import ixmp # type: ignore
4+
import message_ix # type: ignore
5+
6+
from message_ix_models.project.ssp.script.util.functions import (
7+
add_balance_equality,
8+
add_steel_sector_nze,
9+
modify_rc_bounds,
10+
modify_steel_growth,
11+
modify_steel_initial,
12+
modify_tax_emission,
13+
remove_bof_steel_lower,
14+
)
15+
from message_ix_models.project.ssp.script.util.shares import (
16+
main as add_UE_share_constraints,
17+
)
18+
19+
path_ue = "/Users/meas/iiasagit/scenariomip-review/scenariomip_review/data/ue-shares"
20+
# path_ue = "/home/mengm/repo/scenariomip-review/scenariomip_review/data/ue-shares"
21+
22+
# selections
23+
sel_scen = "LED"
24+
scen_suffix = "g05_e9"
25+
# scen_vers = 1
26+
rem_bof_steel = True
27+
mod_growth_steel = True
28+
mod_initial_steel = True
29+
add_steel_target = False
30+
file_ue = "trp_gas0.05_elec0.9.xlsx"
31+
32+
# parameters
33+
trp_year_start = 2035
34+
mult_price = 5.5
35+
rc_years = [2060, 2070, 2080, 2090, 2100, 2110]
36+
steel_years = [2030, 2035, 2040, 2045, 2050, 2055, 2060, 2070, 2080, 2090, 2100, 2110]
37+
steel_growth = 0.075
38+
steel_inital = 1.0
39+
nze_targets = [
40+
0,
41+
0,
42+
0,
43+
0,
44+
]
45+
46+
# model and scenario names
47+
path_ue_file = os.path.join(path_ue, file_ue)
48+
snames = {"SSP1": "SSP1 - Very Low Emissions", "LED": "SSP2 - Very Low Emissions"}
49+
svers = {"SSP1": 1, "LED": 2}
50+
model_orig = "SSP_" + sel_scen + "_v1.0"
51+
scenario_orig = snames[sel_scen]
52+
53+
# add scen_suffic depending on remove_bof_steel, modify_lc_steel,
54+
# steel_scalar, and add_steel_target
55+
if rem_bof_steel:
56+
scen_suffix += "_bof"
57+
if mod_growth_steel:
58+
scen_suffix += "_growth" # + str(steel_growth)
59+
if mod_initial_steel:
60+
scen_suffix += "_initial" # + str(steel_inital)
61+
if add_steel_target:
62+
scen_suffix += "_nzsteel"
63+
64+
model_target = "MM_ScenarioMIP"
65+
scenario_target = "VL_" + sel_scen + "_" + scen_suffix # + "_v" + str(scen_vers)
66+
67+
mp = ixmp.Platform("ixmp_dev")
68+
s_orig = message_ix.Scenario(
69+
mp, model=model_orig, scenario=scenario_orig, version=svers[sel_scen]
70+
)
71+
s_tar = s_orig.clone(model_target, scenario_target, keep_solution=False)
72+
s_tar.set_as_default()
73+
74+
75+
# modify bounds for some fuels in residential and commercial sector
76+
modify_rc_bounds(s_orig, s_tar, rc_years)
77+
78+
# add UE share constraints to transport
79+
add_UE_share_constraints(
80+
s_tar, # scenario object
81+
path_UE_share_input=path_ue_file, # path
82+
ssp=sel_scen, # SSP-name i.e "LED"
83+
start_year=trp_year_start, # the year as of which a constraint should be added
84+
calibration_year=2020, # 2020
85+
clean_relations=False, # set to False
86+
verbose=True, # set to True
87+
)
88+
89+
# modify tax/price emissions
90+
modify_tax_emission(s_orig, s_tar, mult_price)
91+
92+
# modify steel sector
93+
if rem_bof_steel:
94+
remove_bof_steel_lower(s_tar, steel_years)
95+
96+
if mod_growth_steel:
97+
modify_steel_growth(
98+
s_tar,
99+
["dri_gas_steel", "dri_h2_steel", "eaf_steel"],
100+
steel_years,
101+
steel_growth,
102+
)
103+
104+
if mod_initial_steel:
105+
modify_steel_initial(
106+
s_tar,
107+
["dri_gas_steel", "dri_h2_steel"],
108+
steel_years,
109+
steel_inital,
110+
)
111+
112+
if add_steel_target:
113+
add_steel_sector_nze(s_tar, nze_targets)
114+
115+
# add balance equality
116+
add_balance_equality(s_tar)
117+
118+
# solve parameters
119+
# message_ix.models.DEFAULT_CPLEX_OPTIONS = {
120+
# "advind": 0,
121+
# "lpmethod": 4,
122+
# "threads": 4,
123+
# "epopt": 1e-6,
124+
# "scaind": -1,
125+
# }
126+
127+
solve_typ = "MESSAGE-MACRO"
128+
solve_args = dict(model=solve_typ)
129+
s_tar.solve(**solve_args)
130+
s_tar.set_as_default()
131+
132+
mp.close_db()

0 commit comments

Comments
 (0)