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

Jd/add thermal time series #1162

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion src/PowerSimulations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ include("devices_models/devices/common/duration_constraints.jl")
include("devices_models/devices/common/get_time_series.jl")

# Device Modeling components
include("devices_models/devices/interfaces.jl")
include("devices_models/devices/default_interface_methods.jl")
include("devices_models/devices/common/add_to_expression.jl")
include("devices_models/devices/common/set_expression.jl")
include("devices_models/devices/renewable_generation.jl")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@

initial_conditions!(container, devices, D())

if haskey(get_time_series_names(model), ActivePowerTimeSeriesParameter)
add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model)

Check warning on line 60 in src/devices_models/device_constructors/thermalgeneration_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/thermalgeneration_constructor.jl#L60

Added line #L60 was not covered by tests
end

add_to_expression!(
container,
ActivePowerBalance,
Expand Down Expand Up @@ -135,6 +139,17 @@
add_constraints!(container, RampConstraint, devices, model, network_model)
add_constraints!(container, DurationConstraint, devices, model, network_model)

if haskey(get_time_series_names(model), ActivePowerTimeSeriesParameter)
add_constraints!(

Check warning on line 143 in src/devices_models/device_constructors/thermalgeneration_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/thermalgeneration_constructor.jl#L143

Added line #L143 was not covered by tests
container,
ActivePowerVariableTimeSeriesLimitsConstraint,
ActivePowerRangeExpressionUB,
devices,
model,
network_model,
)
end

add_feedforward_constraints!(container, model, devices)

objective_function!(container, devices, model, get_network_formulation(network_model))
Expand Down Expand Up @@ -164,6 +179,10 @@

initial_conditions!(container, devices, D())

if haskey(get_time_series_names(model), ActivePowerTimeSeriesParameter)
add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model)
end

add_to_expression!(
container,
ActivePowerBalance,
Expand Down Expand Up @@ -227,6 +246,16 @@
add_constraints!(container, CommitmentConstraint, devices, model, network_model)
add_constraints!(container, RampConstraint, devices, model, network_model)
add_constraints!(container, DurationConstraint, devices, model, network_model)
if haskey(get_time_series_names(model), ActivePowerTimeSeriesParameter)
add_constraints!(
container,
ActivePowerVariableTimeSeriesLimitsConstraint,
ActivePowerRangeExpressionUB,
devices,
model,
network_model,
)
end

add_feedforward_constraints!(container, model, devices)

Expand Down Expand Up @@ -256,6 +285,10 @@

initial_conditions!(container, devices, ThermalBasicUnitCommitment())

if haskey(get_time_series_names(model), ActivePowerTimeSeriesParameter)
add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model)

Check warning on line 289 in src/devices_models/device_constructors/thermalgeneration_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/thermalgeneration_constructor.jl#L289

Added line #L289 was not covered by tests
end

add_to_expression!(
container,
ActivePowerBalance,
Expand Down Expand Up @@ -335,6 +368,17 @@
)
add_constraints!(container, CommitmentConstraint, devices, model, network_model)

if haskey(get_time_series_names(model), ActivePowerTimeSeriesParameter)
add_constraints!(

Check warning on line 372 in src/devices_models/device_constructors/thermalgeneration_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/thermalgeneration_constructor.jl#L372

Added line #L372 was not covered by tests
container,
ActivePowerVariableTimeSeriesLimitsConstraint,
ActivePowerRangeExpressionUB,
devices,
model,
network_model,
)
end

add_feedforward_constraints!(container, model, devices)

objective_function!(container, devices, model, get_network_formulation(network_model))
Expand All @@ -361,6 +405,10 @@

initial_conditions!(container, devices, ThermalBasicUnitCommitment())

if haskey(get_time_series_names(model), ActivePowerTimeSeriesParameter)
add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model)

Check warning on line 409 in src/devices_models/device_constructors/thermalgeneration_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/thermalgeneration_constructor.jl#L409

Added line #L409 was not covered by tests
end

add_to_expression!(
container,
ActivePowerBalance,
Expand Down Expand Up @@ -423,6 +471,16 @@
)

