From e103bfda0de04107d5e8621b30a522354e2c3c4c Mon Sep 17 00:00:00 2001 From: Roman Bolgaryn Date: Fri, 29 Dec 2023 10:55:25 +0100 Subject: [PATCH] add some safegueards for numerical issues in TDPF --- CHANGELOG.rst | 1 + pandapower/pf/create_jacobian_tdpf.py | 2 +- pandapower/pypower/newtonpf.py | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b22224b5b..bff6a3fe0 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -39,6 +39,7 @@ Change Log - [CHANGED] cim2pp: extracted getting default classes, added generic setting datatypes from CGMES XMI schema - [ADDED] function :code:`getOTDF` to obtain Outage Transfer Distribution Factors, that can be used to analyse outages using the DC approximation of the power system - [ADDED] function :code:`outage_results_OTDF` to obtain the matrix of results for all outage scenarios, with rows as outage scenarios and columns as branch power flows in that scenario +- [FIXED] add some safeguards for TDPF to avoid numerical issues in some cases [2.13.1] - 2023-05-12 diff --git a/pandapower/pf/create_jacobian_tdpf.py b/pandapower/pf/create_jacobian_tdpf.py index efae27ed6..b89eeb010 100644 --- a/pandapower/pf/create_jacobian_tdpf.py +++ b/pandapower/pf/create_jacobian_tdpf.py @@ -115,7 +115,7 @@ def calc_r_theta(t_air_pu, a0, a1, a2, i_square_pu, p_loss_pu): 2019, pp. 1-6, doi: 10.1109/EEEIC.2019.8783234. """ t_rise_pu = a0 + a1 * i_square_pu + a2 * np.square(i_square_pu) - t_air_pu - r_theta_pu = t_rise_pu / p_loss_pu + r_theta_pu = t_rise_pu / np.where(p_loss_pu == 0, 1e-6, p_loss_pu) return r_theta_pu diff --git a/pandapower/pypower/newtonpf.py b/pandapower/pypower/newtonpf.py index a0f836fbf..a2bddb8a2 100644 --- a/pandapower/pypower/newtonpf.py +++ b/pandapower/pypower/newtonpf.py @@ -298,7 +298,8 @@ def newtonpf(Ybus, Sbus, V0, ref, pv, pq, ppci, options, makeYbus=None): if tdpf: # update the R, g, b for the tdpf_lines, and the Y-matrices - branch[tdpf_lines, BR_R] = r = r_ref_pu * (1 + alpha_pu * (T - t_ref_pu)) + # here: limit the change of the R to reflect a realistic range of values for T to avoid numerical issues + branch[tdpf_lines, BR_R] = r = r_ref_pu * (1 + alpha_pu * np.clip(np.nan_to_num(T - t_ref_pu), -50, 250 / T_base)) # todo expansion with SSC and VSC (that are not controllable) Ybus, Yf, Yt = makeYbus(baseMVA, bus, branch) g, b = calc_g_b(r, x)