Skip to content

[bug] pp.create.create_transformers value initialization not working #2886

@garctaedius

Description

@garctaedius

Bug report checklis

  • 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

Reproducible Example

from pandapower.create import (
    create_bus,
    create_empty_network,
    create_transformer,
    create_transformers
)

#create empty net
net = create_empty_network()

#create buses
bus1 = create_bus(net, vn_kv=20., name="Bus 1")
bus2 = create_bus(net, vn_kv=10., name="Bus 2")
bus3 = create_bus(net, vn_kv=5., name="Bus 3")
bus4 = create_bus(net, vn_kv=1., name="Bus 4")
bus5 = create_bus(net, vn_kv=0.4, name="Bus 5")

#create transformers individually
trafo1 = create_transformer(net,
                            hv_bus=bus1,
                            lv_bus=bus2,
                            std_type="0.4 MVA 20/0.4 kV",
                            name="Trafo 1")
trafo2 = create_transformer(net,
                            hv_bus=bus2,
                            lv_bus=bus3,
                            std_type="0.4 MVA 20/0.4 kV",
                            name="Trafo 2")

#create transformers by batch
trafo3, trafo4 = create_transformers(net,
                                     hv_buses=[bus3, bus4],
                                     lv_buses=[bus4, bus5],
                                     std_type="0.4 MVA 20/0.4 kV",
                                     name=["Trafo 3", "Trafo 4"])

Issue Description and Traceback

pp.create.create_transformers does not properly initialize transformers. Some fields are left uninitialized, causing the transformers to behave unexpectedly. Specifically, the following fields produce different results with the two different functions.

  • shift_degree
  • tap_side
  • tap_neutral
  • tap_min
  • tap_max
  • tap_step_percent
  • tap_step_degree
  • tap_pos
  • tap_changer_type

This is the current behavior of the above code:

>>> net.trafo[["name",
...            "shift_degree",
...            "tap_side",
...            "tap_neutral",
...            "tap_min",
...            "tap_max",
...            "tap_step_percent",
...            "tap_step_degree",
...            "tap_pos",
...            "tap_changer_type"]]
...
      name  shift_degree tap_side  tap_neutral  tap_min  tap_max tap_step_percent  tap_step_degree  tap_pos tap_changer_type
0  Trafo 1         150.0       hv          0.0     -2.0      2.0              2.5              0.0      0.0            Ratio
1  Trafo 2         150.0       hv          0.0     -2.0      2.0              2.5              0.0      0.0            Ratio
2  Trafo 3           0.0      NaN          NaN      NaN      NaN              NaN              NaN      NaN              NaN
3  Trafo 4           0.0      NaN          NaN      NaN      NaN              NaN              NaN      NaN              NaN


Expected Behavior

Transformers created using pp.create.create_transformers should be initialized in the same way transformers created by pp.create.create_transformers are.

Installed Versions

  • python version: 3.13.3
  • pandas version: 2.3.3
  • networkx version: 3.6.1
  • scipy version: 1.16.3
  • numpy version: 2.3.5
  • packaging version: 25.0
  • tqdm version: 4.67.3
  • deepdiff version: 8.6.1
  • Operating System name/version: Ubuntu 24.04.3 LTS

Label

  • Relevant labels are selected

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions