From 557b603063e9687d5c1a6a0bd8386b2b4cd26a4f Mon Sep 17 00:00:00 2001 From: gplessm Date: Thu, 26 Oct 2017 19:16:05 +0200 Subject: [PATCH] Fix #40 --- edisgo/tools/pypsa_io.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/edisgo/tools/pypsa_io.py b/edisgo/tools/pypsa_io.py index 2acf260c..7b044c81 100644 --- a/edisgo/tools/pypsa_io.py +++ b/edisgo/tools/pypsa_io.py @@ -1072,9 +1072,15 @@ def process_pfa_results(network, pypsa): network.results.pfa_p = p0.where(s0 > s1, p1) * 1e3 network.results.pfa_q = q0.where(s0 > s1, q1) * 1e3 + def voltage_at_lines(row): + return (pypsa.buses_t['v_mag_pu'][row['bus0']] +\ + pypsa.buses_t['v_mag_pu'][row['bus1']]) / 2 + + line_voltage_avg = pypsa.lines.apply(voltage_at_lines, axis=1) + # Get voltage levels at line (avg. of buses at both sides) network.results._i_res = s0[pypsa.lines_t['q0'].columns].truediv( - pypsa.lines['v_nom'], axis='columns') * 1e3 + pypsa.lines['v_nom'] * line_voltage_avg.T, axis='columns') * 1e3 # process results at nodes generators_names = [repr(g) for g in network.mv_grid.graph.nodes_by_attribute('generator')]