add_constraints!(container, CommitmentConstraint, devices, model, network_model)
if haskey(get_time_series_names(model), ActivePowerTimeSeriesParameter)
add_constraints!(

Check warning on line 475 in src/devices_models/device_constructors/thermalgeneration_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/thermalgeneration_constructor.jl#L475

Added line #L475 was not covered by tests
container,
ActivePowerVariableTimeSeriesLimitsConstraint,
ActivePowerRangeExpressionUB,
devices,
model,
network_model,
)
end

add_feedforward_constraints!(container, model, devices)

Expand Down Expand Up @@ -829,6 +887,10 @@

initial_conditions!(container, devices, ThermalMultiStartUnitCommitment())

if haskey(get_time_series_names(model), ActivePowerTimeSeriesParameter)
add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model)

Check warning on line 891 in src/devices_models/device_constructors/thermalgeneration_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/thermalgeneration_constructor.jl#L891

Added line #L891 was not covered by tests
end

add_to_expression!(
container,
ActivePowerBalance,
Expand Down Expand Up @@ -931,6 +993,16 @@
network_model,
)
add_constraints!(container, ActiveRangeICConstraint, devices, model, network_model)
if haskey(get_time_series_names(model), ActivePowerTimeSeriesParameter)
add_constraints!(

Check warning on line 997 in src/devices_models/device_constructors/thermalgeneration_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/thermalgeneration_constructor.jl#L997

Added line #L997 was not covered by tests
container,
ActivePowerVariableTimeSeriesLimitsConstraint,
ActivePowerRangeExpressionUB,
devices,
model,
network_model,
)
end

add_feedforward_constraints!(container, model, devices)

Expand Down Expand Up @@ -965,6 +1037,10 @@
add_variables!(container, TimeDurationOff, devices, ThermalMultiStartUnitCommitment())
add_variables!(container, PowerOutput, devices, ThermalMultiStartUnitCommitment())

if haskey(get_time_series_names(model), ActivePowerTimeSeriesParameter)
add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model)

Check warning on line 1041 in src/devices_models/device_constructors/thermalgeneration_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/thermalgeneration_constructor.jl#L1041

Added line #L1041 was not covered by tests
end

add_to_expression!(
container,
ActivePowerBalance,
Expand Down Expand Up @@ -1053,6 +1129,16 @@
network_model,
)
add_constraints!(container, ActiveRangeICConstraint, devices, model, network_model)
if haskey(get_time_series_names(model), ActivePowerTimeSeriesParameter)
add_constraints!(

Check warning on line 1133 in src/devices_models/device_constructors/thermalgeneration_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/thermalgeneration_constructor.jl#L1133

Added line #L1133 was not covered by tests
container,
ActivePowerVariableTimeSeriesLimitsConstraint,
ActivePowerRangeExpressionUB,
devices,
model,
network_model,
)
end

add_feedforward_constraints!(container, model, devices)

Expand Down Expand Up @@ -1092,6 +1178,10 @@

initial_conditions!(container, devices, ThermalCompactUnitCommitment())

if haskey(get_time_series_names(model), ActivePowerTimeSeriesParameter)
add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model)

Check warning on line 1182 in src/devices_models/device_constructors/thermalgeneration_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/thermalgeneration_constructor.jl#L1182

Added line #L1182 was not covered by tests
end

add_to_expression!(
container,
ActivePowerBalance,
Expand Down Expand Up @@ -1169,6 +1259,16 @@
add_constraints!(container, CommitmentConstraint, devices, model, network_model)
add_constraints!(container, RampConstraint, devices, model, network_model)
add_constraints!(container, DurationConstraint, devices, model, network_model)
if haskey(get_time_series_names(model), ActivePowerTimeSeriesParameter)
add_constraints!(

Check warning on line 1263 in src/devices_models/device_constructors/thermalgeneration_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/thermalgeneration_constructor.jl#L1263

Added line #L1263 was not covered by tests
container,
ActivePowerVariableTimeSeriesLimitsConstraint,
ActivePowerRangeExpressionUB,
devices,
model,
network_model,
)
end

add_feedforward_constraints!(container, model, devices)

Expand Down Expand Up @@ -1202,6 +1302,10 @@

initial_conditions!(container, devices, ThermalCompactUnitCommitment())

if haskey(get_time_series_names(model), ActivePowerTimeSeriesParameter)
add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model)

