Skip to content

Keep each 3W winding's ratings instead of their minimum - #91

Open
luke-kiernan wants to merge 3 commits into
psy6from
lk/3w-ratings
Open

luke-kiernan wants to merge 3 commits into
psy6from
lk/3w-ratings

Conversation

@luke-kiernan

@luke-kiernan luke-kiernan commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A three-winding transformer's winding rating was min(RATA, RATB, RATC). Zero means "no limit" in PSS/E, so one unset rating made the minimum 0, which the output then read as unbounded. In frankenstein_70.raw, the file gives 336, 268 and 84 MVA with RATC = 0, and all three windings came out as 1e6 MVA.

Each winding now keeps its own ratings, as a two-winding transformer does: rating A is rating, and nonzero B and C are rating_b and rating_c. v35's RATEn1-RATEn3 follow the same mapping.

Output changes

  • Windings with an unset B or C rating keep their real limit.
  • A winding whose lowest rating wasn't A now reports A, matching two-winding transformers.
  • 3W circuits now write rating_b and rating_c, which were always unset.
  • The 3W "rating" key is gone from the PowerModels dict; nothing read it.
  • v35 3W ratings 4-12 are now kept in ext, as they are for lines and 2W transformers.

Writing unset ratings the same way across the parsers is left to #94.

Testing

  • New test covers the legacy and v35 rating layouts, plus the output for frankenstein_70.raw. It fails without the fix.
  • Full suite passes locally (3485/3485).

🤖 Generated with Claude Code

A winding's rating was min(RATA, RATB, RATC), but zero means no limit, so
one unset rating turned the winding unbounded and lost its real limits.
Map each winding's ratings to rating, rating_b and rating_c, as a 2W
transformer does. Drop the 3W "rating" key, which nothing read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@luke-kiernan
luke-kiernan requested a balanced review from Copilot November 6, 2026 00:23
@luke-kiernan luke-kiernan self-assigned this Nov 6, 2026
@luke-kiernan
luke-kiernan requested review from jd-lara and m-bossart and removed request for jd-lara November 6, 2026 00:23

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.

🟡 Changes recommended

The output regression checks only :rating, leaving B/C output omissions undetected; it needs assertions for each winding’s B/C values and for zero source ratings remaining unset.

1 open issue
What changed in this PR

This PR preserves each three-winding transformer's A/B/C ratings instead of taking their minimum, preventing unset B or C ratings from erasing valid A limits.

Changes:

  • Maps legacy and v35 winding ratings individually and removes the unused aggregate rating.
  • Exports per-winding B/C ratings to OpenAPI circuits.
  • Adds parsing regressions and an output check for the previously unbounded winding limits.
File Description
test/​test_parse_transformers.jl Tests legacy/v35 rating mappings and finite output limits.
src/​pm_io/​psse.jl Preserves individual winding ratings, omitting zero B/C values.
src/​openapi/​branch.jl Exports winding B/C ratings and updates the units comment.

Review effort: Balanced

Comment thread src/openapi/branch.jl
Comment on lines +544 to +545
rating_b = _get_rating(name, d, "rating_b_primary"),
rating_c = _get_rating(name, d, "rating_c_primary"),
The output test only checked rating, so dropping rating_b or rating_c
would have passed. Compare all three ratings on each winding's own
circuit, including a case where every rating is distinct.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread src/pm_io/psse.jl
sub_data["rating_secondary"],
sub_data["rating_tertiary"],
)
rating_keys = i -> ("RATE$(i)1", "RATE$(i)2", "RATE$(i)3")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

For Lines and TwoWinding Transformers we add ratings 4-12 into the ext if the source version is PSSE_TWELVE_RATING_VERSIONS. We should probably match that here for 3wT

Comment thread src/pm_io/psse.jl Outdated
"Unsupported PSS(R)E source version: $(pm_data["source_version"])",
)
end
# A zero rating means no limit, so it must not win over the ones that are

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This comment references the old code bug. It should describe the corrected code only

@m-bossart

Copy link
Copy Markdown

Suggestion: Write unset (zero) ratings the same way everywhere the dict is built, by never writing the key, through one helper used by the line, 2W, 3W and MATPOWER parsers. _get_rating then only needs to treat a missing key as unbounded, and its zero-value fallback can be removed. The code today is correct, just not very clean

Lines and 2W transformers keep these in twelve-rating versions, but 3W
transformers dropped them. Also rewrite the rating comment to describe
the code as it is now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@luke-kiernan

Copy link
Copy Markdown
Contributor Author

@m-bossart thanks for the review. Addressed in 9db60ea:

  • 3W ratings 4-12 now go into ext, matching lines and 2W transformers.
  • Rewrote the rating comment to describe the current code.

I left the suggestion about writing unset ratings the same way everywhere for #94, since it reaches beyond this PR.

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.

3 participants