Internals

Index

Types

Methods

EnergyModelsBase.check_case_dataMethod
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}.
source
EnergyModelsBase.check_dataMethod
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.

source
EnergyModelsBase.check_fixed_opexMethod
check_fixed_opex(n::Node, 𝒯ᴵⁿᵛ, check_timeprofiles::Bool)

Checks that the fixed opex value follows the given TimeStructure.

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.
source
EnergyModelsBase.check_modelMethod
check_model(case, modeltype::EnergyModel, check_timeprofiles::Bool)

Checks the modeltype .

Checks

  • All ResourceEmits 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.

source
EnergyModelsBase.check_nodeMethod
check_node(n::Availability, 𝒯, modeltype::EnergyModel)

This method checks that an Availability node is valid. By default, that does not include any checks.

source
EnergyModelsBase.check_nodeMethod
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).
source
EnergyModelsBase.check_nodeMethod
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.
source
EnergyModelsBase.check_nodeMethod
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).
source
EnergyModelsBase.check_nodeMethod
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 value of the field rate_cap is required to be non-negative.
  • The value of the field stor_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).
source
EnergyModelsBase.check_node_dataMethod
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.

source
EnergyModelsBase.check_node_dataMethod
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.
source
EnergyModelsBase.check_profileMethod
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 It currently does not include support for identifying OperationalProfiles.

source
EnergyModelsBase.check_profileMethod
check_profile(fieldname, value::TimeProfile, 𝒯)

Check that an individual TimeProfile corresponds to the time structure 𝒯. It currently does not include support for identifying OperationalProfiles.

source
EnergyModelsBase.check_representative_profileMethod
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

  • TimeProfiles access in RepresentativePeriods cannot include OperationalProfile or ScenarioProfile as this is not allowed through indexing on the TimeProfile.
source
EnergyModelsBase.check_scenario_profileMethod
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

  • TimeProfiles access in RepresentativePeriods cannot include OperationalProfile or ScenarioProfile as this is not allowed through indexing on the TimeProfile.
source
EnergyModelsBase.check_strategic_profileMethod
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

  • TimeProfiles access in StrategicPeriods cannot include OperationalProfile, ScenarioProfile, or RepresentativeProfile as this is not allowed through indexing on the TimeProfile.
source
EnergyModelsBase.collect_typesMethod
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.

source
EnergyModelsBase.constraints_level_auxMethod
constraints_level_aux(m, n::RefStorage{S}, 𝒯, 𝒫, modeltype::EnergyModel) where {S<:ResourceCarrier}

Function for creating the Δ constraint for the level of a reference storage node with a ResourceCarrier resource.

source
EnergyModelsBase.constraints_level_auxMethod
constraints_level_aux(m, n::RefStorage{S}, 𝒯, 𝒫, modeltype::EnergyModel) where {S<:ResourceEmit}

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

source
EnergyModelsBase.constraints_level_spMethod
constraints_level_sp(
    m,
    n::RefStorage{S},
    t_inv::TS.StrategicPeriod{T, RepresentativePeriods{U, T, SimpleTimes{T}}},
    𝒫,
    modeltype::EnergyModel
    ) where {S<:ResourceCarrier, T, U}

Function for creating the level constraint for a reference storage node with a ResourceCarrier resource when the operational TimeStructure is given as RepresentativePeriods.

source
EnergyModelsBase.constraints_level_spMethod
constraints_level_sp(
    m,
    n::RefStorage{S},
    t_inv::TS.StrategicPeriod{T, RepresentativePeriods{U, T, SimpleTimes{T}}},
    𝒫,
    modeltype::EnergyModel
    ) where {S<:ResourceEmit, T, U}

Function for creating the level constraint for a reference storage node with a ResourceEmit resource when the operational TimeStructure is given as RepresentativePeriods.

source
EnergyModelsBase.constraints_level_spMethod
constraints_level_sp(
    m,
    n::RefStorage{S},
    t_inv::TS.StrategicPeriod{T, U},
    𝒫,
    modeltype::EnergyModel
    ) where {S<:ResourceCarrier, T, U<:SimpleTimes}

Function for creating the level constraint for a reference storage node with a ResourceCarrier resource when the operational TimeStructure is given as SimpleTimes.

source
EnergyModelsBase.constraints_level_spMethod
constraints_level_sp(
    m,
    n::RefStorage{S},
    t_inv::TS.StrategicPeriod{T, U},
    𝒫,
    modeltype::EnergyModel
    ) where {S<:ResourceEmit, T, U<:SimpleTimes}

Function for creating the level constraint for a reference storage node with a ResourceEmit resource when the operational TimeStructure is given as SimpleTimes.

source
EnergyModelsBase.constraints_nodeMethod
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.

source
EnergyModelsBase.create_linkMethod
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.

source
EnergyModelsBase.multipleMethod
multiple(t_inv, t)

Provide a simplified function for returning the combination of the functions duration(t) * multiplestrat(tinv, t) * probability(t)

source
EnergyModelsBase.objectiveMethod
objective(m, 𝒩, 𝒯, 𝒫, modeltype::EnergyModel)

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

source
EnergyModelsBase.res_emMethod
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
source
EnergyModelsBase.res_notMethod
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
source
EnergyModelsBase.res_subFunction
res_sub(𝒫::Array{<:Resource}, sub = ResourceEmit)

Return resources that are of type sub for a given Array ::Array{Resource}.

source
EnergyModelsBase.sort_typesMethod
sort_types(types_list::Dict)

Sort the result of collect_types and return a vector where a supertype comes before all its subtypes.

source
EnergyModelsBase.variables_capacityMethod
variables_capacity(m, 𝒩, 𝒯, modeltype::EnergyModel)

Creation 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
  • :cap_inst - installed capacity in each operational period in terms of either :flow_in

or :flow_out (depending on node n ∈ 𝒩)

Creation 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_rate_use - storage rate use in each operational period
  • :stor_cap_inst - installed capacity for storage in each operational period, constrained

in the operational case to n.stor_cap

  • :stor_rate_inst - installed rate for storage, e.g. power in each operational period,

constrained in the operational case to n.rate_cap

source
EnergyModelsBase.variables_capexMethod
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.

source
EnergyModelsBase.variables_emissionMethod
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.
source
EnergyModelsBase.variables_flowMethod
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).

source
EnergyModelsBase.variables_nodesMethod
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.

source
EnergyModelsBase.variables_opexMethod
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.

source