forked from alchemyst/Skogestad-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTESTING.py
36 lines (27 loc) · 1.05 KB
/
TESTING.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import numpy as np
import scipy as sc
import matplotlib.pyplot as plt
import itertools as itr
w = np.logspace(-5, 3, 1000)
s = 1j*w
def G(s):
# the matrix transfer function
G = [[0.001*np.exp(-5*s)*(-34.54*(s+0.0572))/((s+1.72E-04)*(4.32*s+1)),
0.001*np.exp(-5*s)*(1.913)/((s+1.72E-04)*(4.32*s+1))],
[0.001*np.exp(-5*s)*(-32.22*s)/((s+1.72E-04)*(4.32*s+1)),
0.001*np.exp(-5*s)*(-9.188*(s+6.95E-04))/((s+1.72E-04)*(4.32*s+1))]]
return G
freqresp = map(G, s)
sigmas = np.array([Sigma for U, Sigma, V in map(np.linalg.svd, freqresp)])
#maximum input and output vectors
Umax = np.array([U[:, 0] for U, sigma, V in map(np.linalg.svd, freqresp)])
Vmax = np.array([V[:, 0] for U, sigma, V in map(np.linalg.svd, freqresp)])
#minimum input and output vectors
Umin = np.array([U[:, -1] for U, sigma, V in map(np.linalg.svd, freqresp)])
Vmin = np.array([V[:, -1] for U, sigma, V in map(np.linalg.svd, freqresp)])
def Sing(w_s):
s = 1j*w_s
return np.max(np.linalg.svd(G(s))[1])-1
sc.optimize.fsolve(Sing, 0.1)
plt.loglog(w, sigmas)
plt.show()