Methods - EMB
Index
EnergyModelsBase.capacityEnergyModelsBase.check_linkEnergyModelsBase.check_nodeEnergyModelsBase.constraints_capacityEnergyModelsBase.constraints_flow_inEnergyModelsBase.constraints_flow_outEnergyModelsBase.constraints_level_auxEnergyModelsBase.constraints_opex_varEnergyModelsBase.create_linkEnergyModelsBase.has_capacityEnergyModelsBase.has_opexEnergyModelsBase.inputsEnergyModelsBase.outputsEnergyModelsBase.variables_element
Extension methods
EnergyModelsBase.variables_element — Function
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 periodi.demand_sink_deficit[n, i]is a non-negative variable indicating a deficit in demand for each periodi.
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 resourcepin investment periodt_inv.sink_surplus_p[n, t, p]is the surplus of resourcepin operational periodt.sink_deficit_p[n, t, p]is the deficit of resourcepin operational periodt.
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.
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 periodt.load_shift_to[n, t]is an integer variable for how many batches are shifted to the time periodt.:load_shifted[n ,t]is a continous variable for the total capacity load shifted in time periodt. 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.
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.
EMB.variables_element(m, ℒˢᵘᵇ::Vector{<:CapacityCostLink}, 𝒯, modeltype::EnergyModel)Creates the following additional variable for ALL capacity cost links:
ccl_cap_use_max[l, t]is a continuous variable describing the maximum capacity usage over sub periods for aCapacityCostLinklin operational periodt.ccl_cap_use_cost[l, t]is a continuous variable describing the cost over sub periods for aCapacityCostLinklin operational periodt.
EnergyModelsBase.create_link — Function
EMB.create_link(m, l::CapacityCostLink, 𝒯, 𝒫, modeltype::EnergyModel)When the link is a CapacityCostLink, the constraints for a link include capacity-based cost constraints.
In addition, a CapacityCostLink includes a capacity with the potential for investments.
EnergyModelsBase.has_capacity — Function
EMB.has_capacity(l::CapacityCostLink)The CapacityCostLink has a capacity, and hence, requires the declaration of capacity variables.
EnergyModelsBase.has_opex — Function
EMB.has_opex(l::CapacityCostLink)A CapacityCostLink l has operational expenses.
Constraint methods
EnergyModelsBase.constraints_capacity — Function
constraints_capacity(m, n::InflexibleSource, 𝒯::TimeStructure, modeltype::EnergyModel)Function for fixing the capacity of a InflexibleSource to the installed capacity.
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.
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.
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_shiftedvariable to the actual load shifted during load-shifting periods. - Fixes
load_shiftedto zero for non-load-shifting periods.
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.
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.
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.
EnergyModelsBase.constraints_flow_in — Function
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.
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:
- the capacity utilization (replacing
constraints_capacity), - the bounds on the individual flows into the node based on the variable
input_frac_strat, - the summation limit of
input_frac_strat, and - the calculation of the total deficit in the
Sinknode.
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.
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.
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.
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.
EMB.constraints_flow_in(m, n::StorageEfficiency, 𝒯::TimeStructure, ::EnergyModel)Function for creating the constraint on the inlet flow to a StorageEfficiency.
EnergyModelsBase.constraints_flow_out — Function
constraints_flow_out(m, n::Combustion, 𝒯::TimeStructure, modeltype::EnergyModel)Function for creating the constraint on the outlet flow from a Combustion node.
constraints_flow_out(m, n::FlexibleOutput, 𝒯::TimeStructure, modeltype::EnergyModel)Function for creating the constraint on the outlet flow from a FlexibleOutput.
EMB.constraints_flow_out(m, n::StorageEfficiency, 𝒯::TimeStructure, ::EnergyModel)Function for creating the constraint on the outlet flow from a StorageEfficiency.
EnergyModelsBase.constraints_opex_var — Function
constraints_opex_var(m, n::PayAsProducedPPA, 𝒯ᴵⁿᵛ, ::EnergyModel)Function for creating the constraint on the variable OPEX of a PayAsProducedPPA node.
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.
EnergyModelsBase.constraints_level_aux — Function
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.
Check methods
EnergyModelsBase.check_node — Function
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
capis required to be non-negative. - The values of the dictionary
inputare required to be non-negative. - The dictionary
penaltyis required to have the keys:deficitand:surplus. - The sum of the values
:deficitand:surplusin the dictionarypenaltyhas 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.
EMB.check_node(n::LoadShiftingNode, 𝒯, ::EnergyModel, check_timeprofiles::Bool)This method checks that the LoadShiftingNode node is valid.
Checks
- The field
capis required to be non-negative. - The values of the dictionary
inputare 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.
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.
EMB.check_node(
n::LimitedFlexibleInput,
𝒯,
modeltype::EnergyModel,
check_timeprofiles::Bool,
)This method checks that a LimitedFlexibleInput node is valid.
Checks
- The field
capis required to be non-negative. - The values of the dictionary
inputare required to be positive. - The values of the dictionary
outputare required to be non-negative. - The value of the field
fixed_opexis required to be non-negative and accessible through aStrategicPeriodas outlined in the functioncheck_fixed_opex(n, 𝒯ᴵⁿᵛ, check_timeprofiles). - The values of the dictionary
limitare required to be non-negative. - The values of the dictionary
limitare required to not be larger than 1.
EMB.check_node(n::Combustion, 𝒯, modeltype::EnergyModel, check_timeprofiles::Bool)This method checks that a Combustion node is valid.
Checks
- The field
capis required to be non-negative. - The values of the dictionary
inputare required to be positive. - The values of the dictionary
outputare required to be non-negative. - The value of the field
fixed_opexis required to be non-negative and accessible through aStrategicPeriodas outlined in the functioncheck_fixed_opex(n, 𝒯ᴵⁿᵛ, check_timeprofiles). - The values of the dictionary
limitare required to be non-negative. - The values of the dictionary
limitare required to not be larger than 1. - The resource in the
heat_resfield must be in the dictionaryoutput.
EMB.check_node(n::FlexibleOutput, 𝒯, modeltype::EnergyModel, check_timeprofiles::Bool)This method checks that a FlexibleOutput node is valid.
Checks
- The field
capis required to be non-negative. - The values of the dictionary
inputare required to be non-negative. - The values of the dictionary
outputare required to be positive. - The value of the field
fixed_opexis required to be non-negative and accessible through aStrategicPeriodas outlined in the functioncheck_fixed_opex(n, 𝒯ᴵⁿᵛ, check_timeprofiles).
EnergyModelsBase.check_link — Function
EMB.check_link(l::CapacityCostLink, 𝒯, ::EnergyModel, ::Bool)This method checks that the CapacityCostLink link is valid.
Checks
- The field
capis required to be non-negative. - The field
cap_priceis required to be non-negative. - The field
cap_price_periodis required to be positive.
Field extraction methods
EnergyModelsBase.capacity — Function
EMB.capacity(l::CapacityCostLink)
EMB.capacity(l::CapacityCostLink, t)Returns the capacity of a capacity cost link l as TimeProfile or in operational period t.
EnergyModelsBase.inputs — Function
EMB.inputs(l::CapacityCostLink)Returns the input resources of a capacity cost link l, corresponding to its cap_resource.
EnergyModelsBase.outputs — Function
EMB.outputs(l::CapacityCostLink)Returns the output resources of a capacity cost link l, corresponding to its cap_resource.