Skip to content

Commit

Permalink
Fix 2025 material demands for all SSPs
Browse files Browse the repository at this point in the history
  • Loading branch information
macflo8 authored and khaeru committed Nov 26, 2024
1 parent 2fc2588 commit 123ceec
Show file tree
Hide file tree
Showing 12 changed files with 124 additions and 13 deletions.
13 changes: 13 additions & 0 deletions message_ix_models/data/material/aluminum/demand_2025.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
node,commodity,level,year,time,value,unit
R12_AFR,cement,demand,2025,year,140.2425571595793,t
R12_EEU,cement,demand,2025,year,43.839280097299145,t
R12_FSU,cement,demand,2025,year,108.45888265422545,t
R12_LAM,cement,demand,2025,year,200.83402436976078,t
R12_MEA,cement,demand,2025,year,323.46591566959586,t
R12_NAM,cement,demand,2025,year,119.67969767150731,t
R12_PAO,cement,demand,2025,year,53.48376239064636,t
R12_PAS,cement,demand,2025,year,250.72079017745176,t
R12_SAS,cement,demand,2025,year,488.5888605832439,t
R12_WEU,cement,demand,2025,year,210.9156287414474,t
R12_CHN,cement,demand,2025,year,2165.810003963428,t
R12_RCPA,cement,demand,2025,year,106.38144508300388,t
13 changes: 13 additions & 0 deletions message_ix_models/data/material/ammonia/demand_2025.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
node,commodity,level,year,time,value,unit
R12_AFR,NH3,final_material,2025,year,2.655826840613548,t
R12_CHN,NH3,final_material,2025,year,19.509765755986678,t
R12_EEU,NH3,final_material,2025,year,4.213433572242334,t
R12_FSU,NH3,final_material,2025,year,7.204624589619355,t
R12_LAM,NH3,final_material,2025,year,2.6443630084868754,t
R12_MEA,NH3,final_material,2025,year,2.6463332649010893,t
R12_NAM,NH3,final_material,2025,year,7.291628222808803,t
R12_PAO,NH3,final_material,2025,year,2.5658865183830537,t
R12_PAS,NH3,final_material,2025,year,2.661091686760797,t
R12_RCPA,NH3,final_material,2025,year,2.72594836078395,t
R12_SAS,NH3,final_material,2025,year,7.755776900489005,t
R12_WEU,NH3,final_material,2025,year,5.855896480835045,t
13 changes: 13 additions & 0 deletions message_ix_models/data/material/cement/demand_2025.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
node,commodity,level,year,time,value,unit
R12_AFR,cement,demand,2025,year,140.2425571595793,t
R12_EEU,cement,demand,2025,year,43.839280097299145,t
R12_FSU,cement,demand,2025,year,108.45888265422545,t
R12_LAM,cement,demand,2025,year,200.83402436976078,t
R12_MEA,cement,demand,2025,year,323.46591566959586,t
R12_NAM,cement,demand,2025,year,119.67969767150731,t
R12_PAO,cement,demand,2025,year,53.48376239064636,t
R12_PAS,cement,demand,2025,year,250.72079017745176,t
R12_SAS,cement,demand,2025,year,488.5888605832439,t
R12_WEU,cement,demand,2025,year,210.9156287414474,t
R12_CHN,cement,demand,2025,year,2165.810003963428,t
R12_RCPA,cement,demand,2025,year,106.38144508300388,t
13 changes: 13 additions & 0 deletions message_ix_models/data/material/methanol/demand_2025.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
node,commodity,level,year,time,value,unit
R12_AFR,methanol,demand,2025,year,0.6437125259225385,t
R12_CHN,methanol,demand,2025,year,83.4398718653732,t
R12_EEU,methanol,demand,2025,year,1.8738267356744767,t
R12_FSU,methanol,demand,2025,year,3.439439876055323,t
R12_LAM,methanol,demand,2025,year,3.169745811139945,t
R12_MEA,methanol,demand,2025,year,3.8137629836445663,t
R12_NAM,methanol,demand,2025,year,10.194960935440516,t
R12_PAO,methanol,demand,2025,year,2.26845340595827,t
R12_PAS,methanol,demand,2025,year,9.722946298369182,t
R12_RCPA,methanol,demand,2025,year,0.7034326872676644,t
R12_SAS,methanol,demand,2025,year,4.4452928433924335,t
R12_WEU,methanol,demand,2025,year,9.124409617262367,t
13 changes: 13 additions & 0 deletions message_ix_models/data/material/petrochemicals/demand_2025.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
node,commodity,level,year,time,value,unit
R12_AFR,HVC,demand,2025,year,2.7739844174725152,t
R12_CHN,HVC,demand,2025,year,61.08932926073989,t
R12_EEU,HVC,demand,2025,year,3.400187947954376,t
R12_FSU,HVC,demand,2025,year,5.3654010528917055,t
R12_LAM,HVC,demand,2025,year,12.58799309335563,t
R12_MEA,HVC,demand,2025,year,46.1972305755139,t
R12_NAM,HVC,demand,2025,year,54.98681624852799,t
R12_PAO,HVC,demand,2025,year,11.724751702213592,t
R12_PAS,HVC,demand,2025,year,43.54093825352989,t
R12_RCPA,HVC,demand,2025,year,0.5394172787449382,t
R12_SAS,HVC,demand,2025,year,13.58814744115441,t
R12_WEU,HVC,demand,2025,year,32.53579341088541,t
13 changes: 13 additions & 0 deletions message_ix_models/data/material/steel/demand_2025.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
node,commodity,level,year,time,value,unit
R12_AFR,cement,demand,2025,year,140.2425571595793,t
R12_EEU,cement,demand,2025,year,43.839280097299145,t
R12_FSU,cement,demand,2025,year,108.45888265422545,t
R12_LAM,cement,demand,2025,year,200.83402436976078,t
R12_MEA,cement,demand,2025,year,323.46591566959586,t
R12_NAM,cement,demand,2025,year,119.67969767150731,t
R12_PAO,cement,demand,2025,year,53.48376239064636,t
R12_PAS,cement,demand,2025,year,250.72079017745176,t
R12_SAS,cement,demand,2025,year,488.5888605832439,t
R12_WEU,cement,demand,2025,year,210.9156287414474,t
R12_CHN,cement,demand,2025,year,2165.810003963428,t
R12_RCPA,cement,demand,2025,year,106.38144508300388,t
6 changes: 5 additions & 1 deletion message_ix_models/model/material/data_aluminum.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def gen_data_alu_ts(data: pd.DataFrame, nodes: list) -> dict[str, pd.DataFrame]:
Returns
-------
pd.DataFrame
dict[str, pd.DataFrame]
key-value pairs of parameter names and parameter data
"""
tec_ts = set(data.technology) # set of tecs in timeseries sheet
Expand Down Expand Up @@ -455,10 +455,14 @@ def gen_data_aluminum(

parname = "demand"
demand_dict = {}
df_2025 = pd.read_csv(package_data_path("material", "aluminum", "demand_2025.csv"))
df = material_demand_calc.derive_demand("aluminum", scenario, ssp=ssp)
df = df[df["year"] != 2025]
df = pd.concat([df_2025, df])
demand_dict[parname] = df

ts_dict = gen_data_alu_ts(data_aluminum_ts, nodes)
ts_dict.update(gen_hist_new_cap())
rel_dict = gen_data_alu_rel(data_aluminum_rel, modelyears)
trade_dict = gen_data_alu_trade(scenario)

Expand Down
5 changes: 5 additions & 0 deletions message_ix_models/model/material/data_ammonia_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,9 +540,14 @@ def gen_resid_demand_NH3(scenario: message_ix.Scenario) -> dict[str, pd.DataFram
default_gdp_elasticity_2020, default_gdp_elasticity_2030 = iea_elasticity_map[
ssp_mode_map[ssp]
]
df_2025 = pd.read_csv(
package_data_path("material", "ammonia", "demand_2025.csv")
)
df_residual = material_demand_calc.gen_demand_petro(
scenario, "NH3", default_gdp_elasticity_2020, default_gdp_elasticity_2030
)
df_residual = df_residual[df_residual["year"] != 2025]
df_residual = pd.concat([df_2025, df_residual])

return {"demand": df_residual}

Expand Down
5 changes: 5 additions & 0 deletions message_ix_models/model/material/data_cement.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,12 @@ def gen_data_cement(

# Create external demand param
parname = "demand"
df_2025 = pd.read_csv(
package_data_path("material", "cement", "demand_2025.csv")
)
df_demand = material_demand_calc.derive_demand("cement", scenario, ssp=ssp)
df_demand = df_demand[df_demand["year"] != 2025]
df_demand = pd.concat([df_2025, df_demand])
results[parname].append(df_demand)

# Add CCS as addon
Expand Down
29 changes: 19 additions & 10 deletions message_ix_models/model/material/data_methanol.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
from ast import literal_eval
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Dict

import pandas as pd
import yaml
from message_ix import make_df

import message_ix_models.util
from message_ix_models import ScenarioInfo
from message_ix_models.model.material.data_util import (
gen_chemicals_co2_ind_factors,
gen_plastics_emission_factors,
)
from message_ix_models.model.material.material_demand import material_demand_calc
from message_ix_models.model.material.util import combine_df_dictionaries, read_config
from message_ix_models.util import broadcast, nodes_ex_world, same_node
from message_ix_models.util import (
broadcast,
nodes_ex_world,
package_data_path,
same_node,
)

if TYPE_CHECKING:
from message_ix import Scenario
Expand Down Expand Up @@ -45,7 +49,7 @@ def gen_data_methanol(scenario: "Scenario") -> dict[str, pd.DataFrame]:
"""
context = read_config()
df_pars = pd.read_excel(
message_ix_models.util.package_data_path(
package_data_path(
"material", "methanol", "methanol_sensitivity_pars.xlsx"
),
sheet_name="Sheet1",
Expand All @@ -54,15 +58,15 @@ def gen_data_methanol(scenario: "Scenario") -> dict[str, pd.DataFrame]:
pars = df_pars.set_index("par").to_dict()["value"]
if pars["mtbe_scenario"] == "phase-out":
pars_dict = pd.read_excel(
message_ix_models.util.package_data_path(
package_data_path(
"material", "methanol", "methanol_techno_economic.xlsx"
),
sheet_name=None,
dtype=object,
)
else:
pars_dict = pd.read_excel(
message_ix_models.util.package_data_path(
package_data_path(
"material", "methanol", "methanol_techno_economic_high_demand.xlsx"
),
sheet_name=None,
Expand All @@ -73,7 +77,7 @@ def gen_data_methanol(scenario: "Scenario") -> dict[str, pd.DataFrame]:
pars_dict[i] = unpivot_input_data(pars_dict[i], i)
# TODO: only temporary hack to ensure SSP_dev compatibility
if "SSP_dev" in scenario.model:
file_path = message_ix_models.util.package_data_path(
file_path = package_data_path(
"material", "methanol", "missing_rels.yaml"
)

Expand All @@ -85,13 +89,18 @@ def gen_data_methanol(scenario: "Scenario") -> dict[str, pd.DataFrame]:
default_gdp_elasticity_2020, default_gdp_elasticity_2030 = iea_elasticity_map[
ssp_mode_map[context["ssp"]]
]
df_final = material_demand_calc.gen_demand_petro(
df_2025 = pd.read_csv(
package_data_path("material", "methanol", "demand_2025.csv")
)
df_demand = material_demand_calc.gen_demand_petro(
scenario, "methanol", default_gdp_elasticity_2020, default_gdp_elasticity_2030
)
df_final["value"] = df_final["value"].apply(
df_demand["value"] = df_demand["value"].apply(
lambda x: x * pars["methanol_resid_demand_share"]
)
pars_dict["demand"] = df_final
df_demand = df_demand[df_demand["year"] != 2025]
df_demand = pd.concat([df_2025, df_demand])
pars_dict["demand"] = df_demand

s_info = ScenarioInfo(scenario)
downstream_tec_pars = gen_meth_fs_downstream(s_info)
Expand Down
9 changes: 7 additions & 2 deletions message_ix_models/model/material/data_petro.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,10 +483,15 @@ def gen_data_petro_chemicals(
default_gdp_elasticity_2020, default_gdp_elasticity_2030 = iea_elasticity_map[
ssp_mode_map[ssp]
]
demand_hvc = material_demand_calc.gen_demand_petro(
df_demand = material_demand_calc.gen_demand_petro(
scenario, "HVC", default_gdp_elasticity_2020, default_gdp_elasticity_2030
)
results["demand"].append(demand_hvc)
df_2025 = pd.read_csv(
package_data_path("material", "petrochemicals", "demand_2025.csv")
)
df_demand = df_demand[df_demand["year"] != 2025]
df_demand = pd.concat([df_2025, df_demand])
results["demand"].append(df_demand)

# Special treatment for time-varying params
tec_ts = set(data_petro_ts.technology) # set of tecs in timeseries sheet
Expand Down
5 changes: 5 additions & 0 deletions message_ix_models/model/material/data_steel.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,12 @@ def gen_data_steel(scenario: message_ix.Scenario, dry_run: bool = False):

# Create external demand param
parname = "demand"
df_2025 = pd.read_csv(
package_data_path("material", "steel", "demand_2025.csv")
)
df_demand = material_demand_calc.derive_demand("steel", scenario, ssp=ssp)
df_demand = df_demand[df_demand["year"] != 2025]
df_demand = pd.concat([df_2025, df_demand])
results[parname].append(df_demand)

common = dict(
Expand Down

0 comments on commit 123ceec

Please sign in to comment.