Get the buses in a System
You can access all the buses in a System
to view or manipulate their data using two key functions: get_components
or get_buses
.
Option 1a: Get an iterator for all the buses
Use get_components
to get an iterator of all the AC buses in an existing system
:
julia> bus_iter = get_components(ACBus, system)
ACBus Counts: ACBus: 73
The iterator avoids unnecessary memory allocations if there are many buses, and it can be used to view or update the bus data. For example, we can set the base voltage of all buses to 330 kV:
julia> for b in bus_iter set_base_voltage!(b, 330.0) end
Option 1b: Get a vector of all the buses
Use collect
to get a vector of the buses instead of an iterator, which could require a lot of memory:
julia> buses = collect(get_components(ACBus, system))
73-element Vector{ACBus}: ACBus(202, Bacon, ACBusTypes.PV = 2, -0.1877810214196211, 1.04844, (min = 0.95, max = 1.05), 330.0, Area(2, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(22.0, 5.29, 1.08, Dict{String, Any}()), Dict{String, Any}()) ACBus(321, Cobb, ACBusTypes.PV = 2, 0.21539492271297458, 1.05, (min = 0.95, max = 1.05), 330.0, Area(3, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(37.0, 3.33, 0.68, Dict{String, Any}()), Dict{String, Any}()) ACBus(322, Cole, ACBusTypes.PV = 2, 0.3153659860038082, 1.05, (min = 0.95, max = 1.05), 330.0, Area(3, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(37.0, 3.33, 0.68, Dict{String, Any}()), Dict{String, Any}()) ACBus(102, Adams, ACBusTypes.PV = 2, -0.1364470483941135, 1.04783, (min = 0.95, max = 1.05), 330.0, Area(1, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(12.0, 5.29, 1.08, Dict{String, Any}()), Dict{String, Any}()) ACBus(117, Aston, ACBusTypes.PQ = 1, 0.19956391373276003, 1.04783, (min = 0.95, max = 1.05), 330.0, Area(1, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(17.0, 3.33, 0.68, Dict{String, Any}()), Dict{String, Any}()) ACBus(324, Curie, ACBusTypes.PQ = 1, 0.02279504722859714, 1.01046, (min = 0.95, max = 1.05), 330.0, Area(3, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(36.0, 6.109999999999999, 1.23, Dict{String, Any}()), Dict{String, Any}()) ACBus(121, Attlee, ACBusTypes.PV = 2, 0.22840303616101354, 1.05, (min = 0.95, max = 1.05), 330.0, Area(1, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(17.0, 3.33, 0.68, Dict{String, Any}()), Dict{String, Any}()) ACBus(206, Bajer, ACBusTypes.PQ = 1, -0.28198796032281825, 1.03259, (min = 0.95, max = 1.05), 330.0, Area(2, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(22.0, 5.29, 1.08, Dict{String, Any}()), Dict{String, Any}()) ACBus(217, Bates, ACBusTypes.PQ = 1, 0.15390994022494278, 1.04847, (min = 0.95, max = 1.05), 330.0, Area(2, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(27.0, 3.33, 0.68, Dict{String, Any}()), Dict{String, Any}()) ACBus(103, Adler, ACBusTypes.PQ = 1, -0.1258539470320591, 1.01085, (min = 0.95, max = 1.05), 330.0, Area(1, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(11.0, 4.33, 0.88, Dict{String, Any}()), Dict{String, Any}()) ⋮ ACBus(218, Bayle, ACBusTypes.PV = 2, 0.17444094634785287, 1.05, (min = 0.95, max = 1.05), 330.0, Area(2, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(27.0, 3.33, 0.68, Dict{String, Any}()), Dict{String, Any}()) ACBus(219, Bede, ACBusTypes.PQ = 1, 0.07351902768053274, 1.03946, (min = 0.95, max = 1.05), 330.0, Area(2, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(25.0, 3.09, 0.63, Dict{String, Any}()), Dict{String, Any}()) ACBus(114, Arnold, ACBusTypes.PV = 2, -0.03020396990331307, 1.04401, (min = 0.95, max = 1.05), 330.0, Area(1, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(16.0, 6.109999999999999, 1.23, Dict{String, Any}()), Dict{String, Any}()) ACBus(207, Baker, ACBusTypes.PV = 2, -0.23502708427110763, 1.03973, (min = 0.95, max = 1.05), 330.0, Area(2, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(22.0, 5.29, 1.08, Dict{String, Any}()), Dict{String, Any}()) ACBus(214, Barry, ACBusTypes.PV = 2, -0.08177199158151313, 1.04335, (min = 0.95, max = 1.05), 330.0, Area(2, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(26.0, 6.109999999999999, 1.23, Dict{String, Any}()), Dict{String, Any}()) ACBus(212, Barkla, ACBusTypes.PQ = 1, -0.09168807972671891, 1.01921, (min = 0.95, max = 1.05), 330.0, Area(2, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(23.0, 3.7, 0.76, Dict{String, Any}()), Dict{String, Any}()) ACBus(113, Arne, ACBusTypes.REF = 3, 0.0, 1.03943, (min = 0.95, max = 1.05), 330.0, Area(1, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(14.0, 2.65, 0.54, Dict{String, Any}()), Dict{String, Any}()) ACBus(203, Baffin, ACBusTypes.PQ = 1, -0.18281503609892163, 1.01886, (min = 0.95, max = 1.05), 330.0, Area(2, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(21.0, 4.33, 0.88, Dict{String, Any}()), Dict{String, Any}()) ACBus(112, Archer, ACBusTypes.PQ = 1, -0.042310969858547334, 1.02024, (min = 0.95, max = 1.05), 330.0, Area(1, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(13.0, 3.7, 0.76, Dict{String, Any}()), Dict{String, Any}())
Option 2a: Get the buses in an Area or LoadZone
Use get_buses
to get a vector of buses when you know which Area
or LoadZone
you are interested in.
First, we select an Area:
julia> show_components(Area, system) # See available Areas
Area ┌──────┐ │ name │ ├──────┤ │ 1 │ │ 2 │ │ 3 │ └──────┘
julia> area2 = get_component(Area, system, "2"); # Get Area named 2
Then call get_buses
for that Area:
julia> area_buses = get_buses(system, area2)
24-element Vector{ACBus}: ACBus(202, Bacon, ACBusTypes.PV = 2, -0.1877810214196211, 1.04844, (min = 0.95, max = 1.05), 330.0, Area(2, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(22.0, 5.29, 1.08, Dict{String, Any}()), Dict{String, Any}()) ACBus(206, Bajer, ACBusTypes.PQ = 1, -0.28198796032281825, 1.03259, (min = 0.95, max = 1.05), 330.0, Area(2, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(22.0, 5.29, 1.08, Dict{String, Any}()), Dict{String, Any}()) ACBus(217, Bates, ACBusTypes.PQ = 1, 0.15390994022494278, 1.04847, (min = 0.95, max = 1.05), 330.0, Area(2, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(27.0, 3.33, 0.68, Dict{String, Any}()), Dict{String, Any}()) ACBus(204, Bailey, ACBusTypes.PQ = 1, -0.23535398444000616, 1.0189, (min = 0.95, max = 1.05), 330.0, Area(2, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(21.0, 4.33, 0.88, Dict{String, Any}()), Dict{String, Any}()) ACBus(215, Barton, ACBusTypes.PV = 2, 0.08087000542408246, 1.04327, (min = 0.95, max = 1.05), 330.0, Area(2, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(26.0, 6.109999999999999, 1.23, Dict{String, Any}()), Dict{String, Any}()) ACBus(201, Bach, ACBusTypes.PV = 2, -0.18657098464921346, 1.04841, (min = 0.95, max = 1.05), 330.0, Area(2, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(21.0, 4.33, 0.88, Dict{String, Any}()), Dict{String, Any}()) ACBus(205, Bain, ACBusTypes.PQ = 1, -0.23757194885344055, 1.03603, (min = 0.95, max = 1.05), 330.0, Area(2, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(21.0, 4.33, 0.88, Dict{String, Any}()), Dict{String, Any}()) ACBus(222, Bell, ACBusTypes.PV = 2, 0.28679302628648384, 1.05, (min = 0.95, max = 1.05), 330.0, Area(2, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(27.0, 3.33, 0.68, Dict{String, Any}()), Dict{String, Any}()) ACBus(211, Bardeen, ACBusTypes.PQ = 1, -0.12100996022607405, 1.02735, (min = 0.95, max = 1.05), 330.0, Area(2, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(23.0, 3.7, 0.76, Dict{String, Any}()), Dict{String, Any}()) ACBus(223, Bloch, ACBusTypes.PV = 2, 0.125340994764898, 1.05, (min = 0.95, max = 1.05), 330.0, Area(2, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(25.0, 3.09, 0.63, Dict{String, Any}()), Dict{String, Any}()) ⋮ ACBus(220, Beethoven, ACBusTypes.PQ = 1, 0.09886400094629359, 1.0438, (min = 0.95, max = 1.05), 330.0, Area(2, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(25.0, 3.09, 0.63, Dict{String, Any}()), Dict{String, Any}()) ACBus(208, Balch, ACBusTypes.PQ = 1, -0.2831550619936269, 1.01203, (min = 0.95, max = 1.05), 330.0, Area(2, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(22.0, 5.29, 1.08, Dict{String, Any}()), Dict{String, Any}()) ACBus(221, Behring, ACBusTypes.PV = 2, 0.1855649768683639, 1.05, (min = 0.95, max = 1.05), 330.0, Area(2, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(27.0, 3.33, 0.68, Dict{String, Any}()), Dict{String, Any}()) ACBus(218, Bayle, ACBusTypes.PV = 2, 0.17444094634785287, 1.05, (min = 0.95, max = 1.05), 330.0, Area(2, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(27.0, 3.33, 0.68, Dict{String, Any}()), Dict{String, Any}()) ACBus(219, Bede, ACBusTypes.PQ = 1, 0.07351902768053274, 1.03946, (min = 0.95, max = 1.05), 330.0, Area(2, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(25.0, 3.09, 0.63, Dict{String, Any}()), Dict{String, Any}()) ACBus(207, Baker, ACBusTypes.PV = 2, -0.23502708427110763, 1.03973, (min = 0.95, max = 1.05), 330.0, Area(2, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(22.0, 5.29, 1.08, Dict{String, Any}()), Dict{String, Any}()) ACBus(214, Barry, ACBusTypes.PV = 2, -0.08177199158151313, 1.04335, (min = 0.95, max = 1.05), 330.0, Area(2, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(26.0, 6.109999999999999, 1.23, Dict{String, Any}()), Dict{String, Any}()) ACBus(212, Barkla, ACBusTypes.PQ = 1, -0.09168807972671891, 1.01921, (min = 0.95, max = 1.05), 330.0, Area(2, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(23.0, 3.7, 0.76, Dict{String, Any}()), Dict{String, Any}()) ACBus(203, Baffin, ACBusTypes.PQ = 1, -0.18281503609892163, 1.01886, (min = 0.95, max = 1.05), 330.0, Area(2, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(21.0, 4.33, 0.88, Dict{String, Any}()), Dict{String, Any}())
Option 2b: Get buses by ID number
Finally, use get_buses
to get a vector of buses by their ID numbers.
Example getting buses with ID numbers from 101 to 110:
julia> buses_by_ID = get_buses(system, Set(101:110))
10-element Vector{ACBus}: ACBus(102, Adams, ACBusTypes.PV = 2, -0.1364470483941135, 1.04783, (min = 0.95, max = 1.05), 330.0, Area(1, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(12.0, 5.29, 1.08, Dict{String, Any}()), Dict{String, Any}()) ACBus(103, Adler, ACBusTypes.PQ = 1, -0.1258539470320591, 1.01085, (min = 0.95, max = 1.05), 330.0, Area(1, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(11.0, 4.33, 0.88, Dict{String, Any}()), Dict{String, Any}()) ACBus(107, Alder, ACBusTypes.PV = 2, -0.19681606735842017, 1.03745, (min = 0.95, max = 1.05), 330.0, Area(1, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(12.0, 5.29, 1.08, Dict{String, Any}()), Dict{String, Any}()) ACBus(110, Allen, ACBusTypes.PQ = 1, -0.18536496213608536, 1.05, (min = 0.95, max = 1.05), 330.0, Area(1, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(13.0, 3.7, 0.76, Dict{String, Any}()), Dict{String, Any}()) ACBus(109, Ali, ACBusTypes.PQ = 1, -0.15385496235350493, 1.0261, (min = 0.95, max = 1.05), 330.0, Area(1, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(13.0, 3.7, 0.76, Dict{String, Any}()), Dict{String, Any}()) ACBus(108, Alger, ACBusTypes.PQ = 1, -0.23997701256268875, 1.01024, (min = 0.95, max = 1.05), 330.0, Area(1, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(12.0, 5.29, 1.08, Dict{String, Any}()), Dict{String, Any}()) ACBus(104, Agricola, ACBusTypes.PQ = 1, -0.18441393222667365, 1.01765, (min = 0.95, max = 1.05), 330.0, Area(1, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(11.0, 4.33, 0.88, Dict{String, Any}()), Dict{String, Any}()) ACBus(105, Aiken, ACBusTypes.PQ = 1, -0.18690504066804514, 1.03568, (min = 0.95, max = 1.05), 330.0, Area(1, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(11.0, 4.33, 0.88, Dict{String, Any}()), Dict{String, Any}()) ACBus(106, Alber, ACBusTypes.PQ = 1, -0.23176995082103577, 1.03242, (min = 0.95, max = 1.05), 330.0, Area(1, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(12.0, 5.29, 1.08, Dict{String, Any}()), Dict{String, Any}()) ACBus(101, Abel, ACBusTypes.PV = 2, -0.13511501310899143, 1.04777, (min = 0.95, max = 1.05), 330.0, Area(1, 0.0, 0.0, 0.0, Dict{String, Any}()), LoadZone(11.0, 4.33, 0.88, Dict{String, Any}()), Dict{String, Any}())
You can combine this with Option 1 to first view all the bus numbers if needed:
julia> get_number.(get_components(ACBus, system))
73-element Vector{Int64}: 202 321 322 102 117 324 121 206 217 103 ⋮ 218 219 114 207 214 212 113 203 112