Skip to content

runpm_ac_opf() does not converge when angle shift over transformer is < -60° or > 60° #3108

Description

@kornerc

Bug report checklist

  • Searched the issues page for similar reports

  • Read the relevant sections of the documentation

  • Browse the tutorials and tests for usefull code snippets and examples of use

  • Reproduced the issue after updating with pip install --upgrade pandapower (or git pull)

  • Tried basic troubleshooting (if a bug/error) like restarting the interpreter and checking the pythonpath

Issue Description and Traceback

When the absolute value of an angle shift over a transformer is greater to 60 degree, the OPF does not converge when running runpm_ac_opf().

This might be caused by the hardcoded angle check of 60 degrees in the function get_branch_angles in the file to_pm when the parameter correct_pm_network_data is True.


Expected Behavior

OPF converges

Reproducible Example

import pandapower as pp


def create_net() -> pp.pandapowerNet:
    min_vm_pu = 0.9
    max_vm_pu = 1.1
    max_loading_percent = 80.0

    net = pp.create_empty_network()
    b1 = pp.create_bus(net, vn_kv=110., min_vm_pu=min_vm_pu, max_vm_pu=max_vm_pu)
    b2 = pp.create_bus(net, vn_kv=20., min_vm_pu=min_vm_pu, max_vm_pu=max_vm_pu)
    pp.create_transformer(net, hv_bus=b1, lv_bus=b2, std_type="25 MVA 110/20 kV", max_loading_percent=max_loading_percent)
    pp.create_ext_grid(net, bus=b1)
    load = pp.create_load(net, bus=b2, p_mw=1.0, min_p_mw=1.0, max_p_mw=1.0, min_q_mvar=0.0, max_q_mvar=0.0, controllable=True)
    pp.create_poly_cost(net, element=load, et="load", cp1_eur_per_mw=1.0)

    return net

def main():
    net = create_net()

    original_shift_degree = net.trafo.iloc[0]["shift_degree"]
    net.trafo["shift_degree"] = 60.0

    results = []

    for shift_degree in (59.0, 60.0, 61.0, original_shift_degree, -59.0, -60.0, -61.0, -original_shift_degree):

        net.trafo["shift_degree"] = shift_degree

        try:
            pp.runpm_ac_opf(net, opf_flow_lim="I")
            converged = True
        except pp.OPFNotConverged:
            converged = False

        pp.runpp(net)

        results.append((shift_degree, converged, net.res_trafo.at[0, "va_lv_degree"].item()))

        

    for shift_degree, converged, angle in results:
        print(f"shift_degree: {shift_degree} | voltage_angle: {angle:.1f} -> converged: {converged}")

if __name__ == "__main__":
    main()

Output:

shift_degree: 59.0 | voltage_angle: -59.3 -> converged: True
shift_degree: 60.0 | voltage_angle: -60.3 -> converged: False
shift_degree: 61.0 | voltage_angle: -61.3 -> converged: False
shift_degree: 150.0 | voltage_angle: -150.3 -> converged: False
shift_degree: -59.0 | voltage_angle: 58.7 -> converged: True
shift_degree: -60.0 | voltage_angle: 59.7 -> converged: True
shift_degree: -61.0 | voltage_angle: 60.7 -> converged: False
shift_degree: -150.0 | voltage_angle: 149.7 -> converged: False

Installed Versions

  • Operating System name/version: Windows 11
  • pandapower version: 3.5.3
  • python version: 3.13.5
  • pandas version: 2.3.3
  • numpy version: 2.3.5

Label

  • Relevant labels are selected

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions