Methods - EnergyModelsBase

Index

Extension methods

EnergyModelsBase.variables_elementFunction
EMB.variables_element(m, 𝒩ˢⁱⁿᵏ::Vector{<:AbstractPeriodDemandSink}, 𝒯, ::EnergyModel)

Creates the following additional variables for ALL PeriodDemandSink nodes:

  • demand_sink_surplus[n, i] is a non-negative variable indicating a surplus in demand in each period i.
  • demand_sink_deficit[n, i] is a non-negative variable indicating a deficit in demand for each period i.
Definition of period

The period in the description above does not correspond to an operational period as known from TimeStruct. Instead, it is a period in which the demand must be satisfied. A period can consist of multiple operational periods.

source
EMB.variables_element(m, 𝒩::Vector{<:AbstractMultipleInputSinkStrat}, 𝒯, ::EnergyModel)

Creates the following additional variables for ALL AbstractMultipleInputSinkStrat subtypes:

  • input_frac_strat[n, t_inv, p] is the fraction of the demand satisfied by resource p in investment period t_inv.
  • sink_surplus_p[n, t, p] is the surplus of resource p in operational period t.
  • sink_deficit_p[n, t, p] is the deficit of resource p in operational period t.
source
EMB.variables_element(m, 𝒩::Vector{BinaryMultipleInputSinkStrat}, 𝒯, ::EnergyModel)

Modifies the variable input_frac_strat[n, t_inv, p] of BinaryMultipleInputSinkStrat to be binary to not allow fuel switching within a strategic period.

source
EMB.variables_element(m, 𝒩ᴸˢ::Vector{<:LoadShiftingNode}, 𝒯, ::EnergyModel)

Creates the following additional variables for ALL LoadShiftingNode nodes.

  • load_shift_from[n, t] is an integer variable for how many batches are shifted away from time period t.
  • load_shift_to[n, t] is an integer variable for how many batches are shifted to the time period t.
  • :load_shifted[n ,t] is a continous variable for the total capacity load shifted in time period t. The variable can also be negative indicating a load shifted from this time period.

The individual time periods which allow for load shifting are declared by the parameter load_shift_times.

source
EMB.variables_element(m, 𝒩uc::Vector{UnitCommitmentNode}, 𝒯, ::EnergyModel)

Arguments

  • m: The optimization model.
  • 𝒩uc: A vector of unit commitment nodes.
  • 𝒯: The time structure.
  • modeltype: The type of energy model.

Variables

  • onswitch[n, t]: Binary variable indicating the node is switched on.
  • offswitch[n, t]: Binary variable indicating the node is switched off.
  • on_off[n, t]: Binary variable indicating the node's on/off state.
source

Constraint methods

EnergyModelsBase.constraints_capacityFunction
EMB.constraints_capacity(m, n::AbstractPeriodDemandSink, 𝒯::TimeStructure, modeltype::EnergyModel)

Function for creating the constraint on the maximum capacity utilization of an AbstractPeriodDemandSink.

The method is changed from the standard approach through calculating the demand period surplus or deficit in addition to the operational period surplus or deficit.

source
EMB.constraints_capacity(m, n::AbstractMultipleInputSinkStrat, 𝒯::TimeStructure, modeltype::EnergyModel)

Function for creating the constraint on the capacity of a AbstractMultipleInputSinkStrat.

It differs from the standard method as it does not include the capacity constraint as this is included in constraints_flow_in. Instead, it only calls the subfunction constraints_capacity_installed.

source
EMB.constraints_capacity(m, n::LoadShiftingNode, 𝒯::TimeStructure, modeltype::EnergyModel)

Add capacity constraints to the optimization model m for a node n representing a load-shifting node over the time structure 𝒯. The constraints ensure that the node's capacity usage respects its operational limits and accounts for load shifting.

Arguments

  • m: The optimization model.
  • n: The node representing a load-shifting node.
  • 𝒯: The time structure.
  • modeltype: The type of energy model.

Constraints

  • Ensures capacity usage matches installed capacity plus any shifted load.
  • Limits the number of load shifts per period.
  • Balances load shifts from and to operational periods.
  • Sets the load_shifted variable to the actual load shifted during load-shifting periods.
  • Fixes load_shifted to zero for non-load-shifting periods.
