_make_per_unit! rescales shunt gs/bs (src/pm_io/data.jl:331-341, for both the shunt and switched_shunt sections), so by the time the OpenAPI reader runs, d["gs"]/d["bs"] are already per-unit. The reader then declares them as natural MVAr and divides by base_power a second time:
# src/openapi/shunt.jl:22 (make_fixed_admittance!) and :92 (make_switched_admittance!)
set_value!(component, :Y, (real = d["gs"], imag = d["bs"]), "MVAr")
The load reader handles this correctly by undoing the rescale first (src/openapi/load.jl:45-46):
set_value!(component, :impedance_active_power, d["py"] * base_power, "MW")
The comment block at the top of shunt.jl states that _make_per_unit! never touches these sections, which is what hides the bug on inspection. That is true for facts but not for shunt/switched_shunt.
Reproduction — PowerSystemsTestData psse_raw/case14_ybus.raw, FIXED SHUNT section:
102,'1 ',1, 50.000, -300.000
That's natural units on a 100 MVA base, so the expected stored value is 0.5 - 3.0im pu. Calling the getter with SU on the component in the built PSB system, though, you'll see 0.005 - 0.03im: 100x too small, from the double-rescaling.
This was surfaced downstream by PNM Ybus test failures: the mismatch in certain diagonal elements is exactly accounted for by the above. The switched admittance components aren't included in the ybus, but inspecting the code, they follow the same code path (so they'll exhibit the same bug).
Suggested fix: multiply by base_power on the shunt paths, matching the load reader — :Y in make_fixed_admittance!, and :Y, y_increment, and admittance_limits in make_switched_admittance! (all three go through the same rescale at data.jl:339-341). The shunt.jl header comment should be corrected in the same change.
Observed on branch psy6 (PowerFlowFileParser v0.2.0).
_make_per_unit!rescales shuntgs/bs(src/pm_io/data.jl:331-341, for both theshuntandswitched_shuntsections), so by the time the OpenAPI reader runs,d["gs"]/d["bs"]are already per-unit. The reader then declares them as natural MVAr and divides bybase_powera second time:The load reader handles this correctly by undoing the rescale first (
src/openapi/load.jl:45-46):The comment block at the top of
shunt.jlstates that_make_per_unit!never touches these sections, which is what hides the bug on inspection. That is true forfactsbut not forshunt/switched_shunt.Reproduction —
PowerSystemsTestDatapsse_raw/case14_ybus.raw,FIXED SHUNTsection:That's natural units on a 100 MVA base, so the expected stored value is
0.5 - 3.0impu. Calling the getter with SU on the component in the built PSB system, though, you'll see0.005 - 0.03im: 100x too small, from the double-rescaling.This was surfaced downstream by PNM Ybus test failures: the mismatch in certain diagonal elements is exactly accounted for by the above. The switched admittance components aren't included in the ybus, but inspecting the code, they follow the same code path (so they'll exhibit the same bug).
Suggested fix: multiply by
base_poweron the shunt paths, matching the load reader —:Yinmake_fixed_admittance!, and:Y,y_increment, andadmittance_limitsinmake_switched_admittance!(all three go through the same rescale atdata.jl:339-341). Theshunt.jlheader comment should be corrected in the same change.Observed on branch
psy6(PowerFlowFileParser v0.2.0).