How could I reflect 'commodity' set in the 'emission_factor' parameter? (for specific model) #750
-
Hi, I'm currently building an Industry sector model in korea using MESSAGEix. It's more specific model than global model, as a result, many of the technologies have multi inputs. ex) kiln tec has various input such as "raw_material, coalB, biomass, waste, elec, .... ". but output is only 'clinker' but some sets('var_cost' or 'emission_factor', ....) don't have 'commodity' set in their code. I would like to reflect a 'commodity' set in these parameters. and, To revise GAMS code is not to difficult. 'cuz I know how use it. Although revising the GAMS code is not difficult for me, as I know how to use it, I found that even after adding a 'commodity' in the 'emission_factor' parameter, the python code did not reflect this change. Here's what I did:
I suspect that this may be a Python issue. Thank you for your time, and I look forward to hearing back from you soon. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Hi @MESSAGEix-SK-Woo, thanks for your question! I think there is a fundamental misunderstanding here: message_ix uses ixmp in the background, with which you can connect to a database (via the import pandas as pd
import ixmp
import message_ix
mp = ixmp.Platform()
scenario = message_ix.Scenario(
mp, model="Westeros Electrified", scenario="baseline", version="new"
) you can add parameters to the scenario like this: # Define the time frame of the model
history = [690]
model_horizon = [700, 710, 720]
scenario.add_horizon(year=history + model_horizon, firstmodelyear=model_horizon[0])
# Define the locations of the model
country = "Westeros"
scenario.add_spatial_sets({"country": country})
# Define possible values of some categories used to define parameters
scenario.add_set("commodity", ["electricity", "light"])
scenario.add_set("level", ["secondary", "final", "useful"])
# Assume a GDP profile
gdp_profile = pd.Series([1.0, 1.5, 1.9], index=pd.Index(model_horizon, name="Time"))
# Estimate baseline demand
demand_per_year = 40 * 12 * 1000 / 8760
light_demand = pd.DataFrame(
{
"node": country,
"commodity": "light",
"level": "useful",
"year": model_horizon,
"time": "year",
"value": (demand_per_year * gdp_profile).round(),
"unit": "GWa",
}
)
# Use `add_par` for adding data to a MESSAGEix parameter
scenario.add_par("demand", light_demand) The interesting part is that you can use |
Beta Was this translation helpful? Give feedback.
-
Hi @MESSAGEix-SK-Woo — First, I've converted the "issue" you opened to a "discussion" in the "MESSAGEix modeling" section. This is the appropriate place for Q&A related to your individual modeling efforts, especially since there is no particular bug in the code per se. Second, directly to your question, there is indeed a place in the Python code where the dimensionality of each parameter is recorded, particularly here: message_ix/message_ix/models.py Line 176 in 248bcbd emission_factor is used; not merely its definition.) You haven't shared your modified GAMS code, so I can't provide more specific guidance than that.
Third, however, I question whether you have understood the existing features of the model. Maybe if you use these fully, it is not necessary at all to expand the dimensionality of In particular, emissions are computed as: With the full dimensions of this parameter and variable: For simplicity, let's consider only one technology (your This means for every 1 unit of Now this technology would also have a corresponding input efficiency: What this means is that, for every 1 unit of As you say, it's possible for it to have multiple inputs by setting distinct values for various For an example, let's suppose that in a particular mode ( This value will always be valid given the corresponding Please let me know if this explanation is unclear. It doesn't appear so from your original question, but please be more specific if there is something else in particular you are trying to achieve, and you think that the features as described are not sufficient to model it. |
Beta Was this translation helpful? Give feedback.
Hi @MESSAGEix-SK-Woo —
First, I've converted the "issue" you opened to a "discussion" in the "MESSAGEix modeling" section. This is the appropriate place for Q&A related to your individual modeling efforts, especially since there is no particular bug in the code per se.
Second, directly to your question, there is indeed a place in the Python code where the dimensionality of each parameter is recorded, particularly here:
message_ix/message_ix/models.py
Line 176 in 248bcbd