Methods - Internal
Index
EnergyModelsRenewableProducers.build_hydro_reservoir_vol_constraints
EnergyModelsRenewableProducers.build_pq_constaints
EnergyModelsRenewableProducers.build_schedule_constraint
EnergyModelsRenewableProducers.capacity_max
EnergyModelsRenewableProducers.capacity_reduction
EnergyModelsRenewableProducers.check_battery_life
EnergyModelsRenewableProducers.constraints_reserve
EnergyModelsRenewableProducers.constraints_usage
EnergyModelsRenewableProducers.constraints_usage_iterate
EnergyModelsRenewableProducers.constraints_usage_sp
EnergyModelsRenewableProducers.has_degradation
EnergyModelsRenewableProducers.has_penalty
EnergyModelsRenewableProducers.has_penalty_down
EnergyModelsRenewableProducers.has_penalty_up
EnergyModelsRenewableProducers.is_active
EnergyModelsRenewableProducers.is_constraint_data
EnergyModelsRenewableProducers.is_constraint_resource
EnergyModelsRenewableProducers.linear_reformulation
EnergyModelsRenewableProducers.multiplication_variables
EnergyModelsRenewableProducers.previous_usage
EnergyModelsRenewableProducers.replace_disjunct
Constraint functions
EnergyModelsRenewableProducers.build_hydro_reservoir_vol_constraints
— Functionbuild_hydro_reservoir_vol_constraints(m, n::HydroReservoir, c::ScheduleConstraint, 𝒯)
Create minimum/maximum/schedule volume constraints for a HydroReservoir
node. The ScheduleConstraint{T}
can have types T <: AbstractScheduleType
that defines the direction of the constraint.
Penalty variables are included unless the penalty value is not set or Inf
.
EnergyModelsRenewableProducers.build_pq_constaints
— Functionbuild_pq_constaints(m, n::HydroUnit, c::PqPoints, 𝒯::TimeStructure)
Function for creating the constraints on the variables flow_out
, cap_use
, and discharge_segments
as declared in the PqPoints pq
of a HydroUnit
node.
EnergyModelsRenewableProducers.build_schedule_constraint
— Functionbuild_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
`.
EnergyModelsRenewableProducers.constraints_usage
— Functionconstraints_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.
EnergyModelsRenewableProducers.constraints_usage_iterate
— Functionconstraints_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[𝒩, 𝒯ʳᵖ]
.
In the case of OperationalScenarios
, we purely iterate through the individual time structures.
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
.
EnergyModelsRenewableProducers.constraints_usage_sp
— Functionconstraints_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.
EnergyModelsRenewableProducers.constraints_reserve
— Functionconstraints_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.
No constraints are added.
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
.
Identification functions
EnergyModelsRenewableProducers.is_constraint_data
— Functionis_constraint_data(data::Data)
is_constraint_data(data::ScheduleConstraint)
Returns true if Data
input is of type ScheduleConstraint
, otherwise false.
EnergyModelsRenewableProducers.is_constraint_resource
— Functionis_constraint_resource(data::ScheduleConstraint, resource::Resource)
Returns true if Data
is of type ScheduleConstraint
and ScheduleConstraint
resource type is resource
.
EnergyModelsRenewableProducers.is_active
— Functionis_active(data::ScheduleConstraint, t)
Returns true if given constraint data
is active at operational period t
.
EnergyModelsRenewableProducers.has_penalty
— Functionhas_penalty(data::ScheduleConstraint, t)
Returns true if a constraint needs a penalty variable at operational period t
.
EnergyModelsRenewableProducers.has_penalty_up
— Functionhas_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.
EnergyModelsRenewableProducers.has_penalty_down
— Functionhas_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.
EnergyModelsRenewableProducers.has_degradation
— Functionhas_degradation(n::AbstractBattery)
Returns logic whether the AbstractBattery includes degradation of the battery and replacement options for the battery.
Check methods
EnergyModelsRenewableProducers.check_battery_life
— Functioncheckbatterylife(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 aStrategicPeriod
as outlined in the functionEMB.check_fixed_opex
.
Utility methods
EnergyModelsRenewableProducers.capacity_max
— Functioncapacity_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.
If the AbstractBattery
node does not have investments, it reuses the default function.
EnergyModelsRenewableProducers.linear_reformulation
— Functionlinear_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]$.
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
.
EnergyModelsRenewableProducers.multiplication_variables
— Functionmultiplication_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 ofcapacity(level(n), t_inv)
andbat_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
.
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 ofcap_inst[n, t]
andvar_b[t]
or alternativelycap_current[n, t]
andvar_b[t]
, if the TimeStructure is aStrategicPeriods
and the noden
has investments.
EnergyModelsRenewableProducers.previous_usage
— Functionprevious_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.
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
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.
EnergyModelsRenewableProducers.capacity_reduction
— Functioncapacity_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
.
Returns a value of 0 indicating no reduction in storage capacity.
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
.
EnergyModelsRenewableProducers.replace_disjunct
— Functionreplace_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.
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.
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.