Route reactive power and split in/out headroom to power-flow-in-the-loop#185
Draft
acostarelli wants to merge 1 commit into
Draft
Route reactive power and split in/out headroom to power-flow-in-the-loop#185acostarelli wants to merge 1 commit into
acostarelli wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Member
|
@acostarelli we should merge this once the PSY6 branch in PFs is up to date |
|
Performance Results
|
Contributor
There was a problem hiding this comment.
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
templateintoadd_power_flow_data!and add a PF-only time-series parameter injection path so AC PF evaluators can receiveReactivePowerTimeSeriesParameteron PTDF/active-power network models. - Extend PF input mapping to include
:active_power_in/:active_power_outcategories 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
marked this pull request as draft
July 14, 2026 21:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two power-flow-in-the-loop enhancements (
ext/PowerFlowsExt/):templateintoadd_power_flow_data!and add_add_pf_only_time_series_parameters!so an AC power-flow evaluator can receiveReactivePowerTimeSeriesParameterdata even when the optimization formulation (e.g. a DCP/active-power network) never added it. Missing-TS parameter addition is downgraded fromerrorto@info._accumulate_in_out_headroom!handles devices with splitActivePowerInVariable/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