From 29f5fc46afb41dcb758a246be6d2febf45698bb6 Mon Sep 17 00:00:00 2001 From: Taeyoung Kim <taeyoung.kim@eonerc.rwth-aachen.de> Date: Wed, 30 Apr 2025 17:36:08 +0000 Subject: [PATCH] somehow powrflow values are not met Signed-off-by: Taeyoung Kim <taeyoung.kim@eonerc.rwth-aachen.de> --- examples/quickstart/run_nv_powerflow.log | 2 +- examples/quickstart/run_nv_powerflow.py | 6 +++++- pyvolt/export.py | 4 ++-- pyvolt/network.py | 20 ++++++++++++++++++-- run_nv_powerflow.log | 2 +- 5 files changed, 27 insertions(+), 7 deletions(-) diff --git a/examples/quickstart/run_nv_powerflow.log b/examples/quickstart/run_nv_powerflow.log index b7760e2..52b72fc 100644 --- a/examples/quickstart/run_nv_powerflow.log +++ b/examples/quickstart/run_nv_powerflow.log @@ -76,7 +76,7 @@ INFO:cimpy.cimimport:CIM object Line created : 11 times INFO:cimpy.cimimport:CIM object SubGeographicalRegion created : 2 times INFO:cimpy.cimimport:CIM object BusbarSection created : 13 times INFO:cimpy.cimimport:CIM object TopologicalIsland created : 2 times -INFO:cimpy.cimimport:Created totally 275 CIM objects in 0.0252532958984375s +INFO:cimpy.cimimport:Created totally 275 CIM objects in 0.02504444122314453s WARNING:pandapower.auxiliary:numba cannot be imported and numba functions are disabled. diff --git a/examples/quickstart/run_nv_powerflow.py b/examples/quickstart/run_nv_powerflow.py index bd332b8..0257489 100644 --- a/examples/quickstart/run_nv_powerflow.py +++ b/examples/quickstart/run_nv_powerflow.py @@ -2,7 +2,7 @@ import logging from pathlib import Path from pyvolt import network from pyvolt import nv_powerflow -import numpy +import numpy as np import cimpy import os from pyvolt import export @@ -64,11 +64,15 @@ ccc = aaa.convertDFtoPP(dataframe = q) print("Powerflow converged in " + str(num_iter) + " iterations.\n") print("Results: \n") voltages = [] +powers=[] for node in results_pf.nodes: print('{}={}'.format(node.topology_node.type, node.voltage_pu)) # print('{}={}'.format(node.topology_node.type, node.power_pu)) #print('{}={}'.format(node.topology_node.uuid, node.voltage)) voltages.append(node.voltage_pu) + powers.append(node.power_pu) + +vol = np.abs(voltages) # voltages_ref = [(1-7.970485900477431e-27j), (0.9521818868802214-0.11692768153747995j), # (0.9642955926931457-0.09862127081290231j), (0.8796973782245792-0.15318580971335868j), diff --git a/pyvolt/export.py b/pyvolt/export.py index 2e47f7e..a10a881 100644 --- a/pyvolt/export.py +++ b/pyvolt/export.py @@ -289,7 +289,7 @@ class CIMtoDataFrame(Exporter): def get_branch_capacitance(self, frequency=50): sys = self.system - y_mat = sys.Ymatrix + y_mat = sys.Ymatrix_real w = 2 * np.pi * frequency cap = {} @@ -597,7 +597,7 @@ class PandapowerWork(Exporter): length_km= 1, r_ohm_per_km= branch['r'], x_ohm_per_km=branch['x'], - c_nf_per_km= capacity*(10**6), + c_nf_per_km= branch['c']*(1e6), name= lcl_name, max_i_ka = branch['base_current']) diff --git a/pyvolt/network.py b/pyvolt/network.py index 32255cc..592de30 100644 --- a/pyvolt/network.py +++ b/pyvolt/network.py @@ -99,6 +99,8 @@ class System(): self.breakers = [] self.Ymatrix = np.zeros([], dtype=complex) self.Bmatrix = np.zeros([], dtype=complex) + self.Ymatrix_real = np.zeros([], dtype=complex) + self.Bmatrix_real = np.zeros([], dtype=complex) def get_node_by_uuid(self, node_uuid): for node in self.nodes: @@ -251,6 +253,7 @@ class System(): #calculate admitance matrix self.Ymatrix_calc() + self.Ymatrix_calc_real() def _get_nodes(self, list_Terminals, elem_uuid): """ @@ -355,6 +358,19 @@ class System(): self.Ymatrix[to][fr] -= branch.y_pu self.Ymatrix[fr][fr] += branch.y_pu self.Ymatrix[to][to] += branch.y_pu + + def Ymatrix_calc_real(self): + self.reindex_nodes_list() + nodes_num = self.get_nodes_num() + self.Ymatrix_real = np.zeros((nodes_num, nodes_num), dtype=complex) + self.Bmatrix_real = np.zeros((nodes_num, nodes_num), dtype=complex) + for branch in self.branches: + fr = branch.start_node.index + to = branch.end_node.index + self.Ymatrix_real[fr][to] -= branch.y + self.Ymatrix_real[to][fr] -= branch.y + self.Ymatrix_real[fr][fr] += branch.y + self.Ymatrix_real[to][to] += branch.y #testing functions def print_nodes_names(self): @@ -384,10 +400,10 @@ class System(): # endNode= branch.end_node print('from bus {} to bus {}'.format(branch.start_node.index, branch.end_node.index)) print('---------------------------------------------------------') - + def print_breaker_names(self): for breaker in self.breakers: - print('{} {}'.format(breaker.name, breaker.index)) + print('{} {}'.format(breaker.name, breaker.index)) def load_from_m_file(self, file_path): """ diff --git a/run_nv_powerflow.log b/run_nv_powerflow.log index cdf4c10..d8d2c21 100644 --- a/run_nv_powerflow.log +++ b/run_nv_powerflow.log @@ -76,6 +76,6 @@ INFO:cimpy.cimimport:CIM object Line created : 11 times INFO:cimpy.cimimport:CIM object SubGeographicalRegion created : 2 times INFO:cimpy.cimimport:CIM object BusbarSection created : 13 times INFO:cimpy.cimimport:CIM object TopologicalIsland created : 2 times -INFO:cimpy.cimimport:Created totally 275 CIM objects in 0.03760051727294922s +INFO:cimpy.cimimport:Created totally 275 CIM objects in 0.04641366004943848s -- GitLab