Skip to content

Commit

Permalink
Merge pull request #1090 from NREL-Sienna/gks/fix_1064
Browse files Browse the repository at this point in the history
Fix #1064
  • Loading branch information
jd-lara authored Mar 18, 2024
2 parents 50463ac + 20bfb4e commit 0026d14
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions src/devices_models/devices/thermal_generation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions test/test_device_thermal_generation_constructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -816,3 +816,30 @@ 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

0 comments on commit 0026d14

Please sign in to comment.