From bbb20a2a7261ec1da9d3197be70287bf1bf63161 Mon Sep 17 00:00:00 2001 From: GabrielKS <23368820+GabrielKS@users.noreply.github.com> Date: Mon, 18 Mar 2024 15:24:28 -0600 Subject: [PATCH 1/3] Fix #1064 --- src/devices_models/devices/thermal_generation.jl | 4 ++-- test/test_device_thermal_generation_constructors.jl | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/devices_models/devices/thermal_generation.jl b/src/devices_models/devices/thermal_generation.jl index 79ace79bed..8dc84dcfc6 100644 --- a/src/devices_models/devices/thermal_generation.jl +++ b/src/devices_models/devices/thermal_generation.jl @@ -116,10 +116,10 @@ function no_load_cost(cost::Union{PSY.ThreePartCost, PSY.TwoPartCost}, S::OnVari end no_load_cost(cost::PSY.VariableCost{Vector{NTuple{2, Float64}}}, ::OnVariable, ::PSY.ThermalGen, ::AbstractThermalFormulation) = first(PSY.get_cost(cost))[1] -no_load_cost(cost::PSY.VariableCost{Float64}, ::OnVariable, d::PSY.ThermalGen, ::AbstractThermalFormulation) = PSY.get_cost(cost) * PSY.get_active_power_limits(d).min * PSY.get_base_power(d) +no_load_cost(cost::PSY.VariableCost{Float64}, ::OnVariable, d::PSY.ThermalGen, ::AbstractThermalFormulation) = PSY.get_cost(cost) * PSY.get_active_power_limits(d).min * PSY.get_system_base_power(d) function no_load_cost(cost::PSY.VariableCost{Tuple{Float64, Float64}}, ::OnVariable, d::PSY.ThermalGen, ::AbstractThermalFormulation) - return (PSY.get_cost(cost)[1] * (PSY.get_active_power_limits(d).min)^2 + PSY.get_cost(cost)[2] * PSY.get_active_power_limits(d).min)* PSY.get_base_power(d) + return (PSY.get_cost(cost)[1] * (PSY.get_active_power_limits(d).min)^2 + PSY.get_cost(cost)[2] * PSY.get_active_power_limits(d).min)* PSY.get_system_base_power(d) end #! format: on diff --git a/test/test_device_thermal_generation_constructors.jl b/test/test_device_thermal_generation_constructors.jl index 4f9f1f931d..a83524fe42 100644 --- a/test/test_device_thermal_generation_constructors.jl +++ b/test/test_device_thermal_generation_constructors.jl @@ -816,3 +816,14 @@ end on_sundance = on[!, "Sundance"] @test all(isapprox.(on_sundance, 1.0)) end + +# NOTE not a comprehensive test, should expand as part of the cost refactor +@testset "Test no_load_cost" begin + sys = build_system(PSITestSystems, "c_sys5_uc") + comp = get_component(ThermalStandard, sys, "Sundance") + sys_base_power = get_base_power(sys) + set_base_power!(comp, 123.4) + min_limit = PSY.get_active_power_limits(comp).min + @test isapprox(PSI.no_load_cost(VariableCost(5.0), OnVariable(), comp, ThermalBasicUnitCommitment()), 5.0 * min_limit * sys_base_power) + @test isapprox(PSI.no_load_cost(VariableCost((3.0, 5.0)), OnVariable(), comp, ThermalBasicUnitCommitment()), (3.0*min_limit^2 + 5.0*min_limit) * sys_base_power) +end From d71b8d1a63122f29113dcd74bd898bd5df67c735 Mon Sep 17 00:00:00 2001 From: GabrielKS <23368820+GabrielKS@users.noreply.github.com> Date: Mon, 18 Mar 2024 15:30:41 -0600 Subject: [PATCH 2/3] Run formatter --- ..._device_thermal_generation_constructors.jl | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/test/test_device_thermal_generation_constructors.jl b/test/test_device_thermal_generation_constructors.jl index a83524fe42..75b1b1d3ea 100644 --- a/test/test_device_thermal_generation_constructors.jl +++ b/test/test_device_thermal_generation_constructors.jl @@ -824,6 +824,22 @@ end sys_base_power = get_base_power(sys) set_base_power!(comp, 123.4) min_limit = PSY.get_active_power_limits(comp).min - @test isapprox(PSI.no_load_cost(VariableCost(5.0), OnVariable(), comp, ThermalBasicUnitCommitment()), 5.0 * min_limit * sys_base_power) - @test isapprox(PSI.no_load_cost(VariableCost((3.0, 5.0)), OnVariable(), comp, ThermalBasicUnitCommitment()), (3.0*min_limit^2 + 5.0*min_limit) * sys_base_power) + @test isapprox( + PSI.no_load_cost( + VariableCost(5.0), + OnVariable(), + comp, + ThermalBasicUnitCommitment(), + ), + 5.0 * min_limit * sys_base_power, + ) + @test isapprox( + PSI.no_load_cost( + VariableCost((3.0, 5.0)), + OnVariable(), + comp, + ThermalBasicUnitCommitment(), + ), + (3.0 * min_limit^2 + 5.0 * min_limit) * sys_base_power, + ) end From 20bfb4e77ed446cebd90e980f33f2d01148d82e4 Mon Sep 17 00:00:00 2001 From: GabrielKS <23368820+GabrielKS@users.noreply.github.com> Date: Mon, 18 Mar 2024 16:19:21 -0600 Subject: [PATCH 3/3] Update PowerSystems minimum version --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 1d1b4455bf..3956e7510d 100644 --- a/Project.toml +++ b/Project.toml @@ -47,7 +47,7 @@ Logging = "1" MathOptInterface = "1" PowerModels = "^0.20" PowerNetworkMatrices = "^0.10" -PowerSystems = "^3" +PowerSystems = "^3.3" PrettyTables = "2" ProgressMeter = "^1.5" SHA = "0.7"