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

Add initial storage level and storage inflows #239

Merged
merged 5 commits into from
Nov 8, 2023
Merged
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
39 changes: 24 additions & 15 deletions docs/src/mathematical-formulation.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,23 @@ NOTE: Asset types are mutually exclusive.

Name|Domain|Description|Units
---|---|---|---
$p^{investment\_cost}_{a}$ | $\mathcal{A}_i$ | Investment cost of asset units | [kEUR/MW/year]
$p^{unit\_capacity}_{a}$ | $\mathcal{A}$ | Capacity of asset units | [MW]
$p^{peak\_demand}_{a}$ | $\mathcal{A}_c$ | Peak demand | [MW]
$p^{init\_capacity}_{a}$ | $\mathcal{A}$ | Initial capacity of asset units | [MW]
$p^{investment\_cost}_{f}$ | $\mathcal{F}_i$ | Investment cost of flow connections | [kEUR/MW/year]
$p^{variable\_cost}_{f}$ | $\mathcal{F}$ | Variable cost of flow connections | [kEUR/MWh]
$p^{unit\_capacity}_{f}$ | $\mathcal{F}$ | Capacity of flow connections | [MW]
$p^{init\_capacity}_{f}$ | $\mathcal{F}$ | Initial capacity of flow connections | [MW]
$p^{export\_capacity}_{f}$ | $\mathcal{F}_t$ | Export capacity of flow connections | [MW]
$p^{import\_capacity}_{f}$ | $\mathcal{F}_t$ | Import capacity of flow connections | [MW]
$p^{rp\_weight}_{rp}$ | $\mathcal{RP}$ | Representative period weight | [h]
$p^{profile}_{a,rp,k}$ | $\mathcal{A,RP,K}$ | Asset profile | [p.u.]
$p^{profile}_{f,rp,k}$ | $\mathcal{F,RP,K}$ | Flow connections profile | [p.u.]
$p^{ene\_to\_pow\_ratio}_a$| $\mathcal{A}_s$ | Energy to power ratio | [h]
$p^{eff}_f$ | $\mathcal{F}$ | Flow efficiency | [p.u.]
$p^{investment\_cost}_{a}$ | $\mathcal{A}_i$ | Investment cost of asset units | [kEUR/MW/year]
$p^{unit\_capacity}_{a}$ | $\mathcal{A}$ | Capacity of asset units | [MW]
$p^{peak\_demand}_{a}$ | $\mathcal{A}_c$ | Peak demand | [MW]
$p^{init\_capacity}_{a}$ | $\mathcal{A}$ | Initial capacity of asset units | [MW]
$p^{investment\_cost}_{f}$ | $\mathcal{F}_i$ | Investment cost of flow connections | [kEUR/MW/year]
$p^{variable\_cost}_{f}$ | $\mathcal{F}$ | Variable cost of flow connections | [kEUR/MWh]
$p^{unit\_capacity}_{f}$ | $\mathcal{F}$ | Capacity of flow connections | [MW]
$p^{init\_capacity}_{f}$ | $\mathcal{F}$ | Initial capacity of flow connections | [MW]
$p^{export\_capacity}_{f}$ | $\mathcal{F}_t$ | Export capacity of flow connections | [MW]
$p^{import\_capacity}_{f}$ | $\mathcal{F}_t$ | Import capacity of flow connections | [MW]
$p^{rp\_weight}_{rp}$ | $\mathcal{RP}$ | Representative period weight | [h]
$p^{profile}_{a,rp,k}$ | $\mathcal{A,RP,K}$ | Asset profile | [p.u.]
$p^{profile}_{f,rp,k}$ | $\mathcal{F,RP,K}$ | Flow connections profile | [p.u.]
$p^{ene\_to\_pow\_ratio}_a$ | $\mathcal{A}_s$ | Energy to power ratio | [h]
$p^{init\_storage\_level}_{a}$ | $\mathcal{A}_s$ | Initial storage level | [MWh]
$p^{inflow}_{a}$ | $\mathcal{A}_s$ | Energy storage inflows | [MWh]
$p^{eff}_f$ | $\mathcal{F}$ | Flow efficiency | [p.u.]

## [Variables](@id math-variables)

