`EnergyModelsBase.EnergyModelsBase`

— ModuleMain module for `EnergyModelsBase`

a framework for building flexible energy system models.

It exports several types and associated functions for accessing fields. In addition, all required functions for creaeting and running the model are exported.

You can find the exported types and functions below or on the pages *Constraint functions* and *Data functions*.

`EnergyModelsBase.UnionCapacity`

— Type`UnionCapacity`

Union for simpler dispatching for storage parameters that include a capacity.

`EnergyModelsBase.UnionOpexFixed`

— Type`UnionOpexFixed`

Union for simpler dispatching for storage parameters that include fixed OPEX.

`EnergyModelsBase.UnionOpexVar`

— Type`UnionOpexVar`

Union for simpler dispatching for storage parameters that include variable OPEX.

`EnergyModelsBase.AbstractStorageParameters`

— Type`AbstractStorageParameters`

as supertype for individual parameters for `Storage`

nodes.

Storage parameters are used to provide the user the flexibility to include or not include capacities and variable and fixed OPEX parameters for charging, the storage level, and discharging.

`EnergyModelsBase.Accumulating`

— Type`Accumulating`

as supertype for an accumulating storage level.

Accumulating storage behaviour implies that the change in the overall storage level in a strategic period can be both positive or negative.

Examples for potential usage of `Accumulating`

are CO₂ storages in which the CO₂ is permanently stored or multi year hydropower magazines.

`EnergyModelsBase.AccumulatingEmissions`

— Type`AccumulatingEmissions <: Accumulating`

`StorageBehavior`

which accumulates all inflow witin a strategic period. `AccumulatingEmissions`

allows as well to serve as a `ResourceEmit`

emission point to represent a soft constraint on storing the captured emissions.

`EnergyModelsBase.Availability`

— Type`Availability`

node as routing node.

`EnergyModelsBase.CaptureData`

— Type`CaptureData`

as supertype for all `EmissionsData`

that include CO₂ capture.

`EnergyModelsBase.CaptureEnergyEmissions`

— TypeCapture the energy usage related emissions, but not the process emissions. Does not require `emissions`

as input, but can be supplied.

**Fields**

: emissions per unit produced.`emissions::Dict{ResourceEmit, T}`

is the CO₂ capture rate.`co2_capture::Float64`

`EnergyModelsBase.CaptureProcessEmissions`

— TypeCapture the process emissions, but not the energy usage related emissions.

**Fields**

: emissions per unit produced.`emissions::Dict{ResourceEmit, T}`

is the CO₂ capture rate.`co2_capture::Float64`

`EnergyModelsBase.CaptureProcessEnergyEmissions`

— TypeCapture both the process emissions and the energy usage related emissions.

**Fields**

: emissions per unit produced.`emissions::Dict{ResourceEmit, T}`

is the CO₂ capture rate.`co2_capture::Float64`

`EnergyModelsBase.Cyclic`

— Type`Cyclic`

as supertype for a cyclic storage level.

Cyclic storage behaviour implies that the change in the overall storage level in a strategic period behaves cyclic.

`EnergyModelsBase.CyclicPeriods`

— Type`CyclicPeriods{S<:NothingPeriod}`

Contains information for calculating the cyclic constraints. The parameter `S`

should be either an `AbstractStrategicPeriod`

or `AbstractRepresentativePeriod`

.

**Fields**

the last period in the case of`last_per::S`

`S<:AbstractRepresentativePeriod`

or the current period in the case of`S<:AbstractStrategicPeriod`

as the last strategic period is not relevant.the current period in both the case of`current_per::S`

`S<:AbstractRepresentativePeriod`

and`S<:AbstractStrategicPeriod`

.

`EnergyModelsBase.CyclicRepresentative`

— Type`CyclicRepresentative <: Cyclic`

`StorageBehavior`

in which cyclic behaviour is achieved within the lowest time structure excluding operational times.

In the case of `TwoLevel{SimpleTimes}`

, this approach is similar to `CyclicStrategic`

.

In the case of `TwoLevel{RepresentativePeriods{SimpleTimes}}`

, this approach differs from `CyclicStrategic`

as the cyclic constraint is enforeced within each representative period.

`EnergyModelsBase.CyclicStrategic`

— Type`CyclicStrategic <: Cyclic`

`StorageBehavior`

in which the the cyclic behaviour is achieved within a strategic period. This implies that the initial level in individual representative periods can be different when using `RepresentativePeriods`

.

`EnergyModelsBase.Data`

— TypeAbstract type used to define concrete struct containing the package specific elements to add to the composite type defined in this package.

`EnergyModelsBase.Direct`

— Type`Direct <: Link`

A direct link between two nodes.

**Fields**

is the name/identifier of the link.`id`

is node from which there is flow into the link.`from::Node`

is node to which there is flow out of the link.`to::Node`

is the used formulation of links. If not specified, a`formulation::Formulation`

`Linear`

link is assumed.

`EnergyModelsBase.EmissionsData`

— Type`EmissionsData`

as supertype for all `Data`

types for emissions.

`EnergyModelsBase.EmissionsEnergy`

— TypeNo capture, no process emissions are present. Does not require `co2_capture`

or `emissions`

as input, but accepts it and will ignore it, if provided.

`EnergyModelsBase.EmissionsProcess`

— TypeNo capture, but process emissions are present. Does not require `co2_capture`

as input, but accepts it and will ignore it, if provided.

**Fields**

: emissions per unit produced.`emissions::Dict{ResourceEmit, T}`

`EnergyModelsBase.EmptyData`

— TypeEmpty composite type for `Data`

`EnergyModelsBase.EnergyModel`

— TypeAbstract type for differentation between types of models (investment, operational, ...).

`EnergyModelsBase.Formulation`

— TypeDeclaration of the general type for formulation of links.

`EnergyModelsBase.GenAvailability`

— TypeA reference `Availability`

node.

**Fields**

is the name/identifier of the node.`id`

are the input`inputs::Vector{<:Resource}`

`Resource`

s.are the output`output::Vector{<:Resource}`

`Resource`

s.

A constructor is provided so that only a single array can be provided with the fields:

is the name/identifier of the node.`id`

are the`𝒫::Vector{<:Resource}`

`Resource`

s.

`EnergyModelsBase.Linear`

— TypeLinear `Formulation`

, that is input equals output.

`EnergyModelsBase.Link`

— TypeDeclaration of the general type for links connecting nodes.

`EnergyModelsBase.NetworkNode`

— Type`NetworkNode`

node with both input and output.

`EnergyModelsBase.Node`

— Type`Node`

as supertype for all technologies.

`EnergyModelsBase.OperationalModel`

— TypeOperational Energy Model without investments.

**Fields**

is a dictionary with individual emission limits as`emission_limit::Dict{<:ResourceEmit, <:TimeProfile}`

`TimeProfile`

for each emission resource`ResourceEmit`

.are the prices for the different emissions types considered.`emission_price::Dict{<:ResourceEmit, <:TimeProfile}`

is a`co2_instance`

`ResourceEmit`

and corresponds to the type used for CO₂.

`EnergyModelsBase.PreviousPeriods`

— Type`PreviousPeriods{S<:NothingPeriod, T<:NothingPeriod, U<:NothingPeriod}`

Contains the previous strategic, representative, and operational period used through the application of the `with_prev`

iterator developed in `TimeStruct`

.

**Fields**

the previous strategic period.`sp::S`

the previous representative period.`rp::T`

the previous operational period.`op::U`

`EnergyModelsBase.RefNetworkNode`

— TypeA reference `NetworkNode`

node.

**Fields**

is the name/identifier of the node.`id`

is the installed capacity.`cap::TimeProfile`

is the variable operating expense per energy unit produced.`opex_var::TimeProfile`

is the fixed operating expense.`opex_fixed::TimeProfile`

are the input`input::Dict{<:Resource, <:Real}`

`Resource`

s with conversion value`Real`

