Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

case9241 yields weird behavior: rated_u1 == 0, #919

Open
nicow-elia opened this issue Dec 15, 2024 · 8 comments
Open

case9241 yields weird behavior: rated_u1 == 0, #919

nicow-elia opened this issue Dec 15, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@nicow-elia
Copy link

Describe the current behavior

I tried loading the case9241 pegase network - for this I first converted the matpower file using the steps described here to a .mat file and loaded it into pypowsybl. I performed some checks and found multiple problems:

  • AC loadflows don't converge
  • some trafos have 0 pu as the voltage on u1 side.
  • All trafos have the same voltage level on both ends (should be only PSTs?)

Describe the expected behavior

Matpower file loads correctly

Describe the steps

No response

Environment

  • pypowsybl 1.8.1

Relevant Log Output

In the 9241 network, there are 15 transformers who have 0 as one of their voltages:
image

In general there seems to be something fishy with that example:
image
image

Extra Information

case9241pegase.mat.zip

@nicow-elia nicow-elia added the bug Something isn't working label Dec 15, 2024
@jeandemanged
Copy link
Member

Hi @nicow-elia,

Interesting... As you found out, there are issues about PSTs: 15 branches are defined with a non-zero phase-shift (SHIFT column 10) but a zero ratio (RATIO column 9) causing rated_u1 to be 0.0 kV.
This can be "repaired" in MatLab/Octave as follows:

mpc = loadcase('case9241pegase.m');
mpc.branch(mpc.branch(:,10) != 0 & mpc.branch(:,9) == 0, 9) = 1.0
savecase('case9241pegase.mat', mpc);

This will set ratio to 1.0 for branches with a non-zero phase shift and zero ratio.

Then in PyPowSyBl it works:

import pypowsybl as pp
net = pp.network.load('case9241pegase.mat')
t2wt = net.get_2_windings_transformers()
t2wt[t2wt['rated_u1'] == 0]  # Empty DataFrame
pp.loadflow.run_ac(net)
# [ComponentResult(connected_component_num=0, synchronous_component_num=0, status=CONVERGED, status_text=Converged, iteration_count=12, reference_bus_id='VL-4231_0', slack_bus_results=[SlackBusResult(id='VL-4231_0', active_power_mismatch=-0.21574531038126565)], distributed_active_power=-184.18714631784448)]

Let us know if this works for you.

At first glance this looks like a data quality issue (?), although we could do something on powsybl-core MATPOWER importer: either reject or try to repair the file... No strong opinion here, I am not a matpower format expert...

@jeandemanged
Copy link
Member

jeandemanged commented Dec 16, 2024

If my understanding of the matpower code is correct, matpower would rather ignore SHIFT if TAP is zero ...

And this would better replicate matpower behavior:
<del>mpc.branch(mpc.branch(:,10) != 0 & mpc.branch(:,9) == 0, 10) = 0.0 <del>

(converges as well in PyPowSyBl)

edit: my understanding of matpower code was wrong, see further below.

@nicow-elia
Copy link
Author

This indeed fixes the AC convergence problem and the rated_u1 == 0 problem. Now the only problem remaining is the fact that all voltage level ids on both ends of the trafos are the same, but I guess that could also be a problem of this particular test-case.
If you don't repair it, I guess it would be nice to at least warn about these problems somehow so the next person running into the same issues needs less time to debug it.
Thanks for the help!

@geofjamg geofjamg reopened this Dec 17, 2024
@geofjamg
Copy link
Member

geofjamg commented Dec 17, 2024

We have an issue with the way we decide if the Matpower branch is a transformer or a line

    private static boolean isLine(MatpowerModel model, MBranch branch) {
        if (branch.getPhaseShiftAngle() != 0) {
            return false;
        }
        if (branch.getRatio() == 0) {
            return true;
        }
        MBus from = model.getBusByNum(branch.getFrom());
        MBus to = model.getBusByNum(branch.getTo());
        return branch.getRatio() == 1 && from.getBaseVoltage() == to.getBaseVoltage();
    }

    private static boolean isTransformer(MatpowerModel model, MBranch branch) {
        return !isLine(model, branch);
    }

For the mentioned branches, we have a phase shift != 0 but a voltage ratio of 0 and we consider it as a transformer (in IIDM a phase shifter is necessarly a transformer) and put the 0 voltage ratio without any check in the IIDM model.

Thanks @nicow-elia for reporting this issue.

@geofjamg
Copy link
Member

Fixed by powsybl/powsybl-core#3254 in the next release.

@geofjamg
Copy link
Member

geofjamg commented Dec 17, 2024

If my understanding of the matpower code is correct, matpower would rather ignore SHIFT if TAP is zero ...

And this would better replicate matpower behavior:

mpc.branch(mpc.branch(:,10) != 0 & mpc.branch(:,9) == 0, 10) = 0.0

(converges as well in PyPowSyBl)

I fixed using the inverse strategy, often 0 means undefined in matpower, so we can consider a phase shift != 0 and a ratio == 0 to be just a pure phase shifter with a voltage ratio of 1.

@geofjamg
Copy link
Member

geofjamg commented Dec 17, 2024

If my understanding of the matpower code is correct, matpower would rather ignore SHIFT if TAP is zero ...

@jeandemanged, from my understading, it just means that a zero ratio is just set to 1?

tap = ones(nl, 1);                              %% default tap ratio = 1
i = find(branch(:, TAP));                       %% indices of non-zero tap ratios
tap(i) = branch(i, TAP);                        %% assign non-zero tap ratios

@jeandemanged
Copy link
Member

If my understanding of the matpower code is correct, matpower would rather ignore SHIFT if TAP is zero ...

@jeandemanged, from my understading, it just means that a zero ratio is just set to 1?

tap = ones(nl, 1);                              %% default tap ratio = 1
i = find(branch(:, TAP));                       %% indices of non-zero tap ratios
tap(i) = branch(i, TAP);                        %% assign non-zero tap ratios

Sorry indeed i was wrong... I am not so fluent in matlab ...

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants