diff --git a/docs/Project.toml b/docs/Project.toml index 79846ac848..920e4c969c 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" 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() -``` 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 diff --git a/docs/src/tutorials/pcm_simulation.md b/docs/src/tutorials/pcm_simulation.md index dd9bcbabbf..6f0ae2e92e 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 +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"), ) ``` @@ -250,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 @@ -258,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) diff --git a/src/devices_models/devices/common/add_to_expression.jl b/src/devices_models/devices/common/add_to_expression.jl index 11c43e6f9e..eb7702ed08 100644 --- a/src/devices_models/devices/common/add_to_expression.jl +++ b/src/devices_models/devices/common/add_to_expression.jl @@ -1131,8 +1131,11 @@ 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 +1143,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/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 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/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 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 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)) ==