Methods - Internal

Index

Constraint functions

EnergyModelsRenewableProducers.build_schedule_constraintFunction
build_schedule_constraint(m, n::Union{HydroGate, HydroUnit}, c::ScheduleConstraint, 𝒯::TimeStructure, p::ResourceCarrier)

Create minimum/maximum/schedule discharge constraints for the generic Node type. The ScheduleConstraint{T} can have types T <: AbstractScheduleType that defines the direction of the constraint. Penalty variables are included unless penalty value is not set or Inf`.

source
EnergyModelsRenewableProducers.constraints_usageFunction
constraints_usage(m, n::AbstractBattery, 𝒯ᴵⁿᵛ, modeltype::EnergyModel)

Function for creating the usage constraints for an AbstractBattery. These constraints calculate the usage of the battery up to each time step for the lifetime calculations.

source
EnergyModelsRenewableProducers.constraints_usage_iterateFunction
constraints_usage_iterate(
    m,
    n::AbstractBattery,
    prev_pers::PreviousPeriods,
    cyclic_pers::CyclicPeriods,
    t_inv::TS.AbstractStrategicPeriod,
    per,
    ts::RepresentativePeriods,
    modeltype::EnergyModel,
)

Iterate through the individual time structures of an AbstractBattery node.

In the case of RepresentativePeriods, additional constraints are calculated for the usage of the battery in representative periods through introducing the variable bat_use_rp[𝒩, 𝒯ʳᵖ].

source

In the case of OperationalScenarios, we purely iterate through the individual time structures.

source

In the case of SimpleTimes, the iterator function is at its lowest level. In this situation,the previous usage is calculated using the function previous_usage. The approach for calculating the constraints is depending on the types in the parameteric type EMB.PreviousPeriods.

source
EnergyModelsRenewableProducers.constraints_usage_spFunction
constraints_usage_sp(
    m,
    n::AbstractBattery,
    prev_pers::PreviousPeriods,
    t_inv::TS.AbstractStrategicPeriod,
    modeltype::EnergyModel,
)

Function for creating the constraints on the previous usage of an AbstractBattery before the beginning of a strategic period.

In the case of the first strategic period, it fixes the variable bat_prev_use_sp to 0. In all subsequent strategic periods, the previous usage is calculated.

source
EnergyModelsRenewableProducers.constraints_reserveFunction
constraints_reserve(m, n::AbstractBattery, 𝒯::TimeStructure, modeltype::EnergyModel)
constraints_reserve(m, n::ReserveBattery, 𝒯::TimeStructure, modeltype::EnergyModel)

Function for creating the additional constraints on the capacity utilization to account for providing reserve capacity to the system.

Default approach

No constraints are added.

`ReserveBattery`

Several constraints are added to guarantee that the provided reserve can be delivered through the values of the variables :stor_charge_use, stor_discharge_use, and stor_level.

source

Identification functions

EnergyModelsRenewableProducers.has_penalty_upFunction
has_penalty_up(data::ScheduleConstraint)
has_penalty_up(data::ScheduleConstraint, t)
has_penalty_up(data::ScheduleConstraint, t, p::Resource)

Returns true if a constraint data is of a type that may require a penalty up variable, which is true for MinSchedule and EqualSchedule.

When the operational period t is provided in addition, it is furthermore necessary that the penalty is finite.

When the operational period t and the resource p is provided in addition, it is furthermore necessary that the penalty is finite and that p corresponds to the ScheduleConstraint resource.

source
EnergyModelsRenewableProducers.has_penalty_downFunction
has_penalty_down(data::ScheduleConstraint)
has_penalty_down(data::ScheduleConstraint, t)
has_penalty_down(data::ScheduleConstraint, t, resource::Resource)

Returns true if a constraint data is of a type that may require a penalty up down, which is true for MaxSchedule and EqualSchedule.

When the operational period t is provided in addition, it is furthermore necessary that the penalty is finite.

When the operational period t and the resource p is provided in addition, it is furthermore necessary that the penalty is finite and that p corresponds to the ScheduleConstraint resource.

source

Check methods

EnergyModelsRenewableProducers.check_battery_lifeFunction

checkbatterylife(n::AbstractBattery, batlife::AbstractBatteryLife, 𝒯, modeltype::EnergyModel, checktimeprofiles::Bool) checkbatterylife(n::AbstractBattery, batlife::CycleLife, 𝒯, modeltype::EnergyModel, checktimeprofiles::Bool)

Check that the included AbstractBatteryLife types of an AbstractBattery follows to the

Checks AbstractBatteryLife

  • None.

Checks CycleLife

  • All fields must be positive.
  • The value of the field degradation must be smaller than 1.
  • The value of the field stack_cost is required to be accessible through a StrategicPeriod as outlined in the function EMB.check_fixed_opex.
source

Utility methods

EnergyModelsRenewableProducers.capacity_maxFunction
capacity_max(n::AbstractBattery, t_inv, modeltype::EnergyModel)

Function for calculating the maximum capacity, including the number of cycles.

modeltype::EnergyModel

When the modeltype is an EnergyModel, it returns the muliplication of the installed storage level capacity and the number of cycles before the stack must be replaced.

modeltype::AbstractInvestmentModel

When the modeltype is an AbstractInvestmentModel, it returns the muliplication of the maximum installed storage level capacity and the number of cycles before the stack must be replaced.

Note

If the AbstractBattery node does not have investments, it reuses the default function.

source
EnergyModelsRenewableProducers.linear_reformulationFunction
linear_reformulation(
    m,
    𝒯,
    var_binary,
    var_continuous,
    lb::TimeProfile,
    ub::TimeProfile,
)

Linear reformulation of the element-wise multiplication of the binary variable var_binary[𝒯] and the continuous variable var_continuous[𝒯] ∈ [ub, lb].

It returns the product var_aux[𝒯] with

$var\_aux[t] = var\_binary[t] \times var\_continuous[t]$.

Note

The bounds lb and ub must have the ability to access their fields using the iterator of 𝒯, that is if 𝒯 corresponds to the strategic periods, it is not possible to provide an OperationalProfile or RepresentativeProfile.

source
EnergyModelsRenewableProducers.multiplication_variablesFunction
multiplication_variables(
    m,
    n::AbstractBattery,
    𝒯ᴵⁿᵛ,
    modeltype::EnergyModel
)

Function for calculating the muliplication of the capacity of an AbstractBattery and the binary variable :bat_stack_replace_b.

modeltype::EnergyModel

Multiplication of the installed capacity (expressed through capacity(level(n), t_inv)) and the binary variable bat_stack_replace_b in a strategic period t_inv.

Returns

  • prod[t]: Multiplication of capacity(level(n), t_inv) and bat_stack_replace_b[n, t_inv].
modeltype::AbstractInvestmentModel

When the modeltype is an AbstractInvestmentModel, then the function applies a linear reformulation of the binary-continuous multiplication based on the McCormick relaxation and the function linear_reformulation.

Note

If the AbstractBattery node does not have investments, it reuses the default function to avoid increasing the number of variables in the model.

Returns

  • prod[t]: Multiplication of cap_inst[n, t] and var_b[t] or alternatively cap_current[n, t] and var_b[t], if the TimeStructure is a StrategicPeriods and the node n has investments.
source
EnergyModelsRenewableProducers.previous_usageFunction
previous_usage(
    m,
    n::AbstractBattery,
    t_inv::TS.AbstractStrategicPeriod,
    prev_pers::PreviousPeriods,
    modeltype::EnergyModel,
)

Returns the previous usage of an AbstractBattery 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.

source

When the previous operational and representative periods are Nothing, the variable bat_prev_use_sp is used for the initial usage in a strategic period

source

When the previous operational period is Nothing and the previous representative period an AbstractRepresentativePeriod then the time structure does include RepresentativePeriods.

The constraint then sums up the values from the previous representative period.

source
EnergyModelsRenewableProducers.capacity_reductionFunction
capacity_reduction(
    m,
    n::AbstractBattery,
    bat_life::AbstractBatteryLife,
    𝒯::TimeStructure,
    modeltype::EnergyModel,
)

Returns the reduction in the storage capacity of an AbstractBattery depending once on the chosen AbstractBatteryLife.

Default approach

Returns a value of 0 indicating no reduction in storage capacity.

`CycleLife`

Returns the reduction in storage level capacity as linear multiplier of the charge usage of the Battery through the fields cycles and degradation of the CycleLife.

source
EnergyModelsRenewableProducers.replace_disjunctFunction
replace_disjunct(
    m,
    n::AbstractBattery,
    bat_life::AbstractBatteryLife,
    prev_pers::PreviousPeriods,
    t_inv::TS.AbstractStrategicPeriod,
    modeltype::EnergyModel,
)

Function for dispatching no the different type of battery lifes for incorporation of the preivous usage constraints in the first operational period (of the first representative period) of a strategic period.

Default approach

Returns the value based on the the calculation of the previous usage in the previous strategic period and the initial value in the previous strategic period.

`CycleLife`

In the case of a cycle life, it takes into account the potential for battery stack replacement through a bilinear formulation. The bilinear formulation is simplifed due to the known lower bounds.

source