Operation Problem with HydroPowerSimulations.jl

To follow along, you can download this tutorial as a Julia script (.jl) or Jupyter notebook (.ipynb).

Note

HydroPowerSimulations.jl is an extension library of PowerSimulations.jl for modeling hydro units. Users are encouraged to review the tutorial in PowerSimulations.jl on Running a Single-Step Problem before this tutorial.

Load packages

using PowerSystems
using PowerSimulations
using HydroPowerSimulations
using PowerSystemCaseBuilder
using HiGHS ## solver

Data

Note

PowerSystemCaseBuilder.jl is a helper library that makes it easier to reproduce examples in the documentation and tutorials. Normally you would pass your local files to create the system data instead of calling the function PowerSystemCaseBuilder.build_system.

sys = build_system(PSITestSystems, "c_sys5_hy")
System
Property Value
Name
Description
System Units Base SYSTEM_BASE
Base Power 100.0
Base Frequency 60.0
Num Components 26
Static Components
Type Count
ACBus 5
Arc 6
HydroDispatch 1
Line 6
PowerLoad 3
ThermalStandard 5
Forecast Summary
owner_type owner_category name time_series_type initial_timestamp resolution count horizon interval window_count
String String String String String Dates.CompoundPeriod Int64 Dates.CompoundPeriod Dates.CompoundPeriod Int64
HydroDispatch Component max_active_power Deterministic 2024-01-01T00:00:00 1 hour 1 1 day 1 day 2
PowerLoad Component max_active_power Deterministic 2024-01-01T00:00:00 1 hour 3 1 day 1 day 2

With a single PowerSystems.HydroDispatch:

hy = only(get_components(HydroDispatch, sys))
HydroDispatch: HydroDispatch:
   name: HydroDispatch
   available: true
   bus: ACBus: nodeB
   active_power: 0.0
   reactive_power: 0.0
   rating: 6.0
   prime_mover_type: PowerSystems.PrimeMoversModule.PrimeMovers.HY = 16
   active_power_limits: (min = 0.0, max = 6.0)
   reactive_power_limits: (min = 0.0, max = 6.0)
   ramp_limits: nothing
   time_limits: nothing
   base_power: 100.0
   status: false
   time_at_status: 10000.0
   operation_cost: PowerSystems.HydroGenerationCost composed of variable: InfrastructureSystems.CostCurve{InfrastructureSystems.LinearCurve}
   services: 0-element Vector{PowerSystems.Service}
   dynamic_injector: nothing
   ext: Dict{String, Any}()
   InfrastructureSystems.SystemUnitsSettings:
      base_value: 100.0
      unit_system: InfrastructureSystems.UnitSystemModule.UnitSystem.SYSTEM_BASE = 0
   has_supplemental_attributes: false
   has_time_series: true

Decision Model

Setting up the formulations based on PowerSimulations.jl:

template = ProblemTemplate(PTDFPowerModel)
set_device_model!(template, ThermalStandard, ThermalBasicDispatch)
set_device_model!(template, PowerLoad, StaticPowerLoad)
set_device_model!(template, Line, StaticBranch)

but, now we also include the hydro using HydroDispatchRunOfRiver:

set_device_model!(template, HydroDispatch, HydroDispatchRunOfRiver)

With the template properly set-up, we construct, build and solve the optimization problem:

model = DecisionModel(template, sys; optimizer = HiGHS.Optimizer)
build!(model; output_dir = mktempdir())
solve!(model)
InfrastructureSystems.Simulation.RunStatusModule.RunStatus.SUCCESSFULLY_FINALIZED = 0

Exploring Results

Results can be explored using:

res = OptimizationProblemResults(model)

Start: 2024-01-01T00:00:00

End: 2024-01-01T23:00:00

Resolution: 60 minutes

PowerSimulations Problem Auxiliary variables Results
HydroEnergyOutput__HydroDispatch
PowerSimulations Problem Expressions Results
ActivePowerBalance__System
ProductionCostExpression__ThermalStandard
PTDFBranchFlow__Line
ActivePowerBalance__ACBus
ProductionCostExpression__HydroDispatch
PowerSimulations Problem Parameters Results
ActivePowerTimeSeriesParameter__PowerLoad
ActivePowerTimeSeriesParameter__HydroDispatch
PowerSimulations Problem Variables Results
ActivePowerVariable__ThermalStandard
ActivePowerVariable__HydroDispatch

Use read_variable to read in the dispatch variable results for the hydro:

var = read_variable(res, "ActivePowerVariable__HydroDispatch")
14 rows omitted
DateTime name value
Dates.DateTime String Float64
2024-01-01T00:00:00 HydroDispatch 188.58
2024-01-01T01:00:00 HydroDispatch 232.0104
2024-01-01T02:00:00 HydroDispatch 137.1492
2024-01-01T03:00:00 HydroDispatch 136.00619999999998
2024-01-01T04:00:00 HydroDispatch 133.7202
2024-01-01T05:00:00 HydroDispatch 77.718
2024-01-01T06:00:00 HydroDispatch 86.86080000000001
2024-01-01T07:00:00 HydroDispatch 219.43859999999998
2024-01-01T08:00:00 HydroDispatch 124.57679999999999
2024-01-01T09:00:00 HydroDispatch 373.731