Skip to content

Commit

Permalink
Update storage binary charging constraints (#814)
Browse files Browse the repository at this point in the history
  • Loading branch information
datejada authored Sep 20, 2024
1 parent 1210744 commit 2b2a2ff
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 33 deletions.
58 changes: 27 additions & 31 deletions src/constraints/capacity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function add_capacity_constraints!(
accumulated_units_lookup,
accumulated_set_using_compact_method_lookup,
Asb,
assets_investment,
accumulated_initial_units,
accumulated_units,
accumulated_units_compact_method,
accumulated_set_using_compact_method,
Expand Down Expand Up @@ -86,8 +86,7 @@ function add_capacity_constraints!(
1.0,
) *
(
graph[row.asset].capacity *
graph[row.asset].initial_units[row.year][row.year] +
graph[row.asset].capacity * accumulated_initial_units[row.asset, row.year] +
graph[row.asset].investment_limit[row.year]
) *
(1 - row.is_charging)
Expand All @@ -104,10 +103,7 @@ function add_capacity_constraints!(
row.timesteps_block,
1.0,
) *
(
graph[row.asset].capacity *
graph[row.asset].initial_units[row.year][row.year]
) *
(graph[row.asset].capacity * accumulated_initial_units[row.asset, row.year]) *
(1 - row.is_charging)
)
end for row in eachrow(dataframes[:highest_out])
Expand All @@ -128,8 +124,8 @@ function add_capacity_constraints!(
1.0,
) * (
graph[row.asset].capacity * (
graph[row.asset].initial_units[row.year][row.year] *
(1 - row.is_charging) + assets_investment[row.year, row.asset]
accumulated_units[accumulated_units_lookup[(row.asset, row.year)]] -
accumulated_initial_units[row.asset, row.year] * row.is_charging
)
)
)
Expand All @@ -139,22 +135,25 @@ function add_capacity_constraints!(
# - Create capacity limit for incoming flows
assets_profile_times_capacity_in =
model[:assets_profile_times_capacity_in] = [
if row.asset Ai[row.year]
if row.asset decommissionable_assets_using_compact_method
@expression(
model,
profile_aggregation(
Statistics.mean,
graph[row.asset].rep_periods_profiles,
row.year,
row.year,
("availability", row.rep_period),
row.timesteps_block,
1.0,
) * (
graph[row.asset].capacity * (
graph[row.asset].initial_units[row.year][row.year] +
assets_investment[row.year, row.asset]
)
graph[row.asset].capacity * sum(
profile_aggregation(
Statistics.mean,
graph[row.asset].rep_periods_profiles,
row.year,
v,
("availability", row.rep_period),
row.timesteps_block,
1.0,
) *
accumulated_units_compact_method[accumulated_set_using_compact_method_lookup[(
row.asset,
row.year,
v,
)]] for v in V_all if
(row.asset, row.year, v) in accumulated_set_using_compact_method
)
)
else
Expand All @@ -170,7 +169,7 @@ function add_capacity_constraints!(
1.0,
) *
graph[row.asset].capacity *
graph[row.asset].initial_units[row.year][row.year]
accumulated_units[accumulated_units_lookup[(row.asset, row.year)]]
)
end for row in eachrow(dataframes[:highest_in])
]
Expand All @@ -191,8 +190,7 @@ function add_capacity_constraints!(
1.0,
) *
(
graph[row.asset].capacity *
graph[row.asset].initial_units[row.year][row.year] +
graph[row.asset].capacity * accumulated_initial_units[row.asset, row.year] +
graph[row.asset].investment_limit[row.year]
) *
row.is_charging
Expand All @@ -209,10 +207,7 @@ function add_capacity_constraints!(
row.timesteps_block,
1.0,
) *
(
graph[row.asset].capacity *
graph[row.asset].initial_units[row.year][row.year]
) *
(graph[row.asset].capacity * accumulated_initial_units[row.asset, row.year]) *
row.is_charging
)
end for row in eachrow(dataframes[:highest_in])
Expand All @@ -233,7 +228,8 @@ function add_capacity_constraints!(
1.0,
) * (
graph[row.asset].capacity * (
graph[row.asset].initial_units[row.year][row.year] * row.is_charging + assets_investment[row.year, row.asset]
accumulated_units[accumulated_units_lookup[(row.asset, row.year)]] -
accumulated_initial_units[row.asset, row.year] * (1 - row.is_charging)
)
)
)
Expand Down
7 changes: 6 additions & 1 deletion src/create-model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,11 @@ function create_model(

## Expressions for multi-year investment
@timeit to "multi-year investment" begin
accumulated_initial_units = @expression(
model,
accumulated_initial_units[a in A, y in Y],
sum(values(graph[a].initial_units[y]))
)
@expression(
model,
accumulated_units_simple_method[y Y, a decommissionable_assets_using_simple_method],
Expand Down Expand Up @@ -1147,7 +1152,7 @@ function create_model(
accumulated_units_lookup,
accumulated_set_using_compact_method_lookup,
Asb,
assets_investment,
accumulated_initial_units,
accumulated_units,
accumulated_units_compact_method,
accumulated_set_using_compact_method,
Expand Down
4 changes: 4 additions & 0 deletions test/inputs/Multi-year Investments/assets-data.csv
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name,active,year,commission_year,investable,investment_integer,investment_cost,f
ocgt,true,2030,2030,true,true,25,20,,0,0,,false,0,0,0,0,false,0,,0,false,,,,false,,,false,,false,,
ccgt,true,2030,2028,false,false,40,20,10000,1,0,,false,0,0,0,0,false,0,,0,false,,,,false,,,false,,false,,
ccgt,true,2030,2030,true,true,40,20,10000,0,0,,false,0,0,0,0,false,0,,0,false,,,,false,,,false,,false,,
battery,true,2030,2020,false,false,70,20,,0.07,0,,false,0,0,0,0,false,0,,0,false,,,,false,,,false,,false,,
battery,true,2030,2030,true,true,70,20,,0.02,0,,false,0,0,0,0,false,0,,0,false,,,,false,,,false,,false,,
wind,true,2030,2020,false,false,70,20,,0.07,0,,false,0,0,0,0,false,0,,0,false,,,,false,,,false,,false,,
wind,true,2030,2030,true,true,70,20,,0.02,0,,false,0,0,0,0,false,0,,0,false,,,,false,,,false,,false,,
solar,true,2030,2030,true,true,50,20,,0,0,,false,0,0,0,0,false,0,,0,false,,,,false,,,false,,false,,
Expand All @@ -11,6 +13,8 @@ demand,true,2030,2030,false,false,0,20,,0,1115,,false,0,0,0,0,false,0,,0,false,,
ocgt,true,2050,2050,true,true,25,20,,0,0,,false,0,0,0,0,false,0,,0,false,,,,false,,,false,,false,,
ccgt,true,2050,2028,false,false,40,20,10000,1,0,,false,0,0,0,0,false,0,,0,false,,,,false,,,false,,false,,
ccgt,true,2050,2050,false,false,40,20,10000,0,0,,false,0,0,0,0,false,0,,0,false,,,,false,,,false,,false,,
battery,true,2050,2030,false,false,70,20,,0.02,0,,false,0,0,0,0,false,0,,0,false,,,,false,,,false,,false,,
battery,true,2050,2050,true,true,70,20,,0,0,,false,0,0,0,0,false,0,,0,false,,,,false,,,false,,false,,
wind,true,2050,2030,false,false,70,20,,0.02,0,,false,0,0,0,0,false,0,,0,false,,,,false,,,false,,false,,
wind,true,2050,2050,true,true,70,20,,0,0,,false,0,0,0,0,false,0,,0,false,,,,false,,,false,,false,,
solar,true,2050,2050,true,true,50,20,,0,0,,false,0,0,0,0,false,0,,0,false,,,,false,,,false,,false,,
Expand Down
4 changes: 4 additions & 0 deletions test/inputs/Multi-year Investments/flows-data.csv
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ asset_name,asset_name,{true;false},,{true;false},{true;false},{true;false},kEUR/
from_asset,to_asset,active,year,is_transport,investable,investment_integer,variable_cost,investment_cost,investment_limit,initial_export_capacity,initial_import_capacity,efficiency
ocgt,demand,true,2030,false,false,false,0.07,0,,0,0,0
ccgt,demand,true,2030,false,false,false,0.05,0,,0,0,0
battery,demand,true,2030,false,false,false,0.0,0,,0,0,0.95
demand,battery,true,2030,false,false,false,0.0,0,,0,0,0.95
wind,demand,true,2030,false,false,false,0.001,0,,0,0,0
solar,demand,true,2030,false,false,false,0,0,,0,0,0
ens,demand,true,2030,false,false,false,0.18,0,,0,0,0
ocgt,demand,true,2050,false,false,false,0.07,0,,0,0,0
ccgt,demand,true,2050,false,false,false,0.05,0,,0,0,0
battery,demand,true,2050,false,false,false,0.0,0,,0,0,0.95
demand,battery,true,2050,false,false,false,0.0,0,,0,0,0.95
wind,demand,true,2050,false,false,false,0.001,0,,0,0,0
solar,demand,true,2050,false,false,false,0,0,,0,0,0
ens,demand,false,2050,false,false,false,0.18,0,,0,0,0
3 changes: 2 additions & 1 deletion test/inputs/Multi-year Investments/graph-assets-data.csv
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
,{producer;consumer},{group name},{none;simple;compact},MW,year,
,{producer;consumer;storage;hub;conversion},{group name},{none;simple;compact},MW,year,
name,type,group,investment_method,capacity,technical_lifetime,discount_rate
ocgt,producer,,simple,100,15,0.05
ccgt,producer,,simple,400,25,0.05
battery,storage,,compact,50,30,0.05
wind,producer,,compact,50,30,0.05
solar,producer,,simple,10,15,0.05
ens,producer,,none,1115,15,0.05
Expand Down
2 changes: 2 additions & 0 deletions test/inputs/Multi-year Investments/graph-flows-data.csv
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ asset_name,asset_name,,MW
from_asset,to_asset,carrier,capacity
ocgt,demand,electricity,0
ccgt,demand,electricity,0
battery,demand,electricity,0
demand,battery,electricity,0
wind,demand,electricity,0
solar,demand,electricity,0
ens,demand,electricity,0
3 changes: 3 additions & 0 deletions test/inputs/Multi-year Investments/initial-assets-data.csv
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ name,active,year,commission_year,investable,investment_integer,investment_cost,i
wind,true,2020,2020,false,false,0,,50,0.07,0,,false,0,0,0,0,false,0,,0,false,,,,false,,,false,,false,,
wind,true,2030,2030,false,false,70,,50,0.02,0,,false,0,0,0,0,false,0,,0,false,,,,false,,,false,,false,,
wind,true,2035,2020,false,false,0,,50,-0.02,0,,false,0,0,0,0,false,0,,0,false,,,,false,,,false,,false,,
battery,true,2020,2020,false,false,0,,50,0.07,0,,false,0,0,0,0,false,0,,0,false,,,,false,,,false,,false,,
battery,true,2030,2030,false,false,70,,50,0.02,0,,false,0,0,0,0,false,0,,0,false,,,,false,,,false,,false,,
battery,true,2035,2020,false,false,0,,50,-0.02,0,,false,0,0,0,0,false,0,,0,false,,,,false,,,false,,false,,
3 changes: 3 additions & 0 deletions test/inputs/Multi-year Investments/vintage-assets-data.csv
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ name,commission_year,fixed_cost,investment_cost
ocgt,2030,20,25
ccgt,2028,20,40
ccgt,2030,20,40
battery,2020,20,70
battery,2030,20,70
wind,2020,20,70
wind,2030,20,70
solar,2030,20,50
ens,2030,20,0
demand,2030,20,0
ocgt,2050,20,25
ccgt,2050,20,40
battery,2050,20,70
wind,2050,20,70
solar,2050,20,50
ens,2050,20,0
Expand Down

0 comments on commit 2b2a2ff

Please sign in to comment.