diff --git a/src/PowerSimulations.jl b/src/PowerSimulations.jl index 3d4c3e5207..23dacdd660 100644 --- a/src/PowerSimulations.jl +++ b/src/PowerSimulations.jl @@ -313,9 +313,7 @@ export EmergencyDown export RawACE export ProductionCostExpression export ActivePowerRangeExpressionLB -export ReserveRangeExpressionLB export ActivePowerRangeExpressionUB -export ReserveRangeExpressionUB ################################################################################# # Imports diff --git a/src/core/expressions.jl b/src/core/expressions.jl index fd349000ed..8e39e687e5 100644 --- a/src/core/expressions.jl +++ b/src/core/expressions.jl @@ -9,11 +9,7 @@ struct EmergencyDown <: ExpressionType end struct RawACE <: ExpressionType end struct ProductionCostExpression <: CostExpressions end struct ActivePowerRangeExpressionLB <: RangeConstraintLBExpressions end -struct ComponentActivePowerRangeExpressionLB <: RangeConstraintLBExpressions end -struct ReserveRangeExpressionLB <: RangeConstraintLBExpressions end struct ActivePowerRangeExpressionUB <: RangeConstraintUBExpressions end -struct ReserveRangeExpressionUB <: RangeConstraintUBExpressions end -struct ComponentActivePowerRangeExpressionUB <: RangeConstraintUBExpressions end struct ComponentReserveUpBalanceExpression <: ExpressionType end struct ComponentReserveDownBalanceExpression <: ExpressionType end struct InterfaceTotalFlow <: ExpressionType end diff --git a/src/devices_models/devices/common/add_to_expression.jl b/src/devices_models/devices/common/add_to_expression.jl index 29bd067dd9..c3127f79ba 100644 --- a/src/devices_models/devices/common/add_to_expression.jl +++ b/src/devices_models/devices/common/add_to_expression.jl @@ -903,7 +903,7 @@ function add_to_expression!( devices::Union{Vector{V}, IS.FlattenIteratorWrapper{V}}, model::ServiceModel{X, W}, ) where { - T <: Union{ActivePowerRangeExpressionUB, ReserveRangeExpressionUB}, + T <: ActivePowerRangeExpressionUB, U <: VariableType, V <: PSY.Component, X <: PSY.Reserve{PSY.ReserveUp}, @@ -975,7 +975,7 @@ function add_to_expression!( devices::Union{Vector{V}, IS.FlattenIteratorWrapper{V}}, model::ServiceModel{X, W}, ) where { - T <: Union{ActivePowerRangeExpressionLB, ReserveRangeExpressionLB}, + T <: ActivePowerRangeExpressionLB, U <: VariableType, V <: PSY.Component, X <: PSY.Reserve{PSY.ReserveDown}, @@ -1011,7 +1011,8 @@ function add_to_expression!( add_expressions!(container, T, devices, model) end expression = get_expression(container, T(), V) - for d in devices, mult in get_expression_multiplier(U(), T(), d, W()) + for d in devices + mult in get_expression_multiplier(U(), T(), d, W()) for t in get_time_steps(container) name = PSY.get_name(d) _add_to_jump_expression!( diff --git a/src/devices_models/devices/common/rateofchange_constraints.jl b/src/devices_models/devices/common/rateofchange_constraints.jl index ba134bd175..7f9ec2a5d5 100644 --- a/src/devices_models/devices/common/rateofchange_constraints.jl +++ b/src/devices_models/devices/common/rateofchange_constraints.jl @@ -62,13 +62,12 @@ function add_linear_ramp_constraints!( U::Type{S}, devices::IS.FlattenIteratorWrapper{V}, model::DeviceModel{V, W}, - X::Type{<:PM.AbstractPowerModel}, + ::Type{<:PM.AbstractPowerModel}, ) where { S <: Union{PowerAboveMinimumVariable, ActivePowerVariable}, V <: PSY.Component, W <: AbstractDeviceFormulation, } - parameters = built_for_recurrent_solves(container) time_steps = get_time_steps(container) variable = get_variable(container, U(), V) ramp_devices = _get_ramp_constraint_devices(container, devices) @@ -90,26 +89,25 @@ function add_linear_ramp_constraints!( name ∉ set_name && continue ramp_limits = PSY.get_ramp_limits(get_component(ic)) ic_power = get_value(ic) - @debug "add rate_of_change_constraint" name ic_power - @assert (parameters && isa(ic_power, JuMP.VariableRef)) || !parameters + @error "add rate_of_change_constraint" name ic_power con_up[name, 1] = JuMP.@constraint( - container.JuMPmodel, + get_jump_model(container), expr_up[name, 1] - ic_power <= ramp_limits.up * minutes_per_period ) con_down[name, 1] = JuMP.@constraint( - container.JuMPmodel, - ic_power - expr_dn[name, 1] >= -1 * ramp_limits.down * minutes_per_period + get_jump_model(container), + ic_power - expr_dn[name, 1] <= ramp_limits.down * minutes_per_period ) for t in time_steps[2:end] con_up[name, t] = JuMP.@constraint( - container.JuMPmodel, + get_jump_model(container), expr_up[name, t] - variable[name, t - 1] <= ramp_limits.up * minutes_per_period ) con_down[name, t] = JuMP.@constraint( - container.JuMPmodel, - variable[name, t - 1] - expr_dn[name, t] >= - -1 * ramp_limits.down * minutes_per_period + get_jump_model(container), + variable[name, t - 1] - expr_dn[name, t] <= + ramp_limits.down * minutes_per_period ) end end @@ -147,21 +145,21 @@ function add_linear_ramp_constraints!( @debug "add rate_of_change_constraint" name ic_power @assert (parameters && isa(ic_power, JuMP.VariableRef)) || !parameters con_up[name, 1] = JuMP.@constraint( - container.JuMPmodel, + get_jump_model(container), variable[name, 1] - ic_power <= ramp_limits.up * minutes_per_period ) con_down[name, 1] = JuMP.@constraint( - container.JuMPmodel, + get_jump_model(container), ic_power - variable[name, 1] <= ramp_limits.down * minutes_per_period ) for t in time_steps[2:end] con_up[name, t] = JuMP.@constraint( - container.JuMPmodel, + get_jump_model(container), variable[name, t] - variable[name, t - 1] <= ramp_limits.up * minutes_per_period ) con_down[name, t] = JuMP.@constraint( - container.JuMPmodel, + get_jump_model(container), variable[name, t - 1] - variable[name, t] <= ramp_limits.down * minutes_per_period ) @@ -234,23 +232,23 @@ function add_semicontinuous_ramp_constraints!( @debug "add rate_of_change_constraint" name ic_power con_up[name, 1] = JuMP.@constraint( - container.JuMPmodel, + get_jump_model(container), expr_up[name, 1] - ic_power <= ramp_limits.up * minutes_per_period + power_limits.min * varstart[name, 1] ) con_down[name, 1] = JuMP.@constraint( - container.JuMPmodel, + get_jump_model(container), ic_power - expr_dn[name, 1] <= ramp_limits.down * minutes_per_period + power_limits.min * varstop[name, 1] ) for t in time_steps[2:end] con_up[name, t] = JuMP.@constraint( - container.JuMPmodel, + get_jump_model(container), expr_up[name, t] - variable[name, t - 1] <= ramp_limits.up * minutes_per_period + power_limits.min * varstart[name, t] ) con_down[name, t] = JuMP.@constraint( - container.JuMPmodel, + get_jump_model(container), variable[name, t - 1] - expr_dn[name, t] <= ramp_limits.down * minutes_per_period + power_limits.min * varstop[name, t] ) @@ -258,64 +256,3 @@ function add_semicontinuous_ramp_constraints!( end return end - -function add_semicontinuous_ramp_constraints!( - container::OptimizationContainer, - T::Type{<:ConstraintType}, - U::Type{<:VariableType}, - devices::IS.FlattenIteratorWrapper{V}, - model::DeviceModel{V, W}, - X::Type{<:PM.AbstractPowerModel}, -) where {V <: PSY.Component, W <: AbstractDeviceFormulation} - parameters = built_for_recurrent_solves(container) - time_steps = get_time_steps(container) - variable = get_variable(container, U(), V) - varstart = get_variable(container, StartVariable(), V) - varstop = get_variable(container, StopVariable(), V) - - ramp_devices = _get_ramp_constraint_devices(container, devices) - minutes_per_period = _get_minutes_per_period(container) - IC = _get_initial_condition_type(T, V, W) - initial_conditions_power = get_initial_condition(container, IC(), V) - - set_name = [PSY.get_name(r) for r in ramp_devices] - con_up = - add_constraints_container!(container, T(), V, set_name, time_steps; meta = "up") - con_down = - add_constraints_container!(container, T(), V, set_name, time_steps; meta = "dn") - - for ic in initial_conditions_power - name = get_component_name(ic) - # This is to filter out devices that dont need a ramping constraint - name ∉ set_name && continue - device = get_component(ic) - ramp_limits = PSY.get_ramp_limits(device) - power_limits = PSY.get_active_power_limits(device) - ic_power = get_value(ic) - @debug "add rate_of_change_constraint" name ic_power - @assert (parameters && isa(ic_power, JuMP.VariableRef)) || !parameters - con_up[name, 1] = JuMP.@constraint( - container.JuMPmodel, - variable[name, 1] - ic_power <= - ramp_limits.up * minutes_per_period + power_limits.min * varstart[name, 1] - ) - con_down[name, 1] = JuMP.@constraint( - container.JuMPmodel, - ic_power - variable[name, 1] <= - ramp_limits.down * minutes_per_period + power_limits.min * varstop[name, 1] - ) - for t in time_steps[2:end] - con_up[name, t] = JuMP.@constraint( - container.JuMPmodel, - variable[name, t] - variable[name, t - 1] <= - ramp_limits.up * minutes_per_period + power_limits.min * varstart[name, t] - ) - con_down[name, t] = JuMP.@constraint( - container.JuMPmodel, - variable[name, t - 1] - variable[name, t] <= - ramp_limits.down * minutes_per_period + power_limits.min * varstop[name, t] - ) - end - end - return -end