Skip to content

Commit

Permalink
Merge pull request #1162 from NREL-Sienna/jd/add_thermal_time_series
Browse files Browse the repository at this point in the history
Jd/add thermal time series
  • Loading branch information
jd-lara authored Dec 4, 2024
2 parents 5e3e737 + ea672b6 commit 4960e1f
Show file tree
Hide file tree
Showing 12 changed files with 282 additions and 11 deletions.
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 @@ function construct_device!(

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 @@ -135,6 +139,17 @@ function construct_device!(
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)

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

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 @@ function construct_device!(
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 @@ function construct_device!(

initial_conditions!(container, devices, ThermalBasicUnitCommitment())

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

add_to_expression!(
container,
ActivePowerBalance,
Expand Down Expand Up @@ -335,6 +368,17 @@ function construct_device!(
)
add_constraints!(container, CommitmentConstraint, 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)

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

initial_conditions!(container, devices, ThermalBasicUnitCommitment())

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

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

add_constraints!(container, CommitmentConstraint, 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 @@ -829,6 +887,10 @@ function construct_device!(

initial_conditions!(container, devices, ThermalMultiStartUnitCommitment())

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

add_to_expression!(
container,
ActivePowerBalance,
Expand Down Expand Up @@ -931,6 +993,16 @@ function construct_device!(
network_model,
)
add_constraints!(container, ActiveRangeICConstraint, 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 @@ -965,6 +1037,10 @@ function construct_device!(
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)
end

add_to_expression!(
container,
ActivePowerBalance,
Expand Down Expand Up @@ -1053,6 +1129,16 @@ function construct_device!(
network_model,
)
add_constraints!(container, ActiveRangeICConstraint, 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 @@ -1092,6 +1178,10 @@ function construct_device!(

initial_conditions!(container, devices, ThermalCompactUnitCommitment())

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

add_to_expression!(
container,
ActivePowerBalance,
Expand Down Expand Up @@ -1169,6 +1259,16 @@ function construct_device!(
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 @@ -1202,6 +1302,10 @@ function construct_device!(

initial_conditions!(container, devices, ThermalCompactUnitCommitment())

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

add_to_expression!(
container,
ActivePowerBalance,
Expand Down Expand Up @@ -1270,6 +1374,16 @@ function construct_device!(
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 @@ -1307,6 +1421,10 @@ function construct_device!(

initial_conditions!(container, devices, ThermalBasicCompactUnitCommitment())

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

add_to_expression!(
container,
ActivePowerBalance,
Expand Down Expand Up @@ -1382,6 +1500,16 @@ function construct_device!(
network_model,
)
add_constraints!(container, CommitmentConstraint, 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 @@ -1413,6 +1541,10 @@ function construct_device!(

initial_conditions!(container, devices, ThermalBasicCompactUnitCommitment())

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

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

add_constraints!(container, CommitmentConstraint, 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
10 changes: 8 additions & 2 deletions src/devices_models/devices/common/objective_function/common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,14 @@ function _add_vom_cost_to_objective!(
)
for t in get_time_steps(container)
exp =
_add_proportional_term!(container, T(), d, cost_term_normalized * multiplier, t)
add_to_expression!(container, ProductionCostExpression, exp, d, t)
_add_proportional_term!(
container,
T(),
component,
cost_term_normalized * multiplier,
t,
)
add_to_expression!(container, ProductionCostExpression, exp, component, t)
end
return
end
Expand Down
29 changes: 25 additions & 4 deletions src/devices_models/devices/common/range_constraint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,12 @@ function lower_bound_range_with_parameter!(
mult = get_multiplier_array(param_container)
jump_model = get_jump_model(container)
time_steps = axes(constraint_container)[2]
ts_name = get_time_series_names(model)[P]
ts_type = get_default_time_series_type(container)
for device in devices
if !(PSY.has_time_series(device, ts_type, ts_name))
continue
end
name = PSY.get_name(device)
param = get_parameter_column_refs(param_container, name)
for t in time_steps
Expand All @@ -730,8 +735,13 @@ function _add_parameterized_lower_bound_range_constraints_impl!(
W <: AbstractDeviceFormulation,
}
time_steps = get_time_steps(container)
names = [PSY.get_name(d) for d in devices]

ts_name = get_time_series_names(model)[U]
ts_type = get_default_time_series_type(container)
names = [PSY.get_name(d) for d in devices if PSY.has_time_series(d, ts_type, ts_name)]
if isempty(names)
@debug "There are no $V devices with time series data"
return
end
constraint =
add_constraints_container!(container, T(), V, names, time_steps; meta = "lb")

Expand Down Expand Up @@ -834,14 +844,19 @@ function upper_bound_range_with_parameter!(
lhs_array,
param::P,
devices::IS.FlattenIteratorWrapper{V},
::DeviceModel{V, W},
model::DeviceModel{V, W},
) where {P <: TimeSeriesParameter, V <: PSY.Component, W <: AbstractDeviceFormulation}
param_container = get_parameter(container, param, V)
mult = get_multiplier_array(param_container)
jump_model = get_jump_model(container)
time_steps = axes(constraint_container)[2]
ts_name = get_time_series_names(model)[P]
ts_type = get_default_time_series_type(container)
for device in devices
name = PSY.get_name(device)
if !(PSY.has_time_series(device, ts_type, ts_name))
continue
end
param = get_parameter_column_refs(param_container, name)
for t in time_steps
constraint_container[name, t] =
Expand All @@ -865,7 +880,13 @@ function _add_parameterized_upper_bound_range_constraints_impl!(
W <: AbstractDeviceFormulation,
}
time_steps = get_time_steps(container)
names = [PSY.get_name(d) for d in devices]
ts_name = get_time_series_names(model)[P]
ts_type = get_default_time_series_type(container)
names = [PSY.get_name(d) for d in devices if PSY.has_time_series(d, ts_type, ts_name)]
if isempty(names)
@debug "There are no $V devices with time series data $ts_type, $ts_name"
return
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
Loading

0 comments on commit 4960e1f

Please sign in to comment.