From 90e4429fef9920fdc44228a40a912bb09cc985ac Mon Sep 17 00:00:00 2001 From: GabrielKS <23368820+GabrielKS@users.noreply.github.com> Date: Mon, 18 Mar 2024 15:27:22 -0600 Subject: [PATCH 1/2] Add function `get_system_base_power` --- src/models/components.jl | 9 ++++++--- test/test_dynamic_generator.jl | 4 ++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/models/components.jl b/src/models/components.jl index 1208a282cb..e1d8a50948 100644 --- a/src/models/components.jl +++ b/src/models/components.jl @@ -1,9 +1,12 @@ +function get_system_base_power(c::Component) + return get_internal(c).units_info.base_value +end + """ Default behavior of a component. If there is no base_power field, assume is in the system's base power. """ -function get_base_power(c::Component) - return get_internal(c).units_info.base_value -end +get_base_power(c::Component) = get_system_base_power(c) + function _get_multiplier(c::T) where {T <: Component} setting = get_internal(c).units_info diff --git a/test/test_dynamic_generator.jl b/test/test_dynamic_generator.jl index a65405828f..72a6be9fa7 100644 --- a/test/test_dynamic_generator.jl +++ b/test/test_dynamic_generator.jl @@ -484,6 +484,10 @@ end @test get_dynamic_injector(static_gen) === Gen2AVR @test get_base_power(static_gen) == get_base_power(Gen2AVR) + set_base_power!(static_gen, 1234.5) + @test get_base_power(static_gen) == 1234.5 + @test PSY.get_system_base_power(static_gen) == get_base_power(sys) + # Rule: Can't set the pair injector if the current injector is already set. @test_throws ArgumentError set_dynamic_injector!(static_gen, Gen1AVR) From 290a872f14d8d992784a7d1528ec36e6bcf5d7d3 Mon Sep 17 00:00:00 2001 From: GabrielKS <23368820+GabrielKS@users.noreply.github.com> Date: Mon, 18 Mar 2024 15:31:00 -0600 Subject: [PATCH 2/2] Run formatter --- src/models/components.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/models/components.jl b/src/models/components.jl index e1d8a50948..2ff6a0577e 100644 --- a/src/models/components.jl +++ b/src/models/components.jl @@ -7,7 +7,6 @@ end """ get_base_power(c::Component) = get_system_base_power(c) - function _get_multiplier(c::T) where {T <: Component} setting = get_internal(c).units_info if isnothing(setting)