source
constraints_capacity(m, n::MinUpDownTimeNode, 𝒯::TimeStructure, modeltype::EnergyModel)

Add capacity constraints to the optimization model m for a node n with minimum up/down time requirements over the time structure 𝒯. The constraints ensure that the node's capacity usage respects its operational limits and switching constraints.

Arguments

  • m: The optimization model.
  • n: The node with minimum up/down time requirements.
  • 𝒯: The time structure.
  • modeltype: The type of energy model.

Constraints

  • Ensures minimum up/down time requirements are met.
  • Enforces capacity usage within specified limits.
  • Adds switching constraints to prevent simultaneous on/off switching.
source
constraints_capacity(m, n::ActivationCostNode, 𝒯::TimeStructure, ::EnergyModel)

Add capacity constraints to the optimization model m for a node n with activation cost considerations over the time structure 𝒯. The constraints ensure that the node's capacity usage respects its operational limits and switching constraints.

Constraints

  • Ensures proper on/off switching behavior.
  • Enforces capacity usage within specified limits.
  • Adds constraints to prevent simultaneous on/off switching.

Arguments

  • m: The optimization model.
  • n: The node with activation cost considerations.
  • 𝒯: The time structure.
  • modeltype: The type of energy model.
source
constraints_capacity(m, n::ElectricBattery, 𝒯::TimeStructure, modeltype::EnergyModel)

Add capacity constraints to the optimization model m for a node n representing an electric battery over the time structure 𝒯. The constraints ensure that the node's capacity usage respects its operational limits, including charging and discharging rates.

Arguments

  • m: The optimization model.
  • n: The node representing an electric battery.
  • 𝒯: The time structure.
  • modeltype: The type of energy model.

Constraints

  • Ensures storage level does not exceed installed capacity.
  • Limits charge and discharge usage to installed capacity.
  • Enforces charging and discharging rates based on the battery's c_rate.
source
EnergyModelsBase.constraints_flow_inFunction
EMB.constraints_flow_in(m, n::MultipleInputSink, 𝒯::TimeStructure)

Function for creating the constraint on the inlet flow of a MultipleInputSink.

The difference to the standard constraint is that the MultipleInputSink allows for several different resources can be used interchangably and the ratio is not enforced.

source
EMB.constraints_flow_in(m, n::AbstractMultipleInputSinkStrat, 𝒯::TimeStructure)

Function for creating the constraint on the inlet flow to a AbstractMultipleInputSinkStrat.

The difference to the standard method is that the AbstractMultipleInputSinkStrat allows for satisfying the demand with multiple resources as specified through the variable input_frac_strat.

As a consequence, the method includes the constraints for:

  1. the capacity utilization (replacing constraints_capacity),
  2. the bounds on the individual flows into the node based on the variable input_frac_strat,
  3. the summation limit of input_frac_strat, and
  4. the calculation of the total deficit in the Sink node.
source
constraints_flow_in(m, n::ActivationCostNode, 𝒯::TimeStructure, ::EnergyModel)

Add flow input constraints to the optimization model m for a node n with activation cost considerations over the time structure 𝒯. The constraints ensure that the node's input flows respect its capacity usage and activation consumption.

Arguments

  • m: The optimization model.
  • n: The node with activation cost considerations.
  • 𝒯: The time structure.
  • modeltype: The type of energy model.

Constraints

  • Ensures input flow respects capacity usage.
  • Accounts for activation consumption in input flows.
source
constraints_flow_in(m, n::LimitedFlexibleInput, 𝒯::TimeStructure, ::EnergyModel)

Function for creating the constraint on the inlet flow to a LimitedFlexibleInput node. The input resources are limited by the limit field in the node n.

source
constraints_flow_in(m, n::Combustion, 𝒯::TimeStructure, ::EnergyModel)

Function for creating the constraint on the inlet flow to a Combustion node. The input resources are limited by the limit field in the node n as for the LimitedFlexibleInput node, but additionally, it is balance requirement for the input and output flows controlled by the heat_resource field in the node n. If outputs(n, p_heat) == 1, then there is flow balance.

source
constraints_flow_in(m, n::ElectricBattery, 𝒯::TimeStructure, ::EnergyModel)

Add flow input constraints to the optimization model m for a node n representing an electric battery over the time structure 𝒯. The constraints ensure that the node's input flows respect its storage requirements and efficiency.

