iiasa / message_ix

The integrated assessment and energy systems model MESSAGEix
https://docs.messageix.org
Apache License 2.0
111 stars 149 forks source link

How to clone two single-node models into multiple nodes without success #817

Closed meng25meng closed 3 months ago

meng25meng commented 3 months ago

I want to set up power transmission of two single-node model provinces through one-way transmission, according to the second method in the tutorial, but at the beginning, it is difficult to clone the single-node model, and it is always impossible to read the two models. My nodes do not want to create new ones, which are all from the single-node model. So far cloning has been unsuccessful.

import pandas as pd
from itertools import product
import ixmp
import message_ix

from message_ix.util import make_df

%matplotlib inline
# Loading the modeling platform
mp = ixmp.Platform()
model1 = "Anhui energy model"
scenario1 = "baseline2"
base = message_ix.Scenario(mp, model1, scenario1)
model2 = "Xinjiang energy model"
scenario2= "baselinexinjiang_0.05"
base = message_ix.Scenario(mp, model2, scenario2)
base.has_solution()
new_scenario = "multinode"
scen = base.clone(scenario=new_scenario, keep_solution=False)
scen = base.clone(scenario=new_scenario, keep_solution=False)
# Checking out the scenario for editing
scen.check_out()
scen.set("node")
0       World
1    Xinjiang
dtype: object**
glatterf42 commented 3 months ago

Hi @meng25meng, thanks for your question. In your code snippet, you define a variable base as a message_ix.Scenario with model "Anhui energy model" and scenario "baseline2", but then you re-define the variable base as a message_ix.Scenario with model "Xinjiang energy model" and scenario "baselinexinjiang_0.05". If you want to load both Scenarios at the same time, you will need to use different variables for that.

However, I'm not sure this is what you want to do. Please correct me if I'm wrong, but to me it sounds like you want to have a single Scenario with two nodes in it that should be connected via power/energy trade/transmission. If this interpretation is correct, you don't need to define two Scenarios, you just need to add both nodes (or regions) to one Scenario. Please see step 1.1 of this tutorial to learn how to do this.

Please note: I think this is a question about how to use message_ix more than it is an issue with the code. So I will convert this to a discussion.