Expand Down Expand Up @@ -177,3 +179,10 @@ v^{flow}_{f,rp,k} \geq p^{profile}_{f,rp,k} \cdot \left(p^{init\_capacity}_{f} +
0 \leq s_{a,rp,k}^{level} \leq p^{init\_storage\_capacity}_{a} + p^{ene\_to\_pow\_ratio}_a \cdot p^{unit\_capacity}_a \cdot v^{investment}_a \quad
\\ \\ \forall a \in \mathcal{A}_s, \forall rp \in \mathcal{RP},\forall k \in \mathcal{K}
```

#### Cycling Constraints for Storage Level

```math
s_{a,rp,k=K}^{level} \geq p^{init\_storage\_level}_{a} \quad
\\ \\ \forall a \in \mathcal{A}_s, \forall rp \in \mathcal{RP}
```
1 change: 1 addition & 0 deletions src/input-tables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ struct AssetData
initial_capacity::Float64 # MW
peak_demand::Float64 # MW
initial_storage_capacity::Float64 # MWh
initial_storage_level::Float64 # MWh
energy_to_power_ratio::Float64 # Hours
end

Expand Down
3 changes: 3 additions & 0 deletions src/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,12 @@ function create_parameters_and_sets_from_file(input_folder::AbstractString)

# Parameters for storage
initial_storage_capacity = Dict{String,Float64}()
initial_storage_level = Dict{String,Float64}()
energy_to_power_ratio = Dict{String,Float64}()
for row in eachrow(assets_data_df)
if row.name in assets_storage
initial_storage_capacity[row.name] = row.initial_storage_capacity
initial_storage_level[row.name] = row.initial_storage_level
energy_to_power_ratio[row.name] = row.energy_to_power_ratio
end
end
Expand Down Expand Up @@ -134,6 +136,7 @@ function create_parameters_and_sets_from_file(input_folder::AbstractString)
flows_is_transport = flows_is_transport,
peak_demand = peak_demand,
initial_storage_capacity = initial_storage_capacity,
initial_storage_level = initial_storage_level,
energy_to_power_ratio = energy_to_power_ratio,
rp_weight = rp_weight,
rp_resolution = rp_resolution,
Expand Down
34 changes: 25 additions & 9 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 ∈ As∩Ai],
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]] : 0.0) +
(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,20 +243,21 @@ 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 ∈ As∩Ai],
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)]],
storage_level[a, rp, B] ≤
params.initial_storage_capacity[a] + (a ∈ Ai ? energy_limit[a] : 0.0)
)

# - cycling condition for storage level
for a ∈ As, rp ∈ RP
set_lower_bound(
storage_level[a, rp, P[(a, rp)][end]],
params.initial_storage_level[a],
)
end

if write_lp_file
write_to_file(model, "model.lp")
end
Expand Down
48 changes: 24 additions & 24 deletions test/inputs/Norse/assets-data.csv
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
,,{producer;consumer;storage;hub;conversion},{true;false},{true;false},kEUR/MWh,kEUR/MW/year,MW,MW,MW,MW/unit,MW/unit,MW,MW,MWh,h,kEUR/MW/year,year,0
id,name,type,active,investable,variable_cost,investment_cost,capacity,initial_capacity,peak_demand,charging_capacity,discharging_capacity,initial_charging_capacity,initial_discharging_capacity,initial_storage_capacity,energy_to_power_ratio,fixed_cost,lifetime,efficiency
1,Asgard_Battery,storage,true,true,0.003,300,10,0,0,1,1,0,0,0,100,3,10,0
2,Asgard_Solar,producer,true,true,0.001,350,100,0,0,0,0,0,0,0,0,8,25,0
3,Asgard_E_demand,consumer,true,false,0,0,0,0,65787.17792,0,0,0,0,0,0,0,0,0
4,Asgard_CCGT,conversion,true,true,0.0015,650,500,0,0,0,0,0,0,0,0,10,30,0.6
5,G_imports,producer,true,false,0.08,0,0,75000,0,0,0,0,0,0,0,0,0,0
6,Midgard_Wind,producer,true,true,0.002,1300,3,0,0,0,0,0,0,0,0,15,25,0
7,Midgard_Hydro,storage,true,false,0.0012,1600,0,250,0,3,3,0,0,4000,0,16,50,0
8,Midgard_Nuclear_SMR,producer,true,true,0.015,6000,150,1000,0,0,0,0,0,0,0,101,60,0
9,Midgard_E_imports,producer,true,false,0.02,0,0,500,0,0,0,0,0,0,0,0,0,0
10,Midgard_CCGT,conversion,true,true,0.0015,650,500,0,0,0,0,0,0,0,0,10,30,0.6
11,Midgard_E_demand,consumer,true,false,0,0,0,0,19604.76443,0,0,0,0,0,0,0,0,0
12,Valhalla_H2_generator,conversion,true,true,0,479,100,0,0,0,0,0,0,0,0,10,20,0.6
13,Valhalla_H2_storage,storage,true,true,0,0.1,500,0,0,3,3,0,0,0,10000,0.005,50,0
14,Valhalla_H2_demand,consumer,true,false,0,0,0,0,745.735,0,0,0,0,0,0,0,0,0
15,Valhalla_Electrolyser,conversion,true,true,0,1260,100,500,0,0,0,0,0,0,0,60,25,0.704
16,Valhalla_E_balance,hub,true,false,0,0,0,0,0,0,0,0,0,0,0,0,0,0
17,Valhalla_E_exports,consumer,true,false,0.09,0,0,0,50,0,0,0,0,0,0,0,0,0
18,Valhalla_Fuel_cell,conversion,true,true,0,800,100,0,0,0,0,0,0,0,0,40,25,0.5
19,Valhalla_Heat_pump,conversion,true,true,0,300,100,0,0,0,0,0,0,0,0,15,20,4
20,Valhalla_Waste_heat,producer,true,false,0.0025,1450,200,0,0,0,0,0,0,0,0,0,30,0
21,Valhalla_Heat_demand,consumer,true,false,0,0,0,0,3548.42445,0,0,0,0,0,0,0,0,0
22,Valhalla_GT,conversion,true,true,0.0015,400,500,0,0,0,0,0,0,0,0,3.85,30,0.6
,,{producer;consumer;storage;hub;conversion},{true;false},{true;false},kEUR/MWh,kEUR/MW/year,MW,MW,MW,MW/unit,MW/unit,MW,MW,MWh,MWh,h,kEUR/MW/year,year,0
id,name,type,active,investable,variable_cost,investment_cost,capacity,initial_capacity,peak_demand,charging_capacity,discharging_capacity,initial_charging_capacity,initial_discharging_capacity,initial_storage_capacity,initial_storage_level,energy_to_power_ratio,fixed_cost,lifetime,efficiency
1,Asgard_Battery,storage,true,true,0.003,300,10,0,0,1,1,0,0,0,0,100,3,10,0
2,Asgard_Solar,producer,true,true,0.001,350,100,0,0,0,0,0,0,0,0,0,8,25,0
3,Asgard_E_demand,consumer,true,false,0,0,0,0,65787.17792,0,0,0,0,0,0,0,0,0,0
4,Asgard_CCGT,conversion,true,true,0.0015,650,500,0,0,0,0,0,0,0,0,0,10,30,0.6
5,G_imports,producer,true,false,0.08,0,0,75000,0,0,0,0,0,0,0,0,0,0,0
6,Midgard_Wind,producer,true,true,0.002,1300,3,0,0,0,0,0,0,0,0,0,15,25,0
7,Midgard_Hydro,storage,true,false,0.0012,1600,0,250,0,3,3,0,0,4000,2000,0,16,50,0
8,Midgard_Nuclear_SMR,producer,true,true,0.015,6000,150,1000,0,0,0,0,0,0,0,0,101,60,0
9,Midgard_E_imports,producer,true,false,0.02,0,0,500,0,0,0,0,0,0,0,0,0,0,0
10,Midgard_CCGT,conversion,true,true,0.0015,650,500,0,0,0,0,0,0,0,0,0,10,30,0.6
11,Midgard_E_demand,consumer,true,false,0,0,0,0,19604.76443,0,0,0,0,0,0,0,0,0,0
12,Valhalla_H2_generator,conversion,true,true,0,479,100,0,0,0,0,0,0,0,0,0,10,20,0.6
13,Valhalla_H2_storage,storage,true,true,0,0.1,500,0,0,3,3,0,0,0,0,10000,0.005,50,0
14,Valhalla_H2_demand,consumer,true,false,0,0,0,0,745.735,0,0,0,0,0,0,0,0,0,0
15,Valhalla_Electrolyser,conversion,true,true,0,1260,100,500,0,0,0,0,0,0,0,0,60,25,0.704
16,Valhalla_E_balance,hub,true,false,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
17,Valhalla_E_exports,consumer,true,false,0.09,0,0,0,50,0,0,0,0,0,0,0,0,0,0
18,Valhalla_Fuel_cell,conversion,true,true,0,800,100,0,0,0,0,0,0,0,0,0,40,25,0.5
19,Valhalla_Heat_pump,conversion,true,true,0,300,100,0,0,0,0,0,0,0,0,0,15,20,4
20,Valhalla_Waste_heat,producer,true,false,0.0025,1450,200,0,0,0,0,0,0,0,0,0,0,30,0
21,Valhalla_Heat_demand,consumer,true,false,0,0,0,0,3548.42445,0,0,0,0,0,0,0,0,0,0
22,Valhalla_GT,conversion,true,true,0.0015,400,500,0,0,0,0,0,0,0,0,0,3.85,30,0.6
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
Loading
Loading