diff --git a/examples/quickstart/run_nv_powerflow.log b/examples/quickstart/run_nv_powerflow.log index b7760e2d7277aefc793a899f4cd4d15df685bd6d..52b72fccf088f7896737d8837b6ec8cd43b2d568 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 bd332b8cb93eb4a0bd705f8284e0c3bfe85aa6ee..0257489d7fbf02a32f876936e3fa4d4087e017c9 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 2e47f7e4a1033c06799e965aa500c4c020be8048..a10a881d0a4bb5ab88cd2896136bc27d2e598d94 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 32255cc3e75041c957dd8735f6e0ad82dbd5a58a..592de3055f51bfec15b50295d0033c6e02c8aa30 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 cdf4c106f4c7eba212d25afd40f37761ba7c5d4e..d8d2c217a69f73aa9564a8421b582dbd18ae7466 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