Skip to content

Convert 2W transformer ratings/flows with the system base - #75

Open
luke-kiernan wants to merge 2 commits into
psy6from
lk/transformer-rating-system-base
Open

luke-kiernan wants to merge 2 commits into
psy6from
lk/transformer-rating-system-base

Conversation

@luke-kiernan

@luke-kiernan luke-kiernan commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #74, plus a related AreaInterchange fix in a separate commit.

_make_per_unit! leaves rate_a/rate_b/rate_c/pf/qf in system-base pu, but make_transformer_2w! converted them to natural units with the circuit's winding base (SBASE1-2). That scaled ratings and flows by SBASE1-2 / SBASE. Now they're converted with sys_mbase, as make_line! already does. Impedances and the magnetizing shunt are unchanged, since they really are device-base.

Compatibility

  • No API change. make_transformer_2w! is internal and gains a sys_mbase argument, matching make_line!.
  • Output only changes for a 2W transformer with SBASE1-2 ≠ SBASE (and SBASE1-2 ≠ 0). MATPOWER input and modified_14bus_system.raw are unaffected.
  • The one fixture that does discriminate, synthetic_v35_transformer_discriminators.raw, had tests pinning the old behavior and labeling it "right". They now expect the raw RATE11 MVA: T1 is 40 instead of 20, and T2 is 64 instead of 51.2. Those two transformers already act as the regression case from the issue, so I didn't add a new fixture.
  • This diverges from PSCB's oracle on such cases. Any oracle-parity check there will need that field fixed or excluded.

Second commit: AreaInterchange flow

The same kind of inherited scaling bug. The PSS/E manual defines PTRAN as "MW comprising this transfer", and _make_per_unit! never touches interarea_transfer, so power_transfer is already natural MW. read_area_interchanges! multiplied it by sys_mbase anyway: on a 100 MVA system, 25 MW came out as 2500 MW. The new fixture synthetic_v35_interarea_transfer.raw is the first to contain an actual inter-area transfer record, and its test replaces the one that pinned the inflated value. Output changes for any PSS/E case with a nonzero PTRAN.

🤖 Generated with Claude Code

rate_a/rate_b/rate_c/pf/qf are system-base pu after _make_per_unit!, so
multiplying by the winding base (SBASE1-2) scaled them by SBASE1-2/SBASE.
Use sys_mbase, as make_line! does. Output only changes when
SBASE1-2 != SBASE; the synthetic discriminator test, which had pinned the
old values, now expects the raw RATE11 MVA.

Fixes #74

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

PTRAN is "MW comprising this transfer" per the PSS/E manual, and
_make_per_unit! never touches interarea_transfer, so power_transfer is
already natural MW. Multiplying by sys_mbase (inherited from PSCB) inflated
it 100x on a 100 MVA system. Adds a v35 fixture with a real inter-area
transfer record, since none existed.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@luke-kiernan
luke-kiernan marked this pull request as ready for review October 15, 2026 14:50
@luke-kiernan
luke-kiernan requested review from hannahchubin and jd-lara and a balanced review from Copilot October 15, 2026 16:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The conversions match the parser’s unit conventions, with only an optional regression-coverage improvement remaining.

1 open finding
What changed in this PR

Corrects unit conversions in the OpenAPI reader to address #74 while preserving device-base impedances.

Changes:

  • Converts two-winding transformer ratings and flows using the system base.
  • Preserves inter-area transfers in natural MW.
  • Updates regression expectations and adds an inter-area transfer fixture.
File Description
test/​test_openapi_transformer_discriminators.jl Corrects unequal-base rating expectations.
test/​test_openapi_dc_shunt.jl Tests natural-MW inter-area transfers.
test/​test_openapi_branch.jl Updates transformer assertions and explanatory comments.
test/​fixtures/​synthetic_v35_interarea_transfer.raw Adds a 25 MW transfer case.
src/​openapi/​dc_branch.jl Removes redundant transfer scaling.
src/​openapi/​branch.jl Uses the system base for transformer ratings and flows.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/openapi/branch.jl
Comment on lines +433 to +434
rating_b = _natural_value(rate_b, sys_mbase),
rating_c = _natural_value(rate_c, sys_mbase),
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.

2W transformer rating/rating_b/rating_c/flows scaled by winding base instead of system base when SBASE1-2 ≠ SBASE

2 participants