Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fixing Pumped Hydro formulation #29

Merged
merged 3 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/variables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Docs abbreviation: ``E^{surplus}``
"""
struct HydroEnergySurplusVariable <: PSI.VariableType end

# convert_result_to_natural_units(::Type{WaterSpillageVariable }) = true # TODO: is this pu?
# convert_result_to_natural_units(::Type{HydroEnergyVariableUp}) = true # TODO: is this pu?

"""
Auxiliary Variable for Hydro Models that solve for total energy output
Expand Down
3 changes: 2 additions & 1 deletion src/hydro_generation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,7 @@ function PSI.add_constraints!(
(spillage_var[name, 1] + powerout_var[name, 1]) / efficiency
) * fraction_of_hour +
PSI.get_parameter_column_refs(param_container, name)[1] * multiplier[name, 1]
# Be consistent on this parameter definition
)

for t in time_steps[2:end]
Expand All @@ -607,7 +608,7 @@ function PSI.add_constraints!(
PSI.get_parameter_column_refs(param_container, name)[t] *
multiplier[name, t] +
(
powerin_var[name, 1] -
powerin_var[name, t] -
(powerout_var[name, t] + spillage_var[name, t]) / efficiency
) * fraction_of_hour
)
Expand Down
32 changes: 32 additions & 0 deletions test/test_hydro_simulations.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
@testset "Single-stage Hydro Pumped Simulation" begin
output_dir = mktempdir(; cleanup=true)
sys_ed = PSB.build_system(PSITestSystems, "c_sys5_phes_ed")

template_ed = ProblemTemplate(CopperPlatePowerModel)
set_device_model!(template_ed, PowerLoad, StaticPowerLoad)
set_device_model!(template_ed, ThermalStandard, ThermalBasicUnitCommitment)
set_device_model!(template_ed, HydroPumpedStorage, HydroDispatchPumpedStorage)

model = DecisionModel(
template_ed,
sys_ed,
name="ED",
optimizer=HiGHS_optimizer,
optimizer_solve_log_print=true,
store_variable_names=true,
)

@test build!(model, output_dir=output_dir) == PSI.BuildStatus.BUILT
@test solve!(model; optimizer=HiGHS_optimizer, output_dir=output_dir) ==
RunStatus.SUCCESSFUL

results = ProblemResults(model)
variables = read_variables(results)

# Assert that the water level of the up reservoir level is zero at
# the last simulation step.
reservoir_up_level = "HydroEnergyVariableUp__HydroPumpedStorage"
last_value = last(variables[reservoir_up_level])["HydroPumpedStorage"]
@test isapprox(last_value, 0, atol=1e-5)
end

@testset "Multi-Stage Hydro Simulation Build" begin
sys_md = PSB.build_system(PSISystems, "5_bus_hydro_wk_sys")

Expand Down
Loading