Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a working trade model #572

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/muse/agents/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def create_newcapa_agent(
capacity = capacity.sel(region=region)

existing = capacity.interp(year=year, method=interpolation) > 0
assert set(existing.dims) == {"asset"}
# assert set(existing.dims) == {"asset"}
years = [capacity.year.min().values, capacity.year.max().values]

assets = xr.Dataset()
Expand Down
78 changes: 39 additions & 39 deletions src/muse/data/example/trade/input/Projections.csv
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
RegionName,Attribute,Time,electricity,gas,heat,CO2f,wind
Unit,-,Year,MUS$2010/PJ,MUS$2010/PJ,MUS$2010/PJ,MUS$2010/kt,MUS$2010/PJ
R1,CommodityPrice,2010,12.61111111,3.8972,0,0,0
R1,CommodityPrice,2015,13.14814806,4.307,0,0,0
R1,CommodityPrice,2020,13.98148139,4.7168,0,0,0
R1,CommodityPrice,2025,16.27777778,5.1266,0,0,0
R1,CommodityPrice,2030,17.1574075,5.5364,0,0,0
R1,CommodityPrice,2035,17.50925917,5.9462,0,0,0
R1,CommodityPrice,2040,18.05555556,6.3559,0,0,0
R1,CommodityPrice,2045,20.37962972,6.7657,0,0,0
R1,CommodityPrice,2050,21.5,7.1755,0,0,0
R1,CommodityPrice,2055,22.12037028,7.1755,0,0,0
R1,CommodityPrice,2060,22.00925917,7.1755,0,0,0
R1,CommodityPrice,2065,22.14814806,7.1755,0,0,0
R1,CommodityPrice,2070,22,7.1755,0,0,0
R1,CommodityPrice,2075,22.11111111,7.1755,0,0,0
R1,CommodityPrice,2080,21.92592583,7.1755,0,0,0
R1,CommodityPrice,2085,21.51851861,7.1755,0,0,0
R1,CommodityPrice,2090,21.31481472,7.1755,0,0,0
R1,CommodityPrice,2095,21.03703694,7.1755,0,0,0
R1,CommodityPrice,2100,20.46296306,7.1755,0,0,0
R2,CommodityPrice,2010,17.33333333,3.8972,0,0,0
R2,CommodityPrice,2015,15.66666667,4.307,0,0,0
R2,CommodityPrice,2020,19.13888889,4.7168,0,0,0
R2,CommodityPrice,2025,22.86111111,5.1266,0,0,0
R2,CommodityPrice,2030,24.08333333,5.5364,0,0,0
R2,CommodityPrice,2035,20.63888889,5.9462,0,0,0
R2,CommodityPrice,2040,21.32407417,6.3559,0,0,0
R2,CommodityPrice,2045,20.38888889,6.7657,0,0,0
R2,CommodityPrice,2050,19.37037028,7.1755,0,0,0
R2,CommodityPrice,2055,19.13888889,7.1755,0,0,0
R2,CommodityPrice,2060,21.0925925,7.1755,0,0,0
R2,CommodityPrice,2065,22.89814806,7.1755,0,0,0
R2,CommodityPrice,2070,22.94444444,7.1755,0,0,0
R2,CommodityPrice,2075,21.60185194,7.1755,0,0,0
R2,CommodityPrice,2080,21.93518528,7.1755,0,0,0
R2,CommodityPrice,2085,21.87962972,7.1755,0,0,0
R2,CommodityPrice,2090,22.06481472,7.1755,0,0,0
R2,CommodityPrice,2095,23.08333333,7.1755,0,0,0
R2,CommodityPrice,2100,23.82407417,7.1755,0,0,0
Unit,-,Year,MUS$2010/PJ,MUS$2010/PJ,MUS$2010/PJ,MUS$2010/kt,MUS$2010/kt
R1,CommodityPrice,2010,14.81481472,6.6759,100,0,0
R1,CommodityPrice,2015,17.89814806,6.914325,100,0.052913851,0
R1,CommodityPrice,2020,19.5,7.15275,100,0.08314119,0
R1,CommodityPrice,2025,21.93518528,8.10645,100,0.120069795,0
R1,CommodityPrice,2030,26.50925917,9.06015,100,0.156998399,0
R1,CommodityPrice,2035,26.51851861,9.2191,100,0.214877567,0
R1,CommodityPrice,2040,23.85185194,9.37805,100,0.272756734,0
R1,CommodityPrice,2045,23.97222222,9.193829337,100,0.35394801,0
R1,CommodityPrice,2050,24.06481472,9.009608674,100,0.435139285,0
R1,CommodityPrice,2055,25.3425925,8.832625604,100,0.542365578,0
R1,CommodityPrice,2060,25.53703694,8.655642534,100,0.649591871,0
R1,CommodityPrice,2065,25.32407417,8.485612708,100,0.780892624,0
R1,CommodityPrice,2070,23.36111111,8.315582883,100,0.912193378,0
R1,CommodityPrice,2075,22.27777778,8.152233126,100,1.078321687,0
R1,CommodityPrice,2080,22.25925917,7.988883368,100,1.244449995,0
R1,CommodityPrice,2085,22.17592583,7.831951236,100,1.4253503,0
R1,CommodityPrice,2090,22.03703694,7.675019103,100,1.606250604,0
R1,CommodityPrice,2095,21.94444444,7.524252461,100,1.73877515,0
R1,CommodityPrice,2100,21.39814806,7.373485819,100,1.871299697,0
R2,CommodityPrice,2010,14.81481472,6.6759,100,0,0
R2,CommodityPrice,2015,17.89814806,6.914325,100,0.052913851,0
R2,CommodityPrice,2020,19.5,7.15275,100,0.08314119,0
R2,CommodityPrice,2025,21.93518528,8.10645,100,0.120069795,0
R2,CommodityPrice,2030,26.50925917,9.06015,100,0.156998399,0
R2,CommodityPrice,2035,26.51851861,9.2191,100,0.214877567,0
R2,CommodityPrice,2040,23.85185194,9.37805,100,0.272756734,0
R2,CommodityPrice,2045,23.97222222,9.193829337,100,0.35394801,0
R2,CommodityPrice,2050,24.06481472,9.009608674,100,0.435139285,0
R2,CommodityPrice,2055,25.3425925,8.832625604,100,0.542365578,0
R2,CommodityPrice,2060,25.53703694,8.655642534,100,0.649591871,0
R2,CommodityPrice,2065,25.32407417,8.485612708,100,0.780892624,0
R2,CommodityPrice,2070,23.36111111,8.315582883,100,0.912193378,0
R2,CommodityPrice,2075,22.27777778,8.152233126,100,1.078321687,0
R2,CommodityPrice,2080,22.25925917,7.988883368,100,1.244449995,0
R2,CommodityPrice,2085,22.17592583,7.831951236,100,1.4253503,0
R2,CommodityPrice,2090,22.03703694,7.675019103,100,1.606250604,0
R2,CommodityPrice,2095,21.94444444,7.524252461,100,1.73877515,0
R2,CommodityPrice,2100,21.39814806,7.373485819,100,1.871299697,0
76 changes: 23 additions & 53 deletions src/muse/data/example/trade/settings.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Global settings - most REQUIRED

time_framework = [2020, 2025, 2030, 2035]
time_framework = [2020, 2025, 2030, 2035, 2040, 2045, 2050]
foresight = 5 # Has to be a multiple of the minimum separation between the years in time framework
regions = ["R1", "R2"]
interest_rate = 0.1
Expand Down Expand Up @@ -30,25 +30,18 @@ budget = []
projections = '{path}/input/Projections.csv'
global_commodities = '{path}/input/GlobalCommodities.csv'

[sectors.presets]
type = 'presets'
priority = 0
consumption_path = "{path}/technodata/preset/*Consumption.csv"

[sectors.residential]
type = 'default'
priority = 1
dispatch_production = 'share'

[sectors.residential.technodata]
technodata = '{path}/technodata/residential/Technodata.csv'
commodities_in = '{path}/technodata/residential/CommIn.csv'
commodities_out = '{path}/technodata/residential/CommOut.csv'

[sectors.residential.subsectors.retro_and_new]
agents = '{path}/technodata/residential/Agents.csv'
[sectors.residential.subsectors.all]
agents = '{path}/technodata/Agents.csv'
existing_capacity = '{path}/technodata/residential/ExistingCapacity.csv'
lpsolver = "scipy"
lpsolver = "scipy" # Optional, defaults to "adhoc"
constraints = [
# Optional, defaults to the constraints below
"max_production",
Expand All @@ -58,41 +51,22 @@ constraints = [
"minimum_service",
"demand_limiting_capacity"
]
demand_share = "new_and_retro"
forecast = 5
asset_threshold = 1e-4

[[sectors.residential.interactions]]
net = 'new_to_retro'
interaction = 'transfer'
demand_share = "standard_demand" # Optional, default to standard_demand
forecast = 5 # Optional, defaults to 5

[sectors.power]
type = 'default'
priority = 2
dispatch_production = 'share'

[sectors.power.technodata]
technodata = '{path}/technodata/power/Technodata.csv'
trade = '{path}/technodata/power/TradeTechnodata.csv'
commodities_in = '{path}/technodata/power/CommIn.csv'
commodities_out = '{path}/technodata/power/CommOut.csv'

[sectors.power.subsectors.trade]
[sectors.power.subsectors.all]
agents = '{path}/technodata/Agents.csv'
existing_capacity = '{path}/technodata/power/ExistingTrade.csv'
existing_capacity = '{path}/technodata/power/ExistingCapacity.csv'
lpsolver = "scipy"
constraints = [
# Optional, defaults to the constraints below
"max_production",
"max_capacity_expansion",
"demand",
"search_space",
"minimum_service",
"demand_limiting_capacity"
]
demand_share = "unmet_forecasted_demand"
forecast = 5
asset_threshold = 1e-4
demand_share = "standard_demand"

[sectors.gas]
type = 'default'
Expand All @@ -106,27 +80,23 @@ commodities_in = '{path}/technodata/gas/CommIn.csv'
commodities_out = '{path}/technodata/gas/CommOut.csv'

[sectors.gas.subsectors.trade]
agents = '{path}/technodata/Agents.csv'
agents = '{path}/technodata/gas/Agents.csv'
existing_capacity = '{path}/technodata/gas/ExistingTrade.csv'
lpsolver = "scipy"
constraints = [
# Optional, defaults to the constraints below
"max_production",
"max_capacity_expansion",
"demand",
"search_space",
"minimum_service",
"demand_limiting_capacity"
]
demand_share = "unmet_forecasted_demand"
forecast = 5
asset_threshold = 1e-4

[sectors.residential_presets]
type = 'presets'
priority = 0
consumption_path = "{path}/technodata/preset/*Consumption.csv"

[timeslices]
level_names = ["month", "day", "hour"]
all-year.all-week.night = 1460
all-year.all-week.morning = 1460
all-year.all-week.afternoon = 1460
all-year.all-week.early-peak = 1460
all-year.all-week.late-peak = 1460
all-year.all-week.evening = 1460

[timeslices.all-year.all-week]
night = 1460
morning = 1460
afternoon = 1460
early-peak = 1460
late-peak = 1460
evening = 1460
6 changes: 3 additions & 3 deletions src/muse/data/example/trade/technodata/Agents.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
AgentShare,Name,RegionName,Objective,ObjData,Objsort,SearchRule,DecisionMethod,MaturityThreshold,SpendLimit,Type
Agent1,A1,R1,ALCOE,1,TRUE,from_assets->compress->reduce_assets,singleObj,-1,inf,default
Agent1,A1,R2,ALCOE,1,TRUE,from_assets->compress->reduce_assets,singleObj,-1,inf,default
AgentShare,Name,RegionName,Objective1,Objective2,Objective3,ObjData1,ObjData2,ObjData3,Objsort1,Objsort2,Objsort3,SearchRule,DecisionMethod,Quantity,MaturityThreshold,SpendLimit,Type
Agent1,A1,R1,LCOE,,,1,,,True,,,all,singleObj,1,-1,inf,New
Agent1,A1,R2,LCOE,,,1,,,True,,,all,singleObj,1,-1,inf,New
3 changes: 3 additions & 0 deletions src/muse/data/example/trade/technodata/gas/Agents.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
AgentShare,Name,RegionName,Objective1,Objective2,Objective3,ObjData1,ObjData2,ObjData3,Objsort1,Objsort2,Objsort3,SearchRule,DecisionMethod,MaturityThreshold,SpendLimit,Type
Agent1,A1,R1,ALCOE,,,1,,,True,,,from_assets->compress->reduce_assets,singleObj,-1,inf,New
Agent1,A1,R2,ALCOE,,,1,,,True,,,from_assets->compress->reduce_assets,singleObj,-1,inf,New
4 changes: 2 additions & 2 deletions src/muse/data/example/trade/technodata/gas/CommIn.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ProcessName,RegionName,Time,Level,electricity,gas,heat,CO2f,wind
Unit,-,Year,-,PJ/PJ,PJ/PJ,PJ/PJ,kt/PJ,PJ/PJ
gassupply1,R1,2010,fixed,0,1,0,0,0
gassupply1,R2,2010,fixed,0,1,0,0,0
gassupply1,R1,2020,fixed,0,0,0,0,0
gassupply1,R2,2020,fixed,0,0,0,0,0
4 changes: 2 additions & 2 deletions src/muse/data/example/trade/technodata/gas/CommOut.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ProcessName,RegionName,Time,electricity,gas,heat,CO2f,wind
Unit,-,Year,PJ/PJ,PJ/PJ,PJ/PJ,kt/PJ,PJ/PJ
gassupply1,R1,2010,0,1,0,0,0
gassupply1,R2,2010,0,1,0,0,0
gassupply1,R1,2020,0,1,0,0,0
gassupply1,R2,2020,0,1,0,0,0
23 changes: 13 additions & 10 deletions src/muse/data/example/trade/technodata/gas/ExistingTrade.csv
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
ProcessName,RegionName,Time,R1,R2
Unit,-,Year,PJ/y,PJ/y
gassupply1,R1,2010,3000,0
gassupply1,R1,2020,3000,0
gassupply1,R1,2030,2100,0
gassupply1,R1,2040,1470,0
gassupply1,R1,2050,1029,0
gassupply1,R2,2010,0,1200
gassupply1,R2,2020,0,1200
gassupply1,R2,2030,0,700
gassupply1,R2,2040,0,490
gassupply1,R2,2050,0,343
gassupply1,R1,2020,15,0
gassupply1,R1,2025,15,0
gassupply1,R1,2030,7.5,0
gassupply1,R1,2035,0,0
gassupply1,R1,2040,0,0
gassupply1,R1,2045,0,0
gassupply1,R1,2050,0,0
gassupply1,R2,2020,0,15
gassupply1,R2,2025,0,15
gassupply1,R2,2035,0,7.5
gassupply1,R2,2040,0,0
gassupply1,R2,2045,0,0
gassupply1,R2,2050,0,0
8 changes: 4 additions & 4 deletions src/muse/data/example/trade/technodata/gas/Technodata.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ProcessName,RegionName,Time,var_par,var_exp,TechnicalLife,UtilizationFactor,ScalingSize,efficiency,InterestRate,Type,Fuel,EndUse,Agent1
Unit,-,Year,MUS$2010/PJ,-,Years,-,PJ,%,-,-,-,-,New
gassupply1,R1,2010,3,1,10,0.9,0.00000189,86,0.1,energy,gas,gas,1
gassupply1,R2,2010,3,1,10,0.9,0.00000189,86,0.1,energy,gas,gas,1
ProcessName,RegionName,Time,cap_par,cap_exp,fix_par,fix_exp,var_exp,MaxCapacityAddition,MaxCapacityGrowth,TotalCapacityLimit,TechnicalLife,UtilizationFactor,ScalingSize,efficiency,InterestRate,Type,Fuel,EndUse,Agent1
Unit,-,Year,MUS$2010/PJ_a,-,MUS$2010/PJ,-,-,PJ,%,PJ,Years,-,PJ,%,-,-,-,-,New
gassupply1,R1,2020,0,1,0,1,1,10,1,100,35,0.9,0.00000189,86,0.1,energy,gas,gas,1
gassupply1,R2,2020,0,1,0,1,1,10,1,100,35,0.9,0.00000189,86,0.1,energy,gas,gas,1
18 changes: 3 additions & 15 deletions src/muse/data/example/trade/technodata/gas/TradeTechnodata.csv
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
ProcessName,RegionName,Parameter,Unit,R1,R2,R3
gassupply1,R1,cap_par,MUSD/PJ,3,98.013,25
gassupply1,R2,cap_par,MUSD/PJ,7.8406,5,7.8406
gassupply1,R1,cap_exp,MUSD/PJ,1,1,1
gassupply1,R2,cap_exp,MUSD/PJ,1,1,1
gassupply1,R1,fix_par,MUSD/PJ,0.3,0.98013,0.90612
gassupply1,R2,fix_par,MUSD/PJ,0.78406,0.5,0.17434
gassupply1,R1,fix_exp,MUSD/PJ,1,1,1
gassupply1,R2,fix_exp,MUSD/PJ,1,1,1
gassupply1,R1,MaxCapacityAddition,PJ/y,200,0,0.1
gassupply1,R2,MaxCapacityAddition,PJ/y,0,200,0
gassupply1,R1,MaxCapacityGrowth,PJ/y,1,0,0.002
gassupply1,R2,MaxCapacityGrowth,PJ/y,0,1,0
gassupply1,R1,TotalCapacityLimit,PJ/y,3937.219,0,1
gassupply1,R2,TotalCapacityLimit,PJ/y,0,3937.219,0
ProcessName,RegionName,Parameter,Unit,R1,R2
gassupply1,R1,var_par,MUSD/PJ,2.55,2.55
gassupply1,R2,var_par,MUSD/PJ,2.55,2.55
8 changes: 4 additions & 4 deletions src/muse/data/example/trade/technodata/power/CommIn.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ProcessName,RegionName,Time,Level,electricity,gas,heat,CO2f,wind
Unit,-,Year,-,PJ/PJ,PJ/PJ,PJ/PJ,kt/PJ,PJ/PJ
gasCCGT,R1,2010,fixed,0,1.67,0,0,0
windturbine,R1,2010,fixed,0,0,0,0,1
gasCCGT,R2,2010,fixed,0,2,0,0,0
windturbine,R2,2010,fixed,0,0,0,0,1
gasCCGT,R1,2020,fixed,0,1.67,0,0,0
windturbine,R1,2020,fixed,0,0,0,0,1
gasCCGT,R2,2020,fixed,0,1.67,0,0,0
windturbine,R2,2020,fixed,0,0,0,0,1
8 changes: 4 additions & 4 deletions src/muse/data/example/trade/technodata/power/CommOut.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ProcessName,RegionName,Time,electricity,gas,heat,CO2f,wind
Unit,-,Year,PJ/PJ,PJ/PJ,PJ/PJ,kt/PJ,PJ/PJ
gasCCGT,R1,2010,1,0,0,91.66666667,0
windturbine,R1,2010,1,0,0,0,0
gasCCGT,R2,2010,1,0,0,91.66666667,0
windturbine,R2,2010,1,0,0,0,0
gasCCGT,R1,2020,1,0,0,91.67,0
windturbine,R1,2020,1,0,0,0,0
gasCCGT,R2,2020,1,0,0,91.67,0
windturbine,R2,2020,1,0,0,0,0
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ProcessName,RegionName,Unit,2020,2025,2030,2035,2040,2045,2050
gasCCGT,R1,PJ/y,1,1,0,0,0,0,0
windturbine,R1,PJ/y,0,0,0,0,0,0,0
gasCCGT,R2,PJ/y,1,1,0,0,0,0,0
windturbine,R2,PJ/y,0,0,0,0,0,0,0
32 changes: 0 additions & 32 deletions src/muse/data/example/trade/technodata/power/ExistingTrade.csv

This file was deleted.

12 changes: 6 additions & 6 deletions src/muse/data/example/trade/technodata/power/Technodata.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ProcessName,RegionName,Time,cap_exp,fix_exp,var_par,var_exp,TechnicalLife,UtilizationFactor,ScalingSize,efficiency,InterestRate,Type,Fuel,EndUse,Agent1
Unit,-,Year,-,-,MUS$2010/PJ,-,Years,-,PJ,%,-,-,-,-,New
gasCCGT,R1,2010,1,1,0,1,35,0.9,0.00000189,86,0.1,energy,gas,electricity,1
windturbine,R1,2010,1,1,0,1,25,0.4,0.00000189,86,0.1,energy,wind,electricity,1
gasCCGT,R2,2010,1,1,0,1,35,0.9,0.00000189,86,0.1,energy,gas,electricity,1
windturbine,R2,2010,1,1,0,1,25,0.4,0.00000189,86,0.1,energy,wind,electricity,1
ProcessName,RegionName,Time,cap_par,cap_exp,fix_par,fix_exp,var_par,var_exp,MaxCapacityAddition,MaxCapacityGrowth,TotalCapacityLimit,TechnicalLife,UtilizationFactor,ScalingSize,efficiency,InterestRate,Type,Fuel,EndUse,Agent1
Unit,-,Year,MUS$2010/PJ_a,-,MUS$2010/PJ,-,MUS$2010/PJ,-,PJ,%,PJ,Years,-,PJ,%,-,-,-,-,New
gasCCGT,R1,2020,23.78234399,1,0,1,0,1,10,1,100,35,0.9,0.00000189,86,0.1,energy,gas,electricity,1
windturbine,R1,2020,36.30771182,1,0,1,0,1,10,1,100,25,0.4,0.00000189,86,0.1,energy,wind,electricity,1
gasCCGT,R2,2020,23.78234399,1,0,1,0,1,10,1,100,35,0.9,0.00000189,86,0.1,energy,gas,electricity,1
windturbine,R2,2020,36.30771182,1,0,1,0,1,10,1,100,25,0.4,0.00000189,86,0.1,energy,wind,electricity,1
21 changes: 0 additions & 21 deletions src/muse/data/example/trade/technodata/power/TradeTechnodata.csv

This file was deleted.

Loading
Loading