Skip to content
Snippets Groups Projects
Commit 3cc13ac5 authored by Taeyoung Kim's avatar Taeyoung Kim
Browse files

adding all-in-one function that make one dictionary holds all information of the grid(so far)

parent aac34ddb
No related branches found
No related tags found
No related merge requests found
......@@ -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.02631092071533203s
INFO:cimpy.cimimport:Created totally 275 CIM objects in 0.022135496139526367s
......@@ -31,7 +31,7 @@ system.load_cim_data(res['topology'], base_apparent_power)
# Execute power flow analysis
results_pf, num_iter = nv_powerflow.solve(system)
a = export.PPexporter(system)
a = export.CIMtoDataFrame(system)
b = a.parseNode()
c = a.parseBranch()
d = a.createLoads()
......@@ -40,6 +40,8 @@ e = a.createGens()
f,g = a.makeConnectivity(b,c)
h = a.interpretConnectivity(g) #now we can make n-different connection matrix
q = a.makeOneDict()
# Print node voltages
print("Powerflow converged in " + str(num_iter) + " iterations.\n")
print("Results: \n")
......
......@@ -26,14 +26,35 @@ class Exporter():
return self.__class__.__name__
class PPexporter(Exporter):
class CIMtoDataFrame(Exporter):
def __init__(self, system):
self.node = system.nodes
self.branch = system.branches
self.Ymatrix = np.zeros([], dtype=complex)
def makeDataFrame(self, data):
pass
def makeOneDict(self):
"""
this function is all-in-one function that create nested dictonary of all functions below, so user can have one dictionary with all components
"""
node = self.parseNode()
branch = self.parseBranch()
loads = self.createLoads()
gens = self.createGens()
df_connectivity,matrix_connectivity = self.makeConnectivity(node,branch)
sub_connectivity = self.interpretConnectivity(matrix_connectivity) #now we can make n-different connection matrix
whole_thing = dict()
whole_thing['bus'] = node
whole_thing['branch'] = branch
whole_thing['load'] = loads
whole_thing['gen'] = gens
whole_thing['con']=dict()
whole_thing['con']['total_con'] = df_connectivity
whole_thing['con']['grp_con'] = sub_connectivity
return whole_thing
def parseNode(self):
......@@ -207,3 +228,9 @@ class PPexporter(Exporter):
sub_connectivity[k] = df_local
return sub_connectivity
class DataFrameToJson(Exporter):
def __init__(self, dataframe):
self.node = dataframe.nodes
self.branch = dataframe.branches
self.Ymatrix = np.zeros([], dtype=complex)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment