Skip to content

Commit

Permalink
Merge pull request #1164 from e2nIEE/develop
Browse files Browse the repository at this point in the history
Release pandapower 2.6.0
  • Loading branch information
jkupka authored Mar 9, 2021
2 parents 2fa4427 + 0b86fc1 commit b05826e
Show file tree
Hide file tree
Showing 54 changed files with 4,893 additions and 633 deletions.
32 changes: 17 additions & 15 deletions .github/workflows/github_test_action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.6', '3.5', '3.7', '3.8']
python-version: ['3.6', '3.7', '3.8']

steps:
- uses: actions/checkout@v2
Expand All @@ -31,20 +31,31 @@ jobs:
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install .
pip install matplotlib python-igraph
if ${{ (matrix.python-version == '3.5') || (matrix.python-version == '3.7')}}; then python -m pip install pypower; fi
if ${{ (matrix.python-version != '3.5') && (matrix.python-version != '3.6') }}; then python -m pip install numba; fi
if ${{ matrix.python-version == '3.7' }}; then python -m pip install pypower; fi
if ${{ matrix.python-version != '3.6' }}; then python -m pip install numba; fi
- name: Install Julia
if: ${{ matrix.python-version == '3.6'}}
if: ${{ matrix.python-version == '3.6' }}
run: |
./.install_julia.sh 1.5
pip install julia
python ./.install_pycall.py
python ./.install_pycall.py
- name: List of installed packages
run: |
pip list
- name: Test with pytest
if: ${{ matrix.python-version != '3.8' }}
run: |
pytest
- name: Test with pytest and Codecov
if: ${{ matrix.python-version == '3.8' }}
run: |
pip install pytest-cov
pytest --cov=./ --cov-report=xml
- name: Upload coverage to Codecov
if: ${{ matrix.python-version == '3.8' }}
uses: codecov/codecov-action@v1
with:
verbose: true

relying: # packages that rely on pandapower

Expand Down Expand Up @@ -74,7 +85,7 @@ jobs:
pip list
- name: Test pandapipes
run: |
python -c 'from pandapipes.test.run_tests import run_tests as run_pandapipes_tests; run_pandapipes_tests()'
python -c 'from pandapipes import pp_dir; import pytest; import sys; ec = pytest.main([pp_dir]); sys.exit(ec)'
linting:
# run flake8 and check for errors
Expand Down Expand Up @@ -110,12 +121,3 @@ jobs:
run: |
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Generate coverage report
run: |
pip install pytest
pip install pytest-cov
pytest --cov=./ --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
verbose: true
19 changes: 17 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
Change Log
=============

[2.6.0]- 2021-03-09
----------------------

- [ADDED] Factorization mode instead of inversion of Ybus in short-circuit calculation.
- [ADDED] Optimized the calculation of single/selected buses in 1ph/2ph/3ph short-circuit calculation.
- [ADDED] New options for run_control to 'continue on divergence' and 'check each level' PR #1104.
- [ADDED] Check for necessary and valid parameters to calculate 3ph powerflow.
- [ADDED] Toolbox method get_connecting_branches to determine branches which connect two sets of buses.
- [CHANGED] Deleting set_q_from_cosphi from ConstControl and deprecation warning. Use a separate ConstControl for setting Q timeseries instead.
- [CHANGED] Removed official Python 3.5 support due to end of its life #994.
- [FIXED] matching_params was missing in basic controller.
- [FIXED] Order of latitude and longitude in plotly mapbox plot.
- [FIXED] Dependencies of powerflow result plotting.
- [FIXED] init_ne_line to work with switches and parallel lines. Needed for PowerModels TNEP.

