Adding additional data to a component
All PowerSystems.jl
components have an ext
field that contains an empty Dictionary
. This Dictionary is useful to contain additional required data where there is no need to create new behaviors with that data. A simple example is the addition of geographic information, if needed.
Example
Step 1: Use get_ext
to get the ext
field of the desired components and assign your data:
julia> for g in get_components(ThermalStandard, system) external_field = get_ext(g) external_field["my_data"] = 1.0 end
Here, we added additional data called my_data
to the ThermalStandard
generators in a previously defined System
.
Step 2: Retrieve your data using get_ext
again
First, retrieve the first ThermalStandard generator:
julia> gen = collect(get_components(ThermalStandard, system))[1];
Then, retrieve my_data
from the generator and verify it is 1.0, as assigned.
julia> retrieved_data = get_ext(gen)["my_data"]
1.0