Skip to content

Commit

Permalink
Merge pull request #1122 from NREL-Sienna/rh/fix_interface_test
Browse files Browse the repository at this point in the history
Fix Interface Test and Docs Deploy
  • Loading branch information
jd-lara committed Jul 9, 2024
2 parents 8be4a70 + c10d201 commit fecb592
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 23 deletions.
1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ TimeSeries = "9e3dc215-6440-5c97-bce1-76c03772f85e"
Documenter = "0.27"
InfrastructureSystems = "2"
julia = "^1.6"
Latexify = "=0.16.3"
10 changes: 0 additions & 10 deletions docs/src/modeler_guide/problem_templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,3 @@ template_unit_commitment
using PowerSimulations #hide
template_unit_commitment()
```

```@docs
template_agc_reserve_deployment
```

```@example
using PowerSimulations #hide
using HydroPowerSimulations #hide
template_agc_reserve_deployment()
```
1 change: 1 addition & 0 deletions docs/src/tutorials/decision_problem.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ using PowerSimulations
using HydroPowerSimulations
using PowerSystemCaseBuilder
using HiGHS # solver
using Dates
```

## Data
Expand Down
12 changes: 8 additions & 4 deletions docs/src/tutorials/pcm_simulation.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ First, we'll create a `System` with hourly data to represent day-ahead forecaste
solar, and load profiles:

```@example pcm
sys_DA = build_system(PSISystems, "modified_RTS_GMLC_DA_sys")
sys_DA = build_system(PSISystems, "modified_RTS_GMLC_DA_sys"; skip_serialization = true)
```

### 5-Minute system
Expand All @@ -47,7 +47,7 @@ The RTS data also includes 5-minute resolution time series data. So, we can crea
`System` to represent 15 minute ahead forecasted data for a "real-time" market:

```@example pcm
sys_RT = build_system(PSISystems, "modified_RTS_GMLC_RT_sys")
sys_RT = build_system(PSISystems, "modified_RTS_GMLC_RT_sys"; skip_serialization = true)
```

## `ProblemTemplate`s define stages
Expand Down Expand Up @@ -165,12 +165,13 @@ Now, we can build and execute a simulation using the `SimulationSequence` and `S
that we've defined.

```@example pcm
path = mkdir(joinpath(".", "rts-store")) #hide
sim = Simulation(
name = "rts-test",
steps = 2,
models = models,
sequence = DA_RT_sequence,
simulation_folder = mktempdir(".", cleanup = true),
simulation_folder = joinpath(".", "rts-store"),
)
```

Expand Down Expand Up @@ -250,16 +251,19 @@ read_parameter(
)
```

* note that this returns the results of each execution step in a separate dataframe *
!!! info
note that this returns the results of each execution step in a separate dataframe
If you want the realized results (without lookahead periods), you can call `read_realized_*`:

```@example pcm
read_realized_variables(
uc_results,
["ActivePowerVariable__ThermalStandard", "ActivePowerVariable__RenewableDispatch"],
)
rm(path, force = true, recursive = true) #hide
```


## Plotting

Take a look at the plotting capabilities in [PowerGraphics.jl](https://github.com/nrel-siip/powergraphics.jl)
9 changes: 6 additions & 3 deletions src/devices_models/devices/common/add_to_expression.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1131,16 +1131,19 @@ function add_to_expression!(
::Type{InterfaceTotalFlow},
::Type{T},
service::PSY.TransmissionInterface,
model::ServiceModel{PSY.TransmissionInterface, ConstantMaxInterfaceFlow},
) where {T <: Union{InterfaceFlowSlackUp, InterfaceFlowSlackDown}}
model::ServiceModel{PSY.TransmissionInterface, U},
) where {
T <: Union{InterfaceFlowSlackUp, InterfaceFlowSlackDown},
U <: Union{ConstantMaxInterfaceFlow, VariableMaxInterfaceFlow},
}
expression = get_expression(container, InterfaceTotalFlow(), PSY.TransmissionInterface)
service_name = PSY.get_name(service)
variable = get_variable(container, T(), PSY.TransmissionInterface, service_name)
for t in get_time_steps(container)
_add_to_jump_expression!(
expression[service_name, t],
variable[t],
get_variable_multiplier(T(), service, ConstantMaxInterfaceFlow()),
get_variable_multiplier(T(), service, U()),
)
end
return
Expand Down
4 changes: 2 additions & 2 deletions src/operation/emulation_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,9 @@ function validate_time_series!(model::EmulationModel{<:DefaultEmulationProblem})
end

