Repository navigation
Fix renewable reactive power: FixedOutput Q = P and constant-pf sin/tan - #408
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The focused fixes match the reported defects and include targeted regression coverage; tests were not executed.
No open issues 🎉
What changed in this PR
Corrects renewable reactive-power calculations in AC models, addressing issue #381. Thermal and hydro behavior remains unchanged.
Changes:
- Scales renewable
FixedOutputreactive multipliers bytan(acos(pf)). - Corrects the constant-power-factor equation and clarifies its ratio variable.
- Adds regression tests for both corrections at power factor 0.8.
| File | Description |
|---|---|
test/test_device_renewable_generation_constructors.jl |
Tests reactive multipliers and constraint coefficients. |
src/static_injector_models/renewable_generation.jl |
Corrects both renewable reactive-power calculations. |
Review effort: Balanced
|
Performance Results
|
|
Reverted to draft momentarily while I figure out how to make all 3 of the below happen at once:
edit: oh, a further oddity. If you have a reactive power time series that's attached to some devices but not all, then the ones with the time series get treatment 2 above, but the rest get Q = 0, when you'd expect them to get treatment 1. This just seems like a side effect of device model being specified per component type, though. edit: back to ready for review. I decided just to open a stacked PR |
|
Reviewed and ran it merged onto current main: the renewable, load and power-flow-in-the-loop test files all pass (1749/1749). The red CI is the FD-vs-NR tolerance failure that #412 fixed, so merging main should turn it green. One request: guard against `power_factor == 0`. |
rodrigomha
left a comment
There was a problem hiding this comment.
See above about pf = 0
The reactive time-series parameter reads the max_active_power series and used the same max_active_power multiplier as the active parameter, so every FixedOutput renewable injected Q = P. Scale the reactive multiplier by Q/P = tan(acos(power_factor)). Part of #381. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A constant power factor fixes q = p * tan(acos(pf)); the constraint used sin(acos(pf)), giving q/p = 0.6 instead of 0.75 at pf = 0.8. Rename the local to q_to_p since it is a ratio, not a power factor. Part of #381. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
tan(acos(0)) is about 1.6e16, so a pf = 0 renewable got a huge reactive multiplier (FixedOutput) or constraint coefficient (RenewableConstantPowerFactor). Both now throw a ConflictingInputsError naming the device. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
a6918e7 to
f5dbee8
Compare
rodrigomha
left a comment
There was a problem hiding this comment.
Approving. The pf = 0 guard covers both the FixedOutput multiplier and RenewableConstantPowerFactor, with a test for each. At f5dbee8, the renewable, load and power-flow-in-the-loop test files pass locally (1751/1751), and the formatter is clean.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
This is finished and good to merge from my perspective--just I don't have permissions to do so |
Fixes #381.
FixedOutputrenewables: scale the reactive parameter multiplier bytan(acos(pf)).RenewableConstantPowerFactor:q = p · tan(acos(pf)), notsin.Thermal/hydro
FixedOutputhave the same Q = P default but nopower_factorfield, so they are left for a follow-up.🤖 Generated with Claude Code