From 7f0e4d027ac612c04a5108e31325730466a4ef6a Mon Sep 17 00:00:00 2001 From: pesap Date: Thu, 24 Aug 2023 17:26:34 -0600 Subject: [PATCH 1/6] Removing Hydro related stuff. --- src/PowerSimulations.jl | 2 +- src/core/formulations.jl | 26 +- .../hydrogeneration_constructor.jl | 936 +++++++++--------- .../devices/hydro_generation.jl | 589 +++++------ ...st_device_hydro_generation_constructors.jl | 121 --- 5 files changed, 778 insertions(+), 896 deletions(-) delete mode 100644 test/test_device_hydro_generation_constructors.jl diff --git a/src/PowerSimulations.jl b/src/PowerSimulations.jl index 2fc2a5b2b6..f8c7d4c1d8 100644 --- a/src/PowerSimulations.jl +++ b/src/PowerSimulations.jl @@ -70,7 +70,7 @@ export DeviceLimitedRegulation export ReserveLimitedRegulation ###### Hydro ####### -export HydroDispatchRunOfRiver +# export HydroDispatchRunOfRiver export HydroCommitmentRunOfRiver # feedforward models diff --git a/src/core/formulations.jl b/src/core/formulations.jl index 6752ad5599..4fefb8d6f1 100644 --- a/src/core/formulations.jl +++ b/src/core/formulations.jl @@ -73,19 +73,19 @@ Formulation type to enable (continuous) load interruption dispatch struct PowerLoadDispatch <: AbstractControllablePowerLoadFormulation end ############################ Hydro Generation Formulations ################################# -abstract type AbstractHydroFormulation <: AbstractDeviceFormulation end -abstract type AbstractHydroDispatchFormulation <: AbstractHydroFormulation end -abstract type AbstractHydroUnitCommitment <: AbstractHydroFormulation end - -""" -Formulation type to add injection variables constrained by a maximum injection time series for `HydroGen` -""" -struct HydroDispatchRunOfRiver <: AbstractHydroDispatchFormulation end - -""" -Formulation type to add commitment and injection variables constrained by a maximum injection time series for `HydroGen` -""" -struct HydroCommitmentRunOfRiver <: AbstractHydroUnitCommitment end +# abstract type AbstractHydroFormulation <: AbstractDeviceFormulation end +# abstract type AbstractHydroDispatchFormulation <: AbstractHydroFormulation end +# abstract type AbstractHydroUnitCommitment <: AbstractHydroFormulation end + +# """ +# Formulation type to add injection variables constrained by a maximum injection time series for `HydroGen` +# """ +# struct HydroDispatchRunOfRiver <: AbstractHydroDispatchFormulation end + +# """ +# Formulation type to add commitment and injection variables constrained by a maximum injection time series for `HydroGen` +# """ +# struct HydroCommitmentRunOfRiver <: AbstractHydroUnitCommitment end ############################ Regulation Device Formulations ################################ abstract type AbstractRegulationFormulation <: AbstractDeviceFormulation end diff --git a/src/devices_models/device_constructors/hydrogeneration_constructor.jl b/src/devices_models/device_constructors/hydrogeneration_constructor.jl index 75673eba77..c1ed64385f 100644 --- a/src/devices_models/device_constructors/hydrogeneration_constructor.jl +++ b/src/devices_models/device_constructors/hydrogeneration_constructor.jl @@ -1,468 +1,468 @@ -""" -Construct model for HydroGen with FixedOutput Formulation -""" -function construct_device!( - container::OptimizationContainer, - sys::PSY.System, - ::ArgumentConstructStage, - model::DeviceModel{H, FixedOutput}, - network_model::NetworkModel{S}, -) where {H <: PSY.HydroGen, S <: PM.AbstractPowerModel} - devices = - get_available_components(H, sys, get_attribute(model, "filter_function")) - - add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model) - add_parameters!(container, ReactivePowerTimeSeriesParameter, devices, model) - - # Expression - add_to_expression!( - container, - ActivePowerBalance, - ActivePowerTimeSeriesParameter, - devices, - model, - network_model, - ) - add_to_expression!( - container, - ReactivePowerBalance, - ReactivePowerTimeSeriesParameter, - devices, - model, - network_model, - ) - return -end - -function construct_device!( - ::OptimizationContainer, - ::PSY.System, - ::ModelConstructStage, - ::DeviceModel{H, FixedOutput}, - network_model::NetworkModel{S}, -) where {H <: PSY.HydroGen, S <: PM.AbstractPowerModel} - # FixedOutput doesn't add any constraints to the model. This function covers - # AbstractPowerModel and AbstractActivePowerModel - return -end - -function construct_device!( - container::OptimizationContainer, - sys::PSY.System, - ::ArgumentConstructStage, - model::DeviceModel{H, FixedOutput}, - network_model::NetworkModel{S}, -) where {H <: PSY.HydroGen, S <: PM.AbstractActivePowerModel} - devices = - get_available_components(H, sys, get_attribute(model, "filter_function")) - - add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model) - - # Expression - add_to_expression!( - container, - ActivePowerBalance, - ActivePowerTimeSeriesParameter, - devices, - model, - network_model, - ) - return -end - -""" -Construct model for HydroGen with RunOfRiver (default Hydro model) Dispatch Formulation -""" -function construct_device!( - container::OptimizationContainer, - sys::PSY.System, - ::ArgumentConstructStage, - model::DeviceModel{H, D}, - network_model::NetworkModel{S}, -) where { - H <: PSY.HydroGen, - D <: AbstractHydroDispatchFormulation, - S <: PM.AbstractPowerModel, -} - devices = - get_available_components(H, sys, get_attribute(model, "filter_function")) - - add_variables!(container, ActivePowerVariable, devices, D()) - add_variables!(container, ReactivePowerVariable, devices, D()) - add_variables!(container, EnergyOutput, devices, D()) - add_to_expression!( - container, - ActivePowerBalance, - ActivePowerVariable, - devices, - model, - network_model, - ) - add_to_expression!( - container, - ReactivePowerBalance, - ReactivePowerVariable, - devices, - model, - network_model, - ) - - add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model) - - add_expressions!(container, ProductionCostExpression, devices, model) - - add_to_expression!( - container, - ActivePowerRangeExpressionLB, - ActivePowerVariable, - devices, - model, - network_model, - ) - add_to_expression!( - container, - ActivePowerRangeExpressionUB, - ActivePowerVariable, - devices, - model, - network_model, - ) - - add_feedforward_arguments!(container, model, devices) - return -end - -function construct_device!( - container::OptimizationContainer, - sys::PSY.System, - ::ModelConstructStage, - model::DeviceModel{H, D}, - network_model::NetworkModel{S}, -) where { - H <: PSY.HydroGen, - D <: AbstractHydroDispatchFormulation, - S <: PM.AbstractPowerModel, -} - devices = - get_available_components(H, sys, get_attribute(model, "filter_function")) - - add_constraints!( - container, - ActivePowerVariableLimitsConstraint, - ActivePowerRangeExpressionLB, - devices, - model, - network_model, - ) - add_constraints!( - container, - ActivePowerVariableLimitsConstraint, - ActivePowerRangeExpressionUB, - devices, - model, - network_model, - ) - - add_constraints!( - container, - ReactivePowerVariableLimitsConstraint, - ReactivePowerVariable, - devices, - model, - network_model, - ) - add_feedforward_constraints!(container, model, devices) - - objective_function!(container, devices, model, S) - add_constraint_dual!(container, sys, model) - - return -end - -""" -Construct model for HydroGen with RunOfRiver (default Hydro model) Dispatch Formulation -with only Active Power. -""" -function construct_device!( - container::OptimizationContainer, - sys::PSY.System, - ::ArgumentConstructStage, - model::DeviceModel{H, D}, - network_model::NetworkModel{S}, -) where { - H <: PSY.HydroGen, - D <: AbstractHydroDispatchFormulation, - S <: PM.AbstractActivePowerModel, -} - devices = - get_available_components(H, sys, get_attribute(model, "filter_function")) - - add_variables!(container, ActivePowerVariable, devices, D()) - add_variables!(container, EnergyOutput, devices, D()) - add_to_expression!( - container, - ActivePowerBalance, - ActivePowerVariable, - devices, - model, - network_model, - ) - - add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model) - add_to_expression!( - container, - ActivePowerRangeExpressionLB, - ActivePowerVariable, - devices, - model, - network_model, - ) - add_to_expression!( - container, - ActivePowerRangeExpressionUB, - ActivePowerVariable, - devices, - model, - network_model, - ) - - add_expressions!(container, ProductionCostExpression, devices, model) - - add_feedforward_arguments!(container, model, devices) - return -end - -function construct_device!( - container::OptimizationContainer, - sys::PSY.System, - ::ModelConstructStage, - model::DeviceModel{H, D}, - network_model::NetworkModel{S}, -) where { - H <: PSY.HydroGen, - D <: AbstractHydroDispatchFormulation, - S <: PM.AbstractActivePowerModel, -} - devices = - get_available_components(H, sys, get_attribute(model, "filter_function")) - - add_constraints!( - container, - ActivePowerVariableLimitsConstraint, - ActivePowerRangeExpressionLB, - devices, - model, - network_model, - ) - add_constraints!( - container, - ActivePowerVariableLimitsConstraint, - ActivePowerRangeExpressionUB, - devices, - model, - network_model, - ) - - add_feedforward_constraints!(container, model, devices) - - objective_function!(container, devices, model, S) - - add_constraint_dual!(container, sys, model) - return -end - -""" -Construct model for HydroGen with RunOfRiver Commitment Formulation -""" -function construct_device!( - container::OptimizationContainer, - sys::PSY.System, - ::ArgumentConstructStage, - model::DeviceModel{H, D}, - network_model::NetworkModel{S}, -) where {H <: PSY.HydroGen, D <: HydroCommitmentRunOfRiver, S <: PM.AbstractPowerModel} - devices = - get_available_components(H, sys, get_attribute(model, "filter_function")) - - add_variables!(container, ActivePowerVariable, devices, D()) - add_variables!(container, ReactivePowerVariable, devices, D()) - add_variables!(container, OnVariable, devices, D()) - add_variables!(container, EnergyOutput, devices, D()) - add_to_expression!( - container, - ActivePowerBalance, - ActivePowerVariable, - devices, - model, - network_model, - ) - - add_to_expression!( - container, - ReactivePowerBalance, - ReactivePowerVariable, - devices, - model, - network_model, - ) - - add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model) - - add_expressions!(container, ProductionCostExpression, devices, model) - - add_to_expression!( - container, - ActivePowerRangeExpressionLB, - ActivePowerVariable, - devices, - model, - network_model, - ) - add_to_expression!( - container, - ActivePowerRangeExpressionUB, - ActivePowerVariable, - devices, - model, - network_model, - ) - add_feedforward_arguments!(container, model, devices) - return -end - -function construct_device!( - container::OptimizationContainer, - sys::PSY.System, - ::ModelConstructStage, - model::DeviceModel{H, D}, - network_model::NetworkModel{S}, -) where {H <: PSY.HydroGen, D <: HydroCommitmentRunOfRiver, S <: PM.AbstractPowerModel} - devices = - get_available_components(H, sys, get_attribute(model, "filter_function")) - - add_constraints!( - container, - ActivePowerVariableLimitsConstraint, - ActivePowerRangeExpressionLB, - devices, - model, - network_model, - ) - add_constraints!( - container, - ActivePowerVariableLimitsConstraint, - ActivePowerRangeExpressionUB, - devices, - model, - network_model, - ) - - add_constraints!( - container, - ReactivePowerVariableLimitsConstraint, - ReactivePowerVariable, - devices, - model, - network_model, - ) - - add_feedforward_constraints!(container, model, devices) - - objective_function!(container, devices, model, S) - - add_constraint_dual!(container, sys, model) - return -end - -""" -Construct model for HydroGen with RunOfRiver Commitment Formulation -with only Active Power. -""" -function construct_device!( - container::OptimizationContainer, - sys::PSY.System, - ::ArgumentConstructStage, - model::DeviceModel{H, D}, - network_model::NetworkModel{S}, -) where { - H <: PSY.HydroGen, - D <: HydroCommitmentRunOfRiver, - S <: PM.AbstractActivePowerModel, -} - devices = - get_available_components(H, sys, get_attribute(model, "filter_function")) - - add_variables!(container, ActivePowerVariable, devices, D()) - add_variables!(container, OnVariable, devices, D()) - add_variables!(container, EnergyOutput, devices, D()) - add_to_expression!( - container, - ActivePowerBalance, - ActivePowerVariable, - devices, - model, - network_model, - ) - - add_expressions!(container, ProductionCostExpression, devices, model) - - add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model) - add_to_expression!( - container, - ActivePowerRangeExpressionLB, - ActivePowerVariable, - devices, - model, - network_model, - ) - add_to_expression!( - container, - ActivePowerRangeExpressionUB, - ActivePowerVariable, - devices, - model, - network_model, - ) - - add_feedforward_arguments!(container, model, devices) - return -end - -function construct_device!( - container::OptimizationContainer, - sys::PSY.System, - ::ModelConstructStage, - model::DeviceModel{H, D}, - network_model::NetworkModel{S}, -) where { - H <: PSY.HydroGen, - D <: HydroCommitmentRunOfRiver, - S <: PM.AbstractActivePowerModel, -} - devices = - get_available_components(H, sys, get_attribute(model, "filter_function")) - - add_constraints!( - container, - ActivePowerVariableLimitsConstraint, - ActivePowerRangeExpressionLB, - devices, - model, - network_model, - ) - add_constraints!( - container, - ActivePowerVariableLimitsConstraint, - ActivePowerRangeExpressionUB, - devices, - model, - network_model, - ) - - add_feedforward_constraints!(container, model, devices) - - objective_function!(container, devices, model, S) - - add_constraint_dual!(container, sys, model) - return -end +# """ +# Construct model for HydroGen with FixedOutput Formulation +# """ +# function construct_device!( +# container::OptimizationContainer, +# sys::PSY.System, +# ::ArgumentConstructStage, +# model::DeviceModel{H, FixedOutput}, +# network_model::NetworkModel{S}, +# ) where {H <: PSY.HydroGen, S <: PM.AbstractPowerModel} +# devices = +# get_available_components(H, sys, get_attribute(model, "filter_function")) +# +# add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model) +# add_parameters!(container, ReactivePowerTimeSeriesParameter, devices, model) +# +# # Expression +# add_to_expression!( +# container, +# ActivePowerBalance, +# ActivePowerTimeSeriesParameter, +# devices, +# model, +# network_model, +# ) +# add_to_expression!( +# container, +# ReactivePowerBalance, +# ReactivePowerTimeSeriesParameter, +# devices, +# model, +# network_model, +# ) +# return +# end +# +# function construct_device!( +# ::OptimizationContainer, +# ::PSY.System, +# ::ModelConstructStage, +# ::DeviceModel{H, FixedOutput}, +# network_model::NetworkModel{S}, +# ) where {H <: PSY.HydroGen, S <: PM.AbstractPowerModel} +# # FixedOutput doesn't add any constraints to the model. This function covers +# # AbstractPowerModel and AbstractActivePowerModel +# return +# end +# +# function construct_device!( +# container::OptimizationContainer, +# sys::PSY.System, +# ::ArgumentConstructStage, +# model::DeviceModel{H, FixedOutput}, +# network_model::NetworkModel{S}, +# ) where {H <: PSY.HydroGen, S <: PM.AbstractActivePowerModel} +# devices = +# get_available_components(H, sys, get_attribute(model, "filter_function")) +# +# add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model) +# +# # Expression +# add_to_expression!( +# container, +# ActivePowerBalance, +# ActivePowerTimeSeriesParameter, +# devices, +# model, +# network_model, +# ) +# return +# end +# +# """ +# Construct model for HydroGen with RunOfRiver (default Hydro model) Dispatch Formulation +# """ +# function construct_device!( +# container::OptimizationContainer, +# sys::PSY.System, +# ::ArgumentConstructStage, +# model::DeviceModel{H, D}, +# network_model::NetworkModel{S}, +# ) where { +# H <: PSY.HydroGen, +# D <: AbstractHydroDispatchFormulation, +# S <: PM.AbstractPowerModel, +# } +# devices = +# get_available_components(H, sys, get_attribute(model, "filter_function")) +# +# add_variables!(container, ActivePowerVariable, devices, D()) +# add_variables!(container, ReactivePowerVariable, devices, D()) +# add_variables!(container, EnergyOutput, devices, D()) +# add_to_expression!( +# container, +# ActivePowerBalance, +# ActivePowerVariable, +# devices, +# model, +# network_model, +# ) +# add_to_expression!( +# container, +# ReactivePowerBalance, +# ReactivePowerVariable, +# devices, +# model, +# network_model, +# ) +# +# add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model) +# +# add_expressions!(container, ProductionCostExpression, devices, model) +# +# add_to_expression!( +# container, +# ActivePowerRangeExpressionLB, +# ActivePowerVariable, +# devices, +# model, +# network_model, +# ) +# add_to_expression!( +# container, +# ActivePowerRangeExpressionUB, +# ActivePowerVariable, +# devices, +# model, +# network_model, +# ) +# +# add_feedforward_arguments!(container, model, devices) +# return +# end +# +# function construct_device!( +# container::OptimizationContainer, +# sys::PSY.System, +# ::ModelConstructStage, +# model::DeviceModel{H, D}, +# network_model::NetworkModel{S}, +# ) where { +# H <: PSY.HydroGen, +# D <: AbstractHydroDispatchFormulation, +# S <: PM.AbstractPowerModel, +# } +# devices = +# get_available_components(H, sys, get_attribute(model, "filter_function")) +# +# add_constraints!( +# container, +# ActivePowerVariableLimitsConstraint, +# ActivePowerRangeExpressionLB, +# devices, +# model, +# network_model, +# ) +# add_constraints!( +# container, +# ActivePowerVariableLimitsConstraint, +# ActivePowerRangeExpressionUB, +# devices, +# model, +# network_model, +# ) +# +# add_constraints!( +# container, +# ReactivePowerVariableLimitsConstraint, +# ReactivePowerVariable, +# devices, +# model, +# network_model, +# ) +# add_feedforward_constraints!(container, model, devices) +# +# objective_function!(container, devices, model, S) +# add_constraint_dual!(container, sys, model) +# +# return +# end +# +# """ +# Construct model for HydroGen with RunOfRiver (default Hydro model) Dispatch Formulation +# with only Active Power. +# """ +# function construct_device!( +# container::OptimizationContainer, +# sys::PSY.System, +# ::ArgumentConstructStage, +# model::DeviceModel{H, D}, +# network_model::NetworkModel{S}, +# ) where { +# H <: PSY.HydroGen, +# D <: AbstractHydroDispatchFormulation, +# S <: PM.AbstractActivePowerModel, +# } +# devices = +# get_available_components(H, sys, get_attribute(model, "filter_function")) +# +# add_variables!(container, ActivePowerVariable, devices, D()) +# add_variables!(container, EnergyOutput, devices, D()) +# add_to_expression!( +# container, +# ActivePowerBalance, +# ActivePowerVariable, +# devices, +# model, +# network_model, +# ) +# +# add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model) +# add_to_expression!( +# container, +# ActivePowerRangeExpressionLB, +# ActivePowerVariable, +# devices, +# model, +# network_model, +# ) +# add_to_expression!( +# container, +# ActivePowerRangeExpressionUB, +# ActivePowerVariable, +# devices, +# model, +# network_model, +# ) +# +# add_expressions!(container, ProductionCostExpression, devices, model) +# +# add_feedforward_arguments!(container, model, devices) +# return +# end +# +# function construct_device!( +# container::OptimizationContainer, +# sys::PSY.System, +# ::ModelConstructStage, +# model::DeviceModel{H, D}, +# network_model::NetworkModel{S}, +# ) where { +# H <: PSY.HydroGen, +# D <: AbstractHydroDispatchFormulation, +# S <: PM.AbstractActivePowerModel, +# } +# devices = +# get_available_components(H, sys, get_attribute(model, "filter_function")) +# +# add_constraints!( +# container, +# ActivePowerVariableLimitsConstraint, +# ActivePowerRangeExpressionLB, +# devices, +# model, +# network_model, +# ) +# add_constraints!( +# container, +# ActivePowerVariableLimitsConstraint, +# ActivePowerRangeExpressionUB, +# devices, +# model, +# network_model, +# ) +# +# add_feedforward_constraints!(container, model, devices) +# +# objective_function!(container, devices, model, S) +# +# add_constraint_dual!(container, sys, model) +# return +# end +# +# """ +# Construct model for HydroGen with RunOfRiver Commitment Formulation +# """ +# function construct_device!( +# container::OptimizationContainer, +# sys::PSY.System, +# ::ArgumentConstructStage, +# model::DeviceModel{H, D}, +# network_model::NetworkModel{S}, +# ) where {H <: PSY.HydroGen, D <: HydroCommitmentRunOfRiver, S <: PM.AbstractPowerModel} +# devices = +# get_available_components(H, sys, get_attribute(model, "filter_function")) +# +# add_variables!(container, ActivePowerVariable, devices, D()) +# add_variables!(container, ReactivePowerVariable, devices, D()) +# add_variables!(container, OnVariable, devices, D()) +# add_variables!(container, EnergyOutput, devices, D()) +# add_to_expression!( +# container, +# ActivePowerBalance, +# ActivePowerVariable, +# devices, +# model, +# network_model, +# ) +# +# add_to_expression!( +# container, +# ReactivePowerBalance, +# ReactivePowerVariable, +# devices, +# model, +# network_model, +# ) +# +# add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model) +# +# add_expressions!(container, ProductionCostExpression, devices, model) +# +# add_to_expression!( +# container, +# ActivePowerRangeExpressionLB, +# ActivePowerVariable, +# devices, +# model, +# network_model, +# ) +# add_to_expression!( +# container, +# ActivePowerRangeExpressionUB, +# ActivePowerVariable, +# devices, +# model, +# network_model, +# ) +# add_feedforward_arguments!(container, model, devices) +# return +# end +# +# function construct_device!( +# container::OptimizationContainer, +# sys::PSY.System, +# ::ModelConstructStage, +# model::DeviceModel{H, D}, +# network_model::NetworkModel{S}, +# ) where {H <: PSY.HydroGen, D <: HydroCommitmentRunOfRiver, S <: PM.AbstractPowerModel} +# devices = +# get_available_components(H, sys, get_attribute(model, "filter_function")) +# +# add_constraints!( +# container, +# ActivePowerVariableLimitsConstraint, +# ActivePowerRangeExpressionLB, +# devices, +# model, +# network_model, +# ) +# add_constraints!( +# container, +# ActivePowerVariableLimitsConstraint, +# ActivePowerRangeExpressionUB, +# devices, +# model, +# network_model, +# ) +# +# add_constraints!( +# container, +# ReactivePowerVariableLimitsConstraint, +# ReactivePowerVariable, +# devices, +# model, +# network_model, +# ) +# +# add_feedforward_constraints!(container, model, devices) +# +# objective_function!(container, devices, model, S) +# +# add_constraint_dual!(container, sys, model) +# return +# end +# +# """ +# Construct model for HydroGen with RunOfRiver Commitment Formulation +# with only Active Power. +# """ +# function construct_device!( +# container::OptimizationContainer, +# sys::PSY.System, +# ::ArgumentConstructStage, +# model::DeviceModel{H, D}, +# network_model::NetworkModel{S}, +# ) where { +# H <: PSY.HydroGen, +# D <: HydroCommitmentRunOfRiver, +# S <: PM.AbstractActivePowerModel, +# } +# devices = +# get_available_components(H, sys, get_attribute(model, "filter_function")) +# +# add_variables!(container, ActivePowerVariable, devices, D()) +# add_variables!(container, OnVariable, devices, D()) +# add_variables!(container, EnergyOutput, devices, D()) +# add_to_expression!( +# container, +# ActivePowerBalance, +# ActivePowerVariable, +# devices, +# model, +# network_model, +# ) +# +# add_expressions!(container, ProductionCostExpression, devices, model) +# +# add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model) +# add_to_expression!( +# container, +# ActivePowerRangeExpressionLB, +# ActivePowerVariable, +# devices, +# model, +# network_model, +# ) +# add_to_expression!( +# container, +# ActivePowerRangeExpressionUB, +# ActivePowerVariable, +# devices, +# model, +# network_model, +# ) +# +# add_feedforward_arguments!(container, model, devices) +# return +# end +# +# function construct_device!( +# container::OptimizationContainer, +# sys::PSY.System, +# ::ModelConstructStage, +# model::DeviceModel{H, D}, +# network_model::NetworkModel{S}, +# ) where { +# H <: PSY.HydroGen, +# D <: HydroCommitmentRunOfRiver, +# S <: PM.AbstractActivePowerModel, +# } +# devices = +# get_available_components(H, sys, get_attribute(model, "filter_function")) +# +# add_constraints!( +# container, +# ActivePowerVariableLimitsConstraint, +# ActivePowerRangeExpressionLB, +# devices, +# model, +# network_model, +# ) +# add_constraints!( +# container, +# ActivePowerVariableLimitsConstraint, +# ActivePowerRangeExpressionUB, +# devices, +# model, +# network_model, +# ) +# +# add_feedforward_constraints!(container, model, devices) +# +# objective_function!(container, devices, model, S) +# +# add_constraint_dual!(container, sys, model) +# return +# end diff --git a/src/devices_models/devices/hydro_generation.jl b/src/devices_models/devices/hydro_generation.jl index 95cd47efec..4db297382a 100644 --- a/src/devices_models/devices/hydro_generation.jl +++ b/src/devices_models/devices/hydro_generation.jl @@ -1,293 +1,296 @@ -#! format: off -requires_initialization(::AbstractHydroFormulation) = false -requires_initialization(::AbstractHydroUnitCommitment) = true - -get_variable_multiplier(_, ::Type{<:PSY.HydroGen}, ::AbstractHydroFormulation) = 1.0 -get_expression_type_for_reserve(::ActivePowerReserveVariable, ::Type{<:PSY.HydroGen}, ::Type{<:PSY.Reserve{PSY.ReserveUp}}) = ActivePowerRangeExpressionUB -get_expression_type_for_reserve(::ActivePowerReserveVariable, ::Type{<:PSY.HydroGen}, ::Type{<:PSY.Reserve{PSY.ReserveDown}}) = ActivePowerRangeExpressionLB - -########################### ActivePowerVariable, HydroGen ################################# -get_variable_binary(::ActivePowerVariable, ::Type{<:PSY.HydroGen}, ::AbstractHydroFormulation) = false -get_variable_warm_start_value(::ActivePowerVariable, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_active_power(d) -get_variable_lower_bound(::ActivePowerVariable, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_active_power_limits(d).min -get_variable_lower_bound(::ActivePowerVariable, d::PSY.HydroGen, ::AbstractHydroUnitCommitment) = 0.0 -get_variable_upper_bound(::ActivePowerVariable, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_active_power_limits(d).max - -############## ActivePowerVariable, HydroDispatchRunOfRiver #################### -get_variable_lower_bound(::ActivePowerVariable, d::PSY.HydroGen, ::HydroDispatchRunOfRiver) = 0.0 - -############## ReactivePowerVariable, HydroGen #################### -get_variable_binary(::ReactivePowerVariable, ::Type{<:PSY.HydroGen}, ::AbstractHydroFormulation) = false -get_variable_warm_start_value(::ReactivePowerVariable, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_reactive_power(d) -get_variable_lower_bound(::ReactivePowerVariable, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_reactive_power_limits(d).min -get_variable_upper_bound(::ReactivePowerVariable, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_reactive_power_limits(d).max - -############## OnVariable, HydroGen #################### -get_variable_binary(::OnVariable, ::Type{<:PSY.HydroGen}, ::AbstractHydroFormulation) = true -get_variable_warm_start_value(::OnVariable, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_active_power(d) > 0 ? 1.0 : 0.0 - -########################### Parameter related set functions ################################ -get_multiplier_value(::TimeSeriesParameter, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_max_active_power(d) -get_multiplier_value(::TimeSeriesParameter, d::PSY.HydroGen, ::FixedOutput) = PSY.get_max_active_power(d) - -get_parameter_multiplier(::VariableValueParameter, d::PSY.HydroGen, ::AbstractHydroFormulation) = 1.0 -get_initial_parameter_value(::VariableValueParameter, d::PSY.HydroGen, ::AbstractHydroFormulation) = 1.0 -get_expression_multiplier(::OnStatusParameter, ::ActivePowerRangeExpressionUB, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_active_power_limits(d).max -get_expression_multiplier(::OnStatusParameter, ::ActivePowerRangeExpressionLB, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_active_power_limits(d).min - -#################### Initial Conditions for models ############### -initial_condition_default(::DeviceStatus, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_status(d) -initial_condition_variable(::DeviceStatus, d::PSY.HydroGen, ::AbstractHydroFormulation) = OnVariable() -initial_condition_default(::DevicePower, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_active_power(d) -initial_condition_variable(::DevicePower, d::PSY.HydroGen, ::AbstractHydroFormulation) = ActivePowerVariable() -initial_condition_default(::InitialTimeDurationOn, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_status(d) ? PSY.get_time_at_status(d) : 0.0 -initial_condition_variable(::InitialTimeDurationOn, d::PSY.HydroGen, ::AbstractHydroFormulation) = OnVariable() -initial_condition_default(::InitialTimeDurationOff, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_status(d) ? 0.0 : PSY.get_time_at_status(d) -initial_condition_variable(::InitialTimeDurationOff, d::PSY.HydroGen, ::AbstractHydroFormulation) = OnVariable() - -########################Objective Function################################################## -proportional_cost(cost::Nothing, ::PSY.HydroGen, ::ActivePowerVariable, ::AbstractHydroFormulation)=0.0 -proportional_cost(cost::PSY.OperationalCost, ::OnVariable, ::PSY.HydroGen, ::AbstractHydroFormulation)=PSY.get_fixed(cost) - -objective_function_multiplier(::ActivePowerVariable, ::AbstractHydroFormulation)=OBJECTIVE_FUNCTION_POSITIVE -objective_function_multiplier(::ActivePowerOutVariable, ::AbstractHydroFormulation)=OBJECTIVE_FUNCTION_POSITIVE -objective_function_multiplier(::OnVariable, ::AbstractHydroFormulation)=OBJECTIVE_FUNCTION_POSITIVE - -sos_status(::PSY.HydroGen, ::AbstractHydroFormulation)=SOSStatusVariable.NO_VARIABLE -sos_status(::PSY.HydroGen, ::AbstractHydroUnitCommitment)=SOSStatusVariable.VARIABLE - -variable_cost(::Nothing, ::ActivePowerVariable, ::PSY.HydroGen, ::AbstractHydroFormulation)=0.0 -variable_cost(cost::PSY.OperationalCost, ::ActivePowerVariable, ::PSY.HydroGen, ::AbstractHydroFormulation)=PSY.get_variable(cost) -variable_cost(cost::PSY.OperationalCost, ::ActivePowerOutVariable, ::PSY.HydroGen, ::AbstractHydroFormulation)=PSY.get_variable(cost) - -#! format: on - -function get_initial_conditions_device_model( - ::OperationModel, - model::DeviceModel{T, <:AbstractHydroFormulation}, -) where {T <: PSY.HydroEnergyReservoir} - return model -end - -function get_initial_conditions_device_model( - ::OperationModel, - ::DeviceModel{T, <:AbstractHydroFormulation}, -) where {T <: PSY.HydroDispatch} - return DeviceModel(PSY.HydroDispatch, HydroDispatchRunOfRiver) -end - -function get_default_time_series_names( - ::Type{<:PSY.HydroGen}, - ::Type{<:Union{FixedOutput, HydroDispatchRunOfRiver, HydroCommitmentRunOfRiver}}, -) - return Dict{Type{<:TimeSeriesParameter}, String}( - ActivePowerTimeSeriesParameter => "max_active_power", - ReactivePowerTimeSeriesParameter => "max_active_power", - ) -end - -function get_default_attributes( - ::Type{T}, - ::Type{D}, -) where {T <: PSY.HydroGen, D <: Union{FixedOutput, AbstractHydroFormulation}} - return Dict{String, Any}("reservation" => false) -end - -""" -Time series constraints -""" -function add_constraints!( - container::OptimizationContainer, - T::Type{ActivePowerVariableLimitsConstraint}, - U::Type{<:Union{VariableType, ExpressionType}}, - devices::IS.FlattenIteratorWrapper{V}, - model::DeviceModel{V, W}, - ::NetworkModel{X}, -) where {V <: PSY.HydroGen, W <: HydroDispatchRunOfRiver, X <: PM.AbstractPowerModel} - if !has_semicontinuous_feedforward(model, U) - add_range_constraints!(container, T, U, devices, model, X) - end - add_parameterized_upper_bound_range_constraints( - container, - ActivePowerVariableTimeSeriesLimitsConstraint, - U, - ActivePowerTimeSeriesParameter, - devices, - model, - X, - ) - return -end - -function add_constraints!( - container::OptimizationContainer, - T::Type{ActivePowerVariableLimitsConstraint}, - U::Type{<:RangeConstraintLBExpressions}, - devices::IS.FlattenIteratorWrapper{V}, - model::DeviceModel{V, W}, - ::NetworkModel{X}, -) where {V <: PSY.HydroGen, W <: HydroDispatchRunOfRiver, X <: PM.AbstractPowerModel} - if !has_semicontinuous_feedforward(model, U) - add_range_constraints!(container, T, U, devices, model, X) - end - return -end - -""" -Add semicontinuous range constraints for Hydro Unit Commitment formulation -""" -function add_constraints!( - container::OptimizationContainer, - T::Type{ActivePowerVariableLimitsConstraint}, - U::Type{<:Union{VariableType, <:RangeConstraintLBExpressions}}, - devices::IS.FlattenIteratorWrapper{V}, - model::DeviceModel{V, W}, - ::NetworkModel{X}, -) where {V <: PSY.HydroGen, W <: HydroCommitmentRunOfRiver, X <: PM.AbstractPowerModel} - add_semicontinuous_range_constraints!(container, T, U, devices, model, X) - return -end - -function add_constraints!( - container::OptimizationContainer, - T::Type{ActivePowerVariableLimitsConstraint}, - U::Type{<:Union{VariableType, ExpressionType}}, - devices::IS.FlattenIteratorWrapper{V}, - model::DeviceModel{V, W}, - ::NetworkModel{X}, -) where {V <: PSY.HydroGen, W <: HydroCommitmentRunOfRiver, X <: PM.AbstractPowerModel} - add_semicontinuous_range_constraints!(container, T, U, devices, model, X) - add_parameterized_upper_bound_range_constraints( - container, - ActivePowerVariableTimeSeriesLimitsConstraint, - U, - ActivePowerTimeSeriesParameter, - devices, - model, - X, - ) - return -end - -""" -Min and max reactive Power Variable limits -""" -function get_min_max_limits( - x::PSY.HydroGen, - ::Type{<:ReactivePowerVariableLimitsConstraint}, - ::Type{<:AbstractHydroFormulation}, -) - return PSY.get_reactive_power_limits(x) -end - -""" -Min and max active Power Variable limits -""" -function get_min_max_limits( - x::PSY.HydroGen, - ::Type{<:ActivePowerVariableLimitsConstraint}, - ::Type{<:AbstractHydroFormulation}, -) - return PSY.get_active_power_limits(x) -end - -function get_min_max_limits( - x::PSY.HydroGen, - ::Type{<:ActivePowerVariableLimitsConstraint}, - ::Type{HydroDispatchRunOfRiver}, -) - return (min = 0.0, max = PSY.get_max_active_power(x)) -end - -""" -Add power variable limits constraints for hydro unit commitment formulation -""" -function add_constraints!( - container::OptimizationContainer, - T::Type{<:PowerVariableLimitsConstraint}, - U::Type{<:Union{VariableType, ExpressionType}}, - devices::IS.FlattenIteratorWrapper{V}, - model::DeviceModel{V, W}, - ::NetworkModel{X}, -) where {V <: PSY.HydroGen, W <: AbstractHydroUnitCommitment, X <: PM.AbstractPowerModel} - add_semicontinuous_range_constraints!(container, T, U, devices, model, X) - return -end - -""" -Add power variable limits constraints for hydro dispatch formulation -""" -function add_constraints!( - container::OptimizationContainer, - T::Type{<:PowerVariableLimitsConstraint}, - U::Type{<:Union{VariableType, ExpressionType}}, - devices::IS.FlattenIteratorWrapper{V}, - model::DeviceModel{V, W}, - ::NetworkModel{X}, -) where { - V <: PSY.HydroGen, - W <: AbstractHydroDispatchFormulation, - X <: PM.AbstractPowerModel, -} - if !has_semicontinuous_feedforward(model, U) - add_range_constraints!(container, T, U, devices, model, X) - end - return -end - -##################################### Auxillary Variables ############################ -function _calculate_aux_variable_value!( - container::OptimizationContainer, - ::AuxVarKey{EnergyOutput, T}, - system::PSY.System, - p_variable_results::JuMPVariableArray, -) where {T <: PSY.HydroGen} - devices = axes(p_variable_results, 1) - time_steps = get_time_steps(container) - resolution = get_resolution(container) - fraction_of_hour = Dates.value(Dates.Minute(resolution)) / MINUTES_IN_HOUR - aux_variable_container = get_aux_variable(container, EnergyOutput(), T) - for name in devices, t in time_steps - aux_variable_container[name, t] = - jump_value(p_variable_results[name, t]) * fraction_of_hour - end - - return -end - -function calculate_aux_variable_value!( - container::OptimizationContainer, - aux_key::AuxVarKey{EnergyOutput, T}, - system::PSY.System, -) where {T <: PSY.HydroGen} - p_variable_results = get_variable(container, ActivePowerVariable(), T) - _calculate_aux_variable_value!( - container, - aux_key, - system, - p_variable_results, - ) - return -end - -##################################### Hydro generation cost ############################ -function objective_function!( - container::OptimizationContainer, - devices::IS.FlattenIteratorWrapper{T}, - ::DeviceModel{T, U}, - ::Type{<:PM.AbstractPowerModel}, -) where {T <: PSY.HydroGen, U <: AbstractHydroUnitCommitment} - add_variable_cost!(container, ActivePowerVariable(), devices, U()) - add_proportional_cost!(container, OnVariable(), devices, U()) - return -end - -function objective_function!( - container::OptimizationContainer, - devices::IS.FlattenIteratorWrapper{T}, - ::DeviceModel{T, U}, - ::Type{<:PM.AbstractPowerModel}, -) where {T <: PSY.HydroGen, U <: AbstractHydroDispatchFormulation} - add_variable_cost!(container, ActivePowerVariable(), devices, U()) - return -end +# #! format: off +# requires_initialization(::AbstractHydroFormulation) = false +# requires_initialization(::AbstractHydroUnitCommitment) = true +# +# #DELETE +# # get_variable_multiplier(_, ::Type{<:PSY.HydroGen}, ::AbstractHydroFormulation) = 1.0 +# get_expression_type_for_reserve(::ActivePowerReserveVariable, ::Type{<:PSY.HydroGen}, ::Type{<:PSY.Reserve{PSY.ReserveUp}}) = ActivePowerRangeExpressionUB +# get_expression_type_for_reserve(::ActivePowerReserveVariable, ::Type{<:PSY.HydroGen}, ::Type{<:PSY.Reserve{PSY.ReserveDown}}) = ActivePowerRangeExpressionLB +# +# ########################### ActivePowerVariable, HydroGen ################################# +# get_variable_binary(::ActivePowerVariable, ::Type{<:PSY.HydroGen}, ::AbstractHydroFormulation) = false +# get_variable_warm_start_value(::ActivePowerVariable, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_active_power(d) +# get_variable_lower_bound(::ActivePowerVariable, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_active_power_limits(d).min +# get_variable_lower_bound(::ActivePowerVariable, d::PSY.HydroGen, ::AbstractHydroUnitCommitment) = 0.0 +# get_variable_upper_bound(::ActivePowerVariable, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_active_power_limits(d).max +# +# ############## ActivePowerVariable, HydroDispatchRunOfRiver #################### +# get_variable_lower_bound(::ActivePowerVariable, d::PSY.HydroGen, ::HydroDispatchRunOfRiver) = 0.0 +# +# ############## ReactivePowerVariable, HydroGen #################### +# get_variable_binary(::ReactivePowerVariable, ::Type{<:PSY.HydroGen}, ::AbstractHydroFormulation) = false +# get_variable_warm_start_value(::ReactivePowerVariable, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_reactive_power(d) +# get_variable_lower_bound(::ReactivePowerVariable, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_reactive_power_limits(d).min +# get_variable_upper_bound(::ReactivePowerVariable, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_reactive_power_limits(d).max +# +# ############## OnVariable, HydroGen #################### +# get_variable_binary(::OnVariable, ::Type{<:PSY.HydroGen}, ::AbstractHydroFormulation) = true +# get_variable_warm_start_value(::OnVariable, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_active_power(d) > 0 ? 1.0 : 0.0 +# +# ########################### Parameter related set functions ################################ +# get_multiplier_value(::TimeSeriesParameter, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_max_active_power(d) +# get_multiplier_value(::TimeSeriesParameter, d::PSY.HydroGen, ::FixedOutput) = PSY.get_max_active_power(d) +# +# get_parameter_multiplier(::VariableValueParameter, d::PSY.HydroGen, ::AbstractHydroFormulation) = 1.0 +# get_initial_parameter_value(::VariableValueParameter, d::PSY.HydroGen, ::AbstractHydroFormulation) = 1.0 +# get_expression_multiplier(::OnStatusParameter, ::ActivePowerRangeExpressionUB, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_active_power_limits(d).max +# get_expression_multiplier(::OnStatusParameter, ::ActivePowerRangeExpressionLB, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_active_power_limits(d).min +# +# #################### Initial Conditions for models ############### +# initial_condition_default(::DeviceStatus, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_status(d) +# initial_condition_variable(::DeviceStatus, d::PSY.HydroGen, ::AbstractHydroFormulation) = OnVariable() +# initial_condition_default(::DevicePower, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_active_power(d) +# initial_condition_variable(::DevicePower, d::PSY.HydroGen, ::AbstractHydroFormulation) = ActivePowerVariable() +# initial_condition_default(::InitialTimeDurationOn, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_status(d) ? PSY.get_time_at_status(d) : 0.0 +# initial_condition_variable(::InitialTimeDurationOn, d::PSY.HydroGen, ::AbstractHydroFormulation) = OnVariable() +# initial_condition_default(::InitialTimeDurationOff, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_status(d) ? 0.0 : PSY.get_time_at_status(d) +# initial_condition_variable(::InitialTimeDurationOff, d::PSY.HydroGen, ::AbstractHydroFormulation) = OnVariable() +# +# ########################Objective Function################################################## +# proportional_cost(cost::Nothing, ::PSY.HydroGen, ::ActivePowerVariable, ::AbstractHydroFormulation)=0.0 +# proportional_cost(cost::PSY.OperationalCost, ::OnVariable, ::PSY.HydroGen, ::AbstractHydroFormulation)=PSY.get_fixed(cost) +# +# objective_function_multiplier(::ActivePowerVariable, ::AbstractHydroFormulation)=OBJECTIVE_FUNCTION_POSITIVE +# objective_function_multiplier(::ActivePowerOutVariable, ::AbstractHydroFormulation)=OBJECTIVE_FUNCTION_POSITIVE +# objective_function_multiplier(::OnVariable, ::AbstractHydroFormulation)=OBJECTIVE_FUNCTION_POSITIVE +# +# sos_status(::PSY.HydroGen, ::AbstractHydroFormulation)=SOSStatusVariable.NO_VARIABLE +# sos_status(::PSY.HydroGen, ::AbstractHydroUnitCommitment)=SOSStatusVariable.VARIABLE +# +# variable_cost(::Nothing, ::ActivePowerVariable, ::PSY.HydroGen, ::AbstractHydroFormulation)=0.0 +# variable_cost(cost::PSY.OperationalCost, ::ActivePowerVariable, ::PSY.HydroGen, ::AbstractHydroFormulation)=PSY.get_variable(cost) +# variable_cost(cost::PSY.OperationalCost, ::ActivePowerOutVariable, ::PSY.HydroGen, ::AbstractHydroFormulation)=PSY.get_variable(cost) +# +# #! format: on +# +# function get_initial_conditions_device_model( +# ::OperationModel, +# model::DeviceModel{T, <:AbstractHydroFormulation}, +# ) where {T <: PSY.HydroEnergyReservoir} +# return model +# end +# +# function get_initial_conditions_device_model( +# ::OperationModel, +# ::DeviceModel{T, <:AbstractHydroFormulation}, +# ) where {T <: PSY.HydroDispatch} +# return DeviceModel(PSY.HydroDispatch, HydroDispatchRunOfRiver) +# end +# +# # DELETE +# # function get_default_time_series_names( +# # ::Type{<:PSY.HydroGen}, +# # ::Type{<:Union{FixedOutput, HydroDispatchRunOfRiver, HydroCommitmentRunOfRiver}}, +# # ) +# # return Dict{Type{<:TimeSeriesParameter}, String}( +# # ActivePowerTimeSeriesParameter => "max_active_power", +# # ReactivePowerTimeSeriesParameter => "max_active_power", +# # ) +# # end +# +# # DELETE +# # function get_default_attributes( +# # ::Type{T}, +# # ::Type{D}, +# # ) where {T <: PSY.HydroGen, D <: Union{FixedOutput, AbstractHydroFormulation}} +# # return Dict{String, Any}("reservation" => false) +# # end +# +# """ +# Time series constraints +# """ +# function add_constraints!( +# container::OptimizationContainer, +# T::Type{ActivePowerVariableLimitsConstraint}, +# U::Type{<:Union{VariableType, ExpressionType}}, +# devices::IS.FlattenIteratorWrapper{V}, +# model::DeviceModel{V, W}, +# ::NetworkModel{X}, +# ) where {V <: PSY.HydroGen, W <: HydroDispatchRunOfRiver, X <: PM.AbstractPowerModel} +# if !has_semicontinuous_feedforward(model, U) +# add_range_constraints!(container, T, U, devices, model, X) +# end +# add_parameterized_upper_bound_range_constraints( +# container, +# ActivePowerVariableTimeSeriesLimitsConstraint, +# U, +# ActivePowerTimeSeriesParameter, +# devices, +# model, +# X, +# ) +# return +# end +# +# function add_constraints!( +# container::OptimizationContainer, +# T::Type{ActivePowerVariableLimitsConstraint}, +# U::Type{<:RangeConstraintLBExpressions}, +# devices::IS.FlattenIteratorWrapper{V}, +# model::DeviceModel{V, W}, +# ::NetworkModel{X}, +# ) where {V <: PSY.HydroGen, W <: HydroDispatchRunOfRiver, X <: PM.AbstractPowerModel} +# if !has_semicontinuous_feedforward(model, U) +# add_range_constraints!(container, T, U, devices, model, X) +# end +# return +# end +# +# """ +# Add semicontinuous range constraints for Hydro Unit Commitment formulation +# """ +# function add_constraints!( +# container::OptimizationContainer, +# T::Type{ActivePowerVariableLimitsConstraint}, +# U::Type{<:Union{VariableType, <:RangeConstraintLBExpressions}}, +# devices::IS.FlattenIteratorWrapper{V}, +# model::DeviceModel{V, W}, +# ::NetworkModel{X}, +# ) where {V <: PSY.HydroGen, W <: HydroCommitmentRunOfRiver, X <: PM.AbstractPowerModel} +# add_semicontinuous_range_constraints!(container, T, U, devices, model, X) +# return +# end +# +# function add_constraints!( +# container::OptimizationContainer, +# T::Type{ActivePowerVariableLimitsConstraint}, +# U::Type{<:Union{VariableType, ExpressionType}}, +# devices::IS.FlattenIteratorWrapper{V}, +# model::DeviceModel{V, W}, +# ::NetworkModel{X}, +# ) where {V <: PSY.HydroGen, W <: HydroCommitmentRunOfRiver, X <: PM.AbstractPowerModel} +# add_semicontinuous_range_constraints!(container, T, U, devices, model, X) +# add_parameterized_upper_bound_range_constraints( +# container, +# ActivePowerVariableTimeSeriesLimitsConstraint, +# U, +# ActivePowerTimeSeriesParameter, +# devices, +# model, +# X, +# ) +# return +# end +# +# """ +# Min and max reactive Power Variable limits +# """ +# function get_min_max_limits( +# x::PSY.HydroGen, +# ::Type{<:ReactivePowerVariableLimitsConstraint}, +# ::Type{<:AbstractHydroFormulation}, +# ) +# return PSY.get_reactive_power_limits(x) +# end +# +# """ +# Min and max active Power Variable limits +# """ +# function get_min_max_limits( +# x::PSY.HydroGen, +# ::Type{<:ActivePowerVariableLimitsConstraint}, +# ::Type{<:AbstractHydroFormulation}, +# ) +# return PSY.get_active_power_limits(x) +# end +# +# function get_min_max_limits( +# x::PSY.HydroGen, +# ::Type{<:ActivePowerVariableLimitsConstraint}, +# ::Type{HydroDispatchRunOfRiver}, +# ) +# return (min = 0.0, max = PSY.get_max_active_power(x)) +# end +# +# """ +# Add power variable limits constraints for hydro unit commitment formulation +# """ +# function add_constraints!( +# container::OptimizationContainer, +# T::Type{<:PowerVariableLimitsConstraint}, +# U::Type{<:Union{VariableType, ExpressionType}}, +# devices::IS.FlattenIteratorWrapper{V}, +# model::DeviceModel{V, W}, +# ::NetworkModel{X}, +# ) where {V <: PSY.HydroGen, W <: AbstractHydroUnitCommitment, X <: PM.AbstractPowerModel} +# add_semicontinuous_range_constraints!(container, T, U, devices, model, X) +# return +# end +# +# """ +# Add power variable limits constraints for hydro dispatch formulation +# """ +# function add_constraints!( +# container::OptimizationContainer, +# T::Type{<:PowerVariableLimitsConstraint}, +# U::Type{<:Union{VariableType, ExpressionType}}, +# devices::IS.FlattenIteratorWrapper{V}, +# model::DeviceModel{V, W}, +# ::NetworkModel{X}, +# ) where { +# V <: PSY.HydroGen, +# W <: AbstractHydroDispatchFormulation, +# X <: PM.AbstractPowerModel, +# } +# if !has_semicontinuous_feedforward(model, U) +# add_range_constraints!(container, T, U, devices, model, X) +# end +# return +# end +# +# ##################################### Auxillary Variables ############################ +# function _calculate_aux_variable_value!( +# container::OptimizationContainer, +# ::AuxVarKey{EnergyOutput, T}, +# system::PSY.System, +# p_variable_results::JuMPVariableArray, +# ) where {T <: PSY.HydroGen} +# devices = axes(p_variable_results, 1) +# time_steps = get_time_steps(container) +# resolution = get_resolution(container) +# fraction_of_hour = Dates.value(Dates.Minute(resolution)) / MINUTES_IN_HOUR +# aux_variable_container = get_aux_variable(container, EnergyOutput(), T) +# for name in devices, t in time_steps +# aux_variable_container[name, t] = +# jump_value(p_variable_results[name, t]) * fraction_of_hour +# end +# +# return +# end +# +# function calculate_aux_variable_value!( +# container::OptimizationContainer, +# aux_key::AuxVarKey{EnergyOutput, T}, +# system::PSY.System, +# ) where {T <: PSY.HydroGen} +# p_variable_results = get_variable(container, ActivePowerVariable(), T) +# _calculate_aux_variable_value!( +# container, +# aux_key, +# system, +# p_variable_results, +# ) +# return +# end +# +# ##################################### Hydro generation cost ############################ +# function objective_function!( +# container::OptimizationContainer, +# devices::IS.FlattenIteratorWrapper{T}, +# ::DeviceModel{T, U}, +# ::Type{<:PM.AbstractPowerModel}, +# ) where {T <: PSY.HydroGen, U <: AbstractHydroUnitCommitment} +# add_variable_cost!(container, ActivePowerVariable(), devices, U()) +# add_proportional_cost!(container, OnVariable(), devices, U()) +# return +# end +# +# function objective_function!( +# container::OptimizationContainer, +# devices::IS.FlattenIteratorWrapper{T}, +# ::DeviceModel{T, U}, +# ::Type{<:PM.AbstractPowerModel}, +# ) where {T <: PSY.HydroGen, U <: AbstractHydroDispatchFormulation} +# add_variable_cost!(container, ActivePowerVariable(), devices, U()) +# return +# end diff --git a/test/test_device_hydro_generation_constructors.jl b/test/test_device_hydro_generation_constructors.jl deleted file mode 100644 index 7545c57ace..0000000000 --- a/test/test_device_hydro_generation_constructors.jl +++ /dev/null @@ -1,121 +0,0 @@ -################################### -###### FIXED OUTPUT TESTS ######### -################################### - -@testset "Hydro DCPLossLess FixedOutput" begin - device_model = DeviceModel(HydroDispatch, FixedOutput) - c_sys5_hy = PSB.build_system(PSITestSystems, "c_sys5_hy") - - # No Parameters Testing - model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_hy) - mock_construct_device!(model, device_model) - moi_tests(model, 0, 0, 0, 0, 0, false) - psi_checkobjfun_test(model, GAEVF) -end - -@testset "Hydro DCPLossLess HydroEnergyReservoir with FixedOutput formulations" begin - device_model = DeviceModel(HydroEnergyReservoir, FixedOutput) - c_sys5_hyd = PSB.build_system(PSITestSystems, "c_sys5_hyd") - - # No Parameters Testing - model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_hyd) - mock_construct_device!(model, device_model) - moi_tests(model, 0, 0, 0, 0, 0, false) - psi_checkobjfun_test(model, GAEVF) -end - -################################### -### RUN OF RIVER DISPATCH TESTS ### -################################### - -@testset "Hydro DCPLossLess HydroDispatch with HydroDispatchRunOfRiver formulations" begin - device_model = DeviceModel(HydroDispatch, HydroDispatchRunOfRiver) - c_sys5_hy = PSB.build_system(PSITestSystems, "c_sys5_hy") - - # No Parameters Testing - model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_hy) - mock_construct_device!(model, device_model) - moi_tests(model, 24, 0, 48, 24, 0, false) - psi_checkobjfun_test(model, GAEVF) -end - -@testset "Hydro ACPPowerModel HydroDispatch with HydroDispatchRunOfRiver formulations" begin - device_model = DeviceModel(HydroDispatch, HydroDispatchRunOfRiver) - c_sys5_hy = PSB.build_system(PSITestSystems, "c_sys5_hy") - - # No Parameters Testing - model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5_hy) - mock_construct_device!(model, device_model) - moi_tests(model, 48, 0, 72, 48, 0, false) - psi_checkobjfun_test(model, GAEVF) -end - -@testset "Hydro DCPLossLess HydroEnergyReservoir with HydroDispatchRunOfRiver formulations" begin - device_model = DeviceModel(HydroEnergyReservoir, HydroDispatchRunOfRiver) - c_sys5_hyd = PSB.build_system(PSITestSystems, "c_sys5_hyd") - - # No Parameters Testing - model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_hyd) - mock_construct_device!(model, device_model) - moi_tests(model, 24, 0, 48, 24, 0, false) - psi_checkobjfun_test(model, GAEVF) -end - -@testset "Hydro ACPPowerModel HydroEnergyReservoir with HydroDispatchRunOfRiver formulations" begin - device_model = DeviceModel(HydroEnergyReservoir, HydroDispatchRunOfRiver) - c_sys5_hyd = PSB.build_system(PSITestSystems, "c_sys5_hyd") - - # No Parameters Testing - model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5_hyd) - mock_construct_device!(model, device_model) - moi_tests(model, 48, 0, 72, 48, 0, false) - psi_checkobjfun_test(model, GAEVF) -end - -################################### -#### RUN OF RIVER COMMIT TESTS #### -################################### - -@testset "Hydro DCPLossLess HydroDispatch with HydroCommitmentRunOfRiver formulations" begin - device_model = DeviceModel(HydroDispatch, HydroCommitmentRunOfRiver) - c_sys5_hy = PSB.build_system(PSITestSystems, "c_sys5_hy") - - # No Parameters Testing - model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_hy) - mock_construct_device!(model, device_model) - moi_tests(model, 48, 0, 48, 24, 0, true) - psi_checkobjfun_test(model, GAEVF) -end - -@testset "Hydro ACPPowerModel HydroDispatch with HydroCommitmentRunOfRiver formulations" begin - device_model = DeviceModel(HydroDispatch, HydroCommitmentRunOfRiver) - c_sys5_hy = PSB.build_system(PSITestSystems, "c_sys5_hy") - - # No Parameters Testing - model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5_hy) - mock_construct_device!(model, device_model) - moi_tests(model, 72, 0, 72, 48, 0, true) - psi_checkobjfun_test(model, GAEVF) -end - -@testset "Hydro DCPLossLess HydroEnergyReservoir with HydroCommitmentRunOfRiver formulations" begin - device_model = DeviceModel(HydroEnergyReservoir, HydroCommitmentRunOfRiver) - c_sys5_hyd = PSB.build_system(PSITestSystems, "c_sys5_hyd") - - # No Parameters Testing - model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_hyd) - mock_construct_device!(model, device_model) - moi_tests(model, 48, 0, 48, 24, 0, true) - psi_checkobjfun_test(model, GAEVF) -end - -@testset "Hydro ACPPowerModel HydroEnergyReservoir with HydroCommitmentRunOfRiver formulations" begin - device_model = DeviceModel(HydroEnergyReservoir, HydroCommitmentRunOfRiver) - c_sys5_hyd = PSB.build_system(PSITestSystems, "c_sys5_hyd") - - # No Parameters Testing - model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5_hyd) - mock_construct_device!(model, device_model) - moi_tests(model, 72, 0, 72, 48, 0, true) - psi_checkobjfun_test(model, GAEVF) -end From 944d7c17047d8e5ccdfdaf7dea33350d357bff3d Mon Sep 17 00:00:00 2001 From: Jose Daniel Lara Date: Wed, 6 Sep 2023 10:20:31 -0600 Subject: [PATCH 2/6] Update PowerSimulations.jl --- src/PowerSimulations.jl | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/PowerSimulations.jl b/src/PowerSimulations.jl index f8c7d4c1d8..43e2aa2ff4 100644 --- a/src/PowerSimulations.jl +++ b/src/PowerSimulations.jl @@ -69,10 +69,6 @@ export ThermalCompactDispatch export DeviceLimitedRegulation export ReserveLimitedRegulation -###### Hydro ####### -# export HydroDispatchRunOfRiver -export HydroCommitmentRunOfRiver - # feedforward models export UpperBoundFeedforward export LowerBoundFeedforward From 0a9ed84bb9f1da9a1090688cbe269107cee699f0 Mon Sep 17 00:00:00 2001 From: Jose Daniel Lara Date: Wed, 6 Sep 2023 10:21:13 -0600 Subject: [PATCH 3/6] Update formulations.jl --- src/core/formulations.jl | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/core/formulations.jl b/src/core/formulations.jl index 4fefb8d6f1..73e801cdf6 100644 --- a/src/core/formulations.jl +++ b/src/core/formulations.jl @@ -72,21 +72,6 @@ Formulation type to enable (continuous) load interruption dispatch """ struct PowerLoadDispatch <: AbstractControllablePowerLoadFormulation end -############################ Hydro Generation Formulations ################################# -# abstract type AbstractHydroFormulation <: AbstractDeviceFormulation end -# abstract type AbstractHydroDispatchFormulation <: AbstractHydroFormulation end -# abstract type AbstractHydroUnitCommitment <: AbstractHydroFormulation end - -# """ -# Formulation type to add injection variables constrained by a maximum injection time series for `HydroGen` -# """ -# struct HydroDispatchRunOfRiver <: AbstractHydroDispatchFormulation end - -# """ -# Formulation type to add commitment and injection variables constrained by a maximum injection time series for `HydroGen` -# """ -# struct HydroCommitmentRunOfRiver <: AbstractHydroUnitCommitment end - ############################ Regulation Device Formulations ################################ abstract type AbstractRegulationFormulation <: AbstractDeviceFormulation end struct ReserveLimitedRegulation <: AbstractRegulationFormulation end From 8fe2d27450cbca29cbabcd2b6d71f1589ed4e149 Mon Sep 17 00:00:00 2001 From: Jose Daniel Lara Date: Wed, 6 Sep 2023 10:21:33 -0600 Subject: [PATCH 4/6] Delete src/devices_models/device_constructors/hydrogeneration_constructor.jl --- .../hydrogeneration_constructor.jl | 468 ------------------ 1 file changed, 468 deletions(-) delete mode 100644 src/devices_models/device_constructors/hydrogeneration_constructor.jl diff --git a/src/devices_models/device_constructors/hydrogeneration_constructor.jl b/src/devices_models/device_constructors/hydrogeneration_constructor.jl deleted file mode 100644 index c1ed64385f..0000000000 --- a/src/devices_models/device_constructors/hydrogeneration_constructor.jl +++ /dev/null @@ -1,468 +0,0 @@ -# """ -# Construct model for HydroGen with FixedOutput Formulation -# """ -# function construct_device!( -# container::OptimizationContainer, -# sys::PSY.System, -# ::ArgumentConstructStage, -# model::DeviceModel{H, FixedOutput}, -# network_model::NetworkModel{S}, -# ) where {H <: PSY.HydroGen, S <: PM.AbstractPowerModel} -# devices = -# get_available_components(H, sys, get_attribute(model, "filter_function")) -# -# add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model) -# add_parameters!(container, ReactivePowerTimeSeriesParameter, devices, model) -# -# # Expression -# add_to_expression!( -# container, -# ActivePowerBalance, -# ActivePowerTimeSeriesParameter, -# devices, -# model, -# network_model, -# ) -# add_to_expression!( -# container, -# ReactivePowerBalance, -# ReactivePowerTimeSeriesParameter, -# devices, -# model, -# network_model, -# ) -# return -# end -# -# function construct_device!( -# ::OptimizationContainer, -# ::PSY.System, -# ::ModelConstructStage, -# ::DeviceModel{H, FixedOutput}, -# network_model::NetworkModel{S}, -# ) where {H <: PSY.HydroGen, S <: PM.AbstractPowerModel} -# # FixedOutput doesn't add any constraints to the model. This function covers -# # AbstractPowerModel and AbstractActivePowerModel -# return -# end -# -# function construct_device!( -# container::OptimizationContainer, -# sys::PSY.System, -# ::ArgumentConstructStage, -# model::DeviceModel{H, FixedOutput}, -# network_model::NetworkModel{S}, -# ) where {H <: PSY.HydroGen, S <: PM.AbstractActivePowerModel} -# devices = -# get_available_components(H, sys, get_attribute(model, "filter_function")) -# -# add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model) -# -# # Expression -# add_to_expression!( -# container, -# ActivePowerBalance, -# ActivePowerTimeSeriesParameter, -# devices, -# model, -# network_model, -# ) -# return -# end -# -# """ -# Construct model for HydroGen with RunOfRiver (default Hydro model) Dispatch Formulation -# """ -# function construct_device!( -# container::OptimizationContainer, -# sys::PSY.System, -# ::ArgumentConstructStage, -# model::DeviceModel{H, D}, -# network_model::NetworkModel{S}, -# ) where { -# H <: PSY.HydroGen, -# D <: AbstractHydroDispatchFormulation, -# S <: PM.AbstractPowerModel, -# } -# devices = -# get_available_components(H, sys, get_attribute(model, "filter_function")) -# -# add_variables!(container, ActivePowerVariable, devices, D()) -# add_variables!(container, ReactivePowerVariable, devices, D()) -# add_variables!(container, EnergyOutput, devices, D()) -# add_to_expression!( -# container, -# ActivePowerBalance, -# ActivePowerVariable, -# devices, -# model, -# network_model, -# ) -# add_to_expression!( -# container, -# ReactivePowerBalance, -# ReactivePowerVariable, -# devices, -# model, -# network_model, -# ) -# -# add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model) -# -# add_expressions!(container, ProductionCostExpression, devices, model) -# -# add_to_expression!( -# container, -# ActivePowerRangeExpressionLB, -# ActivePowerVariable, -# devices, -# model, -# network_model, -# ) -# add_to_expression!( -# container, -# ActivePowerRangeExpressionUB, -# ActivePowerVariable, -# devices, -# model, -# network_model, -# ) -# -# add_feedforward_arguments!(container, model, devices) -# return -# end -# -# function construct_device!( -# container::OptimizationContainer, -# sys::PSY.System, -# ::ModelConstructStage, -# model::DeviceModel{H, D}, -# network_model::NetworkModel{S}, -# ) where { -# H <: PSY.HydroGen, -# D <: AbstractHydroDispatchFormulation, -# S <: PM.AbstractPowerModel, -# } -# devices = -# get_available_components(H, sys, get_attribute(model, "filter_function")) -# -# add_constraints!( -# container, -# ActivePowerVariableLimitsConstraint, -# ActivePowerRangeExpressionLB, -# devices, -# model, -# network_model, -# ) -# add_constraints!( -# container, -# ActivePowerVariableLimitsConstraint, -# ActivePowerRangeExpressionUB, -# devices, -# model, -# network_model, -# ) -# -# add_constraints!( -# container, -# ReactivePowerVariableLimitsConstraint, -# ReactivePowerVariable, -# devices, -# model, -# network_model, -# ) -# add_feedforward_constraints!(container, model, devices) -# -# objective_function!(container, devices, model, S) -# add_constraint_dual!(container, sys, model) -# -# return -# end -# -# """ -# Construct model for HydroGen with RunOfRiver (default Hydro model) Dispatch Formulation -# with only Active Power. -# """ -# function construct_device!( -# container::OptimizationContainer, -# sys::PSY.System, -# ::ArgumentConstructStage, -# model::DeviceModel{H, D}, -# network_model::NetworkModel{S}, -# ) where { -# H <: PSY.HydroGen, -# D <: AbstractHydroDispatchFormulation, -# S <: PM.AbstractActivePowerModel, -# } -# devices = -# get_available_components(H, sys, get_attribute(model, "filter_function")) -# -# add_variables!(container, ActivePowerVariable, devices, D()) -# add_variables!(container, EnergyOutput, devices, D()) -# add_to_expression!( -# container, -# ActivePowerBalance, -# ActivePowerVariable, -# devices, -# model, -# network_model, -# ) -# -# add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model) -# add_to_expression!( -# container, -# ActivePowerRangeExpressionLB, -# ActivePowerVariable, -# devices, -# model, -# network_model, -# ) -# add_to_expression!( -# container, -# ActivePowerRangeExpressionUB, -# ActivePowerVariable, -# devices, -# model, -# network_model, -# ) -# -# add_expressions!(container, ProductionCostExpression, devices, model) -# -# add_feedforward_arguments!(container, model, devices) -# return -# end -# -# function construct_device!( -# container::OptimizationContainer, -# sys::PSY.System, -# ::ModelConstructStage, -# model::DeviceModel{H, D}, -# network_model::NetworkModel{S}, -# ) where { -# H <: PSY.HydroGen, -# D <: AbstractHydroDispatchFormulation, -# S <: PM.AbstractActivePowerModel, -# } -# devices = -# get_available_components(H, sys, get_attribute(model, "filter_function")) -# -# add_constraints!( -# container, -# ActivePowerVariableLimitsConstraint, -# ActivePowerRangeExpressionLB, -# devices, -# model, -# network_model, -# ) -# add_constraints!( -# container, -# ActivePowerVariableLimitsConstraint, -# ActivePowerRangeExpressionUB, -# devices, -# model, -# network_model, -# ) -# -# add_feedforward_constraints!(container, model, devices) -# -# objective_function!(container, devices, model, S) -# -# add_constraint_dual!(container, sys, model) -# return -# end -# -# """ -# Construct model for HydroGen with RunOfRiver Commitment Formulation -# """ -# function construct_device!( -# container::OptimizationContainer, -# sys::PSY.System, -# ::ArgumentConstructStage, -# model::DeviceModel{H, D}, -# network_model::NetworkModel{S}, -# ) where {H <: PSY.HydroGen, D <: HydroCommitmentRunOfRiver, S <: PM.AbstractPowerModel} -# devices = -# get_available_components(H, sys, get_attribute(model, "filter_function")) -# -# add_variables!(container, ActivePowerVariable, devices, D()) -# add_variables!(container, ReactivePowerVariable, devices, D()) -# add_variables!(container, OnVariable, devices, D()) -# add_variables!(container, EnergyOutput, devices, D()) -# add_to_expression!( -# container, -# ActivePowerBalance, -# ActivePowerVariable, -# devices, -# model, -# network_model, -# ) -# -# add_to_expression!( -# container, -# ReactivePowerBalance, -# ReactivePowerVariable, -# devices, -# model, -# network_model, -# ) -# -# add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model) -# -# add_expressions!(container, ProductionCostExpression, devices, model) -# -# add_to_expression!( -# container, -# ActivePowerRangeExpressionLB, -# ActivePowerVariable, -# devices, -# model, -# network_model, -# ) -# add_to_expression!( -# container, -# ActivePowerRangeExpressionUB, -# ActivePowerVariable, -# devices, -# model, -# network_model, -# ) -# add_feedforward_arguments!(container, model, devices) -# return -# end -# -# function construct_device!( -# container::OptimizationContainer, -# sys::PSY.System, -# ::ModelConstructStage, -# model::DeviceModel{H, D}, -# network_model::NetworkModel{S}, -# ) where {H <: PSY.HydroGen, D <: HydroCommitmentRunOfRiver, S <: PM.AbstractPowerModel} -# devices = -# get_available_components(H, sys, get_attribute(model, "filter_function")) -# -# add_constraints!( -# container, -# ActivePowerVariableLimitsConstraint, -# ActivePowerRangeExpressionLB, -# devices, -# model, -# network_model, -# ) -# add_constraints!( -# container, -# ActivePowerVariableLimitsConstraint, -# ActivePowerRangeExpressionUB, -# devices, -# model, -# network_model, -# ) -# -# add_constraints!( -# container, -# ReactivePowerVariableLimitsConstraint, -# ReactivePowerVariable, -# devices, -# model, -# network_model, -# ) -# -# add_feedforward_constraints!(container, model, devices) -# -# objective_function!(container, devices, model, S) -# -# add_constraint_dual!(container, sys, model) -# return -# end -# -# """ -# Construct model for HydroGen with RunOfRiver Commitment Formulation -# with only Active Power. -# """ -# function construct_device!( -# container::OptimizationContainer, -# sys::PSY.System, -# ::ArgumentConstructStage, -# model::DeviceModel{H, D}, -# network_model::NetworkModel{S}, -# ) where { -# H <: PSY.HydroGen, -# D <: HydroCommitmentRunOfRiver, -# S <: PM.AbstractActivePowerModel, -# } -# devices = -# get_available_components(H, sys, get_attribute(model, "filter_function")) -# -# add_variables!(container, ActivePowerVariable, devices, D()) -# add_variables!(container, OnVariable, devices, D()) -# add_variables!(container, EnergyOutput, devices, D()) -# add_to_expression!( -# container, -# ActivePowerBalance, -# ActivePowerVariable, -# devices, -# model, -# network_model, -# ) -# -# add_expressions!(container, ProductionCostExpression, devices, model) -# -# add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model) -# add_to_expression!( -# container, -# ActivePowerRangeExpressionLB, -# ActivePowerVariable, -# devices, -# model, -# network_model, -# ) -# add_to_expression!( -# container, -# ActivePowerRangeExpressionUB, -# ActivePowerVariable, -# devices, -# model, -# network_model, -# ) -# -# add_feedforward_arguments!(container, model, devices) -# return -# end -# -# function construct_device!( -# container::OptimizationContainer, -# sys::PSY.System, -# ::ModelConstructStage, -# model::DeviceModel{H, D}, -# network_model::NetworkModel{S}, -# ) where { -# H <: PSY.HydroGen, -# D <: HydroCommitmentRunOfRiver, -# S <: PM.AbstractActivePowerModel, -# } -# devices = -# get_available_components(H, sys, get_attribute(model, "filter_function")) -# -# add_constraints!( -# container, -# ActivePowerVariableLimitsConstraint, -# ActivePowerRangeExpressionLB, -# devices, -# model, -# network_model, -# ) -# add_constraints!( -# container, -# ActivePowerVariableLimitsConstraint, -# ActivePowerRangeExpressionUB, -# devices, -# model, -# network_model, -# ) -# -# add_feedforward_constraints!(container, model, devices) -# -# objective_function!(container, devices, model, S) -# -# add_constraint_dual!(container, sys, model) -# return -# end From 87cd68207fd83cf87e21ed3a6e288e7e1f4af442 Mon Sep 17 00:00:00 2001 From: Jose Daniel Lara Date: Wed, 6 Sep 2023 10:21:51 -0600 Subject: [PATCH 5/6] Delete src/devices_models/devices/hydro_generation.jl --- .../devices/hydro_generation.jl | 296 ------------------ 1 file changed, 296 deletions(-) delete mode 100644 src/devices_models/devices/hydro_generation.jl diff --git a/src/devices_models/devices/hydro_generation.jl b/src/devices_models/devices/hydro_generation.jl deleted file mode 100644 index 4db297382a..0000000000 --- a/src/devices_models/devices/hydro_generation.jl +++ /dev/null @@ -1,296 +0,0 @@ -# #! format: off -# requires_initialization(::AbstractHydroFormulation) = false -# requires_initialization(::AbstractHydroUnitCommitment) = true -# -# #DELETE -# # get_variable_multiplier(_, ::Type{<:PSY.HydroGen}, ::AbstractHydroFormulation) = 1.0 -# get_expression_type_for_reserve(::ActivePowerReserveVariable, ::Type{<:PSY.HydroGen}, ::Type{<:PSY.Reserve{PSY.ReserveUp}}) = ActivePowerRangeExpressionUB -# get_expression_type_for_reserve(::ActivePowerReserveVariable, ::Type{<:PSY.HydroGen}, ::Type{<:PSY.Reserve{PSY.ReserveDown}}) = ActivePowerRangeExpressionLB -# -# ########################### ActivePowerVariable, HydroGen ################################# -# get_variable_binary(::ActivePowerVariable, ::Type{<:PSY.HydroGen}, ::AbstractHydroFormulation) = false -# get_variable_warm_start_value(::ActivePowerVariable, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_active_power(d) -# get_variable_lower_bound(::ActivePowerVariable, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_active_power_limits(d).min -# get_variable_lower_bound(::ActivePowerVariable, d::PSY.HydroGen, ::AbstractHydroUnitCommitment) = 0.0 -# get_variable_upper_bound(::ActivePowerVariable, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_active_power_limits(d).max -# -# ############## ActivePowerVariable, HydroDispatchRunOfRiver #################### -# get_variable_lower_bound(::ActivePowerVariable, d::PSY.HydroGen, ::HydroDispatchRunOfRiver) = 0.0 -# -# ############## ReactivePowerVariable, HydroGen #################### -# get_variable_binary(::ReactivePowerVariable, ::Type{<:PSY.HydroGen}, ::AbstractHydroFormulation) = false -# get_variable_warm_start_value(::ReactivePowerVariable, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_reactive_power(d) -# get_variable_lower_bound(::ReactivePowerVariable, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_reactive_power_limits(d).min -# get_variable_upper_bound(::ReactivePowerVariable, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_reactive_power_limits(d).max -# -# ############## OnVariable, HydroGen #################### -# get_variable_binary(::OnVariable, ::Type{<:PSY.HydroGen}, ::AbstractHydroFormulation) = true -# get_variable_warm_start_value(::OnVariable, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_active_power(d) > 0 ? 1.0 : 0.0 -# -# ########################### Parameter related set functions ################################ -# get_multiplier_value(::TimeSeriesParameter, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_max_active_power(d) -# get_multiplier_value(::TimeSeriesParameter, d::PSY.HydroGen, ::FixedOutput) = PSY.get_max_active_power(d) -# -# get_parameter_multiplier(::VariableValueParameter, d::PSY.HydroGen, ::AbstractHydroFormulation) = 1.0 -# get_initial_parameter_value(::VariableValueParameter, d::PSY.HydroGen, ::AbstractHydroFormulation) = 1.0 -# get_expression_multiplier(::OnStatusParameter, ::ActivePowerRangeExpressionUB, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_active_power_limits(d).max -# get_expression_multiplier(::OnStatusParameter, ::ActivePowerRangeExpressionLB, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_active_power_limits(d).min -# -# #################### Initial Conditions for models ############### -# initial_condition_default(::DeviceStatus, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_status(d) -# initial_condition_variable(::DeviceStatus, d::PSY.HydroGen, ::AbstractHydroFormulation) = OnVariable() -# initial_condition_default(::DevicePower, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_active_power(d) -# initial_condition_variable(::DevicePower, d::PSY.HydroGen, ::AbstractHydroFormulation) = ActivePowerVariable() -# initial_condition_default(::InitialTimeDurationOn, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_status(d) ? PSY.get_time_at_status(d) : 0.0 -# initial_condition_variable(::InitialTimeDurationOn, d::PSY.HydroGen, ::AbstractHydroFormulation) = OnVariable() -# initial_condition_default(::InitialTimeDurationOff, d::PSY.HydroGen, ::AbstractHydroFormulation) = PSY.get_status(d) ? 0.0 : PSY.get_time_at_status(d) -# initial_condition_variable(::InitialTimeDurationOff, d::PSY.HydroGen, ::AbstractHydroFormulation) = OnVariable() -# -# ########################Objective Function################################################## -# proportional_cost(cost::Nothing, ::PSY.HydroGen, ::ActivePowerVariable, ::AbstractHydroFormulation)=0.0 -# proportional_cost(cost::PSY.OperationalCost, ::OnVariable, ::PSY.HydroGen, ::AbstractHydroFormulation)=PSY.get_fixed(cost) -# -# objective_function_multiplier(::ActivePowerVariable, ::AbstractHydroFormulation)=OBJECTIVE_FUNCTION_POSITIVE -# objective_function_multiplier(::ActivePowerOutVariable, ::AbstractHydroFormulation)=OBJECTIVE_FUNCTION_POSITIVE -# objective_function_multiplier(::OnVariable, ::AbstractHydroFormulation)=OBJECTIVE_FUNCTION_POSITIVE -# -# sos_status(::PSY.HydroGen, ::AbstractHydroFormulation)=SOSStatusVariable.NO_VARIABLE -# sos_status(::PSY.HydroGen, ::AbstractHydroUnitCommitment)=SOSStatusVariable.VARIABLE -# -# variable_cost(::Nothing, ::ActivePowerVariable, ::PSY.HydroGen, ::AbstractHydroFormulation)=0.0 -# variable_cost(cost::PSY.OperationalCost, ::ActivePowerVariable, ::PSY.HydroGen, ::AbstractHydroFormulation)=PSY.get_variable(cost) -# variable_cost(cost::PSY.OperationalCost, ::ActivePowerOutVariable, ::PSY.HydroGen, ::AbstractHydroFormulation)=PSY.get_variable(cost) -# -# #! format: on -# -# function get_initial_conditions_device_model( -# ::OperationModel, -# model::DeviceModel{T, <:AbstractHydroFormulation}, -# ) where {T <: PSY.HydroEnergyReservoir} -# return model -# end -# -# function get_initial_conditions_device_model( -# ::OperationModel, -# ::DeviceModel{T, <:AbstractHydroFormulation}, -# ) where {T <: PSY.HydroDispatch} -# return DeviceModel(PSY.HydroDispatch, HydroDispatchRunOfRiver) -# end -# -# # DELETE -# # function get_default_time_series_names( -# # ::Type{<:PSY.HydroGen}, -# # ::Type{<:Union{FixedOutput, HydroDispatchRunOfRiver, HydroCommitmentRunOfRiver}}, -# # ) -# # return Dict{Type{<:TimeSeriesParameter}, String}( -# # ActivePowerTimeSeriesParameter => "max_active_power", -# # ReactivePowerTimeSeriesParameter => "max_active_power", -# # ) -# # end -# -# # DELETE -# # function get_default_attributes( -# # ::Type{T}, -# # ::Type{D}, -# # ) where {T <: PSY.HydroGen, D <: Union{FixedOutput, AbstractHydroFormulation}} -# # return Dict{String, Any}("reservation" => false) -# # end -# -# """ -# Time series constraints -# """ -# function add_constraints!( -# container::OptimizationContainer, -# T::Type{ActivePowerVariableLimitsConstraint}, -# U::Type{<:Union{VariableType, ExpressionType}}, -# devices::IS.FlattenIteratorWrapper{V}, -# model::DeviceModel{V, W}, -# ::NetworkModel{X}, -# ) where {V <: PSY.HydroGen, W <: HydroDispatchRunOfRiver, X <: PM.AbstractPowerModel} -# if !has_semicontinuous_feedforward(model, U) -# add_range_constraints!(container, T, U, devices, model, X) -# end -# add_parameterized_upper_bound_range_constraints( -# container, -# ActivePowerVariableTimeSeriesLimitsConstraint, -# U, -# ActivePowerTimeSeriesParameter, -# devices, -# model, -# X, -# ) -# return -# end -# -# function add_constraints!( -# container::OptimizationContainer, -# T::Type{ActivePowerVariableLimitsConstraint}, -# U::Type{<:RangeConstraintLBExpressions}, -# devices::IS.FlattenIteratorWrapper{V}, -# model::DeviceModel{V, W}, -# ::NetworkModel{X}, -# ) where {V <: PSY.HydroGen, W <: HydroDispatchRunOfRiver, X <: PM.AbstractPowerModel} -# if !has_semicontinuous_feedforward(model, U) -# add_range_constraints!(container, T, U, devices, model, X) -# end -# return -# end -# -# """ -# Add semicontinuous range constraints for Hydro Unit Commitment formulation -# """ -# function add_constraints!( -# container::OptimizationContainer, -# T::Type{ActivePowerVariableLimitsConstraint}, -# U::Type{<:Union{VariableType, <:RangeConstraintLBExpressions}}, -# devices::IS.FlattenIteratorWrapper{V}, -# model::DeviceModel{V, W}, -# ::NetworkModel{X}, -# ) where {V <: PSY.HydroGen, W <: HydroCommitmentRunOfRiver, X <: PM.AbstractPowerModel} -# add_semicontinuous_range_constraints!(container, T, U, devices, model, X) -# return -# end -# -# function add_constraints!( -# container::OptimizationContainer, -# T::Type{ActivePowerVariableLimitsConstraint}, -# U::Type{<:Union{VariableType, ExpressionType}}, -# devices::IS.FlattenIteratorWrapper{V}, -# model::DeviceModel{V, W}, -# ::NetworkModel{X}, -# ) where {V <: PSY.HydroGen, W <: HydroCommitmentRunOfRiver, X <: PM.AbstractPowerModel} -# add_semicontinuous_range_constraints!(container, T, U, devices, model, X) -# add_parameterized_upper_bound_range_constraints( -# container, -# ActivePowerVariableTimeSeriesLimitsConstraint, -# U, -# ActivePowerTimeSeriesParameter, -# devices, -# model, -# X, -# ) -# return -# end -# -# """ -# Min and max reactive Power Variable limits -# """ -# function get_min_max_limits( -# x::PSY.HydroGen, -# ::Type{<:ReactivePowerVariableLimitsConstraint}, -# ::Type{<:AbstractHydroFormulation}, -# ) -# return PSY.get_reactive_power_limits(x) -# end -# -# """ -# Min and max active Power Variable limits -# """ -# function get_min_max_limits( -# x::PSY.HydroGen, -# ::Type{<:ActivePowerVariableLimitsConstraint}, -# ::Type{<:AbstractHydroFormulation}, -# ) -# return PSY.get_active_power_limits(x) -# end -# -# function get_min_max_limits( -# x::PSY.HydroGen, -# ::Type{<:ActivePowerVariableLimitsConstraint}, -# ::Type{HydroDispatchRunOfRiver}, -# ) -# return (min = 0.0, max = PSY.get_max_active_power(x)) -# end -# -# """ -# Add power variable limits constraints for hydro unit commitment formulation -# """ -# function add_constraints!( -# container::OptimizationContainer, -# T::Type{<:PowerVariableLimitsConstraint}, -# U::Type{<:Union{VariableType, ExpressionType}}, -# devices::IS.FlattenIteratorWrapper{V}, -# model::DeviceModel{V, W}, -# ::NetworkModel{X}, -# ) where {V <: PSY.HydroGen, W <: AbstractHydroUnitCommitment, X <: PM.AbstractPowerModel} -# add_semicontinuous_range_constraints!(container, T, U, devices, model, X) -# return -# end -# -# """ -# Add power variable limits constraints for hydro dispatch formulation -# """ -# function add_constraints!( -# container::OptimizationContainer, -# T::Type{<:PowerVariableLimitsConstraint}, -# U::Type{<:Union{VariableType, ExpressionType}}, -# devices::IS.FlattenIteratorWrapper{V}, -# model::DeviceModel{V, W}, -# ::NetworkModel{X}, -# ) where { -# V <: PSY.HydroGen, -# W <: AbstractHydroDispatchFormulation, -# X <: PM.AbstractPowerModel, -# } -# if !has_semicontinuous_feedforward(model, U) -# add_range_constraints!(container, T, U, devices, model, X) -# end -# return -# end -# -# ##################################### Auxillary Variables ############################ -# function _calculate_aux_variable_value!( -# container::OptimizationContainer, -# ::AuxVarKey{EnergyOutput, T}, -# system::PSY.System, -# p_variable_results::JuMPVariableArray, -# ) where {T <: PSY.HydroGen} -# devices = axes(p_variable_results, 1) -# time_steps = get_time_steps(container) -# resolution = get_resolution(container) -# fraction_of_hour = Dates.value(Dates.Minute(resolution)) / MINUTES_IN_HOUR -# aux_variable_container = get_aux_variable(container, EnergyOutput(), T) -# for name in devices, t in time_steps -# aux_variable_container[name, t] = -# jump_value(p_variable_results[name, t]) * fraction_of_hour -# end -# -# return -# end -# -# function calculate_aux_variable_value!( -# container::OptimizationContainer, -# aux_key::AuxVarKey{EnergyOutput, T}, -# system::PSY.System, -# ) where {T <: PSY.HydroGen} -# p_variable_results = get_variable(container, ActivePowerVariable(), T) -# _calculate_aux_variable_value!( -# container, -# aux_key, -# system, -# p_variable_results, -# ) -# return -# end -# -# ##################################### Hydro generation cost ############################ -# function objective_function!( -# container::OptimizationContainer, -# devices::IS.FlattenIteratorWrapper{T}, -# ::DeviceModel{T, U}, -# ::Type{<:PM.AbstractPowerModel}, -# ) where {T <: PSY.HydroGen, U <: AbstractHydroUnitCommitment} -# add_variable_cost!(container, ActivePowerVariable(), devices, U()) -# add_proportional_cost!(container, OnVariable(), devices, U()) -# return -# end -# -# function objective_function!( -# container::OptimizationContainer, -# devices::IS.FlattenIteratorWrapper{T}, -# ::DeviceModel{T, U}, -# ::Type{<:PM.AbstractPowerModel}, -# ) where {T <: PSY.HydroGen, U <: AbstractHydroDispatchFormulation} -# add_variable_cost!(container, ActivePowerVariable(), devices, U()) -# return -# end From ac9cb69517ef487926d32d6c90cb8826c7177554 Mon Sep 17 00:00:00 2001 From: Jose Daniel Lara Date: Wed, 6 Sep 2023 10:22:44 -0600 Subject: [PATCH 6/6] Update PowerSimulations.jl --- src/PowerSimulations.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/PowerSimulations.jl b/src/PowerSimulations.jl index 43e2aa2ff4..c582b790c9 100644 --- a/src/PowerSimulations.jl +++ b/src/PowerSimulations.jl @@ -522,7 +522,6 @@ include("devices_models/devices/thermal_generation.jl") include("devices_models/devices/electric_loads.jl") include("devices_models/devices/AC_branches.jl") include("devices_models/devices/DC_branches.jl") -include("devices_models/devices/hydro_generation.jl") include("devices_models/devices/regulation_device.jl") # Services Models