Skip to content

Commit

Permalink
135 include all assets (#161)
Browse files Browse the repository at this point in the history
* WIP: first update in the formulation

* Update the formulation, first draft

* Change the markdown to latex command

* Update formulation with bounds for flows associated to assets

* Updated input data

* Update documentation

* Updated the schema to include new parameters

* Updated schema for different efficiency

* Updated data with efficiency

* Implement all constraints from the mathematical formulation (#1)

* Change code and input data to have the flows with names instead of id

* Change the variable cost data from the assets to the flows

* Fix model funtion to create it properly with the new constraints

* Update solution of the tiny example

* Add write_lp_file option in the creation of the model

* Fix Julia files format

* Add all assets types in the sets structure

* Changes in the model and input to include new assets data

* Update tiny case study data files

* Update tiny case test result and output file

* Update Norse case study input data files

* Change the flow capacity to import/export capacity to set flows bounds

* Update formulation in the documentation with latest changes

* Add test for Norse case study

* Changes to cover all the options in test for the Norse case study

* Changes according to review comments

---------

Co-authored-by: datejada <[email protected]>
Co-authored-by: Abel Soares Siqueira <[email protected]>
  • Loading branch information
3 people authored Oct 24, 2023
1 parent 7f8a48b commit 4e5bbdd
Show file tree
Hide file tree
Showing 12 changed files with 2,340 additions and 2,023 deletions.
153 changes: 121 additions & 32 deletions docs/src/mathematical-formulation.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,75 +5,164 @@ The full mathematical formulation is also freely available in the [preprint](htt

## [Sets](@id math-sets)

NOTE: Asset types are mutually exclusive.
Name|Description|Elements
---|---|---:
$\mathcal{A}$ | Energy assets | $a \in \mathcal{A}$
$\mathcal{A_c}$ | Consumer energy assets | $\mathcal{A_c} \subseteq \mathcal{A}$
$\mathcal{A_p}$ | Producer energy assets | $\mathcal{A_p} \subseteq \mathcal{A}$
$\mathcal{A_i}$ | Energy assets with investment method | $\mathcal{A_i} \subseteq \mathcal{A}$
$\mathcal{A_b}$ | Energy assets with balance method | $\mathcal{A_b} \subseteq \mathcal{A}$
$\mathcal{RP}$ | Representative periods | $rp \in \mathcal{RP}$
$\mathcal{K}$ | Time steps within the $rp$ | $k \in \mathcal{K}$
$\mathcal{F}$ | Flow connections between two assets | $f \in \mathcal{F}$
$\mathcal{F_{rec}}(a)$ | Set of flows with receiving asset $a$ | $\mathcal{F_{rec}}(a) \subseteq \mathcal{F}$
$\mathcal{F_{snd}}(a)$ | Set of flows with sending asset $a$ | $\mathcal{F_{snd}}(a) \subseteq \mathcal{F}$
$\mathcal{A}$ | Energy assets | $a \in \mathcal{A}$
$\mathcal{A}_c$ | Consumer energy assets | $\mathcal{A}_c \subseteq \mathcal{A}$
$\mathcal{A}_p$ | Producer energy assets | $\mathcal{A}_p \subseteq \mathcal{A}$
$\mathcal{A}_s$ | Storage energy assets | $\mathcal{A}_s \subseteq \mathcal{A}$
$\mathcal{A}_h$ | Hub energy assets (e.g., transshipment) | $\mathcal{A}_h \subseteq \mathcal{A}$
$\mathcal{A}_{cv}$ | Conversion energy assets | $\mathcal{A}_{cv}\subseteq \mathcal{A}$
$\mathcal{A}_i$ | Energy assets with investment method | $\mathcal{A}_i \subseteq \mathcal{A}$
$\mathcal{F}$ | Flow connections between two assets | $f \in \mathcal{F}$
$\mathcal{F}_t$ | Transport flow between two assets | $\mathcal{F}_t \subseteq \mathcal{F}$
$\mathcal{F}_i$ | Transport flow with investment method | $\mathcal{F}_i \subseteq \mathcal{F}_t$
$\mathcal{F}_{in}(a)$ | Set of flows going into asset $a$ | $\mathcal{F}_{in}(a) \subseteq \mathcal{F}$
$\mathcal{F}_{out}(a)$ | Set of flows going out of asset $a$ | $\mathcal{F}_{out}(a) \subseteq \mathcal{F}$
$\mathcal{RP}$ | Representative periods | $rp \in \mathcal{RP}$
$\mathcal{K}$ | Time steps within the $rp$ | $k \in \mathcal{K}$

## [Parameters](@id math-parameters)

Name|Description|Units
---|---|---
$p^{investment\_cost}_{a}$ | Investment cost of asset units | [kEUR/MW/year]
$p^{variable\_cost}_{a}$ | Variable cost of asset units | [kEUR/MWh]
$p^{unit\_capacity}_{a}$ | Capacity of asset units | [MW]
$p^{rp\_weight}_{rp}$ | Representative period weight | [h]
$p^{profile}_{a,rp, k}$ | Asset production/consumption profile | [p.u.]
$p^{peak\_demand}_{a}$ | Peak demand | [MW]
$p^{init\_capacity}_{a}$ | initial capacity of asset units | [MW]
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.]

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

Name|Description|Units
---|---|---
$v^{flow}_{f,rp,k} \in \mathbb{R}$ | Flow between two assets |[MW]
$v^{investment}_{a} \in \mathbb{Z^{+}}$| Number of installed asset units |[units]
Name|Domain|Description|Units
---|---|---|---
$v^{flow}_{f,rp,k} \in \mathbb{R}$ | $\mathcal{F,RP,K}$ | Flow between two assets |[MW]
$v^{investment}_{a} \in \mathbb{Z}^{+}$| $\mathcal{A}_i$ | Number of installed asset units |[units]
$v^{investment}_{f} \in \mathbb{Z}^{+}$| $\mathcal{F}_i$ | Number of installed units between two assets |[units]
$s^{level}_{a,rp,k} \in \mathbb{R}$ | $\mathcal{A_s,RP,K}$ | Storage level |[MWh]

## [Objective Function](@id math-objective-function)

Objective function:

```math
\text{{minimize}} \quad investment\_cost + variable\_cost
\begin{aligned}
\text{{minimize}} \quad & assets\_investment\_cost + flows\_investment\_cost \\
& + flows\_variable\_cost
\end{aligned}
```

Where:

```math
\begin{aligned}
investment\_cost &= \sum_{a \in \mathcal{Ai}} p^{investment\_cost}_a \cdot p^{unit\_capacity}_a \cdot v^{investment}_a \\
variable\_cost &= \sum_{a \in \mathcal{Ap}} \sum_{f \in \mathcal{F_{snd}}(a)} \sum_{rp \in \mathcal{RP}} \sum_{k \in \mathcal{K}} p^{rp\_weight}_{rp} \cdot p^{variable\_cost}_a \cdot v^{flow}_{f,rp,k}
assets\_investment\_cost &= \sum_{a \in \mathcal{Ai}} p^{investment\_cost}_a \cdot p^{unit\_capacity}_a \cdot v^{investment}_a \\
flows\_investment\_cost &= \sum_{f \in \mathcal{Fi}} p^{investment\_cost}_f \cdot p^{unit\_capacity}_f \cdot v^{investment}_f \\
flows\_variable\_cost &= \sum_{f \in \mathcal{F}} \sum_{rp \in \mathcal{RP}} \sum_{k \in \mathcal{K}} p^{rp\_weight}_{rp} \cdot p^{variable\_cost}_f \cdot v^{flow}_{f,rp,k}
\end{aligned}
```

## [Constraints](@id math-constraints)

### Balance Constraint
### Balancing Contraints for Asset Type

#### Constraints for Consumers Energy Assets $\mathcal{A}_c$

```math
\begin{aligned}
\sum_{f \in \mathcal{F}_{in}(a)} v^{flow}_{f,rp,k} - \sum_{f \in \mathcal{F}_{out}(a)} v^{flow}_{f,rp,k} \left\{\begin{array}{l} = \\ \geqslant \\ \leqslant \end{array}\right\} p^{profile}_{a,rp,k} \cdot p^{peak\_demand}_{a} \quad \forall a \in \mathcal{A}_c, \forall rp \in \mathcal{RP},\forall k \in \mathcal{K}
\end{aligned}
```

#### Constraints for Storage Energy Assets $\mathcal{A}_s$

```math
\begin{aligned}
s_{a,rp,k}^{level} = s_{a,rp,k-1}^{level} + p_{a,rp,k}^{inflow} + \cdot \sum_{f \in \mathcal{F}_{in}(a)} p^{eff}_f \cdot v^{flow}_{f,rp,k} - \sum_{f \in \mathcal{F}_{out}(a)} \frac{1}{p^{eff}_f} \cdot v^{flow}_{f,rp,k} \quad \forall a \in \mathcal{A}_s, \forall rp \in \mathcal{RP},\forall k \in \mathcal{K}
\end{aligned}
```

#### Constraints for Hub Energy Assets $\mathcal{A}_h$

```math
\begin{aligned}
\sum_{f \in \mathcal{F}_{in}(a)} v^{flow}_{f,rp,k} = \sum_{f \in \mathcal{F}_{out}(a)} v^{flow}_{f,rp,k} \quad \forall a \in \mathcal{A}_h, \forall rp \in \mathcal{RP},\forall k \in \mathcal{K}
\end{aligned}
```

#### Constraints for Conversion Energy Assets $\mathcal{A}_{cv}$

```math
\begin{aligned}
\sum_{f \in \mathcal{F}_{in}(a)} p^{eff}_f \cdot {v^{flow}_{f,rp,k}} = \sum_{f \in \mathcal{F}_{out}(a)} \frac{v^{flow}_{f,rp,k}}{p^{eff}_f} \quad \forall a \in \mathcal{A}_{cv}, \forall rp \in \mathcal{RP},\forall k \in \mathcal{K}
\end{aligned}
```

### Constraints that Define Bounds of Flows Related to Energy Assets $\mathcal{A}$

#### Contraint for the Overall Output Flows from an Asset

```math
\begin{aligned}
\sum_{f \in \mathcal{F}_{out}(a)} v^{flow}_{f,rp,k} \leq p^{profile}_{a,rp,k} \cdot \left(p^{init\_capacity}_{a} + p^{unit\_capacity}_a \cdot v^{investment}_a \right) \quad \forall a \in \mathcal{A}_{cv} \cup \mathcal{A_{s}} \cup \mathcal{A_{p}}, \forall rp \in \mathcal{RP},\forall k \in \mathcal{K}
\end{aligned}
```

#### Contraint for the Overall Input Flows from an Asset

```math
\begin{aligned}
\sum_{f \in \mathcal{F}_{in}(a)} v^{flow}_{f,rp,k} \leq p^{profile}_{a,rp,k} \cdot \left(p^{init\_capacity}_{a} + p^{unit\_capacity}_a \cdot v^{investment}_a \right) \quad \forall a \in \mathcal{A_{s}}, \forall rp \in \mathcal{RP},\forall k \in \mathcal{K}
\end{aligned}
```

#### Upper Bound Constraint for Associated with Asset

```math
\begin{aligned}
\sum_{f \in \mathcal{F_{rec}}(a)} v^{flow}_{f,rp,k} - \sum_{f \in \mathcal{F_{snd}}(a)} v^{flow}_{f,rp,k} = p^{profile}_{a,rp,k} \cdot p^{peak\_demand}_{a} \quad \forall a \in \mathcal{A_b}, \forall rp \in \mathcal{RP},\forall k \in \mathcal{K}
v^{flow}_{f,rp,k} \leq p^{profile}_{a,rp,k} \cdot \left(p^{init\_capacity}_{a} + p^{unit\_capacity}_a \cdot v^{investment}_a \right) \quad \forall a \notin \mathcal{A}_h, \forall f \in \mathcal{F}_{out}(a), \forall rp \in \mathcal{RP},\forall k \in \mathcal{K}
\end{aligned}
```

### Upper Bound Constraint for Flows
#### Lower Bound Constraint Flows Associated with Asset

```math
v^{flow}_{f,rp,k} \geq 0 \quad \forall f \notin \mathcal{F}_t, \forall rp \in \mathcal{RP}, \forall k \in \mathcal{k}
```

### Constraints that Define Bounds for a Transport Flow $\mathcal{F}_t$

#### Upper Bound Constraint for Transport Flows

```math
\begin{aligned}
v^{flow}_{f,rp,k} \leq p^{profile}_{a,rp,k} \cdot \left(p^{init\_capacity}_{a} + p^{unit\_capacity}_a \cdot v^{investment}_a \right) \quad \forall a \in \mathcal{Ap}, \forall f \in \mathcal{F_{snd}}(a), \forall rp \in \mathcal{RP},\forall k \in \mathcal{K}
v^{flow}_{f,rp,k} \leq p^{profile}_{f,rp,k} \cdot \left(p^{init\_capacity}_{f} + p^{export\_capacity}_f \cdot v^{investment}_f \right) \quad \forall f \in \mathcal{F}_t, \forall rp \in \mathcal{RP},\forall k \in \mathcal{K}
\end{aligned}
```

### Lower Bound Constraint for Flows
#### Lower Bound Constraint for Transport Flows

```math
\begin{aligned}
v^{flow}_{f,rp,k} \geq p^{profile}_{f,rp,k} \cdot \left(p^{init\_capacity}_{f} + p^{import\_capacity}_f \cdot v^{investment}_f \right) \quad \forall f \in \mathcal{F}_t, \forall rp \in \mathcal{RP},\forall k \in \mathcal{K}
\end{aligned}
```

### Extra Constraints for Energy Storage Assets $\mathcal{A}_s$

#### Upper and Lower Bound Constraints for Storage Level

```math
v^{flow}_{f,rp,k} \geq 0 \quad \forall f \in \mathcal{F}, \forall rp \in \mathcal{RP}, \forall k \in \mathcal{k}
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}
```
46 changes: 25 additions & 21 deletions src/input_tables.jl
Original file line number Diff line number Diff line change
@@ -1,44 +1,48 @@
struct AssetData
id::Int # Asset ID
name::String # Name of Asset (geographical?)
type::String # Producer/Consumer - maybe an enum?
active::Bool # Active or decomissioned
investable::Bool # Whether able to invest
variable_cost::Float64 # kEUR/MWh
investment_cost::Float64 # kEUR/MW/year
capacity::Float64 # MW
initial_capacity::Float64 # MW
peak_demand::Float64 # MW
id::Int # Asset ID
name::String # Name of Asset (geographical?)
type::String # Producer/Consumer - maybe an enum?
active::Bool # Active or decomissioned
investable::Bool # Whether able to invest
investment_cost::Float64 # kEUR/MW/year
capacity::Float64 # MW
initial_capacity::Float64 # MW
peak_demand::Float64 # MW
initial_storage_capacity::Float64 # MWh
energy_to_power_ratio::Float64 # Hours
end

struct FlowData
id::Int # Flow ID
carrier::String # (Optional?) Energy carrier
from_asset_id::Int # Asset ID
to_asset_id::Int # Asset ID
from_asset::String # Name of Asset
to_asset::String # Name of Asset
active::Bool # Active or decomissioned
is_transport::Bool # Whether a transport flow
investable::Bool # Whether able to invest
variable_cost::Float64 # kEUR/MWh
investment_cost::Float64 # kEUR/MW/year
capacity::Float64 # MW
export_capacity::Float64 # MW
import_capacity::Float64 # MW
initial_capacity::Float64 # MW
efficiency::Float64 # p.u. (per unit)
end

struct FlowProfiles
id::Int # Flow ID
rep_period_id::Int
time_step::Int
value::Float64 # p.u.
rep_period_id::Int # Representative period ID
time_step::Int # Time step ID
value::Float64 # p.u. (per unit)
end

struct AssetProfiles
id::Int # Asset ID
rep_period_id::Int
time_step::Int
value::Float64 # p.u.
rep_period_id::Int # Representative period ID
time_step::Int # Time step ID
value::Float64 # p.u. (per unit)
end

struct RepPeriodData
id::Int
weight::Float64
id::Int # Representative period ID
weight::Float64 # Hours
end
Loading

0 comments on commit 4e5bbdd

Please sign in to comment.