Skip to content

Mb/events port - #218

Draft
m-bossart wants to merge 18 commits into
mainfrom
mb/events-port
Draft

Mb/events port#218
m-bossart wants to merge 18 commits into
mainfrom
mb/events-port

Conversation

@m-bossart

Copy link
Copy Markdown

Draft of porting events

m-bossart added 18 commits July 30, 2026 15:40
Adds supports_events(::Type{<:PSY.Component}) plus
get_initial_parameter_value/get_parameter_multiplier methods for the
event parameter types, enabling outage-event discovery and defaults.
Add PowerOperationsProblemTemplate.events, set_event_model!/get_event_models
so a template can hold EventModels ahead of build-time distribution to
DeviceModels.
Populate EventModel.attribute_device_map from the system's supplemental
attributes during template validation, validate each event's time-series
mapping, and distribute the event to every DeviceModel whose device type
carries the attribute. Preserve event-model identity across the template
deep copy performed at DecisionModel construction (mirroring the existing
PNM-matrix-sharing trick) so callers can inspect discovery results on the
same EventModel object they attached to the template.

Also fix a name collision from the earlier event-model work: POM's
get_value(::StateVariableValueCondition) was defined without qualifying
IOM.get_value, which created a separate local generic function that
shadowed IOM's get_value(::InitialCondition) for every other unqualified
caller in the package (storage, hybrid, thermal generation, AGC),
silently breaking all initial-conditions-consuming builds.
Two distinct event models of the same contingency type discovering the
same device type can't both be registered under the device model's single
(contingency type, device type) events slot. Replace the silent-skip guard
in _build_device_model_events! with a loud error when the existing
registration belongs to a different event model than the one being
processed; re-discovering the same event model for the same key stays a
no-op. Add a covering test case.

Also reword the _deepcopy_template override comment to describe the
deepcopy-unsafe solver-cache behavior directly instead of citing a PR
number.
Wires DeviceModel.events into the ArgumentConstructStage: add_parameters!
creates AvailableStatusParameter and AvailableStatusChangeCountdownParameter
containers for devices carrying a matching supplemental attribute, and a
generic add_to_expression! offsets those parameters into the system balance
via _balance_expression_targets, replacing PSI's four per-network methods
with one. add_event_arguments! now overrides the no-op stub for
PSY.StaticInjection devices.
Loads (StaticPowerLoad/PowerLoadDispatch/PowerLoadInterruption) and
FixedOutput devices now inject an ActivePowerOffsetParameter (and
ReactivePowerOffsetParameter on reactive-capable networks) directly
into the system balance expression when an event is attached, on top
of the generic status/countdown parameters from the StaticInjection
default.
…vices

Implements add_event_constraints! for ThermalGen/RenewableGen/ElectricLoad
across active-only and reactive-capable networks, bounding dispatch by
available capacity during an outage event and adding a quadratic reactive
power bound on reactive-capable networks.
Ports HydroGen/HydroPumpTurbine/EnergyReservoirStorage add_event_constraints!
methods and their pump/input-output contingency-constraint helpers, plus fixes
a get_variable/add_constraints_container! instance-vs-type bug in the shared
reactive-power contingency helper (never previously exercised by any test).
Covers full-template build+solve across CopperPlate/PTDF/DCP/ACP network
models with a FixedForcedOutage event, the PTDF two-target balance offset
and ACP reactive-offset paths for load events, and a recurrent-solve mock
test confirming a forced outage drives thermal output to zero. Also
strengthens the initial-conditions exclusion test to confirm event
parameters land in the main container while staying absent from the IC
container.
…es style

Aligns the new E2E thermal-outage testset with the naming convention
already established in test_model_decision.jl (both are exported by IOM
and used unqualified there).
The prior testset only checked that ReactivePowerOffsetParameter and
ReactivePowerBalance both exist, which proves nothing about the offset
being wired into the balance (the expression is allocated for every ACP
build regardless of events). Add a recurrent-solve mock testset that
checks JuMP.coefficient of the offset parameter's variable in the balance
expression directly, so the test fails if the wiring is ever removed.
Adds an Outage events subsection covering the availability parameters
and per-device-family outage constraints added when an EventModel is
attached to a template. public.md needs no changes: it registers
symbols via a blanket @autodocs, which already picks up the new
exports.
Record the completed event framework port in pom_port_plan.md
(Workstream C and execution order), and add the SDD plan and design
spec artifacts for the branch.
Add an objective to the forced-outage mock test so it fails when
ActivePowerOutageConstraint is removed, assert the constraint's baked RHS
equals the device's max active power, cover the FixedOutput offset path,
and smoke-test the event condition accessors. Also correct the
ReactivePowerOutageConstraint docstring/docs math to match the
max((Q^max)^2, (Q^min)^2) implementation, and update the stale
"no event framework" claim in .claude/CLAUDE.md.
@github-actions

Copy link
Copy Markdown

Performance Results

Version Precompile Time
Main 3.022500095
This Branch 3.229043638
Version Build Time
Main-Build Time Precompile 87.762624981
Main-Build Time Postcompile 1.323349675
This Branch-Build Time Precompile 88.804868658
This Branch-Build Time Postcompile 1.364484561
Version Solve Time
Main-Solve Time Precompile 409.773728445
Main-Solve Time Postcompile 377.679428644
This Branch-Solve Time Precompile 2096.626809364
This Branch-Solve Time Postcompile 2054.990434248

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant