Skip to content

Commit

Permalink
Merge pull request #14 from NREL-Sienna/jd/ntp_bugfix
Browse files Browse the repository at this point in the history
Jd/ntp bugfix
  • Loading branch information
jd-lara authored Aug 4, 2023
2 parents fb19232 + 70a5ad5 commit cd01d2a
Show file tree
Hide file tree
Showing 7 changed files with 165 additions and 133 deletions.
6 changes: 5 additions & 1 deletion src/HydroPowerSimulations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@ export HydroCommitmentReservoirStorage
export HydroDispatchPumpedStorage

######## Hydro Variables ########
export EnergyVariableUp
export HydroEnergyVariableUp
export WaterSpillageVariable
export HydroEnergyShortageVariable

######## Hydro parameters #######
export EnergyTargetParameter

######## Hydro Initial Conditions #######
export InitialHydroEnergyLevelUp
export InitialHydroEnergyLevelDown

#################################################################################
# Imports
using PowerSystems
Expand Down
4 changes: 2 additions & 2 deletions src/core/initial_conditions.jl
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
struct InitialEnergyLevelUp <: PSI.PSI.InitialConditionType end
struct InitialEnergyLevelDown <: PSI.PSI.InitialConditionType end
struct InitialHydroEnergyLevelUp <: PSI.InitialConditionType end
struct InitialHydroEnergyLevelDown <: PSI.InitialConditionType end
6 changes: 3 additions & 3 deletions src/core/variables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ Struct to dispatch the creation of a variable for energy storage level (state of
Docs abbreviation: ``E^{up}``
"""
struct EnergyVariableUp <: PSI.VariableType end
struct HydroEnergyVariableUp <: PSI.VariableType end

"""
Struct to dispatch the creation of a variable for energy storage level (state of charge) of lower reservoir
Docs abbreviation: ``E^{down}``
"""
struct EnergyVariableDown <: PSI.VariableType end
struct HydroEnergyVariableDown <: PSI.VariableType end

"""
Struct to dispatch the creation of a slack variable for energy storage levels < target storage levels
Expand All @@ -31,6 +31,6 @@ Struct to dispatch the creation of a slack variable for energy storage levels >
Docs abbreviation: ``E^{surplus}``
"""
struct EnergySurplusVariable <: PSI.VariableType end
struct HydroEnergySurplusVariable <: PSI.VariableType end

# convert_result_to_natural_units(::Type{WaterSpillageVariable }) = true # TODO: is this pu?
8 changes: 4 additions & 4 deletions src/feedforwards.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ Constructs a equality constraint to a fix a variable in one model using the vari
"""
function PSI.add_feedforward_constraints!(
container::PSI.OptimizationContainer,
::PSI.DeviceModel,
::PSI.DeviceModel{T, U},
devices::IS.FlattenIteratorWrapper{T},
ff::PSI.EnergyTargetFeedforward,
) where {T <: PSY.Component}
) where {T <: PSY.HydroGen, U <: PSI.AbstractHydroFormulation}
time_steps = PSI.get_time_steps(container)
parameter_type = PSI.get_default_parameter_type(ff, T)
param = PSI.get_parameter_array(container, parameter_type(), T)
Expand Down Expand Up @@ -67,10 +67,10 @@ end

function PSI._add_feedforward_arguments!(
container::PSI.OptimizationContainer,
model::PSI.DeviceModel,
model::PSI.DeviceModel{T, U},
devices::IS.FlattenIteratorWrapper{T},
ff::PSI.EnergyTargetFeedforward,
) where {T <: PSY.Component}
) where {T <: PSY.HydroGen, U <: PSI.AbstractHydroFormulation}
parameter_type = PSI.get_default_parameter_type(ff, T)
PSI.add_parameters!(container, parameter_type, ff, model, devices)
# Enabling this FF requires the addition of an extra variable
Expand Down
242 changes: 129 additions & 113 deletions src/hydro_generation.jl

Large diffs are not rendered by default.

28 changes: 20 additions & 8 deletions src/hydrogeneration_constructor.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#=
"""
Construct model for HydroGen with RunOfRiver Dispatch Formulation
"""
Expand Down Expand Up @@ -194,6 +195,7 @@ function PSI.construct_device!(
PSI.add_constraint_dual!(container, sys, model)
return
end
=#

"""
Construct model for HydroGen with ReservoirBudget Dispatch Formulation
Expand Down Expand Up @@ -440,7 +442,7 @@ function PSI.construct_device!(
)
PSI.add_variables!(
container,
EnergySurplusVariable,
HydroEnergySurplusVariable,
devices,
HydroDispatchReservoirStorage(),
)
Expand Down Expand Up @@ -588,7 +590,7 @@ function PSI.construct_device!(
)
PSI.add_variables!(
container,
EnergySurplusVariable,
HydroEnergySurplusVariable,
devices,
HydroDispatchReservoirStorage(),
)
Expand Down Expand Up @@ -929,7 +931,7 @@ function PSI.construct_device!(
)
PSI.add_variables!(
container,
EnergySurplusVariable,
HydroEnergySurplusVariable,
devices,
HydroCommitmentReservoirStorage(),
)
Expand Down Expand Up @@ -1084,7 +1086,7 @@ function PSI.construct_device!(
)
PSI.add_variables!(
container,
EnergySurplusVariable,
HydroEnergySurplusVariable,
devices,
HydroCommitmentReservoirStorage(),
)
Expand Down Expand Up @@ -1203,8 +1205,18 @@ function PSI.construct_device!(
devices,
HydroDispatchPumpedStorage(),
)
PSI.add_variables!(container, EnergyVariableUp, devices, HydroDispatchPumpedStorage())
PSI.add_variables!(container, EnergyVariableDown, devices, HydroDispatchPumpedStorage())
PSI.add_variables!(
container,
HydroEnergyVariableUp,
devices,
HydroDispatchPumpedStorage(),
)
PSI.add_variables!(
container,
HydroEnergyVariableDown,
devices,
HydroDispatchPumpedStorage(),
)
PSI.add_variables!(
container,
WaterSpillageVariable,
Expand Down Expand Up @@ -1280,13 +1292,13 @@ function PSI.construct_device!(
container,
devices,
HydroDispatchPumpedStorage(),
InitialEnergyLevelUp(),
InitialHydroEnergyLevelUp(),
)
PSI.add_initial_condition!(
container,
devices,
HydroDispatchPumpedStorage(),
InitialEnergyLevelDown(),
InitialHydroEnergyLevelDown(),
)

# Energy Balance limits
Expand Down
4 changes: 2 additions & 2 deletions test/test_device_hydro_generation_constructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,8 @@ end

ff_up = PSI.EnergyTargetFeedforward(;
component_type=HydroPumpedStorage,
source=EnergyVariableUp,
affected_values=[EnergyVariableUp],
source=HydroEnergyVariableUp,
affected_values=[HydroEnergyVariableUp],
target_period=12,
penalty_cost=1e4,
)
Expand Down

0 comments on commit cd01d2a

Please sign in to comment.