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

extract Capacitance value directly from Y-matrix of System to have proper power flow value

parent 63b39725
Branches
No related tags found
No related merge requests found
......@@ -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.02181220054626465s
INFO:cimpy.cimimport:Created totally 275 CIM objects in 0.0252532958984375s
WARNING:pandapower.auxiliary:numba cannot be imported and numba functions are disabled.
......
......@@ -34,6 +34,7 @@ class CIMtoDataFrame(Exporter):
self.node = system.nodes
self.branch = system.branches
self.Ymatrix = np.zeros([], dtype=complex)
self.system = system
def makeOneDict(self, save=False):
"""
......@@ -43,6 +44,7 @@ class CIMtoDataFrame(Exporter):
branch = self.parseBranch()
loads = self.createLoads()
gens = self.createGens()
cap = self.get_branch_capacitance()
df_connectivity,matrix_connectivity = self.makeConnectivity(node,branch)
sub_connectivity = self.interpretConnectivity(matrix_connectivity) #now we can make n-different connection matrix
......@@ -57,6 +59,8 @@ class CIMtoDataFrame(Exporter):
whole_thing['con']['total_con'] = df_connectivity
whole_thing['con']['grp_con'] = sub_connectivity
whole_thing['etc']=dict()
whole_thing['etc']['capacitance'] =cap
#ToDo Not working!!!!!!
if save == True:
with open('dict_grid.json', 'w') as f:
......@@ -98,7 +102,7 @@ class CIMtoDataFrame(Exporter):
"""
this function create dataframe of Branch
"""
df = pd.DataFrame(columns=["idx", "start_node", "end_node", "r","r_pu","x","x_pu","y","y_pu","z","z_pu", "base_voltage","base_apparent_power","base_current","base_impedance","uuid"])
df = pd.DataFrame(columns=["idx", "start_node", "end_node", "r","r_pu","x","x_pu","y","y_pu","z","z_pu","c","base_voltage","base_apparent_power","base_current","base_impedance","uuid"])
for k, branch in enumerate(self.branch):
baseVoltage = branch.baseVoltage#
base_apparent_power = branch.base_apparent_power#
......@@ -121,8 +125,11 @@ class CIMtoDataFrame(Exporter):
end_node_index = end_node.index #
index = k #
cap = self.get_branch_capacitance()
cap=cap[k]
df.loc[k]=[
int(index), int(start_node_index), int(end_node_index), r, r_pu, x, x_pu, y, y_pu, z, z_pu, baseVoltage, base_apparent_power, base_current, base_impedance, uuid
int(index), int(start_node_index), int(end_node_index), r, r_pu, x, x_pu, y, y_pu, z, z_pu, cap, baseVoltage, base_apparent_power, base_current, base_impedance, uuid
]
return df
......@@ -280,6 +287,26 @@ class CIMtoDataFrame(Exporter):
sub_connectivity[k] = df_local
return sub_connectivity
def get_branch_capacitance(self, frequency=50):
sys = self.system
y_mat = sys.Ymatrix
w = 2 * np.pi * frequency
cap = {}
idx = 0
for branch in self.branch:
fr = branch.start_node.index
to = branch.end_node.index
y_branch = -y_mat[fr,to]
c = np.imag(y_branch)/w
cap[idx]=c
idx +=1
return cap
class DataFrameToJson(Exporter):
......@@ -470,8 +497,8 @@ class PandapowerWork(Exporter):
elif bus_type == 2: #generation
# static generator with the absolute values.
pp.create_sgen(net, bus_id,
p_mw=abs(p_kw) / 1000.0,
q_mvar=abs(q_kvar) / 1000.0,
p_mw=abs(p_kw) / 1000,
q_mvar=abs(q_kvar) / 1000,
name=f"sgen_{bus['name']}")
......@@ -495,8 +522,13 @@ class PandapowerWork(Exporter):
# getting R,X,Z value
length = branch["lengthkm"]
r_total = branch["resistancePu"] * (V_nom ** 2) / mva_base
x_total = branch["reactancePu"] * (V_nom ** 2) / mva_base
#this is right one, but for now with current json structure, this is wrong.
# r_total = branch["resistancePu"] * (V_nom ** 2) / mva_base
# x_total = branch["reactancePu"] * (V_nom ** 2) / mva_base
#so we use this one, which use q['branch]['base_power'] = 25
r_total = branch["resistancePu"] * (V_nom ** 2) / 25
x_total = branch["reactancePu"] * (V_nom ** 2) / 25
r_ohm_per_km = r_total / length
x_ohm_per_km = x_total / length
......@@ -510,11 +542,13 @@ class PandapowerWork(Exporter):
# c_nf_per_km (line capacitance in nF/km). To convert a PU susceptance to an nF/km value,
# you would need additional parameters (e.g. frequency) and conversion factors.
# For simplicity, we set it to 0 (if you need to account for shunt capacitance, adjust accordingly).
w = 2* np.pi *50
capacity = -1/ (w*abs(x_total))
line_id = pp.create_line_from_parameters(net, bus_from, bus_to, length_km=length,
r_ohm_per_km=r_ohm_per_km,
x_ohm_per_km=x_ohm_per_km,
c_nf_per_km=0.0, # adjust if needed
c_nf_per_km=capacity*(10**6)*10, # adjust if needed
max_i_ka=max_i_ka,
name=f"line_{branch['index']}")
......
......@@ -76,50 +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.041670799255371094s
INFO:cimpy.cimimport:Created totally 275 CIM objects in 0.03760051727294922s
WARNING:pandapower.auxiliary:numba cannot be imported and numba functions are disabled.
Probably the execution is slow.
Please install numba to gain a massive speedup.
(or if you prefer slow execution, set the flag numba=False to avoid this warning!)
WARNING:pandapower.auxiliary:numba cannot be imported and numba functions are disabled.
Probably the execution is slow.
Please install numba to gain a massive speedup.
(or if you prefer slow execution, set the flag numba=False to avoid this warning!)
WARNING:pandapower.auxiliary:numba cannot be imported and numba functions are disabled.
Probably the execution is slow.
Please install numba to gain a massive speedup.
(or if you prefer slow execution, set the flag numba=False to avoid this warning!)
WARNING:pandapower.auxiliary:numba cannot be imported and numba functions are disabled.
Probably the execution is slow.
Please install numba to gain a massive speedup.
(or if you prefer slow execution, set the flag numba=False to avoid this warning!)
WARNING:pandapower.auxiliary:numba cannot be imported and numba functions are disabled.
Probably the execution is slow.
Please install numba to gain a massive speedup.
(or if you prefer slow execution, set the flag numba=False to avoid this warning!)
WARNING:pandapower.auxiliary:numba cannot be imported and numba functions are disabled.
Probably the execution is slow.
Please install numba to gain a massive speedup.
(or if you prefer slow execution, set the flag numba=False to avoid this warning!)
WARNING:pandapower.auxiliary:numba cannot be imported and numba functions are disabled.
Probably the execution is slow.
Please install numba to gain a massive speedup.
(or if you prefer slow execution, set the flag numba=False to avoid this warning!)
WARNING:pandapower.auxiliary:numba cannot be imported and numba functions are disabled.
Probably the execution is slow.
Please install numba to gain a massive speedup.
(or if you prefer slow execution, set the flag numba=False to avoid this warning!)
WARNING:pandapower.auxiliary:numba cannot be imported and numba functions are disabled.
Probably the execution is slow.
Please install numba to gain a massive speedup.
(or if you prefer slow execution, set the flag numba=False to avoid this warning!)
WARNING:pandapower.auxiliary:numba cannot be imported and numba functions are disabled.
Probably the execution is slow.
Please install numba to gain a massive speedup.
(or if you prefer slow execution, set the flag numba=False to avoid this warning!)
WARNING:pandapower.auxiliary:numba cannot be imported and numba functions are disabled.
Probably the execution is slow.
Please install numba to gain a massive speedup.
(or if you prefer slow execution, set the flag numba=False to avoid this warning!)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment