|
|
@ -2,7 +2,6 @@ import numpy as np |
|
|
import matplotlib.pyplot as plt |
|
|
import matplotlib.pyplot as plt |
|
|
import PyQt5 as qt |
|
|
import PyQt5 as qt |
|
|
|
|
|
|
|
|
# Vn = 4e5 # En V |
|
|
|
|
|
|
|
|
|
|
|
def make_Y(n): |
|
|
def make_Y(n): |
|
|
Y = np.zeros((n, n)) |
|
|
Y = np.zeros((n, n)) |
|
|
@ -14,17 +13,6 @@ def connect_Y(x, y, Ys, Yp, Y): |
|
|
Y[x, x] += Ys + Yp |
|
|
Y[x, x] += Ys + Yp |
|
|
Y[y, y] += Ys + Yp |
|
|
Y[y, y] += Ys + Yp |
|
|
|
|
|
|
|
|
def system_matrix(n, Y, Vn): |
|
|
|
|
|
S = np.zeros((n, n)) |
|
|
|
|
|
for i in range(n): |
|
|
|
|
|
for k in range(n): |
|
|
|
|
|
if i == k: |
|
|
|
|
|
S[i, k] = n |
|
|
|
|
|
else: |
|
|
|
|
|
S[i, k] = -1 |
|
|
|
|
|
S[i, k] *= Vn**2 * Y[i, k] |
|
|
|
|
|
return S |
|
|
|
|
|
|
|
|
|
|
|
def line_coor(n): |
|
|
def line_coor(n): |
|
|
tab = [] |
|
|
tab = [] |
|
|
i = 0 |
|
|
i = 0 |
|
|
@ -39,8 +27,6 @@ def line_coor(n): |
|
|
|
|
|
|
|
|
return tab |
|
|
return tab |
|
|
|
|
|
|
|
|
print(line_coor(4)) |
|
|
|
|
|
|
|
|
|
|
|
def line_matrix(Y): |
|
|
def line_matrix(Y): |
|
|
n = len(Y) |
|
|
n = len(Y) |
|
|
t = line_coor(n) |
|
|
t = line_coor(n) |
|
|
@ -68,51 +54,110 @@ def complete_data(P, delta, i): |
|
|
nP = np.array(P[:i].tolist() + [-np.sum(P)] + P[i:].tolist()) |
|
|
nP = np.array(P[:i].tolist() + [-np.sum(P)] + P[i:].tolist()) |
|
|
return ndelta, nP |
|
|
return ndelta, nP |
|
|
|
|
|
|
|
|
# Vn |
|
|
def demo1(): |
|
|
Vn = 2e5 |
|
|
# Vn |
|
|
|
|
|
Vn = 2e5 |
|
|
# Vecteur des puissances |
|
|
|
|
|
P = np.array([1000, -500, -250, -250]) |
|
|
# Vecteur des puissances |
|
|
P = P * 1e6 # Passage en MW |
|
|
P = np.array([1000, -500, -250, -250]) |
|
|
|
|
|
P = P * 1e6 # Passage en MW |
|
|
# Création de la matrice d'admitances (dimension n) |
|
|
|
|
|
Y = make_Y(4) |
|
|
# Création de la matrice d'admitances (dimension n) |
|
|
connect_Y(2, 3, 0.1, 0, Y) |
|
|
Y = make_Y(4) |
|
|
connect_Y(1, 3, 0.15, 0, Y) |
|
|
connect_Y(2, 3, 0.1, 0, Y) |
|
|
connect_Y(2, 1, 0.05, 0, Y) |
|
|
connect_Y(1, 3, 0.15, 0, Y) |
|
|
connect_Y(2, 0, 0.05, 0, Y) |
|
|
connect_Y(2, 1, 0.05, 0, Y) |
|
|
connect_Y(3, 0, 0.05, 0, Y) |
|
|
connect_Y(2, 0, 0.05, 0, Y) |
|
|
print("Admittance matrix :", Y) |
|
|
connect_Y(3, 0, 0.05, 0, Y) |
|
|
|
|
|
print("Admittance matrix :", Y) |
|
|
# Mise en place du système linéaire à résoudre |
|
|
|
|
|
S = system_matrix(4, Y, Vn) # dim n |
|
|
# Mise en place du système linéaire à résoudre |
|
|
S = delta_select(3, S) # dim n-1, sélection de l'angle de transport de référence (delta_3) |
|
|
S = Y |
|
|
print("System matrix :", S) |
|
|
S = delta_select(3, S) # dim n-1, sélection de l'angle de transport de référence (delta_3) |
|
|
|
|
|
S *= Vn**2 |
|
|
# Sélection des puissances (dimension n-1) |
|
|
print("System matrix :", S) |
|
|
P = power_select(3, P) |
|
|
|
|
|
print("Power input : ", P) |
|
|
# Sélection des puissances (dimension n-1) |
|
|
|
|
|
P = power_select(3, P) |
|
|
# Résolution (dimension n-1) |
|
|
print("Power input : ", P) |
|
|
invS = np.linalg.inv(S) |
|
|
|
|
|
print("Inverse : ", invS) |
|
|
# Résolution (dimension n-1) |
|
|
|
|
|
invS = np.linalg.inv(S) |
|
|
# Calcul des angles de transport (dimension n-1) |
|
|
print("Inverse : ", invS) |
|
|
delta = np.dot(invS, P) |
|
|
|
|
|
|
|
|
# Calcul des angles de transport (dimension n-1) |
|
|
# Ajout de l'angle de transport d'origine et de la puissance associée (on repasse en dim n) |
|
|
delta = np.dot(invS, P) |
|
|
ndelta, nP = complete_data(P, delta, 3) |
|
|
|
|
|
print("Power :", nP) |
|
|
# Ajout de l'angle de transport d'origine et de la puissance associée (on repasse en dim n) |
|
|
print("Delta (rad) :", ndelta * 180 / 3.1415) |
|
|
ndelta, nP = complete_data(P, delta, 3) |
|
|
|
|
|
print("Power :", nP) |
|
|
# Calcul de la matrice de ligne |
|
|
print("Delta (deg) :", ndelta * 180 / 3.1415) |
|
|
lS = line_matrix(Y) |
|
|
|
|
|
print("Line matrix : ", lS) |
|
|
# Calcul de la matrice de ligne |
|
|
|
|
|
lS = line_matrix(Y) |
|
|
# Calcul des puissances de lignes |
|
|
print("Line matrix : ", lS) |
|
|
line_power = Vn**2 * np.dot(lS, ndelta) |
|
|
|
|
|
lcoor = line_coor(len(ndelta)) |
|
|
# Calcul des puissances de lignes |
|
|
disp_line = [] |
|
|
line_power = Vn**2 * np.dot(lS, ndelta) |
|
|
for i in range(len(line_power)): |
|
|
lcoor = line_coor(len(ndelta)) |
|
|
|
|
|
disp_line = [] |
|
|
|
|
|
for i in range(len(line_power)): |
|
|
disp_line += [lcoor[i] + [line_power[i]]] |
|
|
disp_line += [lcoor[i] + [line_power[i]]] |
|
|
print("Line power : ", disp_line) |
|
|
print("Line power : ", disp_line) |
|
|
|
|
|
|
|
|
|
|
|
def demo2(): |
|
|
|
|
|
# Vn |
|
|
|
|
|
Vn = 4e5 |
|
|
|
|
|
|
|
|
|
|
|
# Donnée de dimension |
|
|
|
|
|
Dim = 3 |
|
|
|
|
|
NodeRef = 2 |
|
|
|
|
|
|
|
|
|
|
|
# Vecteur des puissances |
|
|
|
|
|
P = np.array([500, 500, -1000]) |
|
|
|
|
|
P = P * 1e6 # Passage en MW |
|
|
|
|
|
|
|
|
|
|
|
# Création de la matrice d'admitances (dimension n) |
|
|
|
|
|
Y = make_Y(Dim) |
|
|
|
|
|
connect_Y(0, 1, 25e-3, 0, Y) |
|
|
|
|
|
connect_Y(0, 2, 20e-3, 0, Y) |
|
|
|
|
|
connect_Y(1, 2, 50e-3, 0, Y) |
|
|
|
|
|
print("Admittance matrix : \n", Y) |
|
|
|
|
|
|
|
|
|
|
|
# Mise en place du système linéaire à résoudre |
|
|
|
|
|
S = Y # dim n |
|
|
|
|
|
S = delta_select(NodeRef, S) # dim n-1, sélection de l'angle de transport de référence (delta_3) |
|
|
|
|
|
S *= Vn**2 |
|
|
|
|
|
print("System matrix : \n", S) |
|
|
|
|
|
|
|
|
|
|
|
# Sélection des puissances (dimension n-1) |
|
|
|
|
|
P = power_select(NodeRef, P) |
|
|
|
|
|
print("Power input : \n", P) |
|
|
|
|
|
|
|
|
|
|
|
# Résolution (dimension n-1) |
|
|
|
|
|
invS = np.linalg.inv(S) |
|
|
|
|
|
print("Inverse : \n", invS) |
|
|
|
|
|
|
|
|
|
|
|
# Calcul des angles de transport (dimension n-1) |
|
|
|
|
|
delta = np.dot(invS, P) |
|
|
|
|
|
|
|
|
|
|
|
# Ajout de l'angle de transport d'origine et de la puissance associée (on repasse en dim n) |
|
|
|
|
|
ndelta, nP = complete_data(P, delta, NodeRef) |
|
|
|
|
|
print("Power : \n", nP) |
|
|
|
|
|
print("Delta (deg) : \n", ndelta * 180 / 3.1415) |
|
|
|
|
|
|
|
|
|
|
|
# Calcul de la matrice de ligne |
|
|
|
|
|
lS = line_matrix(Y) |
|
|
|
|
|
print("Line matrix : \n", lS) |
|
|
|
|
|
|
|
|
|
|
|
# Calcul des puissances de lignes |
|
|
|
|
|
line_power = Vn**2 * np.dot(lS, ndelta) |
|
|
|
|
|
lcoor = line_coor(len(ndelta)) |
|
|
|
|
|
disp_line = [] |
|
|
|
|
|
for i in range(len(line_power)): |
|
|
|
|
|
disp_line += [lcoor[i] + [int(line_power[i] * 1e-6)]] |
|
|
|
|
|
print("Line power : \n", disp_line) |
|
|
|
|
|
|
|
|
|
|
|
if __name__=="__main__": |
|
|
|
|
|
# Exemple du cours |
|
|
|
|
|
demo2() |