.are the generated`output::Dict{<:Resource, <:Real}`

`Resource`

s with conversion value`Real`

.is the additional data (e.g. for investments). The field`data::Vector{Data}`

`data`

is conditional through usage of a constructor.

`EnergyModelsBase.RefSink`

— TypeA reference `Sink`

node.

This node corresponds to a demand given by the field `cap`

.

**Fields**

is the name/identifier of the node.`id`

is the Demand.`cap::TimeProfile`

are penalties for surplus or deficits. Requires the fields`penalty::Dict{Any, TimeProfile}`

`:surplus`

and`:deficit`

.are the input`input::Dict{<:Resource, <:Real}`

`Resource`

s with conversion value`Real`

.is the additional data (e.g. for investments). The field`data::Vector{Data}`

`data`

is conditional through usage of a constructor.

`EnergyModelsBase.RefSource`

— TypeA reference `Source`

node.

**Fields**

is the name/identifier of the node.`id`

is the installed capacity.`cap::TimeProfile`

is the variable operating expense per energy unit produced.`opex_var::TimeProfile`

is the fixed operating expense.`opex_fixed::TimeProfile`

are the generated`output::Dict{<:Resource, <:Real}`

`Resource`

s with conversion value`Real`

.is the additional data (e.g. for investments). The field`data::Vector{Data}`

`data`

is conditional through usage of a constructor.

`EnergyModelsBase.RefStorage`

— TypeA reference `Storage`

node.

This node is designed to store either a `ResourceCarrier`

or a `ResourceEmit`

. It is designed as a parametric type through the type parameter `T`

to differentiate between different cyclic behaviours. Note that the parameter `T`

is only used for dispatching, but does not carry any other information. Hence, it is simple to fast switch between different `StorageBehavior`

s.

The current implemented cyclic behaviours are `CyclicRepresentative`

, `CyclicStrategic`

, and `AccumulatingEmissions`

.

**Fields**

is the name/identifier of the node.`id`

are the charging parameters of the`charge::AbstractStorageParameters`

`Storage`

node. Depending on the chosen type, the charge parameters can include variable OPEX, fixed OPEX, and/or a capacity.are the level parameters of the`level::AbstractStorageParameters`

`Storage`

node. Depending on the chosen type, the charge parameters can include variable OPEX and/or fixed OPEX.is the stored`stor_res::Resource`

`Resource`

.are the input`input::Dict{<:Resource, <:Real}`

`Resource`

s with conversion value`Real`

.are the generated`output::Dict{<:Resource, <:Real}`

`Resource`

s with conversion value`Real`

. Only relevant for linking and the stored`Resource`

.is the additional data (e.g. for investments). The field`data::Vector{<:Data}`

`data`

is conditional through usage of a constructor.

`EnergyModelsBase.RefStorage`

— Method```
RefStorage(
id,
rate_cap::TimeProfile,
stor_cap::TimeProfile,
opex_var::TimeProfile,
opex_fixed::TimeProfile,
stor_res::ResourceCarrier,
input::Dict{<:Resource,<:Real},
output::Dict{<:Resource,<:Real},
data::Vector,
)
```

Legacy constructor for a `RefStorage{ResourceCarrier}`

. This version will be discontinued in the near future and replaced with the new version of `RefStorage{StorageBehavior}`

in which the parametric input defines the behaviour of the storage.

See the *documentation* for further information regarding how you can translate your existing model to the new model.

`EnergyModelsBase.RefStorage`

— Method```
RefStorage(
id,
rate_cap::TimeProfile,
stor_cap::TimeProfile,
opex_var::TimeProfile,
opex_fixed::TimeProfile,
stor_res::ResourceEmit,
input::Dict{<:Resource,<:Real},
output::Dict{<:Resource,<:Real},
data::Vector,
)
```

Legacy constructor for a `RefStorage{ResourceEmit}`

. This version will be discontinued in the near future and replaced with the new version of `RefStorage{StorageBehavior}`

in which the parametric input defines the behaviour of the storage.

See the *documentation* for further information regarding how you can translate your existing model to the new model.

`EnergyModelsBase.Resource`

— TypeGeneral resource supertype to be used for the declaration of subtypes.

`EnergyModelsBase.ResourceCarrier`

— Type`ResourceCarrier{T<:Real} <: Resource`

Resources that can be transported and converted. These resources cannot be included as resources that are emitted, *e.g*, in the variable `emissions_strategic`

.

**Fields**

is the name/identifyer of the resource.`id`

is the the CO₂ intensity,`co2_int::T`

*e.g.*, t/MWh.

`EnergyModelsBase.ResourceEmit`

— Type`ResourceEmit{T<:Real} <: Resource`

Resources that can can be emitted (e.g., CO₂, CH₄, NOₓ).

These resources can be included as resources that are emitted, *e.g*, in the variable `emissions_strategic`

.

**Fields**

is the name/identifyer of the resource.`id`

is the the CO₂ intensity,`co2_int::T`

*e.g.*, t/MWh.

`EnergyModelsBase.Sink`

— Type`Sink`

node with only input.

`EnergyModelsBase.Source`

— Type`Source`

node with only output.

`EnergyModelsBase.StorCap`

— Type`StorCap <: AbstractStorageParameters`

A storage parameter type for including only a capacity. This implies that neither the usage of the `Storage`

, nor the installed capacity have a direct impact on the objective function.

**Fields**

is the installed capacity.`capacity::TimeProfile`

`EnergyModelsBase.StorCapOpex`

— Type`StorCapOpex <: AbstractStorageParameters`

A storage parameter type for including a capacity as well as variable and fixed operational expenditures.

**Fields**

is the installed capacity.`capacity::TimeProfile`

is the variable operating expense per energy unit.`opex_var::TimeProfile`

is the fixed operating expense.`opex_fixed::TimeProfile`

`EnergyModelsBase.StorCapOpexFixed`

— Type`StorCapOpexFixed <: AbstractStorageParameters`

A storage parameter type for including a capacity and fixed operational expenditures. This implies that the installed capacity has no direct impact on the objective function.

**Fields**

is the installed capacity.`capacity::TimeProfile`

is the fixed operating expense.`opex_fixed::TimeProfile`

`EnergyModelsBase.StorCapOpexVar`

— Type`StorCap <: AbstractStorageParameters`

A storage parameter type for including a capacity and variable operational expenditures. This implies that the installed capacity has no direct impact on the objective function.

**Fields**

is the installed capacity.`capacity::TimeProfile`

is the variable operating expense per energy unit.`opex_var::TimeProfile`

`EnergyModelsBase.StorOpexVar`

— Type`StorCap <: AbstractStorageParameters`

A storage parameter type for including variable operational expenditures. This implies that the charge or discharge rate do not have a capacity and the `Storage`

level can be used within a single `TimePeriod`

.

This type can only be used for the fields `charge`

and `discharge`

.

**Fields**

is the variable operating expense per energy unit.`opex_var::TimeProfile`

`EnergyModelsBase.Storage`

— Type`Storage`

node with level.

`EnergyModelsBase.StorageBehavior`

— Type`StorageBehavior`

as supertype for individual storage behaviours.

Storage behaviour is used to identify how a storage node should behave within the individual `TimeStructure`

s of a strategic period.

`EnergyModelsBase.capacity`

— Method`capacity(stor_par::AbstractStorageParameters, t)`

Returns the capacity of storage parameter `stor_par`

at operational period `t`

. The individual storage parameters of a `Storage`

node can be accessed through the functions `charge(n)`

, `level(n)`

, and `discharge(n)`

.

`EnergyModelsBase.capacity`

— Method`capacity(stor_par::AbstractStorageParameters)`

Returns the capacity of storage parameter `stor_par`

as `TimeProfile`

. The individual storage parameters of a `Storage`

node can be accessed through the functions `charge(n)`

, `level(n)`

, and `discharge(n)`

.

`EnergyModelsBase.capacity`

— Method`capacity(n::Node, t)`

