Skip to content

Route reactive power and split in/out headroom to power-flow-in-the-loop#185

Draft
acostarelli wants to merge 1 commit into
mainfrom
ac/power-flow-in-the-loop
Draft

Route reactive power and split in/out headroom to power-flow-in-the-loop#185
acostarelli wants to merge 1 commit into
mainfrom
ac/power-flow-in-the-loop

Conversation

@acostarelli

Copy link
Copy Markdown
Member

Two power-flow-in-the-loop enhancements (ext/PowerFlowsExt/):

  • Reactive power on active-power-only networks — thread the template into add_power_flow_data! and add _add_pf_only_time_series_parameters! so an AC power-flow evaluator can receive ReactivePowerTimeSeriesParameter data even when the optimization formulation (e.g. a DCP/active-power network) never added it. Missing-TS parameter addition is downgraded from error to @info.
  • Split in/out headroom_accumulate_in_out_headroom! handles devices with split ActivePowerInVariable/ActivePowerOutVariable (Storage BookKeeping, Source ImportExport): headroom = p_max_out − (out − in), contributing only when net > 0.

New test coverage: test/test_power_flow_in_the_loop.jl.

Ported from PSI


Part of splitting the former #154 into focused PRs.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jd-lara

jd-lara commented Jul 14, 2026

Copy link
Copy Markdown
Member

@acostarelli we should merge this once the PSY6 branch in PFs is up to date

@github-actions

Copy link
Copy Markdown

Performance Results

Version Precompile Time
Main 2.562840331
This Branch 2.688894162
Version Build Time
Main-Build Time Precompile 62.95690258
Main-Build Time Postcompile 1.317269418
This Branch-Build Time Precompile 72.305518814
This Branch-Build Time Postcompile 1.400219364
Version Solve Time
Main-Solve Time Precompile 341.54274716
Main-Solve Time Postcompile 346.130247636
This Branch-Solve Time Precompile 1890.484335569
This Branch-Solve Time Postcompile 1743.240737549

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the “power-flow-in-the-loop” integration in ext/PowerFlowsExt/ by (1) supporting split in/out active-power variables in PF input routing and headroom-proportional slack, and (2) ensuring reactive-power time series can be routed into AC power-flow evaluators even when the optimization network formulation is active-power-only.

Changes:

  • Thread template into add_power_flow_data! and add a PF-only time-series parameter injection path so AC PF evaluators can receive ReactivePowerTimeSeriesParameter on PTDF/active-power network models.
  • Extend PF input mapping to include :active_power_in / :active_power_out categories and update headroom slack computation to handle split in/out devices via net (out − in).
  • Add targeted regression tests for split in/out routing/headroom and reactive-power routing on PTDF networks.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/test_power_flow_in_the_loop.jl Adds regression tests for split in/out injection routing and reactive-power TS routing into AC PF on PTDF networks.
src/operation/build_problem.jl Passes template into add_power_flow_data! so PF initialization can optionally add PF-only TS parameters.
src/core/interfaces.jl Extends the add_power_flow_data! interface with an optional template argument for the extension pathway.
src/common_models/add_parameters.jl Changes time-series-parameter addition behavior when no devices have the series (error → @info + return).
ext/PowerFlowsExt/pf_input_mapping.jl Adds in/out categories to PF input mapping; adds _add_pf_only_time_series_parameters! and tracks needed input categories across evaluators.
ext/PowerFlowsExt/pf_headroom.jl Implements headroom accumulation for devices with split in/out active-power variables and integrates it into slack participation recomputation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 206 to 209
if isempty(device_names)
error(
"No devices with time series $ts_name found for $D devices. Check DeviceModel time_series_names field.",
)
@info "No devices with time series $ts_name found for $D devices. Skipping parameter addition."
return
end
Comment on lines +122 to +124
`net = p_out - p_in` is the device's signed contribution at time `t`. With net > 0 the
device is dispatching and its headroom is `p_max_out - net`; with net <= 0 the device is
charging (or idle) and contributes no upward slack.
Comment on lines +187 to +188
# Net <= 0 means charging or idle — per spec, no upward slack contribution.
net < 0.0 && continue
@jd-lara
jd-lara marked this pull request as draft July 14, 2026 21:14
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.

4 participants