From 67fb1a5ea72c3dcb14f9577e9d813cae6456ba45 Mon Sep 17 00:00:00 2001 From: rodrigomha Date: Mon, 8 Jul 2024 16:01:26 -0700 Subject: [PATCH 01/12] update test for interface using PTDF --- src/devices_models/devices/common/add_to_expression.jl | 6 +++--- src/services_models/transmission_interface.jl | 3 +++ test/test_services_constructor.jl | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/devices_models/devices/common/add_to_expression.jl b/src/devices_models/devices/common/add_to_expression.jl index 11c43e6f9e..abe6171978 100644 --- a/src/devices_models/devices/common/add_to_expression.jl +++ b/src/devices_models/devices/common/add_to_expression.jl @@ -1131,8 +1131,8 @@ 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) @@ -1140,7 +1140,7 @@ function add_to_expression!( _add_to_jump_expression!( expression[service_name, t], variable[t], - get_variable_multiplier(T(), service, ConstantMaxInterfaceFlow()), + get_variable_multiplier(T(), service, U()), ) end return diff --git a/src/services_models/transmission_interface.jl b/src/services_models/transmission_interface.jl index 60e12cabc3..b76d994aec 100644 --- a/src/services_models/transmission_interface.jl +++ b/src/services_models/transmission_interface.jl @@ -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) diff --git a/test/test_services_constructor.jl b/test/test_services_constructor.jl index 4956904cff..ce3d8b712c 100644 --- a/test/test_services_constructor.jl +++ b/test/test_services_constructor.jl @@ -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) @@ -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)) == From 135cd1ff61324f0284e32eac6c96de8e35cd6589 Mon Sep 17 00:00:00 2001 From: rodrigomha Date: Mon, 8 Jul 2024 16:23:09 -0700 Subject: [PATCH 02/12] formatter --- src/devices_models/devices/common/add_to_expression.jl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/devices_models/devices/common/add_to_expression.jl b/src/devices_models/devices/common/add_to_expression.jl index abe6171978..eb7702ed08 100644 --- a/src/devices_models/devices/common/add_to_expression.jl +++ b/src/devices_models/devices/common/add_to_expression.jl @@ -1132,7 +1132,10 @@ function add_to_expression!( ::Type{T}, service::PSY.TransmissionInterface, model::ServiceModel{PSY.TransmissionInterface, U}, -) where {T <: Union{InterfaceFlowSlackUp, InterfaceFlowSlackDown}, U <: Union{ConstantMaxInterfaceFlow, VariableMaxInterfaceFlow}} +) 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) From 6e3dc1af2fff98aa95bd9fbc535bc763c670307e Mon Sep 17 00:00:00 2001 From: rodrigomha Date: Mon, 8 Jul 2024 16:26:09 -0700 Subject: [PATCH 03/12] fix docs latexify to 0.16.3 --- docs/Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/Project.toml b/docs/Project.toml index 79846ac848..d96ca6ed7c 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -19,3 +19,4 @@ TimeSeries = "9e3dc215-6440-5c97-bce1-76c03772f85e" Documenter = "0.27" InfrastructureSystems = "2" julia = "^1.6" +Latexify = "=0.16.3" \ No newline at end of file From 9e7ff7bcbe24e59de4eb3394cf367ae7eb16c8f9 Mon Sep 17 00:00:00 2001 From: rodrigomha Date: Mon, 8 Jul 2024 16:26:19 -0700 Subject: [PATCH 04/12] remove agc templates --- docs/src/modeler_guide/problem_templates.md | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/docs/src/modeler_guide/problem_templates.md b/docs/src/modeler_guide/problem_templates.md index aea9e98c44..09addbde94 100644 --- a/docs/src/modeler_guide/problem_templates.md +++ b/docs/src/modeler_guide/problem_templates.md @@ -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() -``` From df14bae02eb685d038954a1f563633dbc2ce4bba Mon Sep 17 00:00:00 2001 From: rodrigomha Date: Mon, 8 Jul 2024 16:59:02 -0700 Subject: [PATCH 05/12] add Dates --- docs/src/tutorials/decision_problem.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/src/tutorials/decision_problem.md b/docs/src/tutorials/decision_problem.md index a5a79b0b37..be6325b600 100644 --- a/docs/src/tutorials/decision_problem.md +++ b/docs/src/tutorials/decision_problem.md @@ -16,6 +16,7 @@ using PowerSimulations using HydroPowerSimulations using PowerSystemCaseBuilder using HiGHS # solver +using Dates ``` ## Data From c6b2502c320a508103597862e95adb2f56813bfd Mon Sep 17 00:00:00 2001 From: rodrigomha Date: Mon, 8 Jul 2024 16:59:19 -0700 Subject: [PATCH 06/12] fix PCM folder and remove it --- docs/make.jl | 2 ++ docs/src/tutorials/pcm_simulation.md | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/make.jl b/docs/make.jl index ce9640a385..572815ec9f 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -53,6 +53,8 @@ makedocs(; pages = Any[p for p in pages], ) +rm(joinpath(@__DIR__, "build", "tutorials", "rts-store"); recursive = true) + deploydocs(; repo = "github.com/NREL-Sienna/PowerSimulations.jl.git", target = "build", diff --git a/docs/src/tutorials/pcm_simulation.md b/docs/src/tutorials/pcm_simulation.md index dd9bcbabbf..434099b7d2 100644 --- a/docs/src/tutorials/pcm_simulation.md +++ b/docs/src/tutorials/pcm_simulation.md @@ -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 @@ -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 @@ -165,12 +165,13 @@ Now, we can build and execute a simulation using the `SimulationSequence` and `S that we've defined. ```@example pcm +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"), ) ``` From fe877ff631f59d213d8a4795ba00f35c5c3b4c3e Mon Sep 17 00:00:00 2001 From: Jose Daniel Lara Date: Mon, 8 Jul 2024 18:07:36 -0600 Subject: [PATCH 07/12] add remove in example --- docs/src/tutorials/pcm_simulation.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/src/tutorials/pcm_simulation.md b/docs/src/tutorials/pcm_simulation.md index 434099b7d2..3d9bfd40da 100644 --- a/docs/src/tutorials/pcm_simulation.md +++ b/docs/src/tutorials/pcm_simulation.md @@ -165,7 +165,7 @@ Now, we can build and execute a simulation using the `SimulationSequence` and `S that we've defined. ```@example pcm -mkdir(joinpath(".", "rts-store")) #hide +path = mkdir(joinpath(".", "rts-store")) #hide sim = Simulation( name = "rts-test", steps = 2, @@ -251,7 +251,8 @@ 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 @@ -259,8 +260,10 @@ 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) From 6e8a2ef2793ac037b94baf320bbd83ae90fc72f5 Mon Sep 17 00:00:00 2001 From: rodrigomha Date: Mon, 8 Jul 2024 17:26:24 -0700 Subject: [PATCH 08/12] remove in make.jl --- docs/make.jl | 2 -- docs/src/tutorials/pcm_simulation.md | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/make.jl b/docs/make.jl index 572815ec9f..ce9640a385 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -53,8 +53,6 @@ makedocs(; pages = Any[p for p in pages], ) -rm(joinpath(@__DIR__, "build", "tutorials", "rts-store"); recursive = true) - deploydocs(; repo = "github.com/NREL-Sienna/PowerSimulations.jl.git", target = "build", diff --git a/docs/src/tutorials/pcm_simulation.md b/docs/src/tutorials/pcm_simulation.md index 3d9bfd40da..6f0ae2e92e 100644 --- a/docs/src/tutorials/pcm_simulation.md +++ b/docs/src/tutorials/pcm_simulation.md @@ -260,7 +260,7 @@ read_realized_variables( uc_results, ["ActivePowerVariable__ThermalStandard", "ActivePowerVariable__RenewableDispatch"], ) -rm(path, force =true, recursive = true) # hide +rm(path, force = true, recursive = true) #hide ``` From ac159db85d57ba6d9a84b87ba1c2865ae576c44b Mon Sep 17 00:00:00 2001 From: Jose Daniel Lara Date: Mon, 8 Jul 2024 18:52:31 -0600 Subject: [PATCH 09/12] better printing --- src/utils/printing.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/printing.jl b/src/utils/printing.jl index 9c00e015af..ae3f97fb1c 100644 --- a/src/utils/printing.jl +++ b/src/utils/printing.jl @@ -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 From b3e948a4eaf1c8d46ab3156e613c3b3cf83693a9 Mon Sep 17 00:00:00 2001 From: rodrigomha Date: Mon, 8 Jul 2024 18:08:40 -0700 Subject: [PATCH 10/12] fix emulation check --- src/operation/emulation_model.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/operation/emulation_model.jl b/src/operation/emulation_model.jl index ab7be81b28..c635cf35b6 100644 --- a/src/operation/emulation_model.jl +++ b/src/operation/emulation_model.jl @@ -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 From 35e1f67c0084e62c1a6649111b0d43c4887afe54 Mon Sep 17 00:00:00 2001 From: rodrigomha Date: Mon, 8 Jul 2024 18:13:16 -0700 Subject: [PATCH 11/12] add new line --- docs/Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Project.toml b/docs/Project.toml index d96ca6ed7c..920e4c969c 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -19,4 +19,4 @@ TimeSeries = "9e3dc215-6440-5c97-bce1-76c03772f85e" Documenter = "0.27" InfrastructureSystems = "2" julia = "^1.6" -Latexify = "=0.16.3" \ No newline at end of file +Latexify = "=0.16.3" From c10d201a835f1866280770a083bc54021278b496 Mon Sep 17 00:00:00 2001 From: Jose Daniel Lara Date: Mon, 8 Jul 2024 19:23:49 -0600 Subject: [PATCH 12/12] add additional print --- src/simulation/simulation.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/simulation/simulation.jl b/src/simulation/simulation.jl index 7723e38fe9..68a2ab172c 100644 --- a/src/simulation/simulation.jl +++ b/src/simulation/simulation.jl @@ -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