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
PropertyValue
Name
Description
System Units BaseSYSTEM_BASE
Base Power100.0
Base Frequency60.0
Num Components27
Static Components
TypeCount
ACBus5
Arc6
Line6
PowerLoad3
RenewableDispatch2
ThermalStandard5
StaticTimeSeries Summary
owner_typeowner_categorynametime_series_typeinitial_timestampresolutioncounttime_step_count
StringStringStringStringStringDates.CompoundPeriodInt64Int64
PowerLoadComponentmax_active_powerSingleTimeSeries2024-01-01T00:00:001 hour3168
RenewableDispatchComponentmax_active_powerSingleTimeSeries2024-01-01T00:00:001 hour2168

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