Check warning on line 1306 in src/devices_models/device_constructors/thermalgeneration_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/thermalgeneration_constructor.jl#L1306

Added line #L1306 was not covered by tests
end

add_to_expression!(
container,
ActivePowerBalance,
Expand Down Expand Up @@ -1270,6 +1374,16 @@
add_constraints!(container, CommitmentConstraint, devices, model, network_model)
add_constraints!(container, RampConstraint, devices, model, network_model)
add_constraints!(container, DurationConstraint, devices, model, network_model)
if haskey(get_time_series_names(model), ActivePowerTimeSeriesParameter)
add_constraints!(

Check warning on line 1378 in src/devices_models/device_constructors/thermalgeneration_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/thermalgeneration_constructor.jl#L1378

Added line #L1378 was not covered by tests
container,
ActivePowerVariableTimeSeriesLimitsConstraint,
ActivePowerRangeExpressionUB,
devices,
model,
network_model,
)
end

add_feedforward_constraints!(container, model, devices)

Expand Down Expand Up @@ -1307,6 +1421,10 @@

initial_conditions!(container, devices, ThermalBasicCompactUnitCommitment())

if haskey(get_time_series_names(model), ActivePowerTimeSeriesParameter)
add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model)

Check warning on line 1425 in src/devices_models/device_constructors/thermalgeneration_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/thermalgeneration_constructor.jl#L1425

Added line #L1425 was not covered by tests
end

add_to_expression!(
container,
ActivePowerBalance,
Expand Down Expand Up @@ -1382,6 +1500,16 @@
network_model,
)
add_constraints!(container, CommitmentConstraint, devices, model, network_model)
if haskey(get_time_series_names(model), ActivePowerTimeSeriesParameter)
add_constraints!(

Check warning on line 1504 in src/devices_models/device_constructors/thermalgeneration_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/thermalgeneration_constructor.jl#L1504

Added line #L1504 was not covered by tests
container,
ActivePowerVariableTimeSeriesLimitsConstraint,
ActivePowerRangeExpressionUB,
devices,
model,
network_model,
)
end

add_feedforward_constraints!(container, model, devices)

Expand Down Expand Up @@ -1413,6 +1541,10 @@

initial_conditions!(container, devices, ThermalBasicCompactUnitCommitment())

if haskey(get_time_series_names(model), ActivePowerTimeSeriesParameter)
add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model)

Check warning on line 1545 in src/devices_models/device_constructors/thermalgeneration_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/thermalgeneration_constructor.jl#L1545

Added line #L1545 was not covered by tests
end

add_to_expression!(
container,
ActivePowerBalance,
Expand Down Expand Up @@ -1479,6 +1611,16 @@
)

add_constraints!(container, CommitmentConstraint, devices, model, network_model)
if haskey(get_time_series_names(model), ActivePowerTimeSeriesParameter)
add_constraints!(

Check warning on line 1615 in src/devices_models/device_constructors/thermalgeneration_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/thermalgeneration_constructor.jl#L1615

Added line #L1615 was not covered by tests
container,
ActivePowerVariableTimeSeriesLimitsConstraint,
ActivePowerRangeExpressionUB,
devices,
model,
network_model,
)
end

add_feedforward_constraints!(container, model, devices)

Expand Down
19 changes: 16 additions & 3 deletions src/devices_models/devices/common/range_constraint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,9 @@
jump_model = get_jump_model(container)
time_steps = axes(constraint_container)[2]
for device in devices
if !(PSY.has_time_series(device))
continue

Check warning on line 710 in src/devices_models/devices/common/range_constraint.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/devices/common/range_constraint.jl#L709-L710

