From 9b20947a8d10652f04d3ef1e1ddda87070630555 Mon Sep 17 00:00:00 2001 From: Jose Daniel Lara Date: Fri, 20 Sep 2024 20:50:15 -0600 Subject: [PATCH 1/9] save fixed value for variable --- src/core/optimization_container.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/core/optimization_container.jl b/src/core/optimization_container.jl index e3e7f2ffb..c0fc9dfba 100644 --- a/src/core/optimization_container.jl +++ b/src/core/optimization_container.jl @@ -1716,6 +1716,9 @@ function _process_duals(container::OptimizationContainer, lp_optimizer) if JuMP.has_upper_bound(first(variable)) cache[key][:ub] = JuMP.upper_bound.(variable) end + if JuMP.is_fixed(first(variable)) && is_integer_flag + cache[key][:fixed_int_value] = jump_value.(v) + end cache[key][:integer] = is_integer_flag JuMP.fix.(variable, var_cache[key]; force = true) end @@ -1756,6 +1759,9 @@ function _process_duals(container::OptimizationContainer, lp_optimizer) else JuMP.unfix.(variable) JuMP.set_binary.(variable) + if haskey(cache[key], :fixed_int_value) + JuMP.fix.(variable, cache[key][:fixed_int_value]) + end #= Needed if a model has integer variables if haskey(cache[key], :lb) && JuMP.has_lower_bound(first(variable)) JuMP.set_lower_bound.(variable, cache[key][:lb]) From 7d46f731e103c2ac02df653098fc478865d01495 Mon Sep 17 00:00:00 2001 From: Jose Daniel Lara Date: Fri, 20 Sep 2024 20:50:34 -0600 Subject: [PATCH 2/9] change implementation of must_run vars --- .../devices/thermal_generation.jl | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/devices_models/devices/thermal_generation.jl b/src/devices_models/devices/thermal_generation.jl index 28b12488d..709593521 100644 --- a/src/devices_models/devices/thermal_generation.jl +++ b/src/devices_models/devices/thermal_generation.jl @@ -319,23 +319,25 @@ function add_variable!( container, variable_type, D, - [PSY.get_name(d) for d in devices], + [PSY.get_name(d) for d in devices if !PSY.get_must_run(d)], time_steps, ) - for t in time_steps, d in devices - name = PSY.get_name(d) - variable[name, t] = JuMP.@variable( - get_jump_model(container), - base_name = "$(T)_$(D)_{$(name), $(t)}", - binary = binary - ) - if get_warm_start(settings) - init = get_variable_warm_start_value(variable_type, d, formulation) - init !== nothing && JuMP.set_start_value(variable[name, t], init) - end + for d in devices if PSY.get_must_run(d) - JuMP.fix(variable[name, t], 1.0; force = true) + continue + end + name = PSY.get_name(d) + for t in time_steps + variable[name, t] = JuMP.@variable( + get_jump_model(container), + base_name = "$(T)_$(D)_{$(name), $(t)}", + binary = binary + ) + if get_warm_start(settings) + init = get_variable_warm_start_value(variable_type, d, formulation) + init !== nothing && JuMP.set_start_value(variable[name, t], init) + end end end From ba0bc69e7cfe6317197001d2ab0619434ff6b080 Mon Sep 17 00:00:00 2001 From: Jose Daniel Lara Date: Fri, 20 Sep 2024 20:50:52 -0600 Subject: [PATCH 3/9] change implementation of range constraints with must run --- .../devices/common/range_constraint.jl | 102 ++++++++++++++---- 1 file changed, 82 insertions(+), 20 deletions(-) diff --git a/src/devices_models/devices/common/range_constraint.jl b/src/devices_models/devices/common/range_constraint.jl index a4e056606..d92c5620e 100644 --- a/src/devices_models/devices/common/range_constraint.jl +++ b/src/devices_models/devices/common/range_constraint.jl @@ -104,7 +104,7 @@ function _add_lower_bound_range_constraints_impl!( ci_name = PSY.get_name(device) limits = get_min_max_limits(device, T, W) # depends on constraint type and formulation type con_lb[ci_name, t] = - JuMP.@constraint(container.JuMPmodel, array[ci_name, t] >= limits.min) + JuMP.@constraint(get_jump_model(container), array[ci_name, t] >= limits.min) end return end @@ -126,7 +126,7 @@ function _add_upper_bound_range_constraints_impl!( ci_name = PSY.get_name(device) limits = get_min_max_limits(device, T, W) # depends on constraint type and formulation type con_ub[ci_name, t] = - JuMP.@constraint(container.JuMPmodel, array[ci_name, t] <= limits.max) + JuMP.@constraint(get_jump_model(container), array[ci_name, t] <= limits.max) end return end @@ -246,20 +246,86 @@ function _add_semicontinuous_lower_bound_range_constraints_impl!( ) where {T <: ConstraintType, V <: PSY.Component, W <: AbstractDeviceFormulation} time_steps = get_time_steps(container) names = [PSY.get_name(d) for d in devices] - binary_variables = [OnVariable()] + con_lb = add_constraints_container!(container, T(), V, names, time_steps; meta = "lb") + varbin = get_variable(container, OnVariable(), V) + + for device in devices + ci_name = PSY.get_name(device) + limits = get_min_max_limits(device, T, W) # depends on constraint type and formulation type + for t in time_steps + con_lb[ci_name, t] = JuMP.@constraint( + get_jump_model(container), + array[ci_name, t] >= limits.min * varbin[ci_name, t] + ) + end + end + return +end +function _add_semicontinuous_lower_bound_range_constraints_impl!( + container::OptimizationContainer, + ::Type{T}, + array, + devices::IS.FlattenIteratorWrapper{V}, + ::DeviceModel{V, W}, +) where {T <: ConstraintType, V <: PSY.ThermalGen, W <: AbstractDeviceFormulation} + time_steps = get_time_steps(container) + names = [PSY.get_name(d) for d in devices] con_lb = add_constraints_container!(container, T(), V, names, time_steps; meta = "lb") + varbin = get_variable(container, OnVariable(), V) - @assert length(binary_variables) == 1 "Expected $(binary_variables) for $U $V $T $W to be length 1" - varbin = get_variable(container, only(binary_variables), V) + for device in devices + ci_name = PSY.get_name(device) + limits = get_min_max_limits(device, T, W) # depends on constraint type and formulation type + if PSY.get_must_run_device(device) + for t in time_steps + con_lb[ci_name, t] = JuMP.@constraint( + get_jump_model(container), + array[ci_name, t] >= limits.min + ) + end + else + for t in time_steps + con_lb[ci_name, t] = JuMP.@constraint( + get_jump_model(container), + array[ci_name, t] >= limits.min * varbin[ci_name, t] + ) + end + end + end + return +end - for device in devices, t in time_steps +function _add_semicontinuous_upper_bound_range_constraints_impl!( + container::OptimizationContainer, + ::Type{T}, + array, + devices::IS.FlattenIteratorWrapper{V}, + model::DeviceModel{V, W}, +) where {T <: ConstraintType, V <: PSY.ThermalGen, W <: AbstractDeviceFormulation} + time_steps = get_time_steps(container) + names = [PSY.get_name(d) for d in devices] + con_ub = add_constraints_container!(container, T(), V, names, time_steps; meta = "ub") + varbin = get_variable(container, OnVariable(), V) + + for device in devices ci_name = PSY.get_name(device) limits = get_min_max_limits(device, T, W) # depends on constraint type and formulation type - con_lb[ci_name, t] = JuMP.@constraint( - container.JuMPmodel, - array[ci_name, t] >= limits.min * varbin[ci_name, t] - ) + if PSY.get_must_run_device(device) + for t in time_steps + con_ub[ci_name, t] = JuMP.@constraint( + get_jump_model(container), + array[ci_name, t] <= limits.max + ) + end + else + for t in time_steps + con_ub[ci_name, t] = JuMP.@constraint( + get_jump_model(container), + array[ci_name, t] <= limits.max * varbin[ci_name, t] + ) + end + end end return end @@ -273,18 +339,14 @@ function _add_semicontinuous_upper_bound_range_constraints_impl!( ) where {T <: ConstraintType, V <: PSY.Component, W <: AbstractDeviceFormulation} time_steps = get_time_steps(container) names = [PSY.get_name(d) for d in devices] - binary_variables = [OnVariable()] - con_ub = add_constraints_container!(container, T(), V, names, time_steps; meta = "ub") - - @assert length(binary_variables) == 1 "Expected $(binary_variables) for $U $V $T $W to be length 1" - varbin = get_variable(container, only(binary_variables), V) + varbin = get_variable(container, OnVariable(), V) for device in devices, t in time_steps ci_name = PSY.get_name(device) limits = get_min_max_limits(device, T, W) # depends on constraint type and formulation type con_ub[ci_name, t] = JuMP.@constraint( - container.JuMPmodel, + get_jump_model(container), array[ci_name, t] <= limits.max * varbin[ci_name, t] ) end @@ -375,7 +437,7 @@ function _add_reserve_lower_bound_range_constraints_impl!( ci_name = PSY.get_name(device) limits = get_min_max_limits(device, T, W) con_lb[ci_name, t] = JuMP.@constraint( - container.JuMPmodel, + get_jump_model(container), array[ci_name, t] >= limits.min * (1 - varbin[ci_name, t]) ) end @@ -409,7 +471,7 @@ function _add_reserve_upper_bound_range_constraints_impl!( ci_name = PSY.get_name(device) limits = get_min_max_limits(device, T, W) con_ub[ci_name, t] = JuMP.@constraint( - container.JuMPmodel, + get_jump_model(container), array[ci_name, t] <= limits.max * (1 - varbin[ci_name, t]) ) end @@ -513,7 +575,7 @@ function _add_reserve_lower_bound_range_constraints_impl!( ci_name = PSY.get_name(device) limits = get_min_max_limits(device, T, X) # depends on constraint type and formulation type con_lb[ci_name, t] = JuMP.@constraint( - container.JuMPmodel, + get_jump_model(container), array[ci_name, t] >= limits.min * varbin[ci_name, t] ) end @@ -545,7 +607,7 @@ function _add_reserve_upper_bound_range_constraints_impl!( ci_name = PSY.get_name(device) limits = get_min_max_limits(device, T, X) # depends on constraint type and formulation type con_ub[ci_name, t] = JuMP.@constraint( - container.JuMPmodel, + get_jump_model(container), array[ci_name, t] <= limits.max * varbin[ci_name, t] ) end From cc436e1a221a61914d15410e70cb93c6fe444d57 Mon Sep 17 00:00:00 2001 From: Jose Daniel Lara Date: Fri, 20 Sep 2024 20:57:14 -0600 Subject: [PATCH 4/9] WP fix addition to expressions --- .../devices/common/add_to_expression.jl | 46 +++++++++++++------ 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/src/devices_models/devices/common/add_to_expression.jl b/src/devices_models/devices/common/add_to_expression.jl index efbda4845..3c7ce3277 100644 --- a/src/devices_models/devices/common/add_to_expression.jl +++ b/src/devices_models/devices/common/add_to_expression.jl @@ -530,15 +530,24 @@ function add_to_expression!( variable = get_variable(container, U(), V) expression = get_expression(container, T(), PSY.ACBus) radial_network_reduction = get_radial_network_reduction(network_model) - for d in devices, t in get_time_steps(container) + for d in devices name = PSY.get_name(d) bus_no_ = PSY.get_number(PSY.get_bus(d)) bus_no = PNM.get_mapped_bus_number(radial_network_reduction, bus_no_) - _add_to_jump_expression!( - expression[bus_no, t], - variable[name, t], - get_variable_multiplier(U(), d, W()), - ) + for t in get_time_steps(container) + if PSY.get_must_run(d) + _add_to_jump_expression!( + expression[bus_no, t], + get_variable_multiplier(U(), d, W()), + ) + else + _add_to_jump_expression!( + expression[bus_no, t], + variable[name, t], + get_variable_multiplier(U(), d, W()), + ) + end + end end return end @@ -558,15 +567,24 @@ function add_to_expression!( } variable = get_variable(container, U(), V) expression = get_expression(container, T(), PSY.ACBus) - for d in devices, t in get_time_steps(container) + for d in devices + name = PSY.get_name(d) bus = PSY.get_bus(d) area_name = PSY.get_name(PSY.get_area(bus)) - name = PSY.get_name(d) - _add_to_jump_expression!( - expression[area_name, t], - variable[name, t], - get_variable_multiplier(U(), d, W()), - ) + for t in get_time_steps(container) + if PSY.get_must_run(d) + _add_to_jump_expression!( + expression[area_name, t], + get_variable_multiplier(U(), d, W()), + ) + else + _add_to_jump_expression!( + expression[area_name, t], + variable[name, t], + get_variable_multiplier(U(), d, W()), + ) + end + end end return end @@ -676,7 +694,7 @@ function add_to_expression!( network_model::NetworkModel{CopperPlatePowerModel}, ) where { T <: ActivePowerBalance, - U <: OnVariable, + U <: , V <: PSY.ThermalGen, W <: Union{AbstractCompactUnitCommitment, ThermalCompactDispatch}, } From 6957939b3fb83fa2cbefc0f4e75df74882ae7ea8 Mon Sep 17 00:00:00 2001 From: Jose Daniel Lara Date: Fri, 20 Sep 2024 20:58:46 -0600 Subject: [PATCH 5/9] remove JSON -> JSON3 --- Project.toml | 1 - src/PowerSimulations.jl | 1 - src/utils/file_utils.jl | 4 ++-- src/utils/jump_utils.jl | 2 +- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Project.toml b/Project.toml index 01523f917..860ecd172 100644 --- a/Project.toml +++ b/Project.toml @@ -38,7 +38,6 @@ DocStringExtensions = "~v0.9" HDF5 = "~0.17" InfrastructureSystems = "2" InteractiveUtils = "1" -JSON = "0.21" JSON3 = "1" JuMP = "1" LinearAlgebra = "1" diff --git a/src/PowerSimulations.jl b/src/PowerSimulations.jl index f4d882d98..ddca095e6 100644 --- a/src/PowerSimulations.jl +++ b/src/PowerSimulations.jl @@ -412,7 +412,6 @@ import TimeSeries # I/O Imports import DataFrames -import JSON import CSV import HDF5 import PrettyTables diff --git a/src/utils/file_utils.jl b/src/utils/file_utils.jl index 9ea6116bb..8ee977d89 100644 --- a/src/utils/file_utils.jl +++ b/src/utils/file_utils.jl @@ -3,7 +3,7 @@ Return a decoded JSON file. """ function read_json(filename::AbstractString) open(filename, "r") do io - JSON.parse(io) + JSON3.parse(io) end end @@ -28,7 +28,7 @@ end function read_file_hashes(path) data = open(joinpath(path, IS.HASH_FILENAME), "r") do io - JSON.parse(io) + JSON3.parse(io) end return data["files"] diff --git a/src/utils/jump_utils.jl b/src/utils/jump_utils.jl index e610a91ae..e8635e607 100644 --- a/src/utils/jump_utils.jl +++ b/src/utils/jump_utils.jl @@ -6,7 +6,7 @@ function add_jump_parameter(jump_model::JuMP.Model, val::Number) end function write_data(base_power::Float64, save_path::String) - JSON.write(joinpath(save_path, "base_power.json"), JSON.json(base_power)) + JSON3.write(joinpath(save_path, "base_power.json"), JSON3.json(base_power)) return end From 8c718ce494e379826b35a9cb22c7b1b30f8097c7 Mon Sep 17 00:00:00 2001 From: Jose Daniel Lara Date: Mon, 23 Sep 2024 13:05:55 -0600 Subject: [PATCH 6/9] change use of onvar --- src/devices_models/devices/common/add_to_expression.jl | 2 +- .../devices/common/objective_function/common.jl | 3 +++ src/devices_models/devices/common/range_constraint.jl | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/devices_models/devices/common/add_to_expression.jl b/src/devices_models/devices/common/add_to_expression.jl index 3c7ce3277..ca464980a 100644 --- a/src/devices_models/devices/common/add_to_expression.jl +++ b/src/devices_models/devices/common/add_to_expression.jl @@ -694,7 +694,7 @@ function add_to_expression!( network_model::NetworkModel{CopperPlatePowerModel}, ) where { T <: ActivePowerBalance, - U <: , + U <: OnVariable, V <: PSY.ThermalGen, W <: Union{AbstractCompactUnitCommitment, ThermalCompactDispatch}, } diff --git a/src/devices_models/devices/common/objective_function/common.jl b/src/devices_models/devices/common/objective_function/common.jl index 082cb7993..3d665d35e 100644 --- a/src/devices_models/devices/common/objective_function/common.jl +++ b/src/devices_models/devices/common/objective_function/common.jl @@ -27,6 +27,7 @@ function add_shut_down_cost!( ) where {T <: PSY.Component, U <: VariableType, V <: AbstractDeviceFormulation} multiplier = objective_function_multiplier(U(), V()) for d in devices + PSY.get_must_run(d) && continue op_cost_data = PSY.get_operation_cost(d) cost_term = shut_down_cost(op_cost_data, d, V()) iszero(cost_term) && continue @@ -114,6 +115,7 @@ function _add_start_up_cost_to_objective!( op_cost::Union{PSY.ThermalGenerationCost, PSY.MarketBidCost}, ::U, ) where {T <: VariableType, U <: AbstractDeviceFormulation} + PSY.get_must_run(component) && return cost_term = start_up_cost(op_cost, component, U()) iszero(cost_term) && return multiplier = objective_function_multiplier(T(), U()) @@ -136,6 +138,7 @@ function _add_start_up_cost_to_objective!( op_cost::PSY.ThermalGenerationCost, ::U, ) where {T <: VariableType, U <: ThermalMultiStartUnitCommitment} + PSY.get_must_run(component) && return cost_terms = start_up_cost(op_cost, component, U()) cost_term = cost_terms[MULTI_START_COST_MAP[T]] iszero(cost_term) && return diff --git a/src/devices_models/devices/common/range_constraint.jl b/src/devices_models/devices/common/range_constraint.jl index d92c5620e..0a7c4b804 100644 --- a/src/devices_models/devices/common/range_constraint.jl +++ b/src/devices_models/devices/common/range_constraint.jl @@ -277,7 +277,7 @@ function _add_semicontinuous_lower_bound_range_constraints_impl!( for device in devices ci_name = PSY.get_name(device) limits = get_min_max_limits(device, T, W) # depends on constraint type and formulation type - if PSY.get_must_run_device(device) + if PSY.get_must_run(device) for t in time_steps con_lb[ci_name, t] = JuMP.@constraint( get_jump_model(container), @@ -311,7 +311,7 @@ function _add_semicontinuous_upper_bound_range_constraints_impl!( for device in devices ci_name = PSY.get_name(device) limits = get_min_max_limits(device, T, W) # depends on constraint type and formulation type - if PSY.get_must_run_device(device) + if PSY.get_must_run(device) for t in time_steps con_ub[ci_name, t] = JuMP.@constraint( get_jump_model(container), From 0ce9578f46947dd5349ccfcedabdb1985795b764 Mon Sep 17 00:00:00 2001 From: Jose Daniel Lara Date: Mon, 23 Sep 2024 13:06:03 -0600 Subject: [PATCH 7/9] add new default --- .../devices/thermal_generation.jl | 49 +++++++++++-------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/src/devices_models/devices/thermal_generation.jl b/src/devices_models/devices/thermal_generation.jl index 709593521..5f61b348e 100644 --- a/src/devices_models/devices/thermal_generation.jl +++ b/src/devices_models/devices/thermal_generation.jl @@ -61,7 +61,7 @@ get_expression_multiplier(::OnStatusParameter, ::ActivePowerRangeExpressionLB, d get_expression_multiplier(::OnStatusParameter, ::ActivePowerBalance, d::PSY.ThermalGen, ::AbstractThermalFormulation) = PSY.get_active_power_limits(d).min #################### Initial Conditions for models ############### -initial_condition_default(::DeviceStatus, d::PSY.ThermalGen, ::AbstractThermalFormulation) = PSY.get_status(d) +initial_condition_default(::DeviceStatus, d::PSY.ThermalGen, ::AbstractThermalFormulation) = max(PSY.get_must_run(d), PSY.get_status(d)) initial_condition_variable(::DeviceStatus, d::PSY.ThermalGen, ::AbstractThermalFormulation) = OnVariable() initial_condition_default(::DevicePower, d::PSY.ThermalGen, ::AbstractThermalFormulation) = PSY.get_active_power(d) initial_condition_variable(::DevicePower, d::PSY.ThermalGen, ::AbstractThermalFormulation) = ActivePowerVariable() @@ -307,7 +307,7 @@ function add_variable!( devices::U, formulation::AbstractThermalFormulation, ) where { - T <: OnVariable, + T <: Union{OnVariable, StartVariable, StopVariable}, U <: Union{Vector{D}, IS.FlattenIteratorWrapper{D}}, } where {D <: PSY.ThermalGen} @assert !isempty(devices) @@ -719,26 +719,35 @@ function add_constraints!( for ic in initial_conditions name = PSY.get_name(get_component(ic)) - constraint[name, 1] = JuMP.@constraint( - get_jump_model(container), - varon[name, 1] == get_value(ic) + varstart[name, 1] - varstop[name, 1] - ) - aux_constraint[name, 1] = JuMP.@constraint( - get_jump_model(container), - varstart[name, 1] + varstop[name, 1] <= 1.0 - ) + if !PSY.get_must_run(get_component(ic)) + constraint[name, 1] = JuMP.@constraint( + get_jump_model(container), + varon[name, 1] == get_value(ic) + varstart[name, 1] - varstop[name, 1] + ) + aux_constraint[name, 1] = JuMP.@constraint( + get_jump_model(container), + varstart[name, 1] + varstop[name, 1] <= 1.0 + ) + end end - for t in time_steps[2:end], ic in initial_conditions - name = get_component_name(ic) - constraint[name, t] = JuMP.@constraint( - get_jump_model(container), - varon[name, t] == varon[name, t - 1] + varstart[name, t] - varstop[name, t] - ) - aux_constraint[name, t] = JuMP.@constraint( - get_jump_model(container), - varstart[name, t] + varstop[name, t] <= 1.0 - ) + for ic in initial_conditions + if PSY.get_must_run(get_component(ic)) + continue + else + name = get_component_name(ic) + for t in time_steps[2:end] + constraint[name, t] = JuMP.@constraint( + get_jump_model(container), + varon[name, t] == + varon[name, t - 1] + varstart[name, t] - varstop[name, t] + ) + aux_constraint[name, t] = JuMP.@constraint( + get_jump_model(container), + varstart[name, t] + varstop[name, t] <= 1.0 + ) + end + end end return end From 1e5011f9ede9f2970e9690a9395cf56f4c344fb5 Mon Sep 17 00:00:00 2001 From: Jose Daniel Lara Date: Mon, 23 Sep 2024 13:06:17 -0600 Subject: [PATCH 8/9] WIP fix initial conditions --- src/initial_conditions/add_initial_condition.jl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/initial_conditions/add_initial_condition.jl b/src/initial_conditions/add_initial_condition.jl index 5dd0dba45..2d28e418d 100644 --- a/src/initial_conditions/add_initial_condition.jl +++ b/src/initial_conditions/add_initial_condition.jl @@ -16,7 +16,7 @@ function _get_initial_conditions_value( else val = get_initial_condition_value(ic_data, var_type, W)[1, PSY.get_name(component)] end - @debug "Device $(PSY.get_name(component)) initialized DeviceStatus as $var_type" _group = + @debug "Device $(PSY.get_name(component)) initialized $U as $var_type" _group = LOG_GROUP_BUILD_INITIAL_CONDITIONS return T(component, val) end @@ -39,7 +39,7 @@ function _get_initial_conditions_value( else val = get_initial_condition_value(ic_data, var_type, W)[1, PSY.get_name(component)] end - @debug "Device $(PSY.get_name(component)) initialized DeviceStatus as $var_type" _group = + @debug "Device $(PSY.get_name(component)) initialized $U as $var_type" _group = LOG_GROUP_BUILD_INITIAL_CONDITIONS return T(component, add_jump_parameter(get_jump_model(container), val)) end @@ -66,7 +66,7 @@ function _get_initial_conditions_value( val = PSY.get_time_at_status(component) end end - @debug "Device $(PSY.get_name(component)) initialized DeviceStatus as $var_type" _group = + @debug "Device $(PSY.get_name(component)) initialized $U as $var_type" _group = LOG_GROUP_BUILD_INITIAL_CONDITIONS return T(component, val) end @@ -93,7 +93,7 @@ function _get_initial_conditions_value( val = PSY.get_time_at_status(component) end end - @debug "Device $(PSY.get_name(component)) initialized DeviceStatus as $var_type" _group = + @debug "Device $(PSY.get_name(component)) initialized $U as $var_type" _group = LOG_GROUP_BUILD_INITIAL_CONDITIONS return T(component, add_jump_parameter(get_jump_model(container), val)) end @@ -120,7 +120,7 @@ function _get_initial_conditions_value( val = PSY.get_time_at_status(component) end end - @debug "Device $(PSY.get_name(component)) initialized DeviceStatus as $var_type" _group = + @debug "Device $(PSY.get_name(component)) initialized $U as $var_type" _group = LOG_GROUP_BUILD_INITIAL_CONDITIONS return T(component, val) end @@ -147,7 +147,7 @@ function _get_initial_conditions_value( val = PSY.get_time_at_status(component) end end - @debug "Device $(PSY.get_name(component)) initialized DeviceStatus as $var_type" _group = + @debug "Device $(PSY.get_name(component)) initialized $U as $var_type" _group = LOG_GROUP_BUILD_INITIAL_CONDITIONS return T(component, add_jump_parameter(get_jump_model(container), val)) end @@ -165,7 +165,7 @@ function _get_initial_conditions_value( } where {U <: InitialEnergyLevel} var_type = initial_condition_variable(U(), component, V()) val = initial_condition_default(U(), component, V()) - @debug "Device $(PSY.get_name(component)) initialized DeviceStatus as $var_type" _group = + @debug "Device $(PSY.get_name(component)) initialized $U as $var_type" _group = LOG_GROUP_BUILD_INITIAL_CONDITIONS return T(component, add_jump_parameter(get_jump_model(container), val)) end @@ -183,7 +183,7 @@ function _get_initial_conditions_value( } where {U <: InitialEnergyLevel} var_type = initial_condition_variable(U(), component, V()) val = initial_condition_default(U(), component, V()) - @debug "Device $(PSY.get_name(component)) initialized DeviceStatus as $var_type" _group = + @debug "Device $(PSY.get_name(component)) initialized $U as $var_type" _group = LOG_GROUP_BUILD_INITIAL_CONDITIONS return T(component, val) end From aea5144bce72434f88b4c510eb3832e371cd0173 Mon Sep 17 00:00:00 2001 From: Jose Daniel Lara Date: Mon, 23 Sep 2024 13:06:23 -0600 Subject: [PATCH 9/9] improve testing --- test/test_device_thermal_generation_constructors.jl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/test_device_thermal_generation_constructors.jl b/test/test_device_thermal_generation_constructors.jl index c7387981c..c6bedc670 100644 --- a/test/test_device_thermal_generation_constructors.jl +++ b/test/test_device_thermal_generation_constructors.jl @@ -886,7 +886,7 @@ end sys_5 = build_system(PSITestSystems, "c_sys5_uc") template_uc = ProblemTemplate(NetworkModel(PTDFPowerModel; PTDF_matrix = PTDF(sys_5))) - set_device_model!(template_uc, ThermalStandard, ThermalBasicUnitCommitment) + set_device_model!(template_uc, ThermalStandard, ThermalStandardUnitCommitment) set_device_model!(template_uc, RenewableDispatch, FixedOutput) set_device_model!(template_uc, PowerLoad, StaticPowerLoad) set_device_model!(template_uc, DeviceModel(Line, StaticBranch)) @@ -904,7 +904,10 @@ end solve!(model; output_dir = mktempdir()) ptdf_vars = get_variable_values(OptimizationProblemResults(model)) + power = + ptdf_vars[PowerSimulations.VariableKey{ActivePowerVariable, ThermalStandard}("")] on = ptdf_vars[PowerSimulations.VariableKey{OnVariable, ThermalStandard}("")] - on_sundance = on[!, "Sundance"] - @test all(isapprox.(on_sundance, 1.0)) + power_sundance = power[!, "Sundance"] + @test all(isapprox.(power_sundance, 1.0)) + @test "Sundance" ∉ names(on) end