Returns the capacity of a node `n`

at operational period `t`

. The capacity is not directly defined for `Storage`

nodes. Instead, it is necessary to call the function on the respective field, see `capacity(stor_par::AbstractStorageParameters, t)`

.

`EnergyModelsBase.capacity`

— Method`capacity(n::Node)`

Returns the capacity of a node `n`

as `TimeProfile`

. The capacity is not directly defined for `Storage`

nodes. Instead, it is necessary to call the function on the respective field, see `capacity(stor_par::AbstractStorageParameters)`

.

`EnergyModelsBase.charge`

— Method`charge(n::Storage)`

Returns the parameter type of the `charge`

field of the node. If the node has no field `charge`

, it returns `nothing`

.

`EnergyModelsBase.check_case_data`

— Method`check_case_data(case)`

Checks the `case`

dictionary is in the correct format.

**Checks**

- The dictionary requires the keys
`:T`

,`:nodes`

,`:links`

, and`:products`

. - The individual keys are of the correct type, that is
`:T::TimeStructure`

,`:nodes::Vector{<:Node}`

,`:links::Vector{<:Link}`

, and`:products::Vector{<:Resource}`

.

`EnergyModelsBase.check_data`

— Method`check_data(case, modeltype, check_timeprofiles::Bool)`

Check if the case data is consistent. Use the `@assert_or_log`

macro when testing. Currently only checking node data.

`EnergyModelsBase.check_fixed_opex`

— Method`check_fixed_opex(n, 𝒯ᴵⁿᵛ, check_timeprofiles::Bool)`

Checks that the fixed opex value follows the given `TimeStructure`

. This check requires that a function `opex_fixed(n)`

is defined for the input `n`

which returns a `TimeProfile`

.

**Checks**

- The
`opex_fixed`

time profile cannot have a finer granulation than`StrategicProfile`

.

**Conditional checks (if check_timeprofiles=true)**

- The profiles in
`opex_fixed`

have to have the same length as the number of strategic periods.

`EnergyModelsBase.check_model`

— Method`check_model(case, modeltype::EnergyModel, check_timeprofiles::Bool)`

Checks the `modeltype`

.

**Checks**

- All
`ResourceEmit`

s require a corresponding value in the field`emission_limit`

. - The
`emission_limit`

time profiles cannot have a finer granulation than`StrategicProfile`

. - The
`emission_price`

time profiles cannot have a finer granulation than`StrategicProfile`

.

**Conditional checks (if check_timeprofiles=true)**

- The profiles in
`emission_limit`

have to have the same length as the number of strategic periods. - The profiles in
`emission_price`

have to have the same length as the number of strategic

periods.

`EnergyModelsBase.check_node`

— Method`check_node(n::Availability, 𝒯, modeltype::EnergyModel)`

This method checks that an `Availability`

node is valid. By default, that does not include any checks.

`EnergyModelsBase.check_node`

— Method`check_node(n::Node, 𝒯, modeltype::EnergyModel)`

Check that the fields of a `Node`

corresponds to required structure.

`EnergyModelsBase.check_node`

— Method`check_node(n::NetworkNode, 𝒯, modeltype::EnergyModel)`

This method checks that a `NetworkNode`

node is valid.

These checks are always performed, if the user is not creating a new method. Hence, it is important that a new `NetworkNode`

type includes at least the same fields as in the `RefNetworkNode`

node or that a new `NetworkNode`

type receives a new method for `check_node`

.

**Checks**

- The field
`cap`

is required to be non-negative. - The values of the dictionary
`input`

are required to be non-negative. - The values of the dictionary
`output`

are required to be non-negative. - The value of the field
`fixed_opex`

is required to be non-negative and accessible through a`StrategicPeriod`

as outlined in the function`check_fixed_opex(n, 𝒯ᴵⁿᵛ, check_timeprofiles)`

.

`EnergyModelsBase.check_node`

— Method`check_node(n::Sink, 𝒯, modeltype::EnergyModel)`

This method checks that a `Sink`

node is valid.

These checks are always performed, if the user is not creating a new method. Hence, it is important that a new `Sink`

type includes at least the same fields as in the `RefSink`

node or that a new `Source`

type receives a new method for `check_node`

.

**Checks**

- The field
`cap`

is required to be non-negative. - The values of the dictionary
`input`

are required to be non-negative. - The dictionary
`penalty`

is required to have the keys`:deficit`

and`:surplus`

. - The sum of the values
`:deficit`

and`:surplus`

in the dictionary`penalty`

has to be non-negative to avoid an infeasible model.

`EnergyModelsBase.check_node`

— Method`check_node(n::Source, 𝒯, modeltype::EnergyModel)`

This method checks that a `Source`

node is valid.

These checks are always performed, if the user is not creating a new method. Hence, it is important that a new `Source`

type includes at least the same fields as in the `RefSource`

node or that a new `Source`

type receives a new method for `check_node`

.

**Checks**

- The field
`cap`

is required to be non-negative. - The values of the dictionary
`output`

are required to be non-negative. - The value of the field
`fixed_opex`

is required to be non-negative and accessible through a`StrategicPeriod`

as outlined in the function`check_fixed_opex(n, 𝒯ᴵⁿᵛ, check_timeprofiles)`

.

`EnergyModelsBase.check_node`

— Method`check_node(n::Storage, 𝒯, modeltype::EnergyModel)`

This method checks that a `Storage`

node is valid.

These checks are always performed, if the user is not creating a new method. Hence, it is important that a new `Storage`

type includes at least the same fields as in the `RefStorage`

node or that a new `Storage`

type receives a new method for `check_node`

.

**Checks**

- The
`TimeProfile`

of the field`capacity`

in the type in the field`charge`

is required to be non-negative if the chosen composite type has the field`capacity`

. - The
`TimeProfile`

of the field`capacity`

in the type in the field`level`

