Skip to content

Commit e045829

Browse files
Refactor efficiency parameter for conversion and storage assets (#1241)
* Update JSON schema file * Delete efficiency parameter from data and model preparation * Update storage balance constraints with new efficiency parameters * Update conversion balance constraint with new efficiency parameter * Update input data of test files * Update of MPS files * Update of reference in the docs * Apply suggestions from code review Co-authored-by: Abel Soares Siqueira <abel.siqueira@esciencecenter.nl> * Apply suggestions from code review --------- Co-authored-by: Abel Soares Siqueira <abel.siqueira@esciencecenter.nl>
1 parent fcfc4ed commit e045829

27 files changed

Lines changed: 5788 additions & 5763 deletions

benchmark/EU/asset-commission.csv

Lines changed: 394 additions & 394 deletions
Large diffs are not rendered by default.

benchmark/EU/flow-commission.csv

Lines changed: 596 additions & 596 deletions
Large diffs are not rendered by default.

benchmark/model-mps-folder/Norse.mps

Lines changed: 4465 additions & 4465 deletions
Large diffs are not rendered by default.

benchmark/model-mps-folder/UC-ramping.mps

Lines changed: 72 additions & 72 deletions
Large diffs are not rendered by default.

benchmark/model-mps-folder/Variable Resolution.mps

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ ROWS
3333
E conversion_balance[ccgt,2030,1,1:6]
3434
COLUMNS
3535
flow[(H2,ccgt),2030,1,1:6] max_output_flows_limit_simple_method[H2,2030,1,1:6] 1
36-
flow[(H2,ccgt),2030,1,1:6] conversion_balance[ccgt,2030,1,1:6] 6
36+
flow[(H2,ccgt),2030,1,1:6] conversion_balance[ccgt,2030,1,1:6] 3
3737
flow[(H2,ccgt),2030,1,1:6] OBJ 0.06
3838
flow[(wind,balance),2030,1,1:2] max_output_flows_limit_simple_method[wind,2030,1,1:2] 1
3939
flow[(wind,balance),2030,1,1:2] balance_hub[balance,2030,1,1:1] 1
@@ -69,27 +69,27 @@ COLUMNS
6969
flow[(phs,balance),2030,1,5:6] OBJ 0.002
7070
flow[(ccgt,balance),2030,1,1:1] max_output_flows_limit_simple_method[ccgt,2030,1,1:1] 1
7171
flow[(ccgt,balance),2030,1,1:1] balance_hub[balance,2030,1,1:1] 1
72-
flow[(ccgt,balance),2030,1,1:1] conversion_balance[ccgt,2030,1,1:6] -2
72+
flow[(ccgt,balance),2030,1,1:1] conversion_balance[ccgt,2030,1,1:6] -1
7373
flow[(ccgt,balance),2030,1,1:1] OBJ 0.05
7474
flow[(ccgt,balance),2030,1,2:2] max_output_flows_limit_simple_method[ccgt,2030,1,2:2] 1
7575
flow[(ccgt,balance),2030,1,2:2] balance_hub[balance,2030,1,2:2] 1
76-
flow[(ccgt,balance),2030,1,2:2] conversion_balance[ccgt,2030,1,1:6] -2
76+
flow[(ccgt,balance),2030,1,2:2] conversion_balance[ccgt,2030,1,1:6] -1
7777
flow[(ccgt,balance),2030,1,2:2] OBJ 0.05
7878
flow[(ccgt,balance),2030,1,3:3] max_output_flows_limit_simple_method[ccgt,2030,1,3:3] 1
7979
flow[(ccgt,balance),2030,1,3:3] balance_hub[balance,2030,1,3:3] 1
80-
flow[(ccgt,balance),2030,1,3:3] conversion_balance[ccgt,2030,1,1:6] -2
80+
flow[(ccgt,balance),2030,1,3:3] conversion_balance[ccgt,2030,1,1:6] -1
8181
flow[(ccgt,balance),2030,1,3:3] OBJ 0.05
8282
flow[(ccgt,balance),2030,1,4:4] max_output_flows_limit_simple_method[ccgt,2030,1,4:4] 1
8383
flow[(ccgt,balance),2030,1,4:4] balance_hub[balance,2030,1,4:4] 1
84-
flow[(ccgt,balance),2030,1,4:4] conversion_balance[ccgt,2030,1,1:6] -2
84+
flow[(ccgt,balance),2030,1,4:4] conversion_balance[ccgt,2030,1,1:6] -1
8585
flow[(ccgt,balance),2030,1,4:4] OBJ 0.05
8686
flow[(ccgt,balance),2030,1,5:5] max_output_flows_limit_simple_method[ccgt,2030,1,5:5] 1
8787
flow[(ccgt,balance),2030,1,5:5] balance_hub[balance,2030,1,5:5] 1
88-
flow[(ccgt,balance),2030,1,5:5] conversion_balance[ccgt,2030,1,1:6] -2
88+
flow[(ccgt,balance),2030,1,5:5] conversion_balance[ccgt,2030,1,1:6] -1
8989
flow[(ccgt,balance),2030,1,5:5] OBJ 0.05
9090
flow[(ccgt,balance),2030,1,6:6] max_output_flows_limit_simple_method[ccgt,2030,1,6:6] 1
9191
flow[(ccgt,balance),2030,1,6:6] balance_hub[balance,2030,1,6:6] 1
92-
flow[(ccgt,balance),2030,1,6:6] conversion_balance[ccgt,2030,1,1:6] -2
92+
flow[(ccgt,balance),2030,1,6:6] conversion_balance[ccgt,2030,1,1:6] -1
9393
flow[(ccgt,balance),2030,1,6:6] OBJ 0.05
9494
flow[(balance,demand),2030,1,1:3] max_transport_flow_limit_simple_method[(balance,demand),2030,1,1:3] 1
9595
flow[(balance,demand),2030,1,1:3] min_transport_flow_limit_simple_method[(balance,demand),2030,1,1:3] 1

docs/src/55-outputs.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ Associated input parameters: `investable`, `investment_integer`, `capacity`, `in
6666

6767
For a flow, the optimal flow (of energy) during a particular `rep_period` between `time_block_start` and `time_block_end`, expressed in the same units as `capacity` of flow.
6868

69-
Associated input parameter: `efficiency`
70-
7169
### `var_flows_decommission`
7270

7371
For a transport flow commissioned in `commission_year`, the optimal decommissioning (decrease) of flow capacity in `milestone_year`, expressed in the same units as `capacity` of flow.

src/constraints/conversion.jl

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,51 @@
11
export add_conversion_constraints!
22

33
"""
4-
add_conversion_constraints!(model, constraints)
4+
add_conversion_constraints!(connection, model, constraints)
55
66
Adds the conversion asset constraints to the model.
77
"""
8-
function add_conversion_constraints!(model, constraints)
8+
function add_conversion_constraints!(connection, model, constraints)
99
# - Balance constraint (using the lowest temporal resolution)
1010
let table_name = :balance_conversion, cons = constraints[table_name]
11+
indices = _append_conversion_data_to_indices(connection, table_name)
1112
attach_constraint!(
1213
model,
1314
cons,
1415
table_name,
1516
[
16-
@constraint(
17-
model,
18-
incoming_flow == outgoing_flow,
19-
base_name = "conversion_balance[$(row.asset),$(row.year),$(row.rep_period),$(row.time_block_start):$(row.time_block_end)]"
20-
) for (row, incoming_flow, outgoing_flow) in
21-
zip(cons.indices, cons.expressions[:incoming], cons.expressions[:outgoing])
17+
begin
18+
conversion_efficiency = row.conversion_efficiency::Float64
19+
@constraint(
20+
model,
21+
conversion_efficiency * incoming_flow == outgoing_flow,
22+
base_name = "conversion_balance[$(row.asset),$(row.year),$(row.rep_period),$(row.time_block_start):$(row.time_block_end)]"
23+
)
24+
end for (row, incoming_flow, outgoing_flow) in
25+
zip(indices, cons.expressions[:incoming], cons.expressions[:outgoing])
2226
],
2327
)
2428
end
2529

2630
return
2731
end
32+
33+
function _append_conversion_data_to_indices(connection, table_name)
34+
return DuckDB.query(
35+
connection,
36+
"SELECT
37+
cons.id,
38+
cons.asset,
39+
cons.year,
40+
cons.rep_period,
41+
cons.time_block_start,
42+
cons.time_block_end,
43+
asset_commission.conversion_efficiency,
44+
FROM cons_$table_name AS cons
45+
LEFT JOIN asset_commission
46+
ON cons.asset = asset_commission.asset
47+
AND cons.year = asset_commission.commission_year
48+
ORDER BY cons.id
49+
",
50+
)
51+
end

src/constraints/storage.jl

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ function add_storage_constraints!(connection, model, variables, expressions, con
2727
sum,
2828
0.0,
2929
)
30-
initial_storage_level = row.initial_storage_level
30+
initial_storage_level = row.initial_storage_level::Union{Float64,Missing}
31+
storage_charging_efficiency = row.storage_charging_efficiency::Float64
32+
storage_discharging_efficiency = row.storage_discharging_efficiency::Float64
3133

3234
if row.time_block_start == 1 && !ismissing(initial_storage_level)
3335
# Initial storage is a Float64
@@ -36,7 +38,8 @@ function add_storage_constraints!(connection, model, variables, expressions, con
3638
var_storage_level[row.id] ==
3739
initial_storage_level +
3840
profile_agg * row.storage_inflows +
39-
incoming_flow - outgoing_flow,
41+
storage_charging_efficiency * incoming_flow -
42+
outgoing_flow / storage_discharging_efficiency,
4043
base_name = "$table_name[$(row.asset),$(row.year),$(row.rep_period),$(row.time_block_start):$(row.time_block_end)]"
4144
)
4245
else
@@ -68,7 +71,8 @@ function add_storage_constraints!(connection, model, variables, expressions, con
6871
var_storage_level[row.id] ==
6972
computed_storage_loss_coef * previous_level +
7073
profile_agg * row.storage_inflows +
71-
incoming_flow - outgoing_flow,
74+
storage_charging_efficiency * incoming_flow -
75+
outgoing_flow / storage_discharging_efficiency,
7276
base_name = "$table_name[$(row.asset),$(row.year),$(row.rep_period),$(row.time_block_start):$(row.time_block_end)]"
7377
)
7478
end
@@ -148,14 +152,19 @@ function add_storage_constraints!(connection, model, variables, expressions, con
148152
:balance_storage_over_clustered_year,
149153
[
150154
begin
151-
initial_storage_level = row.initial_storage_level
155+
initial_storage_level = row.initial_storage_level::Union{Float64,Missing}
156+
storage_charging_efficiency = row.storage_charging_efficiency::Float64
157+
storage_discharging_efficiency = row.storage_discharging_efficiency::Float64
152158

153159
if row.period_block_start == 1 && !ismissing(initial_storage_level)
154160
# Initial storage is a Float64
155161
@constraint(
156162
model,
157163
var_storage_level_over_clustered_year.container[row.id] ==
158-
initial_storage_level + inflows_agg + incoming_flow - outgoing_flow,
164+
initial_storage_level +
165+
inflows_agg +
166+
storage_charging_efficiency * incoming_flow -
167+
outgoing_flow / storage_discharging_efficiency,
159168
base_name = "$table_name[$(row.asset),$(row.year),$(row.period_block_start):$(row.period_block_end)]"
160169
)
161170
else
@@ -185,7 +194,8 @@ function add_storage_constraints!(connection, model, variables, expressions, con
185194
var_storage_level_over_clustered_year.container[row.id] ==
186195
computed_storage_loss_coef * previous_level +
187196
inflows_agg +
188-
incoming_flow - outgoing_flow,
197+
storage_charging_efficiency * incoming_flow -
198+
outgoing_flow / storage_discharging_efficiency,
189199
base_name = "$table_name[$(row.asset),$(row.year),$(row.period_block_start):$(row.period_block_end)]"
190200
)
191201
end
@@ -294,6 +304,8 @@ function _append_storage_data_to_indices(connection, table_name)
294304
asset.capacity,
295305
asset_commission.investment_limit,
296306
asset_commission.storage_loss_from_stored_energy,
307+
asset_commission.storage_charging_efficiency,
308+
asset_commission.storage_discharging_efficiency,
297309
asset_milestone.initial_storage_level,
298310
asset_milestone.storage_inflows,
299311
inflows_profile.profile_name AS inflows_profile_name,

src/create-model.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,11 @@ function create_model(
152152

153153
@timeit to "add_hub_constraints!" add_hub_constraints!(model, constraints)
154154

155-
@timeit to "add_conversion_constraints!" add_conversion_constraints!(model, constraints)
155+
@timeit to "add_conversion_constraints!" add_conversion_constraints!(
156+
connection,
157+
model,
158+
constraints,
159+
)
156160

157161
@timeit to "add_transport_constraints!" add_transport_constraints!(
158162
connection,

src/data-preparation.jl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,6 @@ function _append_given_durations(appender, row, durations)
195195
if haskey(row, :rep_period)
196196
DuckDB.append(appender, row.rep_period)
197197
end
198-
if haskey(row, :efficiency)
199-
DuckDB.append(appender, row.efficiency)
200-
end
201198
if haskey(row, :capacity_coefficient)
202199
DuckDB.append(appender, row.capacity_coefficient)
203200
end
@@ -279,7 +276,6 @@ function create_unrolled_partition_tables!(connection)
279276
rep_periods_data.rep_period,
280277
COALESCE(frpp.specification, 'uniform') AS specification,
281278
COALESCE(frpp.partition::string, '1') AS partition,
282-
flow_commission.efficiency,
283279
flow_commission.capacity_coefficient,
284280
flow_commission.conversion_coefficient,
285281
rep_periods_data.num_timesteps,
@@ -351,7 +347,6 @@ function create_unrolled_partition_tables!(connection)
351347
to_asset STRING,
352348
year INT,
353349
rep_period INT,
354-
efficiency DOUBLE,
355350
capacity_coefficient DOUBLE,
356351
conversion_coefficient DOUBLE,
357352
time_block_start INT,

0 commit comments

Comments
 (0)