[2.5.0]- 2021-01-08
----------------------
- [ADDED] github actions for tests added.
Expand All @@ -10,7 +25,7 @@ Change Log
- [ADDED] the Powermodels AC OPF can now be used with line loading constraints formulated with respect to the maximum current net.line.max_i_ka by using pp.runpm_ac_opf(net, opf_flow_lim="I").
- [ADDED] for easier debugging of the Powermodels interface, you can now save your .json file and specify the file name by using pp.runpm(net, delete_buffer_file=False, pm_file_path="filename.json".
- [CHANGED] The create-module now contains some functions for standardized checks and procedures in all create functions.
- [CHANGED] all controllers and output writers do not have net as attribute any more. time series functions, .
- [CHANGED] all controllers and output writers do not have net as attribute any more.
- [CHANGED] due to multi net implementations in pandapipes, time series functions have been adapted drastically in order to minimize duplicated code.
- [CHANGED] internal data structure tutorial contains now an example of a spy plot to visualize the admittance matrix Ybus.
- [CHANGED] introduce abstract node/branch formulation for the plotly functions.
Expand Down Expand Up @@ -55,7 +70,7 @@ Change Log
- [ADDED] Encryption for JSON I/O
- [FIXED] Bug in converting measurements of out-of-service branch in state estimation #859
- [FIXED] Bug in using initialization option "results" in state estimation #859
- [CHANGED] In state estimation power flow results will not be renamed anymore
- [CHANGED] In state estimation power flow results will not be renamed anymore
- [ADDED] New feature for defining the number of logging columns for an eval_function of an outputwriter log variable. Example: See log_variable docstring

[2.2.2]- 2020-03-17
Expand Down
4 changes: 2 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
# built documents.
#
# The short X.Y version.
version = "2.5"
version = "2.6"
# The full version, including alpha/beta/rc tags.
release = "2.5.0"
release = "2.6.0"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
8 changes: 4 additions & 4 deletions doc/elements/trafo3w_res.csv
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ ql_mvar;float;reactive power consumption of the transformer [Mvar]
i_hv_ka ;float;current at the high voltage side of the transformer [kA]
i_mv_ka ;float;current at the medium voltage side of the transformer [kA]
i_lv_ka ;float;current at the low voltage side of the transformer [kA]
vm_hv_pu;float;voltage magnitude at the low voltage bus [pu]
vm_hv_pu;float;voltage magnitude at the high voltage bus [pu]
vm_mv_pu;float;voltage magnitude at the medium voltage bus [pu]
vm_lv_pu;float;voltage magnitude at the high voltage bus [pu]
va_hv_degree;float;voltage angle at the low voltage bus [degrees]
vm_lv_pu;float;voltage magnitude at the low voltage bus [pu]
va_hv_degree;float;voltage angle at the high voltage bus [degrees]
va_mv_degree;float;voltage angle at the medium voltage bus [degrees]
va_lv_degree;float;voltage angle at the high voltage bus [degrees]
va_lv_degree;float;voltage angle at the low voltage bus [degrees]
loading_percent;float;transformer utilization [%]
8 changes: 4 additions & 4 deletions doc/elements/trafo_res.csv
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ pl_mw;float;active power losses of the transformer [MW]
ql_mvar;float;reactive power consumption of the transformer [Mvar]
i_hv_ka;float;current at the high voltage side of the transformer [kA]
i_lv_ka;float;current at the low voltage side of the transformer [kA]
vm_hv_pu;float;voltage magnitude at the low voltage bus [pu]
vm_lv_pu;float;voltage magnitude at the high voltage bus [pu]
va_hv_degree;float;voltage angle at the low voltage bus [degrees]
va_lv_degree;float;voltage angle at the high voltage bus [degrees]
vm_hv_pu;float;voltage magnitude at the high voltage bus [pu]
vm_lv_pu;float;voltage magnitude at the low voltage bus [pu]
va_hv_degree;float;voltage angle at the high voltage bus [degrees]
va_lv_degree;float;voltage angle at the low voltage bus [degrees]
loading_percent;float;load utilization relative to rated power [%]
2 changes: 1 addition & 1 deletion pandapower/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "2.5.0"
__version__ = "2.6.0"

import os
pp_dir = os.path.dirname(os.path.realpath(__file__))
Expand Down
6 changes: 4 additions & 2 deletions pandapower/auxiliary.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,8 @@ def _add_opf_options(net, trafo_loading, ac, v_debug=False, **kwargs):


def _add_sc_options(net, fault, case, lv_tol_percent, tk_s, topology, r_fault_ohm,
x_fault_ohm, kappa, ip, ith, branch_results, kappa_method, return_all_currents):
x_fault_ohm, kappa, ip, ith, branch_results, kappa_method, return_all_currents,
inverse_y):
"""
creates dictionary for pf, opf and short circuit calculations from input parameters.
"""
Expand All @@ -594,7 +595,8 @@ def _add_sc_options(net, fault, case, lv_tol_percent, tk_s, topology, r_fault_oh
"ith": ith,
"branch_results": branch_results,
"kappa_method": kappa_method,
"return_all_currents": return_all_currents
"return_all_currents": return_all_currents,
"inverse_y": inverse_y
}
_add_options(net, options)