is required to be non-negative`. - The
`TimeProfile`

of the field`capacity`

in the type in the field`discharge`

is required to be non-negative if the chosen composite type has the field`capacity`

. - The
`TimeProfile`

of the field`fixed_opex`

is required to be non-negative and accessible through a`StrategicPeriod`

as outlined in the function`check_fixed_opex(n, 𝒯ᴵⁿᵛ, check_timeprofiles)`

for the chosen composite type . - The values of the dictionary
`input`

are required to be non-negative. - The values of the dictionary
`output`

are required to be non-negative.

`EnergyModelsBase.check_node_data`

— Method`check_node_data(n::Node, data::Data, 𝒯, modeltype::EnergyModel, check_timeprofiles::Bool)`

Check that the included `Data`

types of a `Node`

corresponds to required structure. This function will always result in a multiple error message, if several instances of the same supertype is loaded.

`EnergyModelsBase.check_node_data`

— Method`check_node_data(n::Node, data::EmissionsData, 𝒯, modeltype::EnergyModel, check_timeprofiles::Bool)`

Check that the included `Data`

types of a `Node`

corresponds to required structure. This function will always result in a multiple error message, if several instances of the same supertype is loaded.

**Checks**

- Each node can only have a single
`EmissionsData`

. - Time profiles for process emissions, if present.
- The value of the field
`co2_capture`

is required to be in the range $[0, 1]$, if`CaptureData`

is used.

`EnergyModelsBase.check_profile`

— Method`check_profile(fieldname, value::TimeProfile, ts::TimeStructure, sp)`

Check that an individual `TimeProfile`

corresponds to the time structure `ts`

in strategic period `sp`

. The function flow is designed to provide errors in all situations in which the the `TimeProfile`

does not correspond to the chosen `TimeStructure`

through the application of the `@assert_or_log`

macro.

Examples for inconsistent combinations:

```
ts = SimpleTimes(3, 1)
# A too long OperationalProfile resulting in omitting the last 2 values
value = OperationalProfile([1, 2, 3, 4, 5])
# A too short OperationalProfile resulting in repetition of the last value once
value = OperationalProfile([1, 2])
```

If you use a more detailed TimeProfile than the TimeStructure, it will you provide you with a warning, e.g., using `RepresentativeProfile`

without `RepresentativePeriods`

.

It currently does not include support for identifying `OperationalProfile`

s.

`EnergyModelsBase.check_profile`

— Method`check_profile(fieldname, value::TimeProfile, 𝒯)`

Check that an individual `TimeProfile`

corresponds to the time structure `𝒯`

. It currently does not include support for identifying `OperationalScenarios`

.

`EnergyModelsBase.check_representative_profile`

— Method`check_representative_profile(time_profile::TimeProfile, message::String)`

Function for checking that an individual `TimeProfile`

does not include the wrong type for representative periods indexing

**Input**

`time_profile`

- The time profile that should be checked.`message`

- A message that should be printed after the type of profile.

**Checks**

`TimeProfile`

s access in`RepresentativePeriod`

s cannot include`OperationalProfile`

or`ScenarioProfile`

as this is not allowed through indexing on the`TimeProfile`

.

`EnergyModelsBase.check_scenario_profile`

— Method`check_scenario_profile(time_profile::TimeProfile, message::String)`

Function for checking that an individual `TimeProfile`

does not include the wrong type for scenario indexing

**Checks**

`TimeProfile`

s access in`RepresentativePeriod`

s cannot include`OperationalProfile`

or`ScenarioProfile`

as this is not allowed through indexing on the`TimeProfile`

.

`EnergyModelsBase.check_strategic_profile`

— Method`check_strategic_profile(time_profile::TimeProfile, message::String)`

Function for checking that an individual `TimeProfile`

does not include the wrong type for strategic indexing

**Checks**

`TimeProfile`

s access in`StrategicPeriod`

s cannot include`OperationalProfile`

,`ScenarioProfile`

, or`RepresentativeProfile`

as this is not allowed through indexing on the`TimeProfile`

.

`EnergyModelsBase.check_time_structure`

— Method`check_time_structure(n::Node, 𝒯)`

Check that all fields of a `Node`

that are of type `TimeProfile`

correspond to the time structure `𝒯`

.

`EnergyModelsBase.co2_capture`

— Method`co2_capture(data::CaptureData)`

Returns the CO₂ capture rate of the `data`

.

`EnergyModelsBase.co2_instance`

— Method`co2_instance(model::EnergyModel)`

Returns the CO₂ instance used in modelling.

`EnergyModelsBase.co2_int`

— Method`co2_int(p::Resource)`

Returns the CO₂ intensity of resource `p`

`EnergyModelsBase.collect_types`

— Method`collect_types(types_list)`

Return a Dict of all the give types_list and their supertypes. The keys in the dictionary are the types, and their corresponding value is the number in the type hierarchy.

E.g., `Node`

is at the top and will thus have the value 1. Types just below `Node`

will have value 2, and so on.

`EnergyModelsBase.compile_logs`

— Method`compile_logs(case, log_by_element)`

Simple method for showing all log messages.

`EnergyModelsBase.constraints_capacity`

— Method`constraints_capacity(m, n::Node, 𝒯::TimeStructure, modeltype::EnergyModel)`

Function for creating the constraint on the maximum capacity of a generic `Node`

. This function serves as fallback option if no other function is specified for a `Node`

.

`EnergyModelsBase.constraints_capacity`

— Method`constraints_capacity(m, n::Sink, 𝒯::TimeStructure, modeltype::EnergyModel)`

Function for creating the constraint on the maximum capacity of a generic `Sink`

. This function serves as fallback option if no other function is specified for a `Sink`

.

`EnergyModelsBase.constraints_capacity`

— Method`constraints_capacity(m, n::Storage, 𝒯::TimeStructure, modeltype::EnergyModel)`

Function for creating the constraint on the maximum level of a generic `Storage`

. This function serves as fallback option if no other function is specified for a `Storage`

.

`EnergyModelsBase.constraints_capacity_installed`

— Method`constraints_capacity_installed(m, n, 𝒯::TimeStructure, modeltype::EnergyModel)`

Constrain the installed capacity to the available capacity.

This function should only be used to dispatch on the modeltype for providing investments. If you create new capacity variables, it is beneficial to include as well a method for this function and the corresponding node types.

`EnergyModelsBase.constraints_data`

— Method`constraints_data(m, n::Node, 𝒯, 𝒫, modeltype, data::Data)`

Fallback option when data is specified, but it is not desired to add the constraints through this function. This is, e.g., the case for `EnergyModelsInvestments`

as the capacity constraint has to be replaced

`EnergyModelsBase.constraints_data`

— Method`constraints_data(m, n::Node, 𝒯, 𝒫, modeltype, data::DataEmissions)`

Constraints functions for calculating both the emissions and amount of CO₂ captured in the process.

There exist several configurations:

: Only energy usage related emissions.`EmissionsEnergy`

: Both process and energy usage related emissions.`EmissionsProcess`

: Capture of energy usage related emissions, can include process emissions.`CaptureEnergyEmissions`

: Capture of process emissions.`CaptureProcessEmissions`

: Capture of both process and energy usage related`CaptureProcessEnergyEmissions`

emissions.

`EnergyModelsBase.constraints_emissions`

— Method`constraints_emissions(m, 𝒩, 𝒯, 𝒫, modeltype::EnergyModel)`

Create constraints for the emissions accounting for both operational and strategic periods.

`EnergyModelsBase.constraints_flow_in`

— Method`constraints_flow_in(m, n, 𝒯::TimeStructure, modeltype::EnergyModel)`

Function for creating the constraint on the inlet flow to a generic `Node`

. This function serves as fallback option if no other function is specified for a `Node`

.

`EnergyModelsBase.constraints_flow_in`

— Method`constraints_flow_in(m, n::Storage, 𝒯::TimeStructure, modeltype::EnergyModel)`

Function for creating the constraint on the inlet flow to a generic `Storage`

. This function serves as fallback option if no other function is specified for a `Storage`

.

`EnergyModelsBase.constraints_flow_in`

— Method`constraints_flow_in(m, n::Storage, 𝒯::TimeStructure, modeltype::EnergyModel)`

Create the constraint on the inlet flow to a generic `Storage`

. This function serves as fallback option if no other function is specified for a `Storage`

.

`EnergyModelsBase.constraints_flow_out`

— Method`constraints_flow_out(m, n::Node, 𝒯::TimeStructure, modeltype::EnergyModel)`

Function for creating the constraint on the outlet flow from a generic `Node`

. This function serves as fallback option if no other function is specified for a `Node`

.

`EnergyModelsBase.constraints_flow_out`

— Method`constraints_flow_out(m, n::Storage, 𝒯::TimeStructure, modeltype::EnergyModel)`

Function for creating the constraint on the outlet flow from a generic `Storage`

. This function serves as fallback option if no other function is specified for a `Storage`

.

`EnergyModelsBase.constraints_level`

— Method`constraints_level(m, n::Storage, 𝒯, 𝒫, modeltype::EnergyModel)`

Function for creating the level constraint for a reference storage node with a `ResourceCarrier`

resource.

`EnergyModelsBase.constraints_level_aux`

— Method`constraints_level_aux(m, n::RefStorage{S}, 𝒯, 𝒫, modeltype::EnergyModel)`

Function for creating the Δ constraint for the level of a reference storage node with a `ResourceEmit`

resource.

`EnergyModelsBase.constraints_level_aux`

— Method`constraints_level_aux(m, n::Storage, 𝒯, 𝒫, modeltype::EnergyModel)`

Create the Δ constraint for the level of a reference storage node with a `ResourceCarrier`

resource.

`EnergyModelsBase.constraints_level_bounds`

— Method```
constraints_level_bounds(
m,
n::Storage,
t::TS.TimePeriod,
cyclic_pers::CyclicPeriods{<:TS.AbstractRepresentativePeriod},
modeltype::EnergyModel,
)
```

When representative periods are used and the previous operational period is `nothing`

, then bounds are incorporated to avoid that the initial level storage level is violating the maximum and minimum level.

`EnergyModelsBase.constraints_level_bounds`

— Method```
constraints_level_bounds(
m,
n::Storage,
t::TS.TimePeriod,
prev_pers::TS.TimePeriod,
modeltype::EnergyModel,
)
```

Provides bounds on the initial storage level in an operational period to account for the level being modelled at the end of the operational periods.

The default approach is to not provide bounds.

`EnergyModelsBase.constraints_level_iterate`

— Method```
constraints_level_iterate(
m,
n::Storage,
prev_pers::PreviousPeriods,
per,
ts::OperationalScenarios,
modeltype::EnergyModel,
)
```

In the case of `OperationalScenarios`

, this is achieved through calling the function `constraints_level_scp`

. In the default case, no constraints are added.

`EnergyModelsBase.constraints_level_iterate`

— Method```
constraints_level_iterate(
m,
n::Storage,
prev_pers::PreviousPeriods,
cyclic_pers::CyclicPeriods,
per,
ts::RepresentativePeriods,
modeltype::EnergyModel,
)
```

Iterate through the individual time structures of a `Storage`

node. This iteration function should in general allow for all necessary functionality for incorporating modifications.

In the case of `RepresentativePeriods`

, this is achieved through calling the function `constraints_level_rp`

to introduce, *e.g.*, cyclic constraints as it is in the default case.

`EnergyModelsBase.constraints_level_iterate`

— Method```
constraints_level_iterate(
m,
n::Storage,
prev_pers::PreviousPeriods,
per,
ts::SimpleTimes,
modeltype::EnergyModel,
)
```

In the case of `SimpleTimes`

, the iterator function is at its lowest level. In this situation,the previous level is calculated using the function `previous_level`

and used for the storage balance. The the approach for calculating the `previous_level`

is depending on the types in the parameteric type `PreviousPeriods`

.

In addition, additional bounds can be included on the initial level within an operational period.

`EnergyModelsBase.constraints_level_rp`

— Method`constraints_level_rp(m, n::Storage, per, modeltype::EnergyModel)`

Provides additional contraints for representative periods.

The default approach is to set the total change in all representative periods within a strategic period to 0. This implies that the `Storage`

node cannot accumulate energy between individual strategic periods.

`EnergyModelsBase.constraints_level_rp`

— Method`constraints_level_rp(m, n::Storage{<:Accumulating}, per, modeltype::EnergyModel)`

When a `Storage{<:Accumulating}`

is used, the cyclic constraint for restricting the level change within a strategic period to 0 (through setting the sum of `:stor_level_Δ_rp`

within a strategic period to 0) is not implemented as accumulation within a strategic period is desirable.

This implies that `Accumulating`

behaviours require the developer to introduce the function `previous_level`

in the case of `prev_pers = PreviousPeriods{<:NothingPeriod, Nothing, Nothing}`

.

`EnergyModelsBase.constraints_level_rp`

— Method`constraints_level_rp(m, n::Storage{CyclicRepresentative}, per, modeltype::EnergyModel)`

When a `Storage{CyclicRepresentative}`

is used, the change in the representative period is constrained to 0.

`EnergyModelsBase.constraints_level_scp`

— Method`constraints_level_scp(m, n::Storage, per, modeltype::EnergyModel)`

Provides additional constraints for scenario periods.

The default approach is to not provide any constraints.

`EnergyModelsBase.constraints_level_scp`

— Method`constraints_level_scp(m, n::Storage{CyclicRepresentative}, per, modeltype::EnergyModel)`

When a Storage{CyclicRepresentative} is used, the final level in an operational scenario is constrained to be the same in all operational scenarios.

`EnergyModelsBase.constraints_links`

— Method`constraints_links(m, 𝒩, 𝒯, 𝒫, ℒ, modeltype::EnergyModel)`

Call the function `create_link`

for link formulation

`EnergyModelsBase.constraints_node`

— Method`constraints_node(m, 𝒩, 𝒯, 𝒫, ℒ, modeltype::EnergyModel)`

Create link constraints for each `n ∈ 𝒩`

depending on its type and calling the function `create_node(m, n, 𝒯, 𝒫)`

for the individual node constraints.

Create constraints for fixed OPEX.

`EnergyModelsBase.constraints_opex_fixed`

— Method`constraints_opex_fixed(m, n::Node, 𝒯ᴵⁿᵛ, modeltype::EnergyModel)`

Function for creating the constraint on the fixed OPEX of a generic `Node`

. This function serves as fallback option if no other function is specified for a `Node`

.

`EnergyModelsBase.constraints_opex_fixed`

— Method`constraints_opex_fixed(m, n::Sink, 𝒯ᴵⁿᵛ, modeltype::EnergyModel)`

Function for creating the constraint on the fixed OPEX of a generic `Sink`

. This function serves as fallback option if no other function is specified for a `Sink`

.

`EnergyModelsBase.constraints_opex_fixed`

— Methodconstraints*opex*fixed(m, n::Storage, 𝒯ᴵⁿᵛ, modeltype::EnergyModel)

Function for creating the constraint on the fixed OPEX of a generic `Storage`

. This function serves as fallback option if no other function is specified for a `Storage`

.

The fallback option includes fixed OPEX for `charge`

, `level`

, and `discharge`

. The individual contributions are in all situations calculated based on the installed capacities.

`EnergyModelsBase.constraints_opex_var`

— Method`constraints_opex_var(m, n::Node, 𝒯ᴵⁿᵛ, modeltype::EnergyModel)`

Function for creating the constraint on the variable OPEX of a generic `Node`

. This function serves as fallback option if no other function is specified for a `Node`

.

`EnergyModelsBase.constraints_opex_var`

— Method`constraints_opex_var(m, n::Sink, 𝒯ᴵⁿᵛ, modeltype::EnergyModel)`

Function for creating the constraint on the variable OPEX of a generic `Sink`

. This function serves as fallback option if no other function is specified for a `Sink`

.

`EnergyModelsBase.constraints_opex_var`

— Method`constraints_opex_var(m, n::Storage, 𝒯ᴵⁿᵛ, modeltype::EnergyModel)`

Function for creating the constraint on the variable OPEX of a generic `Storage`

. This function serves as fallback option if no other function is specified for a `Storage`

.

`EnergyModelsBase.create_link`

— Method`create_link(m, 𝒯, 𝒫, l, formulation::Formulation)`

Set the constraints for a simple `Link`

(input = output). Can serve as fallback option for all unspecified subtypes of `Link`

.

`EnergyModelsBase.create_model`

— Method`create_model(case, modeltype::EnergyModel, m::JuMP.Model; check_timeprofiles::Bool=true)`

Create the model and call all required functions.

**Input**

`case`

- The case dictionary requiring the keys`:T`

,`:nodes`

,`:links`

, and`products`

. If the input is not provided in the correct form, the checks will identify the problem.`modeltype`

- Used modeltype, that is a subtype of the type`EnergyModel`

.`m`

- the empty`JuMP.Model`

instance. If it is not provided, then it is assumed that the input is a standard`JuMP.Model`

.

**Conditional input**

`check_timeprofiles=true`

- A boolean indicator whether the time profiles of the individual nodes should be checked or not. It is advised to not deactivate the check, except if you are testing new components. It may lead to unexpected behaviour and potential inconsistencies in the input data, if the time profiles are not checked.

`EnergyModelsBase.create_node`

— Method`create_node(m, n::Availability, 𝒯, 𝒫, modeltype::EnergyModel)`

Set all constraints for a `Availability`

. Can serve as fallback option for all unspecified subtypes of `Availability`

.

Availability nodes can be seen as routing nodes. It is not necessary to have more than one available node except if one wants to include as well transport between different `Availability`

nodes with associated costs (not implemented at the moment).

`EnergyModelsBase.create_node`

— Method`create_node(m, n::NetworkNode, 𝒯, 𝒫, modeltype::EnergyModel)`

Set all constraints for a `NetworkNode`

. Can serve as fallback option for all unspecified subtypes of `NetworkNode`

.

`EnergyModelsBase.create_node`

— Method`create_node(m, n::Sink, 𝒯, 𝒫, modeltype::EnergyModel)`

Set all constraints for a `Sink`

. Can serve as fallback option for all unspecified subtypes of `Sink`

.

`EnergyModelsBase.create_node`

— Method`create_node(m, n::Source, 𝒯, 𝒫, modeltype::EnergyModel)`

Set all constraints for a `Source`

. Can serve as fallback option for all unspecified subtypes of `Source`

.

`EnergyModelsBase.create_node`

— Method`create_node(m, n::Storage, 𝒯, 𝒫, modeltype::EnergyModel)`

Set all constraints for a `Storage`

. Can serve as fallback option for all unspecified subtypes of `Storage`

.

`EnergyModelsBase.current_per`

— Method`current_per(cyclic_pers::CyclicPeriods)`

Extracts the current period (fields `current_per`

) from a `CyclicPeriods`

type.

`EnergyModelsBase.deficit_penalty`

— Method`deficit_penalty(n::Sink, t)`

Returns the deficit penalty of sink `n`

at operational period `t`

`EnergyModelsBase.deficit_penalty`

— Method`deficit_penalty(n::Sink)`

Returns the deficit penalty of sink `n`

as `TimeProfile`

.

`EnergyModelsBase.discharge`

— Method`discharge(n::Storage)`

Returns the parameter type of the `discharge`

field of the node. If the node has no field `discharge`

, it returns `nothing`

.

`EnergyModelsBase.emission_limit`

— Method`emission_limit(model::EnergyModel, p::ResourceEmit, t_inv::TS.StrategicPeriod)`

Returns the emission limit of EnergyModel `model`

and ResourceEmit `p`

in strategic period period `t_inv`

.

`EnergyModelsBase.emission_limit`

— Method`emission_limit(model::EnergyModel, p::ResourceEmit)`

Returns the emission limit of EnergyModel `model`

and ResourceEmit `p`

as `TimeProfile`

.

`EnergyModelsBase.emission_limit`

— Method`emission_limit(model::EnergyModel)`

Returns the emission limit of EnergyModel `model`

as dictionary with `TimeProfile`

s for each `ResourceEmit`

.

`EnergyModelsBase.emission_price`

— Method`emission_price(model::EnergyModel, p::ResourceEmit, t_inv::TS.StrategicPeriod)`

Returns the emission price of EnergyModel `model`

and ResourceEmit `p`

in strategic period `t_inv`

. If no emission price is specified for the ResourceEmit `p`

, the function returns 0

`EnergyModelsBase.emission_price`

— Method`emission_price(model::EnergyModel, p::ResourceEmit)`

Returns the emission price of EnergyModel `model`

and ResourceEmit `p`

as `TimeProfile`

. If no emission price is specified for the ResourceEmit `p`

, the function returns 0

`EnergyModelsBase.emission_price`

— Method`emission_price(model::EnergyModel)`

Returns the emission price of EnergyModel `model`

as dictionary with `TimeProfile`

s for each `ResourceEmit`

.

`EnergyModelsBase.formulation`

— Method`formulation(l::Link)`

Return the formulation of a Link ´l´.

`EnergyModelsBase.has_charge`

— Method`has_charge(n::Storage)`

Returns logic whether the node has a `charge`

field allowing for restrictions and/or costs on the (installed) charging rate.

`EnergyModelsBase.has_charge_OPEX_fixed`

— Method`has_charge_OPEX_fixed(n::Storage)`

Returns logic whether the node has a `charge`

fixed OPEX contribution.

`EnergyModelsBase.has_charge_OPEX_var`

— Method`has_charge_OPEX_var(n::Storage)`

Returns logic whether the node has a `charge`

variable OPEX contribution.

`EnergyModelsBase.has_charge_cap`

— Method`has_charge_cap(n::Storage)`

Returns logic whether the node has a `charge`

capacity.

`EnergyModelsBase.has_discharge`

— Method`has_discharge(n::Storage)`

Returns logic whether the node has a `discharge`

field allowing for restrictions and/or costs on the (installed) discharging rate.

`EnergyModelsBase.has_discharge_OPEX_fixed`

— Method`has_discharge_OPEX_fixed(n::Storage)`

Returns logic whether the node has a `discharge`

fixed OPEX contribution.

`EnergyModelsBase.has_discharge_OPEX_var`

— Method`has_discharge_OPEX_var(n::Storage)`

Returns logic whether the node has a `discharge`

variable OPEX contribution.

`EnergyModelsBase.has_discharge_cap`

— Method`has_discharge_cap(n::Storage)`

Returns logic whether the node has a `discharge`

capacity.

`EnergyModelsBase.has_emissions`

— Method`has_emissions(n::Node)`

Checks whether the Node `n`

has emissions.

`EnergyModelsBase.has_input`

— Method`has_input(n::Node)`

Returns logic whether the node is an input node, i.e., `Sink`

and `NetworkNode`

nodes.

`EnergyModelsBase.has_level_OPEX_fixed`

— Method`has_level_OPEX_fixed(n::Storage)`

Returns logic whether the node has a `level`

fixed OPEX contribution.

`EnergyModelsBase.has_level_OPEX_var`

— Method`has_level_OPEX_var(n::Storage)`

Returns logic whether the node has a `level`

variable OPEX contribution.

`EnergyModelsBase.has_output`

— Method`has_output(n::Node)`

Returns logic whether the node is an output node, i.e., `Source`

and `NetworkNode`

nodes.

`EnergyModelsBase.inputs`

— Method`inputs(n::Node, p::Resource)`

Returns the value of an input resource `p`

of a node `n`

.

`EnergyModelsBase.inputs`

— Method`inputs(n::Node)`

Returns the input resources of a node `n`

. These resources are specified via the field `input`

.

`EnergyModelsBase.is_network_node`

— Method`is_network_node(n::Node)`

Checks, whether node `n`

is a `NetworkNode`

node

`EnergyModelsBase.is_resource_emit`

— Method`is_resource_emit(p::Resource)`

Checks whether the Resource `p`

is of type `ResourceEmit`

.

`EnergyModelsBase.is_sink`

— Method`is_sink(n::Node)`

Checks, whether node `n`

is a `Sink`

node

`EnergyModelsBase.is_source`

— Method`is_source(n::Node)`

Checks, whether node `n`

is a `Source`

node

`EnergyModelsBase.is_storage`

— Method`is_storage(n::Node)`

Checks, whether node `n`

is a `Storage`

node

`EnergyModelsBase.last_per`

— Method`last_per(cyclic_pers::CyclicPeriods)`

Extracts the last period (fields `last_per`

) from a `CyclicPeriods`

type.

`EnergyModelsBase.level`

— Method`level(n::Storage)`

Returns the parameter type of the `level`

field of the node.

`EnergyModelsBase.link_res`

— Method`link_res(l::Link)`

Return the resources transported for a given link `l`

.

`EnergyModelsBase.link_sub`

— Method`link_sub(ℒ::Vector{<:Link}, n::Node)`

Return connected links from the vector `ℒ`

for a given node `n`

as array. The first subarray corresponds to the `from`

field, while the second to the `to`

field.

`EnergyModelsBase.multiple`

— Method`multiple(t_inv, t)`

Provide a simplified function for returning the combination of the functions duration(t) * multiple*strat(t*inv, t) * probability(t)

`EnergyModelsBase.node_data`

— Method`node_data(n::Node)`

Returns the `Data`

array of node `n`

.

`EnergyModelsBase.nodes_emissions`

— Method`has_emissions(𝒩::Array{<:Node})`

Returns nodes that have emission data for a given Array `::Array{<:Node}`

.

`EnergyModelsBase.nodes_input`

— Method`nodes_input(𝒩::Array{<:Node}, sub)`

Returns nodes that have an input, i.e., `Sink`

and `NetworkNode`

nodes.

`EnergyModelsBase.nodes_not_av`

— Method`nodes_not_av(𝒩::Array{<:Node})`

Returns nodes that are not `Availability`

nodes for a given Array `𝒩::Array{<:Node}`

.

`EnergyModelsBase.nodes_not_sub`

— Function`nodes_not_sub(𝒩::Array{<:Node}, sub)`

Returns nodes that are not of type `sub`

for a given Array `𝒩::Array{<:Node}`

.

`EnergyModelsBase.nodes_output`

— Method`nodes_output(𝒩::Array{<:Node})`

Returns nodes that have an output, i.e., `Source`

and `NetworkNode`

nodes.

`EnergyModelsBase.nodes_sub`

— Function`nodes_sub(𝒩::Array{<:Node}, sub)`

Returns nodes that are of type `sub`

for a given Array `𝒩::Array{<:Node}`

.

`EnergyModelsBase.objective`

— Method`objective(m, 𝒩, 𝒯, 𝒫, modeltype::EnergyModel)`

Create the objective for the optimization problem for a given modeltype.

`EnergyModelsBase.op_per`

— Method`op_perop_per(prev_periods::PreviousPeriods)`

Extracts the previous operational period (fields `sp`

) from a `PreviousPeriods`

type.

`EnergyModelsBase.opex_fixed`

— Method`opex_fixed(n::Node, t_inv)`

Returns the fixed OPEX of a node `n`

at strategic period `t_inv`

. The fixed OPEX is not directly defined for `Storage`

nodes. Instead, it is necessary to call the function on the respective field, see `opex_fixed(stor_par::AbstractStorageParameters, t)`

.

`EnergyModelsBase.opex_fixed`

— Method`opex_fixed(n::Node)`

Returns the fixed OPEX of a node `n`

as `TimeProfile`

. The fixed OPEX is not directly defined for `Storage`

nodes. Instead, it is necessary to call the function on the respective field, see `opex_fixed(stor_par::AbstractStorageParameters)`

.

`EnergyModelsBase.opex_fixed`

— Method`opex_fixed(stor_par::UnionOpexFixed, t)`

Returns the fixed OPEX of storage parameter `stor_par`

at operational period `t`

. The individual storage parameters of a `Storage`

node can be accessed through the functions `charge(n)`

, `level(n)`

, and `discharge(n)`

.

`EnergyModelsBase.opex_fixed`

— Method`opex_fixed(stor_par::UnionOpexFixed)`

Returns the fixed OPEX of storage parameter `stor_par`

as `TimeProfile`

. The individual storage parameters of a `Storage`

node can be accessed through the functions `charge(n)`

, `level(n)`

, and `discharge(n)`

.

`EnergyModelsBase.opex_var`

— Method`opex_var(n::Node, t)`

Returns the variable OPEX of a node `n`

in operational period `t`

. The variable OPEX is not directly defined for `Storage`

nodes. Instead, it is necessary to call the function on the respective field, see `opex_var(stor_par::AbstractStorageParameters, t)`

.

`EnergyModelsBase.opex_var`

— Method`opex_var(n::Node)`

Returns the variable OPEX of a node `n`

as `TimeProfile`

. The variable OPEX is not directly defined for `Storage`

nodes. Instead, it is necessary to call the function on the respective field, see `opex_var(stor_par::AbstractStorageParameters)`

.

`EnergyModelsBase.opex_var`

— Method`opex_var(stor_par::UnionOpexVar, t)`

Returns the variable OPEX of storage parameter `stor_par`

at operational period `t`

. The individual storage parameters of a `Storage`

node can be accessed through the functions `charge(n)`

, `level(n)`

, and `discharge(n)`

.

`EnergyModelsBase.opex_var`

— Method`opex_var(stor_par::UnionOpexVar)`

Returns the variable OPEX of storage parameter `stor_par`

as `TimeProfile`

. The individual storage parameters of a `Storage`

node can be accessed through the functions `charge(n)`

, `level(n)`

, and `discharge(n)`

.

`EnergyModelsBase.outputs`

— Method`outputs(n::Node, p::Resource)`

Returns the value of an output resource `p`

of a node `n`

.

`EnergyModelsBase.outputs`

— Method`outputs(n::Node)`

Returns the output resources of a node `n`

. These resources are specified via the field `output`

.

`EnergyModelsBase.previous_level`

— Method```
previous_level(
m,
n::Storage,
prev_pers::PreviousPeriods,
cyclic_pers::CyclicPeriods,
modeltype::EnergyModel,
)
```

Returns the level used as previous level of a `Storage`

node depending on the type of `PreviousPeriods`

.

The basic functionality is used in the case when the previous operational period is a `TimePeriod`

, in which case it just returns the previous operational period.

`EnergyModelsBase.previous_level`

— Method```
previous_level(
m,
n::Storage,
prev_pers::PreviousPeriods{<:NothingPeriod, <:TS.AbstractRepresentativePeriod, Nothing},
cyclic_pers::CyclicPeriods,
modeltype::EnergyModel,
)
```

When the previous operational period is `Nothing`

, the previous representative period an `AbstractRepresentativePeriod`

and the last period is an `AbstractRepresentativePeriod`

, then the time structure *does* include `RepresentativePeriods`

.

The cyclic default constraints returns the value at the end of the *previous* representative period while accounting for the number of repetitions of the representative period.

`EnergyModelsBase.previous_level`

— Method```
previous_level(
m,
n::Storage,
prev_pers::PreviousPeriods{<:NothingPeriod, Nothing, Nothing},
cyclic_pers::CyclicPeriods,
modeltype::EnergyModel,
)
```

When the previous operational and representative period are `Nothing`

, the function returns the cyclic constraints within a strategic period. This is achieved through calling a subfunction `previous_level_sp`

to avoid method ambiguities.

`EnergyModelsBase.previous_level`

— Method```
previous_level(
m,
n::Storage,
prev_pers::PreviousPeriods{<:NothingPeriod, Nothing, Nothing},
cyclic_pers::CyclicPeriods,
modeltype::EnergyModel,
)
```

When the previous operational and representative period are `Nothing`

and the storage node is an `AccumulatingEmissions`

storage node, the function returns a value of 0.

`EnergyModelsBase.previous_level`

— Method```
previous_level(
m,
n::Storage{CyclicRepresentative},
prev_pers::PreviousPeriods{<:NothingPeriod, <:TS.AbstractRepresentativePeriod, Nothing},
cyclic_pers::CyclicPeriods,
modeltype::EnergyModel,
)
```

When the previous operational period is `Nothing`

and the previous representative period an `AbstractRepresentativePeriod`

then the time structure *does* include `RepresentativePeriods`

.

The cyclic constraint for a `CyclicRepresentative`

storage nodereturns the value at the end of the *current* representative period.

`EnergyModelsBase.previous_level_sp`

— Method```
previous_level_sp(
m,
n::Storage{<:Cyclic},
cyclic_pers::CyclicPeriods,
modeltype::EnergyModel
)
```

Returns the previous period in the case of the first operational period (in the first representative period) of a strategic period.

The default functionality in the case of a `Cyclic`

storage node in a `TimeStructure`

without `RepresentativePeriods`

returns the last operational period in the strategic period.

`EnergyModelsBase.previous_level_sp`

— Method```
previous_level_sp(
m,
n::Storage{CyclicRepresentative},
cyclic_pers::CyclicPeriods{<:TS.AbstractRepresentativePeriod},
modeltype::EnergyModel,
)
```

When a `CyclicRepresentative`

`Storage`

node is coupled with a `TimeStructure`

containing `RepresentativePeriods`

, then the function returns the previous level as the level at the end of the current representative period.

`EnergyModelsBase.previous_level_sp`

— Method```
previous_level_sp(
m,
n::Storage{CyclicStrategic},
cyclic_pers::CyclicPeriods{<:TS.AbstractRepresentativePeriod},
modeltype::EnergyModel,
)
```

When a `CyclicStrategic`

`Storage`

node is coupled with a `TimeStructure`

containing `RepresentativePeriods`

, then the function calculates the level at the beginning of the first representative period through the changes in the level in the last representative period.

`EnergyModelsBase.process_emissions`

— Method`process_emissions(data::EmissionsData)`

Returns the `ResourceEmit`

s that have process emissions in the `data`

.

`EnergyModelsBase.process_emissions`

— Method`process_emissions(data::EmissionsData{T}, p:ResourceEmit, t)`

Returns the the process emissions of resource `p`

in the `data`

at operational period t. If there are no process emissions, it returns a value of 0.

`EnergyModelsBase.process_emissions`

— Method`process_emissions(data::EmissionsData{T}, p::ResourceEmit)`

Returns the the process emissions of resource `p`

in the `data`

as `TimeProfile`

. If the process emissions are provided as `Float64`

, it returns a `FixedProfile(x)`

. If there are no process emissions, it returns a `FixedProfile(0)`

.

`EnergyModelsBase.rep_per`

— Method`rep_per(prev_periods::PreviousPeriods)`

Extracts the previous representative period (fields `sp`

) from a `PreviousPeriods`

type.

`EnergyModelsBase.res_em`

— Method`res_em(𝒫::Array{<:Resource})`

Returns all emission resources for a

- a given array
`::Array{<:Resource}`

.The output is in this case an`Array{<:Resource}`

- a given dictionary
`::Dict`

.The output is in this case a dictionary`Dict`

with the correct fields

`EnergyModelsBase.res_not`

— Method`res_not(𝒩::Array{<:Resource}, res_inst)`

Return all resources that are not `res_inst`

for

- a given array
`::Array{<:Resource}`

.The output is in this case an`Array{<:Resource}`

- a given dictionary
`::Dict`

.The output is in this case a dictionary`Dict`

with the correct fields

`EnergyModelsBase.res_sub`

— Function`res_sub(𝒫::Array{<:Resource}, sub = ResourceEmit)`

Return resources that are of type `sub`

for a given Array `::Array{Resource}`

.

`EnergyModelsBase.run_model`

— Method`run_model(case::Dict, model::EnergyModel, optimizer)`

Take the `case`

data as a dictionary and the `model`

and build and optimize the model. Returns the solved JuMP model.

The dictionary requires the keys:

`:nodes::Vector{Node}`

`:links::Vector{Link}`

`:products::Vector{Resource}`

`:T::TimeStructure`

`EnergyModelsBase.sort_types`

— Method`sort_types(types_list::Dict)`

Sort the result of `collect_types`

and return a vector where a supertype comes before all its subtypes.

`EnergyModelsBase.storage_resource`

— Method`storage_resource(n::Storage)`

Returns the storage resource of `Storage`

node `n`

.

`EnergyModelsBase.strat_per`

— Method`strat_per(prev_periods::PreviousPeriods)`

Extracts the previous strategic period (fields `sp`

) from a `PreviousPeriods`

type.

`EnergyModelsBase.surplus_penalty`

— Method`surplus_penalty(n::Sink, t)`

Returns the surplus penalty of sink `n`

at operational period `t`

`EnergyModelsBase.surplus_penalty`

— Method`surplus_penalty(n::Sink)`

Returns the surplus penalty of sink `n`

as `TimeProfile`

.

`EnergyModelsBase.variables_capacity`

— Method`variables_capacity(m, 𝒩, 𝒯, modeltype::EnergyModel)`

Declaration of different capacity variables for nodes `𝒩ⁿᵒᵗ`

that are neither `Storage`

nor `Availability`

nodes. These variables are:

`:cap_use`

- use of a technology node in each operational period and`:cap_inst`

- installed capacity in each operational period in terms of either`:flow_in`

or`:flow_out`

(depending on node`n ∈ 𝒩`

)

Declaration of different storage variables for `Storage`

nodes `𝒩ˢᵗᵒʳ`

. These variables are:

`:stor_level`

- storage level at the end of each operational period.`:stor_level_Δ_op`

- storage level change in each operational period.`:stor_level_Δ_rp`

- storage level change in each representative period.`:stor_level_inst`

- installed capacity for storage in each operational period, constrained in the operational case to the provided capacity in the storage parameters used in the field`:level`

.`:stor_charge_use`

- storage charging use in each operational period.`:stor_charge_inst`

- installed charging capacity, e.g. power, in each operational period, constrained in the operational case to the provided capacity in the storage parameters used in the field`:charge`

. This variable is only defined if the`Storage`

node has a field`charge.`

`:stor_discharge_use`

- storage discharging use in each operational period.`:stor_discharge_inst`

- installed charging capacity, e.g. power, in each operational period, constrained in the operational case to the provided capacity in the storage parameters used in the field`:discharge`

. This variable is only defined if the`Storage`

node has a field`discharge.`

`EnergyModelsBase.variables_capex`

— Method`variables_capex(m, 𝒩, 𝒯, 𝒫, modeltype::EnergyModel)`

Declaration of the CAPEX variables of the model for each investment period `𝒯ᴵⁿᵛ ∈ 𝒯`

. Empty for operational models but required for multiple dispatch in investment model.

`EnergyModelsBase.variables_emission`

— Method`variables_emission(m, 𝒩, 𝒯, 𝒫, modeltype::EnergyModel)`

Declaration of emission variables per technology node with emissions `n ∈ 𝒩ᵉᵐ`

and emission resource `𝒫ᵉᵐ ∈ 𝒫`

.

The emission variables are differentiated in:

`:emissions_node`

- emissions of a node in an operational period,`:emissions_total`

- total emissions in an operational period, and`:emissions_strategic`

- total strategic emissions, constrained to an upper limit based on the field`emission_limit`

of the`EnergyModel`

.

`EnergyModelsBase.variables_flow`

— Method`variables_flow(m, 𝒩, 𝒯, 𝒫, ℒ, modeltype::EnergyModel)`

Declaration of the individual input (`:flow_in`

) and output (`:flow_out`

) flowrates for each technological node `n ∈ 𝒩`

and link `l ∈ ℒ`

(`:link_in`

and `:link_out`

).

`EnergyModelsBase.variables_node`

— Method" variables_node(m, 𝒩ˢᵘᵇ::Vector{<:Node}, 𝒯, modeltype::EnergyModel)

Default fallback method when no function is defined for a node type.

`EnergyModelsBase.variables_node`

— Method`variables_node(m, 𝒩ˢⁱⁿᵏ::Vector{<:Sink}, 𝒯, modeltype::EnergyModel)`

Declaration of both surplus (`:sink_surplus`

) and deficit (`:sink_deficit`

) variables for `Sink`

nodes `𝒩ˢⁱⁿᵏ`

to quantify when there is too much or too little energy for satisfying the demand.

`EnergyModelsBase.variables_nodes`

— Method`variables_nodes(m, 𝒩, 𝒯, modeltype::EnergyModel)`

Loop through all node types and create variables specific to each type. This is done by calling the method `variables_node`

on all nodes of each type.

The node type representing the widest cathegory will be called first. That is, `variables_node`

will be called on a `Node`

before it is called on `NetworkNode`

-nodes.

`EnergyModelsBase.variables_opex`

— Method`variables_opex(m, 𝒩, 𝒯, 𝒫, modeltype::EnergyModel)`

Declaration of the OPEX variables (`:opex_var`

and `:opex_fixed`

) of the model for each period `𝒯ᴵⁿᵛ ∈ 𝒯`

. Variable OPEX can be non negative to account for revenue streams.

`EnergyModelsBase.@assert_or_log`

— Macro`assert_or_log(ex, msg)`

Macro that extends the behaviour of the `@assert`

macro. The switch `ASSERTS_AS_LOG`

, controls if the macro should act as a logger or a normal `@assert`

. This macro is designed to be used to check whether the data provided is consistent.