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

Fix Interface Test and Docs Deploy #1122

Merged
merged 13 commits into from
Jul 9, 2024
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"
jd-lara marked this conversation as resolved.
Show resolved Hide resolved
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 @@
_pre_solve_model_checks(model)
catch
set_status!(model, ModelBuildStatus.FAILED)
@error "Failed to build $(get_name(model))"

Check warning on line 344 in src/simulation/simulation.jl

View check run for this annotation

Codecov / codecov/patch

src/simulation/simulation.jl#L344

Added line #L344 was not covered by tests
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
Loading