Expand Down
1 change: 1 addition & 0 deletions pandapower/control/basic_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def __init__(self, net, in_service=True, order=0, level=0, index=None, recycle=F
# add oneself to net, creating the ['controller'] DataFrame, if necessary
if index is None:
index = get_free_id(net.controller)
self.matching_params = dict() if matching_params is None else matching_params
self.index = index
self.add_controller_to_net(net=net, in_service=in_service, initial_run=initial_run, order=order,
level=level, index=index, recycle=recycle,
Expand Down
5 changes: 1 addition & 4 deletions pandapower/control/controller/const_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ConstControl(Controller):

def __init__(self, net, element, variable, element_index, profile_name=None, data_source=None,
scale_factor=1.0, in_service=True, recycle=True, order=0, level=0,
drop_same_existing_ctrl=False, set_q_from_cosphi=False, matching_params=None,
drop_same_existing_ctrl=False, matching_params=None,
initial_run=False, **kwargs):
# just calling init of the parent
if matching_params is None:
Expand All @@ -75,9 +75,6 @@ def __init__(self, net, element, variable, element_index, profile_name=None, dat
self.values = None
self.profile_name = profile_name
self.scale_factor = scale_factor
if set_q_from_cosphi:
logger.error("Parameter set_q_from_cosphi deprecated!")
raise ValueError
self.applied = False
# write functions faster, depending on type of self.element_index
if isinstance(self.element_index, int):
Expand Down
29 changes: 27 additions & 2 deletions pandapower/control/run_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,11 @@ def ctrl_variables_default(net):
ctrl_variables["initial_run"] = check_for_initial_run(
ctrl_variables["controller_order"])
ctrl_variables['continue_on_divergence'] = False
ctrl_variables['check_each_level'] = True
return ctrl_variables


def prepare_run_ctrl(net, ctrl_variables):
def prepare_run_ctrl(net, ctrl_variables, **kwargs):
"""
Prepares run control functions. Internal variables needed:
Expand All @@ -113,9 +114,20 @@ def prepare_run_ctrl(net, ctrl_variables):
"""
# sort controller_order by order if not already done


ctrl_var = ctrl_variables

if ctrl_variables is None:
ctrl_variables = ctrl_variables_default(net)

if ('continue_on_divergence') in kwargs and (ctrl_var is None or 'continue_on_divergence' not in ctrl_var.keys()):
div = kwargs.pop('continue_on_divergence')
ctrl_variables['continue_on_divergence'] = div
if ('check_each_level') in kwargs and (ctrl_var is None or 'continue_on_divergence' not in ctrl_var.keys()):
check = kwargs.pop('check_each_level')
ctrl_variables['check_each_level'] = check

ctrl_variables["errors"] = (LoadflowNotConverged, OPFNotConverged, NetCalculationNotConverged)

return ctrl_variables
Expand Down Expand Up @@ -186,6 +198,8 @@ def _evaluate_net(net, levelorder, ctrl_variables, **kwargs):

def control_implementation(net, controller_order, ctrl_variables, max_iter,
evaluate_net_fct=_evaluate_net, **kwargs):

run_count=0
# run each controller step in given controller order
for levelorder in controller_order:
# converged gives status about convergence of a controller. Is initialized as False
Expand All @@ -201,7 +215,10 @@ def control_implementation(net, controller_order, ctrl_variables, max_iter,
run_count += 1
ctrl_variables = evaluate_net_fct(net, levelorder, ctrl_variables, **kwargs)
# raises controller not converged
check_final_convergence(run_count, max_iter, ctrl_variables['converged'])
if ctrl_variables['check_each_level']:
check_final_convergence(run_count, max_iter, ctrl_variables['converged'])
# is required if you only want to check if in the last level everything is converged
check_final_convergence(run_count, max_iter, ctrl_variables['converged'])


def _control_step(levelorder, run_count):
Expand Down Expand Up @@ -241,6 +258,14 @@ def run_control(net, ctrl_variables=None, max_iter=30, **kwargs):
**ctrl_variables** (dict, None) - variables needed internally to calculate the power flow. See prepare_run_ctrl()
**max_iter** (int, 30) - The maximum number of iterations for controller to converge
KWARGS:
**continue_on_divergence** (bool, False) - if run_funct is not converging control_repair is fired
(only relevant if ctrl_varibales is None, otherwise it needs
to be defined in ctrl_variables anyway)
**check_each_level** (bool, True) - if each level shall be checked if the controllers are converged or not
(only relevant if ctrl_varibales is None, otherwise it needs
to be defined in ctrl_variables anyway)
Runs controller until each one converged or max_iter is hit.
1. Call initialize_control() on each controller
Expand Down
2 changes: 1 addition & 1 deletion pandapower/converter/pypower/to_ppc.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def to_ppc(net, calculate_voltage_angles=False, trafo_model="t", switch_rx_ratio
**switch_rx_ratio** (float, 2) - rx_ratio of bus-bus-switches. If impedance is zero, \
buses connected by a closed bus-bus switch are fused to model an ideal bus. \
Otherwise, they are modelled as branches with resistance defined as z_ohm column in \
switch table and this parameter
switch table and this parameter
**check_connectivity** (bool, True) - Perform an extra connectivity test after the
conversion from pandapower to PYPOWER
Expand Down
13 changes: 6 additions & 7 deletions pandapower/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def create_empty_network(name="", f_hz=50., sn_mva=1, add_stdtypes=True):
('order', "float64"),
('level', dtype(object)),
('initial_run', "bool"),
("recycle", "bool"),
("recycle", dtype(object)),
],
# geodata
"line_geodata": [("coords", dtype(object))],
Expand Down Expand Up @@ -1406,7 +1406,7 @@ def create_gen(net, bus, p_mw, vm_pu=1., sn_mva=nan, name=None, index=None, max_
limit is taken.
- necessary for OPF.
**max_vm_pur** (float, default NaN) - Maximum voltage magnitude. If not set the bus voltage\
**max_vm_pu** (float, default NaN) - Maximum voltage magnitude. If not set the bus voltage\
limit is taken.
- necessary for OPF
Expand Down Expand Up @@ -1531,7 +1531,7 @@ def create_gens(net, buses, p_mw, vm_pu=1., sn_mva=nan, name=None, index=None, m
bus voltage limit is taken.
- necessary for OPF.
**max_vm_pur** (list of float, default NaN) - Maximum voltage magnitude. If not set the bus\
**max_vm_pu** (list of float, default NaN) - Maximum voltage magnitude. If not set the bus\
voltage limit is taken.
- necessary for OPF
Expand Down Expand Up @@ -1796,6 +1796,9 @@ def create_line(net, from_bus, to_bus, length_km, std_type, name=None, index=Non

v.update({param: lineparam[param] for param in ["r_ohm_per_km", "x_ohm_per_km", "c_nf_per_km",
"max_i_ka"]})
if "r0_ohm_per_km" in lineparam:
v.update({param: lineparam[param] for param in ["r0_ohm_per_km", "x0_ohm_per_km", "c0_nf_per_km"]})

v["g_us_per_km"] = lineparam["g_us_per_km"] if "g_us_per_km" in lineparam else 0.

if "type" in lineparam:
Expand Down Expand Up @@ -3342,10 +3345,6 @@ def create_measurement(net, meas_type, element_type, value, std_dev, element, si
4.5 MVar line measurement with 0.1 MVar standard deviation on the "to_bus" side of line 2
create_measurement(net, "q", "line", 2, 4.5, 0.1, "to")
"""
if meas_type in ("p", "q") and element_type == "bus":
logger.warning("Attention! Signing system of P,Q measurement of buses now changed to load "
"reference (match pandapower res_bus pq)!")

if meas_type not in ("v", "p", "q", "i", "va", "ia"):
raise UserWarning("Invalid measurement type ({})".format(meas_type))

Expand Down
8 changes: 4 additions & 4 deletions pandapower/estimation/algorithm/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def initialize(self, eppci: ExtendedPPCI):
self.pp_meas_indices = eppci.pp_meas_indices
self.check_observability(eppci, eppci.z)

def estimate(self, ppci: ExtendedPPCI, **kwargs):
def estimate(self, eppci: ExtendedPPCI, **kwargs):
# Must be implemented individually!!
pass

Expand All @@ -76,7 +76,7 @@ def __init__(self, tolerance, maximum_iterations, logger=std_logger):
self.H = None
self.hx = None

def estimate(self, eppci, **kwargs):
def estimate(self, eppci: ExtendedPPCI, **kwargs):
self.initialize(eppci)
# matrix calculation object
sem = BaseAlgebra(eppci)
Expand Down Expand Up @@ -129,7 +129,7 @@ def estimate(self, eppci, **kwargs):


class WLSZeroInjectionConstraintsAlgorithm(BaseAlgorithm):
def estimate(self, eppci, **kwargs):
def estimate(self, eppci: ExtendedPPCI, **kwargs):
# state vector built from delta, |V| and zero injections
# Find pq bus with zero p,q and shunt admittance
if not np.any(eppci["bus"][:, bus_cols + ZERO_INJ_FLAG]):
Expand Down Expand Up @@ -199,7 +199,7 @@ def estimate(self, eppci, **kwargs):


class IRWLSAlgorithm(BaseAlgorithm):
def estimate(self, eppci, estimator="wls", **kwargs):
def estimate(self, eppci: ExtendedPPCI, estimator="wls", **kwargs):
self.initialize(eppci)

# matrix calculation object
Expand Down
Loading

0 comments on commit b05826e

Please sign in to comment.