counts = PSY.get_time_series_counts(sys)
if counts.forecast_count < 1
if counts.static_time_series_count < 1
error(
"The system does not contain forecast data. A DecisionModel can't be built.",
"The system does not contain Static Time Series data. A EmulationModel can't be built.",
)
end
return
Expand Down
3 changes: 3 additions & 0 deletions src/services_models/transmission_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ get_variable_lower_bound(::InterfaceFlowSlackDown, ::PSY.TransmissionInterface,
get_variable_multiplier(::InterfaceFlowSlackUp, ::PSY.TransmissionInterface, ::ConstantMaxInterfaceFlow) = 1.0
get_variable_multiplier(::InterfaceFlowSlackDown, ::PSY.TransmissionInterface, ::ConstantMaxInterfaceFlow) = -1.0

get_variable_multiplier(::InterfaceFlowSlackUp, ::PSY.TransmissionInterface, ::VariableMaxInterfaceFlow) = 1.0
get_variable_multiplier(::InterfaceFlowSlackDown, ::PSY.TransmissionInterface, ::VariableMaxInterfaceFlow) = -1.0

get_multiplier_value(::MinInterfaceFlowLimitParameter, d::PSY.TransmissionInterface, ::VariableMaxInterfaceFlow) = PSY.get_min_active_power_flow_limit(d)
get_multiplier_value(::MaxInterfaceFlowLimitParameter, d::PSY.TransmissionInterface, ::VariableMaxInterfaceFlow) = PSY.get_max_active_power_flow_limit(d)

Expand Down
1 change: 1 addition & 0 deletions src/simulation/simulation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ function _build_single_model_for_simulation(
_pre_solve_model_checks(model)
catch
set_status!(model, ModelBuildStatus.FAILED)
@error "Failed to build $(get_name(model))"
rethrow()
end
return
Expand Down
4 changes: 2 additions & 2 deletions src/utils/printing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,8 @@ function _show_method(io::IO, sequence::SimulationSequence, backend::Symbol; kwa
table = Matrix{Any}(undef, length(sequence.executions_by_model), length(header))
for (ix, (model, executions)) in enumerate(sequence.executions_by_model)
table[ix, 1] = string(model)
table[ix, 2] = sequence.horizons[model]
table[ix, 3] = Dates.Minute(sequence.intervals[model])
table[ix, 2] = Dates.canonicalize(sequence.horizons[model])
table[ix, 3] = Dates.canonicalize(sequence.intervals[model])
table[ix, 4] = executions
end

Expand Down
4 changes: 2 additions & 2 deletions test/test_services_constructor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ end
template = get_thermal_dispatch_template_network(DCPPowerModel)
set_service_model!(
template,
ServiceModel(TransmissionInterface, ConstantMaxInterfaceFlow; use_slacks = true),
ServiceModel(TransmissionInterface, VariableMaxInterfaceFlow; use_slacks = true),
)

model = DecisionModel(template, c_sys5_uc)
Expand All @@ -515,7 +515,7 @@ end
template = get_thermal_dispatch_template_network(PTDFPowerModel)
set_service_model!(
template,
ServiceModel(TransmissionInterface, ConstantMaxInterfaceFlow; use_slacks = true),
ServiceModel(TransmissionInterface, VariableMaxInterfaceFlow; use_slacks = true),
)
model = DecisionModel(template, c_sys5_uc)
@test build!(model; output_dir = mktempdir(; cleanup = true)) ==
Expand Down

0 comments on commit fecb592

Please sign in to comment.