Get the available generators in a System
You can access use get_available_components
or get_components
to access all the available generators in an existing system
.
Option 1a: Using get_available_components
to get an iterator
Use get_available_components
to get an iterator of all the available generators in an existing system
, which also prints a summary:
julia> gen_iter = get_available_components(Generator, system)
Generator Counts: HydroDispatch: 1 RenewableDispatch: 29 RenewableNonDispatch: 31 ThermalStandard: 54
The iterator avoids unnecessary memory allocations if there are many generators, and it can be used to view or update the generator data, such as seeing each of the names:
julia> get_name.(gen_iter)
115-element Vector{String}: "313_RTPV_1" "320_RTPV_2" "213_RTPV_1" "313_RTPV_9" "313_RTPV_2" "313_RTPV_7" "320_RTPV_3" "308_RTPV_1" "313_RTPV_4" "313_RTPV_5" ⋮ "301_CT_3" "316_STEAM_1" "216_STEAM_1" "315_CT_6" "201_STEAM_3" "302_CT_4" "307_CT_1" "102_STEAM_4" "107_CC_1"
Above, we use the abstract supertype Generator
to get all components that are subtypes of it. You can instead get all the components of a concrete type, such as:
julia> gen_iter = get_available_components(RenewableDispatch, system)
RenewableDispatch Counts: RenewableDispatch: 29
Option 1b: Using get_available_components
to get a vector
Use collect
to get a vector of the generators instead of an iterator, which could require a lot of memory:
julia> gens = collect(get_available_components(Generator, system));
Option 2: Using get_components
to get an iterator
Alternatively, use get_components
with a filter to check for availability:
julia> gen_iter = get_components(get_available, Generator, system)
Generator Counts: HydroDispatch: 1 RenewableDispatch: 29 RenewableNonDispatch: 31 ThermalStandard: 54
collect
can also be used to turn this iterator into a vector.
See Also
- How to: Get the buses in a System