Commit e15940a0 authored by Jan Dinkelbach's avatar Jan Dinkelbach
Browse files

Merge branch 'updates-mpa' into development

parents 1372d438 18f81440
......@@ -95,7 +95,6 @@ class System():
self.branches = []
self.breakers = []
self.Ymatrix = np.zeros([], dtype=np.complex)
self.Adjacencies = np.array([])
def get_node_by_uuid(self, node_uuid):
for node in self.nodes:
......@@ -335,16 +334,16 @@ class System():
self.reindex_nodes_list()
nodes_num = self.get_nodes_num()
self.Ymatrix = np.zeros((nodes_num, nodes_num), dtype=np.complex)
self.Adjacencies = [[] for _ in range(nodes_num)]
self.Bmatrix = np.zeros((nodes_num, nodes_num), dtype=np.complex)
for branch in self.branches:
fr = branch.start_node.index
to = branch.end_node.index
self.Ymatrix[fr][to] -= branch.y_pu
self.Ymatrix[to][fr] -= branch.y_pu
self.Ymatrix[fr][fr] += branch.y_pu
self.Ymatrix[to][to] += branch.y_pu
self.Adjacencies[fr].append(to + 1) # to + 1???
self.Adjacencies[to].append(fr + 1) # fr + 1???
self.Ymatrix[fr][fr] += branch.y_pu # + branch.b_pu
self.Ymatrix[to][to] += branch.y_pu # + branch.b_pu
# self.Bmatrix[fr][to] += branch.b_pu
# self.Bmatrix[to][fr] += branch.b_pu
#Testing functions
def print_nodes_names(self):
......
......@@ -40,24 +40,14 @@ def solve(system):
H[m][i] = 1
H[m + 1][i2] = 1
elif node_type is BusType.PQ:
H[m][i] = - np.real(system.Ymatrix[i][i])
H[m][i2] = np.imag(system.Ymatrix[i][i])
H[m + 1][i] = - np.imag(system.Ymatrix[i][i])
H[m + 1][i2] = - np.real(system.Ymatrix[i][i])
idx1 = np.subtract(system.Adjacencies[i], 1)
idx2 = idx1 + nodes_num
H[m][idx1] = - np.real(system.Ymatrix[i][idx1])
H[m][idx2] = np.imag(system.Ymatrix[i][idx1])
H[m + 1][idx1] = - np.imag(system.Ymatrix[i][idx1])
H[m + 1][idx2] = - np.real(system.Ymatrix[i][idx1])
H[m][:nodes_num] = np.real(system.Ymatrix[i])
H[m][nodes_num:] = - np.imag(system.Ymatrix[i])
H[m+1][:nodes_num] = np.imag(system.Ymatrix[i])
H[m+1][nodes_num:] = np.real(system.Ymatrix[i])
elif node_type is BusType.PV:
z[m + 1] = np.real(node.power)
H[m][i] = - np.real(system.Ymatrix[i][i])
H[m][i2] = np.imag(system.Ymatrix[i][i])
idx1 = np.subtract(system.Adjacencies[i], 1)
idx2 = idx1 + nodes_num
H[m][idx1] = - np.real(system.Ymatrix[i][idx1])
H[m][idx2] = np.imag(system.Ymatrix[i][idx1])
H[m][:nodes_num] = np.real(system.Ymatrix[i])
H[m][nodes_num:] = - np.imag(system.Ymatrix[i])
epsilon = 10 ** (-10)
#epsilon = 0.01
......@@ -86,7 +76,7 @@ def solve(system):
h[m + 1] = np.inner(H[m + 1], state)
elif node_type is BusType.PV:
z[m] = (np.real(node.power_pu) * np.real(V[i]) +
np.imag(node.power_pu) * np.imag(V[i]))(np.abs(V[i]) ** 2)
np.imag(node.power_pu) * np.imag(V[i])) / (np.abs(V[i]) ** 2)
h[m] = np.inner(H[m], state)
h[m + 1] = np.abs(V[i])
H[m + 1][i] = np.cos(np.angle(V[i]))
......
This diff is collapsed.
......@@ -44,7 +44,7 @@ class Results():
self.nodes = []
self.branches = []
self.Ymatrix = system.Ymatrix
self.Adjacencies = system.Adjacencies
self.Bmatrix = system.Bmatrix
for node in system.nodes:
if node.ideal_connected_with == '':
self.nodes.append(ResultsNode(topo_node=node))
......@@ -106,7 +106,7 @@ class Results():
for branch in self.branches:
fr = branch.topology_branch.start_node.index
to = branch.topology_branch.end_node.index
branch.current_pu = - (self.nodes[fr].voltage_pu - self.nodes[to].voltage_pu) * self.Ymatrix[fr][to]
branch.current_pu = - (self.nodes[fr].voltage_pu - self.nodes[to].voltage_pu) * self.Ymatrix[fr][to] + 1j*self.Bmatrix[fr][to] * self.nodes[fr].voltage_pu
branch.current = branch.current_pu * branch.topology_branch.base_current
def calculateIinj(self):
......@@ -121,7 +121,7 @@ class Results():
fr = fr + branch.current_pu
if node.topology_node.index == branch.topology_branch.end_node.index:
to = to + branch.current_pu
node.current_pu = to - fr
node.current_pu = fr - to
node.current = node.current_pu * node.topology_node.base_current
def calculateSinj(self):
......
......@@ -26,7 +26,7 @@ for file in xml_files:
xml_files_abs.append(os.path.abspath(file))
# read cim files and create new network.Systen object
res, _ = cimpy.cim_import(xml_files_abs, "cgmes_v2_4_15")
res, _, _ = cimpy.cim_import(xml_files_abs, "cgmes_v2_4_15")
system = network.System()
base_apparent_power = 25 # MW
system.load_cim_data(res, base_apparent_power)
......@@ -40,7 +40,7 @@ V_unc = 0
I_unc = 0
Sinj_unc = 0
S_unc = 0
Pmu_mag_unc = 1
Pmu_mag_unc = 0
Pmu_phase_unc = 0
# Create measurements data structures
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment