Add custom 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:

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:

gen = collect(get_components(ThermalStandard, system))[1];
ThermalStandard: 322_CT_6:
   name: 322_CT_6
   available: true
   status: true
   bus: ACBus: Cole
   active_power: 0.55
   reactive_power: -0.09730000000000001
   rating: 0.5818934610390462
   active_power_limits: (min = 0.22, max = 0.55)
   reactive_power_limits: (min = -0.15, max = 0.19)
   ramp_limits: (up = 0.037000000000000005, down = 0.037000000000000005)
   operation_cost: ThermalGenerationCost composed of variable: FuelCurve{PiecewiseIncrementalCurve}
   base_power: 64.0
   time_limits: (up = 2.2, down = 2.2)
   must_run: false
   prime_mover_type: PrimeMovers.CT = 8
   fuel: ThermalFuels.NATURAL_GAS = 18
   services: 3-element Vector{Service}
   time_at_status: 10000.0
   dynamic_injector: nothing
   ext: Dict{String, Any}("my_data" => 1.0)
   InfrastructureSystems.SystemUnitsSettings:
      base_value: 100.0
      unit_system: UnitSystem.SYSTEM_BASE = 0
   has_supplemental_attributes: false
   has_time_series: false

Then, retrieve my_data from the generator and verify it is 1.0, as assigned.

retrieved_data = get_ext(gen)["my_data"]
1.0