Attach supplemental data to components

This how-to shows how to attach supplemental attributes to components in a System. It uses FixedForcedOutage as the example. For background on why contextual data is kept separate from components, see Supplemental attributes.

Prerequisites

using PowerSystems
using PowerSystemCaseBuilder

sys = build_system(PSISystems, "c_sys5_pjm")
System
Property Value
Name
Description
System Units Base SYSTEM_BASE
Base Power 100.0
Base Frequency 60.0
Num Components 27
Static Components
Type Count
ACBus 5
Arc 6
Line 6
PowerLoad 3
RenewableDispatch 2
ThermalStandard 5
StaticTimeSeries Summary
owner_type owner_category name time_series_type initial_timestamp resolution count time_step_count
String String String String String Dates.CompoundPeriod Int64 Int64
PowerLoad Component max_active_power SingleTimeSeries 2024-01-01T00:00:00 1 hour 3 168
RenewableDispatch Component max_active_power SingleTimeSeries 2024-01-01T00:00:00 1 hour 2 168

Attach a single attribute

Retrieve the target component, construct the attribute, then attach it with add_supplemental_attribute!:

gen = first(get_components(ThermalStandard, sys))
outage = FixedForcedOutage(; outage_status = 0.0)  # 0.0 = available, 1.0 = outaged
add_supplemental_attribute!(sys, gen, outage)

Attach attributes in bulk and share them across components

For adding many attributes at once, use begin_supplemental_attributes_update to batch the operations. This reduces index update overhead and automatically reverts all changes if an error occurs. The same attribute instance can be attached to more than one component to model shared properties:

gens = collect(get_components(ThermalStandard, sys))
gen1 = gens[1]
gen2 = gens[2]
shared_outage = FixedForcedOutage(; outage_status = 1.0)

begin_supplemental_attributes_update(sys) do
    add_supplemental_attribute!(sys, gen1, shared_outage)
    add_supplemental_attribute!(sys, gen2, shared_outage)
end

Next steps