Tests and Validation

Unit Tests

Test Suite

pandapower is tested with pytest. There are currently over 220 tests testing all kinds of pandapower functionality. The tests also include automatic validation of pandapower results from power flow or short circuit calculations against commercial software, to ensure that the implementation is correct.

The complete test suite can be run with:

import pandapower.test
pandapower.test.run_all_tests()

If all packages are installed correctly, all tests should pass.

Continous Integration Testing

The tests are continously carried out with Travis CI in Python 2.7, 3.4, 3.5 and 3.6:

https://travis-ci.org/lthurner/pandapower.svg?branch=develop https://img.shields.io/pypi/pyversions/pandapower.svg

The test coverage rate is checked with codecov, code quality with codacy:

https://codecov.io/github/lthurner/pandapower/coverage.svg?branch=develop https://api.codacy.com/project/badge/Grade/5d749ed6772e47f6b84fb9afb83903d3

Model and Loadflow Validation

To ensure that pandapower loadflow results are correct, all pandapower element behaviour is tested against DIgSILENT PowerFactory or PSS Sincal.

There is a result test for each of the pandapower elements that checks loadflow results in pandapower against results from a commercial tools. The results are compared with the following tolerances:

Parameter Max. Deviation
Voltage Magnitude 0.000001 pu
Voltage Angle 0.01 \(^\circ\)
Current 0.000001 kA
Power 0.005 kW
Element Loading 0.001%

Example: Transformer Model Validation

To validate the pandapower transformer model, a transformer is created with the same parameters in pandapower and PowerFactory. To test all aspects of the model we use a transformer with

  • both iron and copper losses > 0
  • nominal voltages that deviate from the nominal bus voltages at both sides
  • an active tap changer
  • a voltage angle shift > 0

We use a transformer with the following parameters:

  • vsc_percent= 5.0
  • vscr_percent = 2.0
  • i0_percent = 0.4
  • pfe_kw = 2.0
  • sn_kva = 400
  • vn_hv_kv = 22
  • vn_lv_kv = 0.42
  • tp_max = 10
  • tp_mid = 5
  • tp_min = 0
  • tp_st_percent = 1.25
  • tp_side = “hv”
  • tp_pos = 3
  • shift_degree = 150

To validate the in_service parameter as well as the transformer switch element, we create three transformers in parallel: one in service, on out of service and one with an open switch in open loop operation. All three transformers are connected to a 20kV / 0.4 kV bus network. The test network then looks like this:

../_images/test_trafo.png

The loadflow result for the exact same network are now compared in pandapower and PowerFactory. It can be seen that both bus voltages:

../_images/validation_bus.png

and transformer results:

../_images/validation_trafo.png

match within the margins defined above.

All Test Networks

There is a test network for the validation of each pandapower element in the same way the transformer model is tested.

The PowerFactory file containing all test networks can be downloaded here. The correlating pandapower networks are defined in result_test_network_generatory.py in the pandapower/test module. The tests that check pandapower results against PowerFactory results are located in pandapower/test/test_results.py.

line

../_images/test_line.png

load and sgen

../_images/test_load_sgen.PNG

trafo

../_images/test_trafo.png

trafo3w

../_images/test_trafo3w.PNG

ext_grid

../_images/test_ext_grid.PNG

shunt

../_images/test_shunt.PNG

gen

../_images/test_gen.PNG

impedance

../_images/test_impedance.PNG

ward

../_images/test_ward.png

xward

../_images/test_xward.PNG

switch

../_images/test_bus_bus_switch.PNG