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

refactoring varnames

parent 50a3693b
......@@ -46,8 +46,8 @@ def solve(system):
V = np.ones(nodes_num) + 1j* np.zeros(nodes_num)
num_iter = 0
State = np.ones(2*branches_num)
State = np.concatenate((np.array([1,0]),State),axis=0)
state = np.ones(2*branches_num)
state = np.concatenate((np.array([1,0]),state),axis=0)
while diff > epsilon:
for i in range(0, nodes_num):
......@@ -55,27 +55,27 @@ def solve(system):
i2 = i + nodes_num
node_type = system.nodes[i].type
if node_type is BusType.SLACK:
h[m] = np.inner(H[m],State)
h[m+1] = np.inner(H[m+1],State)
h[m] = np.inner(H[m],state)
h[m+1] = np.inner(H[m+1],state)
elif node_type is BusType.PQ:
z[m] = (np.real(system.nodes[i].power_pu)*np.real(V[i]) + np.imag(system.nodes[i].power_pu)*np.imag(V[i]))/(np.abs(V[i])**2)
z[m+1] = (np.real(system.nodes[i].power_pu)*np.imag(V[i]) - np.imag(system.nodes[i].power_pu)*np.real(V[i]))/(np.abs(V[i])**2)
h[m] = np.inner(H[m],State)
h[m+1] = np.inner(H[m+1],State)
h[m] = np.inner(H[m],state)
h[m+1] = np.inner(H[m+1],state)
elif node_type is BusType.PV:
z[m] = (np.real(system.nodes[i].power_pu)*np.real(V[i])+ np.imag(system.nodes[i].power_pu)*np.imag(V[i]))(np.abs(V[i])**2)
h[m] = np.inner(H[m],State)
h[m] = np.inner(H[m],state)
h[m+1] = np.abs(V[i])
H[m+1][i] = np.cos(np.angle(V[i]))
H[m+1][i2] = np.sin(np.angle(V[i]))
r = np.subtract(z,h)
Hinv = np.linalg.inv(H)
Delta_State = np.inner(Hinv,r)
State = State + Delta_State
diff = np.amax(np.absolute(Delta_State))
delta_state = np.inner(Hinv,r)
state = state + delta_state
diff = np.amax(np.absolute(delta_state))
V = State[:nodes_num] + 1j * State[nodes_num:]
V = state[:nodes_num] + 1j * state[nodes_num:]
num_iter = num_iter+1
# calculate all the other quantities of the grid
......
Supports Markdown
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