Added lines #L709 - L710 were not covered by tests
end
name = PSY.get_name(device)
param = get_parameter_column_refs(param_container, name)
for t in time_steps
Expand All @@ -730,8 +733,11 @@
W <: AbstractDeviceFormulation,
}
time_steps = get_time_steps(container)
names = [PSY.get_name(d) for d in devices]

names = [PSY.get_name(d) for d in devices if PSY.has_time_series(d)]
if isempty(names)
@debug "There are no $V devices with time series data"
return

Check warning on line 739 in src/devices_models/devices/common/range_constraint.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/devices/common/range_constraint.jl#L736-L739

Added lines #L736 - L739 were not covered by tests
end
constraint =
add_constraints_container!(container, T(), V, names, time_steps; meta = "lb")

Expand Down Expand Up @@ -842,6 +848,9 @@
time_steps = axes(constraint_container)[2]
for device in devices
name = PSY.get_name(device)
if !(PSY.has_time_series(device))
continue
end
param = get_parameter_column_refs(param_container, name)
for t in time_steps
constraint_container[name, t] =
Expand All @@ -865,7 +874,11 @@
W <: AbstractDeviceFormulation,
}
time_steps = get_time_steps(container)
names = [PSY.get_name(d) for d in devices]
names = [PSY.get_name(d) for d in devices if PSY.has_time_series(d)]
if isempty(names)
@debug "There are no $V devices with time series data"
return

Check warning on line 880 in src/devices_models/devices/common/range_constraint.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/devices/common/range_constraint.jl#L879-L880

Added lines #L879 - L880 were not covered by tests
end

constraint =
add_constraints_container!(container, T(), V, names, time_steps; meta = "ub")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ get_variable_lower_bound(_, ::PSY.Component, __) = nothing
get_variable_upper_bound(_, ::PSY.Component, __) = nothing

get_multiplier_value(x, y::PSY.Component, z) =
error("Unable to get parameter $x for device $y for formulation $z")
error("Unable to get parameter $x for device $(IS.summary(y)) for formulation $z")

get_expression_type_for_reserve(_, y::Type{<:PSY.Component}, z) =
error("`get_expression_type_for_reserve` must be implemented for $y and $z")
Expand Down
25 changes: 25 additions & 0 deletions src/devices_models/devices/thermal_generation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ get_variable_upper_bound(::StartVariable, d::PSY.ThermalGen, ::AbstractThermalFo
get_variable_binary(::Union{ColdStartVariable, WarmStartVariable, HotStartVariable}, ::Type{PSY.ThermalMultiStart}, ::AbstractThermalFormulation) = true

########################### Parameter related set functions ################################
get_multiplier_value(::ActivePowerTimeSeriesParameter, d::PSY.ThermalGen, ::AbstractThermalFormulation) = PSY.get_max_active_power(d)
get_parameter_multiplier(::VariableValueParameter, d::PSY.ThermalGen, ::AbstractThermalFormulation) = 1.0
get_initial_parameter_value(::VariableValueParameter, d::PSY.ThermalGen, ::AbstractThermalFormulation) = 1.0
get_expression_multiplier(::OnStatusParameter, ::ActivePowerRangeExpressionUB, d::PSY.ThermalGen, ::AbstractThermalFormulation) = PSY.get_active_power_limits(d).max
Expand Down Expand Up @@ -442,6 +443,30 @@ function _get_data_for_range_ic(
return ini_conds
end

function add_constraints!(
container::OptimizationContainer,
::Type{ActivePowerVariableTimeSeriesLimitsConstraint},
U::Type{<:Union{ActivePowerVariable, ActivePowerRangeExpressionUB}},
devices::IS.FlattenIteratorWrapper{V},
model::DeviceModel{V, W},
::NetworkModel{X},
) where {
V <: PSY.ThermalGen,
W <: AbstractThermalUnitCommitment,
X <: PM.AbstractPowerModel,
}
add_parameterized_upper_bound_range_constraints(
container,
ActivePowerVariableTimeSeriesLimitsConstraint,
U,
ActivePowerTimeSeriesParameter,
devices,
model,
X,
)
return
end

"""
This function adds range constraint for the first time period. Constraint (10) from PGLIB formulation
"""
Expand Down
Loading
Loading