Arguments

  • m: The optimization model.
  • n: The node representing an electric battery.
  • 𝒯: The time structure.
  • modeltype: The type of energy model.

Constraints

  • Ensures additional required input flows are proportional to storage input.
  • Accounts for storage rate usage for charging with efficiency.
source
EMB.constraints_flow_in(m, n::StorageEfficiency, 𝒯::TimeStructure, ::EnergyModel)

Function for creating the constraint on the inlet flow to a StorageEfficiency.

source
EnergyModelsBase.constraints_flow_outFunction
constraints_flow_out(m, n::Combustion, 𝒯::TimeStructure, modeltype::EnergyModel)

Function for creating the constraint on the outlet flow from a Combustion node.

source
EMB.constraints_flow_out(m, n::StorageEfficiency, 𝒯::TimeStructure, ::EnergyModel)

Function for creating the constraint on the outlet flow from a StorageEfficiency.

source
EnergyModelsBase.constraints_opex_varFunction
EMB.constraints_opex_var(m, n::PayAsProducedPPA, 𝒯ᴵⁿᵛ, ::EnergyModel)

Function for creating the constraint on the variable OPEX of a PayAsProducedPPA node.

source
EMB.constraints_opex_var(m, n::AbstractPeriodDemandSink, 𝒯ᴵⁿᵛ, ::EnergyModel)

Function for creating the constraint on the variable OPEX of an AbstractPeriodDemandSink.

The method is adjusted from the default method through utilizing the period demand surplus and deficit instead of the operational period deficit or surplus.

source
EnergyModelsBase.constraints_level_auxFunction
constraints_level_aux(m, n::ElectricBattery, 𝒯, 𝒫, ::EnergyModel)

Add auxiliary level constraints to the optimization model m for a node n representing an electric battery over the time structure 𝒯 and subset 𝒫. The constraints ensure that the change in storage level is correctly accounted for in each operational period.

Arguments

  • m: The optimization model.
  • n: The node representing an electric battery.
  • 𝒯: The time structure.
  • 𝒫: The subset of periods.
  • modeltype: The type of energy model.

Constraints

  • Ensures the change in storage level is equal to the difference between charge and discharge usage.
source

Check methods

EnergyModelsBase.check_nodeFunction
check_node(n::PeriodDemandSink, 𝒯, ::EnergyModel)

This method checks that a PeriodDemandSink node is valid.

It reuses the standard checks of a Sink node through calling the function EMB.check_node_default, but adds additional checks on the data.

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.
  • The remainder of the divison of the lowest time structure by the period length must be 0.
  • The length of the period demand must equal the length of the lowest period times the parameter period length.
source
EMB.check_node(n::LoadShiftingNode, 𝒯, ::EnergyModel, check_timeprofiles::Bool)

This method checks that the LoadShiftingNode node is valid.

Checks

  • The field cap is required to be non-negative.
  • The values of the dictionary input are required to be positive.
  • The values of loadshifttimes are required to be larger than 0.
  • The values of loadshifttimes are required to be less than the length of 𝒯.
  • The values of loadshiftmagnitude are required to be non-negative.
  • The values of loadshiftduration are required to be positive.
  • The values of loadshiftsper_period are required to be non-negative.
source
EMB.check_node(n::MinUpDownTimeNode, 𝒯, modeltype::EnergyModel, check_timeprofiles::Bool)

This method checks that a MinUpDownTimeNode node is valid.

Checks

  • The minimum capacity must be greater than zero.
  • The minimum capacity must not be larger than maximum capacity.
source
EMB.check_node(
    n::LimitedFlexibleInput,
    𝒯,
    modeltype::EnergyModel,
    check_timeprofiles::Bool,
)

This method checks that a LimitedFlexibleInput or a Combustion node is valid.

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).
  • The values of the dictionary limit are required to be non-negative.
  • The values of the dictionary limit are required to not be larger than 1.
source
EMB.check_node(n::Combustion, 𝒯, modeltype::EnergyModel, check_timeprofiles::Bool)

This method checks that a LimitedFlexibleInput or a Combustion node is valid.

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).
  • The values of the dictionary limit are required to be non-negative.
  • The values of the dictionary limit are required to not be larger than 1.
  • The resource in the heat_res field must be in the dictionary output.
source