Skip to content

Commit

Permalink
Add function
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielKS committed Mar 18, 2024
1 parent 770d12c commit facc3da
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/models/components.jl
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 4 additions & 0 deletions test/test_dynamic_generator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit facc3da

Please sign in to comment.