Skip to content

Commit

Permalink
Add storage inflows to the model and to the Norse case
Browse files Browse the repository at this point in the history
  • Loading branch information
datejada committed Nov 8, 2023
1 parent 3321aae commit 2afd1e3
Show file tree
Hide file tree
Showing 3 changed files with 209 additions and 9 deletions.
24 changes: 16 additions & 8 deletions src/model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,21 @@ function create_model(graph, params, sets; verbose = false, write_lp_file = fals
)
)

@expression(
model,
energy_limit[a AsAi],
params.energy_to_power_ratio[a] *
params.assets_unit_capacity[a] *
assets_investment[a]
)

@expression(
model,
storage_inflows[a As, rp RP, T P[(a, rp)]],
sum(get(params.assets_profile, (a, rp, k), 0.0) for k T) *
(params.initial_storage_capacity[a] + (a Ai ? energy_limit[a] : 0.0))
)

# Balance equations
# - consumer balance equation
@constraint(
Expand All @@ -136,12 +151,12 @@ function create_model(graph, params, sets; verbose = false, write_lp_file = fals
)

# - storage balance equation
# TODO: Add p^{inflow}
@constraint(
model,
storage_balance[a As, rp RP, (k, B) enumerate(P[(a, rp)])],
storage_level[a, rp, B] ==
(k > 1 ? storage_level[a, rp, P[(a, rp)][k-1]] : params.initial_storage_level[a]) +
storage_inflows[a, rp, B] +
incoming_flow_w_efficiency[(a, rp, B)] - outgoing_flow_w_efficiency[(a, rp, B)]
)

Expand Down Expand Up @@ -228,13 +243,6 @@ function create_model(graph, params, sets; verbose = false, write_lp_file = fals

# Extra constraints
# - upper bound constraints for storage level
@expression(
model,
energy_limit[a AsAi],
params.energy_to_power_ratio[a] *
params.assets_unit_capacity[a] *
assets_investment[a]
)
@constraint(
model,
upper_bound_for_storage_level[a As, rp RP, B P[(a, rp)]],
Expand Down
192 changes: 192 additions & 0 deletions test/inputs/Norse/assets-profiles.csv
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,174 @@ id,rep_period_id,time_step,value
6,1,166,0.654
6,1,167,0.673
6,1,168,0.681
7,1,1,0.0001
7,1,2,0.0001
7,1,3,0.0001
7,1,4,0.0001
7,1,5,0.0001
7,1,6,0.0001
7,1,7,0.0001
7,1,8,0.0001
7,1,9,0.0001
7,1,10,0.0001
7,1,11,0.0001
7,1,12,0.0001
7,1,13,0.0001
7,1,14,0.0001
7,1,15,0.0001
7,1,16,0.0001
7,1,17,0.0001
7,1,18,0.0001
7,1,19,0.0001
7,1,20,0.0001
7,1,21,0.0001
7,1,22,0.0001
7,1,23,0.0001
7,1,24,0.0001
7,1,25,0.0001
7,1,26,0.0001
7,1,27,0.0001
7,1,28,0.0001
7,1,29,0.0001
7,1,30,0.0001
7,1,31,0.0001
7,1,32,0.0001
7,1,33,0.0001
7,1,34,0.0001
7,1,35,0.0001
7,1,36,0.0001
7,1,37,0.0001
7,1,38,0.0001
7,1,39,0.0001
7,1,40,0.0001
7,1,41,0.0001
7,1,42,0.0001
7,1,43,0.0001
7,1,44,0.0001
7,1,45,0.0001
7,1,46,0.0001
7,1,47,0.0001
7,1,48,0.0001
7,1,49,0.0001
7,1,50,0.0001
7,1,51,0.0001
7,1,52,0.0001
7,1,53,0.0001
7,1,54,0.0001
7,1,55,0.0001
7,1,56,0.0001
7,1,57,0.0001
7,1,58,0.0001
7,1,59,0.0001
7,1,60,0.0001
7,1,61,0.0001
7,1,62,0.0001
7,1,63,0.0001
7,1,64,0.0001
7,1,65,0.0001
7,1,66,0.0001
7,1,67,0.0001
7,1,68,0.0001
7,1,69,0.0001
7,1,70,0.0001
7,1,71,0.0001
7,1,72,0.0001
7,1,73,0.0001
7,1,74,0.0001
7,1,75,0.0001
7,1,76,0.0001
7,1,77,0.0001
7,1,78,0.0001
7,1,79,0.0001
7,1,80,0.0001
7,1,81,0.0001
7,1,82,0.0001
7,1,83,0.0001
7,1,84,0.0001
7,1,85,0.0001
7,1,86,0.0001
7,1,87,0.0001
7,1,88,0.0001
7,1,89,0.0001
7,1,90,0.0001
7,1,91,0.0001
7,1,92,0.0001
7,1,93,0.0001
7,1,94,0.0001
7,1,95,0.0001
7,1,96,0.0001
7,1,97,0.0001
7,1,98,0.0001
7,1,99,0.0001
7,1,100,0.0001
7,1,101,0.0001
7,1,102,0.0001
7,1,103,0.0001
7,1,104,0.0001
7,1,105,0.0001
7,1,106,0.0001
7,1,107,0.0001
7,1,108,0.0001
7,1,109,0.0001
7,1,110,0.0001
7,1,111,0.0001
7,1,112,0.0001
7,1,113,0.0001
7,1,114,0.0001
7,1,115,0.0001
7,1,116,0.0001
7,1,117,0.0001
7,1,118,0.0001
7,1,119,0.0001
7,1,120,0.0001
7,1,121,0.0001
7,1,122,0.0001
7,1,123,0.0001
7,1,124,0.0001
7,1,125,0.0001
7,1,126,0.0001
7,1,127,0.0001
7,1,128,0.0001
7,1,129,0.0001
7,1,130,0.0001
7,1,131,0.0001
7,1,132,0.0001
7,1,133,0.0001
7,1,134,0.0001
7,1,135,0.0001
7,1,136,0.0001
7,1,137,0.0001
7,1,138,0.0001
7,1,139,0.0001
7,1,140,0.0001
7,1,141,0.0001
7,1,142,0.0001
7,1,143,0.0001
7,1,144,0.0001
7,1,145,0.0001
7,1,146,0.0001
7,1,147,0.0001
7,1,148,0.0001
7,1,149,0.0001
7,1,150,0.0001
7,1,151,0.0001
7,1,152,0.0001
7,1,153,0.0001
7,1,154,0.0001
7,1,155,0.0001
7,1,156,0.0001
7,1,157,0.0001
7,1,158,0.0001
7,1,159,0.0001
7,1,160,0.0001
7,1,161,0.0001
7,1,162,0.0001
7,1,163,0.0001
7,1,164,0.0001
7,1,165,0.0001
7,1,166,0.0001
7,1,167,0.0001
7,1,168,0.0001
11,1,1,0.688597416
11,1,2,0.676090883
11,1,3,0.654860035
Expand Down Expand Up @@ -1080,6 +1248,30 @@ id,rep_period_id,time_step,value
6,2,22,0.7542
6,2,23,0.7677
6,2,24,0.7785
7,2,1,0.00005
7,2,2,0.00005
7,2,3,0.00005
7,2,4,0.00005
7,2,5,0.00005
7,2,6,0.00005
7,2,7,0.00005
7,2,8,0.00005
7,2,9,0.00005
7,2,10,0.00005
7,2,11,0.00005
7,2,12,0.00005
7,2,13,0.00005
7,2,14,0.00005
7,2,15,0.00005
7,2,16,0.00005
7,2,17,0.00005
7,2,18,0.00005
7,2,19,0.00005
7,2,20,0.00005
7,2,21,0.00005
7,2,22,0.00005
7,2,23,0.00005
7,2,24,0.00005
11,2,1,0.964036382
11,2,2,0.946527236
11,2,3,0.916804049
Expand Down
2 changes: 1 addition & 1 deletion test/test-case-studies.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
graph = create_graph(joinpath(dir, "assets-data.csv"), joinpath(dir, "flows-data.csv"))
model = create_model(graph, parameters, sets)
solution = solve_model(model)
@test solution.objective_value 164432876.31472 atol = 1e-5
@test solution.objective_value 164432875.02939 atol = 1e-5
save_solution_to_file(
OUTPUT_FOLDER,
sets.assets_investment,
Expand Down

0 comments on commit 2afd1e3

Please sign in to comment.