diff --git a/opti_continu.py b/opti_continu.py new file mode 100644 index 0000000..ebbf694 --- /dev/null +++ b/opti_continu.py @@ -0,0 +1,53 @@ +import numpy as np +import matplotlib.pyplot as plt +import PyQt5 as qt + +# Vn = 4e5 # En V + +def make_Y(n): + Y = np.zeros((n, n)) + return Y + +def connect_Y(x, y, Ys, Yp, Y): + Y[x, y] = -Ys + Y[y, x] = -Ys + Y[x, x] += Ys + Yp + Y[y, y] += Ys + Yp + +def spec(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 delta_select(i, S): + for k in range(len(S)): + S[i, k] = 0 + + +Y = make_Y(4) +connect_Y(2, 3, 0.1, 0, Y) +connect_Y(1, 3, 0.15, 0, Y) +connect_Y(2, 1, 0.05, 0, Y) +connect_Y(2, 0, 0.05, 0, Y) +connect_Y(3, 0, 0.05, 0, Y) +print("Admittance matrix :") +print(Y) +S = spec(4, Y, 2e5) +print("System matrix :") +print(S) +invS = np.linalg.inv(S) +print(invS) +P = np.array([1000, -500, -250, -250]) +P = P * 1e6 +print("Power input :") +print(P) +delta = np.dot(invS, P) +print("Delta (rad) :") +print(delta) +print(delta * 180 / 3.1415) \ No newline at end of file diff --git a/opti_prod.py b/opti_prod.py index 8a84dba..f51ab0a 100644 --- a/opti_prod.py +++ b/opti_prod.py @@ -79,6 +79,7 @@ def minimize(f, x0, h=1e-4, step=1e-1, tol=1e-8, N=1e4, echo=False): return x def custom_minimize(f, x0, echo=False): + # Fonction avec plusieurs étapes successives de résolution, pour gagner en précision et éviter de diverger res_app = minimize(f, x0, step=5e-1) if echo: print(res_app)