Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove stale code #1105

Merged
merged 5 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/PowerSimulations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,7 @@ export EmergencyDown
export RawACE
export ProductionCostExpression
export ActivePowerRangeExpressionLB
export ReserveRangeExpressionLB
export ActivePowerRangeExpressionUB
export ReserveRangeExpressionUB

#################################################################################
# Imports
Expand Down
4 changes: 0 additions & 4 deletions src/core/expressions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,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
Expand Down
7 changes: 4 additions & 3 deletions src/devices_models/devices/common/add_to_expression.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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},
Expand Down Expand Up @@ -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!(
Expand Down
97 changes: 17 additions & 80 deletions src/devices_models/devices/common/rateofchange_constraints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
)
Expand Down Expand Up @@ -234,88 +232,27 @@ 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]
)
end
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
Loading