Skip to content

Commit d09b435

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

File tree

1 file changed

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

1 file changed

+106
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
import ixmp # type: ignore
2+
import message_ix # type: ignore
3+
4+
from message_ix_models.project.ssp.script.util.functions import (
5+
add_balance_equality,
6+
add_steel_sector_nze,
7+
modify_steel_growth,
8+
modify_steel_initial,
9+
remove_bof_steel_lower,
10+
)
11+
12+
# path_ue = "/Users/meas/iiasagit/scenariomip-review/scenariomip_review/data/ue-shares"
13+
path_ue = "/home/mengm/repo/scenariomip-review/scenariomip_review/data/ue-shares"
14+
15+
# selections
16+
sel_scen = "SSP1"
17+
scen_suffix = ""
18+
# scen_vers = 1
19+
rem_bof_steel = True
20+
mod_growth_steel = True
21+
mod_initial_steel = True
22+
add_steel_target = False
23+
24+
# parameters
25+
trp_year_start = 2035
26+
mult_price = 5.5
27+
rc_years = [2060, 2070, 2080, 2090, 2100, 2110]
28+
steel_years = [2030, 2035, 2040, 2045, 2050, 2055, 2060, 2070, 2080, 2090, 2100, 2110]
29+
steel_growth = 0.075
30+
steel_inital = 1.0
31+
nze_targets = [
32+
4.2,
33+
3.7,
34+
3.2,
35+
2.7,
36+
]
37+
38+
# model and scenario names
39+
snames = {"SSP1": "SSP1 - Low Emissions", "SSP2": "SSP2 - Low Emissions"}
40+
svers = {"SSP1": 1, "SSP2": 1}
41+
model_orig = "SSP_" + sel_scen + "_v1.0"
42+
scenario_orig = snames[sel_scen]
43+
44+
# add scen_suffic depending on remove_bof_steel, modify_lc_steel,
45+
# steel_scalar, and add_steel_target
46+
if rem_bof_steel:
47+
scen_suffix += "_bof"
48+
if mod_growth_steel:
49+
scen_suffix += "_growth" # + str(steel_growth)
50+
if mod_initial_steel:
51+
scen_suffix += "_initial" # + str(steel_inital)
52+
if add_steel_target:
53+
scen_suffix += "_nzsteel"
54+
55+
model_target = "MM_ScenarioMIP"
56+
scenario_target = "Low_" + sel_scen + scen_suffix # + "_v" + str(scen_vers)
57+
58+
mp = ixmp.Platform("ixmp_dev")
59+
s_orig = message_ix.Scenario(
60+
mp, model=model_orig, scenario=scenario_orig, version=svers[sel_scen]
61+
)
62+
s_tar = s_orig.clone(model_target, scenario_target, keep_solution=False)
63+
s_tar.set_as_default()
64+
65+
66+
# modify steel sector
67+
if rem_bof_steel:
68+
remove_bof_steel_lower(s_tar, steel_years)
69+
70+
if mod_growth_steel:
71+
modify_steel_growth(
72+
s_tar,
73+
["dri_gas_steel", "dri_h2_steel", "eaf_steel"],
74+
steel_years,
75+
steel_growth,
76+
)
77+
78+
if mod_initial_steel:
79+
modify_steel_initial(
80+
s_tar,
81+
["dri_gas_steel", "dri_h2_steel"],
82+
steel_years,
83+
steel_inital,
84+
)
85+
86+
if add_steel_target:
87+
add_steel_sector_nze(s_tar, nze_targets)
88+
89+
# add balance equality
90+
add_balance_equality(s_tar)
91+
92+
# solve parameters
93+
# message_ix.models.DEFAULT_CPLEX_OPTIONS = {
94+
# "advind": 0,
95+
# "lpmethod": 4,
96+
# "threads": 4,
97+
# "epopt": 1e-6,
98+
# "scaind": -1,
99+
# }
100+
101+
solve_typ = "MESSAGE-MACRO"
102+
solve_args = dict(model=solve_typ)
103+
s_tar.solve(**solve_args)
104+
s_tar.set_as_default()
105+
106+
mp.close_db()

0 commit comments

Comments
 (0)